Skip to content

Commit 9aaf033

Browse files
committed
Address #783
1 parent 9ee99d0 commit 9aaf033

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed

Diff for: Examples/Examples/FloorFilterExampleView.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ struct FloorFilterExampleView: View {
7676
maxWidth: 400,
7777
maxHeight: 400
7878
)
79-
.padding([.horizontal], 10)
80-
.padding([.vertical], 10 + attributionBarHeight)
79+
.padding([.bottom, .leading])
80+
.padding(.bottom, attributionBarHeight)
8181
} else if mapLoadError {
8282
Label(
8383
"Map load error!",

Diff for: Sources/ArcGISToolkit/Components/FloorFilter/FloorFilter.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public struct FloorFilter: View {
101101
@StateObject private var viewModel: FloorFilterViewModel
102102

103103
/// A Boolean value that indicates whether the site and facility selector is presented.
104-
@State private var isSitesAndFacilitiesHidden = true
104+
@State private var sitesAndFacilitiesArePresented = false
105105

106106
/// The selected site, floor, or level.
107107
private var selection: Binding<FloorFilterSelection?>?
@@ -119,7 +119,7 @@ public struct FloorFilter: View {
119119
/// Button to open and close the site and facility selector.
120120
private var sitesAndFacilitiesButton: some View {
121121
Button {
122-
isSitesAndFacilitiesHidden.toggle()
122+
sitesAndFacilitiesArePresented.toggle()
123123
} label: {
124124
Image(systemName: "building.2")
125125
.padding(.toolkitDefault)
@@ -133,7 +133,7 @@ public struct FloorFilter: View {
133133
}
134134
}
135135

136-
/// A view that displays the level selector and the sites and facilites button.
136+
/// A view that displays the level selector and the sites and facilities button.
137137
private var levelSelectorContainer: some View {
138138
VStack {
139139
if isTopAligned {
@@ -185,18 +185,18 @@ public struct FloorFilter: View {
185185
@ViewBuilder private var siteAndFacilitySelector: some View {
186186
if horizontalSizeClass == .compact {
187187
Color.clear
188-
.sheet(isPresented: .constant(!$isSitesAndFacilitiesHidden.wrappedValue)) {
189-
SiteAndFacilitySelector(isHidden: $isSitesAndFacilitiesHidden)
188+
.sheet(isPresented: $sitesAndFacilitiesArePresented) {
189+
SiteAndFacilitySelector(isPresented: $sitesAndFacilitiesArePresented)
190190
}
191191
} else {
192192
ZStack {
193193
Color.clear
194194
.esriBorder()
195-
SiteAndFacilitySelector(isHidden: $isSitesAndFacilitiesHidden)
195+
SiteAndFacilitySelector(isPresented: $sitesAndFacilitiesArePresented)
196196
.padding([.top, .leading, .trailing], 2.5)
197197
.padding(.bottom)
198198
}
199-
.opacity(isSitesAndFacilitiesHidden ? .zero : 1)
199+
.opacity(sitesAndFacilitiesArePresented ? 1 : .zero)
200200
}
201201
}
202202

Diff for: Sources/ArcGISToolkit/Components/FloorFilter/SiteAndFacilitySelector.swift

+11-17
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,33 @@ import SwiftUI
1818
/// A view which allows selection of sites and facilities represented in a `FloorManager`.
1919
@MainActor
2020
struct SiteAndFacilitySelector: View {
21-
/// Creates a `SiteAndFacilitySelector`.
22-
/// - Parameter isHidden: A binding used to dismiss the site selector.
23-
init(isHidden: Binding<Bool>) {
24-
self.isHidden = isHidden
25-
}
26-
2721
/// The view model used by the `SiteAndFacilitySelector`.
2822
@EnvironmentObject var viewModel: FloorFilterViewModel
2923

3024
/// Allows the user to toggle the visibility of the site and facility selector.
31-
private var isHidden: Binding<Bool>
25+
@Binding var isPresented: Bool
3226

3327
var body: some View {
3428
NavigationStack {
3529
Group {
3630
// If there's more than one site
3731
if viewModel.sites.count > 1 {
3832
// Show the list of sites for site selection
39-
SitesList(isHidden: isHidden)
33+
SitesList(isPresented: $isPresented)
4034
} else {
4135
// Otherwise there're no sites or only one site, show the list of facilities
4236
FacilitiesList(
4337
usesAllSitesStyling: false,
4438
facilities: viewModel.facilities,
45-
isHidden: isHidden
39+
isPresented: $isPresented
4640
)
4741
.navigationBarBackButtonHidden(true)
4842
}
4943
}
5044
.navigationBarTitleDisplayMode(.inline)
5145
.toolbar {
5246
ToolbarItem(placement: .navigationBarTrailing) {
53-
CloseButton { isHidden.wrappedValue.toggle() }
47+
CloseButton { isPresented = false }
5448
}
5549
}
5650
}
@@ -75,7 +69,7 @@ struct SiteAndFacilitySelector: View {
7569
@State private var userBackedOutOfSelectedSite = false
7670

7771
/// Allows the user to toggle the visibility of the site and facility selector.
78-
var isHidden: Binding<Bool>
72+
@Binding var isPresented: Bool
7973

8074
/// A subset of `sites` with names containing `searchPhrase` or all `sites` if
8175
/// `searchPhrase` is empty.
@@ -133,11 +127,11 @@ struct SiteAndFacilitySelector: View {
133127
FacilitiesList(
134128
usesAllSitesStyling: true,
135129
facilities: viewModel.sites.flatMap(\.facilities),
136-
isHidden: isHidden
130+
isPresented: $isPresented
137131
)
138132
.toolbar {
139133
ToolbarItem(placement: .navigationBarTrailing) {
140-
CloseButton { isHidden.wrappedValue.toggle() }
134+
CloseButton { isPresented = false }
141135
}
142136
}
143137
} label: {
@@ -213,7 +207,7 @@ struct SiteAndFacilitySelector: View {
213207
let facilities: [FloorFacility]
214208

215209
/// Allows the user to toggle the visibility of the site and facility selector.
216-
var isHidden: Binding<Bool>
210+
@Binding var isPresented: Bool
217211

218212
/// A subset of `facilities` with names containing `searchPhrase` or all
219213
/// `facilities` if `searchPhrase` is empty.
@@ -298,7 +292,7 @@ struct SiteAndFacilitySelector: View {
298292
.onTapGesture {
299293
viewModel.setFacility(facility, zoomTo: true)
300294
if horizontalSizeClass == .compact {
301-
isHidden.wrappedValue.toggle()
295+
isPresented = false
302296
}
303297
}
304298
}
@@ -340,7 +334,7 @@ extension SiteAndFacilitySelector.SitesList {
340334
SiteAndFacilitySelector.FacilitiesList(
341335
usesAllSitesStyling: false,
342336
facilities: site.facilities,
343-
isHidden: isHidden
337+
isPresented: $isPresented
344338
)
345339
.navigationBarBackButtonHidden(true)
346340
.toolbar {
@@ -354,7 +348,7 @@ extension SiteAndFacilitySelector.SitesList {
354348
}
355349
.toolbar {
356350
ToolbarItem(placement: .navigationBarTrailing) {
357-
CloseButton { isHidden.wrappedValue.toggle() }
351+
CloseButton { isPresented = false }
358352
}
359353
}
360354
}

0 commit comments

Comments
 (0)