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: Dashboard Screen (ReVanced#18)
* feat: add Dashboard Screen and Sources Screen * fix: fix tab onClick not working * refactor: remove AppBar --------- Co-authored-by: CnC-Robert <[email protected]>
- Loading branch information
1 parent
cb0150a
commit 9065c0d
Showing
12 changed files
with
183 additions
and
12 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
102 changes: 102 additions & 0 deletions
102
app/src/main/java/app/revanced/manager/compose/ui/screen/DashboardScreen.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,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() | ||
} | ||
} | ||
} | ||
) | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/app/revanced/manager/compose/ui/screen/InstalledAppsScreen.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,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) | ||
) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/app/revanced/manager/compose/ui/screen/SourcesScreen.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,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) | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -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> |
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 |
---|---|---|
@@ -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 | ||
} |
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