Skip to content

Commit

Permalink
Merge pull request #1196 from radixdlt/feature/ABW-3268-rename-link-c…
Browse files Browse the repository at this point in the history
…onnector

[ABW-3268] Rename link connector
  • Loading branch information
giannis-rdx authored Sep 16, 2024
2 parents 357ba1a + 32b7f2b commit c08c0a0
Show file tree
Hide file tree
Showing 6 changed files with 331 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
Expand Down Expand Up @@ -120,7 +121,9 @@ fun AccountSettingsScreen(
viewModel.setBottomSheetContent(AccountPreferenceUiState.BottomSheetContent.HideAccount)
bottomSheetState.show()
}
}
},
isAccountNameUpdated = state.isAccountNameUpdated,
onSnackbarMessageShown = viewModel::onSnackbarMessageShown
)

if (state.isBottomSheetVisible) {
Expand Down Expand Up @@ -173,14 +176,29 @@ private fun AccountSettingsContent(
onGetFreeXrdClick: () -> Unit,
faucetState: FaucetState,
isXrdLoading: Boolean,
onHideAccount: () -> Unit
onHideAccount: () -> Unit,
isAccountNameUpdated: Boolean,
onSnackbarMessageShown: () -> Unit,
) {
val snackBarHostState = remember { SnackbarHostState() }
val snackbarHostState = remember { SnackbarHostState() }
SnackbarUIMessage(
message = error,
snackbarHostState = snackBarHostState,
snackbarHostState = snackbarHostState,
onMessageShown = onMessageShown
)

val accountUpdatedText = stringResource(R.string.accountSettings_updatedAccountHUDMessage)
LaunchedEffect(isAccountNameUpdated) {
if (isAccountNameUpdated) {
snackbarHostState.showSnackbar(
message = accountUpdatedText,
duration = SnackbarDuration.Short,
withDismissAction = true
)
onSnackbarMessageShown()
}
}

Scaffold(
modifier = modifier,
topBar = {
Expand All @@ -193,7 +211,7 @@ private fun AccountSettingsContent(
snackbarHost = {
RadixSnackbarHost(
modifier = Modifier.padding(RadixTheme.dimensions.paddingDefault),
hostState = snackBarHostState
hostState = snackbarHostState
)
},
containerColor = RadixTheme.colors.gray5
Expand Down Expand Up @@ -430,7 +448,9 @@ fun AccountSettingsPreview() {
onGetFreeXrdClick = {},
faucetState = FaucetState.Available(isEnabled = true),
isXrdLoading = false,
onHideAccount = {}
onHideAccount = {},
isAccountNameUpdated = false,
onSnackbarMessageShown = {}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class AccountSettingsViewModel @Inject constructor(
accountToRename = it,
newDisplayName = DisplayName(newAccountName)
)
_state.update { state -> state.copy(isAccountNameUpdated = true) }
} ?: Timber.d("Couldn't find account to rename the display name!")
}
}
Expand Down Expand Up @@ -170,6 +171,10 @@ class AccountSettingsViewModel @Inject constructor(
sendEvent(Event.AccountHidden)
}
}

fun onSnackbarMessageShown() {
_state.update { state -> state.copy(isAccountNameUpdated = false) }
}
}

sealed interface Event : OneOffEvent {
Expand All @@ -185,6 +190,7 @@ data class AccountPreferenceUiState(
val bottomSheetContent: BottomSheetContent = BottomSheetContent.None,
val error: UiMessage? = null,
val faucetState: FaucetState = FaucetState.Unavailable,
val isAccountNameUpdated: Boolean = false,
val isFreeXRDLoading: Boolean = false
) : UiState {

Expand Down
Loading

0 comments on commit c08c0a0

Please sign in to comment.