Skip to content

Commit

Permalink
Add tapping on cancel button to dismiss bottom sheet in Example app
Browse files Browse the repository at this point in the history
  • Loading branch information
weitieda committed Nov 14, 2022
1 parent cc11d8e commit 6b21007
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion iOS Example/Sources/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct ContentView: View {
topBarCornerRadius: 16,
showTopIndicator: false
) {
MapSettingView()
MapSettingView{ self.showMapSetting = false }
}
.navigationBarTitle("Bottom Sheet")
.navigationBarItems(
Expand Down
9 changes: 7 additions & 2 deletions iOS Example/Sources/MapSettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
import SwiftUI

struct MapSettingView: View {
let dismiss: () -> Void

var body: some View {
VStack(alignment: .leading) {
HStack {
Text("Map Settings").font(.title).bold()
Spacer()
Image(systemName: "xmark.circle.fill").foregroundColor(.gray).font(.system(size: 26))
Image(systemName: "xmark.circle.fill")
.foregroundColor(.gray)
.font(.system(size: 26))
.onTapGesture { dismiss() }
}.padding(.horizontal)
Picker(selection: .constant(0), label: Text("")) {
Text("Map").tag(0)
Expand Down Expand Up @@ -62,6 +67,6 @@ struct MapSettingView: View {

struct MapSettingView_Previews: PreviewProvider {
static var previews: some View {
MapSettingView()
MapSettingView(dismiss: {})
}
}

0 comments on commit 6b21007

Please sign in to comment.