mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 03:32:38 +08:00
This commit is contained in:
parent
b4474f5041
commit
dbc4a28e08
|
@ -44,7 +44,6 @@ plugins {
|
||||||
alias(libs.plugins.kotlin.serialization)
|
alias(libs.plugins.kotlin.serialization)
|
||||||
alias(libs.plugins.kotlin.compose)
|
alias(libs.plugins.kotlin.compose)
|
||||||
alias(libs.plugins.google.ksp)
|
alias(libs.plugins.google.ksp)
|
||||||
alias(libs.plugins.google.hilt)
|
|
||||||
alias(libs.plugins.rikka.refine)
|
alias(libs.plugins.rikka.refine)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,10 +242,6 @@ dependencies {
|
||||||
implementation(libs.destinations.core)
|
implementation(libs.destinations.core)
|
||||||
ksp(libs.destinations.ksp)
|
ksp(libs.destinations.ksp)
|
||||||
|
|
||||||
implementation(libs.google.hilt.android)
|
|
||||||
ksp(libs.google.hilt.android.compiler)
|
|
||||||
implementation(libs.androidx.hilt.navigation.compose)
|
|
||||||
|
|
||||||
implementation(libs.reorderable)
|
implementation(libs.reorderable)
|
||||||
|
|
||||||
implementation(libs.androidx.splashscreen)
|
implementation(libs.androidx.splashscreen)
|
||||||
|
|
|
@ -8,7 +8,6 @@ import com.blankj.utilcode.util.LogUtils
|
||||||
import com.blankj.utilcode.util.Utils
|
import com.blankj.utilcode.util.Utils
|
||||||
import com.hjq.toast.Toaster
|
import com.hjq.toast.Toaster
|
||||||
import com.tencent.mmkv.MMKV
|
import com.tencent.mmkv.MMKV
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.MainScope
|
import kotlinx.coroutines.MainScope
|
||||||
import li.songe.gkd.debug.clearHttpSubs
|
import li.songe.gkd.debug.clearHttpSubs
|
||||||
|
@ -38,7 +37,6 @@ val applicationInfo by lazy {
|
||||||
|
|
||||||
val channel by lazy { applicationInfo.metaData.getString("channel") }
|
val channel by lazy { applicationInfo.metaData.getString("channel") }
|
||||||
|
|
||||||
@HiltAndroidApp
|
|
||||||
class App : Application() {
|
class App : Application() {
|
||||||
override fun attachBaseContext(base: Context?) {
|
override fun attachBaseContext(base: Context?) {
|
||||||
super.attachBaseContext(base)
|
super.attachBaseContext(base)
|
||||||
|
|
|
@ -14,7 +14,6 @@ import com.blankj.utilcode.util.ServiceUtils
|
||||||
import com.dylanc.activityresult.launcher.PickContentLauncher
|
import com.dylanc.activityresult.launcher.PickContentLauncher
|
||||||
import com.dylanc.activityresult.launcher.StartActivityLauncher
|
import com.dylanc.activityresult.launcher.StartActivityLauncher
|
||||||
import com.ramcosta.composedestinations.DestinationsNavHost
|
import com.ramcosta.composedestinations.DestinationsNavHost
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
|
@ -42,7 +41,6 @@ import li.songe.gkd.util.launchTry
|
||||||
import li.songe.gkd.util.map
|
import li.songe.gkd.util.map
|
||||||
import li.songe.gkd.util.storeFlow
|
import li.songe.gkd.util.storeFlow
|
||||||
|
|
||||||
@AndroidEntryPoint
|
|
||||||
class MainActivity : CompositionActivity({
|
class MainActivity : CompositionActivity({
|
||||||
this as MainActivity
|
this as MainActivity
|
||||||
useLifeCycleLog()
|
useLifeCycleLog()
|
||||||
|
@ -120,7 +118,8 @@ class MainActivity : CompositionActivity({
|
||||||
activityVisibleFlow.update { it - 1 }
|
activityVisibleFlow.update { it - 1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastBackPressedTime = 0L
|
private var lastBackPressedTime = 0L
|
||||||
|
|
||||||
@Suppress("OVERRIDE_DEPRECATION")
|
@Suppress("OVERRIDE_DEPRECATION")
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
// onBackPressedDispatcher.addCallback is not work, it will be covered by compose navigation
|
// onBackPressedDispatcher.addCallback is not work, it will be covered by compose navigation
|
||||||
|
|
|
@ -29,8 +29,8 @@ import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.paging.compose.collectAsLazyPagingItems
|
import androidx.paging.compose.collectAsLazyPagingItems
|
||||||
import androidx.paging.compose.itemKey
|
import androidx.paging.compose.itemKey
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
|
@ -52,7 +52,7 @@ import li.songe.gkd.util.throttle
|
||||||
fun ActivityLogPage() {
|
fun ActivityLogPage() {
|
||||||
val context = LocalContext.current as MainActivity
|
val context = LocalContext.current as MainActivity
|
||||||
val mainVm = context.mainVm
|
val mainVm = context.mainVm
|
||||||
val vm = hiltViewModel<ActivityLogVm>()
|
val vm = viewModel<ActivityLogVm>()
|
||||||
val navController = LocalNavController.current
|
val navController = LocalNavController.current
|
||||||
|
|
||||||
val logCount by vm.logCountFlow.collectAsState()
|
val logCount by vm.logCountFlow.collectAsState()
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
package li.songe.gkd.ui
|
package li.songe.gkd.ui
|
||||||
|
|
||||||
import androidx.lifecycle.SavedStateHandle
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import androidx.paging.Pager
|
import androidx.paging.Pager
|
||||||
import androidx.paging.PagingConfig
|
import androidx.paging.PagingConfig
|
||||||
import androidx.paging.cachedIn
|
import androidx.paging.cachedIn
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import li.songe.gkd.db.DbSet
|
import li.songe.gkd.db.DbSet
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
class ActivityLogVm : ViewModel() {
|
||||||
class ActivityLogVm @Inject constructor(stateHandle: SavedStateHandle) : ViewModel() {
|
|
||||||
val pagingDataFlow = Pager(PagingConfig(pageSize = 100)) { DbSet.activityLogDao.pagingSource() }
|
val pagingDataFlow = Pager(PagingConfig(pageSize = 100)) { DbSet.activityLogDao.pagingSource() }
|
||||||
.flow.cachedIn(viewModelScope)
|
.flow.cachedIn(viewModelScope)
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,8 @@ import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.blankj.utilcode.util.LogUtils
|
import com.blankj.utilcode.util.LogUtils
|
||||||
import com.dylanc.activityresult.launcher.launchForResult
|
import com.dylanc.activityresult.launcher.launchForResult
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
|
@ -107,7 +107,7 @@ import rikka.shizuku.Shizuku
|
||||||
@Composable
|
@Composable
|
||||||
fun AdvancedPage() {
|
fun AdvancedPage() {
|
||||||
val context = LocalContext.current as MainActivity
|
val context = LocalContext.current as MainActivity
|
||||||
val vm = hiltViewModel<AdvancedVm>()
|
val vm = viewModel<AdvancedVm>()
|
||||||
val launcher = LocalLauncher.current
|
val launcher = LocalLauncher.current
|
||||||
val navController = LocalNavController.current
|
val navController = LocalNavController.current
|
||||||
val store by storeFlow.collectAsState()
|
val store by storeFlow.collectAsState()
|
||||||
|
|
|
@ -2,16 +2,13 @@ package li.songe.gkd.ui
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import li.songe.gkd.db.DbSet
|
import li.songe.gkd.db.DbSet
|
||||||
import li.songe.gkd.ui.component.UploadOptions
|
import li.songe.gkd.ui.component.UploadOptions
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
class AdvancedVm : ViewModel() {
|
||||||
class AdvancedVm @Inject constructor() : ViewModel() {
|
|
||||||
val snapshotCountFlow =
|
val snapshotCountFlow =
|
||||||
DbSet.snapshotDao.count().stateIn(viewModelScope, SharingStarted.Eagerly, 0)
|
DbSet.snapshotDao.count().stateIn(viewModelScope, SharingStarted.Eagerly, 0)
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
||||||
import com.ramcosta.composedestinations.navigation.navigate
|
import com.ramcosta.composedestinations.navigation.navigate
|
||||||
|
@ -80,7 +80,7 @@ import li.songe.gkd.util.throttle
|
||||||
@Composable
|
@Composable
|
||||||
fun AppConfigPage(appId: String) {
|
fun AppConfigPage(appId: String) {
|
||||||
val navController = LocalNavController.current
|
val navController = LocalNavController.current
|
||||||
val vm = hiltViewModel<AppConfigVm>()
|
val vm = viewModel<AppConfigVm>()
|
||||||
val ruleSortType by vm.ruleSortTypeFlow.collectAsState()
|
val ruleSortType by vm.ruleSortTypeFlow.collectAsState()
|
||||||
val appInfoCache by appInfoCacheFlow.collectAsState()
|
val appInfoCache by appInfoCacheFlow.collectAsState()
|
||||||
val appInfo = appInfoCache[appId]
|
val appInfo = appInfoCache[appId]
|
||||||
|
|
|
@ -3,7 +3,6 @@ package li.songe.gkd.ui
|
||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
|
@ -20,10 +19,8 @@ import li.songe.gkd.util.collator
|
||||||
import li.songe.gkd.util.getGroupRawEnable
|
import li.songe.gkd.util.getGroupRawEnable
|
||||||
import li.songe.gkd.util.subsIdToRawFlow
|
import li.songe.gkd.util.subsIdToRawFlow
|
||||||
import li.songe.gkd.util.subsItemsFlow
|
import li.songe.gkd.util.subsItemsFlow
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
class AppConfigVm (stateHandle: SavedStateHandle) : ViewModel() {
|
||||||
class AppConfigVm @Inject constructor(stateHandle: SavedStateHandle) : ViewModel() {
|
|
||||||
private val args = AppConfigPageDestination.argsFrom(stateHandle)
|
private val args = AppConfigPageDestination.argsFrom(stateHandle)
|
||||||
|
|
||||||
private val latestGlobalLogsFlow = DbSet.clickLogDao.queryAppLatest(
|
private val latestGlobalLogsFlow = DbSet.clickLogDao.queryAppLatest(
|
||||||
|
|
|
@ -51,8 +51,8 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.blankj.utilcode.util.ClipboardUtils
|
import com.blankj.utilcode.util.ClipboardUtils
|
||||||
import com.blankj.utilcode.util.LogUtils
|
import com.blankj.utilcode.util.LogUtils
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
|
@ -75,7 +75,6 @@ import li.songe.gkd.util.LocalMainViewModel
|
||||||
import li.songe.gkd.util.LocalNavController
|
import li.songe.gkd.util.LocalNavController
|
||||||
import li.songe.gkd.util.ProfileTransitions
|
import li.songe.gkd.util.ProfileTransitions
|
||||||
import li.songe.gkd.util.appInfoCacheFlow
|
import li.songe.gkd.util.appInfoCacheFlow
|
||||||
import li.songe.json5.encodeToJson5String
|
|
||||||
import li.songe.gkd.util.getGroupRawEnable
|
import li.songe.gkd.util.getGroupRawEnable
|
||||||
import li.songe.gkd.util.json
|
import li.songe.gkd.util.json
|
||||||
import li.songe.gkd.util.launchAsFn
|
import li.songe.gkd.util.launchAsFn
|
||||||
|
@ -84,6 +83,7 @@ import li.songe.gkd.util.throttle
|
||||||
import li.songe.gkd.util.toast
|
import li.songe.gkd.util.toast
|
||||||
import li.songe.gkd.util.updateSubscription
|
import li.songe.gkd.util.updateSubscription
|
||||||
import li.songe.json5.Json5
|
import li.songe.json5.Json5
|
||||||
|
import li.songe.json5.encodeToJson5String
|
||||||
|
|
||||||
@RootNavGraph
|
@RootNavGraph
|
||||||
@Destination(style = ProfileTransitions::class)
|
@Destination(style = ProfileTransitions::class)
|
||||||
|
@ -95,7 +95,7 @@ fun AppItemPage(
|
||||||
) {
|
) {
|
||||||
val navController = LocalNavController.current
|
val navController = LocalNavController.current
|
||||||
val mainVm = LocalMainViewModel.current
|
val mainVm = LocalMainViewModel.current
|
||||||
val vm = hiltViewModel<AppItemVm>()
|
val vm = viewModel<AppItemVm>()
|
||||||
val subsItem = vm.subsItemFlow.collectAsState().value
|
val subsItem = vm.subsItemFlow.collectAsState().value
|
||||||
val subsRaw = vm.subsRawFlow.collectAsState().value
|
val subsRaw = vm.subsRawFlow.collectAsState().value
|
||||||
val subsConfigs by vm.subsConfigsFlow.collectAsState()
|
val subsConfigs by vm.subsConfigsFlow.collectAsState()
|
||||||
|
@ -285,7 +285,7 @@ fun AppItemPage(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (editable && subsRaw != null) {
|
if (editable && subsRaw != null && subsItem != null) {
|
||||||
DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
text = {
|
text = {
|
||||||
Text(text = "删除", color = MaterialTheme.colorScheme.error)
|
Text(text = "删除", color = MaterialTheme.colorScheme.error)
|
||||||
|
|
|
@ -3,7 +3,6 @@ package li.songe.gkd.ui
|
||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
|
@ -13,10 +12,8 @@ import li.songe.gkd.ui.destinations.AppItemPageDestination
|
||||||
import li.songe.gkd.util.map
|
import li.songe.gkd.util.map
|
||||||
import li.songe.gkd.util.subsIdToRawFlow
|
import li.songe.gkd.util.subsIdToRawFlow
|
||||||
import li.songe.gkd.util.subsItemsFlow
|
import li.songe.gkd.util.subsItemsFlow
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
class AppItemVm (stateHandle: SavedStateHandle) : ViewModel() {
|
||||||
class AppItemVm @Inject constructor(stateHandle: SavedStateHandle) : ViewModel() {
|
|
||||||
private val args = AppItemPageDestination.argsFrom(stateHandle)
|
private val args = AppItemPageDestination.argsFrom(stateHandle)
|
||||||
|
|
||||||
val subsItemFlow =
|
val subsItemFlow =
|
||||||
|
|
|
@ -42,8 +42,8 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -72,7 +72,7 @@ fun CategoryPage(subsItemId: Long) {
|
||||||
val navController = LocalNavController.current
|
val navController = LocalNavController.current
|
||||||
val mainVm = LocalMainViewModel.current
|
val mainVm = LocalMainViewModel.current
|
||||||
|
|
||||||
val vm = hiltViewModel<CategoryVm>()
|
val vm = viewModel<CategoryVm>()
|
||||||
val subsItem by vm.subsItemFlow.collectAsState()
|
val subsItem by vm.subsItemFlow.collectAsState()
|
||||||
val subsRaw by vm.subsRawFlow.collectAsState()
|
val subsRaw by vm.subsRawFlow.collectAsState()
|
||||||
val categoryConfigs by vm.categoryConfigsFlow.collectAsState()
|
val categoryConfigs by vm.categoryConfigsFlow.collectAsState()
|
||||||
|
|
|
@ -3,7 +3,6 @@ package li.songe.gkd.ui
|
||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import li.songe.gkd.db.DbSet
|
import li.songe.gkd.db.DbSet
|
||||||
|
@ -11,10 +10,8 @@ import li.songe.gkd.ui.destinations.CategoryPageDestination
|
||||||
import li.songe.gkd.util.map
|
import li.songe.gkd.util.map
|
||||||
import li.songe.gkd.util.subsIdToRawFlow
|
import li.songe.gkd.util.subsIdToRawFlow
|
||||||
import li.songe.gkd.util.subsItemsFlow
|
import li.songe.gkd.util.subsItemsFlow
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
class CategoryVm (stateHandle: SavedStateHandle) : ViewModel() {
|
||||||
class CategoryVm @Inject constructor(stateHandle: SavedStateHandle) : ViewModel() {
|
|
||||||
private val args = CategoryPageDestination.argsFrom(stateHandle)
|
private val args = CategoryPageDestination.argsFrom(stateHandle)
|
||||||
|
|
||||||
val subsItemFlow =
|
val subsItemFlow =
|
||||||
|
|
|
@ -38,8 +38,8 @@ import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.paging.compose.collectAsLazyPagingItems
|
import androidx.paging.compose.collectAsLazyPagingItems
|
||||||
import androidx.paging.compose.itemKey
|
import androidx.paging.compose.itemKey
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
|
@ -78,7 +78,7 @@ fun ClickLogPage() {
|
||||||
val context = LocalContext.current as MainActivity
|
val context = LocalContext.current as MainActivity
|
||||||
val mainVm = context.mainVm
|
val mainVm = context.mainVm
|
||||||
val navController = LocalNavController.current
|
val navController = LocalNavController.current
|
||||||
val vm = hiltViewModel<ClickLogVm>()
|
val vm = viewModel<ClickLogVm>()
|
||||||
val clickLogCount by vm.clickLogCountFlow.collectAsState()
|
val clickLogCount by vm.clickLogCountFlow.collectAsState()
|
||||||
val clickDataItems = vm.pagingDataFlow.collectAsLazyPagingItems()
|
val clickDataItems = vm.pagingDataFlow.collectAsLazyPagingItems()
|
||||||
val appInfoCache by appInfoCacheFlow.collectAsState()
|
val appInfoCache by appInfoCacheFlow.collectAsState()
|
||||||
|
|
|
@ -6,7 +6,6 @@ import androidx.paging.Pager
|
||||||
import androidx.paging.PagingConfig
|
import androidx.paging.PagingConfig
|
||||||
import androidx.paging.cachedIn
|
import androidx.paging.cachedIn
|
||||||
import androidx.paging.map
|
import androidx.paging.map
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
|
@ -14,10 +13,8 @@ import li.songe.gkd.data.SubsConfig
|
||||||
import li.songe.gkd.data.Tuple3
|
import li.songe.gkd.data.Tuple3
|
||||||
import li.songe.gkd.db.DbSet
|
import li.songe.gkd.db.DbSet
|
||||||
import li.songe.gkd.util.subsIdToRawFlow
|
import li.songe.gkd.util.subsIdToRawFlow
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
class ClickLogVm : ViewModel() {
|
||||||
class ClickLogVm @Inject constructor() : ViewModel() {
|
|
||||||
|
|
||||||
val pagingDataFlow = Pager(PagingConfig(pageSize = 100)) { DbSet.clickLogDao.pagingSource() }
|
val pagingDataFlow = Pager(PagingConfig(pageSize = 100)) { DbSet.clickLogDao.pagingSource() }
|
||||||
.flow.cachedIn(viewModelScope)
|
.flow.cachedIn(viewModelScope)
|
||||||
|
|
|
@ -56,8 +56,8 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.google.accompanist.drawablepainter.rememberDrawablePainter
|
import com.google.accompanist.drawablepainter.rememberDrawablePainter
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
||||||
|
@ -84,7 +84,7 @@ import li.songe.gkd.util.toast
|
||||||
@Composable
|
@Composable
|
||||||
fun GlobalRuleExcludePage(subsItemId: Long, groupKey: Int) {
|
fun GlobalRuleExcludePage(subsItemId: Long, groupKey: Int) {
|
||||||
val navController = LocalNavController.current
|
val navController = LocalNavController.current
|
||||||
val vm = hiltViewModel<GlobalRuleExcludeVm>()
|
val vm = viewModel<GlobalRuleExcludeVm>()
|
||||||
val rawSubs = vm.rawSubsFlow.collectAsState().value
|
val rawSubs = vm.rawSubsFlow.collectAsState().value
|
||||||
val group = vm.groupFlow.collectAsState().value
|
val group = vm.groupFlow.collectAsState().value
|
||||||
val excludeData = vm.excludeDataFlow.collectAsState().value
|
val excludeData = vm.excludeDataFlow.collectAsState().value
|
||||||
|
@ -221,17 +221,15 @@ fun GlobalRuleExcludePage(subsItemId: Long, groupKey: Int) {
|
||||||
)
|
)
|
||||||
DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
text = {
|
text = {
|
||||||
Row(
|
Text("显示隐藏应用")
|
||||||
verticalAlignment = Alignment.CenterVertically
|
},
|
||||||
) {
|
trailingIcon = {
|
||||||
Checkbox(
|
Checkbox(
|
||||||
checked = showHiddenApp,
|
checked = showHiddenApp,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
vm.showHiddenAppFlow.value =
|
vm.showHiddenAppFlow.value =
|
||||||
!vm.showHiddenAppFlow.value
|
!vm.showHiddenAppFlow.value
|
||||||
})
|
})
|
||||||
Text("显示隐藏应用")
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onClick = {
|
onClick = {
|
||||||
vm.showHiddenAppFlow.value = !vm.showHiddenAppFlow.value
|
vm.showHiddenAppFlow.value = !vm.showHiddenAppFlow.value
|
||||||
|
|
|
@ -3,7 +3,6 @@ package li.songe.gkd.ui
|
||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
|
@ -17,10 +16,8 @@ import li.songe.gkd.util.SortTypeOption
|
||||||
import li.songe.gkd.util.map
|
import li.songe.gkd.util.map
|
||||||
import li.songe.gkd.util.orderedAppInfosFlow
|
import li.songe.gkd.util.orderedAppInfosFlow
|
||||||
import li.songe.gkd.util.subsIdToRawFlow
|
import li.songe.gkd.util.subsIdToRawFlow
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
class GlobalRuleExcludeVm (stateHandle: SavedStateHandle) : ViewModel() {
|
||||||
class GlobalRuleExcludeVm @Inject constructor(stateHandle: SavedStateHandle) : ViewModel() {
|
|
||||||
private val args = GlobalRuleExcludePageDestination.argsFrom(stateHandle)
|
private val args = GlobalRuleExcludePageDestination.argsFrom(stateHandle)
|
||||||
|
|
||||||
val rawSubsFlow = subsIdToRawFlow.map(viewModelScope) { it[args.subsItemId] }
|
val rawSubsFlow = subsIdToRawFlow.map(viewModelScope) { it[args.subsItemId] }
|
||||||
|
|
|
@ -52,8 +52,8 @@ import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.blankj.utilcode.util.ClipboardUtils
|
import com.blankj.utilcode.util.ClipboardUtils
|
||||||
import com.blankj.utilcode.util.LogUtils
|
import com.blankj.utilcode.util.LogUtils
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
|
@ -72,13 +72,13 @@ import li.songe.gkd.ui.style.itemPadding
|
||||||
import li.songe.gkd.util.LocalMainViewModel
|
import li.songe.gkd.util.LocalMainViewModel
|
||||||
import li.songe.gkd.util.LocalNavController
|
import li.songe.gkd.util.LocalNavController
|
||||||
import li.songe.gkd.util.ProfileTransitions
|
import li.songe.gkd.util.ProfileTransitions
|
||||||
import li.songe.json5.encodeToJson5String
|
|
||||||
import li.songe.gkd.util.json
|
import li.songe.gkd.util.json
|
||||||
import li.songe.gkd.util.launchAsFn
|
import li.songe.gkd.util.launchAsFn
|
||||||
import li.songe.gkd.util.launchTry
|
import li.songe.gkd.util.launchTry
|
||||||
import li.songe.gkd.util.throttle
|
import li.songe.gkd.util.throttle
|
||||||
import li.songe.gkd.util.toast
|
import li.songe.gkd.util.toast
|
||||||
import li.songe.gkd.util.updateSubscription
|
import li.songe.gkd.util.updateSubscription
|
||||||
|
import li.songe.json5.encodeToJson5String
|
||||||
|
|
||||||
@RootNavGraph
|
@RootNavGraph
|
||||||
@Destination(style = ProfileTransitions::class)
|
@Destination(style = ProfileTransitions::class)
|
||||||
|
@ -86,7 +86,7 @@ import li.songe.gkd.util.updateSubscription
|
||||||
fun GlobalRulePage(subsItemId: Long, focusGroupKey: Int? = null) {
|
fun GlobalRulePage(subsItemId: Long, focusGroupKey: Int? = null) {
|
||||||
val navController = LocalNavController.current
|
val navController = LocalNavController.current
|
||||||
val mainVm = LocalMainViewModel.current
|
val mainVm = LocalMainViewModel.current
|
||||||
val vm = hiltViewModel<GlobalRuleVm>()
|
val vm = viewModel<GlobalRuleVm>()
|
||||||
val subsItem by vm.subsItemFlow.collectAsState()
|
val subsItem by vm.subsItemFlow.collectAsState()
|
||||||
val rawSubs = vm.subsRawFlow.collectAsState().value
|
val rawSubs = vm.subsRawFlow.collectAsState().value
|
||||||
val subsConfigs by vm.subsConfigsFlow.collectAsState()
|
val subsConfigs by vm.subsConfigsFlow.collectAsState()
|
||||||
|
@ -246,7 +246,7 @@ fun GlobalRulePage(subsItemId: Long, focusGroupKey: Int? = null) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if (editable) {
|
if (editable && rawSubs != null) {
|
||||||
DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
text = {
|
text = {
|
||||||
Text(text = "删除", color = MaterialTheme.colorScheme.error)
|
Text(text = "删除", color = MaterialTheme.colorScheme.error)
|
||||||
|
|
|
@ -3,7 +3,6 @@ package li.songe.gkd.ui
|
||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import li.songe.gkd.db.DbSet
|
import li.songe.gkd.db.DbSet
|
||||||
|
@ -11,10 +10,8 @@ import li.songe.gkd.ui.destinations.GlobalRulePageDestination
|
||||||
import li.songe.gkd.util.map
|
import li.songe.gkd.util.map
|
||||||
import li.songe.gkd.util.subsIdToRawFlow
|
import li.songe.gkd.util.subsIdToRawFlow
|
||||||
import li.songe.gkd.util.subsItemsFlow
|
import li.songe.gkd.util.subsItemsFlow
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
class GlobalRuleVm (stateHandle: SavedStateHandle) : ViewModel() {
|
||||||
class GlobalRuleVm @Inject constructor(stateHandle: SavedStateHandle) : ViewModel() {
|
|
||||||
private val args = GlobalRulePageDestination.argsFrom(stateHandle)
|
private val args = GlobalRulePageDestination.argsFrom(stateHandle)
|
||||||
val subsItemFlow =
|
val subsItemFlow =
|
||||||
subsItemsFlow.map(viewModelScope) { s -> s.find { v -> v.id == args.subsItemId } }
|
subsItemsFlow.map(viewModelScope) { s -> s.find { v -> v.id == args.subsItemId } }
|
||||||
|
|
|
@ -38,8 +38,8 @@ import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.blankj.utilcode.util.ClipboardUtils
|
import com.blankj.utilcode.util.ClipboardUtils
|
||||||
import com.blankj.utilcode.util.ImageUtils
|
import com.blankj.utilcode.util.ImageUtils
|
||||||
import com.blankj.utilcode.util.UriUtils
|
import com.blankj.utilcode.util.UriUtils
|
||||||
|
@ -80,7 +80,7 @@ fun SnapshotPage() {
|
||||||
|
|
||||||
val pickContentLauncher = LocalPickContentLauncher.current
|
val pickContentLauncher = LocalPickContentLauncher.current
|
||||||
|
|
||||||
val vm = hiltViewModel<SnapshotVm>()
|
val vm = viewModel<SnapshotVm>()
|
||||||
val snapshots by vm.snapshotsState.collectAsState()
|
val snapshots by vm.snapshotsState.collectAsState()
|
||||||
|
|
||||||
vm.uploadOptions.ShowDialog()
|
vm.uploadOptions.ShowDialog()
|
||||||
|
|
|
@ -2,17 +2,13 @@ package li.songe.gkd.ui
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import li.songe.gkd.db.DbSet
|
import li.songe.gkd.db.DbSet
|
||||||
import li.songe.gkd.ui.component.UploadOptions
|
import li.songe.gkd.ui.component.UploadOptions
|
||||||
import li.songe.gkd.util.IMPORT_BASE_URL
|
import li.songe.gkd.util.IMPORT_BASE_URL
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
|
class SnapshotVm : ViewModel() {
|
||||||
@HiltViewModel
|
|
||||||
class SnapshotVm @Inject constructor() : ViewModel() {
|
|
||||||
val snapshotsState = DbSet.snapshotDao.query()
|
val snapshotsState = DbSet.snapshotDao.query()
|
||||||
.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList())
|
.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList())
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ import androidx.compose.ui.focus.FocusRequester
|
||||||
import androidx.compose.ui.focus.focusRequester
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.blankj.utilcode.util.LogUtils
|
import com.blankj.utilcode.util.LogUtils
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
||||||
|
@ -65,13 +65,13 @@ import li.songe.gkd.util.LocalNavController
|
||||||
import li.songe.gkd.util.ProfileTransitions
|
import li.songe.gkd.util.ProfileTransitions
|
||||||
import li.songe.gkd.util.SortTypeOption
|
import li.songe.gkd.util.SortTypeOption
|
||||||
import li.songe.gkd.util.appInfoCacheFlow
|
import li.songe.gkd.util.appInfoCacheFlow
|
||||||
import li.songe.json5.encodeToJson5String
|
|
||||||
import li.songe.gkd.util.json
|
import li.songe.gkd.util.json
|
||||||
import li.songe.gkd.util.launchAsFn
|
import li.songe.gkd.util.launchAsFn
|
||||||
import li.songe.gkd.util.launchTry
|
import li.songe.gkd.util.launchTry
|
||||||
import li.songe.gkd.util.throttle
|
import li.songe.gkd.util.throttle
|
||||||
import li.songe.gkd.util.toast
|
import li.songe.gkd.util.toast
|
||||||
import li.songe.gkd.util.updateSubscription
|
import li.songe.gkd.util.updateSubscription
|
||||||
|
import li.songe.json5.encodeToJson5String
|
||||||
|
|
||||||
|
|
||||||
@RootNavGraph
|
@RootNavGraph
|
||||||
|
@ -83,7 +83,7 @@ fun SubsPage(
|
||||||
val navController = LocalNavController.current
|
val navController = LocalNavController.current
|
||||||
val mainVm = LocalMainViewModel.current
|
val mainVm = LocalMainViewModel.current
|
||||||
|
|
||||||
val vm = hiltViewModel<SubsVm>()
|
val vm = viewModel<SubsVm>()
|
||||||
val subsItem = vm.subsItemFlow.collectAsState().value
|
val subsItem = vm.subsItemFlow.collectAsState().value
|
||||||
val appAndConfigs by vm.filterAppAndConfigsFlow.collectAsState()
|
val appAndConfigs by vm.filterAppAndConfigsFlow.collectAsState()
|
||||||
val searchStr by vm.searchStrFlow.collectAsState()
|
val searchStr by vm.searchStrFlow.collectAsState()
|
||||||
|
|
|
@ -3,7 +3,6 @@ package li.songe.gkd.ui
|
||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
|
@ -22,10 +21,8 @@ import li.songe.gkd.util.getGroupRawEnable
|
||||||
import li.songe.gkd.util.map
|
import li.songe.gkd.util.map
|
||||||
import li.songe.gkd.util.subsIdToRawFlow
|
import li.songe.gkd.util.subsIdToRawFlow
|
||||||
import li.songe.gkd.util.subsItemsFlow
|
import li.songe.gkd.util.subsItemsFlow
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
class SubsVm (stateHandle: SavedStateHandle) : ViewModel() {
|
||||||
class SubsVm @Inject constructor(stateHandle: SavedStateHandle) : ViewModel() {
|
|
||||||
private val args = SubsPageDestination.argsFrom(stateHandle)
|
private val args = SubsPageDestination.argsFrom(stateHandle)
|
||||||
|
|
||||||
val subsItemFlow =
|
val subsItemFlow =
|
||||||
|
|
|
@ -58,8 +58,8 @@ import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.blankj.utilcode.util.KeyboardUtils
|
import com.blankj.utilcode.util.KeyboardUtils
|
||||||
import com.google.accompanist.drawablepainter.rememberDrawablePainter
|
import com.google.accompanist.drawablepainter.rememberDrawablePainter
|
||||||
import com.ramcosta.composedestinations.navigation.navigate
|
import com.ramcosta.composedestinations.navigation.navigate
|
||||||
|
@ -91,7 +91,7 @@ fun useAppListPage(): ScaffoldExt {
|
||||||
val context = LocalContext.current as MainActivity
|
val context = LocalContext.current as MainActivity
|
||||||
val softwareKeyboardController = LocalSoftwareKeyboardController.current
|
val softwareKeyboardController = LocalSoftwareKeyboardController.current
|
||||||
|
|
||||||
val vm = hiltViewModel<HomeVm>()
|
val vm = viewModel<HomeVm>()
|
||||||
val showSystemApp by vm.showSystemAppFlow.collectAsState()
|
val showSystemApp by vm.showSystemAppFlow.collectAsState()
|
||||||
val showHiddenApp by vm.showHiddenAppFlow.collectAsState()
|
val showHiddenApp by vm.showHiddenAppFlow.collectAsState()
|
||||||
val sortType by vm.sortTypeFlow.collectAsState()
|
val sortType by vm.sortTypeFlow.collectAsState()
|
||||||
|
|
|
@ -26,8 +26,8 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.ramcosta.composedestinations.navigation.navigate
|
import com.ramcosta.composedestinations.navigation.navigate
|
||||||
import li.songe.gkd.MainActivity
|
import li.songe.gkd.MainActivity
|
||||||
import li.songe.gkd.permission.notificationState
|
import li.songe.gkd.permission.notificationState
|
||||||
|
@ -57,7 +57,7 @@ val controlNav = BottomNavItem(label = "主页", icon = Icons.Outlined.Home)
|
||||||
fun useControlPage(): ScaffoldExt {
|
fun useControlPage(): ScaffoldExt {
|
||||||
val context = LocalContext.current as MainActivity
|
val context = LocalContext.current as MainActivity
|
||||||
val navController = LocalNavController.current
|
val navController = LocalNavController.current
|
||||||
val vm = hiltViewModel<HomeVm>()
|
val vm = viewModel<HomeVm>()
|
||||||
val latestRecordDesc by vm.latestRecordDescFlow.collectAsState()
|
val latestRecordDesc by vm.latestRecordDescFlow.collectAsState()
|
||||||
val subsStatus by vm.subsStatusFlow.collectAsState()
|
val subsStatus by vm.subsStatusFlow.collectAsState()
|
||||||
val store by storeFlow.collectAsState()
|
val store by storeFlow.collectAsState()
|
||||||
|
|
|
@ -12,8 +12,8 @@ import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.blankj.utilcode.util.LogUtils
|
import com.blankj.utilcode.util.LogUtils
|
||||||
import com.ramcosta.composedestinations.annotation.Destination
|
import com.ramcosta.composedestinations.annotation.Destination
|
||||||
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
import com.ramcosta.composedestinations.annotation.RootNavGraph
|
||||||
|
@ -36,7 +36,7 @@ data class BottomNavItem(
|
||||||
@Composable
|
@Composable
|
||||||
fun HomePage() {
|
fun HomePage() {
|
||||||
val context = LocalContext.current as MainActivity
|
val context = LocalContext.current as MainActivity
|
||||||
val vm = hiltViewModel<HomeVm>()
|
val vm = viewModel<HomeVm>()
|
||||||
val tab by vm.tabFlow.collectAsState()
|
val tab by vm.tabFlow.collectAsState()
|
||||||
|
|
||||||
val controlPage = useControlPage()
|
val controlPage = useControlPage()
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package li.songe.gkd.ui.home
|
package li.songe.gkd.ui.home
|
||||||
|
|
||||||
import android.webkit.URLUtil
|
import android.webkit.URLUtil
|
||||||
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.blankj.utilcode.util.LogUtils
|
import com.blankj.utilcode.util.LogUtils
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import io.ktor.client.request.get
|
import io.ktor.client.request.get
|
||||||
import io.ktor.client.statement.bodyAsText
|
import io.ktor.client.statement.bodyAsText
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -14,6 +14,7 @@ import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.debounce
|
import kotlinx.coroutines.flow.debounce
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import li.songe.gkd.appScope
|
import li.songe.gkd.appScope
|
||||||
import li.songe.gkd.data.RawSubscription
|
import li.songe.gkd.data.RawSubscription
|
||||||
import li.songe.gkd.data.SubsItem
|
import li.songe.gkd.data.SubsItem
|
||||||
|
@ -33,10 +34,14 @@ import li.songe.gkd.util.subsItemsFlow
|
||||||
import li.songe.gkd.util.subsRefreshingFlow
|
import li.songe.gkd.util.subsRefreshingFlow
|
||||||
import li.songe.gkd.util.toast
|
import li.songe.gkd.util.toast
|
||||||
import li.songe.gkd.util.updateSubscription
|
import li.songe.gkd.util.updateSubscription
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
class HomeVm(stateHandle: SavedStateHandle) : ViewModel() {
|
||||||
class HomeVm @Inject constructor() : ViewModel() {
|
init {
|
||||||
|
viewModelScope.launch {
|
||||||
|
LogUtils.d(this, stateHandle)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val tabFlow = MutableStateFlow(controlNav)
|
val tabFlow = MutableStateFlow(controlNav)
|
||||||
|
|
||||||
private val latestRecordFlow =
|
private val latestRecordFlow =
|
||||||
|
|
|
@ -35,8 +35,8 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.ramcosta.composedestinations.navigation.navigate
|
import com.ramcosta.composedestinations.navigation.navigate
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import li.songe.gkd.BuildConfig
|
import li.songe.gkd.BuildConfig
|
||||||
|
@ -73,7 +73,7 @@ fun useSettingsPage(): ScaffoldExt {
|
||||||
val mainVm = LocalMainViewModel.current
|
val mainVm = LocalMainViewModel.current
|
||||||
val navController = LocalNavController.current
|
val navController = LocalNavController.current
|
||||||
val store by storeFlow.collectAsState()
|
val store by storeFlow.collectAsState()
|
||||||
val vm = hiltViewModel<HomeVm>()
|
val vm = viewModel<HomeVm>()
|
||||||
|
|
||||||
var showToastInputDlg by remember {
|
var showToastInputDlg by remember {
|
||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
|
|
|
@ -54,8 +54,8 @@ import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.dylanc.activityresult.launcher.launchForResult
|
import com.dylanc.activityresult.launcher.launchForResult
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -101,7 +101,7 @@ fun useSubsManagePage(): ScaffoldExt {
|
||||||
val launcher = LocalLauncher.current
|
val launcher = LocalLauncher.current
|
||||||
val mainVm = LocalMainViewModel.current
|
val mainVm = LocalMainViewModel.current
|
||||||
|
|
||||||
val vm = hiltViewModel<HomeVm>()
|
val vm = viewModel<HomeVm>()
|
||||||
val subItems by subsItemsFlow.collectAsState()
|
val subItems by subsItemsFlow.collectAsState()
|
||||||
val subsIdToRaw by subsIdToRawFlow.collectAsState()
|
val subsIdToRaw by subsIdToRawFlow.collectAsState()
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ buildscript {
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.google.ksp) apply false
|
alias(libs.plugins.google.ksp) apply false
|
||||||
alias(libs.plugins.google.hilt) apply false
|
|
||||||
|
|
||||||
alias(libs.plugins.android.library) apply false
|
alias(libs.plugins.android.library) apply false
|
||||||
alias(libs.plugins.android.application) apply false
|
alias(libs.plugins.android.application) apply false
|
||||||
|
|
|
@ -7,7 +7,6 @@ rikka = "4.4.0"
|
||||||
room = "2.6.1"
|
room = "2.6.1"
|
||||||
paging = "3.3.2"
|
paging = "3.3.2"
|
||||||
ktor = "2.3.12"
|
ktor = "2.3.12"
|
||||||
hilt = "2.52"
|
|
||||||
destinations = "1.10.2"
|
destinations = "1.10.2"
|
||||||
coil = "2.7.0"
|
coil = "2.7.0"
|
||||||
|
|
||||||
|
@ -57,9 +56,6 @@ ktor_client_content_negotiation = { module = "io.ktor:ktor-client-content-negoti
|
||||||
ktor_serialization_kotlinx_json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
|
ktor_serialization_kotlinx_json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
|
||||||
kotlinx_serialization_json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.7.1" }
|
kotlinx_serialization_json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.7.1" }
|
||||||
kotlinx_collections_immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version = "0.3.7" }
|
kotlinx_collections_immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version = "0.3.7" }
|
||||||
google_hilt_android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
|
|
||||||
google_hilt_android_compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" }
|
|
||||||
androidx_hilt_navigation_compose = { module = "androidx.hilt:hilt-navigation-compose", version = "1.2.0" }
|
|
||||||
destinations_core = { module = "io.github.raamcosta.compose-destinations:core", version.ref = "destinations" }
|
destinations_core = { module = "io.github.raamcosta.compose-destinations:core", version.ref = "destinations" }
|
||||||
destinations_ksp = { module = "io.github.raamcosta.compose-destinations:ksp", version.ref = "destinations" }
|
destinations_ksp = { module = "io.github.raamcosta.compose-destinations:ksp", version.ref = "destinations" }
|
||||||
coil_compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
|
coil_compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
|
||||||
|
@ -80,5 +76,4 @@ kotlin_android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
kotlin_compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
kotlin_compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||||
rikka_refine = { id = "dev.rikka.tools.refine", version.ref = "rikka" }
|
rikka_refine = { id = "dev.rikka.tools.refine", version.ref = "rikka" }
|
||||||
google_ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
google_ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||||
google_hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
|
|
||||||
androidx_room = { id = "androidx.room", version.ref = "room" }
|
androidx_room = { id = "androidx.room", version.ref = "room" }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user