Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Optimize WorkingModeScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
SanmerDev committed Nov 24, 2023
1 parent cbedf57 commit 9d3b3d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeightIn
import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
Expand All @@ -29,17 +31,21 @@ fun WorkingModeItem(
selected: Boolean = false,
onClick: () -> Unit
) = Box(
modifier = modifier.fillMaxWidth(0.65f)
modifier = Modifier
.requiredWidth(240.dp)
.then(modifier)
) {
Surface(
onClick = onClick,
modifier = modifier.fillMaxWidth(),
tonalElevation = if (selected) 4.dp else 0.dp,
border = BorderStroke(1.dp, color = MaterialTheme.colorScheme.outline),
shape = RoundedCornerShape(15.dp)
) {
Column(
modifier = Modifier.padding(all = 16.dp)
modifier = Modifier
.padding(all = 16.dp)
.requiredHeightIn(min = 120.dp)
.fillMaxWidth()
) {
Text(
text = title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ package com.sanmer.mrepo.ui.screens.settings.workingmode

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Scaffold
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.TopAppBarScrollBehavior
Expand Down Expand Up @@ -44,29 +48,27 @@ fun WorkingModeScreen(
Column(
modifier = Modifier
.padding(innerPadding)
.padding(top = 20.dp)
.fillMaxSize(),
.fillMaxSize()
.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(20.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Spacer(modifier = Modifier.height(20.dp))

WorkingModeItem(
title = stringResource(id = R.string.setup_root_title),
desc1 = stringResource(id = R.string.setup_root_desc1),
desc2 = stringResource(id = R.string.setup_root_desc2),
selected = userPreferences.isRoot,
onClick = {
viewModel.setWorkingMode(WorkingMode.MODE_ROOT)
}
onClick = { viewModel.setWorkingMode(WorkingMode.MODE_ROOT) }
)

WorkingModeItem(
title = stringResource(id = R.string.setup_non_root_title),
desc1 = stringResource(id = R.string.setup_non_root_desc1),
desc2 = stringResource(id = R.string.setup_non_root_desc2),
selected = userPreferences.isNonRoot,
onClick = {
viewModel.setWorkingMode(WorkingMode.MODE_NON_ROOT)
}
onClick = { viewModel.setWorkingMode(WorkingMode.MODE_NON_ROOT) }
)
}
}
Expand Down

0 comments on commit 9d3b3d3

Please sign in to comment.