Add counter example to show viewActions modifying the state.

This commit is contained in:
David Langley
2021-09-20 17:05:54 +01:00
parent a94969403c
commit e22848dcda
11 changed files with 65 additions and 47 deletions
@@ -38,10 +38,16 @@ struct TemplateUserProfile: View {
presence: viewModel.viewState.presence
)
Divider()
VStack{
Text("More great user content!")
HStack{
Text("Counter: \(viewModel.viewState.count)")
.font(theme.fonts.title2)
.foregroundColor(theme.colors.secondaryContent)
Button("-") {
viewModel.send(viewAction: .decrementCount)
}
Button("+") {
viewModel.send(viewAction: .incrementCount)
}
}
.frame(maxHeight: .infinity)
}