Skip to content

Commit

Permalink
♻️ auth モジュールに explicitApi を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsutakein committed Nov 23, 2023
1 parent 06dc426 commit 4346f65
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
2 changes: 2 additions & 0 deletions feature/auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ plugins {
android.namespace = "club.nito.feature.auth"

kotlin {
explicitApi()

sourceSets {
commonMain {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import moe.tlaster.precompose.navigation.NavOptions
import moe.tlaster.precompose.navigation.Navigator
import moe.tlaster.precompose.navigation.RouteBuilder

const val loginNavigationRoute = "login_route"
public const val loginNavigationRoute: String = "login_route"

fun Navigator.navigateToLogin(navOptions: NavOptions? = null) {
public fun Navigator.navigateToLogin(navOptions: NavOptions? = null) {
this.navigate(loginNavigationRoute, navOptions)
}

fun RouteBuilder.loginScreen(
public fun RouteBuilder.loginScreen(
onLoggedIn: () -> Unit = {},
onRegisterClick: () -> Unit = {},
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import club.nito.core.ui.koinStateMachine
import club.nito.core.ui.message.SnackbarMessageEffect

@Composable
fun LoginRoute(
public fun LoginRoute(
viewModel: LoginScreenStateMachine = koinStateMachine(),
onLoggedIn: () -> Unit = {},
onRegisterClick: () -> Unit = {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package club.nito.feature.auth

sealed class LoginScreenEvent {
data object LoggedIn : LoginScreenEvent()
data object NavigateToRegister : LoginScreenEvent()
public sealed class LoginScreenEvent {
public data object LoggedIn : LoginScreenEvent()
public data object NavigateToRegister : LoginScreenEvent()
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package club.nito.feature.auth

sealed class LoginScreenIntent {
data class ChangeInputEmail(val email: String) : LoginScreenIntent()
data class ChangeInputPassword(val password: String) : LoginScreenIntent()
data object ClickSignIn : LoginScreenIntent()
data object ClickRegister : LoginScreenIntent()
public sealed class LoginScreenIntent {
public data class ChangeInputEmail(val email: String) : LoginScreenIntent()
public data class ChangeInputPassword(val password: String) : LoginScreenIntent()
public data object ClickSignIn : LoginScreenIntent()
public data object ClickRegister : LoginScreenIntent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch

class LoginScreenStateMachine internal constructor(
public class LoginScreenStateMachine internal constructor(
observeAuthStatusUseCase: ObserveAuthStatusUseCase,
private val signInUseCase: SignInUseCase,
val userMessageStateHolder: UserMessageStateHolder,
public val userMessageStateHolder: UserMessageStateHolder,
) : StateMachine(),
UserMessageStateHolder by userMessageStateHolder {

Expand All @@ -33,7 +33,7 @@ class LoginScreenStateMachine internal constructor(
initialValue = FetchSingleResult.Loading,
)

val uiState: StateFlow<LoginScreenUiState> = buildUiState(
public val uiState: StateFlow<LoginScreenUiState> = buildUiState(
email,
password,
authStatus,
Expand All @@ -46,7 +46,7 @@ class LoginScreenStateMachine internal constructor(
}

private val _events = MutableStateFlow<List<LoginScreenEvent>>(emptyList())
val event: Flow<LoginScreenEvent?> = _events.map { it.firstOrNull() }
public val event: Flow<LoginScreenEvent?> = _events.map { it.firstOrNull() }

init {
stateMachineScope.launch {
Expand All @@ -58,7 +58,7 @@ class LoginScreenStateMachine internal constructor(
}
}

fun dispatch(intent: LoginScreenIntent) {
public fun dispatch(intent: LoginScreenIntent) {
stateMachineScope.launch {
when (intent) {
is LoginScreenIntent.ChangeInputEmail -> email.emit(intent.email)
Expand All @@ -75,7 +75,7 @@ class LoginScreenStateMachine internal constructor(
}
}

fun consume(event: LoginScreenEvent) {
public fun consume(event: LoginScreenEvent) {
stateMachineScope.launch {
_events.emit(_events.value.filterNot { it == event })
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package club.nito.feature.auth

data class LoginScreenUiState(
public data class LoginScreenUiState(
val email: String,
val password: String,
val isSignInning: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import club.nito.feature.auth.LoginScreenStateMachine
import org.koin.core.module.Module
import org.koin.dsl.module

val authFeatureModule: Module = module {
public val authFeatureModule: Module = module {
factory {
LoginScreenStateMachine(
observeAuthStatusUseCase = get(),
Expand Down

0 comments on commit 4346f65

Please sign in to comment.