mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-04-01 23:13:28 +02:00
Xcode 11 beta 6
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import SwiftUI
|
||||
import Combine
|
||||
|
||||
public final class Store<StateType>: BindableObject where StateType: StateMachine {
|
||||
public final class Store<StateType>: ObservableObject where StateType: StateMachine {
|
||||
|
||||
private let initialState: StateType
|
||||
private var subsequentStates: [StateType] = []
|
||||
|
||||
public let willChange = PassthroughSubject<Void, Never>()
|
||||
public let objectWillChange = PassthroughSubject<Void, Never>()
|
||||
|
||||
public init(state: StateType) {
|
||||
initialState = state
|
||||
@@ -23,7 +23,7 @@ public final class Store<StateType>: BindableObject where StateType: StateMachin
|
||||
var currentStateIndex: Int = 0 {
|
||||
didSet {
|
||||
withAnimation {
|
||||
willChange.send(())
|
||||
objectWillChange.send(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ struct TimeTravelBarView : View {
|
||||
@EnvironmentObject var store: Store<TodoState>
|
||||
|
||||
var body: some View {
|
||||
let indexBinding = Binding<Double>(
|
||||
getValue: { Double(self.store.currentStateIndex) },
|
||||
setValue: { self.store.currentStateIndex = Int($0) })
|
||||
let indexBinding = Binding(
|
||||
get: { Double(self.store.currentStateIndex) },
|
||||
set: { self.store.currentStateIndex = Int($0) })
|
||||
|
||||
return Slider(value: indexBinding, in: 0...Double(store.stateCount-1))
|
||||
.background(Color.white)
|
||||
|
||||
@@ -6,9 +6,9 @@ struct AddItemView: View {
|
||||
|
||||
var body: some View {
|
||||
|
||||
let textBinding = Binding<String>(
|
||||
getValue: { self.store.state.partialItemName },
|
||||
setValue: { self.store.dispatch(event: .changePartialItemName($0)) })
|
||||
let textBinding = Binding(
|
||||
get: { self.store.state.partialItemName },
|
||||
set: { self.store.dispatch(event: .changePartialItemName($0)) })
|
||||
|
||||
return VStack(spacing: 16) {
|
||||
TextField("Title", text: textBinding)
|
||||
|
||||
@@ -12,7 +12,7 @@ struct ModalDimmingView : View {
|
||||
.opacity(0.3)
|
||||
.edgesIgnoringSafeArea([.bottom, .top])
|
||||
.transition(.opacity)
|
||||
.tapAction {
|
||||
.onTapGesture {
|
||||
self.store.dispatch(event: .cancelCreatingItem)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user