优化KPM模块列表的获取逻辑,添加定时刷新功能,并调整空状态显示

This commit is contained in:
ShirkNeko
2025-04-01 16:16:56 +08:00
parent 57c65fdcda
commit f71de1742a

View File

@@ -1,5 +1,3 @@
package shirkneko.zako.sukisu.ui.screen
import android.app.Activity.RESULT_OK
import android.content.Context
import android.content.Intent
@@ -14,8 +12,6 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.*
import androidx.compose.material3.*
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -27,6 +23,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootGraph
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import shirkneko.zako.sukisu.R
import shirkneko.zako.sukisu.ui.component.ConfirmResult
@@ -42,7 +39,6 @@ import java.io.File
import androidx.core.content.edit
import shirkneko.zako.sukisu.ui.theme.ThemeConfig
/**
* KPM 管理界面
* 以下内核模块功能由KernelPatch开发经过修改后加入SukiSU Ultra的内核模块功能
@@ -132,8 +128,9 @@ fun KpmScreen(
}
LaunchedEffect(Unit) {
if (viewModel.moduleList.isEmpty()) {
while(true) {
viewModel.fetchModuleList()
delay(5000)
}
}
@@ -206,11 +203,6 @@ fun KpmScreen(
}
}
PullToRefreshBox(
onRefresh = { viewModel.fetchModuleList() },
isRefreshing = viewModel.isRefreshing,
modifier = Modifier,
) {
if (viewModel.moduleList.isEmpty()) {
Box(
modifier = Modifier.fillMaxSize(),
@@ -273,7 +265,6 @@ fun KpmScreen(
}
}
}
}
}
@Composable