This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.koin.androidx.viewmodel.dsl.viewModel | |
import org.koin.dsl.module | |
val appModule = module { | |
viewModel { MainViewModel(get()) } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
private val viewModel: MainViewModel by viewModel() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
Navigation(viewModel) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class Intent : UiIntent { | |
object FetchOrigamiData : Intent() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class State : UiState { | |
object Idle : State() | |
object Error : State() | |
object Loading : State() | |
data class Origami(val origami: List<Entity>) : State() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainViewModel( | |
private val getOrigamiUseCase: GetOrigamiUseCase | |
) : BaseViewModel<Intent,State>() { | |
override fun createInitialState(): State = State.Idle | |
override fun handleIntent(intent: Intent) { | |
when(intent){ | |
Intent.FetchOrigamiData -> getOrigami() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun HomeScreen( | |
navController: NavController, | |
viewModel: MainViewModel = viewModel() | |
) { | |
val uiState = viewModel | |
.uiState | |
.collectAsState() | |
.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
@main | |
struct iOSApp: App { | |
init(){ | |
startKoin() | |
} | |
var body: some Scene { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import shared | |
func startKoin() { | |
_koin = InjectorKt.doInitKoin().koin | |
} | |
private var _koin: Koin_coreKoin? | |
var koin: Koin_coreKoin { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import shared | |
enum DataState { | |
case loading | |
case result([Entity]) | |
case error | |
} |