@@ -20,15 +20,12 @@ package com.rwmobi.kunigami.ui.destinations.account
2020import androidx.compose.desktop.ui.tooling.preview.Preview
2121import androidx.compose.foundation.layout.Arrangement
2222import androidx.compose.foundation.layout.Column
23- import androidx.compose.foundation.layout.Row
2423import androidx.compose.foundation.layout.Spacer
2524import androidx.compose.foundation.layout.fillMaxSize
2625import androidx.compose.foundation.layout.fillMaxWidth
2726import androidx.compose.foundation.layout.height
2827import androidx.compose.foundation.layout.padding
29- import androidx.compose.foundation.layout.width
30- import androidx.compose.foundation.layout.wrapContentHeight
31- import androidx.compose.material3.ButtonDefaults
28+ import androidx.compose.material3.Card
3229import androidx.compose.material3.MaterialTheme
3330import androidx.compose.material3.Surface
3431import androidx.compose.material3.Text
@@ -37,37 +34,30 @@ import androidx.compose.runtime.getValue
3734import androidx.compose.runtime.mutableStateOf
3835import androidx.compose.runtime.saveable.rememberSaveable
3936import androidx.compose.runtime.setValue
40- import androidx.compose.ui.Alignment
4137import androidx.compose.ui.Modifier
38+ import androidx.compose.ui.draw.alpha
4239import androidx.compose.ui.text.font.FontWeight
4340import androidx.compose.ui.unit.dp
4441import com.rwmobi.kunigami.domain.extensions.getLocalDateString
4542import com.rwmobi.kunigami.domain.model.account.UserProfile
4643import com.rwmobi.kunigami.ui.components.CommonPreviewSetup
4744import com.rwmobi.kunigami.ui.components.MessageActionScreen
48- import com.rwmobi.kunigami.ui.components.SquareButton
4945import com.rwmobi.kunigami.ui.composehelper.getScreenSizeInfo
46+ import com.rwmobi.kunigami.ui.destinations.account.components.AccountOperationButtonBar
5047import com.rwmobi.kunigami.ui.destinations.account.components.AppInfoFooter
51- import com.rwmobi.kunigami.ui.destinations.account.components.DemoModeConfirmDialog
5248import com.rwmobi.kunigami.ui.destinations.account.components.ElectricityMeterPointCard
5349import com.rwmobi.kunigami.ui.destinations.account.components.UpdateApiKeyDialog
5450import com.rwmobi.kunigami.ui.model.SpecialErrorScreen
5551import com.rwmobi.kunigami.ui.previewsampledata.AccountSamples
5652import com.rwmobi.kunigami.ui.theme.AppTheme
5753import com.rwmobi.kunigami.ui.theme.getDimension
5854import kunigami.composeapp.generated.resources.Res
59- import kunigami.composeapp.generated.resources.account_clear_cache
6055import kunigami.composeapp.generated.resources.account_clear_credential_title
61- import kunigami.composeapp.generated.resources.account_demo_mode
6256import kunigami.composeapp.generated.resources.account_error_account_empty
6357import kunigami.composeapp.generated.resources.account_moved_in
6458import kunigami.composeapp.generated.resources.account_moved_out
6559import kunigami.composeapp.generated.resources.account_number
6660import kunigami.composeapp.generated.resources.account_unknown_installation_address
67- import kunigami.composeapp.generated.resources.account_update_api_key
68- import kunigami.composeapp.generated.resources.database_remove_outline
69- import kunigami.composeapp.generated.resources.eraser
70- import kunigami.composeapp.generated.resources.key
7161import kunigami.composeapp.generated.resources.retry
7262import kunigami.composeapp.generated.resources.unlink
7363import org.jetbrains.compose.resources.ExperimentalResourceApi
@@ -98,39 +88,62 @@ internal fun AccountInformationScreen(
9888 onSecondaryButtonClicked = uiEvent.onClearCredentialButtonClicked,
9989 )
10090 } else {
101- Spacer (modifier = Modifier .height(height = dimension.grid_2))
102-
103- Text (
104- style = MaterialTheme .typography.headlineMedium,
105- fontWeight = FontWeight .Bold ,
106- maxLines = 1 ,
107- text = stringResource(resource = Res .string.account_number, uiState.userProfile.account.accountNumber),
108- )
109-
110- uiState.userProfile.account.fullAddress?.let {
111- Text (
112- style = MaterialTheme .typography.bodyLarge,
113- text = it,
114- )
115- } ? : run {
116- Text (
117- style = MaterialTheme .typography.bodyLarge,
118- text = stringResource(resource = Res .string.account_unknown_installation_address),
119- )
120- }
121-
122- uiState.userProfile.account.movedInAt?.let {
123- Text (
124- style = MaterialTheme .typography.bodyMedium,
125- text = stringResource(resource = Res .string.account_moved_in, it.getLocalDateString()),
126- )
127- }
128-
129- uiState.userProfile.account.movedOutAt?.let {
130- Text (
131- style = MaterialTheme .typography.bodyMedium,
132- text = stringResource(resource = Res .string.account_moved_out, it.getLocalDateString()),
133- )
91+ Spacer (modifier = Modifier .height(height = dimension.grid_1))
92+
93+ Card (
94+ modifier = Modifier .fillMaxWidth(),
95+ ) {
96+ Column (
97+ modifier = Modifier
98+ .fillMaxWidth()
99+ .padding(dimension.grid_2),
100+ verticalArrangement = Arrangement .spacedBy(dimension.grid_2),
101+ ) {
102+ Column {
103+ Text (
104+ style = MaterialTheme .typography.titleLarge,
105+ fontWeight = FontWeight .Bold ,
106+ maxLines = 1 ,
107+ text = " Welcome back ${uiState.userProfile.account.preferredName} !" ,
108+ )
109+
110+ Text (
111+ modifier = Modifier .alpha(0.5f ),
112+ style = MaterialTheme .typography.bodyLarge,
113+ fontWeight = FontWeight .Bold ,
114+ maxLines = 1 ,
115+ text = stringResource(resource = Res .string.account_number, uiState.userProfile.account.accountNumber),
116+ )
117+ }
118+
119+ uiState.userProfile.account.fullAddress?.let {
120+ Text (
121+ style = MaterialTheme .typography.bodyLarge,
122+ text = it,
123+ )
124+ } ? : run {
125+ Text (
126+ style = MaterialTheme .typography.bodyLarge,
127+ text = stringResource(resource = Res .string.account_unknown_installation_address),
128+ )
129+ }
130+
131+ Column {
132+ uiState.userProfile.account.movedInAt?.let {
133+ Text (
134+ style = MaterialTheme .typography.bodyMedium,
135+ text = stringResource(resource = Res .string.account_moved_in, it.getLocalDateString()),
136+ )
137+ }
138+
139+ uiState.userProfile.account.movedOutAt?.let {
140+ Text (
141+ style = MaterialTheme .typography.bodyMedium,
142+ text = stringResource(resource = Res .string.account_moved_out, it.getLocalDateString()),
143+ )
144+ }
145+ }
146+ }
134147 }
135148
136149 uiState.userProfile.account.electricityMeterPoints.forEach { meterPoint ->
@@ -158,61 +171,11 @@ internal fun AccountInformationScreen(
158171 )
159172 }
160173
161- var shouldShowDemoModeConfirmDialog by rememberSaveable { mutableStateOf(false ) }
162- Row (
163- modifier = Modifier .fillMaxWidth(),
164- verticalAlignment = Alignment .Top ,
165- horizontalArrangement = Arrangement .spacedBy(
166- dimension.grid_4,
167- alignment = Alignment .CenterHorizontally ,
168- ),
169- ) {
170- SquareButton (
171- modifier = Modifier
172- .width(width = 80 .dp)
173- .wrapContentHeight(),
174- icon = painterResource(resource = Res .drawable.key),
175- text = stringResource(resource = Res .string.account_update_api_key),
176- colors = ButtonDefaults .buttonColors().copy(
177- containerColor = MaterialTheme .colorScheme.secondaryContainer,
178- contentColor = MaterialTheme .colorScheme.onSecondaryContainer,
179- ),
180- onClick = { isUpdateAPIKeyDialogOpened = true },
181- )
182-
183- SquareButton (
184- modifier = Modifier
185- .width(width = 80 .dp)
186- .wrapContentHeight(),
187- icon = painterResource(resource = Res .drawable.database_remove_outline),
188- text = stringResource(resource = Res .string.account_clear_cache),
189- colors = ButtonDefaults .buttonColors().copy(
190- containerColor = MaterialTheme .colorScheme.secondaryContainer,
191- contentColor = MaterialTheme .colorScheme.onSecondaryContainer,
192- ),
193- onClick = { uiEvent.onClearCache { getString(resource = it) } },
194- )
195-
196- SquareButton (
197- modifier = Modifier
198- .width(width = 80 .dp)
199- .wrapContentHeight(),
200- icon = painterResource(resource = Res .drawable.eraser),
201- text = stringResource(resource = Res .string.account_demo_mode),
202- colors = ButtonDefaults .buttonColors().copy(
203- containerColor = MaterialTheme .colorScheme.secondaryContainer,
204- contentColor = MaterialTheme .colorScheme.onSecondaryContainer,
205- ),
206- onClick = { shouldShowDemoModeConfirmDialog = true },
207- )
208- }
209-
210- if (shouldShowDemoModeConfirmDialog) {
211- DemoModeConfirmDialog (
212- onSwitchToDemoMode = uiEvent.onClearCredentialButtonClicked,
213- onCancel = { shouldShowDemoModeConfirmDialog = false },
214- )
215- }
174+ AccountOperationButtonBar (
175+ onUpdateApiKey = { isUpdateAPIKeyDialogOpened = true },
176+ onClearCache = { uiEvent.onClearCache { getString(resource = it) } },
177+ onSwitchToDemoMode = { uiEvent.onClearCredentialButtonClicked },
178+ )
216179
217180 AppInfoFooter (modifier = Modifier .fillMaxWidth())
218181 }
0 commit comments