Style(Code): Optimize code style
This commit is contained in:
@@ -121,11 +121,11 @@ fun OxygenApp(appState: OxygenAppState) {
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier
|
||||
.nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
|
||||
.nestedScroll(connection = topAppBarScrollBehavior.nestedScrollConnection),
|
||||
containerColor = Color.Transparent,
|
||||
contentColor = MaterialTheme.colorScheme.onBackground,
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
||||
snackbarHost = { SnackbarHost(snackbarHostState) },
|
||||
contentWindowInsets = WindowInsets(left = 0, top = 0, right = 0, bottom = 0),
|
||||
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
|
||||
bottomBar = {
|
||||
AnimatedVisibility(
|
||||
visible = appState.shouldShowBottomBar && destination != null,
|
||||
@@ -135,8 +135,8 @@ fun OxygenApp(appState: OxygenAppState) {
|
||||
) {
|
||||
OxygenBottomBar(
|
||||
destinations = appState.topLevelDestinations,
|
||||
onNavigateToDestination = appState::navigateToTopLevelDestination,
|
||||
currentDestination = appState.currentDestination
|
||||
currentDestination = appState.currentDestination,
|
||||
onNavigateToDestination = appState::navigateToTopLevelDestination
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -153,12 +153,12 @@ fun OxygenApp(appState: OxygenAppState) {
|
||||
)
|
||||
)
|
||||
) {
|
||||
AnimatedVisibility(appState.shouldShowNavRail && destination != null) {
|
||||
AnimatedVisibility(visible = appState.shouldShowNavRail && destination != null) {
|
||||
OxygenNavRail(
|
||||
modifier = Modifier.safeDrawingPadding(),
|
||||
destinations = appState.topLevelDestinations,
|
||||
onNavigateToDestination = appState::navigateToTopLevelDestination,
|
||||
currentDestination = appState.currentDestination
|
||||
currentDestination = appState.currentDestination,
|
||||
onNavigateToDestination = appState::navigateToTopLevelDestination
|
||||
)
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ fun OxygenApp(appState: OxygenAppState) {
|
||||
OxygenTopAppBar(
|
||||
scrollBehavior = topAppBarScrollBehavior,
|
||||
title = {
|
||||
Text(text = stringResource(id = destination.titleTextId))
|
||||
Text(text = stringResource(destination.titleTextId))
|
||||
},
|
||||
navigationIcon = OxygenIcons.Search,
|
||||
navigationIconContentDescription = stringResource(R.string.feature_settings_top_app_bar_navigation_icon_description),
|
||||
@@ -226,8 +226,8 @@ fun OxygenApp(appState: OxygenAppState) {
|
||||
private fun OxygenBottomBar(
|
||||
modifier: Modifier = Modifier,
|
||||
destinations: List<TopLevelDestination>,
|
||||
onNavigateToDestination: (TopLevelDestination) -> Unit,
|
||||
currentDestination: NavDestination?
|
||||
currentDestination: NavDestination?,
|
||||
onNavigateToDestination: (TopLevelDestination) -> Unit
|
||||
) {
|
||||
OxygenNavigationBar(
|
||||
modifier = modifier
|
||||
@@ -260,8 +260,8 @@ private fun OxygenBottomBar(
|
||||
private fun OxygenNavRail(
|
||||
modifier: Modifier = Modifier,
|
||||
destinations: List<TopLevelDestination>,
|
||||
onNavigateToDestination: (TopLevelDestination) -> Unit,
|
||||
currentDestination: NavDestination?
|
||||
currentDestination: NavDestination?,
|
||||
onNavigateToDestination: (TopLevelDestination) -> Unit
|
||||
) {
|
||||
OxygenNavigationRail(
|
||||
modifier = modifier
|
||||
|
||||
@@ -91,14 +91,14 @@ class OxygenAppState(
|
||||
.stateIn(
|
||||
scope = coroutineScope,
|
||||
initialValue = false,
|
||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
||||
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||
)
|
||||
|
||||
val currentTimeZone = timeZoneMonitor.currentTimeZone
|
||||
.stateIn(
|
||||
scope = coroutineScope,
|
||||
initialValue = TimeZone.currentSystemDefault(),
|
||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
||||
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||
)
|
||||
|
||||
fun navigateToTopLevelDestination(topLevelDestination: TopLevelDestination) {
|
||||
@@ -121,4 +121,4 @@ class OxygenAppState(
|
||||
fun navigateToLibraries() = navController.navigateToLibraries()
|
||||
|
||||
fun navigateToAbout() = navController.navigateToAbout()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ import top.fatweb.oxygen.toolbox.ui.util.ResourcesUtils
|
||||
@Composable
|
||||
internal fun AboutRoute(
|
||||
modifier: Modifier = Modifier,
|
||||
onNavigateToLibraries: () -> Unit,
|
||||
onBackClick: () -> Unit
|
||||
onBackClick: () -> Unit,
|
||||
onNavigateToLibraries: () -> Unit
|
||||
) {
|
||||
AboutScreen(
|
||||
modifier = modifier.safeDrawingPadding(),
|
||||
@@ -57,8 +57,8 @@ internal fun AboutRoute(
|
||||
@Composable
|
||||
internal fun AboutScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
onNavigateToLibraries: () -> Unit,
|
||||
onBackClick: () -> Unit
|
||||
onBackClick: () -> Unit,
|
||||
onNavigateToLibraries: () -> Unit
|
||||
) {
|
||||
val scrollState = rememberScrollState()
|
||||
val topAppBarScrollBehavior =
|
||||
@@ -66,9 +66,9 @@ internal fun AboutScreen(
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier
|
||||
.nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
|
||||
.nestedScroll(connection = topAppBarScrollBehavior.nestedScrollConnection),
|
||||
containerColor = Color.Transparent,
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
||||
contentWindowInsets = WindowInsets(left = 0, top = 0, right = 0, bottom = 0),
|
||||
) { padding ->
|
||||
Column(
|
||||
modifier = modifier
|
||||
@@ -80,12 +80,13 @@ internal fun AboutScreen(
|
||||
WindowInsetsSides.Horizontal
|
||||
)
|
||||
)
|
||||
.verticalScroll(scrollState), horizontalAlignment = Alignment.CenterHorizontally
|
||||
.verticalScroll(state = scrollState),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
OxygenTopAppBar(
|
||||
scrollBehavior = topAppBarScrollBehavior,
|
||||
title = {
|
||||
Text(text = stringResource(id = R.string.feature_settings_more_about))
|
||||
Text(text = stringResource(R.string.feature_settings_more_about))
|
||||
},
|
||||
navigationIcon = OxygenIcons.Back,
|
||||
navigationIconContentDescription = stringResource(R.string.core_back),
|
||||
@@ -95,13 +96,9 @@ internal fun AboutScreen(
|
||||
),
|
||||
onNavigationClick = onBackClick
|
||||
)
|
||||
Spacer(
|
||||
modifier = Modifier.height(64.dp)
|
||||
)
|
||||
Spacer(Modifier.height(64.dp))
|
||||
AboutAppInfo()
|
||||
Spacer(
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
Spacer(Modifier.weight(1f))
|
||||
AboutFooter(
|
||||
onNavigateToLibraries = onNavigateToLibraries
|
||||
)
|
||||
@@ -114,26 +111,27 @@ private fun AboutAppInfo(
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier, horizontalAlignment = Alignment.CenterHorizontally
|
||||
modifier = modifier,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Image(
|
||||
imageVector = ImageVector.vectorResource(R.drawable.ic_oxygen),
|
||||
contentDescription = stringResource(R.string.app_full_name)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Spacer(Modifier.height(16.dp))
|
||||
Text(
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
text = stringResource(R.string.app_name)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.outline,
|
||||
text = stringResource(R.string.app_description)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.outline,
|
||||
|
||||
@@ -26,4 +26,4 @@ fun LazyStaggeredGridScope.librariesPanel(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,9 +123,9 @@ internal fun LibrariesScreen(
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier
|
||||
.nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
|
||||
.nestedScroll(connection = topAppBarScrollBehavior.nestedScrollConnection),
|
||||
containerColor = Color.Transparent,
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
||||
contentWindowInsets = WindowInsets(left = 0, top = 0, right = 0, bottom = 0),
|
||||
) { padding ->
|
||||
Column(
|
||||
modifier
|
||||
@@ -141,7 +141,7 @@ internal fun LibrariesScreen(
|
||||
OxygenTopAppBar(
|
||||
scrollBehavior = topAppBarScrollBehavior,
|
||||
title = {
|
||||
Text(text = stringResource(id = R.string.feature_settings_open_source_license))
|
||||
Text(text = stringResource(R.string.feature_settings_open_source_license))
|
||||
},
|
||||
navigationIcon = OxygenIcons.Back,
|
||||
navigationIconContentDescription = stringResource(R.string.core_back),
|
||||
@@ -180,14 +180,14 @@ internal fun LibrariesScreen(
|
||||
initialValue = 0F,
|
||||
targetValue = 360F,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(800, easing = Ease),
|
||||
animation = tween(durationMillis = 800, easing = Ease),
|
||||
), label = "angle"
|
||||
)
|
||||
Icon(
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.graphicsLayer { rotationZ = angle },
|
||||
imageVector = OxygenIcons.Loading,
|
||||
imageVector = Loading,
|
||||
contentDescription = ""
|
||||
)
|
||||
}
|
||||
@@ -255,7 +255,7 @@ internal fun LibrariesScreen(
|
||||
},
|
||||
text = {
|
||||
Column(
|
||||
modifier = Modifier.verticalScroll(rememberScrollState())
|
||||
modifier = Modifier.verticalScroll(state = rememberScrollState())
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier,
|
||||
|
||||
@@ -44,7 +44,7 @@ class LibrariesScreenViewModel @Inject constructor(
|
||||
.stateIn(
|
||||
scope = viewModelScope,
|
||||
initialValue = LibrariesScreenUiState.Loading,
|
||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
||||
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||
)
|
||||
|
||||
fun onSearchValueChange(value: String) {
|
||||
|
||||
@@ -80,7 +80,7 @@ fun DialogChooserRow(
|
||||
selected = selected,
|
||||
onClick = null
|
||||
)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(text)
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ fun DialogClickerRow(
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(imageVector = icon ?: OxygenIcons.Reorder, contentDescription = null)
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(text)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,13 +59,13 @@ fun LibraryCard(
|
||||
version = artifactVersion ?: stringResource(R.string.core_unknown)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
LibraryContent(
|
||||
text = description ?: ""
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
LibraryFooter(
|
||||
licenses = licenses,
|
||||
@@ -192,4 +192,4 @@ private fun LibraryCardPreview() {
|
||||
),
|
||||
onClickLicense = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,16 +27,15 @@ fun RowScope.OxygenNavigationBarItem(
|
||||
label: @Composable (() -> Unit)? = null,
|
||||
icon: @Composable () -> Unit,
|
||||
selectedIcon: @Composable () -> Unit,
|
||||
onClick: () -> Unit,
|
||||
enabled: Boolean = true,
|
||||
alwaysShowLabel: Boolean = false
|
||||
alwaysShowLabel: Boolean = false,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
NavigationBarItem(
|
||||
modifier = modifier,
|
||||
selected = selected,
|
||||
label = label,
|
||||
icon = if (selected) selectedIcon else icon,
|
||||
onClick = onClick,
|
||||
enabled = enabled,
|
||||
alwaysShowLabel = alwaysShowLabel,
|
||||
colors = NavigationBarItemDefaults.colors(
|
||||
@@ -45,7 +44,8 @@ fun RowScope.OxygenNavigationBarItem(
|
||||
selectedTextColor = OxygenNavigationDefaults.navigationSelectedItemColor(),
|
||||
unselectedTextColor = OxygenNavigationDefaults.navigationContentColor(),
|
||||
indicatorColor = OxygenNavigationDefaults.navigationIndicatorColor()
|
||||
)
|
||||
),
|
||||
onClick = onClick
|
||||
)
|
||||
}
|
||||
|
||||
@@ -69,16 +69,15 @@ fun OxygenNavigationRailItem(
|
||||
label: @Composable (() -> Unit)? = null,
|
||||
icon: @Composable () -> Unit,
|
||||
selectedIcon: @Composable () -> Unit,
|
||||
onClick: () -> Unit,
|
||||
enabled: Boolean = true,
|
||||
alwaysShowLabel: Boolean = true
|
||||
alwaysShowLabel: Boolean = true,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
NavigationRailItem(
|
||||
modifier = modifier,
|
||||
selected = selected,
|
||||
label = label,
|
||||
icon = if (selected) selectedIcon else icon,
|
||||
onClick = onClick,
|
||||
enabled = enabled,
|
||||
alwaysShowLabel = alwaysShowLabel,
|
||||
colors = NavigationRailItemDefaults.colors(
|
||||
@@ -87,7 +86,8 @@ fun OxygenNavigationRailItem(
|
||||
selectedTextColor = OxygenNavigationDefaults.navigationSelectedItemColor(),
|
||||
unselectedTextColor = OxygenNavigationDefaults.navigationContentColor(),
|
||||
indicatorColor = OxygenNavigationDefaults.navigationIndicatorColor()
|
||||
)
|
||||
),
|
||||
onClick = onClick
|
||||
)
|
||||
}
|
||||
|
||||
@@ -177,4 +177,4 @@ private fun OxygenNavigationRailPreview() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,4 +182,4 @@ private fun OxygenTopAppBarPreview() {
|
||||
actionIconContentDescription = "Action icon"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,15 +65,15 @@ fun ToolCard(
|
||||
actionIconContentDescription = actionIconContentDescription,
|
||||
onAction = onAction
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Spacer(Modifier.height(16.dp))
|
||||
ToolIcon(icon = tool.icon)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Spacer(Modifier.height(16.dp))
|
||||
ToolInfo(
|
||||
toolName = tool.name,
|
||||
toolId = tool.toolId,
|
||||
toolDesc = tool.description
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Spacer(Modifier.height(16.dp))
|
||||
AuthorInfo(
|
||||
avatar = tool.authorAvatar,
|
||||
nickname = tool.authorNickname
|
||||
@@ -95,7 +95,7 @@ private fun ToolHeader(
|
||||
.height(28.dp)
|
||||
) {
|
||||
ToolVer(ver = ver)
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Spacer(Modifier.weight(1f))
|
||||
actionIcon?.let {
|
||||
ToolAction(
|
||||
actionIcon = actionIcon,
|
||||
|
||||
@@ -85,9 +85,9 @@ fun ToolGroupTitle(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(modifier = Modifier.size(18.dp), imageVector = icon, contentDescription = title)
|
||||
Spacer(modifier = Modifier.width(10.dp))
|
||||
Spacer(Modifier.width(10.dp))
|
||||
Text(text = title, style = MaterialTheme.typography.titleMedium)
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Spacer(Modifier.weight(1f))
|
||||
SwitchableIcon(icon = OxygenIcons.ArrowDown, switched = !isExpanded)
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ fun ToolGroupItem(
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Icon(modifier = Modifier.size(16.dp), imageVector = icon, contentDescription = null)
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Spacer(Modifier.width(4.dp))
|
||||
Text(text = title, style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ private fun ToolGroupCardPreview() {
|
||||
LazyColumn {
|
||||
itemsIndexed(groups) { index, item ->
|
||||
if (index != 0) {
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
Spacer(Modifier.height(10.dp))
|
||||
}
|
||||
ToolGroupCard(
|
||||
toolGroup = item
|
||||
|
||||
@@ -218,4 +218,4 @@ fun LazyStaggeredGridState.scrollbarState(
|
||||
}
|
||||
|
||||
private inline fun <T> List<T>.floatSumOf(selector: (T) -> Float): Float =
|
||||
fold(initial = 0f) { accumulator, listItem -> accumulator + selector(listItem) }
|
||||
fold(initial = 0f) { accumulator, listItem -> accumulator + selector(listItem) }
|
||||
|
||||
@@ -52,22 +52,22 @@ import top.fatweb.oxygen.toolbox.ui.theme.supportsDynamicTheming
|
||||
fun SettingsDialog(
|
||||
modifier: Modifier = Modifier,
|
||||
viewModel: SettingsViewModel = hiltViewModel(),
|
||||
onDismiss: () -> Unit,
|
||||
onNavigateToLibraries: () -> Unit,
|
||||
onNavigateToAbout: () -> Unit
|
||||
onNavigateToAbout: () -> Unit,
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
val settingsUiState by viewModel.settingsUiState.collectAsStateWithLifecycle()
|
||||
SettingsDialog(
|
||||
modifier = modifier,
|
||||
settingsUiState = settingsUiState,
|
||||
onNavigateToLibraries = onNavigateToLibraries,
|
||||
onNavigateToAbout = onNavigateToAbout,
|
||||
onDismiss = onDismiss,
|
||||
onChangeLanguageConfig = viewModel::updateLanguageConfig,
|
||||
onChangeLaunchPageConfig = viewModel::updateLaunchPageConfig,
|
||||
onchangeThemeBrandConfig = viewModel::updateThemeBrandConfig,
|
||||
onChangeDarkThemeConfig = viewModel::updateDarkThemeConfig,
|
||||
onchangeUseDynamicColor = viewModel::updateUseDynamicColor,
|
||||
onNavigateToLibraries = onNavigateToLibraries,
|
||||
onNavigateToAbout = onNavigateToAbout
|
||||
onchangeUseDynamicColor = viewModel::updateUseDynamicColor
|
||||
)
|
||||
}
|
||||
|
||||
@@ -75,15 +75,15 @@ fun SettingsDialog(
|
||||
fun SettingsDialog(
|
||||
modifier: Modifier = Modifier,
|
||||
settingsUiState: SettingsUiState,
|
||||
onNavigateToLibraries: () -> Unit,
|
||||
onNavigateToAbout: () -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
supportDynamicColor: Boolean = supportsDynamicTheming(),
|
||||
onChangeLanguageConfig: (languageConfig: LanguageConfig) -> Unit,
|
||||
onChangeLaunchPageConfig: (launchPageConfig: LaunchPageConfig) -> Unit,
|
||||
onchangeThemeBrandConfig: (themeBrandConfig: ThemeBrandConfig) -> Unit,
|
||||
onChangeDarkThemeConfig: (darkThemeConfig: DarkThemeConfig) -> Unit,
|
||||
onchangeUseDynamicColor: (useDynamicColor: Boolean) -> Unit,
|
||||
onNavigateToLibraries: () -> Unit,
|
||||
onNavigateToAbout: () -> Unit
|
||||
onchangeUseDynamicColor: (useDynamicColor: Boolean) -> Unit
|
||||
) {
|
||||
val configuration = LocalConfiguration.current
|
||||
val infiniteTransition = rememberInfiniteTransition(label = "infiniteTransition")
|
||||
@@ -122,7 +122,7 @@ fun SettingsDialog(
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.graphicsLayer { rotationZ = angle },
|
||||
imageVector = OxygenIcons.Loading,
|
||||
imageVector = Loading,
|
||||
contentDescription = ""
|
||||
)
|
||||
}
|
||||
@@ -132,14 +132,14 @@ fun SettingsDialog(
|
||||
SettingsPanel(
|
||||
settings = settingsUiState.settings,
|
||||
supportDynamicColor = supportDynamicColor,
|
||||
onNavigateToLibraries = onNavigateToLibraries,
|
||||
onNavigateToAbout = onNavigateToAbout,
|
||||
onDismiss = onDismiss,
|
||||
onChangeLanguageConfig = onChangeLanguageConfig,
|
||||
onChangeLaunchPageConfig = onChangeLaunchPageConfig,
|
||||
onchangeThemeBrandConfig = onchangeThemeBrandConfig,
|
||||
onChangeDarkThemeConfig = onChangeDarkThemeConfig,
|
||||
onchangeUseDynamicColor = onchangeUseDynamicColor,
|
||||
onNavigateToLibraries = onNavigateToLibraries,
|
||||
onNavigateToAbout = onNavigateToAbout
|
||||
onchangeUseDynamicColor = onchangeUseDynamicColor
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -162,14 +162,14 @@ fun SettingsDialog(
|
||||
private fun ColumnScope.SettingsPanel(
|
||||
settings: UserData,
|
||||
supportDynamicColor: Boolean,
|
||||
onNavigateToLibraries: () -> Unit,
|
||||
onNavigateToAbout: () -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
onChangeLanguageConfig: (languageConfig: LanguageConfig) -> Unit,
|
||||
onChangeLaunchPageConfig: (launchPageConfig: LaunchPageConfig) -> Unit,
|
||||
onchangeThemeBrandConfig: (themeBrandConfig: ThemeBrandConfig) -> Unit,
|
||||
onChangeDarkThemeConfig: (darkThemeConfig: DarkThemeConfig) -> Unit,
|
||||
onchangeUseDynamicColor: (useDynamicColor: Boolean) -> Unit,
|
||||
onNavigateToLibraries: () -> Unit,
|
||||
onNavigateToAbout: () -> Unit
|
||||
onchangeUseDynamicColor: (useDynamicColor: Boolean) -> Unit
|
||||
) {
|
||||
DialogSectionTitle(text = stringResource(R.string.feature_settings_language))
|
||||
DialogSectionGroup {
|
||||
@@ -275,15 +275,15 @@ private fun ColumnScope.SettingsPanel(
|
||||
private fun SettingsDialogLoadingPreview() {
|
||||
OxygenTheme {
|
||||
SettingsDialog(
|
||||
onNavigateToLibraries = {},
|
||||
onNavigateToAbout = {},
|
||||
onDismiss = { },
|
||||
settingsUiState = SettingsUiState.Loading,
|
||||
onChangeLanguageConfig = {},
|
||||
onChangeLaunchPageConfig = {},
|
||||
onchangeThemeBrandConfig = {},
|
||||
onChangeDarkThemeConfig = {},
|
||||
onchangeUseDynamicColor = {},
|
||||
onNavigateToLibraries = {},
|
||||
onNavigateToAbout = {}
|
||||
onchangeUseDynamicColor = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -293,6 +293,8 @@ private fun SettingsDialogLoadingPreview() {
|
||||
private fun SettingDialogPreview() {
|
||||
OxygenTheme {
|
||||
SettingsDialog(
|
||||
onNavigateToLibraries = {},
|
||||
onNavigateToAbout = {},
|
||||
onDismiss = {},
|
||||
settingsUiState = SettingsUiState.Success(
|
||||
UserData(
|
||||
@@ -307,9 +309,7 @@ private fun SettingDialogPreview() {
|
||||
onChangeLaunchPageConfig = {},
|
||||
onchangeThemeBrandConfig = {},
|
||||
onChangeDarkThemeConfig = {},
|
||||
onchangeUseDynamicColor = {},
|
||||
onNavigateToLibraries = {},
|
||||
onNavigateToAbout = {}
|
||||
onchangeUseDynamicColor = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class SettingsViewModel @Inject constructor(
|
||||
.stateIn(
|
||||
scope = viewModelScope,
|
||||
initialValue = SettingsUiState.Loading,
|
||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
||||
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||
)
|
||||
|
||||
fun updateLanguageConfig(languageConfig: LanguageConfig) {
|
||||
@@ -66,4 +66,4 @@ class SettingsViewModel @Inject constructor(
|
||||
sealed interface SettingsUiState {
|
||||
data object Loading : SettingsUiState
|
||||
data class Success(val settings: UserData) : SettingsUiState
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ internal fun StarScreen(
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.graphicsLayer { rotationZ = angle },
|
||||
imageVector = OxygenIcons.Loading,
|
||||
imageVector = Loading,
|
||||
contentDescription = ""
|
||||
)
|
||||
}
|
||||
@@ -152,8 +152,8 @@ internal fun StarScreen(
|
||||
)
|
||||
|
||||
item(span = StaggeredGridItemSpan.FullLine) {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Spacer(modifier = Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,8 +173,8 @@ internal fun StarScreen(
|
||||
|
||||
if (isShowMenu && selectedTool != null) {
|
||||
ToolMenu(
|
||||
onDismiss = { isShowMenu = false },
|
||||
selectedTool = selectedTool!!,
|
||||
onDismiss = { isShowMenu = false },
|
||||
onUnstar = {
|
||||
isShowMenu = false
|
||||
onUnstar(selectedTool!!)
|
||||
@@ -207,8 +207,8 @@ private fun LazyStaggeredGridScope.toolsPanel(
|
||||
@Composable
|
||||
private fun ToolMenu(
|
||||
modifier: Modifier = Modifier,
|
||||
onDismiss: () -> Unit,
|
||||
selectedTool: ToolEntity,
|
||||
onDismiss: () -> Unit,
|
||||
onUnstar: () -> Unit
|
||||
) {
|
||||
ModalBottomSheet(onDismissRequest = onDismiss, dragHandle = {}) {
|
||||
@@ -217,7 +217,7 @@ private fun ToolMenu(
|
||||
){
|
||||
DialogTitle(text = selectedTool.name)
|
||||
HorizontalDivider()
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Spacer(Modifier.height(4.dp))
|
||||
DialogSectionGroup {
|
||||
DialogClickerRow(
|
||||
icon = OxygenIcons.StarBorder,
|
||||
|
||||
@@ -36,7 +36,7 @@ class StarScreenViewModel @Inject constructor(
|
||||
}.stateIn(
|
||||
scope = viewModelScope,
|
||||
initialValue = StarScreenUiState.Loading,
|
||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
||||
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||
)
|
||||
|
||||
fun onSearchValueChange(value: String) {
|
||||
@@ -56,4 +56,4 @@ sealed interface StarScreenUiState {
|
||||
data class Success(val tools: List<ToolEntity>) : StarScreenUiState
|
||||
}
|
||||
|
||||
private const val SEARCH_VALUE = "searchValue"
|
||||
private const val SEARCH_VALUE = "searchValue"
|
||||
|
||||
@@ -78,26 +78,26 @@ internal fun ToolStoreRoute(
|
||||
|
||||
ToolStoreScreen(
|
||||
modifier = modifier,
|
||||
onNavigateToToolView = onNavigateToToolView,
|
||||
toolStorePagingItems = toolStorePagingItems,
|
||||
installInfo = installInfo,
|
||||
onNavigateToToolView = onNavigateToToolView,
|
||||
onChangeInstallStatus = viewModel::changeInstallInfo,
|
||||
onChangeInstallType = {
|
||||
viewModel.changeInstallInfo(type = it)
|
||||
},
|
||||
onInstallTool = viewModel::installTool,
|
||||
installInfo = installInfo
|
||||
onInstallTool = viewModel::installTool
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun ToolStoreScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
||||
toolStorePagingItems: LazyPagingItems<ToolEntity>,
|
||||
installInfo: ToolStoreUiState.InstallInfo,
|
||||
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
||||
onChangeInstallStatus: (status: ToolStoreUiState.InstallInfo.Status) -> Unit,
|
||||
onChangeInstallType: (type: ToolStoreUiState.InstallInfo.Type) -> Unit,
|
||||
onInstallTool: (installTool: ToolEntity) -> Unit,
|
||||
installInfo: ToolStoreUiState.InstallInfo
|
||||
onInstallTool: (installTool: ToolEntity) -> Unit
|
||||
) {
|
||||
val isToolLoading =
|
||||
toolStorePagingItems.loadState.refresh is LoadState.Loading
|
||||
@@ -112,7 +112,11 @@ internal fun ToolStoreScreen(
|
||||
|
||||
val infiniteTransition = rememberInfiniteTransition(label = "infiniteTransition")
|
||||
|
||||
var installTool by remember { mutableStateOf(ToolEntity("Unknown", "Unknown", "Unknown")) }
|
||||
var installTool by remember { mutableStateOf(ToolEntity(
|
||||
toolId = "Unknown",
|
||||
authorUsername = "Unknown",
|
||||
ver = "Unknown"
|
||||
)) }
|
||||
|
||||
Box(
|
||||
modifier.fillMaxSize()
|
||||
@@ -137,7 +141,7 @@ internal fun ToolStoreScreen(
|
||||
)
|
||||
|
||||
item(span = StaggeredGridItemSpan.FullLine) {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
|
||||
}
|
||||
}
|
||||
@@ -152,14 +156,14 @@ internal fun ToolStoreScreen(
|
||||
initialValue = 0F,
|
||||
targetValue = 360F,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(800, easing = Ease),
|
||||
animation = tween(durationMillis = 800, easing = Ease),
|
||||
), label = "angle"
|
||||
)
|
||||
Icon(
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.graphicsLayer { rotationZ = angle },
|
||||
imageVector = OxygenIcons.Loading,
|
||||
imageVector = Loading,
|
||||
contentDescription = ""
|
||||
)
|
||||
}
|
||||
@@ -171,7 +175,8 @@ internal fun ToolStoreScreen(
|
||||
.windowInsetsPadding(WindowInsets.systemBars)
|
||||
.padding(horizontal = 2.dp)
|
||||
.align(Alignment.CenterEnd),
|
||||
state = scrollbarState, orientation = Orientation.Vertical,
|
||||
state = scrollbarState,
|
||||
orientation = Orientation.Vertical,
|
||||
onThumbMoved = state.rememberDraggableScroller(itemsAvailable = itemsAvailable)
|
||||
)
|
||||
}
|
||||
@@ -242,7 +247,7 @@ private fun InstallAlertDialog(
|
||||
}
|
||||
)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Spacer(Modifier.width(4.dp))
|
||||
Text(
|
||||
text = stringResource(
|
||||
when (type) {
|
||||
@@ -296,7 +301,7 @@ private fun InstallAlertDialog(
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Spacer(Modifier.height(16.dp))
|
||||
Text(
|
||||
text = stringResource(
|
||||
when (type) {
|
||||
@@ -369,4 +374,4 @@ private fun InstallAlertDialog(
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,4 @@ data class BackgroundTheme(
|
||||
val tonalElevation: Dp = Dp.Unspecified
|
||||
)
|
||||
|
||||
val LocalBackgroundTheme = staticCompositionLocalOf { BackgroundTheme() }
|
||||
val LocalBackgroundTheme = staticCompositionLocalOf { BackgroundTheme() }
|
||||
|
||||
@@ -63,4 +63,4 @@ internal val Teal20 = Color(0xFF02363F)
|
||||
internal val Teal30 = Color(0xFF214D56)
|
||||
internal val Teal40 = Color(0xFF3A656F)
|
||||
internal val Teal80 = Color(0xFFA2CED9)
|
||||
internal val Teal90 = Color(0xFFBEEAF6)
|
||||
internal val Teal90 = Color(0xFFBEEAF6)
|
||||
|
||||
@@ -11,4 +11,4 @@ data class GradientColors(
|
||||
val container: Color = Color.Unspecified
|
||||
)
|
||||
|
||||
val LocalGradientColors = staticCompositionLocalOf { GradientColors() }
|
||||
val LocalGradientColors = staticCompositionLocalOf { GradientColors() }
|
||||
|
||||
@@ -207,4 +207,4 @@ fun supportsDynamicTheming() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||
name = "Api 21 Light", group = "ApiLevelPreviews", apiLevel = 21,
|
||||
uiMode = Configuration.UI_MODE_NIGHT_NO or Configuration.UI_MODE_TYPE_NORMAL
|
||||
)
|
||||
annotation class OxygenPreviews
|
||||
annotation class OxygenPreviews
|
||||
|
||||
@@ -9,4 +9,4 @@ data class TintTheme(
|
||||
val iconTint: Color = Color.Unspecified
|
||||
)
|
||||
|
||||
val LocalTintTheme = staticCompositionLocalOf { TintTheme() }
|
||||
val LocalTintTheme = staticCompositionLocalOf { TintTheme() }
|
||||
|
||||
@@ -126,4 +126,4 @@ internal val OxygenTypography = Typography(
|
||||
trim = LineHeightStyle.Trim.LastLineBottom
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -69,9 +69,9 @@ internal fun ToolsRoute(
|
||||
modifier: Modifier = Modifier,
|
||||
viewModel: ToolsScreenViewModel = hiltViewModel(),
|
||||
searchValue: String,
|
||||
onShowSnackbar: suspend (message: String, action: String?) -> Boolean,
|
||||
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
||||
onNavigateToToolStore: () -> Unit
|
||||
onNavigateToToolStore: () -> Unit,
|
||||
onShowSnackbar: suspend (message: String, action: String?) -> Boolean
|
||||
) {
|
||||
val toolsScreenUiStateState by viewModel.toolsScreenUiState.collectAsStateWithLifecycle()
|
||||
|
||||
@@ -81,10 +81,10 @@ internal fun ToolsRoute(
|
||||
|
||||
ToolsScreen(
|
||||
modifier = modifier,
|
||||
onShowSnackbar = onShowSnackbar,
|
||||
toolsScreenUiState = toolsScreenUiStateState,
|
||||
onNavigateToToolView = onNavigateToToolView,
|
||||
onNavigateToToolStore = onNavigateToToolStore,
|
||||
toolsScreenUiState = toolsScreenUiStateState,
|
||||
onShowSnackbar = onShowSnackbar,
|
||||
onUninstall = viewModel::uninstall,
|
||||
onUndo = viewModel::undo,
|
||||
onChangeStar = viewModel::changeStar
|
||||
@@ -95,9 +95,9 @@ internal fun ToolsRoute(
|
||||
internal fun ToolsScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
toolsScreenUiState: ToolsScreenUiState,
|
||||
onShowSnackbar: suspend (message: String, action: String?) -> Boolean,
|
||||
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
||||
onNavigateToToolStore: () -> Unit,
|
||||
onShowSnackbar: suspend (message: String, action: String?) -> Boolean,
|
||||
onUninstall: (ToolEntity) -> Unit,
|
||||
onUndo: (ToolEntity) -> Unit,
|
||||
onChangeStar: (ToolEntity, Boolean) -> Unit
|
||||
@@ -131,14 +131,14 @@ internal fun ToolsScreen(
|
||||
) {
|
||||
val angle by infiniteTransition.animateFloat(
|
||||
initialValue = 0F, targetValue = 360F, animationSpec = infiniteRepeatable(
|
||||
animation = tween(800, easing = Ease),
|
||||
animation = tween(durationMillis = 800, easing = Ease),
|
||||
), label = "angle"
|
||||
)
|
||||
Icon(
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.graphicsLayer { rotationZ = angle },
|
||||
imageVector = OxygenIcons.Loading,
|
||||
imageVector = Loading,
|
||||
contentDescription = ""
|
||||
)
|
||||
}
|
||||
@@ -176,8 +176,8 @@ internal fun ToolsScreen(
|
||||
)
|
||||
|
||||
item(span = StaggeredGridItemSpan.FullLine) {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Spacer(modifier = Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,7 +255,7 @@ private fun ToolMenu(
|
||||
) {
|
||||
DialogTitle(text = selectedTool.name)
|
||||
HorizontalDivider()
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Spacer(Modifier.height(4.dp))
|
||||
DialogSectionGroup {
|
||||
DialogClickerRow(
|
||||
icon = OxygenIcons.Delete,
|
||||
|
||||
@@ -36,7 +36,7 @@ class ToolsScreenViewModel @Inject constructor(
|
||||
}.stateIn(
|
||||
scope = viewModelScope,
|
||||
initialValue = ToolsScreenUiState.Loading,
|
||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
||||
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@ package top.fatweb.oxygen.toolbox.ui.util
|
||||
import androidx.compose.runtime.compositionLocalOf
|
||||
import kotlinx.datetime.TimeZone
|
||||
|
||||
val LocalTimeZone = compositionLocalOf { TimeZone.currentSystemDefault() }
|
||||
val LocalTimeZone = compositionLocalOf { TimeZone.currentSystemDefault() }
|
||||
|
||||
@@ -55,4 +55,4 @@ object LocaleUtils {
|
||||
|
||||
return context
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,4 +44,4 @@ object ResourcesUtils {
|
||||
|
||||
fun getString(context: Context, @StringRes resId: Int): String =
|
||||
context.resources.getString(resId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ internal fun ToolViewRoute(
|
||||
|
||||
ToolViewScreen(
|
||||
modifier = modifier,
|
||||
toolViewUiState = toolViewUiState,
|
||||
isPreview = isPreview,
|
||||
onBackClick = onBackClick,
|
||||
toolViewUiState = toolViewUiState
|
||||
onBackClick = onBackClick
|
||||
)
|
||||
}
|
||||
|
||||
@@ -63,9 +63,9 @@ internal fun ToolViewRoute(
|
||||
@Composable
|
||||
internal fun ToolViewScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
toolViewUiState: ToolViewUiState,
|
||||
isPreview: Boolean,
|
||||
onBackClick: () -> Unit,
|
||||
toolViewUiState: ToolViewUiState
|
||||
onBackClick: () -> Unit
|
||||
) {
|
||||
|
||||
val infiniteTransition = rememberInfiniteTransition(label = "infiniteTransition")
|
||||
@@ -73,7 +73,7 @@ internal fun ToolViewScreen(
|
||||
Scaffold(
|
||||
modifier = Modifier,
|
||||
containerColor = Color.Transparent,
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0)
|
||||
contentWindowInsets = WindowInsets(left = 0, top = 0, right = 0, bottom = 0)
|
||||
) { padding ->
|
||||
Column(
|
||||
modifier
|
||||
@@ -119,14 +119,14 @@ internal fun ToolViewScreen(
|
||||
initialValue = 0F,
|
||||
targetValue = 360F,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(800, easing = Ease),
|
||||
animation = tween(durationMillis = 800, easing = Ease),
|
||||
), label = "angle"
|
||||
)
|
||||
Icon(
|
||||
modifier = Modifier
|
||||
.size(32.dp)
|
||||
.graphicsLayer { rotationZ = angle },
|
||||
imageVector = OxygenIcons.Loading,
|
||||
imageVector = Loading,
|
||||
contentDescription = ""
|
||||
)
|
||||
}
|
||||
@@ -156,4 +156,4 @@ internal fun ToolViewScreen(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class ToolViewScreenViewModel @Inject constructor(
|
||||
.stateIn(
|
||||
scope = viewModelScope,
|
||||
initialValue = ToolViewUiState.Loading,
|
||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
||||
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user