From 9bd4d95eba23852689e84b1367249d60b8134e03 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 24 Sep 2024 20:03:07 -0700 Subject: [PATCH] [ios] name tweak - they are "insets" not "inset" (#265) --- .../FerrostarMapLibreUI/Extensions/View.swift | 30 +++++++++---------- .../DynamicallyOrientingNavigationView.swift | 4 +-- .../Views/LandscapeNavigationView.swift | 2 +- .../Views/PortraitNavigationView.swift | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apple/Sources/FerrostarMapLibreUI/Extensions/View.swift b/apple/Sources/FerrostarMapLibreUI/Extensions/View.swift index 6f9dc0c0..37b518e1 100644 --- a/apple/Sources/FerrostarMapLibreUI/Extensions/View.swift +++ b/apple/Sources/FerrostarMapLibreUI/Extensions/View.swift @@ -1,11 +1,11 @@ import SwiftUI extension View { - /// Given the view's `geometry`, synchronizes `childInsets`, such that - /// accumulating the child's insets with the parents insets, will be at least `minimumInset`. + /// Given the parent view's `geometry`, synchronizes this views `safeAreaInsets`, such that + /// accumulating this view's insets with the parents insets, will be at least `minimumInset`. /// /// ``` - /// Given a minimumInset of 16: + /// Given minimumInsets of 16: /// +-------------------------------------------------------------+ /// | `parentGeometry` | /// | +-----------------------------------------------------+ | @@ -26,9 +26,9 @@ extension View { /// ``` func complementSafeAreaInsets( parentGeometry: GeometryProxy, - minimumInset: EdgeInsets = EdgeInsets(top: 16, leading: 16, bottom: 16, trailing: 16) + minimumInsets: EdgeInsets = EdgeInsets(top: 16, leading: 16, bottom: 16, trailing: 16) ) -> some View { - ComplementingSafeAreaView(content: self, parentGeometry: parentGeometry, minimumInset: minimumInset) + ComplementingSafeAreaView(content: self, parentGeometry: parentGeometry, minimumInsets: minimumInsets) } /// Do something reasonable-ish for clients that don't yet support @@ -46,28 +46,28 @@ struct ComplementingSafeAreaView: View { var content: V var parentGeometry: GeometryProxy - var minimumInset: EdgeInsets + var minimumInsets: EdgeInsets @State var childInsets: EdgeInsets = .init() - static func complement(parentInset: EdgeInsets, minimumInset: EdgeInsets) -> EdgeInsets { - var innerInsets = parentInset - innerInsets.top = max(0, minimumInset.top - parentInset.top) - innerInsets.bottom = max(0, minimumInset.bottom - parentInset.bottom) - innerInsets.leading = max(0, minimumInset.leading - parentInset.leading) - innerInsets.trailing = max(0, minimumInset.trailing - parentInset.trailing) + static func complement(parentInsets: EdgeInsets, minimumInsets: EdgeInsets) -> EdgeInsets { + var innerInsets = parentInsets + innerInsets.top = max(0, minimumInsets.top - parentInsets.top) + innerInsets.bottom = max(0, minimumInsets.bottom - parentInsets.bottom) + innerInsets.leading = max(0, minimumInsets.leading - parentInsets.leading) + innerInsets.trailing = max(0, minimumInsets.trailing - parentInsets.trailing) return innerInsets } var body: some View { content.onAppear { childInsets = ComplementingSafeAreaView.complement( - parentInset: parentGeometry.safeAreaInsets, - minimumInset: minimumInset + parentInsets: parentGeometry.safeAreaInsets, + minimumInsets: minimumInsets ) }.onChange(of: parentGeometry.safeAreaInsets) { newValue in - childInsets = ComplementingSafeAreaView.complement(parentInset: newValue, minimumInset: minimumInset) + childInsets = ComplementingSafeAreaView.complement(parentInsets: newValue, minimumInsets: minimumInsets) }.safeAreaPaddingPolyfill(childInsets) } } diff --git a/apple/Sources/FerrostarMapLibreUI/Views/DynamicallyOrientingNavigationView.swift b/apple/Sources/FerrostarMapLibreUI/Views/DynamicallyOrientingNavigationView.swift index ac7c28ee..6a62ec1a 100644 --- a/apple/Sources/FerrostarMapLibreUI/Views/DynamicallyOrientingNavigationView.swift +++ b/apple/Sources/FerrostarMapLibreUI/Views/DynamicallyOrientingNavigationView.swift @@ -99,7 +99,7 @@ public struct DynamicallyOrientingNavigationView: View, CustomizableNavigatingIn midLeading?() } bottomTrailing: { bottomTrailing?() - }.complementSafeAreaInsets(parentGeometry: geometry, minimumInset: minimumSafeAreaInsets) + }.complementSafeAreaInsets(parentGeometry: geometry, minimumInsets: minimumSafeAreaInsets) default: PortraitNavigationOverlayView( navigationState: navigationState, @@ -119,7 +119,7 @@ public struct DynamicallyOrientingNavigationView: View, CustomizableNavigatingIn midLeading?() } bottomTrailing: { bottomTrailing?() - }.complementSafeAreaInsets(parentGeometry: geometry, minimumInset: minimumSafeAreaInsets) + }.complementSafeAreaInsets(parentGeometry: geometry, minimumInsets: minimumSafeAreaInsets) } } } diff --git a/apple/Sources/FerrostarMapLibreUI/Views/LandscapeNavigationView.swift b/apple/Sources/FerrostarMapLibreUI/Views/LandscapeNavigationView.swift index 302c3159..0320ed44 100644 --- a/apple/Sources/FerrostarMapLibreUI/Views/LandscapeNavigationView.swift +++ b/apple/Sources/FerrostarMapLibreUI/Views/LandscapeNavigationView.swift @@ -93,7 +93,7 @@ public struct LandscapeNavigationView: View, CustomizableNavigatingInnerGridView midLeading?() } bottomTrailing: { bottomTrailing?() - }.complementSafeAreaInsets(parentGeometry: geometry, minimumInset: minimumSafeAreaInsets) + }.complementSafeAreaInsets(parentGeometry: geometry, minimumInsets: minimumSafeAreaInsets) } } } diff --git a/apple/Sources/FerrostarMapLibreUI/Views/PortraitNavigationView.swift b/apple/Sources/FerrostarMapLibreUI/Views/PortraitNavigationView.swift index a74dbdf6..7b2e26ae 100644 --- a/apple/Sources/FerrostarMapLibreUI/Views/PortraitNavigationView.swift +++ b/apple/Sources/FerrostarMapLibreUI/Views/PortraitNavigationView.swift @@ -95,7 +95,7 @@ public struct PortraitNavigationView: View, CustomizableNavigatingInnerGridView midLeading?() } bottomTrailing: { bottomTrailing?() - }.complementSafeAreaInsets(parentGeometry: geometry, minimumInset: minimumSafeAreaInsets) + }.complementSafeAreaInsets(parentGeometry: geometry, minimumInsets: minimumSafeAreaInsets) } } }