feat: add website

This commit is contained in:
particle-box
2026-02-07 09:34:22 +05:30
parent 6eec014493
commit c16f1f130d

View File

@@ -46,13 +46,13 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.Help
import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Bolt import androidx.compose.material.icons.filled.Bolt
import androidx.compose.material.icons.filled.BugReport import androidx.compose.material.icons.filled.BugReport
import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Check
import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Download import androidx.compose.material.icons.filled.Download
import androidx.compose.material.icons.filled.Language
import androidx.compose.material.icons.filled.Info import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.Notifications import androidx.compose.material.icons.filled.Notifications
import androidx.compose.material.icons.filled.Schedule import androidx.compose.material.icons.filled.Schedule
@@ -137,6 +137,7 @@ class HomeRootSection : Routes.Route() {
override val translation by lazy { context.translation.getCategory("manager.sections.home") } override val translation by lazy { context.translation.getCategory("manager.sections.home") }
companion object { companion object {
private const val QUICK_TILES_INITIALIZED_PREF = "quick_tiles_initialized"
val cardMargin = 10.dp val cardMargin = 10.dp
val pageBackgroundGradient = Brush.verticalGradient( val pageBackgroundGradient = Brush.verticalGradient(
listOf( listOf(
@@ -408,7 +409,7 @@ class HomeRootSection : Routes.Route() {
onUpdateAction: () -> Unit, onUpdateAction: () -> Unit,
channelLabel: String, channelLabel: String,
isPurrAuraActive: Boolean, isPurrAuraActive: Boolean,
onWikiClick: () -> Unit, onWebsiteClick: () -> Unit,
onTelegramClick: () -> Unit, onTelegramClick: () -> Unit,
onGithubClick: () -> Unit, onGithubClick: () -> Unit,
authorName: String, authorName: String,
@@ -649,15 +650,15 @@ class HomeRootSection : Routes.Route() {
) { ) {
Button( Button(
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
onClick = onWikiClick, onClick = onWebsiteClick,
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
containerColor = Color.White, containerColor = Color.White,
contentColor = Color(0xFF1B152E) contentColor = Color(0xFF1B152E)
) )
) { ) {
Icon(Icons.AutoMirrored.Filled.Help, contentDescription = null, modifier = Modifier.size(18.dp)) Icon(Icons.Filled.Language, contentDescription = null, modifier = Modifier.size(18.dp))
Spacer(modifier = Modifier.width(8.dp)) Spacer(modifier = Modifier.width(8.dp))
Text(text = translation["wiki_button"], maxLines = 1, overflow = TextOverflow.Ellipsis) Text(text = "Site", maxLines = 1, overflow = TextOverflow.Ellipsis)
} }
OutlinedButton( OutlinedButton(
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
@@ -736,8 +737,25 @@ class HomeRootSection : Routes.Route() {
val avenirNext = remember { val avenirNext = remember {
FontFamily(Font(R.font.avenir_next_medium, FontWeight.Medium)) FontFamily(Font(R.font.avenir_next_medium, FontWeight.Medium))
} }
val selectedTiles = rememberAsyncMutableStateList(defaultValue = listOf()) { val prefs = remember { context.sharedPreferences }
context.database.getQuickTiles().filter { it.isNotBlank() } val allQuickTileNames = remember(cards) { cards.keys.map { it.first } }
val selectedTiles = rememberAsyncMutableStateList(defaultValue = allQuickTileNames) {
val storedTiles = context.database.getQuickTiles().filter { it.isNotBlank() }
val hasInitializedQuickTiles = prefs.getBoolean(QUICK_TILES_INITIALIZED_PREF, false)
when {
storedTiles.isNotEmpty() -> {
if (!hasInitializedQuickTiles) {
prefs.edit().putBoolean(QUICK_TILES_INITIALIZED_PREF, true).apply()
}
storedTiles
}
hasInitializedQuickTiles -> storedTiles
else -> {
context.database.setQuickTiles(allQuickTileNames)
prefs.edit().putBoolean(QUICK_TILES_INITIALIZED_PREF, true).apply()
allQuickTileNames
}
}
} }
val updateChannel = context.config.root.global.updateSettings.updateChannel.getNullable() ?: "stable" val updateChannel = context.config.root.global.updateSettings.updateChannel.getNullable() ?: "stable"
val channelLabel = if (updateChannel == "prerelease") translation["channel_label_prerelease"] else translation["channel_label_stable"] val channelLabel = if (updateChannel == "prerelease") translation["channel_label_prerelease"] else translation["channel_label_stable"]
@@ -952,9 +970,9 @@ class HomeRootSection : Routes.Route() {
onUpdateAction = onUpdateButtonClick, onUpdateAction = onUpdateButtonClick,
channelLabel = channelLabel, channelLabel = channelLabel,
isPurrAuraActive = isPurrAuraActive, isPurrAuraActive = isPurrAuraActive,
onWikiClick = { onWebsiteClick = {
context.androidContext.openLink( context.androidContext.openLink(
"https://github.com/particle-box/PurrfectSnap/wiki", "https://purrfectsnap.vercel.app/",
context.translation["toast_open_link_failed"] context.translation["toast_open_link_failed"]
) )
}, },
@@ -1313,6 +1331,7 @@ class HomeRootSection : Routes.Route() {
newList.forEach { clearTileOffset(it) } newList.forEach { clearTileOffset(it) }
selectedTiles.clear() selectedTiles.clear()
selectedTiles.addAll(newList) selectedTiles.addAll(newList)
prefs.edit().putBoolean(QUICK_TILES_INITIALIZED_PREF, true).apply()
context.coroutineScope.launch { context.coroutineScope.launch {
context.database.setQuickTiles(selectedTiles) context.database.setQuickTiles(selectedTiles)
} }