Skip to content

Commit

Permalink
♻️ Refactor settings related screens
Browse files Browse the repository at this point in the history
  • Loading branch information
sukchan-0811 committed Nov 2, 2023
1 parent f76ff48 commit d9f1948
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -84,16 +84,4 @@ fun BackupScreen(
)
}
}
}

@Preview
@Composable
fun BackupScreenPreview() {
SpeechBuddyTheme {
BackupScreen(
modifier = Modifier,
onBackClick = {},
lastBackupDate = "2023.10.27"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.example.speechbuddy.R
import com.example.speechbuddy.ui.SpeechBuddyTheme

@Composable
fun DeveloperInfoScreen(
fun DevelopersInfo(
modifier: Modifier,
onBackClick: () -> Unit,
) {
Expand Down Expand Up @@ -68,6 +68,6 @@ fun DeveloperInfoScreen(
@Composable
fun DeveloperInfoScreenPreview() {
SpeechBuddyTheme {
DeveloperInfoScreen(modifier = Modifier, onBackClick = { /*TODO*/ })
DevelopersInfo(modifier = Modifier, onBackClick = { /*TODO*/ })
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -99,15 +99,4 @@ fun DisplayScreen(
}
}
}
}

@Preview
@Composable
fun DisplayScreenPreview() {
SpeechBuddyTheme {
DisplayScreen(
modifier = Modifier,
onBackClick = {}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package com.example.speechbuddy.compose.settings
import androidx.compose.runtime.Composable

@Composable
fun ManageSymbolScreen() {
fun MySymbolSettings() {

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 = "[email protected]",
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
}

0 comments on commit d9f1948

Please sign in to comment.