parent
31834b320d
commit
7cdbf8f613
|
|
@ -39,8 +39,8 @@ android {
|
|||
applicationId = "com.img.rabbit"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
versionCode = 3
|
||||
versionName = "1.0.3"
|
||||
multiDexEnabled = true
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
|
|
|||
|
|
@ -95,10 +95,8 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
|||
@OptIn(DelicateCoroutinesApi::class, ExperimentalPermissionsApi::class)
|
||||
@SuppressLint("UnrememberedMutableState", "CoroutineCreationDuringComposition")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
// 必须在 super.onCreate 之前调用
|
||||
val splashScreen = installSplashScreen()
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
// 启用Edge-to-Edge模式(沉浸模式)
|
||||
enableEdgeToEdge()
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ class ConfigEntity {
|
|||
var homeIconEntity: List<UniIconEntity>? = emptyList()
|
||||
@SerializedName("client.wgt.password") //WGT解压密码
|
||||
var wgtPassword: String? = null
|
||||
@SerializedName("client.uni.open") //是否开启小程序模拟器
|
||||
var isUniMpOpen: Boolean? = null
|
||||
|
||||
|
||||
|
||||
|
||||
@SerializedName("client.popup.display") //显示开关控制
|
||||
|
|
|
|||
|
|
@ -78,9 +78,8 @@ fun HomeScreen(
|
|||
val TAG = "Rabbit_HomeScreen"
|
||||
val context = LocalContext.current
|
||||
val scope: CoroutineScope = rememberCoroutineScope()
|
||||
val progressPair = mutableStateMapOf<String, Float>()
|
||||
|
||||
val reportViewModel = viewModel<ReportViewModel>()
|
||||
val progressPair = mutableStateMapOf<String, Float>()
|
||||
|
||||
// 获取当前路由状态
|
||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
|
|
@ -139,10 +138,7 @@ fun HomeScreen(
|
|||
shape = RoundedCornerShape(topStart = 18.dp, topEnd = 18.dp)
|
||||
)
|
||||
){
|
||||
val homeIconConfig = homeIconConfig
|
||||
//大于9时,每排展示3个,否则每排展示4个
|
||||
val columnsCount = if((homeIconConfig?.size?:0) >= 9){ 3 }else{ 4 }
|
||||
val rows = homeIconConfig?.chunked(columnsCount)?:emptyList()
|
||||
// 顶部mask
|
||||
item {
|
||||
Image(
|
||||
painter = painterResource(id = R.mipmap.ic_home_top_mask),
|
||||
|
|
@ -163,252 +159,127 @@ fun HomeScreen(
|
|||
}
|
||||
}
|
||||
|
||||
item {
|
||||
Column(
|
||||
) {
|
||||
// 当配置开启模拟器时,展示模拟器部分
|
||||
if(PreferenceUtil.getUserConfig()?.config?.isUniMpOpen?:false){
|
||||
//模拟器部分,大于9时,每排展示3个,否则每排展示4个
|
||||
val columnsCount = if((homeIconConfig?.size?:0) >= 9){ 3 }else{ 4 }
|
||||
val rows = homeIconConfig?.chunked(columnsCount)?:emptyList()
|
||||
//模拟器
|
||||
item {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.offset(y = (-36).dp)
|
||||
.background(
|
||||
color = Color.White,
|
||||
shape = RoundedCornerShape(topStart = 18.dp, topEnd = 18.dp)
|
||||
)
|
||||
) {
|
||||
//通过配置展示-AD1(模拟器)
|
||||
val uniVersionConfig = uniVersionConfig
|
||||
if(uniVersionConfig?.isNotEmpty() == true){
|
||||
val uniVersionSize = uniVersionConfig.size
|
||||
//模拟器
|
||||
Image(
|
||||
painter = painterResource(id = R.mipmap.ic_home_title_0_mock),
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier
|
||||
.wrapContentWidth()
|
||||
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
|
||||
){
|
||||
Box(
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.offset(y = (-36).dp)
|
||||
.background(
|
||||
color = Color.White,
|
||||
shape = RoundedCornerShape(topStart = 18.dp, topEnd = 18.dp)
|
||||
)
|
||||
) {
|
||||
//通过配置展示-AD1(模拟器)
|
||||
val uniVersionConfig = uniVersionConfig
|
||||
if(uniVersionConfig?.isNotEmpty() == true){
|
||||
val uniVersionSize = uniVersionConfig.size
|
||||
//模拟器
|
||||
Image(
|
||||
painter = painterResource(id = R.mipmap.ic_home_title_0_mock),
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier
|
||||
.wrapContentWidth()
|
||||
.weight(1f)
|
||||
.clickable(
|
||||
indication = null,
|
||||
interactionSource = remember { MutableInteractionSource() }
|
||||
) {
|
||||
val uniMp = uniVersionConfig[0]
|
||||
val uniMpId = uniMp.unimp_id
|
||||
// 处理点击事件,微信模拟器
|
||||
if (UniAppUtils.isDownloadUniMp(uniMp)) {
|
||||
//强制更新(更新释放新版本并启动)
|
||||
UniAppUtils.downloadWGT(
|
||||
context,
|
||||
scope,
|
||||
uniMp
|
||||
) { uniState, _, progress ->
|
||||
progressPair[uniMpId]
|
||||
?: mutableMapOf<String, Float>().apply { put(uniMpId, 0f) }
|
||||
when (uniState) {
|
||||
UniMpUpdate.DOWNLOAD_START -> {
|
||||
//资源开始下载
|
||||
progressPair.apply { put(uniMpId, 0f) }
|
||||
Log.i("HomeScreen", "DOWNLOAD_START")
|
||||
}
|
||||
|
||||
UniMpUpdate.DOWNLOAD_FINISH -> {
|
||||
//资源下载完成
|
||||
progressPair.apply { put(uniMpId, 1f) }
|
||||
Log.i("HomeScreen", "DOWNLOAD_FINISH")
|
||||
}
|
||||
|
||||
UniMpUpdate.DOWNLOAD_FAIL -> {
|
||||
//资源下载失败
|
||||
progressPair.apply { put(uniMpId, -1f) }
|
||||
Log.i("HomeScreen", "DOWNLOAD_FAIL")
|
||||
}
|
||||
|
||||
else -> {
|
||||
//资源下载进度
|
||||
if (progress != null) {
|
||||
progressPair.apply {
|
||||
put(
|
||||
uniMpId,
|
||||
progress
|
||||
)
|
||||
}
|
||||
Log.i(
|
||||
"HomeScreen",
|
||||
"DOWNLOAD_PROGRESS:$progress"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (UniAppUtils.isUpdate(uniMp)) {
|
||||
// 提示更新(1、更新释放新版本并启动;2、直接启动现有版本)
|
||||
UniAppUtils.currentUpdateUniMp = uniMp
|
||||
scope.launch {
|
||||
GlobalStateManager(context).storeGlobalUniUpdateNotify(
|
||||
true
|
||||
)
|
||||
}
|
||||
} else {
|
||||
loadingCallback?.showLoading()
|
||||
//启动uni小程序(1、直接启动;2、释放并启动)
|
||||
UniAppUtils.distributeUniMp(context, uniMp, reportViewModel) {
|
||||
loadingCallback?.hideLoading()
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
val uniMpId = uniVersionConfig[0].unimp_id
|
||||
val uniIcon = uniVersionConfig[0].icon
|
||||
AsyncImage(
|
||||
model = uniIcon,
|
||||
contentDescription = "微信模拟器图标",
|
||||
contentScale = ContentScale.FillWidth,
|
||||
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 16.dp, end = 16.dp, top = 12.dp)
|
||||
){
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(168 / 96f),
|
||||
fallback = painterResource(id = R.mipmap.ic_wx_mock),
|
||||
error = painterResource(id = R.mipmap.ic_wx_mock)
|
||||
)
|
||||
|
||||
//下载完成前显示
|
||||
if((progressPair[uniMpId]?:0f) > 0f && (progressPair[uniMpId]?:0f) < 1f){
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(168 / 96f)
|
||||
.background(
|
||||
Color(
|
||||
0x66000000
|
||||
), RoundedCornerShape(18.dp)
|
||||
),
|
||||
){
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.align(Alignment.Center)
|
||||
.padding(horizontal = 12.dp)
|
||||
.wrapContentWidth()
|
||||
.weight(1f)
|
||||
.clickable(
|
||||
indication = null,
|
||||
interactionSource = remember { MutableInteractionSource() }
|
||||
) {
|
||||
// 使用 LinearProgressIndicator 显示确定性进度
|
||||
LinearProgressIndicator(
|
||||
progress = { progressPair[uniMpId]?:0f }, // 使用 Lambda 更新进度0~1
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(8.dp)
|
||||
)
|
||||
Text(
|
||||
text = "下载${((progressPair[uniMpId]?:0f) * 100).toInt()}%",
|
||||
color = Color.White,
|
||||
fontSize = 12.sp,
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Box(modifier = Modifier.width(7.dp))
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.wrapContentWidth()
|
||||
.weight(1f)
|
||||
.clickable(
|
||||
indication = null,
|
||||
interactionSource = remember { MutableInteractionSource() }
|
||||
) {
|
||||
val uniMp = uniVersionConfig[1]
|
||||
val uniMpId = uniMp.unimp_id
|
||||
// 处理点击事件,微信模拟器
|
||||
if (UniAppUtils.isDownloadUniMp(uniMp)) {
|
||||
//强制更新(更新释放新版本并启动)
|
||||
UniAppUtils.downloadWGT(
|
||||
context,
|
||||
scope,
|
||||
uniMp
|
||||
) { uniState, _, progress ->
|
||||
progressPair[uniMpId]
|
||||
?: mutableMapOf<String, Float>().apply {
|
||||
put(
|
||||
uniMpId,
|
||||
0f
|
||||
)
|
||||
}
|
||||
when (uniState) {
|
||||
UniMpUpdate.DOWNLOAD_START -> {
|
||||
//资源开始下载
|
||||
progressPair.apply { put(uniMpId, 0f) }
|
||||
Log.i("HomeScreen", "DOWNLOAD_START")
|
||||
}
|
||||
|
||||
UniMpUpdate.DOWNLOAD_FINISH -> {
|
||||
//资源下载完成
|
||||
progressPair.apply { put(uniMpId, 1f) }
|
||||
Log.i("HomeScreen", "DOWNLOAD_FINISH")
|
||||
}
|
||||
|
||||
UniMpUpdate.DOWNLOAD_FAIL -> {
|
||||
//资源下载失败
|
||||
progressPair.apply { put(uniMpId, -1f) }
|
||||
Log.i("HomeScreen", "DOWNLOAD_FAIL")
|
||||
}
|
||||
|
||||
else -> {
|
||||
//资源下载进度
|
||||
if (progress != null) {
|
||||
progressPair.apply {
|
||||
put(
|
||||
uniMpId,
|
||||
progress
|
||||
)
|
||||
}
|
||||
Log.i(
|
||||
"HomeScreen",
|
||||
"DOWNLOAD_PROGRESS:$progress"
|
||||
)
|
||||
val uniMp = uniVersionConfig[0]
|
||||
val uniMpId = uniMp.unimp_id
|
||||
// 处理点击事件,微信模拟器
|
||||
if (UniAppUtils.isDownloadUniMp(uniMp)) {
|
||||
//强制更新(更新释放新版本并启动)
|
||||
UniAppUtils.downloadWGT(
|
||||
context,
|
||||
scope,
|
||||
uniMp
|
||||
) { uniState, _, progress ->
|
||||
progressPair[uniMpId]
|
||||
?: mutableMapOf<String, Float>().apply { put(uniMpId, 0f) }
|
||||
when (uniState) {
|
||||
UniMpUpdate.DOWNLOAD_START -> {
|
||||
//资源开始下载
|
||||
progressPair.apply { put(uniMpId, 0f) }
|
||||
Log.i("HomeScreen", "DOWNLOAD_START")
|
||||
}
|
||||
|
||||
UniMpUpdate.DOWNLOAD_FINISH -> {
|
||||
//资源下载完成
|
||||
progressPair.apply { put(uniMpId, 1f) }
|
||||
Log.i("HomeScreen", "DOWNLOAD_FINISH")
|
||||
}
|
||||
|
||||
UniMpUpdate.DOWNLOAD_FAIL -> {
|
||||
//资源下载失败
|
||||
progressPair.apply { put(uniMpId, -1f) }
|
||||
Log.i("HomeScreen", "DOWNLOAD_FAIL")
|
||||
}
|
||||
|
||||
else -> {
|
||||
//资源下载进度
|
||||
if (progress != null) {
|
||||
progressPair.apply {
|
||||
put(
|
||||
uniMpId,
|
||||
progress
|
||||
)
|
||||
}
|
||||
Log.i(
|
||||
"HomeScreen",
|
||||
"DOWNLOAD_PROGRESS:$progress"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (UniAppUtils.isUpdate(uniMp)) {
|
||||
// 提示更新(1、更新释放新版本并启动;2、直接启动现有版本)
|
||||
UniAppUtils.currentUpdateUniMp = uniMp
|
||||
scope.launch {
|
||||
GlobalStateManager(context).storeGlobalUniUpdateNotify(
|
||||
true
|
||||
)
|
||||
}
|
||||
} else {
|
||||
loadingCallback?.showLoading()
|
||||
//启动uni小程序(1、直接启动;2、释放并启动)
|
||||
UniAppUtils.distributeUniMp(context, uniMp, reportViewModel) {
|
||||
loadingCallback?.hideLoading()
|
||||
} else if (UniAppUtils.isUpdate(uniMp)) {
|
||||
// 提示更新(1、更新释放新版本并启动;2、直接启动现有版本)
|
||||
UniAppUtils.currentUpdateUniMp = uniMp
|
||||
scope.launch {
|
||||
GlobalStateManager(context).storeGlobalUniUpdateNotify(
|
||||
true
|
||||
)
|
||||
}
|
||||
} else {
|
||||
loadingCallback?.showLoading()
|
||||
//启动uni小程序(1、直接启动;2、释放并启动)
|
||||
UniAppUtils.distributeUniMp(context, uniMp, reportViewModel) {
|
||||
loadingCallback?.hideLoading()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
val uniMpId = uniVersionConfig[1].unimp_id
|
||||
val uniIcon = uniVersionConfig[1].icon
|
||||
if(uniVersionSize>1){
|
||||
) {
|
||||
val uniMpId = uniVersionConfig[0].unimp_id
|
||||
val uniIcon = uniVersionConfig[0].icon
|
||||
AsyncImage(
|
||||
model = uniIcon,
|
||||
contentDescription = "支付宝模拟器",
|
||||
contentDescription = "微信模拟器图标",
|
||||
contentScale = ContentScale.FillWidth,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(168 / 96f),
|
||||
fallback = painterResource(id = R.mipmap.ic_alipay_mock),
|
||||
error = painterResource(id = R.mipmap.ic_alipay_mock)
|
||||
fallback = painterResource(id = R.mipmap.ic_wx_mock),
|
||||
error = painterResource(id = R.mipmap.ic_wx_mock)
|
||||
)
|
||||
|
||||
//下载完成前显示
|
||||
|
|
@ -446,83 +317,217 @@ fun HomeScreen(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
items(rows) {rowItems ->
|
||||
//通过配置展示-AD2
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.offset(y = (-36).dp)
|
||||
) {
|
||||
for (item in rowItems) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.clickable(
|
||||
indication = null,
|
||||
interactionSource = remember { MutableInteractionSource() }
|
||||
) {
|
||||
|
||||
val uniVersion =
|
||||
PreferenceUtil.getUserConfig()?.config?.uniVersionEntity?.firstOrNull { it.unimp_type == item.type }
|
||||
if(uniVersion == null){
|
||||
CenterToast.show("无可用资源...")
|
||||
return@clickable
|
||||
}
|
||||
val uniMpId = uniVersion.unimp_id
|
||||
UniAppUtils.currentUniMpJumpPatch = item.url
|
||||
val wgtExists = UniAppUtils.wgtIsExists(uniMpId)
|
||||
if(!wgtExists){
|
||||
//是否下载
|
||||
scope.launch {
|
||||
UniAppUtils.currentDownloadUniMp = uniVersion
|
||||
GlobalStateManager(context).storeGlobalUniDownloadNotify(true)
|
||||
Box(modifier = Modifier.width(7.dp))
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.wrapContentWidth()
|
||||
.weight(1f)
|
||||
.clickable(
|
||||
indication = null,
|
||||
interactionSource = remember { MutableInteractionSource() }
|
||||
) {
|
||||
val uniMp = uniVersionConfig[1]
|
||||
val uniMpId = uniMp.unimp_id
|
||||
// 处理点击事件,微信模拟器
|
||||
if (UniAppUtils.isDownloadUniMp(uniMp)) {
|
||||
//强制更新(更新释放新版本并启动)
|
||||
UniAppUtils.downloadWGT(
|
||||
context,
|
||||
scope,
|
||||
uniMp
|
||||
) { uniState, _, progress ->
|
||||
progressPair[uniMpId]
|
||||
?: mutableMapOf<String, Float>().apply {
|
||||
put(
|
||||
uniMpId,
|
||||
0f
|
||||
)
|
||||
}
|
||||
when (uniState) {
|
||||
UniMpUpdate.DOWNLOAD_START -> {
|
||||
//资源开始下载
|
||||
progressPair.apply { put(uniMpId, 0f) }
|
||||
Log.i("HomeScreen", "DOWNLOAD_START")
|
||||
}
|
||||
|
||||
UniMpUpdate.DOWNLOAD_FINISH -> {
|
||||
//资源下载完成
|
||||
progressPair.apply { put(uniMpId, 1f) }
|
||||
Log.i("HomeScreen", "DOWNLOAD_FINISH")
|
||||
}
|
||||
|
||||
UniMpUpdate.DOWNLOAD_FAIL -> {
|
||||
//资源下载失败
|
||||
progressPair.apply { put(uniMpId, -1f) }
|
||||
Log.i("HomeScreen", "DOWNLOAD_FAIL")
|
||||
}
|
||||
|
||||
else -> {
|
||||
//资源下载进度
|
||||
if (progress != null) {
|
||||
progressPair.apply {
|
||||
put(
|
||||
uniMpId,
|
||||
progress
|
||||
)
|
||||
}
|
||||
Log.i(
|
||||
"HomeScreen",
|
||||
"DOWNLOAD_PROGRESS:$progress"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (UniAppUtils.isUpdate(uniMp)) {
|
||||
// 提示更新(1、更新释放新版本并启动;2、直接启动现有版本)
|
||||
UniAppUtils.currentUpdateUniMp = uniMp
|
||||
scope.launch {
|
||||
GlobalStateManager(context).storeGlobalUniUpdateNotify(
|
||||
true
|
||||
)
|
||||
}
|
||||
} else {
|
||||
loadingCallback?.showLoading()
|
||||
//启动uni小程序(1、直接启动;2、释放并启动)
|
||||
UniAppUtils.distributeUniMp(context, uniMp, reportViewModel) {
|
||||
loadingCallback?.hideLoading()
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
val uniMpId = uniVersionConfig[1].unimp_id
|
||||
val uniIcon = uniVersionConfig[1].icon
|
||||
if(uniVersionSize>1){
|
||||
AsyncImage(
|
||||
model = uniIcon,
|
||||
contentDescription = "支付宝模拟器",
|
||||
contentScale = ContentScale.FillWidth,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(168 / 96f),
|
||||
fallback = painterResource(id = R.mipmap.ic_alipay_mock),
|
||||
error = painterResource(id = R.mipmap.ic_alipay_mock)
|
||||
)
|
||||
|
||||
//下载完成前显示
|
||||
if((progressPair[uniMpId]?:0f) > 0f && (progressPair[uniMpId]?:0f) < 1f){
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(168 / 96f)
|
||||
.background(
|
||||
Color(
|
||||
0x66000000
|
||||
), RoundedCornerShape(18.dp)
|
||||
),
|
||||
){
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.align(Alignment.Center)
|
||||
.padding(horizontal = 12.dp)
|
||||
) {
|
||||
// 使用 LinearProgressIndicator 显示确定性进度
|
||||
LinearProgressIndicator(
|
||||
progress = { progressPair[uniMpId]?:0f }, // 使用 Lambda 更新进度0~1
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(8.dp)
|
||||
)
|
||||
Text(
|
||||
text = "下载${((progressPair[uniMpId]?:0f) * 100).toInt()}%",
|
||||
color = Color.White,
|
||||
fontSize = 12.sp,
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
UniAppUtils.startUniMpPage(context = context, uniMpId = uniMpId, uniMpType = item.type, pagePath = item.url, reportViewModel = reportViewModel)
|
||||
}
|
||||
}
|
||||
) {
|
||||
Column {
|
||||
Box(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(8.dp))
|
||||
AsyncImage(
|
||||
model = item.icon,
|
||||
contentDescription = item.text,
|
||||
contentScale = ContentScale.FillWidth,
|
||||
modifier = Modifier
|
||||
.width(48.dp)
|
||||
.aspectRatio(48 / 48f)
|
||||
.align(Alignment.CenterHorizontally),
|
||||
fallback = painterResource(id = R.mipmap.ic_alipay_mock),
|
||||
error = painterResource(id = R.mipmap.ic_alipay_mock)
|
||||
)
|
||||
Text(
|
||||
text = item.text,
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Normal,
|
||||
color = Color(0xFF1A1A1A),
|
||||
modifier = Modifier
|
||||
.wrapContentSize()
|
||||
.align(Alignment.CenterHorizontally)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 如果最后一行不满,填充空白占位
|
||||
if (rowItems.size < columnsCount) {
|
||||
Spacer(Modifier.weight((columnsCount - rowItems.size).toFloat()))
|
||||
}
|
||||
//模拟器指定页
|
||||
items(rows) {rowItems ->
|
||||
//通过配置展示-AD2
|
||||
Row(
|
||||
Modifier
|
||||
.fillMaxWidth()
|
||||
.offset(y = (-36).dp)
|
||||
) {
|
||||
for (item in rowItems) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.clickable(
|
||||
indication = null,
|
||||
interactionSource = remember { MutableInteractionSource() }
|
||||
) {
|
||||
|
||||
val uniVersion =
|
||||
PreferenceUtil.getUserConfig()?.config?.uniVersionEntity?.firstOrNull { it.unimp_type == item.type }
|
||||
if(uniVersion == null){
|
||||
CenterToast.show("无可用资源...")
|
||||
return@clickable
|
||||
}
|
||||
val uniMpId = uniVersion.unimp_id
|
||||
UniAppUtils.currentUniMpJumpPatch = item.url
|
||||
val wgtExists = UniAppUtils.wgtIsExists(uniMpId)
|
||||
if(!wgtExists){
|
||||
//是否下载
|
||||
scope.launch {
|
||||
UniAppUtils.currentDownloadUniMp = uniVersion
|
||||
GlobalStateManager(context).storeGlobalUniDownloadNotify(true)
|
||||
}
|
||||
}else {
|
||||
UniAppUtils.startUniMpPage(context = context, uniMpId = uniMpId, uniMpType = item.type, pagePath = item.url, reportViewModel = reportViewModel)
|
||||
}
|
||||
}
|
||||
) {
|
||||
Column {
|
||||
Box(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(8.dp))
|
||||
AsyncImage(
|
||||
model = item.icon,
|
||||
contentDescription = item.text,
|
||||
contentScale = ContentScale.FillWidth,
|
||||
modifier = Modifier
|
||||
.width(48.dp)
|
||||
.aspectRatio(48 / 48f)
|
||||
.align(Alignment.CenterHorizontally),
|
||||
fallback = painterResource(id = R.mipmap.ic_alipay_mock),
|
||||
error = painterResource(id = R.mipmap.ic_alipay_mock)
|
||||
)
|
||||
Text(
|
||||
text = item.text,
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Normal,
|
||||
color = Color(0xFF1A1A1A),
|
||||
modifier = Modifier
|
||||
.wrapContentSize()
|
||||
.align(Alignment.CenterHorizontally)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果最后一行不满,填充空白占位
|
||||
if (rowItems.size < columnsCount) {
|
||||
Spacer(Modifier.weight((columnsCount - rowItems.size).toFloat()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//选尺寸制作
|
||||
item {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
|
|
@ -794,6 +799,7 @@ fun HomeScreen(
|
|||
}
|
||||
}
|
||||
}
|
||||
//选证件制作
|
||||
item {
|
||||
//选证件制作
|
||||
Column(
|
||||
|
|
@ -1272,6 +1278,7 @@ fun HomeScreen(
|
|||
}
|
||||
}
|
||||
}
|
||||
//其他
|
||||
item {
|
||||
//其他
|
||||
Column(
|
||||
|
|
|
|||
|
|
@ -53,8 +53,12 @@ class GeneralViewModel: BaseViewModel(){
|
|||
}
|
||||
}
|
||||
|
||||
private val _agreementStatus = MutableLiveData<Boolean>()
|
||||
private val _agreementStatus = MutableLiveData(PreferenceUtil.getAgreement())
|
||||
val agreementStatus: LiveData<Boolean> = _agreementStatus
|
||||
fun setIsAgreement(agreement: Boolean){
|
||||
PreferenceUtil.saveAgreement(agreement)
|
||||
_agreementStatus.value = agreement
|
||||
}
|
||||
|
||||
init {
|
||||
// 注册网络监听
|
||||
|
|
@ -66,14 +70,12 @@ class GeneralViewModel: BaseViewModel(){
|
|||
.build()
|
||||
connectivityManager.registerNetworkCallback(request, networkCallback)
|
||||
}
|
||||
|
||||
// 初始化状态
|
||||
_networkStatus.value = isNetworkAvailable()
|
||||
// 初始化隐私政策状态
|
||||
_agreementStatus.value = PreferenceUtil.getAgreement()
|
||||
|
||||
// 初始化微信API
|
||||
HeadParamUtils.applicationContext?.let { initWXApi(it) }
|
||||
// 隐私政策状态
|
||||
_agreementStatus.value = PreferenceUtil.getAgreement()
|
||||
}
|
||||
|
||||
private fun isNetworkAvailable(): Boolean {
|
||||
|
|
@ -92,11 +94,6 @@ class GeneralViewModel: BaseViewModel(){
|
|||
_isNavigationBarVisible.value = visible
|
||||
}
|
||||
|
||||
fun setIsAgreement(agreement: Boolean){
|
||||
PreferenceUtil.saveAgreement(agreement)
|
||||
_agreementStatus.value = agreement
|
||||
}
|
||||
|
||||
private fun initWXApi(context: Context) {
|
||||
api = WXAPIFactory.createWXAPI(context, Constants.WxAppId, true)
|
||||
api.registerApp(Constants.WxAppId)
|
||||
|
|
@ -116,18 +113,6 @@ class GeneralViewModel: BaseViewModel(){
|
|||
}
|
||||
}
|
||||
|
||||
// private fun wxPay(api: IWXAPI){
|
||||
// val request = PayReq()
|
||||
// request.appId = "wx7d1a7d1507482cef"
|
||||
// request.partnerId = "1511850511";
|
||||
// request.prepayId= "wx06112039579543463f9116a0527ce30001"
|
||||
// request.packageValue = "Sign=WXPay"
|
||||
// request.nonceStr= "QjlkDdZY54eKmvfKrtawJD9Cws7pvUh0"
|
||||
// request.timeStamp= "1772767239"
|
||||
// request.sign= "DOhyV8QBng20nrZxgV8l8+4DD1foi7XKRfPnhHbzf63qWvL2f3miKTqAVtoS1U9syO38ENXrS18XzWHRMNnoyWgTGLp/SxbZjRjqHvrLJKIa1pH0svdv/uPXK1GlvjqsMXgeoTEXn73aHBNlcctNaZ8GCWbxpg77kdcCJfM+qWOSQOMJOpKh8lTx4dQzhWqdOSzABkQJTg6TThNUN3/00yeN7K9wZ4JOpN+Tmtaliztp0wQ3iAHgAqZmhxwv7ZyRev2izpoukdJ2aBn/+xPK/Hs5kI2KM67x6quvrWiQV31GixU2i84ddI3uxn1DwR90f5iEyA10NOylPA+D9rOEUQ=="
|
||||
// api.sendReq(request)
|
||||
// }
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
connectivityManager.unregisterNetworkCallback(networkCallback)
|
||||
|
|
|
|||
Loading…
Reference in New Issue