comparison 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
comparison
equal deleted inserted replaced
155:681f2cbe8c7f 156:84137052813d
1 //
2 // ModalSheetSelection.swift
3 // Simoleon
4 //
5 // Created by Dennis Concepción Martín on 26/8/21.
6 //
7
8 import SwiftUI
9
10 struct ParentView: View {
11 @State var selection: Int = 1
12 @State private var showingList = false
13
14 var body: some View {
15 VStack {
16 Button("Show list", action: {showingList = true})
17 .sheet(isPresented: $showingList) {
18 ModalSheetSelection(selection: $selection)
19 }
20
21 Text("My first var is: \(selection)")
22 }
23 }
24 }
25
26 struct ModalSheetSelection: View {
27 @Binding var selection: Int
28
29 var body: some View {
30 NavigationView {
31 List {
32 SearchBar(placeholder: "", text: .constant(""))
33 ForEach((1..<100), id: \.self) { number in
34 Button(action: {selection = number}) {
35 Text("\(number)")
36 }
37 }
38 }
39 .id(UUID())
40 .navigationTitle("Currencies")
41 .navigationBarTitleDisplayMode(.inline)
42 }
43 }
44 }