feat: 新 UI 实验性特性

This commit is contained in:
HuanCheng65 2023-10-05 18:33:33 +08:00
parent abc4a7b862
commit 37e69fdbcc
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
2 changed files with 47 additions and 5 deletions

View File

@ -1,6 +1,8 @@
package com.huanchengfly.tieba.post.ui.page.settings.about package com.huanchengfly.tieba.post.ui.page.settings.about
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
@ -15,19 +17,27 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.material.TextButton import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.google.accompanist.drawablepainter.rememberDrawablePainter import com.google.accompanist.drawablepainter.rememberDrawablePainter
import com.google.accompanist.insets.ui.Scaffold
import com.huanchengfly.tieba.post.BuildConfig import com.huanchengfly.tieba.post.BuildConfig
import com.huanchengfly.tieba.post.R import com.huanchengfly.tieba.post.R
import com.huanchengfly.tieba.post.toastShort
import com.huanchengfly.tieba.post.ui.common.theme.compose.ExtendedTheme import com.huanchengfly.tieba.post.ui.common.theme.compose.ExtendedTheme
import com.huanchengfly.tieba.post.ui.widgets.compose.BackNavigationIcon import com.huanchengfly.tieba.post.ui.widgets.compose.BackNavigationIcon
import com.huanchengfly.tieba.post.ui.widgets.compose.MyScaffold
import com.huanchengfly.tieba.post.ui.widgets.compose.TitleCentredToolbar import com.huanchengfly.tieba.post.ui.widgets.compose.TitleCentredToolbar
import com.huanchengfly.tieba.post.utils.appPreferences
import com.huanchengfly.tieba.post.utils.launchUrl import com.huanchengfly.tieba.post.utils.launchUrl
import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.DestinationsNavigator
@ -37,11 +47,20 @@ import com.ramcosta.composedestinations.navigation.DestinationsNavigator
fun AboutPage( fun AboutPage(
navigator: DestinationsNavigator, navigator: DestinationsNavigator,
) { ) {
Scaffold( var lastClickTime by remember { mutableLongStateOf(0L) }
var clickCount by remember { mutableIntStateOf(0) }
MyScaffold(
backgroundColor = Color.Transparent, backgroundColor = Color.Transparent,
topBar = { topBar = {
TitleCentredToolbar( TitleCentredToolbar(
title = stringResource(id = R.string.title_about), title = {
Text(
text = stringResource(id = R.string.title_about),
fontWeight = FontWeight.Bold,
style = MaterialTheme.typography.h6
)
},
navigationIcon = { navigationIcon = {
BackNavigationIcon(onBackPressed = { navigator.navigateUp() }) BackNavigationIcon(onBackPressed = { navigator.navigateUp() })
} }
@ -91,7 +110,30 @@ fun AboutPage(
Text( Text(
text = stringResource(id = R.string.tip_about, BuildConfig.VERSION_NAME), text = stringResource(id = R.string.tip_about, BuildConfig.VERSION_NAME),
style = MaterialTheme.typography.caption, style = MaterialTheme.typography.caption,
color = ExtendedTheme.colors.textSecondary color = ExtendedTheme.colors.textSecondary,
modifier = Modifier.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null,
onClick = {
val currentTime = System.currentTimeMillis()
if (currentTime - lastClickTime < 500) {
clickCount++
} else {
clickCount = 1
}
lastClickTime = currentTime
if (clickCount >= 7) {
clickCount = 0
context.appPreferences.showExperimentalFeatures =
!context.appPreferences.showExperimentalFeatures
if (context.appPreferences.showExperimentalFeatures) {
context.toastShort(R.string.toast_experimental_features_enabled)
} else {
context.toastShort(R.string.toast_experimental_features_disabled)
}
}
}
)
) )
} }
Spacer(modifier = Modifier.height(48.dp)) Spacer(modifier = Modifier.height(48.dp))

View File

@ -641,7 +641,7 @@
<string name="insert_voice">语音</string> <string name="insert_voice">语音</string>
<string name="emoticon_default">表情</string> <string name="emoticon_default">表情</string>
<string name="emoticon">表情 %s</string> <string name="emoticon">表情 %s</string>
<string name="summary_enable_new_ui">(实验性特性)启用新版 UI。仅少部分页面完成BUG 可能较多,仅供尝鲜使用!</string> <string name="summary_enable_new_ui">启用新版 UI。部分页面尚未完成BUG 可能较多,仅供尝鲜使用!</string>
<string name="title_enable_new_ui">启用新版 UI</string> <string name="title_enable_new_ui">启用新版 UI</string>
<string name="title_dialog_oksign_battery_optimization">请忽略“电池优化”</string> <string name="title_dialog_oksign_battery_optimization">请忽略“电池优化”</string>
<string name="message_dialog_oksign_battery_optimization">在 Android 12 及以上版本中,后台启动前台服务被严格限制。为了避免一键签到无法正常启动,请忽略本应用的“电池优化”。</string> <string name="message_dialog_oksign_battery_optimization">在 Android 12 及以上版本中,后台启动前台服务被严格限制。为了避免一键签到无法正常启动,请忽略本应用的“电池优化”。</string>