Skip to content

Instantly share code, notes, and snippets.

@GuilhE
Created April 14, 2022 13:41
Show Gist options
  • Save GuilhE/bfcfee6be8b6b57b11fb7b57481de305 to your computer and use it in GitHub Desktop.
Save GuilhE/bfcfee6be8b6b57b11fb7b57481de305 to your computer and use it in GitHub Desktop.
Medium articles - KMM with MVI+FSM
import SwiftUI
import shared
struct TimerView: View {
@StateObject private var viewModel = ViewModels().timerViewModel().asObservableObject()
@State private var currentProgress: Float = 0.0
var body: some View {
ZStack {
//...
CircularProgressView(progress: $currentProgress)
if(viewModel.state.isRestarting) {
//...
}
}
.onReceive(viewModel.$state, perform: { new in
currentProgress = new.progress
})
}
}
struct CircularProgressView: View {
@Binding var progress: Float
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment