One of these days, I'll settle on a project structure
This commit is contained in:
parent
1637d058b1
commit
59c7bdbb78
7 changed files with 21 additions and 41 deletions
|
@ -9,12 +9,13 @@ import androidx.navigation.compose.NavHost
|
|||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import kotlinx.serialization.Serializable
|
||||
import software.makeshift.debtpirate.screens.auth.SignUpScreen
|
||||
import software.makeshift.debtpirate.screens.auth.AuthScreen
|
||||
import software.makeshift.debtpirate.screens.auth.signup.SignUpScreenViewModel
|
||||
import software.makeshift.debtpirate.ui.theme.DebtPirateTheme
|
||||
|
||||
@Serializable
|
||||
object LoginRoute
|
||||
object AuthRoute
|
||||
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -24,10 +25,10 @@ class MainActivity : ComponentActivity() {
|
|||
val navController = rememberNavController()
|
||||
|
||||
DebtPirateTheme {
|
||||
NavHost(navController = navController, startDestination = LoginRoute) {
|
||||
composable<LoginRoute> {
|
||||
SignUpScreen(
|
||||
viewModel = viewModel<SignUpScreenViewModel>()
|
||||
NavHost(navController = navController, startDestination = AuthRoute) {
|
||||
composable<AuthRoute> {
|
||||
AuthScreen(
|
||||
signUpViewModel = viewModel<SignUpScreenViewModel>()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,19 +20,17 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import software.makeshift.debtpirate.R
|
||||
import software.makeshift.debtpirate.screens.auth.signup.SignUpScreen
|
||||
import software.makeshift.debtpirate.screens.auth.signup.SignUpScreenViewModel
|
||||
|
||||
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
|
||||
@Composable
|
||||
fun SignUpScreen(
|
||||
viewModel: SignUpScreenViewModel
|
||||
fun AuthScreen(
|
||||
viewModel: AuthScreenViewModel
|
||||
) {
|
||||
Scaffold(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) { innerPadding ->
|
||||
Column {
|
||||
LoginTopBar(
|
||||
AuthScreenTopAppBar(
|
||||
innerPadding,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
@ -55,7 +53,7 @@ fun SignUpScreen(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun LoginTopBar(innerPadding: PaddingValues, modifier: Modifier = Modifier) {
|
||||
private fun AuthScreenTopAppBar(innerPadding: PaddingValues, modifier: Modifier = Modifier) {
|
||||
Box(modifier = modifier.background(Color.Green)) {
|
||||
Text(
|
||||
text = "Hello from Login! I'm in a box!",
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package software.makeshift.debtpirate.screens.auth.signup
|
||||
package software.makeshift.debtpirate.screens.auth
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
|
||||
class SignUpScreenViewModel : ViewModel() {
|
||||
class AuthScreenViewModel : ViewModel() {
|
||||
private val _displayName = MutableStateFlow("")
|
||||
val displayName = _displayName.asStateFlow()
|
||||
|
||||
|
@ -18,8 +18,4 @@ class SignUpScreenViewModel : ViewModel() {
|
|||
fun updateEmailAddress(emailAddress: String) {
|
||||
_emailAddress.value = emailAddress
|
||||
}
|
||||
|
||||
fun isValidPassword() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package software.makeshift.debtpirate.screens.auth.signin
|
||||
package software.makeshift.debtpirate.screens.auth
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.interaction.FocusInteraction
|
|
@ -1,4 +1,4 @@
|
|||
package software.makeshift.debtpirate.screens.auth.signup
|
||||
package software.makeshift.debtpirate.screens.auth
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
|
@ -1,21 +0,0 @@
|
|||
package software.makeshift.debtpirate.screens.auth.signin
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
|
||||
class SignInViewModel : ViewModel() {
|
||||
private val _username = MutableStateFlow("")
|
||||
val username = _username.asStateFlow()
|
||||
|
||||
private val _password = MutableStateFlow("")
|
||||
val password = _password.asStateFlow()
|
||||
|
||||
fun updateUsername(username: String) {
|
||||
_username.value = username
|
||||
}
|
||||
|
||||
fun updateLoginPassword(password: String) {
|
||||
_password.value = password
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package software.makeshift.debtpirate.types
|
||||
|
||||
sealed class Either<out A, out B> {
|
||||
class Left<A>(val value: A) : Either<A, Nothing>()
|
||||
class Right<B>(val value: B) : Either<Nothing, B>()
|
||||
}
|
Loading…
Add table
Reference in a new issue