diff --git a/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/NotesApp.kt b/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/NotesApp.kt index 139af7a..0a47ed0 100644 --- a/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/NotesApp.kt +++ b/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/NotesApp.kt @@ -82,7 +82,7 @@ fun NavGraphBuilder.notesGraph(appState: NotesAppState) { composable(SIGN_IN_SCREEN) { SignInScreen( - onSignUpClicked = { route -> appState.navigate(route) }, + openScreen = { route -> appState.navigate(route) }, openAndPopUp = { route, popUp -> appState.navigateAndPopUp(route, popUp) } ) } diff --git a/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/authentication/sign_in/SignInScreen.kt b/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/authentication/sign_in/SignInScreen.kt index 02ca586..102323d 100644 --- a/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/authentication/sign_in/SignInScreen.kt +++ b/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/authentication/sign_in/SignInScreen.kt @@ -38,6 +38,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.hilt.navigation.compose.hiltViewModel import com.notes.app.R +import com.notes.app.SIGN_UP_SCREEN import com.notes.app.screens.authentication.AuthenticationButton import com.notes.app.screens.authentication.launchCredManBottomSheet import com.notes.app.ui.theme.NotesTheme @@ -46,7 +47,7 @@ import com.notes.app.ui.theme.Purple40 @Composable @OptIn(ExperimentalMaterial3Api::class) fun SignInScreen( - onSignUpClicked: (String) -> Unit, + openScreen: (String) -> Unit, openAndPopUp: (String, String) -> Unit, modifier: Modifier = Modifier, viewModel: SignInViewModel = hiltViewModel() @@ -159,7 +160,7 @@ fun SignInScreen( .fillMaxWidth() .padding(8.dp)) - TextButton(onClick = { viewModel.onSignUpClick(onSignUpClicked) }) { + TextButton(onClick = { openScreen(SIGN_UP_SCREEN) }) { Text(text = stringResource(R.string.sign_up_description), fontSize = 16.sp, color = Purple40) } } diff --git a/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/authentication/sign_in/SignInViewModel.kt b/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/authentication/sign_in/SignInViewModel.kt index dee9454..0df80f1 100644 --- a/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/authentication/sign_in/SignInViewModel.kt +++ b/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/authentication/sign_in/SignInViewModel.kt @@ -8,7 +8,6 @@ import com.google.android.libraries.identity.googleid.GoogleIdTokenCredential.Co import com.notes.app.ERROR_TAG import com.notes.app.SIGN_IN_SCREEN import com.notes.app.NOTES_LIST_SCREEN -import com.notes.app.SIGN_UP_SCREEN import com.notes.app.UNEXPECTED_CREDENTIAL import com.notes.app.model.service.AccountService import com.notes.app.screens.NotesAppViewModel @@ -55,8 +54,4 @@ class SignInViewModel @Inject constructor( } } } - - fun onSignUpClick(openScreen: (String) -> Unit) { - openScreen(SIGN_UP_SCREEN) - } } \ No newline at end of file diff --git a/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/notes_list/NotesListScreen.kt b/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/notes_list/NotesListScreen.kt index a899458..20eecaa 100644 --- a/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/notes_list/NotesListScreen.kt +++ b/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/notes_list/NotesListScreen.kt @@ -34,6 +34,10 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel +import com.notes.app.ACCOUNT_CENTER_SCREEN +import com.notes.app.NOTE_DEFAULT_ID +import com.notes.app.NOTE_ID +import com.notes.app.NOTE_SCREEN import com.notes.app.R import com.notes.app.model.Note import com.notes.app.model.getTitle @@ -54,7 +58,7 @@ fun NotesListScreen( Scaffold( floatingActionButton = { FloatingActionButton( - onClick = { viewModel.onAddClick(openScreen) }, + onClick = { openScreen("$NOTE_SCREEN?$NOTE_ID=$NOTE_DEFAULT_ID") }, modifier = modifier.padding(16.dp), containerColor = Purple40, shape = RoundedCornerShape(16.dp) @@ -71,7 +75,7 @@ fun NotesListScreen( TopAppBar( title = { Text(stringResource(R.string.app_name)) }, actions = { - IconButton(onClick = { viewModel.onAccountCenterClick(openScreen) }) { + IconButton(onClick = { openScreen(ACCOUNT_CENTER_SCREEN) }) { Icon(Icons.Filled.Person, "Account center") } } @@ -90,7 +94,7 @@ fun NotesListScreen( items(notes, key = { it.id }) { noteItem -> NoteItem( note = noteItem, - onActionClick = { viewModel.onNoteClick(openScreen, noteItem) } + onActionClick = { openScreen("$NOTE_SCREEN?$NOTE_ID=${noteItem.id}") } ) } } diff --git a/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/notes_list/NotesListViewModel.kt b/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/notes_list/NotesListViewModel.kt index 48543d9..de5f6cc 100644 --- a/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/notes_list/NotesListViewModel.kt +++ b/fundamentals/android/auth-sign-in-with-google/Notes/app/src/main/java/com/notes/app/screens/notes_list/NotesListViewModel.kt @@ -1,11 +1,6 @@ package com.notes.app.screens.notes_list -import com.notes.app.ACCOUNT_CENTER_SCREEN -import com.notes.app.NOTE_DEFAULT_ID -import com.notes.app.NOTE_ID -import com.notes.app.NOTE_SCREEN import com.notes.app.SPLASH_SCREEN -import com.notes.app.model.Note import com.notes.app.model.service.AccountService import com.notes.app.model.service.StorageService import com.notes.app.screens.NotesAppViewModel @@ -26,16 +21,4 @@ class NotesListViewModel @Inject constructor( } } } - - fun onAddClick(openScreen: (String) -> Unit) { - openScreen("$NOTE_SCREEN?$NOTE_ID=$NOTE_DEFAULT_ID") - } - - fun onNoteClick(openScreen: (String) -> Unit, note: Note) { - openScreen("$NOTE_SCREEN?$NOTE_ID=${note.id}") - } - - fun onAccountCenterClick(openScreen: (String) -> Unit) { - openScreen(ACCOUNT_CENTER_SCREEN) - } } \ No newline at end of file