mirror of
https://github.com/revanced/revanced-manager-compose
synced 2024-09-10 08:27:11 +02:00
feat: Dashboard Screen (#18)
* feat: add Dashboard Screen and Sources Screen * fix: fix tab onClick not working * refactor: remove AppBar --------- Co-authored-by: CnC-Robert <CnC.Rob3rt@gmail.com>
This commit is contained in:
parent
e7d1221d83
commit
d3dbe33262
4
.gitignore
vendored
4
.gitignore
vendored
@ -7,9 +7,13 @@
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
/.idea/deploymentTargetDropDown.xml
|
||||
/.idea/misc.xml
|
||||
/.idea/gradle.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
|
||||
|
6
.idea/kotlinc.xml
Normal file
6
.idea/kotlinc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.8.20" />
|
||||
</component>
|
||||
</project>
|
@ -48,9 +48,11 @@ dependencies {
|
||||
implementation("androidx.activity:activity-compose:1.7.1")
|
||||
|
||||
// Compose
|
||||
implementation(platform("androidx.compose:compose-bom:2023.04.00"))
|
||||
implementation(platform("androidx.compose:compose-bom:2023.04.01"))
|
||||
implementation("androidx.compose.ui:ui")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview")
|
||||
implementation("androidx.paging:paging-common-ktx:3.1.1")
|
||||
implementation("androidx.core:core-ktx:1.10.0")
|
||||
|
||||
// Accompanist
|
||||
val accompanistVersion = "0.30.1"
|
||||
@ -68,7 +70,7 @@ dependencies {
|
||||
|
||||
|
||||
// ReVanced
|
||||
implementation("app.revanced:revanced-patcher:6.4.3")
|
||||
implementation("app.revanced:revanced-patcher:7.0.0")
|
||||
|
||||
// Koin
|
||||
implementation("io.insert-koin:koin-android:3.4.0")
|
||||
|
@ -5,12 +5,15 @@ import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import app.revanced.manager.compose.domain.manager.PreferencesManager
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import app.revanced.manager.compose.destination.Destination
|
||||
import app.revanced.manager.compose.domain.manager.PreferencesManager
|
||||
import app.revanced.manager.compose.ui.screen.DashboardScreen
|
||||
import app.revanced.manager.compose.ui.theme.ReVancedManagerTheme
|
||||
import app.revanced.manager.compose.ui.theme.Theme
|
||||
import dev.olshevski.navigation.reimagined.*
|
||||
import dev.olshevski.navigation.reimagined.AnimatedNavHost
|
||||
import dev.olshevski.navigation.reimagined.NavBackHandler
|
||||
import dev.olshevski.navigation.reimagined.rememberNavController
|
||||
import org.koin.android.ext.android.inject
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
@ -26,7 +29,7 @@ class MainActivity : ComponentActivity() {
|
||||
darkTheme = prefs.theme == Theme.SYSTEM && isSystemInDarkTheme() || prefs.theme == Theme.DARK,
|
||||
dynamicColor = prefs.dynamicColor
|
||||
) {
|
||||
val navController = rememberNavController<Destination>(startDestination = Destination.Home)
|
||||
val navController = rememberNavController<Destination>(startDestination = Destination.Dashboard)
|
||||
|
||||
NavBackHandler(navController)
|
||||
|
||||
@ -34,7 +37,9 @@ class MainActivity : ComponentActivity() {
|
||||
controller = navController,
|
||||
) { destination ->
|
||||
when (destination) {
|
||||
Destination.Home -> {} // TODO: Add screens
|
||||
is Destination.Dashboard -> {
|
||||
DashboardScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ class ManagerApplication: Application() {
|
||||
preferencesModule,
|
||||
repositoryModule,
|
||||
serviceModule,
|
||||
viewModelModule
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ import kotlinx.parcelize.Parcelize
|
||||
sealed interface Destination: Parcelable {
|
||||
|
||||
@Parcelize
|
||||
object Home: Destination
|
||||
object Dashboard: Destination
|
||||
|
||||
} // TODO: Add screens
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package app.revanced.manager.compose.ui.screen
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.outlined.Info
|
||||
import androidx.compose.material.icons.outlined.Notifications
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FloatingActionButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Tab
|
||||
import androidx.compose.material3.TabRow
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import app.revanced.manager.compose.R
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
enum class DashboardPage(
|
||||
val titleResId: Int,
|
||||
) {
|
||||
DASHBOARD(R.string.tab_apps),
|
||||
SOURCES(R.string.tab_sources),
|
||||
}
|
||||
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun DashboardScreen() {
|
||||
val pages: Array<DashboardPage> = DashboardPage.values()
|
||||
|
||||
val pagerState = rememberPagerState()
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text("ReVanced Manager") },
|
||||
actions = {
|
||||
IconButton(onClick = {}) {
|
||||
Icon(imageVector = Icons.Outlined.Info, contentDescription = null)
|
||||
}
|
||||
IconButton(onClick = {}) {
|
||||
Icon(imageVector = Icons.Outlined.Notifications, contentDescription = null)
|
||||
}
|
||||
IconButton(onClick = {}) {
|
||||
Icon(imageVector = Icons.Outlined.Settings, contentDescription = null)
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
floatingActionButton = {
|
||||
FloatingActionButton(onClick = {}) {
|
||||
Icon(imageVector = Icons.Default.Add, contentDescription = null)
|
||||
}
|
||||
}
|
||||
) { paddingValues ->
|
||||
Column(Modifier.padding(paddingValues)) {
|
||||
TabRow(selectedTabIndex = pagerState.currentPage) {
|
||||
pages.forEachIndexed { index, page ->
|
||||
val title = stringResource(id = page.titleResId)
|
||||
Tab(
|
||||
selected = pagerState.currentPage == index,
|
||||
onClick = { coroutineScope.launch { pagerState.animateScrollToPage(index) } },
|
||||
text = { Text(text = title) },
|
||||
selectedContentColor = MaterialTheme.colorScheme.primary,
|
||||
unselectedContentColor = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalPager(
|
||||
pageCount = pages.size,
|
||||
state = pagerState,
|
||||
userScrollEnabled = true,
|
||||
contentPadding = paddingValues,
|
||||
pageContent = { index ->
|
||||
when (pages[index]) {
|
||||
DashboardPage.DASHBOARD -> {
|
||||
InstalledAppsScreen()
|
||||
}
|
||||
|
||||
DashboardPage.SOURCES -> {
|
||||
SourcesScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package app.revanced.manager.compose.ui.screen
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.sp
|
||||
import app.revanced.manager.compose.R
|
||||
|
||||
@Composable
|
||||
fun InstalledAppsScreen() {
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
Text(
|
||||
text = stringResource(R.string.no_patched_apps_found),
|
||||
fontSize = 24.sp,
|
||||
modifier = Modifier
|
||||
.align(alignment = Alignment.Center)
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package app.revanced.manager.compose.ui.screen
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.sp
|
||||
import app.revanced.manager.compose.R
|
||||
|
||||
@Composable
|
||||
fun SourcesScreen() {
|
||||
Box(Modifier.fillMaxSize()) {
|
||||
Text(
|
||||
text = stringResource(R.string.no_sources_set),
|
||||
fontSize = 24.sp,
|
||||
modifier = Modifier
|
||||
.align(alignment = Alignment.Center)
|
||||
)
|
||||
}
|
||||
}
|
@ -1,3 +1,8 @@
|
||||
<resources>
|
||||
<string name="app_name">ReVanced Manager</string>
|
||||
<string name="dashboard">Dashboard</string>
|
||||
<string name="tab_apps">Apps</string>
|
||||
<string name="tab_sources">Sources</string>
|
||||
<string name="no_sources_set">No sources set</string>
|
||||
<string name="no_patched_apps_found">No patched apps found</string>
|
||||
</resources>
|
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("com.android.application") version "7.4.2" apply false
|
||||
id("com.android.library") version "7.4.2" apply false
|
||||
id("com.android.application") version "8.0.0" apply false
|
||||
id("com.android.library") version "8.0.0" apply false
|
||||
id("org.jetbrains.kotlin.android") version "1.8.20" apply false
|
||||
}
|
||||
|
@ -20,4 +20,6 @@ kotlin.code.style=official
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
android.nonTransitiveRClass=true
|
||||
android.defaults.buildfeatures.buildconfig=true
|
||||
android.nonFinalResIds=false
|
Loading…
Reference in New Issue
Block a user