Style(Code): Optimize code style
This commit is contained in:
@@ -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,18 +143,23 @@ class MainActivity : ComponentActivity() {
|
||||
override fun attachBaseContext(newBase: Context) {
|
||||
val userDataRepository =
|
||||
EntryPointAccessors.fromApplication<UserDataRepositoryEntryPoint>(newBase).userDataRepository
|
||||
super.attachBaseContext(LocaleUtils.attachBaseContext(newBase, runBlocking {
|
||||
super.attachBaseContext(
|
||||
LocaleUtils.attachBaseContext(
|
||||
context = newBase,
|
||||
languageConfig = runBlocking {
|
||||
userDataRepository.userData.first().languageConfig
|
||||
}))
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun shouldUseDarkTheme(
|
||||
uiState: MainActivityUiState
|
||||
): Boolean = when (uiState) {
|
||||
private fun shouldUseDarkTheme(uiState: MainActivityUiState): Boolean =
|
||||
when (uiState) {
|
||||
MainActivityUiState.Loading -> isSystemInDarkTheme()
|
||||
is MainActivityUiState.Success -> when (uiState.userData.darkThemeConfig) {
|
||||
is MainActivityUiState.Success ->
|
||||
when (uiState.userData.darkThemeConfig) {
|
||||
DarkThemeConfig.FollowSystem -> isSystemInDarkTheme()
|
||||
DarkThemeConfig.Light -> false
|
||||
DarkThemeConfig.Dark -> true
|
||||
@@ -160,36 +167,33 @@ private fun shouldUseDarkTheme(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun shouldUseAndroidTheme(
|
||||
uiState: MainActivityUiState
|
||||
): Boolean = when (uiState) {
|
||||
private fun shouldUseAndroidTheme(uiState: MainActivityUiState): Boolean =
|
||||
when (uiState) {
|
||||
MainActivityUiState.Loading -> false
|
||||
is MainActivityUiState.Success -> when (uiState.userData.themeBrandConfig) {
|
||||
is MainActivityUiState.Success ->
|
||||
when (uiState.userData.themeBrandConfig) {
|
||||
ThemeBrandConfig.Default -> false
|
||||
ThemeBrandConfig.Android -> true
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun shouldUseDynamicColor(
|
||||
uiState: MainActivityUiState
|
||||
): Boolean = when (uiState) {
|
||||
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) {
|
||||
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) {
|
||||
private fun whatLaunchPage(uiState: MainActivityUiState): LaunchPageConfig =
|
||||
when (uiState) {
|
||||
MainActivityUiState.Loading -> LaunchPageConfig.Tools
|
||||
is MainActivityUiState.Success -> uiState.userData.launchPageConfig
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class MainActivityViewModel @Inject constructor(
|
||||
}.stateIn(
|
||||
scope = viewModelScope,
|
||||
initialValue = MainActivityUiState.Loading,
|
||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
||||
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,11 @@ 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 }
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@ class UserPreferencesSerializer @Inject constructor() : Serializer<UserPreferenc
|
||||
try {
|
||||
UserPreferences.parseFrom(input)
|
||||
} catch (exception: InvalidProtocolBufferException) {
|
||||
throw CorruptionException("Cannot read proto.", exception)
|
||||
throw CorruptionException(
|
||||
message = "Cannot read proto.",
|
||||
cause = exception
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun writeTo(t: UserPreferences, output: OutputStream) {
|
||||
|
||||
@@ -23,6 +23,8 @@ internal object CoroutineScopesModule {
|
||||
@Singleton
|
||||
@ApplicationScope
|
||||
fun providesCoroutineScope(
|
||||
@Dispatcher(OxygenDispatchers.Default) dispatcher: CoroutineDispatcher
|
||||
): CoroutineScope = CoroutineScope(SupervisorJob() + dispatcher)
|
||||
@Dispatcher(OxygenDispatchers.Default)
|
||||
dispatcher: CoroutineDispatcher
|
||||
): CoroutineScope =
|
||||
CoroutineScope(SupervisorJob() + dispatcher)
|
||||
}
|
||||
@@ -41,5 +41,6 @@ internal object NetworkModule {
|
||||
fun providesOxygenNetworkDataSource(
|
||||
networkJson: Json,
|
||||
okhttpCallFactory: dagger.Lazy<Call.Factory>
|
||||
): OxygenNetworkDataSource = RetrofitOxygenNetwork(networkJson, okhttpCallFactory)
|
||||
): OxygenNetworkDataSource =
|
||||
RetrofitOxygenNetwork(networkJson, okhttpCallFactory)
|
||||
}
|
||||
@@ -16,17 +16,11 @@ 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!!
|
||||
}
|
||||
loading = ImageVector.Builder(
|
||||
val Loading: ImageVector
|
||||
get() = ImageVector.Builder(
|
||||
name = "Loading",
|
||||
defaultWidth = 1024.dp,
|
||||
defaultHeight = 1024.dp,
|
||||
@@ -44,37 +38,77 @@ val OxygenIcons.Loading: ImageVector
|
||||
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
|
||||
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(
|
||||
437.71f,
|
||||
437.71f,
|
||||
0f,
|
||||
a = 440.45f,
|
||||
b = 440.45f,
|
||||
theta = 0f,
|
||||
isMoreThanHalf = false,
|
||||
isPositiveArc = false,
|
||||
-139.9f,
|
||||
-94.3f
|
||||
dx1 = -94.3f,
|
||||
dy1 = -139.9f
|
||||
)
|
||||
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)
|
||||
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()
|
||||
}
|
||||
}.build()
|
||||
return loading!!
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ internal class ConnectivityManagerNetworkMonitor @Inject constructor(
|
||||
.conflate()
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun ConnectivityManager.isCurrentlyConnected() = when {
|
||||
private fun ConnectivityManager.isCurrentlyConnected() =
|
||||
when {
|
||||
VERSION.SDK_INT >= VERSION_CODES.M ->
|
||||
activeNetwork
|
||||
?.let(::getNetworkCapabilities)
|
||||
|
||||
@@ -64,5 +64,9 @@ class TimeZoneBroadcastMonitor @Inject constructor(
|
||||
.distinctUntilChanged()
|
||||
.conflate()
|
||||
.flowOn(ioDispatcher)
|
||||
.shareIn(appScope, SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds), 1)
|
||||
.shareIn(
|
||||
scope = appScope,
|
||||
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds),
|
||||
replay = 1
|
||||
)
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,8 @@ data class PageVo<T>(
|
||||
val records: List<T>
|
||||
)
|
||||
|
||||
fun <T, R> PageVo<T>.asExternalModel(block: (T) -> R): Page<R> = Page(
|
||||
fun <T, R> PageVo<T>.asExternalModel(block: (T) -> R): Page<R> =
|
||||
Page(
|
||||
total = total,
|
||||
pages = pages,
|
||||
size = size,
|
||||
|
||||
@@ -23,7 +23,10 @@ internal class ToolStorePagingSource(
|
||||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, ToolEntity> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -63,7 +63,8 @@ internal class RetrofitOxygenNetwork @Inject constructor(
|
||||
toolId: String,
|
||||
ver: String,
|
||||
platform: ToolBaseVo.Platform
|
||||
): Flow<Result<ToolVo>> = flow {
|
||||
): Flow<Result<ToolVo>> =
|
||||
flow {
|
||||
emit(
|
||||
networkApi.detail(
|
||||
username = username,
|
||||
|
||||
@@ -9,15 +9,13 @@ import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
object LocalDateTimeSerializer : KSerializer<LocalDateTime> {
|
||||
|
||||
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'))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<PagingData<ToolEntity>> =
|
||||
Pager(
|
||||
config = PagingConfig(PAGE_SIZE),
|
||||
config = PagingConfig(pageSize = PAGE_SIZE),
|
||||
pagingSourceFactory = {
|
||||
ToolStorePagingSource(
|
||||
oxygenNetworkDataSource,
|
||||
toolDao,
|
||||
searchValue
|
||||
oxygenNetworkDataSource = oxygenNetworkDataSource,
|
||||
toolDao = toolDao,
|
||||
searchValue = searchValue
|
||||
)
|
||||
}
|
||||
).flow
|
||||
@@ -44,9 +43,9 @@ internal class NetworkStoreRepository @Inject constructor(
|
||||
ver: String
|
||||
): Flow<Result<ToolEntity>> =
|
||||
oxygenNetworkDataSource.detail(
|
||||
username,
|
||||
toolId,
|
||||
ver
|
||||
username = username,
|
||||
toolId = toolId,
|
||||
ver = ver
|
||||
).map {
|
||||
it.asExternalModel(ToolVo::asExternalModel)
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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 = ""
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user