mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-03-19 16:21:20 +01:00
Xcode 11 beta 6
This commit is contained in:
@@ -10,8 +10,8 @@ import Foundation
|
||||
import SwiftUI
|
||||
import Combine
|
||||
|
||||
final class AppState: BindableObject {
|
||||
var willChange = PassthroughSubject<AppState, Never>()
|
||||
final class AppState: ObservableObject {
|
||||
var objectWillChange = PassthroughSubject<AppState, Never>()
|
||||
|
||||
var usersState: UsersState
|
||||
|
||||
@@ -21,7 +21,7 @@ final class AppState: BindableObject {
|
||||
|
||||
func dispatch(action: Action) {
|
||||
usersState = UserStateReducer().reduce(state: usersState, action: action)
|
||||
willChange.send(self)
|
||||
objectWillChange.send(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ struct TabbarView : View {
|
||||
@State var selectedIndex: Int = 0
|
||||
|
||||
var body: some View {
|
||||
TabbedView(selection: $selectedIndex) {
|
||||
TabView(selection: $selectedIndex) {
|
||||
UsersListView()
|
||||
.tabItem({ Text("Users") })
|
||||
MapView()
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
Text("User name")
|
||||
TextField("New name", text: $newUserName)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
.textFieldStyle(RoundedBorderTextFieldStyle())
|
||||
Divider()
|
||||
Text("Username")
|
||||
TextField("New username", text: $newUserUsername)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
}.padding(16)
|
||||
.textFieldStyle(RoundedBorderTextFieldStyle())
|
||||
}.padding(16)
|
||||
Button(action: save) {
|
||||
Text("Save")
|
||||
.padding(8)
|
||||
@@ -42,7 +42,7 @@
|
||||
Text("Close")
|
||||
})
|
||||
.navigationBarTitle(Text("Edit \(user.name)"), displayMode: .inline)
|
||||
|
||||
|
||||
Badge(text: "Saved successfully", color: .green, show: $showSaved)
|
||||
Badge(text: "Missing username or name", color: .red, show: $showError)
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ struct UsersListView : View {
|
||||
.onMove(perform: move)
|
||||
}
|
||||
}
|
||||
.listStyle(.grouped)
|
||||
.listStyle(GroupedListStyle())
|
||||
.navigationBarTitle(Text("Users (\(state.usersState.users.count))"))
|
||||
.navigationBarItems(trailing: EditButton())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user