forked from ReVanced/revanced-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add patch bundle info screen (ReVanced#55)
- Loading branch information
Showing
19 changed files
with
892 additions
and
312 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,4 +59,5 @@ fun AppTopBar( | |
containerColor = containerColor | ||
) | ||
) | ||
} | ||
} | ||
|
57 changes: 57 additions & 0 deletions
57
app/src/main/java/app/revanced/manager/ui/component/NotificationCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package app.revanced.manager.ui.component | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun NotificationCard( | ||
color: Color, | ||
icon: ImageVector, | ||
text: String, | ||
content: @Composable () -> Unit | ||
) { | ||
Card( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.clip(RoundedCornerShape(28.dp)) | ||
.background(color) | ||
) { | ||
Row( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(16.dp), | ||
verticalAlignment = Alignment.CenterVertically, | ||
horizontalArrangement = Arrangement.spacedBy( | ||
16.dp, | ||
Alignment.Start | ||
) | ||
) { | ||
Icon( | ||
imageVector = icon, | ||
contentDescription = null, | ||
) | ||
Text( | ||
modifier = Modifier.width(220.dp), | ||
text = text, | ||
style = MaterialTheme.typography.bodyMedium | ||
) | ||
content() | ||
} | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
app/src/main/java/app/revanced/manager/ui/component/SourceItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package app.revanced.manager.ui.component | ||
|
||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.res.pluralStringResource | ||
import androidx.compose.ui.unit.dp | ||
import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
import app.revanced.manager.R | ||
import app.revanced.manager.domain.sources.RemoteSource | ||
import app.revanced.manager.domain.sources.Source | ||
import app.revanced.manager.ui.component.bundle.BundleInformationDialog | ||
import app.revanced.manager.ui.viewmodel.SourcesViewModel | ||
import app.revanced.manager.util.uiSafe | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.launch | ||
|
||
@Composable | ||
fun SourceItem( | ||
source: Source, onDelete: () -> Unit, | ||
coroutineScope: CoroutineScope, | ||
) { | ||
var viewBundleDialogPage by rememberSaveable { mutableStateOf(false) } | ||
|
||
val bundle by source.bundle.collectAsStateWithLifecycle() | ||
val patchCount = bundle.patches.size | ||
val padding = PaddingValues(16.dp, 0.dp) | ||
|
||
val androidContext = LocalContext.current | ||
|
||
if (viewBundleDialogPage) { | ||
BundleInformationDialog( | ||
onDismissRequest = { viewBundleDialogPage = false }, | ||
onDeleteRequest = { | ||
viewBundleDialogPage = false | ||
onDelete() | ||
}, | ||
source = source, | ||
patchCount = patchCount, | ||
onRefreshButton = { | ||
coroutineScope.launch { | ||
uiSafe( | ||
androidContext, | ||
R.string.source_download_fail, | ||
SourcesViewModel.failLogMsg | ||
) { | ||
if (source is RemoteSource) source.update() | ||
} | ||
} | ||
}, | ||
) | ||
} | ||
|
||
Row( | ||
verticalAlignment = Alignment.CenterVertically, | ||
modifier = Modifier | ||
.height(64.dp) | ||
.fillMaxWidth() | ||
.clickable { | ||
viewBundleDialogPage = true | ||
} | ||
) { | ||
Text( | ||
text = source.name, | ||
style = MaterialTheme.typography.bodyLarge, | ||
color = MaterialTheme.colorScheme.onSurface, | ||
modifier = Modifier.padding(padding) | ||
) | ||
|
||
Spacer( | ||
modifier = Modifier.weight(1f) | ||
) | ||
|
||
Text( | ||
text = pluralStringResource(R.plurals.patches_count, patchCount, patchCount), | ||
style = MaterialTheme.typography.labelSmall, | ||
color = MaterialTheme.colorScheme.onSurfaceVariant, | ||
modifier = Modifier.padding(padding) | ||
) | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
app/src/main/java/app/revanced/manager/ui/component/bundle/BundleInfoContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package app.revanced.manager.ui.component.bundle | ||
|
||
import androidx.compose.foundation.layout.RowScope | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.ArrowRight | ||
import androidx.compose.material3.FilledTonalButton | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Switch | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import app.revanced.manager.R | ||
|
||
@Composable | ||
fun BundleInfoContent( | ||
switchChecked: Boolean, | ||
onCheckedChange: (Boolean) -> Unit, | ||
patchInfoText: String, | ||
patchCount: Int, | ||
onArrowClick: () -> Unit, | ||
isLocal: Boolean, | ||
tonalButtonOnClick: () -> Unit = {}, | ||
tonalButtonContent: @Composable RowScope.() -> Unit, | ||
) { | ||
if(!isLocal) { | ||
BundleInfoListItem( | ||
headlineText = stringResource(R.string.automatically_update), | ||
supportingText = stringResource(R.string.automatically_update_description), | ||
trailingContent = { | ||
Switch( | ||
checked = switchChecked, | ||
onCheckedChange = onCheckedChange | ||
) | ||
} | ||
) | ||
} | ||
|
||
BundleInfoListItem( | ||
headlineText = stringResource(R.string.bundle_type), | ||
supportingText = stringResource(R.string.bundle_type_description) | ||
) { | ||
FilledTonalButton( | ||
onClick = tonalButtonOnClick, | ||
content = tonalButtonContent, | ||
) | ||
} | ||
|
||
Text( | ||
text = stringResource(R.string.information), | ||
modifier = Modifier.padding( | ||
horizontal = 16.dp, | ||
vertical = 12.dp | ||
), | ||
style = MaterialTheme.typography.labelLarge, | ||
color = MaterialTheme.colorScheme.primary, | ||
) | ||
|
||
BundleInfoListItem( | ||
headlineText = stringResource(R.string.patches), | ||
supportingText = patchInfoText, | ||
trailingContent = { | ||
if (patchCount > 0) { | ||
IconButton(onClick = onArrowClick) { | ||
Icon( | ||
Icons.Outlined.ArrowRight, | ||
stringResource(R.string.patches) | ||
) | ||
} | ||
} | ||
} | ||
) | ||
|
||
BundleInfoListItem( | ||
headlineText = stringResource(R.string.patches_version), | ||
supportingText = "1.0.0", | ||
) | ||
|
||
BundleInfoListItem( | ||
headlineText = stringResource(R.string.integrations_version), | ||
supportingText = "1.0.0", | ||
) | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/app/revanced/manager/ui/component/bundle/BundleInfoListItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package app.revanced.manager.ui.component.bundle | ||
|
||
import androidx.compose.material3.ListItem | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
fun BundleInfoListItem( | ||
headlineText: String, | ||
supportingText: String = "", | ||
trailingContent: @Composable (() -> Unit)? = null, | ||
) { | ||
ListItem( | ||
headlineContent = { | ||
Text( | ||
text = headlineText, | ||
style = MaterialTheme.typography.titleLarge | ||
) | ||
}, | ||
supportingContent = { | ||
Text( | ||
text = supportingText, | ||
style = MaterialTheme.typography.bodyMedium, | ||
color = MaterialTheme.colorScheme.outline | ||
) | ||
}, | ||
trailingContent = trailingContent, | ||
) | ||
} |
Oops, something went wrong.