From 18764daccc50fa505eedb932e35a4ad36770aded Mon Sep 17 00:00:00 2001 From: Super12138 <70494801+Super12138@users.noreply.github.com> Date: Tue, 25 Mar 2025 21:15:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20GitHub=20=E5=A4=A7=E5=B0=8F=E5=86=99?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 顺便修改彩蛋触发逻辑 --- .../super12138/todo/ui/icons/GithubIcons.kt | 14 +++++----- .../todo/ui/pages/settings/SettingsAbout.kt | 27 +++++++++++++++---- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/app/src/main/kotlin/cn/super12138/todo/ui/icons/GithubIcons.kt b/app/src/main/kotlin/cn/super12138/todo/ui/icons/GithubIcons.kt index e1066de..30525c6 100644 --- a/app/src/main/kotlin/cn/super12138/todo/ui/icons/GithubIcons.kt +++ b/app/src/main/kotlin/cn/super12138/todo/ui/icons/GithubIcons.kt @@ -6,13 +6,13 @@ import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.path import androidx.compose.ui.unit.dp -val GithubIcon: ImageVector +val GitHubIcon: ImageVector get() { - if (_GithubIcon != null) { - return _GithubIcon!! + if (_GitHubIcon != null) { + return _GitHubIcon!! } - _GithubIcon = ImageVector.Builder( - name = "GithubIcon", + _GitHubIcon = ImageVector.Builder( + name = "GitHubIcon", defaultWidth = 24.dp, defaultHeight = 24.dp, viewportWidth = 24f, @@ -49,8 +49,8 @@ val GithubIcon: ImageVector } }.build() - return _GithubIcon!! + return _GitHubIcon!! } @Suppress("ObjectPropertyName") -private var _GithubIcon: ImageVector? = null +private var _GitHubIcon: ImageVector? = null diff --git a/app/src/main/kotlin/cn/super12138/todo/ui/pages/settings/SettingsAbout.kt b/app/src/main/kotlin/cn/super12138/todo/ui/pages/settings/SettingsAbout.kt index f68d510..5d48f06 100644 --- a/app/src/main/kotlin/cn/super12138/todo/ui/pages/settings/SettingsAbout.kt +++ b/app/src/main/kotlin/cn/super12138/todo/ui/pages/settings/SettingsAbout.kt @@ -1,7 +1,6 @@ package cn.super12138.todo.ui.pages.settings import android.content.Intent -import android.net.Uri import android.widget.Toast import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize @@ -15,20 +14,24 @@ import androidx.compose.material.icons.outlined.Person4 import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect 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.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource +import androidx.core.net.toUri import cn.super12138.todo.R import cn.super12138.todo.constants.Constants import cn.super12138.todo.ui.components.LargeTopAppBarScaffold -import cn.super12138.todo.ui.icons.GithubIcon +import cn.super12138.todo.ui.icons.GitHubIcon import cn.super12138.todo.ui.pages.settings.components.SettingsItem import cn.super12138.todo.utils.SystemUtils +import kotlinx.coroutines.delay @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -53,6 +56,20 @@ fun SettingsAbout( .verticalScroll(rememberScrollState()) ) { var clickCount by remember { mutableIntStateOf(0) } + var lastClickTime by remember { mutableLongStateOf(0L) } + + LaunchedEffect(clickCount) { + if (clickCount > 0) { + lastClickTime = System.currentTimeMillis() + val currentClickTime = lastClickTime + delay(300L) + + if (currentClickTime == lastClickTime) { + clickCount = 0 + } + } + } + SettingsItem( leadingIcon = Icons.Outlined.Numbers, title = stringResource(R.string.pref_app_version), @@ -74,16 +91,16 @@ fun SettingsAbout( title = stringResource(R.string.pref_developer), description = stringResource(R.string.developer_name), onClick = { - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(Constants.DEVELOPER_GITHUB)) + val intent = Intent(Intent.ACTION_VIEW, Constants.DEVELOPER_GITHUB.toUri()) context.startActivity(intent) } ) SettingsItem( - leadingIcon = GithubIcon, + leadingIcon = GitHubIcon, title = stringResource(R.string.pref_view_on_github), description = stringResource(R.string.pref_view_on_github_desc), onClick = { - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(Constants.GITHUB_REPO)) + val intent = Intent(Intent.ACTION_VIEW, Constants.GITHUB_REPO.toUri()) context.startActivity(intent) } )