-
-
Notifications
You must be signed in to change notification settings - Fork 778
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Separate bundle list screen code from dashboard
- Loading branch information
1 parent
9305a7b
commit eac6ce9
Showing
2 changed files
with
68 additions
and
38 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
app/src/main/java/app/revanced/manager/ui/screen/BundleListScreen.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.screen | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.lazy.items | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.snapshots.SnapshotStateList | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import app.revanced.manager.domain.bundles.PatchBundleSource | ||
import app.revanced.manager.ui.component.LazyColumnWithScrollbar | ||
import app.revanced.manager.ui.component.bundle.BundleItem | ||
|
||
@Composable | ||
fun BundleListScreen( | ||
onDelete: (PatchBundleSource) -> Unit, | ||
onUpdate: (PatchBundleSource) -> Unit, | ||
sources: List<PatchBundleSource>, | ||
selectedSources: SnapshotStateList<PatchBundleSource>, | ||
bundlesSelectable: Boolean = false, | ||
) { | ||
Column { | ||
LazyColumnWithScrollbar( | ||
modifier = Modifier.fillMaxSize(), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
verticalArrangement = Arrangement.Top, | ||
) { | ||
items( | ||
sources, | ||
key = { it.uid } | ||
) { source -> | ||
BundleItem( | ||
bundle = source, | ||
onDelete = { | ||
onDelete(source) | ||
}, | ||
onUpdate = { | ||
onUpdate(source) | ||
}, | ||
selectable = bundlesSelectable, | ||
onSelect = { | ||
selectedSources.add(source) | ||
}, | ||
isBundleSelected = selectedSources.contains(source), | ||
toggleSelection = { bundleIsNotSelected -> | ||
if (bundleIsNotSelected) { | ||
selectedSources.add(source) | ||
} else { | ||
selectedSources.remove(source) | ||
} | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} |
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