Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed Jan 26, 2024
1 parent 05bebd8 commit 0163a6b
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import cafe.adriel.voyager.core.model.ScreenModel
import cafe.adriel.voyager.core.model.screenModelScope
import com.aliucord.manager.BuildConfig
import com.aliucord.manager.R
import com.aliucord.manager.manager.PreferencesManager
import com.aliucord.manager.domain.repository.GithubRepository
import com.aliucord.manager.installer.util.uninstallApk
import com.aliucord.manager.manager.PreferencesManager
import com.aliucord.manager.network.utils.fold
import com.aliucord.manager.ui.util.DiscordVersion
import com.aliucord.manager.util.getPackageVersion
Expand Down
126 changes: 63 additions & 63 deletions app/src/main/kotlin/com/aliucord/manager/ui/screens/home/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,78 +86,78 @@ class HomeScreen : Screen {
modifier = Modifier
) {

AnimatedVisibility(
enter = fadeIn() + slideInVertically { it * -2 },
visible = model.installedVersion !is DiscordVersion.None,
) {
Text(
text = buildAnnotatedString {
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
append(stringResource(R.string.version_supported))
}
append(" ")
if (model.installedVersion is DiscordVersion.Existing) {
append((model.installedVersion as DiscordVersion.Existing).name)
append(" - ")
}
append(model.installedVersion.toDisplayName())
},
style = MaterialTheme.typography.labelLarge,
color = LocalContentColor.current.copy(alpha = .5f),
)
}

FilledTonalIconButton(
shape = MaterialTheme.shapes.large,
enabled = true, // TODO: disable when installation is already present (no multi-install support yet)
onClick = { showInstallerDialog = true },
modifier = Modifier.fillMaxWidth(),
) {
Row(
horizontalArrangement = Arrangement.spacedBy(6.dp),
verticalAlignment = Alignment.CenterVertically,
AnimatedVisibility(
enter = fadeIn() + slideInVertically { it * -2 },
visible = model.installedVersion !is DiscordVersion.None,
) {
Icon(
painter = painterResource(R.drawable.ic_add),
contentDescription = null,
)
Text(
text = stringResource(R.string.action_add_install),
text = buildAnnotatedString {
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
append(stringResource(R.string.version_supported))
}
append(" ")
if (model.installedVersion is DiscordVersion.Existing) {
append((model.installedVersion as DiscordVersion.Existing).name)
append(" - ")
}
append(model.installedVersion.toDisplayName())
},
style = MaterialTheme.typography.labelLarge,
color = LocalContentColor.current.copy(alpha = .5f),
)
}
}

val ctx = LocalContext.current
val appIcon = remember {
ctx.packageManager
.getApplicationIcon("com.aliucord")
.toBitmap()
.asImageBitmap()
.let(::BitmapPainter)
}

InstalledItemCard(
appIcon = appIcon,
appName = "Aliucord",
packageName = "com.aliucord",
discordVersion = model.installedVersion,
onOpenApp = model::launchAliucord,
onOpenInfo = {},
onUninstall = model::uninstallAliucord,
)
FilledTonalIconButton(
shape = MaterialTheme.shapes.large,
enabled = true, // TODO: disable when installation is already present (no multi-install support yet)
onClick = { showInstallerDialog = true },
modifier = Modifier.fillMaxWidth(),
) {
Row(
horizontalArrangement = Arrangement.spacedBy(6.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
painter = painterResource(R.drawable.ic_add),
contentDescription = null,
)
Text(
text = stringResource(R.string.action_add_install),
style = MaterialTheme.typography.labelLarge,
)
}
}

InstalledItemCard(
appIcon = appIcon,
appName = "Aliucord test",
packageName = "com.aliucord2",
discordVersion = model.installedVersion,
onOpenApp = model::launchAliucord,
onOpenInfo = {},
onUninstall = model::uninstallAliucord,
)
val ctx = LocalContext.current
val appIcon = remember {
ctx.packageManager
.getApplicationIcon("com.aliucord")
.toBitmap()
.asImageBitmap()
.let(::BitmapPainter)
}

InstalledItemCard(
appIcon = appIcon,
appName = "Aliucord",
packageName = "com.aliucord",
discordVersion = model.installedVersion,
onOpenApp = model::launchAliucord,
onOpenInfo = {},
onUninstall = model::uninstallAliucord,
)

InstalledItemCard(
appIcon = appIcon,
appName = "Aliucord test",
packageName = "com.aliucord2",
discordVersion = model.installedVersion,
onOpenApp = model::launchAliucord,
onOpenInfo = {},
onUninstall = model::uninstallAliucord,
)
}

Spacer(Modifier.height(120.dp))
InfoCard(
packageName = model.preferences.packageName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import cafe.adriel.voyager.core.model.ScreenModel
import cafe.adriel.voyager.core.model.screenModelScope
import com.aliucord.manager.BuildConfig
import com.aliucord.manager.R
import com.aliucord.manager.manager.DownloadManager
import com.aliucord.manager.manager.PreferencesManager
import com.aliucord.manager.domain.repository.AliucordMavenRepository
import com.aliucord.manager.domain.repository.GithubRepository
import com.aliucord.manager.installer.util.*
import com.aliucord.manager.manager.DownloadManager
import com.aliucord.manager.manager.PreferencesManager
import com.aliucord.manager.network.utils.getOrThrow
import com.aliucord.manager.ui.components.installer.InstallStatus
import com.aliucord.manager.ui.components.installer.InstallStepData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import cafe.adriel.voyager.koin.getScreenModel
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.currentOrThrow
import com.aliucord.manager.R
import com.aliucord.manager.ui.components.BackButton
import com.aliucord.manager.ui.components.back
import com.aliucord.manager.ui.components.dialogs.DownloadMethod
import com.aliucord.manager.ui.components.dialogs.InstallerAbortDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import androidx.compose.runtime.*
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.aliucord.manager.BuildConfig
import com.aliucord.manager.manager.DownloadManager
import com.aliucord.manager.domain.repository.GithubRepository
import com.aliucord.manager.installer.util.installApks
import com.aliucord.manager.manager.DownloadManager
import com.aliucord.manager.network.utils.SemVer
import com.aliucord.manager.network.utils.getOrNull
import kotlinx.coroutines.Dispatchers
Expand Down

0 comments on commit 0163a6b

Please sign in to comment.