Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/settings-frontend #17

Merged
merged 28 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8507b54
:lipstick:Add settings utils elements
89645321 Oct 27, 2023
9af8a8f
:lipstick: Implement settings screen
prime2do Oct 27, 2023
1a33304
:art: Modify structure of settings screen
prime2do Oct 27, 2023
3219924
:lipstick: Implement settings_account screen
prime2do Oct 27, 2023
c2b01e5
:lipstick: Add BackupScreen, DisplayScreen
89645321 Oct 27, 2023
b41da23
Merge branch 'feat/settings-frontend' of github.com:snuhcs-course/swp…
89645321 Oct 27, 2023
66998a9
:lipstick: Add VersionInfoScreen, DeveloperInfoScreen
89645321 Oct 27, 2023
02f8fd5
:lipstick: Integrate settings screen
prime2do Oct 27, 2023
4fefde7
:lipstick: Modify screens in settings
89645321 Oct 29, 2023
ef8a35a
:lipstick: Add BackupViewModel, DisplayViewModel, UserSettingsViewModel
89645321 Oct 29, 2023
13976e9
:lipstick: Add BackupViewModel, DisplayViewModel, UserSettingsViewMod…
89645321 Oct 29, 2023
b08d9e1
:art: Refactor structure of settingsScreen
prime2do Nov 1, 2023
eebad37
:truck: Refactor alert dialog ui & back button ui
sukchan-0811 Nov 2, 2023
f76ff48
:bug: Fix user settings screen
sukchan-0811 Nov 2, 2023
d9f1948
:recycle: Refactor settings related screens
sukchan-0811 Nov 2, 2023
d387d08
:sparkles: Implement home top app bar ui
sukchan-0811 Nov 2, 2023
bffa1fc
:sparkles: Implement home top app bar ui
sukchan-0811 Nov 2, 2023
58ff608
:sparkles: Apply home top app bar ui to home screens
sukchan-0811 Nov 2, 2023
1c1747d
:ambulance: Re-add files that have been lost
sukchan-0811 Nov 2, 2023
7c28c7d
:recycle: Separate main settings from settings screen
sukchan-0811 Nov 2, 2023
7ed44a1
:recycle: Refactor account settings
sukchan-0811 Nov 2, 2023
a2adb2b
:recycle: Refactor backup settings
sukchan-0811 Nov 2, 2023
f4b2be4
:recycle: Refactor display settings
sukchan-0811 Nov 2, 2023
80416aa
:recycle: Refactor version & developers info
sukchan-0811 Nov 2, 2023
6c229dc
:twisted_rightwards_arrows: Merge branch 'main' into feat/settings-fr…
sukchan-0811 Nov 2, 2023
08ae175
Merge branch 'main' into feat/settings-frontend
sukchan-0811 Nov 2, 2023
4efda96
:lipstick: Remove ripple effect in buttons
sukchan-0811 Nov 3, 2023
abe3da8
:lipstick: Calculate bottom padding values
sukchan-0811 Nov 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
import com.example.speechbuddy.R
import com.example.speechbuddy.compose.utils.AuthTopAppBarUi
import com.example.speechbuddy.compose.utils.ButtonLevel
import com.example.speechbuddy.compose.utils.ButtonUi
import com.example.speechbuddy.compose.utils.TextFieldUi
import com.example.speechbuddy.compose.utils.TitleUi
import com.example.speechbuddy.compose.utils.TopAppBarUi
import com.example.speechbuddy.ui.models.EmailVerificationErrorType
import com.example.speechbuddy.viewmodel.EmailVerificationViewModel

Expand All @@ -47,7 +47,9 @@ fun EmailVerificationScreen(
Surface(
modifier = modifier.fillMaxSize()
) {
Scaffold(topBar = { TopAppBarUi(onBackClick = onBackClick) }) {
Scaffold(
topBar = { AuthTopAppBarUi(onBackClick = onBackClick) }
) {
Column(
modifier = Modifier
.fillMaxSize()
Expand All @@ -72,7 +74,7 @@ fun EmailVerificationScreen(
// Email Text Field
TextFieldUi(value = viewModel.emailInput,
onValueChange = { viewModel.setEmail(it) },
label = { Text(text = stringResource(id = R.string.email_field)) },
label = { Text(text = stringResource(id = R.string.email)) },
supportingButton = {
ButtonUi(
text = stringResource(id = R.string.send_validation_code),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.example.speechbuddy.compose.settings.SettingsScreen
import com.example.speechbuddy.compose.symbolcreation.SymbolCreationScreen
import com.example.speechbuddy.compose.symbolselection.SymbolSelectionScreen
import com.example.speechbuddy.compose.texttospeech.TextToSpeechScreen
import com.example.speechbuddy.compose.utils.HomeTopAppBarUi
import com.example.speechbuddy.ui.SpeechBuddyTheme

data class BottomNavItem(
Expand All @@ -44,12 +45,12 @@ fun HomeScreen(
val navItems = listOf(
BottomNavItem(
"symbol_selection",
R.string.symbol_selection,
R.string.talk_with_symbols,
R.drawable.outline_touch_app_24
),
BottomNavItem(
"text_to_speech",
R.string.text_to_speech,
R.string.talk_with_speech,
R.drawable.outline_volume_up_24
),
BottomNavItem(
Expand All @@ -69,8 +70,6 @@ fun HomeScreen(
BottomNavigationBar(
items = navItems,
navController = navController,
modifier = Modifier
.height(100.dp),
onItemClick = {
navController.navigate(it.route)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.example.speechbuddy.R
import com.example.speechbuddy.compose.utils.AuthTopAppBarUi
import com.example.speechbuddy.compose.utils.ButtonLevel
import com.example.speechbuddy.compose.utils.ButtonUi
import com.example.speechbuddy.compose.utils.TextFieldUi
import com.example.speechbuddy.compose.utils.TitleUi
import com.example.speechbuddy.compose.utils.TopAppBarUi
import com.example.speechbuddy.ui.models.LoginErrorType
import com.example.speechbuddy.viewmodel.LoginViewModel

Expand All @@ -46,7 +46,7 @@ fun LoginScreen(

Surface(modifier = modifier.fillMaxSize()) {
Scaffold(
topBar = { TopAppBarUi(onBackClick = onBackClick) }
topBar = { AuthTopAppBarUi(onBackClick = onBackClick) }
) {
Column(
modifier = Modifier
Expand All @@ -66,7 +66,7 @@ fun LoginScreen(
TextFieldUi(
value = viewModel.emailInput,
onValueChange = { viewModel.setEmail(it) },
label = { Text(stringResource(id = R.string.email_field)) },
label = { Text(stringResource(id = R.string.email)) },
supportingText = {
if (isEmailError) {
Text(stringResource(id = uiState.error!!.messageId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.example.speechbuddy.compose.utils.ButtonLevel
import com.example.speechbuddy.compose.utils.ButtonUi
import com.example.speechbuddy.compose.utils.TextFieldUi
import com.example.speechbuddy.compose.utils.TitleUi
import com.example.speechbuddy.compose.utils.TopAppBarUi
import com.example.speechbuddy.compose.utils.AuthTopAppBarUi
import com.example.speechbuddy.ui.models.ResetPasswordErrorType
import com.example.speechbuddy.viewmodel.ResetPasswordViewModel

Expand All @@ -48,7 +48,7 @@ fun ResetPasswordScreen(
) {
Scaffold(
topBar = {
TopAppBarUi(
AuthTopAppBarUi(
onBackClick = onBackClick
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
package com.example.speechbuddy.compose.settings

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.example.speechbuddy.R
import com.example.speechbuddy.compose.utils.AlertDialogUi
import com.example.speechbuddy.compose.utils.ButtonLevel
import com.example.speechbuddy.compose.utils.ButtonUi
import com.example.speechbuddy.compose.utils.HomeTopAppBarUi
import com.example.speechbuddy.compose.utils.TitleUi
import com.example.speechbuddy.ui.models.AccountSettingsAlert
import com.example.speechbuddy.viewmodel.AccountSettingsViewModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AccountSettings(
modifier: Modifier = Modifier,
onBackClick: () -> Unit,
viewModel: AccountSettingsViewModel = hiltViewModel()
) {
val uiState by viewModel.uiState.collectAsState()

Surface(
modifier = modifier.fillMaxSize()
) {
Scaffold(
topBar = {
HomeTopAppBarUi(
title = stringResource(id = R.string.settings),
onBackClick = onBackClick,
isBackClickEnabled = true
)
}
) { paddingValues ->
Column(
modifier = Modifier
.fillMaxSize()
.padding(top = paddingValues.calculateTopPadding())
.padding(24.dp),
verticalArrangement = Arrangement.Center
) {
TitleUi(title = stringResource(id = R.string.account))

Spacer(modifier = Modifier.height(20.dp))

Column(
verticalArrangement = Arrangement.spacedBy(10.dp)
) {
SettingsRow(
label = stringResource(id = R.string.email),
content = {
SettingsRowText(text = uiState.email)
}
)

SettingsRow(
label = stringResource(id = R.string.nickname),
content = {
SettingsRowText(text = uiState.nickname)
}
)
}

Spacer(modifier = Modifier.height(80.dp))

Column(
verticalArrangement = Arrangement.spacedBy(14.dp)
) {
ButtonUi(
text = stringResource(id = R.string.logout),
onClick = { viewModel.showAlert(AccountSettingsAlert.LOGOUT) }
)

ButtonUi(
text = stringResource(id = R.string.withdraw),
onClick = { viewModel.showAlert(AccountSettingsAlert.WITHDRAW) },
level = ButtonLevel.QUATERNARY
)
}
}
}
}

uiState.alert?.let { alert ->
when (alert) {
AccountSettingsAlert.LOGOUT -> {
AlertDialogUi(
title = stringResource(id = R.string.logout),
text = stringResource(id = R.string.logout_warning),
dismissButtonText = stringResource(id = R.string.dismiss),
confirmButtonText = stringResource(id = R.string.logout),
onDismiss = { viewModel.hideAlert() },
onConfirm = { viewModel.logout() }
)
}

AccountSettingsAlert.WITHDRAW -> {
AlertDialogUi(
title = stringResource(id = R.string.withdraw),
text = stringResource(id = R.string.withdraw_warning),
dismissButtonText = stringResource(id = R.string.dismiss),
confirmButtonText = stringResource(id = R.string.proceed),
onDismiss = { viewModel.hideAlert() },
onConfirm = {
viewModel.showAlert(AccountSettingsAlert.WITHDRAW_PROCEED)
}
)
}

AccountSettingsAlert.WITHDRAW_PROCEED -> {
AlertDialogUi(
title = stringResource(id = R.string.withdraw),
text = stringResource(id = R.string.withdraw_proceed_warning),
dismissButtonText = stringResource(id = R.string.dismiss),
confirmButtonText = stringResource(id = R.string.withdraw),
onDismiss = { viewModel.hideAlert() },
onConfirm = { viewModel.deleteAccount() }
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.example.speechbuddy.compose.settings

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.example.speechbuddy.R
import com.example.speechbuddy.compose.utils.ButtonUi
import com.example.speechbuddy.compose.utils.HomeTopAppBarUi
import com.example.speechbuddy.compose.utils.TitleUi
import com.example.speechbuddy.viewmodel.BackupSettingsViewModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun BackupSettings(
modifier: Modifier = Modifier,
onBackClick: () -> Unit,
viewModel: BackupSettingsViewModel = hiltViewModel()
) {
val uiState by viewModel.uiState.collectAsState()

Surface(
modifier = modifier.fillMaxSize()
) {
Scaffold(topBar = {
HomeTopAppBarUi(
title = stringResource(id = R.string.settings),
onBackClick = onBackClick,
isBackClickEnabled = true
)
}) { paddingValues ->
Column(
modifier = Modifier
.fillMaxSize()
.padding(top = paddingValues.calculateTopPadding())
.padding(24.dp), verticalArrangement = Arrangement.Center
) {
TitleUi(title = stringResource(id = R.string.backup_to_server))

Spacer(modifier = Modifier.height(20.dp))

Column(
verticalArrangement = Arrangement.spacedBy(10.dp)
) {
SettingsRow(
label = stringResource(id = R.string.last_backup_date),
content = {
SettingsRowText(text = uiState.lastBackupDate)
}
)

SettingsRow(label = stringResource(id = R.string.enable_auto_backup),
content = {
Switch(
checked = uiState.isAutoBackupEnabled,
onCheckedChange = { viewModel.setAutoBackup(it) },
modifier = Modifier.heightIn(max = 32.dp)
)
}
)
}

Spacer(modifier = Modifier.height(80.dp))

ButtonUi(
text = stringResource(id = R.string.backup_now),
onClick = { viewModel.backup() }
)
}
}
}
}
Loading