diff --git a/LeCountdown/Views/CountdownFormView.swift b/LeCountdown/Views/CountdownFormView.swift index c6f82da..7a22414 100644 --- a/LeCountdown/Views/CountdownFormView.swift +++ b/LeCountdown/Views/CountdownFormView.swift @@ -20,6 +20,8 @@ struct CountdownFormView : View { var textFieldIsFocused: FocusState.Binding + @State var imageSelectionSheetShown: Bool = false + var body: some View { Form { Section(header: Text("Duration")) { @@ -45,12 +47,12 @@ struct CountdownFormView : View { Text("Sound") } Toggle("Sound repeats", isOn: repeatsBinding) - } - Section { - NavigationLink { - ImageSelectionView(imageBinding: imageBinding) + Section(header: Text("Background")) { + + Button { + self.imageSelectionSheetShown = true } label: { Group { if let image = self.imageBinding.wrappedValue { @@ -63,10 +65,13 @@ struct CountdownFormView : View { .aspectRatio(1, contentMode: .fit) .frame(width: 100.0, height: 100.0) .cornerRadius(40.0) - + } + } + }.sheet(isPresented: self.$imageSelectionSheetShown) { + ImageSelectionView(showBinding: self.$imageSelectionSheetShown, imageBinding: self.imageBinding) } } diff --git a/LeCountdown/Views/ImageSelectionView.swift b/LeCountdown/Views/ImageSelectionView.swift index cbfe9a8..38989e5 100644 --- a/LeCountdown/Views/ImageSelectionView.swift +++ b/LeCountdown/Views/ImageSelectionView.swift @@ -9,6 +9,8 @@ import SwiftUI struct ImageSelectionView: View { + var showBinding: Binding + var imageBinding: Binding private let columns: [GridItem] = [ @@ -35,11 +37,10 @@ struct ImageSelectionView: View { .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) .aspectRatio(1, contentMode: .fit) .cornerRadius(40.0) - .roundedCorner(selected: self.imageBinding.wrappedValue == coolPic) - } .onTapGesture { self.imageBinding.wrappedValue = coolPic + self.showBinding.wrappedValue = false print("coolPic = \(coolPic), image = \(String(describing: self.imageBinding.wrappedValue))") } @@ -53,6 +54,6 @@ struct ImageSelectionView: View { struct ImageSelectionView_Previews: PreviewProvider { static var previews: some View { - ImageSelectionView(imageBinding: .constant(.pic3)) + ImageSelectionView(showBinding: .constant(true), imageBinding: .constant(.pic3)) } }