From bc69bd4a9dfe74db48e555cfcee20bf23cd6a20f Mon Sep 17 00:00:00 2001 From: X1nto Date: Mon, 28 Jun 2021 16:22:12 +0400 Subject: [PATCH] more refactor --- .../manager/network/model/AppDtoMapper.kt | 3 +- .../com/vanced/manager/ui/MainActivity.kt | 2 +- .../components/button/ManagerThemedButton.kt | 1 - .../button/ManagerThemedTextButton.kt | 3 - .../ui/components/card/ManagerItemCard.kt | 2 - .../ui/components/checkbox/ManagerCheckbox.kt | 3 - .../components/color/ColorContentProvider.kt | 3 - .../ui/components/color/ColorPicker.kt | 4 -- .../ui/components/color/ManagerColors.kt | 1 - .../ui/components/list/CheckboxItem.kt | 2 - .../ui/components/list/RadiobuttonItem.kt | 2 - .../components/preference/DialogPreference.kt | 1 - .../ui/components/preference/Preference.kt | 1 - .../ManagerProgressIndicator.kt | 22 +++++++ .../ui/components/text/CategoryTitleText.kt | 1 - .../vanced/manager/ui/layouts/AboutLayout.kt | 2 +- .../vanced/manager/ui/layouts/LogLayout.kt | 7 +- .../manager/ui/layouts/SettingsLayout.kt | 3 +- .../java/com/vanced/manager/ui/theme/Color.kt | 2 - .../widgets/home/apps/card/AppActionCard.kt | 43 +++++++----- .../ui/widgets/home/apps/card/AppCard.kt | 65 ++++++++++++------- .../home/apps/dialog/AppChangelogDialog.kt | 31 ++++----- .../home/apps/dialog/AppDownloadDialog.kt | 50 +++++--------- .../home/download/AppDownloadDialogButtons.kt | 18 ----- .../download/AppDownloadDialogProgress.kt | 48 +++++++------- .../CheckboxInstallationOption.kt | 2 +- .../ui/widgets/layout/CategoryLayout.kt | 2 +- .../ui/widgets/settings/AccentColorItem.kt | 2 +- 28 files changed, 152 insertions(+), 174 deletions(-) create mode 100644 app/src/main/java/com/vanced/manager/ui/components/progressindicator/ManagerProgressIndicator.kt delete mode 100644 app/src/main/java/com/vanced/manager/ui/widgets/home/download/AppDownloadDialogButtons.kt diff --git a/app/src/main/java/com/vanced/manager/network/model/AppDtoMapper.kt b/app/src/main/java/com/vanced/manager/network/model/AppDtoMapper.kt index ec65d012..05990004 100644 --- a/app/src/main/java/com/vanced/manager/network/model/AppDtoMapper.kt +++ b/app/src/main/java/com/vanced/manager/network/model/AppDtoMapper.kt @@ -12,7 +12,8 @@ import com.vanced.manager.downloader.impl.VancedDownloader import com.vanced.manager.network.util.MICROG_NAME import com.vanced.manager.network.util.MUSIC_NAME import com.vanced.manager.network.util.VANCED_NAME -import com.vanced.manager.ui.preferences.* +import com.vanced.manager.ui.preferences.CheckboxPreference +import com.vanced.manager.ui.preferences.RadioButtonPreference import com.vanced.manager.ui.preferences.holder.musicVersionPref import com.vanced.manager.ui.preferences.holder.vancedLanguagesPref import com.vanced.manager.ui.preferences.holder.vancedThemePref diff --git a/app/src/main/java/com/vanced/manager/ui/MainActivity.kt b/app/src/main/java/com/vanced/manager/ui/MainActivity.kt index b7f5a411..e6b0c47b 100644 --- a/app/src/main/java/com/vanced/manager/ui/MainActivity.kt +++ b/app/src/main/java/com/vanced/manager/ui/MainActivity.kt @@ -23,11 +23,11 @@ import com.vanced.manager.ui.components.color.managerAnimatedColor import com.vanced.manager.ui.components.color.managerSurfaceColor import com.vanced.manager.ui.components.color.managerTextColor import com.vanced.manager.ui.components.menu.ManagerDropdownMenuItem +import com.vanced.manager.ui.components.text.ToolbarTitleText import com.vanced.manager.ui.resources.managerString import com.vanced.manager.ui.screens.Screen import com.vanced.manager.ui.theme.ManagerTheme import com.vanced.manager.ui.theme.isDark -import com.vanced.manager.ui.components.text.ToolbarTitleText class MainActivity : AppCompatActivity() { diff --git a/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedButton.kt b/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedButton.kt index fb2bea85..4894d3c1 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedButton.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedButton.kt @@ -11,7 +11,6 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.luminance import androidx.compose.ui.unit.dp import com.vanced.manager.ui.components.color.managerAccentColor -import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun ManagerThemedButton( diff --git a/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedTextButton.kt b/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedTextButton.kt index 4c9a220b..d2524b25 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedTextButton.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/button/ManagerThemedTextButton.kt @@ -1,13 +1,10 @@ package com.vanced.manager.ui.components.button -import androidx.annotation.StringRes -import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import com.vanced.manager.ui.components.color.managerAccentColor import com.vanced.manager.ui.components.text.ManagerText -import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun ManagerThemedTextButton( diff --git a/app/src/main/java/com/vanced/manager/ui/components/card/ManagerItemCard.kt b/app/src/main/java/com/vanced/manager/ui/components/card/ManagerItemCard.kt index 93d96b84..ed6ae897 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/card/ManagerItemCard.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/card/ManagerItemCard.kt @@ -10,14 +10,12 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.vanced.manager.ui.components.color.ThemedItemContentColorProvider import com.vanced.manager.ui.components.color.managerAccentColor -import com.vanced.manager.ui.preferences.holder.managerAccentColorPref private val cardModifier = Modifier.sizeIn( minHeight = 95.dp, diff --git a/app/src/main/java/com/vanced/manager/ui/components/checkbox/ManagerCheckbox.kt b/app/src/main/java/com/vanced/manager/ui/components/checkbox/ManagerCheckbox.kt index 60d758c5..43d1b689 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/checkbox/ManagerCheckbox.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/checkbox/ManagerCheckbox.kt @@ -7,21 +7,18 @@ import androidx.compose.animation.core.updateTransition import androidx.compose.foundation.layout.requiredSize import androidx.compose.foundation.layout.size import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme import androidx.compose.material.icons.Icons import androidx.compose.material.icons.rounded.Close import androidx.compose.material.icons.rounded.Done import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import com.vanced.manager.ui.components.card.ManagerCard import com.vanced.manager.ui.components.color.contentColorForColor import com.vanced.manager.ui.components.color.managerAccentColor import com.vanced.manager.ui.components.color.managerAnimatedColor import com.vanced.manager.ui.components.color.managerThemedCardColor -import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @SuppressLint("UnusedTransitionTargetStateParameter") @Composable diff --git a/app/src/main/java/com/vanced/manager/ui/components/color/ColorContentProvider.kt b/app/src/main/java/com/vanced/manager/ui/components/color/ColorContentProvider.kt index 85791383..2b7022cc 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/color/ColorContentProvider.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/color/ColorContentProvider.kt @@ -1,11 +1,8 @@ package com.vanced.manager.ui.components.color import androidx.compose.material.LocalContentColor -import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.ui.graphics.Color -import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun ThemedItemContentColorProvider( diff --git a/app/src/main/java/com/vanced/manager/ui/components/color/ColorPicker.kt b/app/src/main/java/com/vanced/manager/ui/components/color/ColorPicker.kt index 268097c0..2eb04d90 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/color/ColorPicker.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/color/ColorPicker.kt @@ -2,17 +2,13 @@ package com.vanced.manager.ui.components.color import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.wrapContentHeight -import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import com.skydoves.colorpickerview.ColorEnvelope import com.skydoves.orchestra.colorpicker.ColorPicker -import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun ManagerColorPicker( diff --git a/app/src/main/java/com/vanced/manager/ui/components/color/ManagerColors.kt b/app/src/main/java/com/vanced/manager/ui/components/color/ManagerColors.kt index 4a38e1d5..cbaa4607 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/color/ManagerColors.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/color/ManagerColors.kt @@ -4,7 +4,6 @@ import androidx.compose.animation.animateColorAsState import androidx.compose.animation.core.tween import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.luminance import com.vanced.manager.ui.preferences.holder.managerAccentColorPref diff --git a/app/src/main/java/com/vanced/manager/ui/components/list/CheckboxItem.kt b/app/src/main/java/com/vanced/manager/ui/components/list/CheckboxItem.kt index 6312715e..19d238d1 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/list/CheckboxItem.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/list/CheckboxItem.kt @@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material.Checkbox import androidx.compose.material.CheckboxDefaults -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -16,7 +15,6 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.vanced.manager.ui.components.color.managerAccentColor import com.vanced.manager.ui.components.color.managerTextColor -import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun CheckboxItem( diff --git a/app/src/main/java/com/vanced/manager/ui/components/list/RadiobuttonItem.kt b/app/src/main/java/com/vanced/manager/ui/components/list/RadiobuttonItem.kt index 8db2b0e3..f8246bcd 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/list/RadiobuttonItem.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/list/RadiobuttonItem.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.material.MaterialTheme import androidx.compose.material.RadioButton import androidx.compose.material.RadioButtonDefaults import androidx.compose.material.Text @@ -16,7 +15,6 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.vanced.manager.ui.components.color.managerAccentColor import com.vanced.manager.ui.components.color.managerTextColor -import com.vanced.manager.ui.preferences.holder.managerAccentColorPref @Composable fun RadiobuttonItem( diff --git a/app/src/main/java/com/vanced/manager/ui/components/preference/DialogPreference.kt b/app/src/main/java/com/vanced/manager/ui/components/preference/DialogPreference.kt index 873b8ecc..c9c25021 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/preference/DialogPreference.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/preference/DialogPreference.kt @@ -1,6 +1,5 @@ package com.vanced.manager.ui.components.preference -import androidx.annotation.StringRes import androidx.compose.foundation.layout.ColumnScope import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState diff --git a/app/src/main/java/com/vanced/manager/ui/components/preference/Preference.kt b/app/src/main/java/com/vanced/manager/ui/components/preference/Preference.kt index d0f298f7..4d3e84e9 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/preference/Preference.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/preference/Preference.kt @@ -1,6 +1,5 @@ package com.vanced.manager.ui.components.preference -import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.padding import androidx.compose.material.LocalContentColor import androidx.compose.material.LocalTextStyle diff --git a/app/src/main/java/com/vanced/manager/ui/components/progressindicator/ManagerProgressIndicator.kt b/app/src/main/java/com/vanced/manager/ui/components/progressindicator/ManagerProgressIndicator.kt new file mode 100644 index 00000000..f6c80a2a --- /dev/null +++ b/app/src/main/java/com/vanced/manager/ui/components/progressindicator/ManagerProgressIndicator.kt @@ -0,0 +1,22 @@ +package com.vanced.manager.ui.components.progressindicator + +import androidx.compose.material.LinearProgressIndicator +import androidx.compose.runtime.Composable +import com.vanced.manager.ui.components.color.managerAccentColor + +@Composable +fun ManagerProgressIndicator() { + LinearProgressIndicator( + color = managerAccentColor() + ) +} + +@Composable +fun ManagerProgressIndicator( + progress: Float +) { + LinearProgressIndicator( + color = managerAccentColor(), + progress = progress + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/components/text/CategoryTitleText.kt b/app/src/main/java/com/vanced/manager/ui/components/text/CategoryTitleText.kt index 43d17a73..e5c7710b 100644 --- a/app/src/main/java/com/vanced/manager/ui/components/text/CategoryTitleText.kt +++ b/app/src/main/java/com/vanced/manager/ui/components/text/CategoryTitleText.kt @@ -1,6 +1,5 @@ package com.vanced.manager.ui.components.text -import androidx.annotation.StringRes import androidx.compose.foundation.layout.padding import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable diff --git a/app/src/main/java/com/vanced/manager/ui/layouts/AboutLayout.kt b/app/src/main/java/com/vanced/manager/ui/layouts/AboutLayout.kt index 4b55d8f9..ac3a27ba 100644 --- a/app/src/main/java/com/vanced/manager/ui/layouts/AboutLayout.kt +++ b/app/src/main/java/com/vanced/manager/ui/layouts/AboutLayout.kt @@ -21,9 +21,9 @@ import com.vanced.manager.ui.components.card.ManagerLinkCard import com.vanced.manager.ui.components.card.ManagerThemedCard import com.vanced.manager.ui.components.layout.ManagerScrollableColumn import com.vanced.manager.ui.components.layout.ScrollableItemRow -import com.vanced.manager.ui.resources.managerString import com.vanced.manager.ui.components.list.ManagerListItem import com.vanced.manager.ui.components.text.ManagerText +import com.vanced.manager.ui.resources.managerString import com.vanced.manager.ui.widgets.layout.CategoryLayout data class Person( diff --git a/app/src/main/java/com/vanced/manager/ui/layouts/LogLayout.kt b/app/src/main/java/com/vanced/manager/ui/layouts/LogLayout.kt index 81189fee..fbb8483a 100644 --- a/app/src/main/java/com/vanced/manager/ui/layouts/LogLayout.kt +++ b/app/src/main/java/com/vanced/manager/ui/layouts/LogLayout.kt @@ -2,16 +2,17 @@ package com.vanced.manager.ui.layouts import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.lazy.items -import androidx.compose.material.* +import androidx.compose.material.FloatingActionButton +import androidx.compose.material.Icon +import androidx.compose.material.Scaffold +import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Share import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import com.vanced.manager.ui.components.color.managerAccentColor import com.vanced.manager.ui.components.color.managerSurfaceColor import com.vanced.manager.ui.components.layout.ManagerLazyColumn -import com.vanced.manager.ui.preferences.holder.managerAccentColorPref import com.vanced.manager.util.logs @Composable diff --git a/app/src/main/java/com/vanced/manager/ui/layouts/SettingsLayout.kt b/app/src/main/java/com/vanced/manager/ui/layouts/SettingsLayout.kt index 43b6456d..b2c8a3fd 100644 --- a/app/src/main/java/com/vanced/manager/ui/layouts/SettingsLayout.kt +++ b/app/src/main/java/com/vanced/manager/ui/layouts/SettingsLayout.kt @@ -1,7 +1,6 @@ package com.vanced.manager.ui.layouts -import androidx.compose.runtime.* -import androidx.compose.ui.res.stringResource +import androidx.compose.runtime.Composable import androidx.compose.ui.unit.dp import com.vanced.manager.R import com.vanced.manager.ui.components.layout.ManagerScrollableColumn diff --git a/app/src/main/java/com/vanced/manager/ui/theme/Color.kt b/app/src/main/java/com/vanced/manager/ui/theme/Color.kt index 3bb279fc..8df8e374 100644 --- a/app/src/main/java/com/vanced/manager/ui/theme/Color.kt +++ b/app/src/main/java/com/vanced/manager/ui/theme/Color.kt @@ -1,8 +1,6 @@ package com.vanced.manager.ui.theme import androidx.compose.ui.graphics.Color -import com.vanced.manager.ui.components.color.managerAccentColor -import com.vanced.manager.ui.preferences.holder.managerAccentColorPref val primaryColor = Color(defAccentColor) val primaryColorVariant = primaryColor.copy(alpha = 0.25f) diff --git a/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/card/AppActionCard.kt b/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/card/AppActionCard.kt index 0f62cb0c..73278eec 100644 --- a/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/card/AppActionCard.kt +++ b/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/card/AppActionCard.kt @@ -7,25 +7,24 @@ import androidx.compose.material.icons.rounded.DeleteForever import androidx.compose.material.icons.rounded.Download import androidx.compose.material.icons.rounded.Launch import androidx.compose.runtime.Composable -import androidx.compose.runtime.MutableState import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.vanced.manager.R import com.vanced.manager.ui.components.button.IconButton +import com.vanced.manager.ui.components.text.AppVersionText import com.vanced.manager.ui.components.text.ManagerText import com.vanced.manager.ui.utils.defaultContentPaddingHorizontal -import com.vanced.manager.ui.components.text.AppVersionText @Composable fun AppActionCard( appRemoteVersion: String?, appInstalledVersion: String?, - showDownloadDialog: MutableState, - showAppInfo: MutableState, - showInstallationOptions: MutableState, - hasInstallationOptions: Boolean + onInfoClick: () -> Unit, + onUninstallClick: () -> Unit, + onLaunchClick: () -> Unit, + onDownloadClick: () -> Unit, ) { Row( modifier = Modifier.padding( @@ -65,18 +64,26 @@ fun AppActionCard( .padding(start = 4.dp) .wrapContentWidth(Alignment.End) ) { - IconButton(icon = Icons.Outlined.Info, contentDescription = "App Info") { - showAppInfo.value = true - } - IconButton(icon = Icons.Rounded.DeleteForever, contentDescription = "Uninstall") {} - IconButton(icon = Icons.Rounded.Launch, contentDescription = "Launch") {} - IconButton(icon = Icons.Rounded.Download, contentDescription = "Install") { - if (hasInstallationOptions) { - showInstallationOptions.value = true - } else { - showDownloadDialog.value = true - } - } + IconButton( + icon = Icons.Outlined.Info, + contentDescription = "App Info", + onClick = onInfoClick + ) + IconButton( + icon = Icons.Rounded.DeleteForever, + contentDescription = "Uninstall", + onClick = onUninstallClick + ) + IconButton( + icon = Icons.Rounded.Launch, + contentDescription = "Launch", + onClick = onLaunchClick + ) + IconButton( + icon = Icons.Rounded.Download, + contentDescription = "Install", + onClick = onDownloadClick + ) } } } \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/card/AppCard.kt b/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/card/AppCard.kt index ffc013aa..334dc1a8 100644 --- a/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/card/AppCard.kt +++ b/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/card/AppCard.kt @@ -1,14 +1,16 @@ package com.vanced.manager.ui.widgets.home.apps.card -import androidx.compose.animation.* +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.core.tween +import androidx.compose.animation.expandVertically +import androidx.compose.animation.shrinkVertically import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember +import androidx.compose.runtime.* import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp import com.google.accompanist.glide.rememberGlidePainter import com.vanced.manager.domain.model.App @@ -27,14 +29,21 @@ fun AppCard( app: App, fetching: Boolean ) { - val showDownloadDialog = remember { mutableStateOf(false) } - val showAppInfo = remember { mutableStateOf(false) } - val showInstallationOptions = remember { mutableStateOf(false) } + var showDownloadDialog by remember { mutableStateOf(false) } + var showAppInfoDialog by remember { mutableStateOf(false) } + var showInstallationOptions by remember { mutableStateOf(false) } + val icon = rememberGlidePainter( request = app.iconUrl ?: "", fadeIn = true ) - val hasInstallationOption = app.installationOptions != null + + val hasInstallationOptions = app.installationOptions != null + val animationSpec = tween(400) + + fun download() { + + } Column { ManagerThemedCard { @@ -50,23 +59,31 @@ fun AppCard( AppActionCard( appInstalledVersion = app.installedVersion, appRemoteVersion = app.remoteVersion, - showDownloadDialog = showDownloadDialog, - showAppInfo = showAppInfo, - showInstallationOptions = showInstallationOptions, - hasInstallationOptions = hasInstallationOption + onDownloadClick = { + if (hasInstallationOptions) { + showInstallationOptions = true + } else { + showDownloadDialog = true + } + }, + onInfoClick = { + showAppInfoDialog = true + }, + onLaunchClick = {}, + onUninstallClick = {} ) } } } - if (hasInstallationOption) { + if (hasInstallationOptions) { AnimatedVisibility( modifier = Modifier.fillMaxWidth(), - visible = showInstallationOptions.value, + visible = showInstallationOptions, enter = expandVertically( - animationSpec = tween(400) + animationSpec = animationSpec ), exit = shrinkVertically( - animationSpec = tween(400) + animationSpec = animationSpec ) ) { Column( @@ -81,10 +98,10 @@ fun AppCard( .padding(top = defaultContentPaddingVertical) ) { ManagerDownloadButton { - showDownloadDialog.value = true + showDownloadDialog = true } ManagerCancelButton { - showInstallationOptions.value = false + showInstallationOptions = false } } } @@ -92,19 +109,23 @@ fun AppCard( } } - if (app.name != null && app.downloader != null) { + if (app.name != null && app.downloader != null && showDownloadDialog) { AppDownloadDialog( app = app.name, downloader = app.downloader, - showDialog = showDownloadDialog + onCancelClick = { + showDownloadDialog = false + } ) } - if (app.name != null && app.changelog != null) { + if (app.name != null && app.changelog != null && showAppInfoDialog) { AppChangelogDialog( appName = app.name, changelog = app.changelog, - showDialog = showAppInfo + onDismissRequest = { + showAppInfoDialog = false + } ) } } \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/dialog/AppChangelogDialog.kt b/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/dialog/AppChangelogDialog.kt index 845a61b9..fff49047 100644 --- a/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/dialog/AppChangelogDialog.kt +++ b/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/dialog/AppChangelogDialog.kt @@ -3,36 +3,31 @@ package com.vanced.manager.ui.widgets.home.apps.dialog import androidx.compose.foundation.layout.padding import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable -import androidx.compose.runtime.MutableState import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.vanced.manager.R import com.vanced.manager.ui.components.dialog.ManagerDialog -import com.vanced.manager.ui.resources.managerString import com.vanced.manager.ui.components.text.ManagerText +import com.vanced.manager.ui.resources.managerString import com.vanced.manager.ui.widgets.button.ManagerCloseButton @Composable fun AppChangelogDialog( appName: String, changelog: String, - showDialog: MutableState + onDismissRequest: () -> Unit, ) { - if (showDialog.value) { - ManagerDialog( - title = managerString(R.string.app_info_title, appName), - onDismissRequest = { showDialog.value = false }, - buttons = { - ManagerCloseButton { - showDialog.value = false - } - } - ) { - ManagerText( - modifier = Modifier.padding(top = 4.dp), - text = changelog, - textStyle = MaterialTheme.typography.subtitle1 - ) + ManagerDialog( + title = managerString(R.string.app_info_title, appName), + onDismissRequest = onDismissRequest, + buttons = { + ManagerCloseButton(onClick = onDismissRequest) } + ) { + ManagerText( + modifier = Modifier.padding(top = 4.dp), + text = changelog, + textStyle = MaterialTheme.typography.subtitle1 + ) } } \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/dialog/AppDownloadDialog.kt b/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/dialog/AppDownloadDialog.kt index 905e9f91..e0913a6e 100644 --- a/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/dialog/AppDownloadDialog.kt +++ b/app/src/main/java/com/vanced/manager/ui/widgets/home/apps/dialog/AppDownloadDialog.kt @@ -1,53 +1,33 @@ package com.vanced.manager.ui.widgets.home.apps.dialog -import androidx.compose.runtime.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import com.vanced.manager.downloader.base.BaseDownloader import com.vanced.manager.ui.components.dialog.ManagerDialog -import com.vanced.manager.ui.widgets.home.download.AppDownloadDialogButtons +import com.vanced.manager.ui.widgets.button.ManagerCancelButton import com.vanced.manager.ui.widgets.home.download.AppDownloadDialogProgress -import kotlinx.coroutines.launch @Composable fun AppDownloadDialog( app: String, downloader: BaseDownloader, - showDialog: MutableState + onCancelClick: () -> Unit, ) { - val coroutineScope = rememberCoroutineScope() - val rememberProgress = remember { downloader.downloadProgress } val rememberFile = remember { downloader.downloadFile } val rememberInstalling = remember { downloader.installing } - val showProgress = remember { mutableStateOf(false) } - - if (showDialog.value) { - ManagerDialog( - title = app, - onDismissRequest = { showDialog.value = false }, - buttons = { - AppDownloadDialogButtons( - showProgress = showProgress, - onDownloadClick = { - coroutineScope.launch { - showProgress.value = true - downloader.download() - } - }, - onCancelClick = { - downloader.cancelDownload() - showDialog.value = false - showProgress.value = false - } - ) - } - ) { - AppDownloadDialogProgress( - progress = rememberProgress, - file = rememberFile, - showProgress = showProgress.value, - installing = rememberInstalling - ) + ManagerDialog( + title = app, + onDismissRequest = {}, + buttons = { + ManagerCancelButton(onClick = onCancelClick) } + ) { + AppDownloadDialogProgress( + progress = rememberProgress, + file = rememberFile, + installing = rememberInstalling + ) } } \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/widgets/home/download/AppDownloadDialogButtons.kt b/app/src/main/java/com/vanced/manager/ui/widgets/home/download/AppDownloadDialogButtons.kt deleted file mode 100644 index 35aa46ee..00000000 --- a/app/src/main/java/com/vanced/manager/ui/widgets/home/download/AppDownloadDialogButtons.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.vanced.manager.ui.widgets.home.download - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.MutableState -import com.vanced.manager.ui.widgets.button.ManagerCancelButton -import com.vanced.manager.ui.widgets.button.ManagerDownloadButton - -@Composable -fun AppDownloadDialogButtons( - showProgress: MutableState, - onDownloadClick: () -> Unit, - onCancelClick: () -> Unit, -) { - when (showProgress.value) { - true -> ManagerCancelButton(onClick = onCancelClick) - false -> ManagerDownloadButton(onClick = onDownloadClick) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/widgets/home/download/AppDownloadDialogProgress.kt b/app/src/main/java/com/vanced/manager/ui/widgets/home/download/AppDownloadDialogProgress.kt index 3e4b17b5..06a20870 100644 --- a/app/src/main/java/com/vanced/manager/ui/widgets/home/download/AppDownloadDialogProgress.kt +++ b/app/src/main/java/com/vanced/manager/ui/widgets/home/download/AppDownloadDialogProgress.kt @@ -2,43 +2,39 @@ package com.vanced.manager.ui.widgets.home.download import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.wrapContentWidth -import androidx.compose.material.LinearProgressIndicator import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import com.vanced.manager.ui.components.color.managerAccentColor -import com.vanced.manager.ui.preferences.holder.managerAccentColorPref +import com.vanced.manager.R +import com.vanced.manager.ui.components.progressindicator.ManagerProgressIndicator +import com.vanced.manager.ui.resources.managerString @Composable fun AppDownloadDialogProgress( progress: Float, file: String, - showProgress: Boolean, installing: Boolean ) { - if (showProgress) { - when (installing) { - true -> LinearProgressIndicator(color = managerAccentColor()) - false -> LinearProgressIndicator( - progress = progress, - color = managerAccentColor() + when (installing) { + true -> ManagerProgressIndicator() + false -> ManagerProgressIndicator(progress = progress) + } + Row { + Text( + modifier = Modifier + .weight(1f) + .wrapContentWidth(Alignment.Start), + text = managerString( + stringId = R.string.app_download_dialog_downloading_file, + file ) - } - Row { - Text( - modifier = Modifier - .weight(1f) - .wrapContentWidth(Alignment.Start), - text = "Downloading $file" - ) - Text( - modifier = Modifier - .weight(1f) - .wrapContentWidth(Alignment.End), - text = "$progress" - ) - } + ) + Text( + modifier = Modifier + .weight(1f) + .wrapContentWidth(Alignment.End), + text = "%$progress" + ) } } \ No newline at end of file diff --git a/app/src/main/java/com/vanced/manager/ui/widgets/home/installation/CheckboxInstallationOption.kt b/app/src/main/java/com/vanced/manager/ui/widgets/home/installation/CheckboxInstallationOption.kt index c2997841..34b8ec1f 100644 --- a/app/src/main/java/com/vanced/manager/ui/widgets/home/installation/CheckboxInstallationOption.kt +++ b/app/src/main/java/com/vanced/manager/ui/widgets/home/installation/CheckboxInstallationOption.kt @@ -1,10 +1,10 @@ package com.vanced.manager.ui.widgets.home.installation import androidx.annotation.StringRes -import com.vanced.manager.ui.resources.managerString import com.vanced.manager.ui.components.preference.CheckboxDialogPreference import com.vanced.manager.ui.preferences.CheckboxPreference import com.vanced.manager.ui.preferences.ManagerPreference +import com.vanced.manager.ui.resources.managerString data class CheckboxInstallationOption( @StringRes val titleId: Int, diff --git a/app/src/main/java/com/vanced/manager/ui/widgets/layout/CategoryLayout.kt b/app/src/main/java/com/vanced/manager/ui/widgets/layout/CategoryLayout.kt index b6ed6aae..e0fbb7ed 100644 --- a/app/src/main/java/com/vanced/manager/ui/widgets/layout/CategoryLayout.kt +++ b/app/src/main/java/com/vanced/manager/ui/widgets/layout/CategoryLayout.kt @@ -4,9 +4,9 @@ import androidx.compose.foundation.layout.* import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.Dp +import com.vanced.manager.ui.components.text.CategoryTitleText import com.vanced.manager.ui.utils.defaultContentPaddingHorizontal import com.vanced.manager.ui.utils.defaultContentPaddingVertical -import com.vanced.manager.ui.components.text.CategoryTitleText @Composable fun CategoryLayout( diff --git a/app/src/main/java/com/vanced/manager/ui/widgets/settings/AccentColorItem.kt b/app/src/main/java/com/vanced/manager/ui/widgets/settings/AccentColorItem.kt index 8dfc3343..c0706d1e 100644 --- a/app/src/main/java/com/vanced/manager/ui/widgets/settings/AccentColorItem.kt +++ b/app/src/main/java/com/vanced/manager/ui/widgets/settings/AccentColorItem.kt @@ -5,8 +5,8 @@ import androidx.compose.ui.graphics.Color import com.vanced.manager.R import com.vanced.manager.ui.components.color.ManagerColorPicker import com.vanced.manager.ui.components.preference.DialogPreference -import com.vanced.manager.ui.resources.managerString import com.vanced.manager.ui.preferences.holder.managerAccentColorPref +import com.vanced.manager.ui.resources.managerString import com.vanced.manager.ui.widgets.button.ManagerSaveButton @Composable