From d9f1948c62a6e400d9f46dac46cf8ca8d10f7504 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Thu, 2 Nov 2023 19:31:15 +0900 Subject: [PATCH] :recycle: Refactor settings related screens --- ...erSettingsScreen.kt => AccountSettings.kt} | 2 +- .../{BackupScreen.kt => BackupSettings.kt} | 14 +-- ...eveloperInfoScreen.kt => DeveloperInfo.kt} | 4 +- .../{DisplayScreen.kt => DisplaySettings.kt} | 13 +-- ...ageSymbolScreen.kt => MySymbolSettings.kt} | 2 +- .../compose/settings/SettingsMainScreen.kt | 81 ---------------- .../compose/settings/SettingsScreen.kt | 97 +++++++++++++------ .../compose/settings/VersionInfoScreen.kt | 4 +- 8 files changed, 75 insertions(+), 142 deletions(-) rename frontend/app/src/main/java/com/example/speechbuddy/compose/settings/{UserSettingsScreen.kt => AccountSettings.kt} (99%) rename frontend/app/src/main/java/com/example/speechbuddy/compose/settings/{BackupScreen.kt => BackupSettings.kt} (92%) rename frontend/app/src/main/java/com/example/speechbuddy/compose/settings/{DeveloperInfoScreen.kt => DeveloperInfo.kt} (95%) rename frontend/app/src/main/java/com/example/speechbuddy/compose/settings/{DisplayScreen.kt => DisplaySettings.kt} (94%) rename frontend/app/src/main/java/com/example/speechbuddy/compose/settings/{ManageSymbolScreen.kt => MySymbolSettings.kt} (80%) delete mode 100644 frontend/app/src/main/java/com/example/speechbuddy/compose/settings/SettingsMainScreen.kt diff --git a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/UserSettingsScreen.kt b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/AccountSettings.kt similarity index 99% rename from frontend/app/src/main/java/com/example/speechbuddy/compose/settings/UserSettingsScreen.kt rename to frontend/app/src/main/java/com/example/speechbuddy/compose/settings/AccountSettings.kt index 832ec077..2196459c 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/UserSettingsScreen.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/AccountSettings.kt @@ -22,7 +22,7 @@ import com.example.speechbuddy.compose.utils.ButtonUi import com.example.speechbuddy.viewmodel.UserSettingsViewModel @Composable -fun UserSettingsScreen( +fun AccountSettings( modifier: Modifier = Modifier, onBackClick: () -> Unit, email: String, diff --git a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/BackupScreen.kt b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/BackupSettings.kt similarity index 92% rename from frontend/app/src/main/java/com/example/speechbuddy/compose/settings/BackupScreen.kt rename to frontend/app/src/main/java/com/example/speechbuddy/compose/settings/BackupSettings.kt index 157de95a..8ceab14d 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/BackupScreen.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/BackupSettings.kt @@ -24,7 +24,7 @@ import com.example.speechbuddy.ui.SpeechBuddyTheme import com.example.speechbuddy.viewmodel.BackupViewModel @Composable -fun BackupScreen( +fun BackupSettings( modifier: Modifier, onBackClick: () -> Unit, lastBackupDate: String, @@ -84,16 +84,4 @@ fun BackupScreen( ) } } -} - -@Preview -@Composable -fun BackupScreenPreview() { - SpeechBuddyTheme { - BackupScreen( - modifier = Modifier, - onBackClick = {}, - lastBackupDate = "2023.10.27" - ) - } } \ No newline at end of file diff --git a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/DeveloperInfoScreen.kt b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/DeveloperInfo.kt similarity index 95% rename from frontend/app/src/main/java/com/example/speechbuddy/compose/settings/DeveloperInfoScreen.kt rename to frontend/app/src/main/java/com/example/speechbuddy/compose/settings/DeveloperInfo.kt index 353a84ac..657775bf 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/DeveloperInfoScreen.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/DeveloperInfo.kt @@ -19,7 +19,7 @@ import com.example.speechbuddy.R import com.example.speechbuddy.ui.SpeechBuddyTheme @Composable -fun DeveloperInfoScreen( +fun DevelopersInfo( modifier: Modifier, onBackClick: () -> Unit, ) { @@ -68,6 +68,6 @@ fun DeveloperInfoScreen( @Composable fun DeveloperInfoScreenPreview() { SpeechBuddyTheme { - DeveloperInfoScreen(modifier = Modifier, onBackClick = { /*TODO*/ }) + DevelopersInfo(modifier = Modifier, onBackClick = { /*TODO*/ }) } } \ No newline at end of file diff --git a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/DisplayScreen.kt b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/DisplaySettings.kt similarity index 94% rename from frontend/app/src/main/java/com/example/speechbuddy/compose/settings/DisplayScreen.kt rename to frontend/app/src/main/java/com/example/speechbuddy/compose/settings/DisplaySettings.kt index dea93a71..a689f30a 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/DisplayScreen.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/DisplaySettings.kt @@ -24,7 +24,7 @@ import com.example.speechbuddy.ui.SpeechBuddyTheme import com.example.speechbuddy.viewmodel.DisplayViewModel @Composable -fun DisplayScreen( +fun DisplaySettings( modifier: Modifier, onBackClick: () -> Unit, viewModel: DisplayViewModel = hiltViewModel() @@ -99,15 +99,4 @@ fun DisplayScreen( } } } -} - -@Preview -@Composable -fun DisplayScreenPreview() { - SpeechBuddyTheme { - DisplayScreen( - modifier = Modifier, - onBackClick = {} - ) - } } \ No newline at end of file diff --git a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/ManageSymbolScreen.kt b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/MySymbolSettings.kt similarity index 80% rename from frontend/app/src/main/java/com/example/speechbuddy/compose/settings/ManageSymbolScreen.kt rename to frontend/app/src/main/java/com/example/speechbuddy/compose/settings/MySymbolSettings.kt index d7ff5e68..63a350c8 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/ManageSymbolScreen.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/MySymbolSettings.kt @@ -3,6 +3,6 @@ package com.example.speechbuddy.compose.settings import androidx.compose.runtime.Composable @Composable -fun ManageSymbolScreen() { +fun MySymbolSettings() { } \ No newline at end of file diff --git a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/SettingsMainScreen.kt b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/SettingsMainScreen.kt deleted file mode 100644 index 3866550b..00000000 --- a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/SettingsMainScreen.kt +++ /dev/null @@ -1,81 +0,0 @@ -package com.example.speechbuddy.compose.settings - -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Surface -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import com.example.speechbuddy.R -import com.example.speechbuddy.ui.SpeechBuddyTheme - -@Composable -fun SettingsMainScreen( - onUserSettingsClick: () -> Unit, - onBackupClick: () -> Unit, - onDisplayClick: () -> Unit, - onManageSymbolClick: () -> Unit, - onVersionInfoClick: () -> Unit, - onDeveloperInfoClick: () -> Unit -) { - Surface( - modifier = Modifier - .fillMaxSize() - ) { - Column( - modifier = Modifier - .padding(horizontal = 30.dp, vertical = 50.dp) - .fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally - ) { - SettingsTextButtonUi( - text = stringResource(id = R.string.settings_account_button), - onClick = onUserSettingsClick - ) - - SettingsTextButtonUi( - text = stringResource(id = R.string.settings_backup_button), - onClick = onBackupClick - ) - - SettingsTextButtonUi( - text = stringResource(id = R.string.settings_display_button), - onClick = onDisplayClick - ) - - SettingsTextButtonUi( - text = stringResource(id = R.string.settings_manage_symbol_button), - onClick = onManageSymbolClick - ) - - SettingsTextButtonUi( - text = stringResource(id = R.string.settings_versioninfo_button), - onClick = onVersionInfoClick - ) - - SettingsTextButtonUi( - text = stringResource(id = R.string.settings_developerinfo_button), - onClick = onDeveloperInfoClick - ) - } - } -} - -@Preview -@Composable -private fun SettingsMainScreenPreview() { - SpeechBuddyTheme { - SettingsMainScreen( - onUserSettingsClick = {}, - onBackupClick = {}, - onDisplayClick = {}, - onManageSymbolClick = {}, - onVersionInfoClick = {}, - onDeveloperInfoClick = {} - ) - } -} \ No newline at end of file diff --git a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/SettingsScreen.kt b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/SettingsScreen.kt index 1fb107ef..a10a1423 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/SettingsScreen.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/SettingsScreen.kt @@ -1,18 +1,24 @@ package com.example.speechbuddy.compose.settings +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Surface import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController +import com.example.speechbuddy.R import com.example.speechbuddy.ui.SpeechBuddyTheme @Composable -fun SettingsScreen( - -) { +fun SettingsScreen() { val navController = rememberNavController() SettingsScreenNavHost( navController = navController @@ -23,56 +29,87 @@ fun SettingsScreen( private fun SettingsScreenNavHost( navController: NavHostController ) { - NavHost(navController = navController, startDestination = "settings_main") { - composable("settings_main") { - SettingsMainScreen( - onUserSettingsClick = { navController.navigate("settings_usersettings") }, - onBackupClick = { navController.navigate("settings_backup") }, - onDisplayClick = { navController.navigate("settings_display") }, - onManageSymbolClick = { navController.navigate("settings_managesymbol") }, - onVersionInfoClick = { navController.navigate("settings_versioninfo") }, - onDeveloperInfoClick = { navController.navigate("settings_developerinfo") } + val navigateToMain = { navController.navigate("main") } + + NavHost(navController = navController, startDestination = "main") { + composable("main") { + MainSettings( + navController = navController ) } - composable("settings_usersettings") { - UserSettingsScreen( - onBackClick = { navController.navigate("settings_main") }, + composable("account") { + AccountSettings( + onBackClick = navigateToMain, email = "example@example.com", nickname = "example", ) } - composable("settings_backup") { - BackupScreen( + composable("backup") { + BackupSettings( modifier = Modifier, - onBackClick = { navController.navigate("settings_main") }, - lastBackupDate = "2023.10.29.", + onBackClick = navigateToMain, + lastBackupDate = "2023.10.29." ) } - composable("settings_display") { - DisplayScreen( + composable("display") { + DisplaySettings( modifier = Modifier, - onBackClick = { navController.navigate("settings_main") }, + onBackClick = navigateToMain ) } - composable("settings_managesymbol") { - ManageSymbolScreen() + composable("my_symbol") { + MySymbolSettings() } - composable("settings_versioninfo") { - VersionInfoScreen( + composable("version") { + VersionInfo( modifier = Modifier, - onBackClick = { navController.navigate("settings_main") }, + onBackClick = navigateToMain, versionText = "1.0.0" ) } - composable("settings_developerinfo") { - DeveloperInfoScreen( + composable("developers") { + DevelopersInfo( modifier = Modifier, - onBackClick = { navController.navigate("settings_main") } + onBackClick = navigateToMain ) } } } +@Composable +fun MainSettings( + navController: NavHostController +) { + Surface( + modifier = Modifier.fillMaxSize() + ) { + Column( + modifier = Modifier + .padding(horizontal = 30.dp, vertical = 50.dp) + .fillMaxSize(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + SettingsTextButtonUi(text = stringResource(id = R.string.settings_account_button), + onClick = { navController.navigate("account") }) + + SettingsTextButtonUi(text = stringResource(id = R.string.settings_backup_button), + onClick = { navController.navigate("backup") }) + + SettingsTextButtonUi(text = stringResource(id = R.string.settings_display_button), + onClick = { navController.navigate("display") }) + + SettingsTextButtonUi(text = stringResource(id = R.string.settings_manage_symbol_button), + onClick = { navController.navigate("my_symbol") }) + + SettingsTextButtonUi(text = stringResource(id = R.string.settings_versioninfo_button), + onClick = { navController.navigate("version") }) + + SettingsTextButtonUi(text = stringResource(id = R.string.settings_developerinfo_button), + onClick = { navController.navigate("developers") }) + } + } +} + @Preview @Composable private fun SettingsScreenPreview() { diff --git a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/VersionInfoScreen.kt b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/VersionInfoScreen.kt index 15cffa24..83abb86f 100644 --- a/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/VersionInfoScreen.kt +++ b/frontend/app/src/main/java/com/example/speechbuddy/compose/settings/VersionInfoScreen.kt @@ -19,7 +19,7 @@ import com.example.speechbuddy.R import com.example.speechbuddy.ui.SpeechBuddyTheme @Composable -fun VersionInfoScreen( +fun VersionInfo( modifier: Modifier, onBackClick: () -> Unit, versionText: String @@ -68,6 +68,6 @@ fun VersionInfoScreen( @Composable fun VersionInfoScreenPreview() { SpeechBuddyTheme { - VersionInfoScreen(modifier = Modifier, onBackClick = { /*TODO*/ }, versionText = "1.0.0") + VersionInfo(modifier = Modifier, onBackClick = { /*TODO*/ }, versionText = "1.0.0") } } \ No newline at end of file