From 683ad5a9bfba8964425152b0ebad57f0aaeed1b6 Mon Sep 17 00:00:00 2001 From: Mystery0 Date: Thu, 5 Sep 2024 00:25:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E7=95=8C=E9=9D=A2UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为用户选择栏添加了surfaceContainer背景色 --- .../base/BaseSelectComposeActivity.kt | 22 ++++++++++++++----- .../xhu/timetable/ui/activity/ExamActivity.kt | 12 +++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/vip/mystery0/xhu/timetable/base/BaseSelectComposeActivity.kt b/app/src/main/java/vip/mystery0/xhu/timetable/base/BaseSelectComposeActivity.kt index 0935b24..0c16744 100644 --- a/app/src/main/java/vip/mystery0/xhu/timetable/base/BaseSelectComposeActivity.kt +++ b/app/src/main/java/vip/mystery0/xhu/timetable/base/BaseSelectComposeActivity.kt @@ -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 @@ -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 @@ -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, @@ -48,7 +52,6 @@ abstract class BaseSelectComposeActivity : BasePageComposeActivity() { onDataLoad() } }, - contentPadding = PaddingValues(2.dp), shape = RoundedCornerShape(36.dp), ) { Icon(painter = XhuIcons.Action.search, contentDescription = null) @@ -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 = { @@ -81,7 +89,6 @@ abstract class BaseSelectComposeActivity : BasePageComposeActivity() { onDataLoad() } }, - contentPadding = PaddingValues(2.dp), shape = RoundedCornerShape(36.dp), ) { Icon(painter = XhuIcons.Action.search, contentDescription = null) @@ -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 = { diff --git a/app/src/main/java/vip/mystery0/xhu/timetable/ui/activity/ExamActivity.kt b/app/src/main/java/vip/mystery0/xhu/timetable/ui/activity/ExamActivity.kt index 39db761..909f649 100644 --- a/app/src/main/java/vip/mystery0/xhu/timetable/ui/activity/ExamActivity.kt +++ b/app/src/main/java/vip/mystery0/xhu/timetable/ui/activity/ExamActivity.kt @@ -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 @@ -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) @@ -92,9 +92,11 @@ class ExamActivity : BaseSelectComposeActivity() { } ) }, - itemContent = @Composable { item -> - BuildItem(item) - } + listContent = { + itemsIndexed(pager) { item -> + BuildItem(item) + } + }, ) } ShowUserDialog(selectList = userSelect, show = userDialog, onSelect = {