-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Auth モジュールを Compose Multiplatform 化
- Loading branch information
1 parent
95a09da
commit 2e9b2a4
Showing
19 changed files
with
123 additions
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package club.nito.app.di | ||
|
||
import club.nito.feature.auth.di.authFeatureModule | ||
import club.nito.feature.schedule.di.scheduleFeatureModule | ||
import club.nito.feature.top.di.topFeatureModule | ||
import org.koin.core.module.Module | ||
|
||
val featureModules: List<Module> = listOf( | ||
authFeatureModule, | ||
topFeatureModule, | ||
scheduleFeatureModule, | ||
) |
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
24 changes: 24 additions & 0 deletions
24
feature/auth/src/androidMain/kotlin/club/nito/feature/auth/LoginNavigation.android.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,24 @@ | ||
package club.nito.feature.auth | ||
|
||
import androidx.navigation.NavController | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.NavOptions | ||
import androidx.navigation.compose.composable | ||
|
||
fun NavController.navigateToLogin(navOptions: NavOptions? = null) { | ||
this.navigate(loginNavigationRoute, navOptions) | ||
} | ||
|
||
fun NavGraphBuilder.loginScreen( | ||
onLoggedIn: () -> Unit = {}, | ||
onRegisterClick: () -> Unit = {}, | ||
) { | ||
composable( | ||
route = loginNavigationRoute, | ||
) { | ||
LoginRoute( | ||
onLoggedIn = onLoggedIn, | ||
onRegisterClick = onRegisterClick, | ||
) | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
feature/auth/src/androidMain/kotlin/club/nito/feature/auth/Platform.android.kt
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
feature/auth/src/androidMain/kotlin/club/nito/feature/auth/SignInEvent.kt
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
feature/auth/src/androidMain/kotlin/club/nito/feature/auth/SignInIntent.kt
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
feature/auth/src/androidMain/kotlin/club/nito/feature/auth/SignInNavigation.kt
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
feature/auth/src/commonMain/kotlin/club/nito/feature/auth/Greeting.kt
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
feature/auth/src/commonMain/kotlin/club/nito/feature/auth/LoginNavigation.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,25 @@ | ||
package club.nito.feature.auth | ||
|
||
import moe.tlaster.precompose.navigation.NavOptions | ||
import moe.tlaster.precompose.navigation.Navigator | ||
import moe.tlaster.precompose.navigation.RouteBuilder | ||
|
||
const val loginNavigationRoute = "login_route" | ||
|
||
fun Navigator.navigateToLogin(navOptions: NavOptions? = null) { | ||
this.navigate(loginNavigationRoute, navOptions) | ||
} | ||
|
||
fun RouteBuilder.loginScreen( | ||
onLoggedIn: () -> Unit = {}, | ||
onRegisterClick: () -> Unit = {}, | ||
) { | ||
scene( | ||
route = loginNavigationRoute, | ||
) { | ||
LoginRoute( | ||
onLoggedIn = onLoggedIn, | ||
onRegisterClick = onRegisterClick, | ||
) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -20,23 +20,23 @@ import androidx.compose.ui.text.input.ImeAction | |
import androidx.compose.ui.text.input.KeyboardType | ||
import androidx.compose.ui.text.input.PasswordVisualTransformation | ||
import androidx.compose.ui.unit.dp | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import club.nito.core.designsystem.component.CenterAlignedTopAppBar | ||
import club.nito.core.designsystem.component.Scaffold | ||
import club.nito.core.designsystem.component.Text | ||
import club.nito.core.ui.koinStateMachine | ||
import club.nito.core.ui.message.SnackbarMessageEffect | ||
|
||
@Composable | ||
fun SignInRoute( | ||
viewModel: SignInViewModel = hiltViewModel(), | ||
onSignedIn: () -> Unit = {}, | ||
fun LoginRoute( | ||
viewModel: LoginScreenStateMachine = koinStateMachine(), | ||
onLoggedIn: () -> Unit = {}, | ||
onRegisterClick: () -> Unit = {}, | ||
) { | ||
viewModel.event.collectAsState(initial = null).value?.let { | ||
LaunchedEffect(it.hashCode()) { | ||
when (it) { | ||
SignInEvent.NavigateToRegister -> onRegisterClick() | ||
SignInEvent.SignedIn -> onSignedIn() | ||
LoginScreenEvent.NavigateToRegister -> onRegisterClick() | ||
LoginScreenEvent.LoggedIn -> onLoggedIn() | ||
} | ||
viewModel.consume(it) | ||
} | ||
|
@@ -50,7 +50,7 @@ fun SignInRoute( | |
userMessageStateHolder = viewModel.userMessageStateHolder, | ||
) | ||
|
||
SignInScreen( | ||
LoginScreen( | ||
uiState = uiState, | ||
snackbarHostState = snackbarHostState, | ||
dispatch = viewModel::dispatch, | ||
|
@@ -59,10 +59,10 @@ fun SignInRoute( | |
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
private fun SignInScreen( | ||
uiState: SignInScreenUiState, | ||
private fun LoginScreen( | ||
uiState: LoginScreenUiState, | ||
snackbarHostState: SnackbarHostState, | ||
dispatch: (SignInIntent) -> Unit = {}, | ||
dispatch: (LoginScreenIntent) -> Unit = {}, | ||
) { | ||
Scaffold( | ||
topBar = { | ||
|
@@ -85,7 +85,7 @@ private fun SignInScreen( | |
) { | ||
OutlinedTextField( | ||
value = uiState.email, | ||
onValueChange = { dispatch(SignInIntent.ChangeInputEmail(it)) }, | ||
onValueChange = { dispatch(LoginScreenIntent.ChangeInputEmail(it)) }, | ||
modifier = Modifier.fillMaxWidth(), | ||
label = { Text(text = "Email") }, | ||
placeholder = { Text(text = "[email protected]") }, | ||
|
@@ -97,7 +97,7 @@ private fun SignInScreen( | |
) | ||
OutlinedTextField( | ||
value = uiState.password, | ||
onValueChange = { dispatch(SignInIntent.ChangeInputPassword(it)) }, | ||
onValueChange = { dispatch(LoginScreenIntent.ChangeInputPassword(it)) }, | ||
modifier = Modifier.fillMaxWidth(), | ||
label = { Text(text = "Password") }, | ||
placeholder = { Text(text = "password") }, | ||
|
@@ -111,7 +111,7 @@ private fun SignInScreen( | |
Button( | ||
modifier = Modifier | ||
.fillMaxWidth(), | ||
onClick = { dispatch(SignInIntent.ClickSignIn) }, | ||
onClick = { dispatch(LoginScreenIntent.ClickSignIn) }, | ||
enabled = uiState.isSignInButtonEnabled, | ||
) { | ||
Text( | ||
|
6 changes: 6 additions & 0 deletions
6
feature/auth/src/commonMain/kotlin/club/nito/feature/auth/LoginScreenEvent.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,6 @@ | ||
package club.nito.feature.auth | ||
|
||
sealed class LoginScreenEvent { | ||
data object LoggedIn : LoginScreenEvent() | ||
data object NavigateToRegister : LoginScreenEvent() | ||
} |
8 changes: 8 additions & 0 deletions
8
feature/auth/src/commonMain/kotlin/club/nito/feature/auth/LoginScreenIntent.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,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() | ||
} |
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
2 changes: 1 addition & 1 deletion
2
.../nito/feature/auth/SignInScreenUiState.kt → ...b/nito/feature/auth/LoginScreenUiState.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
7 changes: 0 additions & 7 deletions
7
feature/auth/src/commonMain/kotlin/club/nito/feature/auth/Platform.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.