-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge pull request #17 from snuhcs-course/feat/settings-frontend
Feat/settings-frontend
- Loading branch information
Showing
33 changed files
with
1,318 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
frontend/app/src/main/java/com/example/speechbuddy/compose/settings/AccountSettings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
package com.example.speechbuddy.compose.settings | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.PaddingValues | ||
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, | ||
bottomPaddingValues: PaddingValues, | ||
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 | ||
) | ||
} | ||
) { topPaddingValues -> | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding( | ||
top = topPaddingValues.calculateTopPadding(), | ||
bottom = bottomPaddingValues.calculateBottomPadding() | ||
) | ||
.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() } | ||
) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.