From 18c03c194bce951402c2ae42faf1dc34b8c2a64f Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Tue, 20 Aug 2024 18:24:27 +0800 Subject: [PATCH] Style(Code): Optimize code style --- .../top/fatweb/oxygen/toolbox/MainActivity.kt | 92 ++++++----- .../oxygen/toolbox/MainActivityViewModel.kt | 4 +- .../oxygen/toolbox/OxygenApplication.kt | 2 +- .../oxygen/toolbox/data/lib/DepDataSource.kt | 2 +- .../data/network/OxygenNetworkDataSource.kt | 2 +- .../toolbox/data/tool/ToolDataSource.kt | 2 +- .../oxygen/toolbox/data/tool/ToolDatabase.kt | 8 +- .../oxygen/toolbox/data/tool/dao/ToolDao.kt | 2 +- .../data/userdata/IntToStringIdsMigration.kt | 2 +- .../userdata/UserPreferencesSerializer.kt | 7 +- .../toolbox/di/CoroutineScopesModule.kt | 8 +- .../fatweb/oxygen/toolbox/di/DataModule.kt | 2 +- .../oxygen/toolbox/di/DataStoreModule.kt | 2 +- .../oxygen/toolbox/di/DatabaseModule.kt | 2 +- .../oxygen/toolbox/di/DispatchersModule.kt | 2 +- .../fatweb/oxygen/toolbox/di/NetworkModule.kt | 5 +- .../top/fatweb/oxygen/toolbox/icon/Loading.kt | 152 +++++++++++------- .../fatweb/oxygen/toolbox/model/Converters.kt | 2 +- .../top/fatweb/oxygen/toolbox/model/Result.kt | 2 +- .../oxygen/toolbox/model/tool/ToolEntity.kt | 16 +- .../oxygen/toolbox/model/tool/ToolGroup.kt | 2 +- .../toolbox/model/userdata/DarkThemeConfig.kt | 2 +- .../toolbox/model/userdata/LanguageConfig.kt | 2 +- .../model/userdata/LaunchPageConfig.kt | 2 +- .../model/userdata/ThemeBrandConfig.kt | 2 +- .../ConnectivityManagerNetworkMonitor.kt | 17 +- .../oxygen/toolbox/monitor/NetworkMonitor.kt | 2 +- .../monitor/TimeZoneBroadcastMonitor.kt | 8 +- .../toolbox/navigation/AboutNavigation.kt | 2 +- .../toolbox/navigation/LibrariesNavigation.kt | 4 +- .../toolbox/navigation/OxygenNavHost.kt | 2 +- .../toolbox/navigation/StarNavigation.kt | 5 +- .../toolbox/navigation/ToolStoreNavigation.kt | 2 +- .../toolbox/navigation/ToolViewNavigation.kt | 6 +- .../toolbox/navigation/ToolsNavigation.kt | 13 +- .../toolbox/navigation/TopLevelDestination.kt | 2 +- .../toolbox/network/OxygenDispatchers.kt | 2 +- .../oxygen/toolbox/network/model/PageVo.kt | 15 +- .../toolbox/network/model/ToolCategoryVo.kt | 2 +- .../toolbox/network/model/UserWithInfoVo.kt | 2 +- .../network/paging/ToolStorePagingSource.kt | 12 +- .../network/retrofit/RetrofitOxygenNetwork.kt | 19 +-- .../serializer/LocalDateTimeSerializer.kt | 10 +- .../toolbox/repository/lib/DepRepository.kt | 2 +- .../repository/lib/impl/LocalDepRepository.kt | 2 +- .../repository/tool/StoreRepository.kt | 2 +- .../toolbox/repository/tool/ToolRepository.kt | 2 +- .../tool/impl/NetworkStoreRepository.kt | 17 +- .../tool/impl/OfflineToolRepository.kt | 2 +- .../repository/userdata/UserDataRepository.kt | 2 +- .../userdata/impl/LocalUserDataRepository.kt | 2 +- .../top/fatweb/oxygen/toolbox/ui/OxygenApp.kt | 26 +-- .../oxygen/toolbox/ui/OxygenAppState.kt | 6 +- .../oxygen/toolbox/ui/about/AboutScreen.kt | 34 ++-- .../oxygen/toolbox/ui/about/LibrariesPanel.kt | 2 +- .../toolbox/ui/about/LibrariesScreen.kt | 12 +- .../ui/about/LibrariesScreenViewModel.kt | 2 +- .../oxygen/toolbox/ui/component/Dialog.kt | 4 +- .../toolbox/ui/component/LibraryCard.kt | 6 +- .../oxygen/toolbox/ui/component/Navigation.kt | 18 +-- .../toolbox/ui/component/OxygenTopAppBar.kt | 2 +- .../oxygen/toolbox/ui/component/ToolCard.kt | 8 +- .../toolbox/ui/component/ToolGroupCard.kt | 8 +- .../ui/component/scrollbar/ScrollbarExt.kt | 2 +- .../toolbox/ui/settings/SettingsDialog.kt | 44 ++--- .../toolbox/ui/settings/SettingsViewModel.kt | 4 +- .../oxygen/toolbox/ui/star/ToolStarScreen.kt | 12 +- .../ui/star/ToolStarScreenViewModel.kt | 4 +- .../toolbox/ui/store/ToolStoreScreen.kt | 33 ++-- .../oxygen/toolbox/ui/theme/Background.kt | 2 +- .../fatweb/oxygen/toolbox/ui/theme/Color.kt | 2 +- .../oxygen/toolbox/ui/theme/Gradient.kt | 2 +- .../fatweb/oxygen/toolbox/ui/theme/Theme.kt | 2 +- .../fatweb/oxygen/toolbox/ui/theme/Tint.kt | 2 +- .../fatweb/oxygen/toolbox/ui/theme/Type.kt | 2 +- .../oxygen/toolbox/ui/tools/ToolsScreen.kt | 20 +-- .../toolbox/ui/tools/ToolsScreenViewModel.kt | 2 +- .../oxygen/toolbox/ui/util/LocalTimeZone.kt | 2 +- .../oxygen/toolbox/ui/util/LocaleUtils.kt | 2 +- .../oxygen/toolbox/ui/util/ResourcesUtils.kt | 2 +- .../oxygen/toolbox/ui/view/ToolViewScreen.kt | 16 +- .../ui/view/ToolViewScreenViewModel.kt | 2 +- .../oxygen/toolbox/util/OxygenLogger.kt | 6 +- 83 files changed, 424 insertions(+), 349 deletions(-) diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/MainActivity.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/MainActivity.kt index 3b8e61f..730e274 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/MainActivity.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/MainActivity.kt @@ -92,8 +92,8 @@ class MainActivity : ComponentActivity() { LaunchedEffect(darkTheme) { enableEdgeToEdge( statusBarStyle = SystemBarStyle.auto( - android.graphics.Color.TRANSPARENT, - android.graphics.Color.TRANSPARENT + lightScrim = android.graphics.Color.TRANSPARENT, + darkScrim = android.graphics.Color.TRANSPARENT ) { darkTheme }, navigationBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT) ) @@ -108,9 +108,7 @@ class MainActivity : ComponentActivity() { val currentTimeZone by appState.currentTimeZone.collectAsStateWithLifecycle() - CompositionLocalProvider( - LocalTimeZone provides currentTimeZone - ) { + CompositionLocalProvider(LocalTimeZone provides currentTimeZone) { OxygenTheme( darkTheme = darkTheme, androidTheme = shouldUseAndroidTheme(uiState), @@ -125,7 +123,11 @@ class MainActivity : ComponentActivity() { val pathSegments = pathSegments val preview = getBooleanQueryParameter(PREVIEW_ARG, false) if (pathSegments.size == 2) { - appState.navController.navigateToToolView(pathSegments[0], pathSegments[1], preview) + appState.navController.navigateToToolView( + username = pathSegments[0], + toolId = pathSegments[1], + preview = preview + ) } } } @@ -141,55 +143,57 @@ class MainActivity : ComponentActivity() { override fun attachBaseContext(newBase: Context) { val userDataRepository = EntryPointAccessors.fromApplication(newBase).userDataRepository - super.attachBaseContext(LocaleUtils.attachBaseContext(newBase, runBlocking { - userDataRepository.userData.first().languageConfig - })) + super.attachBaseContext( + LocaleUtils.attachBaseContext( + context = newBase, + languageConfig = runBlocking { + userDataRepository.userData.first().languageConfig + } + ) + ) } } @Composable -private fun shouldUseDarkTheme( - uiState: MainActivityUiState -): Boolean = when (uiState) { - MainActivityUiState.Loading -> isSystemInDarkTheme() - is MainActivityUiState.Success -> when (uiState.userData.darkThemeConfig) { - DarkThemeConfig.FollowSystem -> isSystemInDarkTheme() - DarkThemeConfig.Light -> false - DarkThemeConfig.Dark -> true +private fun shouldUseDarkTheme(uiState: MainActivityUiState): Boolean = + when (uiState) { + MainActivityUiState.Loading -> isSystemInDarkTheme() + is MainActivityUiState.Success -> + when (uiState.userData.darkThemeConfig) { + DarkThemeConfig.FollowSystem -> isSystemInDarkTheme() + DarkThemeConfig.Light -> false + DarkThemeConfig.Dark -> true + } } -} @Composable -private fun shouldUseAndroidTheme( - uiState: MainActivityUiState -): Boolean = when (uiState) { - MainActivityUiState.Loading -> false - is MainActivityUiState.Success -> when (uiState.userData.themeBrandConfig) { - ThemeBrandConfig.Default -> false - ThemeBrandConfig.Android -> true +private fun shouldUseAndroidTheme(uiState: MainActivityUiState): Boolean = + when (uiState) { + MainActivityUiState.Loading -> false + is MainActivityUiState.Success -> + when (uiState.userData.themeBrandConfig) { + ThemeBrandConfig.Default -> false + ThemeBrandConfig.Android -> true + } } -} @Composable -private fun shouldUseDynamicColor( - uiState: MainActivityUiState -): Boolean = when (uiState) { - MainActivityUiState.Loading -> true - is MainActivityUiState.Success -> uiState.userData.useDynamicColor -} +private fun shouldUseDynamicColor(uiState: MainActivityUiState): Boolean = + when (uiState) { + MainActivityUiState.Loading -> true + is MainActivityUiState.Success -> uiState.userData.useDynamicColor + } @Composable -private fun whatLocale( - uiState: MainActivityUiState -): LanguageConfig = when (uiState) { - MainActivityUiState.Loading -> LanguageConfig.FollowSystem - is MainActivityUiState.Success -> uiState.userData.languageConfig -} +private fun whatLocale(uiState: MainActivityUiState): LanguageConfig = + when (uiState) { + MainActivityUiState.Loading -> LanguageConfig.FollowSystem + is MainActivityUiState.Success -> uiState.userData.languageConfig + } @Composable -private fun whatLaunchPage( - uiState: MainActivityUiState -): LaunchPageConfig = when (uiState) { - MainActivityUiState.Loading -> LaunchPageConfig.Tools - is MainActivityUiState.Success -> uiState.userData.launchPageConfig -} +private fun whatLaunchPage(uiState: MainActivityUiState): LaunchPageConfig = + when (uiState) { + MainActivityUiState.Loading -> LaunchPageConfig.Tools + is MainActivityUiState.Success -> uiState.userData.launchPageConfig + } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/MainActivityViewModel.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/MainActivityViewModel.kt index eec6640..524b7b8 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/MainActivityViewModel.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/MainActivityViewModel.kt @@ -21,11 +21,11 @@ class MainActivityViewModel @Inject constructor( }.stateIn( scope = viewModelScope, initialValue = MainActivityUiState.Loading, - started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds) + started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds) ) } sealed interface MainActivityUiState { data object Loading : MainActivityUiState data class Success(val userData: UserData) : MainActivityUiState -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/OxygenApplication.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/OxygenApplication.kt index 0e15135..011ec39 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/OxygenApplication.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/OxygenApplication.kt @@ -17,4 +17,4 @@ class OxygenApplication : Application() { Timber.plant(if (BuildConfig.DEBUG) Timber.DebugTree() else OxygenLogTree(this)) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/lib/DepDataSource.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/lib/DepDataSource.kt index 2e48645..57bb278 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/lib/DepDataSource.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/lib/DepDataSource.kt @@ -24,4 +24,4 @@ class DepDataSource @Inject constructor( val dependencies = json.decodeFromString(jsonString) emit(dependencies) }.flowOn(ioDispatcher) -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/network/OxygenNetworkDataSource.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/network/OxygenNetworkDataSource.kt index 9f5ba91..a025f53 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/network/OxygenNetworkDataSource.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/network/OxygenNetworkDataSource.kt @@ -19,4 +19,4 @@ interface OxygenNetworkDataSource { ver: String = "latest", platform: ToolBaseVo.Platform = ToolBaseVo.Platform.Android ): Flow> -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/ToolDataSource.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/ToolDataSource.kt index 6ca7daa..e28ad53 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/ToolDataSource.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/ToolDataSource.kt @@ -22,4 +22,4 @@ class ToolDataSource @Inject constructor( } ) }.flowOn(ioDispatcher) -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/ToolDatabase.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/ToolDatabase.kt index e250e22..14c6d5a 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/ToolDatabase.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/ToolDatabase.kt @@ -22,9 +22,13 @@ abstract class ToolDatabase : RoomDatabase() { fun getInstance(context: Context): ToolDatabase = INSTANCE ?: synchronized(this) { - Room.databaseBuilder(context, ToolDatabase::class.java, "tools.db") + Room.databaseBuilder( + context = context, + klass = ToolDatabase::class.java, + name = "tools.db" + ) .build() .also { INSTANCE = it } } } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/dao/ToolDao.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/dao/ToolDao.kt index 3826a11..78fbecc 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/dao/ToolDao.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/dao/ToolDao.kt @@ -44,4 +44,4 @@ interface ToolDao { "WHERE authorUsername = :username " + "and toolId = :toolId LIMIT 1") fun selectToolByUsernameAndToolId(username: String, toolId: String): Flow -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/IntToStringIdsMigration.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/IntToStringIdsMigration.kt index c2e5a59..3eabb55 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/IntToStringIdsMigration.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/IntToStringIdsMigration.kt @@ -11,4 +11,4 @@ internal object IntToStringIdsMigration : DataMigration { currentData.copy { } override suspend fun shouldMigrate(currentData: UserPreferences): Boolean = false -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/UserPreferencesSerializer.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/UserPreferencesSerializer.kt index cb0a96b..53d79f8 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/UserPreferencesSerializer.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/UserPreferencesSerializer.kt @@ -15,10 +15,13 @@ class UserPreferencesSerializer @Inject constructor() : Serializer - ): OxygenNetworkDataSource = RetrofitOxygenNetwork(networkJson, okhttpCallFactory) -} \ No newline at end of file + ): OxygenNetworkDataSource = + RetrofitOxygenNetwork(networkJson, okhttpCallFactory) +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/icon/Loading.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/icon/Loading.kt index 266ca7e..8714f04 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/icon/Loading.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/icon/Loading.kt @@ -16,65 +16,99 @@ import androidx.compose.ui.unit.dp @Preview @Composable private fun VectorPreview() { - Image(OxygenIcons.Loading, null) + Image(Loading, null) } -private var loading: ImageVector? = null - -val OxygenIcons.Loading: ImageVector - get() { - if (loading != null) { - return loading!! +val Loading: ImageVector + get() = ImageVector.Builder( + name = "Loading", + defaultWidth = 1024.dp, + defaultHeight = 1024.dp, + viewportWidth = 1024f, + viewportHeight = 1024f + ).apply { + path( + fill = SolidColor(Color.Black), + fillAlpha = 1.0f, + stroke = null, + strokeAlpha = 1.0f, + strokeLineWidth = 1.0f, + strokeLineCap = StrokeCap.Butt, + strokeLineJoin = StrokeJoin.Miter, + strokeLineMiter = 1.0f, + pathFillType = PathFillType.NonZero + ) { + moveTo(x = 988f, y = 548f) + curveToRelative( + dx1 = -19.9f, + dy1 = 0f, + dx2 = -36f, + dy2 = -16.1f, + dx3 = -36f, + dy3 = -36f + ) + curveToRelative( + dx1 = 0f, + dy1 = -59.4f, + dx2 = -11.6f, + dy2 = -117f, + dx3 = -34.6f, + dy3 = -171.3f + ) + arcToRelative( + a = 440.45f, + b = 440.45f, + theta = 0f, + isMoreThanHalf = false, + isPositiveArc = false, + dx1 = -94.3f, + dy1 = -139.9f + ) + arcToRelative( + a = 437.71f, + b = 437.71f, + theta = 0f, + isMoreThanHalf = false, + isPositiveArc = false, + dx1 = -139.9f, + dy1 = -94.3f + ) + curveTo(x1 = 629f, y1 = 83.6f, x2 = 571.4f, y2 = 72f, x3 = 512f, y3 = 72f) + curveToRelative( + dx1 = -19.9f, + dy1 = 0f, + dx2 = -36f, + dy2 = -16.1f, + dx3 = -36f, + dy3 = -36f + ) + reflectiveCurveToRelative(dx1 = 16.1f, dy1 = -36f, dx2 = 36f, dy2 = -36f) + curveToRelative( + dx1 = 69.1f, + dy1 = 0f, + dx2 = 136.2f, + dy2 = 13.5f, + dx3 = 199.3f, + dy3 = 40.3f + ) + curveTo(x1 = 772.3f, y1 = 66f, x2 = 827f, y2 = 103f, x3 = 874f, y3 = 150f) + curveToRelative( + dx1 = 47f, + dy1 = 47f, + dx2 = 83.9f, + dy2 = 101.8f, + dx3 = 109.7f, + dy3 = 162.7f + ) + curveToRelative( + dx1 = 26.7f, + dy1 = 63.1f, + dx2 = 40.2f, + dy2 = 130.2f, + dx3 = 40.2f, + dy3 = 199.3f + ) + curveToRelative(dx1 = 0.1f, dy1 = 19.9f, dx2 = -16f, dy2 = 36f, dx3 = -35.9f, dy3 = 36f) + close() } - loading = ImageVector.Builder( - name = "Loading", - defaultWidth = 1024.dp, - defaultHeight = 1024.dp, - viewportWidth = 1024f, - viewportHeight = 1024f - ).apply { - path( - fill = SolidColor(Color.Black), - fillAlpha = 1.0f, - stroke = null, - strokeAlpha = 1.0f, - strokeLineWidth = 1.0f, - strokeLineCap = StrokeCap.Butt, - strokeLineJoin = StrokeJoin.Miter, - strokeLineMiter = 1.0f, - pathFillType = PathFillType.NonZero - ) { - moveTo(988f, 548f) - curveToRelative(-19.9f, 0f, -36f, -16.1f, -36f, -36f) - curveToRelative(0f, -59.4f, -11.6f, -117f, -34.6f, -171.3f) - arcToRelative( - 440.45f, - 440.45f, - 0f, - isMoreThanHalf = false, - isPositiveArc = false, - -94.3f, - -139.9f - ) - arcToRelative( - 437.71f, - 437.71f, - 0f, - isMoreThanHalf = false, - isPositiveArc = false, - -139.9f, - -94.3f - ) - curveTo(629f, 83.6f, 571.4f, 72f, 512f, 72f) - curveToRelative(-19.9f, 0f, -36f, -16.1f, -36f, -36f) - reflectiveCurveToRelative(16.1f, -36f, 36f, -36f) - curveToRelative(69.1f, 0f, 136.2f, 13.5f, 199.3f, 40.3f) - curveTo(772.3f, 66f, 827f, 103f, 874f, 150f) - curveToRelative(47f, 47f, 83.9f, 101.8f, 109.7f, 162.7f) - curveToRelative(26.7f, 63.1f, 40.2f, 130.2f, 40.2f, 199.3f) - curveToRelative(0.1f, 19.9f, -16f, 36f, -35.9f, 36f) - close() - } - }.build() - return loading!! - } + }.build() diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/Converters.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/Converters.kt index 86c5cae..1d66ffa 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/Converters.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/Converters.kt @@ -26,4 +26,4 @@ class Converters { @TypeConverter fun toLocalDateTime(string: String): LocalDateTime = LocalDateTime.parse(string) -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/Result.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/Result.kt index 52c2048..a9023e4 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/Result.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/Result.kt @@ -38,4 +38,4 @@ fun Result.asExternalModel(block: (T) -> R): Result = } Result.Loading -> Result.Loading - } \ No newline at end of file + } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/tool/ToolEntity.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/tool/ToolEntity.kt index 611a442..46602cb 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/tool/ToolEntity.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/tool/ToolEntity.kt @@ -68,8 +68,20 @@ data class ToolEntity( keywords = emptyList(), categories = emptyList(), entryPoint = "", - createTime = LocalDateTime(1970, 1, 1, 0, 0), - updateTime = LocalDateTime(1970, 1, 1, 0, 0), + createTime = LocalDateTime( + year = 1970, + monthNumber = 1, + dayOfMonth = 1, + hour = 0, + minute = 0 + ), + updateTime = LocalDateTime( + year = 1970, + monthNumber = 1, + dayOfMonth = 1, + hour = 0, + minute = 0 + ), upgrade = upgrade ) diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/tool/ToolGroup.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/tool/ToolGroup.kt index 16335f0..6db70ee 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/tool/ToolGroup.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/tool/ToolGroup.kt @@ -11,4 +11,4 @@ data class ToolGroup( val title: String, val tools: List = emptyList() -) \ No newline at end of file +) diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/DarkThemeConfig.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/DarkThemeConfig.kt index 02900b2..65c138f 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/DarkThemeConfig.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/DarkThemeConfig.kt @@ -4,4 +4,4 @@ enum class DarkThemeConfig { FollowSystem, Light, Dark, -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LanguageConfig.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LanguageConfig.kt index 97e3c37..e07e39a 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LanguageConfig.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LanguageConfig.kt @@ -4,4 +4,4 @@ enum class LanguageConfig(val code: String? = null) { FollowSystem, Chinese("cn"), English("en") -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LaunchPageConfig.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LaunchPageConfig.kt index 5e94ea6..ece4bd4 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LaunchPageConfig.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LaunchPageConfig.kt @@ -3,4 +3,4 @@ package top.fatweb.oxygen.toolbox.model.userdata enum class LaunchPageConfig { Tools, Star -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/ThemeBrandConfig.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/ThemeBrandConfig.kt index 691e9cd..f45debe 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/ThemeBrandConfig.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/ThemeBrandConfig.kt @@ -3,4 +3,4 @@ package top.fatweb.oxygen.toolbox.model.userdata enum class ThemeBrandConfig { Default, Android -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/monitor/ConnectivityManagerNetworkMonitor.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/monitor/ConnectivityManagerNetworkMonitor.kt index 6246c08..cc04290 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/monitor/ConnectivityManagerNetworkMonitor.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/monitor/ConnectivityManagerNetworkMonitor.kt @@ -58,12 +58,13 @@ internal class ConnectivityManagerNetworkMonitor @Inject constructor( .conflate() @Suppress("DEPRECATION") - private fun ConnectivityManager.isCurrentlyConnected() = when { - VERSION.SDK_INT >= VERSION_CODES.M -> - activeNetwork - ?.let(::getNetworkCapabilities) - ?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) + private fun ConnectivityManager.isCurrentlyConnected() = + when { + VERSION.SDK_INT >= VERSION_CODES.M -> + activeNetwork + ?.let(::getNetworkCapabilities) + ?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) - else -> activeNetworkInfo?.isConnected - } ?: false -} \ No newline at end of file + else -> activeNetworkInfo?.isConnected + } ?: false +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/monitor/NetworkMonitor.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/monitor/NetworkMonitor.kt index 22795f9..eb8fe36 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/monitor/NetworkMonitor.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/monitor/NetworkMonitor.kt @@ -4,4 +4,4 @@ import kotlinx.coroutines.flow.Flow interface NetworkMonitor { val isOnline: Flow -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/monitor/TimeZoneBroadcastMonitor.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/monitor/TimeZoneBroadcastMonitor.kt index 72f0e7e..0a6369d 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/monitor/TimeZoneBroadcastMonitor.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/monitor/TimeZoneBroadcastMonitor.kt @@ -64,5 +64,9 @@ class TimeZoneBroadcastMonitor @Inject constructor( .distinctUntilChanged() .conflate() .flowOn(ioDispatcher) - .shareIn(appScope, SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds), 1) -} \ No newline at end of file + .shareIn( + scope = appScope, + started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds), + replay = 1 + ) +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/AboutNavigation.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/AboutNavigation.kt index 4dc9db0..0675308 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/AboutNavigation.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/AboutNavigation.kt @@ -11,7 +11,7 @@ import top.fatweb.oxygen.toolbox.ui.about.AboutRoute const val ABOUT_ROUTE = "about_route" fun NavController.navigateToAbout(navOptions: NavOptions? = null) = - navigate(ABOUT_ROUTE, navOptions) + navigate(route = ABOUT_ROUTE, navOptions = navOptions) fun NavGraphBuilder.aboutScreen( onNavigateToLibraries: () -> Unit, diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/LibrariesNavigation.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/LibrariesNavigation.kt index 40d6a48..a8e4503 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/LibrariesNavigation.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/LibrariesNavigation.kt @@ -11,7 +11,7 @@ import top.fatweb.oxygen.toolbox.ui.about.LibrariesRoute const val LIBRARIES_ROUTE = "libraries_route" fun NavController.navigateToLibraries(navOptions: NavOptions? = null) = - navigate(LIBRARIES_ROUTE, navOptions) + navigate(route = LIBRARIES_ROUTE, navOptions = navOptions) fun NavGraphBuilder.librariesScreen( onBackClick: () -> Unit @@ -28,4 +28,4 @@ fun NavGraphBuilder.librariesScreen( ) { LibrariesRoute(onBackClick = onBackClick) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/OxygenNavHost.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/OxygenNavHost.kt index 6dfb791..f69e8d6 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/OxygenNavHost.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/OxygenNavHost.kt @@ -50,4 +50,4 @@ fun OxygenNavHost( onBackClick = navController::popBackStack ) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/StarNavigation.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/StarNavigation.kt index 7b2c4cb..b6ae10b 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/StarNavigation.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/StarNavigation.kt @@ -12,7 +12,8 @@ import top.fatweb.oxygen.toolbox.ui.star.StarRoute const val STAR_ROUTE = "star_route" -fun NavController.navigateToStar(navOptions: NavOptions) = navigate(STAR_ROUTE, navOptions) +fun NavController.navigateToStar(navOptions: NavOptions) = + navigate(route = STAR_ROUTE, navOptions = navOptions) fun NavGraphBuilder.starScreen( isVertical: Boolean, @@ -45,4 +46,4 @@ fun NavGraphBuilder.starScreen( onNavigateToToolView = onNavigateToToolView ) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/ToolStoreNavigation.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/ToolStoreNavigation.kt index 029034a..1043c65 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/ToolStoreNavigation.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/ToolStoreNavigation.kt @@ -13,7 +13,7 @@ import top.fatweb.oxygen.toolbox.ui.store.ToolStoreRoute const val TOOL_STORE_ROUTE = "tool_store_route" fun NavController.navigateToToolStore(navOptions: NavOptions? = null) = - navigate(TOOL_STORE_ROUTE, navOptions) + navigate(route = TOOL_STORE_ROUTE, navOptions = navOptions) fun NavGraphBuilder.toolStoreScreen( isVertical: Boolean, diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/ToolViewNavigation.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/ToolViewNavigation.kt index 686420e..1218b29 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/ToolViewNavigation.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/ToolViewNavigation.kt @@ -19,7 +19,11 @@ internal const val TOOL_ID_ARG = "toolId" internal const val PREVIEW_ARG = "preview" const val TOOL_VIEW_ROUTE = "tool_view_route" -internal class ToolViewArgs(val username: String, val toolId: String, val preview: Boolean) { +internal class ToolViewArgs( + val username: String, + val toolId: String, + val preview: Boolean +) { constructor(savedStateHandle: SavedStateHandle) : this( URLDecoder.decode( diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/ToolsNavigation.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/ToolsNavigation.kt index db822ff..bda698d 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/ToolsNavigation.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/ToolsNavigation.kt @@ -12,14 +12,15 @@ import top.fatweb.oxygen.toolbox.ui.tools.ToolsRoute const val TOOLS_ROUTE = "tools_route" -fun NavController.navigateToTools(navOptions: NavOptions) = navigate(TOOLS_ROUTE, navOptions) +fun NavController.navigateToTools(navOptions: NavOptions) = + navigate(route = TOOLS_ROUTE, navOptions = navOptions) fun NavGraphBuilder.toolsScreen( isVertical: Boolean, 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 ) { composable( route = TOOLS_ROUTE, @@ -52,9 +53,9 @@ fun NavGraphBuilder.toolsScreen( ) { ToolsRoute( searchValue = searchValue, - onShowSnackbar = onShowSnackbar, onNavigateToToolView = onNavigateToToolView, - onNavigateToToolStore = onNavigateToToolStore + onNavigateToToolStore = onNavigateToToolStore, + onShowSnackbar = onShowSnackbar ) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt index cdd6f33..83afb52 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt @@ -35,4 +35,4 @@ enum class TopLevelDestination( iconTextId = R.string.feature_star_title, titleTextId = R.string.feature_star_title ) -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/OxygenDispatchers.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/OxygenDispatchers.kt index 50155aa..af63679 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/OxygenDispatchers.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/OxygenDispatchers.kt @@ -9,4 +9,4 @@ annotation class Dispatcher(val oxygenDispatcher: OxygenDispatchers) enum class OxygenDispatchers { Default, IO -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/PageVo.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/PageVo.kt index 9ae9a78..9821124 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/PageVo.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/PageVo.kt @@ -16,10 +16,11 @@ data class PageVo( val records: List ) -fun PageVo.asExternalModel(block: (T) -> R): Page = Page( - total = total, - pages = pages, - size = size, - current = current, - records = records.map(block) -) +fun PageVo.asExternalModel(block: (T) -> R): Page = + Page( + total = total, + pages = pages, + size = size, + current = current, + records = records.map(block) + ) diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/ToolCategoryVo.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/ToolCategoryVo.kt index df054e8..c7b0a6d 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/ToolCategoryVo.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/ToolCategoryVo.kt @@ -17,4 +17,4 @@ data class ToolCategoryVo( @Serializable(LocalDateTimeSerializer::class) val updateTime: LocalDateTime -) \ No newline at end of file +) diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/UserWithInfoVo.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/UserWithInfoVo.kt index 0a7d68a..e075c97 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/UserWithInfoVo.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/UserWithInfoVo.kt @@ -18,4 +18,4 @@ data class UserWithInfoVo( val avatar: String ) -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/paging/ToolStorePagingSource.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/paging/ToolStorePagingSource.kt index 91fc69d..32aef6b 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/paging/ToolStorePagingSource.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/paging/ToolStorePagingSource.kt @@ -23,7 +23,10 @@ internal class ToolStorePagingSource( override suspend fun load(params: LoadParams): LoadResult { return try { val currentPage = params.key ?: 1 - val (_, success, msg, data) = oxygenNetworkDataSource.getStore(searchValue, currentPage) + val (_, success, msg, data) = oxygenNetworkDataSource.getStore( + searchValue = searchValue, + currentPage = currentPage + ) if (!success) { return LoadResult.Error(RuntimeException(msg)) @@ -33,8 +36,8 @@ internal class ToolStorePagingSource( LoadResult.Page( data = records.map(ToolVo::asExternalModel).map { toolEntity -> toolDao.selectToolByUsernameAndToolId( - toolEntity.authorUsername, - toolEntity.toolId + username = toolEntity.authorUsername, + toolId = toolEntity.toolId ).first()?.let { if (it.id == toolEntity.id) { it @@ -52,5 +55,4 @@ internal class ToolStorePagingSource( LoadResult.Error(e) } } - -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/retrofit/RetrofitOxygenNetwork.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/retrofit/RetrofitOxygenNetwork.kt index 5ee93f2..adea2e2 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/retrofit/RetrofitOxygenNetwork.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/retrofit/RetrofitOxygenNetwork.kt @@ -63,14 +63,15 @@ internal class RetrofitOxygenNetwork @Inject constructor( toolId: String, ver: String, platform: ToolBaseVo.Platform - ): Flow> = flow { - emit( - networkApi.detail( - username = username, - toolId = toolId, - ver = ver, - platform = platform + ): Flow> = + flow { + emit( + networkApi.detail( + username = username, + toolId = toolId, + ver = ver, + platform = platform + ) ) - ) - }.asResult() + }.asResult() } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/serializer/LocalDateTimeSerializer.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/serializer/LocalDateTimeSerializer.kt index 7f7de88..ede1e5c 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/serializer/LocalDateTimeSerializer.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/serializer/LocalDateTimeSerializer.kt @@ -9,15 +9,13 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder object LocalDateTimeSerializer : KSerializer { - override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("LocalDateTime", PrimitiveKind.STRING) + PrimitiveSerialDescriptor(serialName = "LocalDateTime", kind = PrimitiveKind.STRING) override fun deserialize(decoder: Decoder): LocalDateTime = - LocalDateTime.parse(decoder.decodeString().removeSuffix("Z")) + LocalDateTime.parse(input = decoder.decodeString().removeSuffix("Z")) override fun serialize(encoder: Encoder, value: LocalDateTime) { - encoder.encodeString(value.toString().padEnd(24, 'Z')) + encoder.encodeString(value.toString().padEnd(length = 24, padChar = 'Z')) } - -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/lib/DepRepository.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/lib/DepRepository.kt index 4a91613..3b72744 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/lib/DepRepository.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/lib/DepRepository.kt @@ -7,4 +7,4 @@ interface DepRepository { fun searchName(name: String): Flow fun getSearchNameCount(): Flow -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/lib/impl/LocalDepRepository.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/lib/impl/LocalDepRepository.kt index a2dd943..31c0465 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/lib/impl/LocalDepRepository.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/lib/impl/LocalDepRepository.kt @@ -25,4 +25,4 @@ class LocalDepRepository @Inject constructor( @OptIn(ExperimentalCoroutinesApi::class) override fun getSearchNameCount(): Flow = depDataSource.dependencies.flatMapLatest { flowOf(it.libraries.size) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/StoreRepository.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/StoreRepository.kt index e79af2c..7b3f21f 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/StoreRepository.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/StoreRepository.kt @@ -13,4 +13,4 @@ interface StoreRepository { toolId: String, ver: String = "latest" ): Flow> -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/ToolRepository.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/ToolRepository.kt index d30f138..3070a81 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/ToolRepository.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/ToolRepository.kt @@ -19,4 +19,4 @@ interface ToolRepository { suspend fun updateTool(toolEntity: ToolEntity) suspend fun removeTool(toolEntity: ToolEntity) -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/impl/NetworkStoreRepository.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/impl/NetworkStoreRepository.kt index 0b4d14a..cc78cb6 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/impl/NetworkStoreRepository.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/impl/NetworkStoreRepository.kt @@ -22,18 +22,17 @@ internal class NetworkStoreRepository @Inject constructor( private val oxygenNetworkDataSource: OxygenNetworkDataSource, private val toolDao: ToolDao ) : StoreRepository { - override suspend fun getStore( searchValue: String, currentPage: Int ): Flow> = Pager( - config = PagingConfig(PAGE_SIZE), + config = PagingConfig(pageSize = PAGE_SIZE), pagingSourceFactory = { ToolStorePagingSource( - oxygenNetworkDataSource, - toolDao, - searchValue + oxygenNetworkDataSource = oxygenNetworkDataSource, + toolDao = toolDao, + searchValue = searchValue ) } ).flow @@ -44,10 +43,10 @@ internal class NetworkStoreRepository @Inject constructor( ver: String ): Flow> = oxygenNetworkDataSource.detail( - username, - toolId, - ver + username = username, + toolId = toolId, + ver = ver ).map { it.asExternalModel(ToolVo::asExternalModel) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/impl/OfflineToolRepository.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/impl/OfflineToolRepository.kt index 47ebe73..5078400 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/impl/OfflineToolRepository.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/impl/OfflineToolRepository.kt @@ -34,4 +34,4 @@ class OfflineToolRepository @Inject constructor( override suspend fun removeTool(toolEntity: ToolEntity) = toolDao.deleteTool(toolEntity) -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/UserDataRepository.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/UserDataRepository.kt index 22ac7aa..5680534 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/UserDataRepository.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/UserDataRepository.kt @@ -19,4 +19,4 @@ interface UserDataRepository { suspend fun setDarkThemeConfig(darkThemeConfig: DarkThemeConfig) suspend fun setUseDynamicColor(useDynamicColor: Boolean) -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/impl/LocalUserDataRepository.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/impl/LocalUserDataRepository.kt index 8de15d0..72339b4 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/impl/LocalUserDataRepository.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/impl/LocalUserDataRepository.kt @@ -35,4 +35,4 @@ internal class LocalUserDataRepository @Inject constructor( override suspend fun setUseDynamicColor(useDynamicColor: Boolean) { oxygenPreferencesDataSource.setUseDynamicColor(useDynamicColor) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt index 01f058a..a59a4fc 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt @@ -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, - 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, - onNavigateToDestination: (TopLevelDestination) -> Unit, - currentDestination: NavDestination? + currentDestination: NavDestination?, + onNavigateToDestination: (TopLevelDestination) -> Unit ) { OxygenNavigationRail( modifier = modifier diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenAppState.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenAppState.kt index dcf841b..3c8301b 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenAppState.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenAppState.kt @@ -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() -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/AboutScreen.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/AboutScreen.kt index eafb509..34f4c7e 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/AboutScreen.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/AboutScreen.kt @@ -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, diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/LibrariesPanel.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/LibrariesPanel.kt index f2a8668..c880d15 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/LibrariesPanel.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/LibrariesPanel.kt @@ -26,4 +26,4 @@ fun LazyStaggeredGridScope.librariesPanel( } } } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/LibrariesScreen.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/LibrariesScreen.kt index a4bdabe..d49d107 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/LibrariesScreen.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/LibrariesScreen.kt @@ -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, diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/LibrariesScreenViewModel.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/LibrariesScreenViewModel.kt index 8932f34..d5fdc58 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/LibrariesScreenViewModel.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/about/LibrariesScreenViewModel.kt @@ -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) { diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/Dialog.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/Dialog.kt index f88b9c0..9df7120 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/Dialog.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/Dialog.kt @@ -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) } } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/LibraryCard.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/LibraryCard.kt index 8290490..0c85784 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/LibraryCard.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/LibraryCard.kt @@ -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 = {} ) -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/Navigation.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/Navigation.kt index 7670dd2..0e2f7fc 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/Navigation.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/Navigation.kt @@ -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() { } } } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/OxygenTopAppBar.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/OxygenTopAppBar.kt index 72ae6cc..0868efd 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/OxygenTopAppBar.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/OxygenTopAppBar.kt @@ -182,4 +182,4 @@ private fun OxygenTopAppBarPreview() { actionIconContentDescription = "Action icon" ) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/ToolCard.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/ToolCard.kt index 304c63a..466cf9d 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/ToolCard.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/ToolCard.kt @@ -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, diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/ToolGroupCard.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/ToolGroupCard.kt index b20e288..8707ef0 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/ToolGroupCard.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/ToolGroupCard.kt @@ -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 diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/scrollbar/ScrollbarExt.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/scrollbar/ScrollbarExt.kt index be760ca..51cd473 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/scrollbar/ScrollbarExt.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/scrollbar/ScrollbarExt.kt @@ -218,4 +218,4 @@ fun LazyStaggeredGridState.scrollbarState( } private inline fun List.floatSumOf(selector: (T) -> Float): Float = - fold(initial = 0f) { accumulator, listItem -> accumulator + selector(listItem) } \ No newline at end of file + fold(initial = 0f) { accumulator, listItem -> accumulator + selector(listItem) } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/settings/SettingsDialog.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/settings/SettingsDialog.kt index 593c9a5..931e632 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/settings/SettingsDialog.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/settings/SettingsDialog.kt @@ -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 = {} ) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/settings/SettingsViewModel.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/settings/SettingsViewModel.kt index 4074aa6..3b7bb83 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/settings/SettingsViewModel.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/settings/SettingsViewModel.kt @@ -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 -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/star/ToolStarScreen.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/star/ToolStarScreen.kt index bf6e35c..4107b8b 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/star/ToolStarScreen.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/star/ToolStarScreen.kt @@ -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, diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/star/ToolStarScreenViewModel.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/star/ToolStarScreenViewModel.kt index 8c256e6..360d132 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/star/ToolStarScreenViewModel.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/star/ToolStarScreenViewModel.kt @@ -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) : StarScreenUiState } -private const val SEARCH_VALUE = "searchValue" \ No newline at end of file +private const val SEARCH_VALUE = "searchValue" diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/store/ToolStoreScreen.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/store/ToolStoreScreen.kt index 8288675..0d4465a 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/store/ToolStoreScreen.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/store/ToolStoreScreen.kt @@ -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, + 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( } ) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Background.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Background.kt index 83e5016..050017a 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Background.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Background.kt @@ -11,4 +11,4 @@ data class BackgroundTheme( val tonalElevation: Dp = Dp.Unspecified ) -val LocalBackgroundTheme = staticCompositionLocalOf { BackgroundTheme() } \ No newline at end of file +val LocalBackgroundTheme = staticCompositionLocalOf { BackgroundTheme() } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Color.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Color.kt index 41f3c31..5f139d2 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Color.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Color.kt @@ -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) \ No newline at end of file +internal val Teal90 = Color(0xFFBEEAF6) diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Gradient.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Gradient.kt index fa25259..5fdd1c1 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Gradient.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Gradient.kt @@ -11,4 +11,4 @@ data class GradientColors( val container: Color = Color.Unspecified ) -val LocalGradientColors = staticCompositionLocalOf { GradientColors() } \ No newline at end of file +val LocalGradientColors = staticCompositionLocalOf { GradientColors() } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Theme.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Theme.kt index 0febfc1..778f0b9 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Theme.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Theme.kt @@ -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 \ No newline at end of file +annotation class OxygenPreviews diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Tint.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Tint.kt index 75ca5ef..42c3c77 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Tint.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Tint.kt @@ -9,4 +9,4 @@ data class TintTheme( val iconTint: Color = Color.Unspecified ) -val LocalTintTheme = staticCompositionLocalOf { TintTheme() } \ No newline at end of file +val LocalTintTheme = staticCompositionLocalOf { TintTheme() } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Type.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Type.kt index 5f1d0c2..d99e491 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Type.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/theme/Type.kt @@ -126,4 +126,4 @@ internal val OxygenTypography = Typography( trim = LineHeightStyle.Trim.LastLineBottom ) ) -) \ No newline at end of file +) diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/tools/ToolsScreen.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/tools/ToolsScreen.kt index b1f29c3..7da17a5 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/tools/ToolsScreen.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/tools/ToolsScreen.kt @@ -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, diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/tools/ToolsScreenViewModel.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/tools/ToolsScreenViewModel.kt index 8b5022d..1b7b05e 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/tools/ToolsScreenViewModel.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/tools/ToolsScreenViewModel.kt @@ -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) ) diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/LocalTimeZone.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/LocalTimeZone.kt index 66f6d30..b561da1 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/LocalTimeZone.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/LocalTimeZone.kt @@ -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() } \ No newline at end of file +val LocalTimeZone = compositionLocalOf { TimeZone.currentSystemDefault() } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/LocaleUtils.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/LocaleUtils.kt index f2adc61..ffa1b04 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/LocaleUtils.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/LocaleUtils.kt @@ -55,4 +55,4 @@ object LocaleUtils { return context } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/ResourcesUtils.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/ResourcesUtils.kt index 0e97b8c..fe3ae36 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/ResourcesUtils.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/ResourcesUtils.kt @@ -44,4 +44,4 @@ object ResourcesUtils { fun getString(context: Context, @StringRes resId: Int): String = context.resources.getString(resId) -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/view/ToolViewScreen.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/view/ToolViewScreen.kt index cac9feb..5a8c76a 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/view/ToolViewScreen.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/view/ToolViewScreen.kt @@ -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( } } } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/view/ToolViewScreenViewModel.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/view/ToolViewScreenViewModel.kt index 3fd5ded..9da58c4 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/view/ToolViewScreenViewModel.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/view/ToolViewScreenViewModel.kt @@ -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) ) } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/util/OxygenLogger.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/util/OxygenLogger.kt index e620386..4af480f 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/util/OxygenLogger.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/util/OxygenLogger.kt @@ -12,7 +12,7 @@ import java.time.format.DateTimeFormatter class HttpLogger : HttpLoggingInterceptor.Logger { override fun log(message: String) { - Timber.i(message) + Timber.i(message = message) } } @@ -39,7 +39,7 @@ class OxygenLogTree( if (logFile.length() >= maxFileSize) { rotateLogFile() } - logFile.appendText(format(priority, tag, message, t)) + logFile.appendText(text = format(priority = priority, tag = tag, message = message, t = t)) } catch (e: Exception) { Log.e("OxygenLogTree", "Error writing log message to file", e) } @@ -78,4 +78,4 @@ class OxygenLogTree( ) logFile.createNewFile() } -} \ No newline at end of file +}