Skip to content

Commit

Permalink
use ModManagerTheme instead of MaterialTheme
Browse files Browse the repository at this point in the history
  • Loading branch information
lings03 committed Dec 29, 2024
1 parent 6d57d97 commit 405ad13
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
39 changes: 19 additions & 20 deletions app/src/main/kotlin/top/lings/start/StartActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import android.util.DisplayMetrics
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.ui.graphics.toArgb
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsControllerCompat
import top.laoxin.modmanager.MainActivity
import top.laoxin.modmanager.ui.theme.ModManagerTheme
import top.lings.userAgreement.UserAgreementActivity

class StartActivity : ComponentActivity() {
Expand All @@ -41,23 +39,8 @@ class StartActivity : ComponentActivity() {
@Suppress("DEPRECATION")
window.navigationBarColor = MaterialTheme.colorScheme.surfaceContainer.toArgb()
}
MaterialTheme(
colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()
) {
Start(onTimeout = {
// 检查用户协议状态并跳转到 MainActivity 或 UserAgreementActivity
val sharedPreferences = getSharedPreferences("AppLaunch", MODE_PRIVATE)
val isConfirm = sharedPreferences.getBoolean("isConfirm", false)

val intent = if (isConfirm) {
Intent(this, MainActivity::class.java)
} else {
Intent(this, UserAgreementActivity::class.java)
}

startActivity(intent)
finish()
})
ModManagerTheme {
Start(onTimeout = ::jumpToActivity)
}
}
}
Expand All @@ -66,6 +49,22 @@ class StartActivity : ComponentActivity() {
super.onDestroy()
}

// 跳转到 MainActivity 或 UserAgreementActivity
fun jumpToActivity() {
// 检查用户协议状态并跳转到 MainActivity 或 UserAgreementActivity
val sharedPreferences = getSharedPreferences("AppLaunch", MODE_PRIVATE)
val isConfirm = sharedPreferences.getBoolean("isConfirm", false)

val intent = if (isConfirm) {
Intent(this, MainActivity::class.java)
} else {
Intent(this, UserAgreementActivity::class.java)
}

startActivity(intent)
finish()
}

// 检查屏幕方向
fun checkOrientation() {
// 获取屏幕宽度
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.ui.graphics.toArgb
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsControllerCompat
import top.laoxin.modmanager.ui.theme.ModManagerTheme

class UserAgreementActivity : ComponentActivity() {

Expand All @@ -32,9 +30,7 @@ class UserAgreementActivity : ComponentActivity() {
@Suppress("DEPRECATION")
window.navigationBarColor = MaterialTheme.colorScheme.surfaceContainer.toArgb()
}
MaterialTheme(
colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()
) {
ModManagerTheme {
UserAgreement()
}
}
Expand Down

0 comments on commit 405ad13

Please sign in to comment.