Mercurial > public > simoleon
view Simoleon/Tests/ChildListResets.swift @ 156:84137052813d
Refactor code
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Sat, 28 Aug 2021 11:15:25 +0100 |
parents | |
children |
line wrap: on
line source
// // ModalSheetSelection.swift // Simoleon // // Created by Dennis Concepción Martín on 26/8/21. // import SwiftUI struct ParentView: View { @State var selection: Int = 1 @State private var showingList = false var body: some View { VStack { Button("Show list", action: {showingList = true}) .sheet(isPresented: $showingList) { ModalSheetSelection(selection: $selection) } Text("My first var is: \(selection)") } } } struct ModalSheetSelection: View { @Binding var selection: Int var body: some View { NavigationView { List { SearchBar(placeholder: "", text: .constant("")) ForEach((1..<100), id: \.self) { number in Button(action: {selection = number}) { Text("\(number)") } } } .id(UUID()) .navigationTitle("Currencies") .navigationBarTitleDisplayMode(.inline) } } }