diff --git a/Airship/AirshipCore/Source/EmbeddedView.swift b/Airship/AirshipCore/Source/EmbeddedView.swift index 8ba159b8b..10efda9e3 100644 --- a/Airship/AirshipCore/Source/EmbeddedView.swift +++ b/Airship/AirshipCore/Source/EmbeddedView.swift @@ -30,6 +30,30 @@ struct AdoptLayout: SwiftUI.Layout { /// proposal.replacingUnspecifiedDimensions() uses `10`, so we shall as well let size = CGSize(width: width ?? 10, height: height ?? 10) + + let constraintWidth: CGFloat? = if placement.size.width.isAuto { + nil + } else { + size.width + } + + let constraintHeight: CGFloat? = if placement.size.height.isAuto { + nil + } else { + size.height + } + + let viewConstraints = ViewConstraints( + width: constraintWidth, + height: constraintHeight + ) + + DispatchQueue.main.async { + if (self.viewConstraints != viewConstraints) { + self.viewConstraints = viewConstraints + } + } + return size } @@ -48,16 +72,6 @@ struct AdoptLayout: SwiftUI.Layout { } func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) { - - let constraints = ViewConstraints( - width: embeddedSize?.parentWidth ?? bounds.width, - height: embeddedSize?.parentHeight ?? bounds.height - ) - - DispatchQueue.main.async { - viewConstraints = constraints - } - let viewProposal = ProposedViewSize( width: size( constraint: placement.size.width, @@ -107,25 +121,25 @@ struct EmbeddedView: View { height: placement.size.height.calculateSize(self.embeddedSize?.parentHeight) ) - createView(constraints: constraints, placement: placement) + let contentConstraints = constraints.contentConstraints( + placement.size, + contentSize: nil, + margin: placement.margin + ) + + createView(constraints: contentConstraints, placement: placement) } } } @MainActor private func createView(constraints: ViewConstraints, placement: EmbeddedPlacement) -> some View { - let contentConstraints = constraints.contentConstraints( - placement.size, - contentSize: nil, - margin: placement.margin - ) - return ViewFactory - .createView(model: layout.view, constraints: contentConstraints) + .createView(model: layout.view, constraints: constraints) .background(placement.backgroundColor) .border(placement.border) .margin(placement.margin) - .constraints(contentConstraints) + .constraints(constraints) } private func resolvePlacement(orientation: Orientation, windowSize: WindowSize) -> EmbeddedPlacement { diff --git a/Airship/AirshipCore/Source/Pager.swift b/Airship/AirshipCore/Source/Pager.swift index 9c4226a2d..a11d026bd 100644 --- a/Airship/AirshipCore/Source/Pager.swift +++ b/Airship/AirshipCore/Source/Pager.swift @@ -339,8 +339,6 @@ struct Pager: View { } private func handleTouch(isPressed: Bool, index: Binding) { - print("isPressed: \(isPressed)") - self.model.retrieveGestures(type: PagerHoldGesture.self).forEach { gesture in let behavior = isPressed ? gesture.pressBehavior : gesture.releaseBehavior handleGestureBehavior( diff --git a/Airship/AirshipCore/Source/TouchViewModifier.swift b/Airship/AirshipCore/Source/TouchViewModifier.swift index d835607d9..019b2760f 100644 --- a/Airship/AirshipCore/Source/TouchViewModifier.swift +++ b/Airship/AirshipCore/Source/TouchViewModifier.swift @@ -14,7 +14,7 @@ fileprivate struct TouchViewModifier: ViewModifier { TapGesture() ) .gesture( - LongPressGesture(minimumDuration: 0.0) + LongPressGesture(minimumDuration: 0.1) .sequenced(before: LongPressGesture(minimumDuration: .infinity)) .updating($isPressed) { value, state, transaction in switch value { diff --git a/Airship/AirshipCore/Source/ViewConstraints.swift b/Airship/AirshipCore/Source/ViewConstraints.swift index b15c1d9db..7afc1a58b 100644 --- a/Airship/AirshipCore/Source/ViewConstraints.swift +++ b/Airship/AirshipCore/Source/ViewConstraints.swift @@ -95,7 +95,7 @@ struct ViewConstraints: Equatable { parentHeight ) - childHeight = childHeight? .bound( + childHeight = childHeight?.bound( minValue: childMinHeight, maxValue: childMaxHeight ) diff --git a/Thomas/Thomas/EmbeddedView/HomeView23Grande.swift b/Thomas/Thomas/EmbeddedView/HomeView23Grande.swift index 3021b12be..1d7de6b7f 100644 --- a/Thomas/Thomas/EmbeddedView/HomeView23Grande.swift +++ b/Thomas/Thomas/EmbeddedView/HomeView23Grande.swift @@ -21,34 +21,43 @@ struct HomeView23Grande: View { .frame(maxWidth: .infinity) .background(Color.white) - ScrollView(showsIndicators: false) { + GeometryReader { scrollViewSize in + ScrollView(showsIndicators: false) { - AirshipEmbeddedView(embeddedID: "home_image") - .setAirshipEmbeddedStyle(DismissableStyle()) + AirshipEmbeddedView( + embeddedID: "home_image", + embeddedSize: AirshipEmbeddedSize( + parentHeight: scrollViewSize.size.height + ) + ) - Spacer(minLength: 30) + .setAirshipEmbeddedStyle(DismissableStyle()) - VStack(spacing:0) { - FashionMenu(tabIndex: $tabIndex) - Separation() - FashionImages(tabIndex: $tabIndex) - .frame(height: max(300.0, geo.size.height * 0.50)) - } - Text("NEW ARRIVALS") - .fontWeight(.bold) - .multilineTextAlignment(.center) - - ScrollView(.horizontal, showsIndicators: false) { - HStack(spacing:10) { - Spacer() - Image("23GrandeArrival1") - .resize(width: geo.size.width * 0.40) - Image("23GrandeArrival2") - .resize(width: geo.size.width * 0.40) - Spacer() + Spacer(minLength: 30) + + VStack(spacing:0) { + FashionMenu(tabIndex: $tabIndex) + Separation() + FashionImages(tabIndex: $tabIndex) + .frame(height: max(300.0, geo.size.height * 0.50)) + } + + Text("NEW ARRIVALS") + .fontWeight(.bold) + .multilineTextAlignment(.center) + + ScrollView(.horizontal, showsIndicators: false) { + HStack(spacing:10) { + Spacer() + Image("23GrandeArrival1") + .resize(width: geo.size.width * 0.40) + Image("23GrandeArrival2") + .resize(width: geo.size.width * 0.40) + Spacer() + } } } } diff --git a/Thomas/Thomas/Resources/Scenes/Embedded/home_image.yml b/Thomas/Thomas/Resources/Scenes/Embedded/home_image.yml index be9f6aafa..fd37c0756 100644 --- a/Thomas/Thomas/Resources/Scenes/Embedded/home_image.yml +++ b/Thomas/Thomas/Resources/Scenes/Embedded/home_image.yml @@ -7,7 +7,13 @@ presentation: size: width: 100% height: auto + margin: + start: 16 + end: 16 + top: 16 + bottom: 16 embedded_id: home_image + view: type: pager_controller identifier: cd21507b-c0b1-4094-9cc6-a1c7e0713c82