Style(Code): Optimize code style
This commit is contained in:
@@ -92,8 +92,8 @@ class MainActivity : ComponentActivity() {
|
|||||||
LaunchedEffect(darkTheme) {
|
LaunchedEffect(darkTheme) {
|
||||||
enableEdgeToEdge(
|
enableEdgeToEdge(
|
||||||
statusBarStyle = SystemBarStyle.auto(
|
statusBarStyle = SystemBarStyle.auto(
|
||||||
android.graphics.Color.TRANSPARENT,
|
lightScrim = android.graphics.Color.TRANSPARENT,
|
||||||
android.graphics.Color.TRANSPARENT
|
darkScrim = android.graphics.Color.TRANSPARENT
|
||||||
) { darkTheme },
|
) { darkTheme },
|
||||||
navigationBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT)
|
navigationBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT)
|
||||||
)
|
)
|
||||||
@@ -108,9 +108,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
|
|
||||||
val currentTimeZone by appState.currentTimeZone.collectAsStateWithLifecycle()
|
val currentTimeZone by appState.currentTimeZone.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
CompositionLocalProvider(
|
CompositionLocalProvider(LocalTimeZone provides currentTimeZone) {
|
||||||
LocalTimeZone provides currentTimeZone
|
|
||||||
) {
|
|
||||||
OxygenTheme(
|
OxygenTheme(
|
||||||
darkTheme = darkTheme,
|
darkTheme = darkTheme,
|
||||||
androidTheme = shouldUseAndroidTheme(uiState),
|
androidTheme = shouldUseAndroidTheme(uiState),
|
||||||
@@ -125,7 +123,11 @@ class MainActivity : ComponentActivity() {
|
|||||||
val pathSegments = pathSegments
|
val pathSegments = pathSegments
|
||||||
val preview = getBooleanQueryParameter(PREVIEW_ARG, false)
|
val preview = getBooleanQueryParameter(PREVIEW_ARG, false)
|
||||||
if (pathSegments.size == 2) {
|
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) {
|
override fun attachBaseContext(newBase: Context) {
|
||||||
val userDataRepository =
|
val userDataRepository =
|
||||||
EntryPointAccessors.fromApplication<UserDataRepositoryEntryPoint>(newBase).userDataRepository
|
EntryPointAccessors.fromApplication<UserDataRepositoryEntryPoint>(newBase).userDataRepository
|
||||||
super.attachBaseContext(LocaleUtils.attachBaseContext(newBase, runBlocking {
|
super.attachBaseContext(
|
||||||
|
LocaleUtils.attachBaseContext(
|
||||||
|
context = newBase,
|
||||||
|
languageConfig = runBlocking {
|
||||||
userDataRepository.userData.first().languageConfig
|
userDataRepository.userData.first().languageConfig
|
||||||
}))
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun shouldUseDarkTheme(
|
private fun shouldUseDarkTheme(uiState: MainActivityUiState): Boolean =
|
||||||
uiState: MainActivityUiState
|
when (uiState) {
|
||||||
): Boolean = when (uiState) {
|
|
||||||
MainActivityUiState.Loading -> isSystemInDarkTheme()
|
MainActivityUiState.Loading -> isSystemInDarkTheme()
|
||||||
is MainActivityUiState.Success -> when (uiState.userData.darkThemeConfig) {
|
is MainActivityUiState.Success ->
|
||||||
|
when (uiState.userData.darkThemeConfig) {
|
||||||
DarkThemeConfig.FollowSystem -> isSystemInDarkTheme()
|
DarkThemeConfig.FollowSystem -> isSystemInDarkTheme()
|
||||||
DarkThemeConfig.Light -> false
|
DarkThemeConfig.Light -> false
|
||||||
DarkThemeConfig.Dark -> true
|
DarkThemeConfig.Dark -> true
|
||||||
@@ -160,36 +167,33 @@ private fun shouldUseDarkTheme(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun shouldUseAndroidTheme(
|
private fun shouldUseAndroidTheme(uiState: MainActivityUiState): Boolean =
|
||||||
uiState: MainActivityUiState
|
when (uiState) {
|
||||||
): Boolean = when (uiState) {
|
|
||||||
MainActivityUiState.Loading -> false
|
MainActivityUiState.Loading -> false
|
||||||
is MainActivityUiState.Success -> when (uiState.userData.themeBrandConfig) {
|
is MainActivityUiState.Success ->
|
||||||
|
when (uiState.userData.themeBrandConfig) {
|
||||||
ThemeBrandConfig.Default -> false
|
ThemeBrandConfig.Default -> false
|
||||||
ThemeBrandConfig.Android -> true
|
ThemeBrandConfig.Android -> true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun shouldUseDynamicColor(
|
private fun shouldUseDynamicColor(uiState: MainActivityUiState): Boolean =
|
||||||
uiState: MainActivityUiState
|
when (uiState) {
|
||||||
): Boolean = when (uiState) {
|
|
||||||
MainActivityUiState.Loading -> true
|
MainActivityUiState.Loading -> true
|
||||||
is MainActivityUiState.Success -> uiState.userData.useDynamicColor
|
is MainActivityUiState.Success -> uiState.userData.useDynamicColor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun whatLocale(
|
private fun whatLocale(uiState: MainActivityUiState): LanguageConfig =
|
||||||
uiState: MainActivityUiState
|
when (uiState) {
|
||||||
): LanguageConfig = when (uiState) {
|
|
||||||
MainActivityUiState.Loading -> LanguageConfig.FollowSystem
|
MainActivityUiState.Loading -> LanguageConfig.FollowSystem
|
||||||
is MainActivityUiState.Success -> uiState.userData.languageConfig
|
is MainActivityUiState.Success -> uiState.userData.languageConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun whatLaunchPage(
|
private fun whatLaunchPage(uiState: MainActivityUiState): LaunchPageConfig =
|
||||||
uiState: MainActivityUiState
|
when (uiState) {
|
||||||
): LaunchPageConfig = when (uiState) {
|
|
||||||
MainActivityUiState.Loading -> LaunchPageConfig.Tools
|
MainActivityUiState.Loading -> LaunchPageConfig.Tools
|
||||||
is MainActivityUiState.Success -> uiState.userData.launchPageConfig
|
is MainActivityUiState.Success -> uiState.userData.launchPageConfig
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class MainActivityViewModel @Inject constructor(
|
|||||||
}.stateIn(
|
}.stateIn(
|
||||||
scope = viewModelScope,
|
scope = viewModelScope,
|
||||||
initialValue = MainActivityUiState.Loading,
|
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 =
|
fun getInstance(context: Context): ToolDatabase =
|
||||||
INSTANCE ?: synchronized(this) {
|
INSTANCE ?: synchronized(this) {
|
||||||
Room.databaseBuilder(context, ToolDatabase::class.java, "tools.db")
|
Room.databaseBuilder(
|
||||||
|
context = context,
|
||||||
|
klass = ToolDatabase::class.java,
|
||||||
|
name = "tools.db"
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.also { INSTANCE = it }
|
.also { INSTANCE = it }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ class UserPreferencesSerializer @Inject constructor() : Serializer<UserPreferenc
|
|||||||
try {
|
try {
|
||||||
UserPreferences.parseFrom(input)
|
UserPreferences.parseFrom(input)
|
||||||
} catch (exception: InvalidProtocolBufferException) {
|
} 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) {
|
override suspend fun writeTo(t: UserPreferences, output: OutputStream) {
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ internal object CoroutineScopesModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
@ApplicationScope
|
@ApplicationScope
|
||||||
fun providesCoroutineScope(
|
fun providesCoroutineScope(
|
||||||
@Dispatcher(OxygenDispatchers.Default) dispatcher: CoroutineDispatcher
|
@Dispatcher(OxygenDispatchers.Default)
|
||||||
): CoroutineScope = CoroutineScope(SupervisorJob() + dispatcher)
|
dispatcher: CoroutineDispatcher
|
||||||
|
): CoroutineScope =
|
||||||
|
CoroutineScope(SupervisorJob() + dispatcher)
|
||||||
}
|
}
|
||||||
@@ -41,5 +41,6 @@ internal object NetworkModule {
|
|||||||
fun providesOxygenNetworkDataSource(
|
fun providesOxygenNetworkDataSource(
|
||||||
networkJson: Json,
|
networkJson: Json,
|
||||||
okhttpCallFactory: dagger.Lazy<Call.Factory>
|
okhttpCallFactory: dagger.Lazy<Call.Factory>
|
||||||
): OxygenNetworkDataSource = RetrofitOxygenNetwork(networkJson, okhttpCallFactory)
|
): OxygenNetworkDataSource =
|
||||||
|
RetrofitOxygenNetwork(networkJson, okhttpCallFactory)
|
||||||
}
|
}
|
||||||
@@ -16,17 +16,11 @@ import androidx.compose.ui.unit.dp
|
|||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
private fun VectorPreview() {
|
private fun VectorPreview() {
|
||||||
Image(OxygenIcons.Loading, null)
|
Image(Loading, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var loading: ImageVector? = null
|
val Loading: ImageVector
|
||||||
|
get() = ImageVector.Builder(
|
||||||
val OxygenIcons.Loading: ImageVector
|
|
||||||
get() {
|
|
||||||
if (loading != null) {
|
|
||||||
return loading!!
|
|
||||||
}
|
|
||||||
loading = ImageVector.Builder(
|
|
||||||
name = "Loading",
|
name = "Loading",
|
||||||
defaultWidth = 1024.dp,
|
defaultWidth = 1024.dp,
|
||||||
defaultHeight = 1024.dp,
|
defaultHeight = 1024.dp,
|
||||||
@@ -44,37 +38,77 @@ val OxygenIcons.Loading: ImageVector
|
|||||||
strokeLineMiter = 1.0f,
|
strokeLineMiter = 1.0f,
|
||||||
pathFillType = PathFillType.NonZero
|
pathFillType = PathFillType.NonZero
|
||||||
) {
|
) {
|
||||||
moveTo(988f, 548f)
|
moveTo(x = 988f, y = 548f)
|
||||||
curveToRelative(-19.9f, 0f, -36f, -16.1f, -36f, -36f)
|
curveToRelative(
|
||||||
curveToRelative(0f, -59.4f, -11.6f, -117f, -34.6f, -171.3f)
|
dx1 = -19.9f,
|
||||||
arcToRelative(
|
dy1 = 0f,
|
||||||
440.45f,
|
dx2 = -36f,
|
||||||
440.45f,
|
dy2 = -16.1f,
|
||||||
0f,
|
dx3 = -36f,
|
||||||
isMoreThanHalf = false,
|
dy3 = -36f
|
||||||
isPositiveArc = false,
|
)
|
||||||
-94.3f,
|
curveToRelative(
|
||||||
-139.9f
|
dx1 = 0f,
|
||||||
|
dy1 = -59.4f,
|
||||||
|
dx2 = -11.6f,
|
||||||
|
dy2 = -117f,
|
||||||
|
dx3 = -34.6f,
|
||||||
|
dy3 = -171.3f
|
||||||
)
|
)
|
||||||
arcToRelative(
|
arcToRelative(
|
||||||
437.71f,
|
a = 440.45f,
|
||||||
437.71f,
|
b = 440.45f,
|
||||||
0f,
|
theta = 0f,
|
||||||
isMoreThanHalf = false,
|
isMoreThanHalf = false,
|
||||||
isPositiveArc = false,
|
isPositiveArc = false,
|
||||||
-139.9f,
|
dx1 = -94.3f,
|
||||||
-94.3f
|
dy1 = -139.9f
|
||||||
)
|
)
|
||||||
curveTo(629f, 83.6f, 571.4f, 72f, 512f, 72f)
|
arcToRelative(
|
||||||
curveToRelative(-19.9f, 0f, -36f, -16.1f, -36f, -36f)
|
a = 437.71f,
|
||||||
reflectiveCurveToRelative(16.1f, -36f, 36f, -36f)
|
b = 437.71f,
|
||||||
curveToRelative(69.1f, 0f, 136.2f, 13.5f, 199.3f, 40.3f)
|
theta = 0f,
|
||||||
curveTo(772.3f, 66f, 827f, 103f, 874f, 150f)
|
isMoreThanHalf = false,
|
||||||
curveToRelative(47f, 47f, 83.9f, 101.8f, 109.7f, 162.7f)
|
isPositiveArc = false,
|
||||||
curveToRelative(26.7f, 63.1f, 40.2f, 130.2f, 40.2f, 199.3f)
|
dx1 = -139.9f,
|
||||||
curveToRelative(0.1f, 19.9f, -16f, 36f, -35.9f, 36f)
|
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()
|
close()
|
||||||
}
|
}
|
||||||
}.build()
|
}.build()
|
||||||
return loading!!
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -68,8 +68,20 @@ data class ToolEntity(
|
|||||||
keywords = emptyList(),
|
keywords = emptyList(),
|
||||||
categories = emptyList(),
|
categories = emptyList(),
|
||||||
entryPoint = "",
|
entryPoint = "",
|
||||||
createTime = LocalDateTime(1970, 1, 1, 0, 0),
|
createTime = LocalDateTime(
|
||||||
updateTime = LocalDateTime(1970, 1, 1, 0, 0),
|
year = 1970,
|
||||||
|
monthNumber = 1,
|
||||||
|
dayOfMonth = 1,
|
||||||
|
hour = 0,
|
||||||
|
minute = 0
|
||||||
|
),
|
||||||
|
updateTime = LocalDateTime(
|
||||||
|
year = 1970,
|
||||||
|
monthNumber = 1,
|
||||||
|
dayOfMonth = 1,
|
||||||
|
hour = 0,
|
||||||
|
minute = 0
|
||||||
|
),
|
||||||
upgrade = upgrade
|
upgrade = upgrade
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ internal class ConnectivityManagerNetworkMonitor @Inject constructor(
|
|||||||
.conflate()
|
.conflate()
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
private fun ConnectivityManager.isCurrentlyConnected() = when {
|
private fun ConnectivityManager.isCurrentlyConnected() =
|
||||||
|
when {
|
||||||
VERSION.SDK_INT >= VERSION_CODES.M ->
|
VERSION.SDK_INT >= VERSION_CODES.M ->
|
||||||
activeNetwork
|
activeNetwork
|
||||||
?.let(::getNetworkCapabilities)
|
?.let(::getNetworkCapabilities)
|
||||||
|
|||||||
@@ -64,5 +64,9 @@ class TimeZoneBroadcastMonitor @Inject constructor(
|
|||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.conflate()
|
.conflate()
|
||||||
.flowOn(ioDispatcher)
|
.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"
|
const val ABOUT_ROUTE = "about_route"
|
||||||
|
|
||||||
fun NavController.navigateToAbout(navOptions: NavOptions? = null) =
|
fun NavController.navigateToAbout(navOptions: NavOptions? = null) =
|
||||||
navigate(ABOUT_ROUTE, navOptions)
|
navigate(route = ABOUT_ROUTE, navOptions = navOptions)
|
||||||
|
|
||||||
fun NavGraphBuilder.aboutScreen(
|
fun NavGraphBuilder.aboutScreen(
|
||||||
onNavigateToLibraries: () -> Unit,
|
onNavigateToLibraries: () -> Unit,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import top.fatweb.oxygen.toolbox.ui.about.LibrariesRoute
|
|||||||
const val LIBRARIES_ROUTE = "libraries_route"
|
const val LIBRARIES_ROUTE = "libraries_route"
|
||||||
|
|
||||||
fun NavController.navigateToLibraries(navOptions: NavOptions? = null) =
|
fun NavController.navigateToLibraries(navOptions: NavOptions? = null) =
|
||||||
navigate(LIBRARIES_ROUTE, navOptions)
|
navigate(route = LIBRARIES_ROUTE, navOptions = navOptions)
|
||||||
|
|
||||||
fun NavGraphBuilder.librariesScreen(
|
fun NavGraphBuilder.librariesScreen(
|
||||||
onBackClick: () -> Unit
|
onBackClick: () -> Unit
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ import top.fatweb.oxygen.toolbox.ui.star.StarRoute
|
|||||||
|
|
||||||
const val STAR_ROUTE = "star_route"
|
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(
|
fun NavGraphBuilder.starScreen(
|
||||||
isVertical: Boolean,
|
isVertical: Boolean,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import top.fatweb.oxygen.toolbox.ui.store.ToolStoreRoute
|
|||||||
const val TOOL_STORE_ROUTE = "tool_store_route"
|
const val TOOL_STORE_ROUTE = "tool_store_route"
|
||||||
|
|
||||||
fun NavController.navigateToToolStore(navOptions: NavOptions? = null) =
|
fun NavController.navigateToToolStore(navOptions: NavOptions? = null) =
|
||||||
navigate(TOOL_STORE_ROUTE, navOptions)
|
navigate(route = TOOL_STORE_ROUTE, navOptions = navOptions)
|
||||||
|
|
||||||
fun NavGraphBuilder.toolStoreScreen(
|
fun NavGraphBuilder.toolStoreScreen(
|
||||||
isVertical: Boolean,
|
isVertical: Boolean,
|
||||||
|
|||||||
@@ -19,7 +19,11 @@ internal const val TOOL_ID_ARG = "toolId"
|
|||||||
internal const val PREVIEW_ARG = "preview"
|
internal const val PREVIEW_ARG = "preview"
|
||||||
const val TOOL_VIEW_ROUTE = "tool_view_route"
|
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) :
|
constructor(savedStateHandle: SavedStateHandle) :
|
||||||
this(
|
this(
|
||||||
URLDecoder.decode(
|
URLDecoder.decode(
|
||||||
|
|||||||
@@ -12,14 +12,15 @@ import top.fatweb.oxygen.toolbox.ui.tools.ToolsRoute
|
|||||||
|
|
||||||
const val TOOLS_ROUTE = "tools_route"
|
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(
|
fun NavGraphBuilder.toolsScreen(
|
||||||
isVertical: Boolean,
|
isVertical: Boolean,
|
||||||
searchValue: String,
|
searchValue: String,
|
||||||
onShowSnackbar: suspend (message: String, action: String?) -> Boolean,
|
|
||||||
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
||||||
onNavigateToToolStore: () -> Unit
|
onNavigateToToolStore: () -> Unit,
|
||||||
|
onShowSnackbar: suspend (message: String, action: String?) -> Boolean
|
||||||
) {
|
) {
|
||||||
composable(
|
composable(
|
||||||
route = TOOLS_ROUTE,
|
route = TOOLS_ROUTE,
|
||||||
@@ -52,9 +53,9 @@ fun NavGraphBuilder.toolsScreen(
|
|||||||
) {
|
) {
|
||||||
ToolsRoute(
|
ToolsRoute(
|
||||||
searchValue = searchValue,
|
searchValue = searchValue,
|
||||||
onShowSnackbar = onShowSnackbar,
|
|
||||||
onNavigateToToolView = onNavigateToToolView,
|
onNavigateToToolView = onNavigateToToolView,
|
||||||
onNavigateToToolStore = onNavigateToToolStore
|
onNavigateToToolStore = onNavigateToToolStore,
|
||||||
|
onShowSnackbar = onShowSnackbar
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,8 @@ data class PageVo<T>(
|
|||||||
val records: List<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,
|
total = total,
|
||||||
pages = pages,
|
pages = pages,
|
||||||
size = size,
|
size = size,
|
||||||
|
|||||||
@@ -23,7 +23,10 @@ internal class ToolStorePagingSource(
|
|||||||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, ToolEntity> {
|
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, ToolEntity> {
|
||||||
return try {
|
return try {
|
||||||
val currentPage = params.key ?: 1
|
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) {
|
if (!success) {
|
||||||
return LoadResult.Error(RuntimeException(msg))
|
return LoadResult.Error(RuntimeException(msg))
|
||||||
@@ -33,8 +36,8 @@ internal class ToolStorePagingSource(
|
|||||||
LoadResult.Page(
|
LoadResult.Page(
|
||||||
data = records.map(ToolVo::asExternalModel).map { toolEntity ->
|
data = records.map(ToolVo::asExternalModel).map { toolEntity ->
|
||||||
toolDao.selectToolByUsernameAndToolId(
|
toolDao.selectToolByUsernameAndToolId(
|
||||||
toolEntity.authorUsername,
|
username = toolEntity.authorUsername,
|
||||||
toolEntity.toolId
|
toolId = toolEntity.toolId
|
||||||
).first()?.let {
|
).first()?.let {
|
||||||
if (it.id == toolEntity.id) {
|
if (it.id == toolEntity.id) {
|
||||||
it
|
it
|
||||||
@@ -52,5 +55,4 @@ internal class ToolStorePagingSource(
|
|||||||
LoadResult.Error(e)
|
LoadResult.Error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,8 @@ internal class RetrofitOxygenNetwork @Inject constructor(
|
|||||||
toolId: String,
|
toolId: String,
|
||||||
ver: String,
|
ver: String,
|
||||||
platform: ToolBaseVo.Platform
|
platform: ToolBaseVo.Platform
|
||||||
): Flow<Result<ToolVo>> = flow {
|
): Flow<Result<ToolVo>> =
|
||||||
|
flow {
|
||||||
emit(
|
emit(
|
||||||
networkApi.detail(
|
networkApi.detail(
|
||||||
username = username,
|
username = username,
|
||||||
|
|||||||
@@ -9,15 +9,13 @@ import kotlinx.serialization.encoding.Decoder
|
|||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
object LocalDateTimeSerializer : KSerializer<LocalDateTime> {
|
object LocalDateTimeSerializer : KSerializer<LocalDateTime> {
|
||||||
|
|
||||||
override val descriptor: SerialDescriptor =
|
override val descriptor: SerialDescriptor =
|
||||||
PrimitiveSerialDescriptor("LocalDateTime", PrimitiveKind.STRING)
|
PrimitiveSerialDescriptor(serialName = "LocalDateTime", kind = PrimitiveKind.STRING)
|
||||||
|
|
||||||
override fun deserialize(decoder: Decoder): LocalDateTime =
|
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) {
|
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 oxygenNetworkDataSource: OxygenNetworkDataSource,
|
||||||
private val toolDao: ToolDao
|
private val toolDao: ToolDao
|
||||||
) : StoreRepository {
|
) : StoreRepository {
|
||||||
|
|
||||||
override suspend fun getStore(
|
override suspend fun getStore(
|
||||||
searchValue: String,
|
searchValue: String,
|
||||||
currentPage: Int
|
currentPage: Int
|
||||||
): Flow<PagingData<ToolEntity>> =
|
): Flow<PagingData<ToolEntity>> =
|
||||||
Pager(
|
Pager(
|
||||||
config = PagingConfig(PAGE_SIZE),
|
config = PagingConfig(pageSize = PAGE_SIZE),
|
||||||
pagingSourceFactory = {
|
pagingSourceFactory = {
|
||||||
ToolStorePagingSource(
|
ToolStorePagingSource(
|
||||||
oxygenNetworkDataSource,
|
oxygenNetworkDataSource = oxygenNetworkDataSource,
|
||||||
toolDao,
|
toolDao = toolDao,
|
||||||
searchValue
|
searchValue = searchValue
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
).flow
|
).flow
|
||||||
@@ -44,9 +43,9 @@ internal class NetworkStoreRepository @Inject constructor(
|
|||||||
ver: String
|
ver: String
|
||||||
): Flow<Result<ToolEntity>> =
|
): Flow<Result<ToolEntity>> =
|
||||||
oxygenNetworkDataSource.detail(
|
oxygenNetworkDataSource.detail(
|
||||||
username,
|
username = username,
|
||||||
toolId,
|
toolId = toolId,
|
||||||
ver
|
ver = ver
|
||||||
).map {
|
).map {
|
||||||
it.asExternalModel(ToolVo::asExternalModel)
|
it.asExternalModel(ToolVo::asExternalModel)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,11 +121,11 @@ fun OxygenApp(appState: OxygenAppState) {
|
|||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
|
.nestedScroll(connection = topAppBarScrollBehavior.nestedScrollConnection),
|
||||||
containerColor = Color.Transparent,
|
containerColor = Color.Transparent,
|
||||||
contentColor = MaterialTheme.colorScheme.onBackground,
|
contentColor = MaterialTheme.colorScheme.onBackground,
|
||||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
contentWindowInsets = WindowInsets(left = 0, top = 0, right = 0, bottom = 0),
|
||||||
snackbarHost = { SnackbarHost(snackbarHostState) },
|
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = appState.shouldShowBottomBar && destination != null,
|
visible = appState.shouldShowBottomBar && destination != null,
|
||||||
@@ -135,8 +135,8 @@ fun OxygenApp(appState: OxygenAppState) {
|
|||||||
) {
|
) {
|
||||||
OxygenBottomBar(
|
OxygenBottomBar(
|
||||||
destinations = appState.topLevelDestinations,
|
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(
|
OxygenNavRail(
|
||||||
modifier = Modifier.safeDrawingPadding(),
|
modifier = Modifier.safeDrawingPadding(),
|
||||||
destinations = appState.topLevelDestinations,
|
destinations = appState.topLevelDestinations,
|
||||||
onNavigateToDestination = appState::navigateToTopLevelDestination,
|
currentDestination = appState.currentDestination,
|
||||||
currentDestination = appState.currentDestination
|
onNavigateToDestination = appState::navigateToTopLevelDestination
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ fun OxygenApp(appState: OxygenAppState) {
|
|||||||
OxygenTopAppBar(
|
OxygenTopAppBar(
|
||||||
scrollBehavior = topAppBarScrollBehavior,
|
scrollBehavior = topAppBarScrollBehavior,
|
||||||
title = {
|
title = {
|
||||||
Text(text = stringResource(id = destination.titleTextId))
|
Text(text = stringResource(destination.titleTextId))
|
||||||
},
|
},
|
||||||
navigationIcon = OxygenIcons.Search,
|
navigationIcon = OxygenIcons.Search,
|
||||||
navigationIconContentDescription = stringResource(R.string.feature_settings_top_app_bar_navigation_icon_description),
|
navigationIconContentDescription = stringResource(R.string.feature_settings_top_app_bar_navigation_icon_description),
|
||||||
@@ -226,8 +226,8 @@ fun OxygenApp(appState: OxygenAppState) {
|
|||||||
private fun OxygenBottomBar(
|
private fun OxygenBottomBar(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
destinations: List<TopLevelDestination>,
|
destinations: List<TopLevelDestination>,
|
||||||
onNavigateToDestination: (TopLevelDestination) -> Unit,
|
currentDestination: NavDestination?,
|
||||||
currentDestination: NavDestination?
|
onNavigateToDestination: (TopLevelDestination) -> Unit
|
||||||
) {
|
) {
|
||||||
OxygenNavigationBar(
|
OxygenNavigationBar(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
@@ -260,8 +260,8 @@ private fun OxygenBottomBar(
|
|||||||
private fun OxygenNavRail(
|
private fun OxygenNavRail(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
destinations: List<TopLevelDestination>,
|
destinations: List<TopLevelDestination>,
|
||||||
onNavigateToDestination: (TopLevelDestination) -> Unit,
|
currentDestination: NavDestination?,
|
||||||
currentDestination: NavDestination?
|
onNavigateToDestination: (TopLevelDestination) -> Unit
|
||||||
) {
|
) {
|
||||||
OxygenNavigationRail(
|
OxygenNavigationRail(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
|
|||||||
@@ -91,14 +91,14 @@ class OxygenAppState(
|
|||||||
.stateIn(
|
.stateIn(
|
||||||
scope = coroutineScope,
|
scope = coroutineScope,
|
||||||
initialValue = false,
|
initialValue = false,
|
||||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||||
)
|
)
|
||||||
|
|
||||||
val currentTimeZone = timeZoneMonitor.currentTimeZone
|
val currentTimeZone = timeZoneMonitor.currentTimeZone
|
||||||
.stateIn(
|
.stateIn(
|
||||||
scope = coroutineScope,
|
scope = coroutineScope,
|
||||||
initialValue = TimeZone.currentSystemDefault(),
|
initialValue = TimeZone.currentSystemDefault(),
|
||||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun navigateToTopLevelDestination(topLevelDestination: TopLevelDestination) {
|
fun navigateToTopLevelDestination(topLevelDestination: TopLevelDestination) {
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ import top.fatweb.oxygen.toolbox.ui.util.ResourcesUtils
|
|||||||
@Composable
|
@Composable
|
||||||
internal fun AboutRoute(
|
internal fun AboutRoute(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onNavigateToLibraries: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
onBackClick: () -> Unit
|
onNavigateToLibraries: () -> Unit
|
||||||
) {
|
) {
|
||||||
AboutScreen(
|
AboutScreen(
|
||||||
modifier = modifier.safeDrawingPadding(),
|
modifier = modifier.safeDrawingPadding(),
|
||||||
@@ -57,8 +57,8 @@ internal fun AboutRoute(
|
|||||||
@Composable
|
@Composable
|
||||||
internal fun AboutScreen(
|
internal fun AboutScreen(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onNavigateToLibraries: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
onBackClick: () -> Unit
|
onNavigateToLibraries: () -> Unit
|
||||||
) {
|
) {
|
||||||
val scrollState = rememberScrollState()
|
val scrollState = rememberScrollState()
|
||||||
val topAppBarScrollBehavior =
|
val topAppBarScrollBehavior =
|
||||||
@@ -66,9 +66,9 @@ internal fun AboutScreen(
|
|||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
|
.nestedScroll(connection = topAppBarScrollBehavior.nestedScrollConnection),
|
||||||
containerColor = Color.Transparent,
|
containerColor = Color.Transparent,
|
||||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
contentWindowInsets = WindowInsets(left = 0, top = 0, right = 0, bottom = 0),
|
||||||
) { padding ->
|
) { padding ->
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
@@ -80,12 +80,13 @@ internal fun AboutScreen(
|
|||||||
WindowInsetsSides.Horizontal
|
WindowInsetsSides.Horizontal
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.verticalScroll(scrollState), horizontalAlignment = Alignment.CenterHorizontally
|
.verticalScroll(state = scrollState),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
OxygenTopAppBar(
|
OxygenTopAppBar(
|
||||||
scrollBehavior = topAppBarScrollBehavior,
|
scrollBehavior = topAppBarScrollBehavior,
|
||||||
title = {
|
title = {
|
||||||
Text(text = stringResource(id = R.string.feature_settings_more_about))
|
Text(text = stringResource(R.string.feature_settings_more_about))
|
||||||
},
|
},
|
||||||
navigationIcon = OxygenIcons.Back,
|
navigationIcon = OxygenIcons.Back,
|
||||||
navigationIconContentDescription = stringResource(R.string.core_back),
|
navigationIconContentDescription = stringResource(R.string.core_back),
|
||||||
@@ -95,13 +96,9 @@ internal fun AboutScreen(
|
|||||||
),
|
),
|
||||||
onNavigationClick = onBackClick
|
onNavigationClick = onBackClick
|
||||||
)
|
)
|
||||||
Spacer(
|
Spacer(Modifier.height(64.dp))
|
||||||
modifier = Modifier.height(64.dp)
|
|
||||||
)
|
|
||||||
AboutAppInfo()
|
AboutAppInfo()
|
||||||
Spacer(
|
Spacer(Modifier.weight(1f))
|
||||||
modifier = Modifier.weight(1f)
|
|
||||||
)
|
|
||||||
AboutFooter(
|
AboutFooter(
|
||||||
onNavigateToLibraries = onNavigateToLibraries
|
onNavigateToLibraries = onNavigateToLibraries
|
||||||
)
|
)
|
||||||
@@ -114,26 +111,27 @@ private fun AboutAppInfo(
|
|||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier, horizontalAlignment = Alignment.CenterHorizontally
|
modifier = modifier,
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Image(
|
Image(
|
||||||
imageVector = ImageVector.vectorResource(R.drawable.ic_oxygen),
|
imageVector = ImageVector.vectorResource(R.drawable.ic_oxygen),
|
||||||
contentDescription = stringResource(R.string.app_full_name)
|
contentDescription = stringResource(R.string.app_full_name)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
Text(
|
Text(
|
||||||
style = MaterialTheme.typography.headlineMedium,
|
style = MaterialTheme.typography.headlineMedium,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
text = stringResource(R.string.app_name)
|
text = stringResource(R.string.app_name)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(Modifier.height(8.dp))
|
||||||
Text(
|
Text(
|
||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
color = MaterialTheme.colorScheme.outline,
|
color = MaterialTheme.colorScheme.outline,
|
||||||
text = stringResource(R.string.app_description)
|
text = stringResource(R.string.app_description)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(Modifier.height(8.dp))
|
||||||
Text(
|
Text(
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.outline,
|
color = MaterialTheme.colorScheme.outline,
|
||||||
|
|||||||
@@ -123,9 +123,9 @@ internal fun LibrariesScreen(
|
|||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.nestedScroll(topAppBarScrollBehavior.nestedScrollConnection),
|
.nestedScroll(connection = topAppBarScrollBehavior.nestedScrollConnection),
|
||||||
containerColor = Color.Transparent,
|
containerColor = Color.Transparent,
|
||||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
contentWindowInsets = WindowInsets(left = 0, top = 0, right = 0, bottom = 0),
|
||||||
) { padding ->
|
) { padding ->
|
||||||
Column(
|
Column(
|
||||||
modifier
|
modifier
|
||||||
@@ -141,7 +141,7 @@ internal fun LibrariesScreen(
|
|||||||
OxygenTopAppBar(
|
OxygenTopAppBar(
|
||||||
scrollBehavior = topAppBarScrollBehavior,
|
scrollBehavior = topAppBarScrollBehavior,
|
||||||
title = {
|
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,
|
navigationIcon = OxygenIcons.Back,
|
||||||
navigationIconContentDescription = stringResource(R.string.core_back),
|
navigationIconContentDescription = stringResource(R.string.core_back),
|
||||||
@@ -180,14 +180,14 @@ internal fun LibrariesScreen(
|
|||||||
initialValue = 0F,
|
initialValue = 0F,
|
||||||
targetValue = 360F,
|
targetValue = 360F,
|
||||||
animationSpec = infiniteRepeatable(
|
animationSpec = infiniteRepeatable(
|
||||||
animation = tween(800, easing = Ease),
|
animation = tween(durationMillis = 800, easing = Ease),
|
||||||
), label = "angle"
|
), label = "angle"
|
||||||
)
|
)
|
||||||
Icon(
|
Icon(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(32.dp)
|
.size(32.dp)
|
||||||
.graphicsLayer { rotationZ = angle },
|
.graphicsLayer { rotationZ = angle },
|
||||||
imageVector = OxygenIcons.Loading,
|
imageVector = Loading,
|
||||||
contentDescription = ""
|
contentDescription = ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -255,7 +255,7 @@ internal fun LibrariesScreen(
|
|||||||
},
|
},
|
||||||
text = {
|
text = {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.verticalScroll(rememberScrollState())
|
modifier = Modifier.verticalScroll(state = rememberScrollState())
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier,
|
modifier = Modifier,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class LibrariesScreenViewModel @Inject constructor(
|
|||||||
.stateIn(
|
.stateIn(
|
||||||
scope = viewModelScope,
|
scope = viewModelScope,
|
||||||
initialValue = LibrariesScreenUiState.Loading,
|
initialValue = LibrariesScreenUiState.Loading,
|
||||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun onSearchValueChange(value: String) {
|
fun onSearchValueChange(value: String) {
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ fun DialogChooserRow(
|
|||||||
selected = selected,
|
selected = selected,
|
||||||
onClick = null
|
onClick = null
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
Spacer(Modifier.width(8.dp))
|
||||||
Text(text)
|
Text(text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ fun DialogClickerRow(
|
|||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Icon(imageVector = icon ?: OxygenIcons.Reorder, contentDescription = null)
|
Icon(imageVector = icon ?: OxygenIcons.Reorder, contentDescription = null)
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
Spacer(Modifier.width(8.dp))
|
||||||
Text(text)
|
Text(text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,13 +59,13 @@ fun LibraryCard(
|
|||||||
version = artifactVersion ?: stringResource(R.string.core_unknown)
|
version = artifactVersion ?: stringResource(R.string.core_unknown)
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
|
|
||||||
LibraryContent(
|
LibraryContent(
|
||||||
text = description ?: ""
|
text = description ?: ""
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
|
|
||||||
LibraryFooter(
|
LibraryFooter(
|
||||||
licenses = licenses,
|
licenses = licenses,
|
||||||
|
|||||||
@@ -27,16 +27,15 @@ fun RowScope.OxygenNavigationBarItem(
|
|||||||
label: @Composable (() -> Unit)? = null,
|
label: @Composable (() -> Unit)? = null,
|
||||||
icon: @Composable () -> Unit,
|
icon: @Composable () -> Unit,
|
||||||
selectedIcon: @Composable () -> Unit,
|
selectedIcon: @Composable () -> Unit,
|
||||||
onClick: () -> Unit,
|
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
alwaysShowLabel: Boolean = false
|
alwaysShowLabel: Boolean = false,
|
||||||
|
onClick: () -> Unit
|
||||||
) {
|
) {
|
||||||
NavigationBarItem(
|
NavigationBarItem(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
selected = selected,
|
selected = selected,
|
||||||
label = label,
|
label = label,
|
||||||
icon = if (selected) selectedIcon else icon,
|
icon = if (selected) selectedIcon else icon,
|
||||||
onClick = onClick,
|
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
alwaysShowLabel = alwaysShowLabel,
|
alwaysShowLabel = alwaysShowLabel,
|
||||||
colors = NavigationBarItemDefaults.colors(
|
colors = NavigationBarItemDefaults.colors(
|
||||||
@@ -45,7 +44,8 @@ fun RowScope.OxygenNavigationBarItem(
|
|||||||
selectedTextColor = OxygenNavigationDefaults.navigationSelectedItemColor(),
|
selectedTextColor = OxygenNavigationDefaults.navigationSelectedItemColor(),
|
||||||
unselectedTextColor = OxygenNavigationDefaults.navigationContentColor(),
|
unselectedTextColor = OxygenNavigationDefaults.navigationContentColor(),
|
||||||
indicatorColor = OxygenNavigationDefaults.navigationIndicatorColor()
|
indicatorColor = OxygenNavigationDefaults.navigationIndicatorColor()
|
||||||
)
|
),
|
||||||
|
onClick = onClick
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,16 +69,15 @@ fun OxygenNavigationRailItem(
|
|||||||
label: @Composable (() -> Unit)? = null,
|
label: @Composable (() -> Unit)? = null,
|
||||||
icon: @Composable () -> Unit,
|
icon: @Composable () -> Unit,
|
||||||
selectedIcon: @Composable () -> Unit,
|
selectedIcon: @Composable () -> Unit,
|
||||||
onClick: () -> Unit,
|
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
alwaysShowLabel: Boolean = true
|
alwaysShowLabel: Boolean = true,
|
||||||
|
onClick: () -> Unit
|
||||||
) {
|
) {
|
||||||
NavigationRailItem(
|
NavigationRailItem(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
selected = selected,
|
selected = selected,
|
||||||
label = label,
|
label = label,
|
||||||
icon = if (selected) selectedIcon else icon,
|
icon = if (selected) selectedIcon else icon,
|
||||||
onClick = onClick,
|
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
alwaysShowLabel = alwaysShowLabel,
|
alwaysShowLabel = alwaysShowLabel,
|
||||||
colors = NavigationRailItemDefaults.colors(
|
colors = NavigationRailItemDefaults.colors(
|
||||||
@@ -87,7 +86,8 @@ fun OxygenNavigationRailItem(
|
|||||||
selectedTextColor = OxygenNavigationDefaults.navigationSelectedItemColor(),
|
selectedTextColor = OxygenNavigationDefaults.navigationSelectedItemColor(),
|
||||||
unselectedTextColor = OxygenNavigationDefaults.navigationContentColor(),
|
unselectedTextColor = OxygenNavigationDefaults.navigationContentColor(),
|
||||||
indicatorColor = OxygenNavigationDefaults.navigationIndicatorColor()
|
indicatorColor = OxygenNavigationDefaults.navigationIndicatorColor()
|
||||||
)
|
),
|
||||||
|
onClick = onClick
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,15 +65,15 @@ fun ToolCard(
|
|||||||
actionIconContentDescription = actionIconContentDescription,
|
actionIconContentDescription = actionIconContentDescription,
|
||||||
onAction = onAction
|
onAction = onAction
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
ToolIcon(icon = tool.icon)
|
ToolIcon(icon = tool.icon)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
ToolInfo(
|
ToolInfo(
|
||||||
toolName = tool.name,
|
toolName = tool.name,
|
||||||
toolId = tool.toolId,
|
toolId = tool.toolId,
|
||||||
toolDesc = tool.description
|
toolDesc = tool.description
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
AuthorInfo(
|
AuthorInfo(
|
||||||
avatar = tool.authorAvatar,
|
avatar = tool.authorAvatar,
|
||||||
nickname = tool.authorNickname
|
nickname = tool.authorNickname
|
||||||
@@ -95,7 +95,7 @@ private fun ToolHeader(
|
|||||||
.height(28.dp)
|
.height(28.dp)
|
||||||
) {
|
) {
|
||||||
ToolVer(ver = ver)
|
ToolVer(ver = ver)
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(Modifier.weight(1f))
|
||||||
actionIcon?.let {
|
actionIcon?.let {
|
||||||
ToolAction(
|
ToolAction(
|
||||||
actionIcon = actionIcon,
|
actionIcon = actionIcon,
|
||||||
|
|||||||
@@ -85,9 +85,9 @@ fun ToolGroupTitle(
|
|||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
Icon(modifier = Modifier.size(18.dp), imageVector = icon, contentDescription = title)
|
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)
|
Text(text = title, style = MaterialTheme.typography.titleMedium)
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(Modifier.weight(1f))
|
||||||
SwitchableIcon(icon = OxygenIcons.ArrowDown, switched = !isExpanded)
|
SwitchableIcon(icon = OxygenIcons.ArrowDown, switched = !isExpanded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ fun ToolGroupItem(
|
|||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Icon(modifier = Modifier.size(16.dp), imageVector = icon, contentDescription = null)
|
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)
|
Text(text = title, style = MaterialTheme.typography.bodyMedium)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ private fun ToolGroupCardPreview() {
|
|||||||
LazyColumn {
|
LazyColumn {
|
||||||
itemsIndexed(groups) { index, item ->
|
itemsIndexed(groups) { index, item ->
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
Spacer(modifier = Modifier.height(10.dp))
|
Spacer(Modifier.height(10.dp))
|
||||||
}
|
}
|
||||||
ToolGroupCard(
|
ToolGroupCard(
|
||||||
toolGroup = item
|
toolGroup = item
|
||||||
|
|||||||
@@ -52,22 +52,22 @@ import top.fatweb.oxygen.toolbox.ui.theme.supportsDynamicTheming
|
|||||||
fun SettingsDialog(
|
fun SettingsDialog(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
viewModel: SettingsViewModel = hiltViewModel(),
|
viewModel: SettingsViewModel = hiltViewModel(),
|
||||||
onDismiss: () -> Unit,
|
|
||||||
onNavigateToLibraries: () -> Unit,
|
onNavigateToLibraries: () -> Unit,
|
||||||
onNavigateToAbout: () -> Unit
|
onNavigateToAbout: () -> Unit,
|
||||||
|
onDismiss: () -> Unit
|
||||||
) {
|
) {
|
||||||
val settingsUiState by viewModel.settingsUiState.collectAsStateWithLifecycle()
|
val settingsUiState by viewModel.settingsUiState.collectAsStateWithLifecycle()
|
||||||
SettingsDialog(
|
SettingsDialog(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
settingsUiState = settingsUiState,
|
settingsUiState = settingsUiState,
|
||||||
|
onNavigateToLibraries = onNavigateToLibraries,
|
||||||
|
onNavigateToAbout = onNavigateToAbout,
|
||||||
onDismiss = onDismiss,
|
onDismiss = onDismiss,
|
||||||
onChangeLanguageConfig = viewModel::updateLanguageConfig,
|
onChangeLanguageConfig = viewModel::updateLanguageConfig,
|
||||||
onChangeLaunchPageConfig = viewModel::updateLaunchPageConfig,
|
onChangeLaunchPageConfig = viewModel::updateLaunchPageConfig,
|
||||||
onchangeThemeBrandConfig = viewModel::updateThemeBrandConfig,
|
onchangeThemeBrandConfig = viewModel::updateThemeBrandConfig,
|
||||||
onChangeDarkThemeConfig = viewModel::updateDarkThemeConfig,
|
onChangeDarkThemeConfig = viewModel::updateDarkThemeConfig,
|
||||||
onchangeUseDynamicColor = viewModel::updateUseDynamicColor,
|
onchangeUseDynamicColor = viewModel::updateUseDynamicColor
|
||||||
onNavigateToLibraries = onNavigateToLibraries,
|
|
||||||
onNavigateToAbout = onNavigateToAbout
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,15 +75,15 @@ fun SettingsDialog(
|
|||||||
fun SettingsDialog(
|
fun SettingsDialog(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
settingsUiState: SettingsUiState,
|
settingsUiState: SettingsUiState,
|
||||||
|
onNavigateToLibraries: () -> Unit,
|
||||||
|
onNavigateToAbout: () -> Unit,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
supportDynamicColor: Boolean = supportsDynamicTheming(),
|
supportDynamicColor: Boolean = supportsDynamicTheming(),
|
||||||
onChangeLanguageConfig: (languageConfig: LanguageConfig) -> Unit,
|
onChangeLanguageConfig: (languageConfig: LanguageConfig) -> Unit,
|
||||||
onChangeLaunchPageConfig: (launchPageConfig: LaunchPageConfig) -> Unit,
|
onChangeLaunchPageConfig: (launchPageConfig: LaunchPageConfig) -> Unit,
|
||||||
onchangeThemeBrandConfig: (themeBrandConfig: ThemeBrandConfig) -> Unit,
|
onchangeThemeBrandConfig: (themeBrandConfig: ThemeBrandConfig) -> Unit,
|
||||||
onChangeDarkThemeConfig: (darkThemeConfig: DarkThemeConfig) -> Unit,
|
onChangeDarkThemeConfig: (darkThemeConfig: DarkThemeConfig) -> Unit,
|
||||||
onchangeUseDynamicColor: (useDynamicColor: Boolean) -> Unit,
|
onchangeUseDynamicColor: (useDynamicColor: Boolean) -> Unit
|
||||||
onNavigateToLibraries: () -> Unit,
|
|
||||||
onNavigateToAbout: () -> Unit
|
|
||||||
) {
|
) {
|
||||||
val configuration = LocalConfiguration.current
|
val configuration = LocalConfiguration.current
|
||||||
val infiniteTransition = rememberInfiniteTransition(label = "infiniteTransition")
|
val infiniteTransition = rememberInfiniteTransition(label = "infiniteTransition")
|
||||||
@@ -122,7 +122,7 @@ fun SettingsDialog(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(32.dp)
|
.size(32.dp)
|
||||||
.graphicsLayer { rotationZ = angle },
|
.graphicsLayer { rotationZ = angle },
|
||||||
imageVector = OxygenIcons.Loading,
|
imageVector = Loading,
|
||||||
contentDescription = ""
|
contentDescription = ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -132,14 +132,14 @@ fun SettingsDialog(
|
|||||||
SettingsPanel(
|
SettingsPanel(
|
||||||
settings = settingsUiState.settings,
|
settings = settingsUiState.settings,
|
||||||
supportDynamicColor = supportDynamicColor,
|
supportDynamicColor = supportDynamicColor,
|
||||||
|
onNavigateToLibraries = onNavigateToLibraries,
|
||||||
|
onNavigateToAbout = onNavigateToAbout,
|
||||||
onDismiss = onDismiss,
|
onDismiss = onDismiss,
|
||||||
onChangeLanguageConfig = onChangeLanguageConfig,
|
onChangeLanguageConfig = onChangeLanguageConfig,
|
||||||
onChangeLaunchPageConfig = onChangeLaunchPageConfig,
|
onChangeLaunchPageConfig = onChangeLaunchPageConfig,
|
||||||
onchangeThemeBrandConfig = onchangeThemeBrandConfig,
|
onchangeThemeBrandConfig = onchangeThemeBrandConfig,
|
||||||
onChangeDarkThemeConfig = onChangeDarkThemeConfig,
|
onChangeDarkThemeConfig = onChangeDarkThemeConfig,
|
||||||
onchangeUseDynamicColor = onchangeUseDynamicColor,
|
onchangeUseDynamicColor = onchangeUseDynamicColor
|
||||||
onNavigateToLibraries = onNavigateToLibraries,
|
|
||||||
onNavigateToAbout = onNavigateToAbout
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,14 +162,14 @@ fun SettingsDialog(
|
|||||||
private fun ColumnScope.SettingsPanel(
|
private fun ColumnScope.SettingsPanel(
|
||||||
settings: UserData,
|
settings: UserData,
|
||||||
supportDynamicColor: Boolean,
|
supportDynamicColor: Boolean,
|
||||||
|
onNavigateToLibraries: () -> Unit,
|
||||||
|
onNavigateToAbout: () -> Unit,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
onChangeLanguageConfig: (languageConfig: LanguageConfig) -> Unit,
|
onChangeLanguageConfig: (languageConfig: LanguageConfig) -> Unit,
|
||||||
onChangeLaunchPageConfig: (launchPageConfig: LaunchPageConfig) -> Unit,
|
onChangeLaunchPageConfig: (launchPageConfig: LaunchPageConfig) -> Unit,
|
||||||
onchangeThemeBrandConfig: (themeBrandConfig: ThemeBrandConfig) -> Unit,
|
onchangeThemeBrandConfig: (themeBrandConfig: ThemeBrandConfig) -> Unit,
|
||||||
onChangeDarkThemeConfig: (darkThemeConfig: DarkThemeConfig) -> Unit,
|
onChangeDarkThemeConfig: (darkThemeConfig: DarkThemeConfig) -> Unit,
|
||||||
onchangeUseDynamicColor: (useDynamicColor: Boolean) -> Unit,
|
onchangeUseDynamicColor: (useDynamicColor: Boolean) -> Unit
|
||||||
onNavigateToLibraries: () -> Unit,
|
|
||||||
onNavigateToAbout: () -> Unit
|
|
||||||
) {
|
) {
|
||||||
DialogSectionTitle(text = stringResource(R.string.feature_settings_language))
|
DialogSectionTitle(text = stringResource(R.string.feature_settings_language))
|
||||||
DialogSectionGroup {
|
DialogSectionGroup {
|
||||||
@@ -275,15 +275,15 @@ private fun ColumnScope.SettingsPanel(
|
|||||||
private fun SettingsDialogLoadingPreview() {
|
private fun SettingsDialogLoadingPreview() {
|
||||||
OxygenTheme {
|
OxygenTheme {
|
||||||
SettingsDialog(
|
SettingsDialog(
|
||||||
|
onNavigateToLibraries = {},
|
||||||
|
onNavigateToAbout = {},
|
||||||
onDismiss = { },
|
onDismiss = { },
|
||||||
settingsUiState = SettingsUiState.Loading,
|
settingsUiState = SettingsUiState.Loading,
|
||||||
onChangeLanguageConfig = {},
|
onChangeLanguageConfig = {},
|
||||||
onChangeLaunchPageConfig = {},
|
onChangeLaunchPageConfig = {},
|
||||||
onchangeThemeBrandConfig = {},
|
onchangeThemeBrandConfig = {},
|
||||||
onChangeDarkThemeConfig = {},
|
onChangeDarkThemeConfig = {},
|
||||||
onchangeUseDynamicColor = {},
|
onchangeUseDynamicColor = {}
|
||||||
onNavigateToLibraries = {},
|
|
||||||
onNavigateToAbout = {}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,6 +293,8 @@ private fun SettingsDialogLoadingPreview() {
|
|||||||
private fun SettingDialogPreview() {
|
private fun SettingDialogPreview() {
|
||||||
OxygenTheme {
|
OxygenTheme {
|
||||||
SettingsDialog(
|
SettingsDialog(
|
||||||
|
onNavigateToLibraries = {},
|
||||||
|
onNavigateToAbout = {},
|
||||||
onDismiss = {},
|
onDismiss = {},
|
||||||
settingsUiState = SettingsUiState.Success(
|
settingsUiState = SettingsUiState.Success(
|
||||||
UserData(
|
UserData(
|
||||||
@@ -307,9 +309,7 @@ private fun SettingDialogPreview() {
|
|||||||
onChangeLaunchPageConfig = {},
|
onChangeLaunchPageConfig = {},
|
||||||
onchangeThemeBrandConfig = {},
|
onchangeThemeBrandConfig = {},
|
||||||
onChangeDarkThemeConfig = {},
|
onChangeDarkThemeConfig = {},
|
||||||
onchangeUseDynamicColor = {},
|
onchangeUseDynamicColor = {}
|
||||||
onNavigateToLibraries = {},
|
|
||||||
onNavigateToAbout = {}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ class SettingsViewModel @Inject constructor(
|
|||||||
.stateIn(
|
.stateIn(
|
||||||
scope = viewModelScope,
|
scope = viewModelScope,
|
||||||
initialValue = SettingsUiState.Loading,
|
initialValue = SettingsUiState.Loading,
|
||||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun updateLanguageConfig(languageConfig: LanguageConfig) {
|
fun updateLanguageConfig(languageConfig: LanguageConfig) {
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ internal fun StarScreen(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(32.dp)
|
.size(32.dp)
|
||||||
.graphicsLayer { rotationZ = angle },
|
.graphicsLayer { rotationZ = angle },
|
||||||
imageVector = OxygenIcons.Loading,
|
imageVector = Loading,
|
||||||
contentDescription = ""
|
contentDescription = ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -152,8 +152,8 @@ internal fun StarScreen(
|
|||||||
)
|
)
|
||||||
|
|
||||||
item(span = StaggeredGridItemSpan.FullLine) {
|
item(span = StaggeredGridItemSpan.FullLine) {
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(Modifier.height(8.dp))
|
||||||
Spacer(modifier = Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
|
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,8 +173,8 @@ internal fun StarScreen(
|
|||||||
|
|
||||||
if (isShowMenu && selectedTool != null) {
|
if (isShowMenu && selectedTool != null) {
|
||||||
ToolMenu(
|
ToolMenu(
|
||||||
onDismiss = { isShowMenu = false },
|
|
||||||
selectedTool = selectedTool!!,
|
selectedTool = selectedTool!!,
|
||||||
|
onDismiss = { isShowMenu = false },
|
||||||
onUnstar = {
|
onUnstar = {
|
||||||
isShowMenu = false
|
isShowMenu = false
|
||||||
onUnstar(selectedTool!!)
|
onUnstar(selectedTool!!)
|
||||||
@@ -207,8 +207,8 @@ private fun LazyStaggeredGridScope.toolsPanel(
|
|||||||
@Composable
|
@Composable
|
||||||
private fun ToolMenu(
|
private fun ToolMenu(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onDismiss: () -> Unit,
|
|
||||||
selectedTool: ToolEntity,
|
selectedTool: ToolEntity,
|
||||||
|
onDismiss: () -> Unit,
|
||||||
onUnstar: () -> Unit
|
onUnstar: () -> Unit
|
||||||
) {
|
) {
|
||||||
ModalBottomSheet(onDismissRequest = onDismiss, dragHandle = {}) {
|
ModalBottomSheet(onDismissRequest = onDismiss, dragHandle = {}) {
|
||||||
@@ -217,7 +217,7 @@ private fun ToolMenu(
|
|||||||
){
|
){
|
||||||
DialogTitle(text = selectedTool.name)
|
DialogTitle(text = selectedTool.name)
|
||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(Modifier.height(4.dp))
|
||||||
DialogSectionGroup {
|
DialogSectionGroup {
|
||||||
DialogClickerRow(
|
DialogClickerRow(
|
||||||
icon = OxygenIcons.StarBorder,
|
icon = OxygenIcons.StarBorder,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class StarScreenViewModel @Inject constructor(
|
|||||||
}.stateIn(
|
}.stateIn(
|
||||||
scope = viewModelScope,
|
scope = viewModelScope,
|
||||||
initialValue = StarScreenUiState.Loading,
|
initialValue = StarScreenUiState.Loading,
|
||||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun onSearchValueChange(value: String) {
|
fun onSearchValueChange(value: String) {
|
||||||
|
|||||||
@@ -78,26 +78,26 @@ internal fun ToolStoreRoute(
|
|||||||
|
|
||||||
ToolStoreScreen(
|
ToolStoreScreen(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
onNavigateToToolView = onNavigateToToolView,
|
|
||||||
toolStorePagingItems = toolStorePagingItems,
|
toolStorePagingItems = toolStorePagingItems,
|
||||||
|
installInfo = installInfo,
|
||||||
|
onNavigateToToolView = onNavigateToToolView,
|
||||||
onChangeInstallStatus = viewModel::changeInstallInfo,
|
onChangeInstallStatus = viewModel::changeInstallInfo,
|
||||||
onChangeInstallType = {
|
onChangeInstallType = {
|
||||||
viewModel.changeInstallInfo(type = it)
|
viewModel.changeInstallInfo(type = it)
|
||||||
},
|
},
|
||||||
onInstallTool = viewModel::installTool,
|
onInstallTool = viewModel::installTool
|
||||||
installInfo = installInfo
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun ToolStoreScreen(
|
internal fun ToolStoreScreen(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
|
||||||
toolStorePagingItems: LazyPagingItems<ToolEntity>,
|
toolStorePagingItems: LazyPagingItems<ToolEntity>,
|
||||||
|
installInfo: ToolStoreUiState.InstallInfo,
|
||||||
|
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
||||||
onChangeInstallStatus: (status: ToolStoreUiState.InstallInfo.Status) -> Unit,
|
onChangeInstallStatus: (status: ToolStoreUiState.InstallInfo.Status) -> Unit,
|
||||||
onChangeInstallType: (type: ToolStoreUiState.InstallInfo.Type) -> Unit,
|
onChangeInstallType: (type: ToolStoreUiState.InstallInfo.Type) -> Unit,
|
||||||
onInstallTool: (installTool: ToolEntity) -> Unit,
|
onInstallTool: (installTool: ToolEntity) -> Unit
|
||||||
installInfo: ToolStoreUiState.InstallInfo
|
|
||||||
) {
|
) {
|
||||||
val isToolLoading =
|
val isToolLoading =
|
||||||
toolStorePagingItems.loadState.refresh is LoadState.Loading
|
toolStorePagingItems.loadState.refresh is LoadState.Loading
|
||||||
@@ -112,7 +112,11 @@ internal fun ToolStoreScreen(
|
|||||||
|
|
||||||
val infiniteTransition = rememberInfiniteTransition(label = "infiniteTransition")
|
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(
|
Box(
|
||||||
modifier.fillMaxSize()
|
modifier.fillMaxSize()
|
||||||
@@ -137,7 +141,7 @@ internal fun ToolStoreScreen(
|
|||||||
)
|
)
|
||||||
|
|
||||||
item(span = StaggeredGridItemSpan.FullLine) {
|
item(span = StaggeredGridItemSpan.FullLine) {
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(Modifier.height(8.dp))
|
||||||
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
|
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,14 +156,14 @@ internal fun ToolStoreScreen(
|
|||||||
initialValue = 0F,
|
initialValue = 0F,
|
||||||
targetValue = 360F,
|
targetValue = 360F,
|
||||||
animationSpec = infiniteRepeatable(
|
animationSpec = infiniteRepeatable(
|
||||||
animation = tween(800, easing = Ease),
|
animation = tween(durationMillis = 800, easing = Ease),
|
||||||
), label = "angle"
|
), label = "angle"
|
||||||
)
|
)
|
||||||
Icon(
|
Icon(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(32.dp)
|
.size(32.dp)
|
||||||
.graphicsLayer { rotationZ = angle },
|
.graphicsLayer { rotationZ = angle },
|
||||||
imageVector = OxygenIcons.Loading,
|
imageVector = Loading,
|
||||||
contentDescription = ""
|
contentDescription = ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -171,7 +175,8 @@ internal fun ToolStoreScreen(
|
|||||||
.windowInsetsPadding(WindowInsets.systemBars)
|
.windowInsetsPadding(WindowInsets.systemBars)
|
||||||
.padding(horizontal = 2.dp)
|
.padding(horizontal = 2.dp)
|
||||||
.align(Alignment.CenterEnd),
|
.align(Alignment.CenterEnd),
|
||||||
state = scrollbarState, orientation = Orientation.Vertical,
|
state = scrollbarState,
|
||||||
|
orientation = Orientation.Vertical,
|
||||||
onThumbMoved = state.rememberDraggableScroller(itemsAvailable = itemsAvailable)
|
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(
|
||||||
text = stringResource(
|
text = stringResource(
|
||||||
when (type) {
|
when (type) {
|
||||||
@@ -296,7 +301,7 @@ private fun InstallAlertDialog(
|
|||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
CircularProgressIndicator()
|
CircularProgressIndicator()
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(
|
text = stringResource(
|
||||||
when (type) {
|
when (type) {
|
||||||
|
|||||||
@@ -69,9 +69,9 @@ internal fun ToolsRoute(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
viewModel: ToolsScreenViewModel = hiltViewModel(),
|
viewModel: ToolsScreenViewModel = hiltViewModel(),
|
||||||
searchValue: String,
|
searchValue: String,
|
||||||
onShowSnackbar: suspend (message: String, action: String?) -> Boolean,
|
|
||||||
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
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()
|
val toolsScreenUiStateState by viewModel.toolsScreenUiState.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
@@ -81,10 +81,10 @@ internal fun ToolsRoute(
|
|||||||
|
|
||||||
ToolsScreen(
|
ToolsScreen(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
onShowSnackbar = onShowSnackbar,
|
toolsScreenUiState = toolsScreenUiStateState,
|
||||||
onNavigateToToolView = onNavigateToToolView,
|
onNavigateToToolView = onNavigateToToolView,
|
||||||
onNavigateToToolStore = onNavigateToToolStore,
|
onNavigateToToolStore = onNavigateToToolStore,
|
||||||
toolsScreenUiState = toolsScreenUiStateState,
|
onShowSnackbar = onShowSnackbar,
|
||||||
onUninstall = viewModel::uninstall,
|
onUninstall = viewModel::uninstall,
|
||||||
onUndo = viewModel::undo,
|
onUndo = viewModel::undo,
|
||||||
onChangeStar = viewModel::changeStar
|
onChangeStar = viewModel::changeStar
|
||||||
@@ -95,9 +95,9 @@ internal fun ToolsRoute(
|
|||||||
internal fun ToolsScreen(
|
internal fun ToolsScreen(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
toolsScreenUiState: ToolsScreenUiState,
|
toolsScreenUiState: ToolsScreenUiState,
|
||||||
onShowSnackbar: suspend (message: String, action: String?) -> Boolean,
|
|
||||||
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
onNavigateToToolView: (username: String, toolId: String, preview: Boolean) -> Unit,
|
||||||
onNavigateToToolStore: () -> Unit,
|
onNavigateToToolStore: () -> Unit,
|
||||||
|
onShowSnackbar: suspend (message: String, action: String?) -> Boolean,
|
||||||
onUninstall: (ToolEntity) -> Unit,
|
onUninstall: (ToolEntity) -> Unit,
|
||||||
onUndo: (ToolEntity) -> Unit,
|
onUndo: (ToolEntity) -> Unit,
|
||||||
onChangeStar: (ToolEntity, Boolean) -> Unit
|
onChangeStar: (ToolEntity, Boolean) -> Unit
|
||||||
@@ -131,14 +131,14 @@ internal fun ToolsScreen(
|
|||||||
) {
|
) {
|
||||||
val angle by infiniteTransition.animateFloat(
|
val angle by infiniteTransition.animateFloat(
|
||||||
initialValue = 0F, targetValue = 360F, animationSpec = infiniteRepeatable(
|
initialValue = 0F, targetValue = 360F, animationSpec = infiniteRepeatable(
|
||||||
animation = tween(800, easing = Ease),
|
animation = tween(durationMillis = 800, easing = Ease),
|
||||||
), label = "angle"
|
), label = "angle"
|
||||||
)
|
)
|
||||||
Icon(
|
Icon(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(32.dp)
|
.size(32.dp)
|
||||||
.graphicsLayer { rotationZ = angle },
|
.graphicsLayer { rotationZ = angle },
|
||||||
imageVector = OxygenIcons.Loading,
|
imageVector = Loading,
|
||||||
contentDescription = ""
|
contentDescription = ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -176,8 +176,8 @@ internal fun ToolsScreen(
|
|||||||
)
|
)
|
||||||
|
|
||||||
item(span = StaggeredGridItemSpan.FullLine) {
|
item(span = StaggeredGridItemSpan.FullLine) {
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(Modifier.height(8.dp))
|
||||||
Spacer(modifier = Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
|
Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.safeDrawing))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,7 +255,7 @@ private fun ToolMenu(
|
|||||||
) {
|
) {
|
||||||
DialogTitle(text = selectedTool.name)
|
DialogTitle(text = selectedTool.name)
|
||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Spacer(Modifier.height(4.dp))
|
||||||
DialogSectionGroup {
|
DialogSectionGroup {
|
||||||
DialogClickerRow(
|
DialogClickerRow(
|
||||||
icon = OxygenIcons.Delete,
|
icon = OxygenIcons.Delete,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class ToolsScreenViewModel @Inject constructor(
|
|||||||
}.stateIn(
|
}.stateIn(
|
||||||
scope = viewModelScope,
|
scope = viewModelScope,
|
||||||
initialValue = ToolsScreenUiState.Loading,
|
initialValue = ToolsScreenUiState.Loading,
|
||||||
started = SharingStarted.WhileSubscribed(5.seconds.inWholeMilliseconds)
|
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5.seconds.inWholeMilliseconds)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ internal fun ToolViewRoute(
|
|||||||
|
|
||||||
ToolViewScreen(
|
ToolViewScreen(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
|
toolViewUiState = toolViewUiState,
|
||||||
isPreview = isPreview,
|
isPreview = isPreview,
|
||||||
onBackClick = onBackClick,
|
onBackClick = onBackClick
|
||||||
toolViewUiState = toolViewUiState
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,9 +63,9 @@ internal fun ToolViewRoute(
|
|||||||
@Composable
|
@Composable
|
||||||
internal fun ToolViewScreen(
|
internal fun ToolViewScreen(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
toolViewUiState: ToolViewUiState,
|
||||||
isPreview: Boolean,
|
isPreview: Boolean,
|
||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit
|
||||||
toolViewUiState: ToolViewUiState
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val infiniteTransition = rememberInfiniteTransition(label = "infiniteTransition")
|
val infiniteTransition = rememberInfiniteTransition(label = "infiniteTransition")
|
||||||
@@ -73,7 +73,7 @@ internal fun ToolViewScreen(
|
|||||||
Scaffold(
|
Scaffold(
|
||||||
modifier = Modifier,
|
modifier = Modifier,
|
||||||
containerColor = Color.Transparent,
|
containerColor = Color.Transparent,
|
||||||
contentWindowInsets = WindowInsets(0, 0, 0, 0)
|
contentWindowInsets = WindowInsets(left = 0, top = 0, right = 0, bottom = 0)
|
||||||
) { padding ->
|
) { padding ->
|
||||||
Column(
|
Column(
|
||||||
modifier
|
modifier
|
||||||
@@ -119,14 +119,14 @@ internal fun ToolViewScreen(
|
|||||||
initialValue = 0F,
|
initialValue = 0F,
|
||||||
targetValue = 360F,
|
targetValue = 360F,
|
||||||
animationSpec = infiniteRepeatable(
|
animationSpec = infiniteRepeatable(
|
||||||
animation = tween(800, easing = Ease),
|
animation = tween(durationMillis = 800, easing = Ease),
|
||||||
), label = "angle"
|
), label = "angle"
|
||||||
)
|
)
|
||||||
Icon(
|
Icon(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(32.dp)
|
.size(32.dp)
|
||||||
.graphicsLayer { rotationZ = angle },
|
.graphicsLayer { rotationZ = angle },
|
||||||
imageVector = OxygenIcons.Loading,
|
imageVector = Loading,
|
||||||
contentDescription = ""
|
contentDescription = ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class ToolViewScreenViewModel @Inject constructor(
|
|||||||
.stateIn(
|
.stateIn(
|
||||||
scope = viewModelScope,
|
scope = viewModelScope,
|
||||||
initialValue = ToolViewUiState.Loading,
|
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 {
|
class HttpLogger : HttpLoggingInterceptor.Logger {
|
||||||
override fun log(message: String) {
|
override fun log(message: String) {
|
||||||
Timber.i(message)
|
Timber.i(message = message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ class OxygenLogTree(
|
|||||||
if (logFile.length() >= maxFileSize) {
|
if (logFile.length() >= maxFileSize) {
|
||||||
rotateLogFile()
|
rotateLogFile()
|
||||||
}
|
}
|
||||||
logFile.appendText(format(priority, tag, message, t))
|
logFile.appendText(text = format(priority = priority, tag = tag, message = message, t = t))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("OxygenLogTree", "Error writing log message to file", e)
|
Log.e("OxygenLogTree", "Error writing log message to file", e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user