mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2026-01-20 09:43:58 +00: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:
@@ -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)
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user