Cleanup SelectSiteScreen
This commit is contained in:
1 parent
5977d77381
commit
2f69b942d9
1 file changed
+32
-48
@@ -9,12 +9,15 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.IntrinsicSize
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.asPaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.systemBars
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Button
|
||||
@@ -55,10 +58,7 @@ fun SelectSiteScreen() {
|
||||
}
|
||||
|
||||
Column(
|
||||
Modifier
|
||||
.padding(horizontal = dimensionResource(R.dimen.keyline_margin))
|
||||
.padding(top = dimensionResource(R.dimen.keyline_margin))
|
||||
.fillMaxSize(),
|
||||
modifier = Modifier.padding(WindowInsets.systemBars.asPaddingValues()).padding(horizontal = dimensionResource(R.dimen.keyline_margin)).padding(top = dimensionResource(R.dimen.keyline_margin)).fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Text(
|
||||
@@ -70,20 +70,14 @@ fun SelectSiteScreen() {
|
||||
// TODO: Replace this dummy impl with official one when available
|
||||
// See https://m3.material.io/components/segmented-buttons/overview
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.height(IntrinsicSize.Min)
|
||||
.border(
|
||||
1.dp,
|
||||
MaterialTheme.colorScheme.outline,
|
||||
RoundedCornerShape(90f, 90f, 90f, 90f),
|
||||
)
|
||||
.clip(RoundedCornerShape(90f, 90f, 90f, 90f)),
|
||||
modifier = Modifier.height(IntrinsicSize.Min).border(
|
||||
1.dp,
|
||||
MaterialTheme.colorScheme.outline,
|
||||
RoundedCornerShape(90f, 90f, 90f, 90f),
|
||||
).clip(RoundedCornerShape(90f, 90f, 90f, 90f)),
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.background(if (!siteEx) MaterialTheme.colorScheme.secondaryContainer else MaterialTheme.colorScheme.surface)
|
||||
.clickable { siteEx = false }
|
||||
.size(100.dp, 40.dp),
|
||||
modifier = Modifier.background(if (!siteEx) MaterialTheme.colorScheme.secondaryContainer else MaterialTheme.colorScheme.surface).clickable { siteEx = false }.size(100.dp, 40.dp),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Text(
|
||||
@@ -91,19 +85,12 @@ fun SelectSiteScreen() {
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
)
|
||||
}
|
||||
|
||||
Divider(
|
||||
color = MaterialTheme.colorScheme.outline,
|
||||
modifier = Modifier
|
||||
.fillMaxHeight()
|
||||
.width(1.dp),
|
||||
modifier = Modifier.fillMaxHeight().width(1.dp),
|
||||
)
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.background(if (siteEx) MaterialTheme.colorScheme.secondaryContainer else MaterialTheme.colorScheme.surface)
|
||||
.clickable { siteEx = true }
|
||||
.size(100.dp, 40.dp),
|
||||
modifier = Modifier.background(if (siteEx) MaterialTheme.colorScheme.secondaryContainer else MaterialTheme.colorScheme.surface).clickable { siteEx = true }.size(100.dp, 40.dp),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Text(
|
||||
@@ -118,32 +105,29 @@ fun SelectSiteScreen() {
|
||||
text = stringResource(id = R.string.select_scene_explain),
|
||||
modifier = Modifier.padding(top = 16.dp),
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 12.dp)
|
||||
.padding(top = 4.dp, bottom = 20.dp)
|
||||
.fillMaxWidth(),
|
||||
) {
|
||||
Button(onClick = {
|
||||
Settings.selectSite = false
|
||||
Settings.needSignIn = false
|
||||
coroutineScope.launchNonCancellable {
|
||||
runCatching {
|
||||
if (!siteEx) {
|
||||
Settings.gallerySite = EhUrl.SITE_E
|
||||
EhEngine.getUConfig()
|
||||
} else {
|
||||
// Get cookies for image limits
|
||||
EhEngine.getUConfig(EhUrl.URL_UCONFIG_E)
|
||||
Box(modifier = Modifier.padding(horizontal = 12.dp).padding(top = 4.dp, bottom = 20.dp).fillMaxWidth()) {
|
||||
Button(
|
||||
onClick = {
|
||||
Settings.selectSite = false
|
||||
Settings.needSignIn = false
|
||||
coroutineScope.launchNonCancellable {
|
||||
runCatching {
|
||||
if (!siteEx) {
|
||||
Settings.gallerySite = EhUrl.SITE_E
|
||||
EhEngine.getUConfig()
|
||||
} else {
|
||||
// Get cookies for image limits
|
||||
EhEngine.getUConfig(EhUrl.URL_UCONFIG_E)
|
||||
}
|
||||
}.onFailure {
|
||||
it.printStackTrace()
|
||||
}
|
||||
}.onFailure {
|
||||
it.printStackTrace()
|
||||
}
|
||||
}
|
||||
activity.finish()
|
||||
}, Modifier.fillMaxWidth()) {
|
||||
activity.finish()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Text(text = stringResource(id = android.R.string.ok))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user