暗黑模式按钮、更新弹框文案

This commit is contained in:
2024-10-26 06:53:47 +08:00
parent e38c36aa2c
commit 8dca3e8de1
6 changed files with 135 additions and 7 deletions

View File

@@ -25,6 +25,7 @@ import androidx.compose.animation.SharedTransitionScope
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.core.content.ContextCompat
import androidx.core.view.WindowCompat
import androidx.lifecycle.ProcessLifecycleOwner
@@ -112,15 +113,16 @@ class MainActivity : ComponentActivity() {
private fun showUpdateDialog(updateInfo: UpdateInfo) {
val builder = AlertDialog.Builder(this)
builder.setTitle("发现新版本 v${updateInfo.versionName}")
builder.setTitle("🔴 ${getString(R.string.update_find_new_version)} v${updateInfo.versionName}")
builder.setMessage(updateInfo.updateContent)
builder.setPositiveButton("立即更新") { dialog, _ ->
builder.setPositiveButton(R.string.update_update_now) { dialog, _ ->
downloadApk(updateInfo.downloadUrl,updateInfo.versionName)
dialog.dismiss()
}
if (!updateInfo.forceUpdate) {
builder.setNegativeButton("稍后再说") { dialog, _ ->
builder.setNegativeButton(R.string.update_later) { dialog, _ ->
dialog.dismiss()
}
} else {

View File

@@ -3,6 +3,7 @@ package com.aiosman.riderpro.ui.index.tabs.profile
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.widget.Toast
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
@@ -33,6 +34,7 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
@@ -61,6 +63,7 @@ import androidx.paging.PagingData
import androidx.paging.compose.collectAsLazyPagingItems
import com.aiosman.riderpro.AppColors
import com.aiosman.riderpro.AppState
import com.aiosman.riderpro.AppStore
import com.aiosman.riderpro.ConstVars
import com.aiosman.riderpro.LocalNavController
import com.aiosman.riderpro.R
@@ -282,6 +285,16 @@ fun ProfileV3(
scope.launch {
navController.navigate(NavigationRoute.FavouriteList.route)
}
},
MenuItem(
stringResource(R.string.dark_mode),
R.drawable.rider_pro_theme_mode_light
) {
expanded = false
scope.launch {
AppStore.saveDarkMode(!AppState.darkMode)
Toast.makeText(context, "Theme mode changed,please restart app", Toast.LENGTH_SHORT).show()
}
}
)
)
@@ -334,10 +347,6 @@ fun ProfileV3(
}
}
// collapsed bar
}
}
@@ -399,6 +408,7 @@ fun ProfileV3(
tint = AppColors.text
)
}
val themeModeString = if (AppState.darkMode) R.string.light_mode else R.string.dark_mode
DropdownMenu(
expanded = minibarExpanded,
onDismissRequest = { minibarExpanded = false },
@@ -435,6 +445,16 @@ fun ProfileV3(
scope.launch {
navController.navigate(NavigationRoute.FavouriteList.route)
}
},
MenuItem(
stringResource(themeModeString),
R.drawable.rider_pro_theme_mode_light
) {
minibarExpanded = false
scope.launch {
AppStore.saveDarkMode(!AppState.darkMode)
Toast.makeText(context, "Theme mode changed,please restart app", Toast.LENGTH_SHORT).show()
}
}
)
)