Skip to content

Commit

Permalink
fix: 优化界面UI
Browse files Browse the repository at this point in the history
- 为用户选择栏添加了surfaceContainer背景色
  • Loading branch information
Mystery00 committed Sep 4, 2024
1 parent c5f3019 commit 683ad5a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package vip.mystery0.xhu.timetable.base

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilterChip
Expand All @@ -12,6 +14,7 @@ import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.list.ListDialog
Expand All @@ -20,10 +23,11 @@ import com.maxkeppeler.sheets.list.models.ListSelection
import kotlinx.coroutines.launch
import vip.mystery0.xhu.timetable.ui.component.XhuDialogState
import vip.mystery0.xhu.timetable.ui.component.rememberXhuDialogState
import vip.mystery0.xhu.timetable.ui.theme.ExtendedTheme
import vip.mystery0.xhu.timetable.ui.theme.XhuIcons

abstract class BaseSelectComposeActivity : BasePageComposeActivity() {
@OptIn(ExperimentalLayoutApi::class, ExperimentalMaterial3Api::class)
@OptIn(ExperimentalLayoutApi::class)
@Composable
protected fun BuildUserSelectFilterChipContent(
userSelect: List<UserSelect>,
Expand All @@ -48,7 +52,6 @@ abstract class BaseSelectComposeActivity : BasePageComposeActivity() {
onDataLoad()
}
},
contentPadding = PaddingValues(2.dp),
shape = RoundedCornerShape(36.dp),
) {
Icon(painter = XhuIcons.Action.search, contentDescription = null)
Expand All @@ -64,7 +67,12 @@ abstract class BaseSelectComposeActivity : BasePageComposeActivity() {
onDataLoad: suspend () -> Unit,
) {
val scope = rememberCoroutineScope()
FlowRow(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
FlowRow(
horizontalArrangement = Arrangement.spacedBy(4.dp),
modifier = Modifier
.fillMaxWidth()
.background(ExtendedTheme.colorScheme.surfaceContainer),
) {
FilterChip(
selected = true,
onClick = {
Expand All @@ -81,7 +89,6 @@ abstract class BaseSelectComposeActivity : BasePageComposeActivity() {
onDataLoad()
}
},
contentPadding = PaddingValues(2.dp),
shape = RoundedCornerShape(36.dp),
) {
Icon(painter = XhuIcons.Action.search, contentDescription = null)
Expand All @@ -101,7 +108,12 @@ abstract class BaseSelectComposeActivity : BasePageComposeActivity() {
onDataLoad: suspend () -> Unit,
) {
val scope = rememberCoroutineScope()
FlowRow(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
FlowRow(
horizontalArrangement = Arrangement.spacedBy(4.dp),
modifier = Modifier
.fillMaxWidth()
.background(ExtendedTheme.colorScheme.surfaceContainer),
) {
FilterChip(
selected = true,
onClick = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package vip.mystery0.xhu.timetable.ui.activity
import androidx.activity.compose.BackHandler
import androidx.activity.viewModels
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
Expand Down Expand Up @@ -43,7 +43,7 @@ import vip.mystery0.xhu.timetable.viewmodel.ExamViewModel
class ExamActivity : BaseSelectComposeActivity() {
private val viewModel: ExamViewModel by viewModels()

@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
@Composable
override fun BuildContent() {
val pager = viewModel.pageState.collectAndHandleState(viewModel::handleLoadState)
Expand Down Expand Up @@ -92,9 +92,11 @@ class ExamActivity : BaseSelectComposeActivity() {
}
)
},
itemContent = @Composable { item ->
BuildItem(item)
}
listContent = {
itemsIndexed(pager) { item ->
BuildItem(item)
}
},
)
}
ShowUserDialog(selectList = userSelect, show = userDialog, onSelect = {
Expand Down

0 comments on commit 683ad5a

Please sign in to comment.