mirror of https://github.com/readrops/Readrops.git
Improve AccountSelectionScreen UI
This commit is contained in:
parent
ba7b2b7108
commit
36d9aef2bb
|
@ -29,6 +29,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import cafe.adriel.voyager.koin.getScreenModel
|
import cafe.adriel.voyager.koin.getScreenModel
|
||||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||||
|
import com.readrops.app.BuildConfig
|
||||||
import com.readrops.app.R
|
import com.readrops.app.R
|
||||||
import com.readrops.app.account.credentials.AccountCredentialsScreen
|
import com.readrops.app.account.credentials.AccountCredentialsScreen
|
||||||
import com.readrops.app.account.credentials.AccountCredentialsScreenMode
|
import com.readrops.app.account.credentials.AccountCredentialsScreenMode
|
||||||
|
@ -36,6 +37,7 @@ import com.readrops.app.home.HomeScreen
|
||||||
import com.readrops.app.util.components.AndroidScreen
|
import com.readrops.app.util.components.AndroidScreen
|
||||||
import com.readrops.app.util.components.SelectableImageText
|
import com.readrops.app.util.components.SelectableImageText
|
||||||
import com.readrops.app.util.theme.LargeSpacer
|
import com.readrops.app.util.theme.LargeSpacer
|
||||||
|
import com.readrops.app.util.theme.MediumSpacer
|
||||||
import com.readrops.app.util.theme.ShortSpacer
|
import com.readrops.app.util.theme.ShortSpacer
|
||||||
import com.readrops.app.util.theme.spacing
|
import com.readrops.app.util.theme.spacing
|
||||||
import com.readrops.db.entities.account.Account
|
import com.readrops.db.entities.account.Account
|
||||||
|
@ -58,20 +60,32 @@ class AccountSelectionScreen : AndroidScreen() {
|
||||||
|
|
||||||
is NavState.GoToAccountCredentialsScreen -> {
|
is NavState.GoToAccountCredentialsScreen -> {
|
||||||
val accountType = (state as NavState.GoToAccountCredentialsScreen).accountType
|
val accountType = (state as NavState.GoToAccountCredentialsScreen).accountType
|
||||||
val account = Account(accountType = accountType, accountName = stringResource(id = accountType.typeName))
|
val account = Account(
|
||||||
|
accountType = accountType,
|
||||||
|
accountName = stringResource(id = accountType.typeName)
|
||||||
|
)
|
||||||
|
|
||||||
navigator.push(AccountCredentialsScreen(account, AccountCredentialsScreenMode.NEW_CREDENTIALS))
|
navigator.push(
|
||||||
|
AccountCredentialsScreen(
|
||||||
|
account,
|
||||||
|
AccountCredentialsScreenMode.NEW_CREDENTIALS
|
||||||
|
)
|
||||||
|
)
|
||||||
screenModel.resetNavState()
|
screenModel.resetNavState()
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxSize()
|
||||||
|
) {
|
||||||
Column(
|
Column(
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
verticalArrangement = Arrangement.Center,
|
verticalArrangement = Arrangement.Center,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
|
.weight(1f)
|
||||||
.padding(MaterialTheme.spacing.mediumSpacing)
|
.padding(MaterialTheme.spacing.mediumSpacing)
|
||||||
) {
|
) {
|
||||||
Image(
|
Image(
|
||||||
|
@ -95,32 +109,74 @@ class AccountSelectionScreen : AndroidScreen() {
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(id = R.string.choose_account),
|
text = stringResource(id = R.string.choose_account),
|
||||||
style = MaterialTheme.typography.labelLarge
|
style = MaterialTheme.typography.titleMedium,
|
||||||
|
modifier = Modifier.align(Alignment.CenterHorizontally)
|
||||||
)
|
)
|
||||||
|
|
||||||
ShortSpacer()
|
MediumSpacer()
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = stringResource(id = R.string.local),
|
||||||
|
style = MaterialTheme.typography.bodyMedium
|
||||||
|
)
|
||||||
|
|
||||||
AccountType.values().forEach { accountType ->
|
|
||||||
SelectableImageText(
|
SelectableImageText(
|
||||||
image = adaptiveIconPainterResource(id = accountType.iconRes),
|
image = adaptiveIconPainterResource(id = R.mipmap.ic_launcher),
|
||||||
text = stringResource(id = accountType.typeName),
|
text = stringResource(id = AccountType.LOCAL.typeName),
|
||||||
style = MaterialTheme.typography.titleLarge,
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
onClick = { screenModel.createAccount(accountType) },
|
spacing = MaterialTheme.spacing.mediumSpacing,
|
||||||
spacing = MaterialTheme.spacing.shortSpacing,
|
padding = MaterialTheme.spacing.mediumSpacing,
|
||||||
|
imageSize = 24.dp,
|
||||||
|
onClick = { screenModel.createAccount(AccountType.LOCAL) }
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
SelectableImageText(
|
SelectableImageText(
|
||||||
image = adaptiveIconPainterResource(id = R.mipmap.ic_launcher),
|
image = adaptiveIconPainterResource(id = R.mipmap.ic_launcher),
|
||||||
text = stringResource(id = R.string.opml_import),
|
text = stringResource(id = R.string.opml_import),
|
||||||
style = MaterialTheme.typography.titleLarge,
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
onClick = { },
|
spacing = MaterialTheme.spacing.mediumSpacing,
|
||||||
spacing = MaterialTheme.spacing.shortSpacing,
|
padding = MaterialTheme.spacing.mediumSpacing,
|
||||||
|
imageSize = 24.dp,
|
||||||
|
onClick = { }
|
||||||
|
)
|
||||||
|
|
||||||
|
MediumSpacer()
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = "External",
|
||||||
|
style = MaterialTheme.typography.bodyMedium
|
||||||
|
)
|
||||||
|
|
||||||
|
ShortSpacer()
|
||||||
|
|
||||||
|
AccountType.entries.filter { it != AccountType.LOCAL }
|
||||||
|
.forEach { accountType ->
|
||||||
|
SelectableImageText(
|
||||||
|
image = adaptiveIconPainterResource(id = accountType.iconRes),
|
||||||
|
text = stringResource(id = accountType.typeName),
|
||||||
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
|
imageSize = 24.dp,
|
||||||
|
spacing = MaterialTheme.spacing.mediumSpacing,
|
||||||
|
padding = MaterialTheme.spacing.mediumSpacing,
|
||||||
|
onClick = { screenModel.createAccount(accountType) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = "v${BuildConfig.VERSION_NAME}",
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.CenterHorizontally)
|
||||||
|
.padding(bottom = MaterialTheme.spacing.largeSpacing)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// from https://gist.github.com/tkuenneth/ddf598663f041dc79960cda503d14448
|
// from https://gist.github.com/tkuenneth/ddf598663f041dc79960cda503d14448
|
||||||
|
|
Loading…
Reference in New Issue