From 37c905f75016610d04b12b85d5f015942890748b Mon Sep 17 00:00:00 2001 From: oxy Date: Sun, 19 Nov 2023 17:22:29 +0800 Subject: [PATCH] fix: replace some unstable parameters. style: fix m3 style. --- androidApp/build.gradle.kts | 4 +- .../androidApp/components/AppNavigation.kt | 7 +- .../java/com/m3u/features/live/LiveScreen.kt | 27 +----- .../java/com/m3u/features/live/LiveState.kt | 2 + .../live/components/DlnaDeviceItem.kt | 4 +- .../live/components/DlnaDevicesBottomSheet.kt | 2 +- .../features/live/fragments/LiveFragment.kt | 32 +++---- .../m3u/features/main/components/FeedItem.kt | 24 ++---- .../com/m3u/features/setting/SettingScreen.kt | 16 ++-- .../setting/fragments/PreferencesFragment.kt | 8 +- .../fragments/SubscriptionsFragment.kt | 7 +- .../m3u/material/components/Preferences.kt | 86 +++++++++---------- .../com/m3u/material/components/TextFields.kt | 17 ++-- .../material/components/ToolkitScaffold.kt | 2 +- 14 files changed, 100 insertions(+), 138 deletions(-) diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 3a3a4cf35..375d79e33 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -14,8 +14,8 @@ android { applicationId = "com.m3u.androidApp" minSdk = 26 targetSdk = 33 - versionCode = 74 - versionName = "1.13.0-alpha01" + versionCode = 75 + versionName = "1.13.0-alpha02" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunnerArguments["androidx.benchmark.profiling.mode"] = "MethodTracing" diff --git a/androidApp/src/main/java/com/m3u/androidApp/components/AppNavigation.kt b/androidApp/src/main/java/com/m3u/androidApp/components/AppNavigation.kt index 2d70ac1db..224ac5e82 100644 --- a/androidApp/src/main/java/com/m3u/androidApp/components/AppNavigation.kt +++ b/androidApp/src/main/java/com/m3u/androidApp/components/AppNavigation.kt @@ -52,7 +52,7 @@ fun AppNavigation( ) { Content( navigate = navigate, - destinations = destinations, + destinationsFactory = { destinations }, rootDestination = rootDestination, fob = fob, selectedColor = selectedColor, @@ -69,7 +69,7 @@ fun AppNavigation( ) { Content( navigate = navigate, - destinations = destinations, + destinationsFactory = { destinations }, rootDestination = rootDestination, fob = fob, selectedColor = selectedColor, @@ -85,7 +85,7 @@ fun AppNavigation( @Composable private fun Content( navigate: Navigate, - destinations: List, + destinationsFactory: () -> List, rootDestination: Destination.Root?, fob: Fob?, selectedColor: Color, @@ -94,6 +94,7 @@ private fun Content( ) { val relation = fob?.rootDestination val actualActiveDestination = rootDestination ?: relation + val destinations = destinationsFactory() destinations.forEach { default -> val fobbed = default == relation val selected = default == actualActiveDestination diff --git a/features/live/src/main/java/com/m3u/features/live/LiveScreen.kt b/features/live/src/main/java/com/m3u/features/live/LiveScreen.kt index a5181d302..c3f5af651 100644 --- a/features/live/src/main/java/com/m3u/features/live/LiveScreen.kt +++ b/features/live/src/main/java/com/m3u/features/live/LiveScreen.kt @@ -1,6 +1,5 @@ package com.m3u.features.live -import android.graphics.Rect import androidx.compose.foundation.background import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.pager.VerticalPager @@ -20,8 +19,6 @@ import androidx.compose.ui.util.lerp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.Lifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.media3.common.PlaybackException -import androidx.media3.common.Player import com.m3u.core.annotation.ClipMode import com.m3u.core.unspecified.UBoolean import com.m3u.core.unspecified.unspecifiable @@ -114,13 +111,9 @@ internal fun LiveRoute( onFavourite = { viewModel.onEvent(LiveEvent.OnFavourite(it)) }, onBackPressed = onBackPressed, maskState = maskState, - player = playerState.player, - playState = playerState.playState, - videoSize = playerState.videoSize, - playerError = playerState.playerError, + playerState = playerState, onInstallMedia = { viewModel.onEvent(LiveEvent.InstallMedia(it)) }, onUninstallMedia = { viewModel.onEvent(LiveEvent.UninstallMedia) }, - muted = playerState.muted, onMuted = { viewModel.onEvent(LiveEvent.OnMuted) }, modifier = modifier ) @@ -138,13 +131,9 @@ private fun LiveScreen( onBackPressed: () -> Unit, maskState: MaskState, experimentalMode: Boolean, - player: Player?, - playState: @Player.State Int, - videoSize: Rect, - playerError: PlaybackException?, + playerState: LiveState.PlayerState, onInstallMedia: (String) -> Unit, onUninstallMedia: () -> Unit, - muted: Boolean, onMuted: () -> Unit, modifier: Modifier = Modifier, ) { @@ -155,10 +144,7 @@ private fun LiveScreen( val url = live?.url.orEmpty() val favourite = live?.favourite ?: false LiveFragment( - player = player, - playState = playState, - videoSize = videoSize, - playerError = playerError, + playerState = playerState, title = init.live?.title ?: "--", url = url, cover = init.live?.cover.orEmpty(), @@ -175,7 +161,6 @@ private fun LiveScreen( onBackPressed = onBackPressed, onInstallMedia = onInstallMedia, onUninstallMedia = onUninstallMedia, - muted = muted, onMuted = onMuted, modifier = modifier .fillMaxSize() @@ -197,10 +182,7 @@ private fun LiveScreen( val url = live.url val favourite = live.favourite LiveFragment( - player = player, - playState = playState, - videoSize = videoSize, - playerError = playerError, + playerState = playerState, title = live.title, feedTitle = init.feed?.title.orEmpty(), url = url, @@ -217,7 +199,6 @@ private fun LiveScreen( onBackPressed = onBackPressed, onInstallMedia = onInstallMedia, onUninstallMedia = onUninstallMedia, - muted = muted, onMuted = onMuted, modifier = Modifier .fillMaxSize() diff --git a/features/live/src/main/java/com/m3u/features/live/LiveState.kt b/features/live/src/main/java/com/m3u/features/live/LiveState.kt index a8e1dd3e6..99f7516a6 100644 --- a/features/live/src/main/java/com/m3u/features/live/LiveState.kt +++ b/features/live/src/main/java/com/m3u/features/live/LiveState.kt @@ -1,6 +1,7 @@ package com.m3u.features.live import android.graphics.Rect +import androidx.compose.runtime.Immutable import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue import androidx.media3.common.PlaybackException @@ -32,6 +33,7 @@ data class LiveState( val initialIndex: Int = 0 ) : Init() + @Immutable data class PlayerState( val playState: @Player.State Int = Player.STATE_IDLE, val videoSize: Rect = Rect(), diff --git a/features/live/src/main/java/com/m3u/features/live/components/DlnaDeviceItem.kt b/features/live/src/main/java/com/m3u/features/live/components/DlnaDeviceItem.kt index 2578e27af..d98b4e349 100644 --- a/features/live/src/main/java/com/m3u/features/live/components/DlnaDeviceItem.kt +++ b/features/live/src/main/java/com/m3u/features/live/components/DlnaDeviceItem.kt @@ -18,7 +18,7 @@ import androidx.compose.material3.MaterialTheme @Composable internal fun DlnaDeviceItem( - device: Device<*, *, *>, + deviceFactory: () -> Device<*, *, *>, connected: Boolean, requestConnection: () -> Unit, loseConnection: () -> Unit, @@ -29,7 +29,7 @@ internal fun DlnaDeviceItem( ListItem( headlineContent = { - Text(device.displayString) + Text(deviceFactory().displayString) }, trailingContent = { Crossfade(connected, label = "icon") { connected -> diff --git a/features/live/src/main/java/com/m3u/features/live/components/DlnaDevicesBottomSheet.kt b/features/live/src/main/java/com/m3u/features/live/components/DlnaDevicesBottomSheet.kt index fd502cdb2..7f4ae65b6 100644 --- a/features/live/src/main/java/com/m3u/features/live/components/DlnaDevicesBottomSheet.kt +++ b/features/live/src/main/java/com/m3u/features/live/components/DlnaDevicesBottomSheet.kt @@ -86,7 +86,7 @@ fun DlnaDevicesBottomSheet( ) { items(devices ?: emptyList()) { device -> DlnaDeviceItem( - device = device, + deviceFactory = { device }, connected = device == connected, requestConnection = { connectDlnaDevice(device) }, loseConnection = { disconnectDlnaDevice(device) } diff --git a/features/live/src/main/java/com/m3u/features/live/fragments/LiveFragment.kt b/features/live/src/main/java/com/m3u/features/live/fragments/LiveFragment.kt index 31d20e9e5..f75af1efd 100644 --- a/features/live/src/main/java/com/m3u/features/live/fragments/LiveFragment.kt +++ b/features/live/src/main/java/com/m3u/features/live/fragments/LiveFragment.kt @@ -1,6 +1,5 @@ package com.m3u.features.live.fragments -import android.graphics.Rect import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.basicMarquee import androidx.compose.foundation.layout.Arrangement @@ -38,6 +37,7 @@ import androidx.media3.common.PlaybackException import androidx.media3.common.Player import com.m3u.core.annotation.ClipMode import com.m3u.core.util.basic.isNotEmpty +import com.m3u.features.live.LiveState import com.m3u.features.live.components.CoverPlaceholder import com.m3u.features.live.components.LiveMask import com.m3u.i18n.R.string @@ -53,10 +53,7 @@ import com.m3u.ui.rememberPlayerState @Composable internal fun LiveFragment( - player: Player?, - playState: @Player.State Int, - videoSize: Rect, - playerError: PlaybackException?, + playerState: LiveState.PlayerState, title: String, feedTitle: String, url: String, @@ -73,7 +70,6 @@ internal fun LiveFragment( onBackPressed: () -> Unit, onInstallMedia: (String) -> Unit, onUninstallMedia: () -> Unit, - muted: Boolean, onMuted: () -> Unit, modifier: Modifier = Modifier ) { @@ -85,7 +81,7 @@ internal fun LiveFragment( Box(modifier) { val helper = LocalHelper.current val state = rememberPlayerState( - player = player, + player = playerState.player, url = url, clipMode = clipMode, onInstallMedia = onInstallMedia, @@ -97,7 +93,7 @@ internal fun LiveFragment( modifier = Modifier.fillMaxSize() ) - val shouldShowPlaceholder = cover.isNotEmpty() && videoSize.isEmpty + val shouldShowPlaceholder = cover.isNotEmpty() && playerState.videoSize.isEmpty CoverPlaceholder( visible = shouldShowPlaceholder, @@ -117,12 +113,12 @@ internal fun LiveFragment( Spacer(modifier = Modifier.weight(1f)) MaskButton( state = maskState, - icon = if (muted) Icons.AutoMirrored.Rounded.VolumeOff + icon = if (playerState.muted) Icons.AutoMirrored.Rounded.VolumeOff else Icons.AutoMirrored.Rounded.VolumeUp, onClick = onMuted, - contentDescription = if (muted) stringResource(string.feat_live_tooltip_unmute) + contentDescription = if (playerState.muted) stringResource(string.feat_live_tooltip_unmute) else stringResource(string.feat_live_tooltip_mute), - tint = if (muted) theme.error else Color.Unspecified + tint = if (playerState.muted) theme.error else Color.Unspecified ) MaskButton( state = maskState, @@ -144,7 +140,7 @@ internal fun LiveFragment( contentDescription = if (recording) stringResource(string.feat_live_tooltip_unrecord) else stringResource(string.feat_live_tooltip_record) ) - if (playState != Player.STATE_IDLE) { + if (playerState.playState != Player.STATE_IDLE) { MaskButton( state = maskState, icon = Icons.Rounded.Cast, @@ -153,12 +149,12 @@ internal fun LiveFragment( ) } } - if (videoSize.isNotEmpty) { + if (playerState.videoSize.isNotEmpty) { MaskButton( state = maskState, icon = Icons.Rounded.PictureInPicture, onClick = { - helper.enterPipMode(videoSize) + helper.enterPipMode(playerState.videoSize) maskState.sleep() }, contentDescription = stringResource(string.feat_live_tooltip_enter_pip_mode) @@ -205,9 +201,9 @@ internal fun LiveFragment( modifier = Modifier.basicMarquee() ) val playStateDisplayText = - LiveFragmentDefaults.playStateDisplayText(playState) + LiveFragmentDefaults.playStateDisplayText(playerState.playState) val exceptionDisplayText = - LiveFragmentDefaults.playbackExceptionDisplayText(playerError) + LiveFragmentDefaults.playbackExceptionDisplayText(playerState.playerError) if (playStateDisplayText.isNotEmpty() || exceptionDisplayText.isNotEmpty()) { Spacer( modifier = Modifier.height(spacing.small) @@ -238,8 +234,8 @@ internal fun LiveFragment( } } ) - LaunchedEffect(playerError) { - if (playerError != null) { + LaunchedEffect(playerState.playerError) { + if (playerState.playerError != null) { maskState.active() } } diff --git a/features/main/src/main/java/com/m3u/features/main/components/FeedItem.kt b/features/main/src/main/java/com/m3u/features/main/components/FeedItem.kt index d1697b187..1b4d38820 100644 --- a/features/main/src/main/java/com/m3u/features/main/components/FeedItem.kt +++ b/features/main/src/main/java/com/m3u/features/main/components/FeedItem.kt @@ -1,6 +1,5 @@ package com.m3u.features.main.components -import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Box @@ -9,24 +8,22 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.rounded.DriveFileMove +import androidx.compose.material3.CardDefaults import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface +import androidx.compose.material3.OutlinedCard import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import com.m3u.material.components.OuterRow -import com.m3u.material.ktx.animateColor -import com.m3u.material.ktx.animateDp import com.m3u.material.ktx.animated import com.m3u.material.model.LocalSpacing @@ -41,22 +38,11 @@ internal fun FeedItem( ) { val spacing = LocalSpacing.current val theme = MaterialTheme.colorScheme - val actualBackgroundColor by theme.surface.animated("FeedItemBackground") val actualContentColor by theme.onSurface.animated("FeedItemContent") - val actualBorderDp by animateDp("FeedItemBorder") { - if (local) spacing.extraSmall - else spacing.none - } - val actualBorderColor by animateColor("FeedItemBorderColor") { - if (local) Color.Black.copy(alpha = 0.12f) - else Color.Transparent - } - Surface( + + OutlinedCard( shape = RoundedCornerShape(spacing.medium), - color = actualBackgroundColor, - contentColor = actualContentColor, - tonalElevation = spacing.none, - border = BorderStroke(actualBorderDp, actualBorderColor) + border = CardDefaults.outlinedCardBorder(local) ) { OuterRow( modifier = modifier diff --git a/features/setting/src/main/java/com/m3u/features/setting/SettingScreen.kt b/features/setting/src/main/java/com/m3u/features/setting/SettingScreen.kt index aa8f466a0..7779acebc 100644 --- a/features/setting/src/main/java/com/m3u/features/setting/SettingScreen.kt +++ b/features/setting/src/main/java/com/m3u/features/setting/SettingScreen.kt @@ -96,7 +96,7 @@ fun SettingRoute( versionCode = state.versionCode, title = state.title, url = state.url, - uri = state.uri, + uriFactory = { state.uri }, feedStrategy = state.feedStrategy, godMode = state.godMode, clipMode = state.clipMode, @@ -149,7 +149,7 @@ private fun SettingScreen( versionCode: Int, title: String, url: String, - uri: Uri, + uriFactory: () -> Uri, @FeedStrategy feedStrategy: Int, godMode: Boolean, @ClipMode clipMode: Int, @@ -220,7 +220,7 @@ private fun SettingScreen( fragment = fragment, title = title, url = url, - uri = uri, + uriFactory = uriFactory, godMode = godMode, connectTimeout = connectTimeout, scrollMode = scrollMode, @@ -276,7 +276,7 @@ private fun SettingScreen( fragment = fragment, title = title, url = url, - uri = uri, + uriFactory = uriFactory, godMode = godMode, clipMode = clipMode, scrollMode = scrollMode, @@ -339,7 +339,7 @@ private fun PortraitOrientationContent( fragment: SettingFragments, title: String, url: String, - uri: Uri, + uriFactory: () -> Uri, @FeedStrategy feedStrategy: Int, godMode: Boolean, @ClipMode clipMode: Int, @@ -431,7 +431,7 @@ private fun PortraitOrientationContent( contentPadding = contentPadding, title = title, url = url, - uri = uri, + uriFactory = uriFactory, mutedLivesFactory = mutedLivesFactory, onBanned = onBanned, onTitle = onTitle, @@ -466,7 +466,7 @@ private fun LandscapeOrientationContent( fragment: SettingFragments, title: String, url: String, - uri: Uri, + uriFactory: () -> Uri, godMode: Boolean, @ClipMode clipMode: Int, replaceFragment: (SettingFragments) -> Unit, @@ -561,7 +561,7 @@ private fun LandscapeOrientationContent( contentPadding = contentPadding, title = title, url = url, - uri = uri, + uriFactory = uriFactory, mutedLivesFactory = mutedLivesFactory, onBanned = onBanned, onTitle = onTitle, diff --git a/features/setting/src/main/java/com/m3u/features/setting/fragments/PreferencesFragment.kt b/features/setting/src/main/java/com/m3u/features/setting/fragments/PreferencesFragment.kt index c173522b5..24a94e0d8 100644 --- a/features/setting/src/main/java/com/m3u/features/setting/fragments/PreferencesFragment.kt +++ b/features/setting/src/main/java/com/m3u/features/setting/fragments/PreferencesFragment.kt @@ -11,9 +11,9 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.rounded.OpenInNew +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -85,7 +85,7 @@ internal fun PreferencesFragment( Column( modifier = Modifier .padding(spacing.medium) - .clip(RoundedCornerShape(spacing.medium)), + .clip(MaterialTheme.shapes.medium), verticalArrangement = Arrangement.spacedBy(1.dp) ) { Preference( @@ -182,7 +182,7 @@ internal fun PreferencesFragment( Column( modifier = Modifier .padding(spacing.medium) - .clip(RoundedCornerShape(spacing.medium)), + .clip(MaterialTheme.shapes.medium), verticalArrangement = Arrangement.spacedBy(1.dp) ) { CheckBoxPreference( @@ -258,7 +258,7 @@ internal fun PreferencesFragment( Column( modifier = Modifier .padding(spacing.medium) - .clip(RoundedCornerShape(spacing.medium)), + .clip(MaterialTheme.shapes.medium), verticalArrangement = Arrangement.spacedBy(1.dp) ) { val context = LocalContext.current diff --git a/features/setting/src/main/java/com/m3u/features/setting/fragments/SubscriptionsFragment.kt b/features/setting/src/main/java/com/m3u/features/setting/fragments/SubscriptionsFragment.kt index 179bb8b30..e5dbcd036 100644 --- a/features/setting/src/main/java/com/m3u/features/setting/fragments/SubscriptionsFragment.kt +++ b/features/setting/src/main/java/com/m3u/features/setting/fragments/SubscriptionsFragment.kt @@ -55,7 +55,7 @@ internal fun SubscriptionsFragment( contentPadding: PaddingValues, title: String, url: String, - uri: Uri, + uriFactory: () -> Uri, localStorage: Boolean, mutedLivesFactory: MutedLivesFactory, onBanned: (Int) -> Unit, @@ -140,7 +140,7 @@ internal fun SubscriptionsFragment( ) } else { LocalStorageButton( - uri = uri, + uriFactory = uriFactory, openDocument = openDocument, ) } @@ -202,10 +202,11 @@ fun LocalStorageSwitch( @Composable private fun LocalStorageButton( - uri: Uri, + uriFactory: () -> Uri, openDocument: (Uri) -> Unit, modifier: Modifier = Modifier ) { + val uri = uriFactory() val context = LocalContext.current val selected = uri != Uri.EMPTY val theme = MaterialTheme.colorScheme diff --git a/material/src/main/java/com/m3u/material/components/Preferences.kt b/material/src/main/java/com/m3u/material/components/Preferences.kt index 60d9a5faa..90577e1c0 100644 --- a/material/src/main/java/com/m3u/material/components/Preferences.kt +++ b/material/src/main/java/com/m3u/material/components/Preferences.kt @@ -1,6 +1,5 @@ package com.m3u.material.components -import androidx.compose.foundation.background import androidx.compose.foundation.basicMarquee import androidx.compose.foundation.clickable import androidx.compose.foundation.focusable @@ -8,8 +7,10 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.selection.toggleable import androidx.compose.material3.Checkbox +import androidx.compose.material3.ElevatedCard import androidx.compose.material3.Icon import androidx.compose.material3.ListItem +import androidx.compose.material3.LocalAbsoluteTonalElevation import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme import androidx.compose.material3.PlainTooltip @@ -17,7 +18,6 @@ import androidx.compose.material3.Switch import androidx.compose.material3.Text import androidx.compose.material3.TooltipBox import androidx.compose.material3.TooltipDefaults -import androidx.compose.material3.minimumInteractiveComponentSize import androidx.compose.material3.rememberTooltipState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -27,12 +27,13 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.semantics.Role import androidx.compose.ui.text.capitalize +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.intl.Locale import androidx.compose.ui.text.style.TextOverflow -import com.m3u.material.ktx.animated import com.m3u.material.model.LocalSpacing @Composable @@ -44,9 +45,7 @@ fun Preference( onClick: () -> Unit = {}, trailingContent: @Composable () -> Unit = {} ) { - val theme = MaterialTheme.colorScheme var focus by remember { mutableStateOf(false) } - val actualBackgroundColor by theme.surface.animated("FoldPreferenceBackground") TooltipBox( state = rememberTooltipState(), @@ -63,47 +62,46 @@ fun Preference( } } ) { - ListItem( - headlineContent = { - Text( - text = title, - style = MaterialTheme.typography.titleMedium, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) - }, - supportingContent = { - if (subtitle != null) { + ElevatedCard(shape = RectangleShape) { + ListItem( + headlineContent = { Text( - text = subtitle.capitalize(Locale.current), - style = MaterialTheme.typography.bodyMedium, + text = title, + style = MaterialTheme.typography.titleMedium, maxLines = 1, overflow = TextOverflow.Ellipsis, - modifier = Modifier - .let { - if (focus) it.basicMarquee() - else it - } ) - } - }, - trailingContent = trailingContent, - modifier = modifier - .fillMaxWidth() - .onFocusChanged { - focus = it.hasFocus - } - .focusable() - .clickable( - enabled = enabled, - onClick = onClick, - role = Role.Button - ) - .background(actualBackgroundColor) - .padding( - start = LocalSpacing.current.small - ) - ) + }, + supportingContent = { + if (subtitle != null) { + Text( + text = subtitle.capitalize(Locale.current), + style = MaterialTheme.typography.bodyMedium, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + modifier = Modifier + .let { + if (focus) it.basicMarquee() + else it + } + ) + } + }, + trailingContent = trailingContent, + tonalElevation = LocalAbsoluteTonalElevation.current, + modifier = modifier + .fillMaxWidth() + .onFocusChanged { + focus = it.hasFocus + } + .focusable() + .clickable( + enabled = enabled, + onClick = onClick, + role = Role.Button + ) + ) + } } } @@ -198,8 +196,7 @@ fun IconPreference( Icon( imageVector = imageVector, contentDescription = null, - tint = LocalContentColor.current.copy(alpha = 0.65f), - modifier = Modifier.minimumInteractiveComponentSize() + tint = LocalContentColor.current.copy(alpha = 0.65f) ) } ) @@ -227,6 +224,7 @@ fun TextPreference( text = content.uppercase(), color = MaterialTheme.colorScheme.primary, style = MaterialTheme.typography.bodyMedium, + fontWeight = FontWeight.Bold, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.padding( diff --git a/material/src/main/java/com/m3u/material/components/TextFields.kt b/material/src/main/java/com/m3u/material/components/TextFields.kt index 218927c55..c76527bcc 100644 --- a/material/src/main/java/com/m3u/material/components/TextFields.kt +++ b/material/src/main/java/com/m3u/material/components/TextFields.kt @@ -9,7 +9,6 @@ import androidx.compose.foundation.background import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.collectIsFocusedAsState import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth @@ -25,6 +24,7 @@ import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.selection.LocalTextSelectionColors import androidx.compose.foundation.text.selection.TextSelectionColors +import androidx.compose.material3.ElevatedCard import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -35,7 +35,6 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.focus.FocusDirection @@ -143,8 +142,8 @@ fun TextField( readOnly = readOnly, cursorBrush = SolidColor(contentColor), decorationBox = { innerTextField -> - Box( - Modifier + ElevatedCard( + modifier = Modifier .clip(shape) .background(if (isError) MaterialTheme.colorScheme.error else background) .interactionBorder( @@ -154,7 +153,6 @@ fun TextField( ) .height(height) .padding(horizontal = 12.dp), - contentAlignment = if (singleLine) Alignment.CenterStart else Alignment.TopStart, ) { Box( Modifier @@ -258,8 +256,8 @@ fun TextField( readOnly = readOnly, cursorBrush = SolidColor(contentColor), decorationBox = { innerTextField -> - Box( - Modifier + ElevatedCard( + modifier = Modifier .clip(shape) .background(if (isError) theme.error else backgroundColor) .interactionBorder( @@ -269,7 +267,6 @@ fun TextField( ) .height(height) .padding(horizontal = 12.dp), - contentAlignment = if (singleLine) Alignment.CenterStart else Alignment.TopStart, ) { Box( Modifier @@ -373,7 +370,7 @@ fun LabelField( color = contentColor, ), decorationBox = { innerTextField -> - Row( + ElevatedCard( Modifier .clip(shape) .background(background) @@ -519,7 +516,7 @@ fun LabelField( color = contentColor, ), decorationBox = { innerTextField -> - Row( + ElevatedCard( modifier = Modifier .clip(shape) .background(background) diff --git a/material/src/main/java/com/m3u/material/components/ToolkitScaffold.kt b/material/src/main/java/com/m3u/material/components/ToolkitScaffold.kt index d1c5e0698..2784c12dc 100644 --- a/material/src/main/java/com/m3u/material/components/ToolkitScaffold.kt +++ b/material/src/main/java/com/m3u/material/components/ToolkitScaffold.kt @@ -199,7 +199,7 @@ fun ToolkitScaffold( } Text( text = title, - style = MaterialTheme.typography.headlineSmall, + style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.ExtraBold, textAlign = TextAlign.Start, maxLines = 1,