-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5b36a2
commit 93d43f9
Showing
10 changed files
with
139 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.wwt.jetflow | ||
|
||
import com.wwt.jetflow.welcome.WelcomeViewModel | ||
import org.koin.core.component.KoinComponent | ||
import org.koin.core.context.loadKoinModules | ||
import org.koin.dsl.module | ||
|
||
object AppModule : KoinComponent { | ||
fun init(){ | ||
val welcomeModules = module { | ||
single{WelcomeViewModel()} | ||
} | ||
|
||
val moduleList = listOf( | ||
welcomeModules | ||
) | ||
loadKoinModules(moduleList) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.wwt.jetflow | ||
|
||
import androidx.compose.runtime.Composable | ||
import com.wwt.jetflow.welcome.WelcomeScreen | ||
import com.wwt.jetflow.welcome.WelcomeViewModel | ||
import org.koin.androidx.compose.inject | ||
|
||
@Composable | ||
fun JetflowApp() { | ||
val welcomeViewModel: WelcomeViewModel by inject() | ||
WelcomeScreen( | ||
state = welcomeViewModel.viewState.value, | ||
effectFlow = welcomeViewModel.effect, | ||
onEventSent = { event -> welcomeViewModel.setEvent(event) }) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.wwt.jetflow | ||
|
||
import android.app.Application | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.core.context.startKoin | ||
import org.koin.core.context.stopKoin | ||
|
||
class JetflowApplication : Application(){ | ||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
startKoin { | ||
androidContext(this@JetflowApplication) | ||
} | ||
AppModule.init() | ||
} | ||
|
||
override fun onTerminate() { | ||
super.onTerminate() | ||
stopKoin() | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/wwt/jetflow/welcome/WelcomeScreen.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.wwt.jetflow.welcome | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
@Composable | ||
fun WelcomeScreen( | ||
state: WelcomeScreenContract.State, | ||
effectFlow: Flow<WelcomeScreenContract.Effect>?, | ||
onEventSent: (event: WelcomeScreenContract.Event) -> Unit | ||
){ | ||
Box( | ||
contentAlignment = Alignment.Center, | ||
modifier = Modifier.fillMaxSize() | ||
) { | ||
Text(text = state.welcomeText) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/wwt/jetflow/welcome/WelcomeScreenContract.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.wwt.jetflow.welcome | ||
|
||
import com.wwt.jetflow.base.ViewEvent | ||
import com.wwt.jetflow.base.ViewSideEffect | ||
import com.wwt.jetflow.base.ViewState | ||
|
||
|
||
class WelcomeScreenContract { | ||
sealed class Event : ViewEvent { | ||
} | ||
|
||
data class State( | ||
val welcomeText: String ="" | ||
) : ViewState | ||
|
||
sealed class Effect : ViewSideEffect { | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/wwt/jetflow/welcome/WelcomeViewModel.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.wwt.jetflow.welcome | ||
|
||
import androidx.lifecycle.viewModelScope | ||
import com.wwt.jetflow.base.BaseViewModel | ||
import kotlinx.coroutines.launch | ||
|
||
|
||
class WelcomeViewModel : | ||
BaseViewModel<WelcomeScreenContract.Event, | ||
WelcomeScreenContract.State, | ||
WelcomeScreenContract.Effect>() { | ||
|
||
|
||
init { | ||
viewModelScope.launch { | ||
setState { | ||
copy(welcomeText = "Welcome to Jetflow") | ||
} | ||
} | ||
} | ||
|
||
override fun setInitialState(): WelcomeScreenContract.State = | ||
WelcomeScreenContract.State(welcomeText = "") | ||
|
||
override fun handleEvents(event: WelcomeScreenContract.Event) { | ||
TODO("Not yet implemented") | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
buildscript { | ||
ext { | ||
compose_version = '1.0.1' | ||
koin_version = '3.1.3' | ||
} | ||
repositories { | ||
google() | ||
|