Skip to content

Commit

Permalink
more fun facts & success banner
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed May 19, 2024
1 parent b614937 commit c50e7a0
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.app.Application
import android.content.Intent
import android.os.Build
import android.util.Log
import androidx.annotation.StringRes
import androidx.compose.runtime.*
import cafe.adriel.voyager.core.model.StateScreenModel
import cafe.adriel.voyager.core.model.screenModelScope
Expand All @@ -26,6 +27,7 @@ import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import java.text.SimpleDateFormat
import java.util.Date
import kotlin.time.Duration.Companion.seconds

class InstallModel(
private val application: Application,
Expand All @@ -42,11 +44,19 @@ class InstallModel(
var showGppWarning by mutableStateOf(false)
private set

@get:StringRes
var funFact by mutableIntStateOf(0)
private set

init {
restart()

screenModelScope.launch {
while (true) {
funFact = FUN_FACTS.random()
delay(20.seconds)
}
}
}

fun launchApp() {
Expand Down Expand Up @@ -79,7 +89,7 @@ class InstallModel(
}

fun clearCache() {
paths.clearCache()
screenModelScope.launch { paths.clearCache() }
application.showToast(R.string.action_cleared_cache)
}

Expand All @@ -102,7 +112,6 @@ class InstallModel(
installSteps = null

startTime = Date()
funFact = FUN_FACTS.random()
mutableState.value = InstallScreenState.Working

val newInstallJob = screenModelScope.launch {
Expand Down Expand Up @@ -198,6 +207,13 @@ class InstallModel(
R.string.fun_fact_2,
R.string.fun_fact_3,
R.string.fun_fact_4,
R.string.fun_fact_5,
R.string.fun_fact_6,
R.string.fun_fact_7,
R.string.fun_fact_8,
R.string.fun_fact_9,
R.string.fun_fact_10,
R.string.fun_fact_11,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ package com.aliucord.manager.ui.screens.install
import android.os.Parcelable
import androidx.activity.compose.BackHandler
import androidx.compose.animation.*
import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.painterResource
Expand All @@ -37,6 +39,7 @@ import com.aliucord.manager.ui.screens.install.components.*
import com.aliucord.manager.ui.screens.installopts.InstallOptions
import com.aliucord.manager.ui.util.paddings.*
import com.aliucord.manager.ui.util.spacedByLastAtBottom
import com.aliucord.manager.ui.util.thenIf
import com.aliucord.manager.util.isIgnoringBatteryOptimizations
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.flow.filter
Expand Down Expand Up @@ -174,6 +177,21 @@ class InstallScreen(private val data: InstallOptions) : Screen, Parcelable {
}
}

item(key = "INSTALLED_BANNER") {
BannerSection(visible = state is InstallScreenState.Success) {
TextBanner(
text = "Successfully installed Aliucord! Do *NOT* uninstall the manager (this app) as it is required to perform certain types of updates.",
icon = painterResource(R.drawable.ic_check_circle),
iconColor = Color(0xFF59B463),
outlineColor = MaterialTheme.colorScheme.surfaceVariant,
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh,
modifier = Modifier
.padding(bottom = VERTICAL_PADDING)
.fillMaxWidth(),
)
}
}

for ((group, steps) in model.installSteps?.entries ?: persistentListOf()) {
item(key = System.identityHashCode(group)) {
StepGroupCard(
Expand All @@ -184,11 +202,13 @@ class InstallScreen(private val data: InstallOptions) : Screen, Parcelable {
modifier = Modifier
.padding(bottom = VERTICAL_PADDING)
.fillMaxWidth()
.thenIf(state is InstallScreenState.Success) { alpha(.6f) }
)
}
}

item(key = "BUTTONS") {
var cacheCleared by remember { mutableStateOf(false) }
val filteredState by remember { model.state.filter { it.isNewlyFinished } }
.collectAsState(initial = null)

Expand Down Expand Up @@ -224,21 +244,49 @@ class InstallScreen(private val data: InstallOptions) : Screen, Parcelable {

else -> error("unreachable")
}

Row(
horizontalArrangement = Arrangement.End,
modifier = Modifier
.padding(top = 8.dp)
.fillMaxWidth()
) {
// Clear cache button
Button(
// TODO: adjust colors
onClick = {
cacheCleared = true
// model.clearCache()
},
enabled = !cacheCleared,
) {
Text(stringResource(R.string.setting_clear_cache))
}
}
}
}
}

item(key = "FUN_FACT") {
Text(
text = stringResource(R.string.fun_fact_prefix, stringResource(model.funFact)),
style = MaterialTheme.typography.bodySmall,
textAlign = TextAlign.Center,
modifier = Modifier
.padding(horizontal = VERTICAL_PADDING)
.padding(bottom = 25.dp)
.fillMaxWidth()
.alpha(.6f)
)
AnimatedContent(
targetState = model.funFact,
label = "fun fact transition",
transitionSpec = {
(fadeIn(tween(220, delayMillis = 90)) + slideInHorizontally { it * -2 }) togetherWith
(fadeOut(tween(90)) + slideOutHorizontally { it * 2 })
}
) { text ->
Text(
text = stringResource(R.string.fun_fact_prefix, stringResource(text)),
style = MaterialTheme.typography.bodySmall,
textAlign = TextAlign.Center,
modifier = Modifier
.padding(horizontal = VERTICAL_PADDING)
.padding(bottom = 25.dp)
.fillMaxWidth()
.alpha(.6f)
)
}
}
}
}
Expand Down

This file was deleted.

7 changes: 7 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,11 @@
<string name="fun_fact_2">Did you know Aliucord with 150+ plugins somehow runs better than Discord\'s new app?</string>
<string name="fun_fact_3">Did you know Aliucord has over 200 available plugins?</string>
<string name="fun_fact_4">i am in your walls</string>
<string name="fun_fact_5">Did you know AliucordRN spawned Enmity and Vendetta?</string>
<string name="fun_fact_6">Having issues? Visit the #support channel in our Discord!</string>
<string name="fun_fact_7">The IWillCrashYourDiscord plugin crashes your discord.</string>
<string name="fun_fact_8">\"@Vendicated my bad.\"</string>
<string name="fun_fact_9">Aliucord can run on WearOS</string>
<string name="fun_fact_10">Aliucord uses the *real* old UI, from mid-2022!</string>
<string name="fun_fact_11">There was an attempt to make Aliucord run on iOS…</string>
</resources>

0 comments on commit c50e7a0

Please sign in to comment.