Skip to content

Commit

Permalink
some minor refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
yamin8000 committed Feb 9, 2024
1 parent aab4958 commit 116a95c
Show file tree
Hide file tree
Showing 17 changed files with 380 additions and 446 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/dependency-submission.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Dependency Submission

on: [ push ]

permissions:
contents: write

jobs:
dependency-submission:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v3
88 changes: 46 additions & 42 deletions app/src/main/java/io/github/yamin8000/dooz/content/About.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,60 +49,64 @@ import io.github.yamin8000.dooz.ui.composables.ScaffoldWithTitle

@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun AboutContent(onBackClick: () -> Unit) {
internal fun AboutContent(
onBackClick: () -> Unit
) {
ScaffoldWithTitle(
title = stringResource(R.string.about),
onBackClick = onBackClick,
content = {
Surface(
modifier = Modifier.fillMaxSize()
) {
Column(
verticalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.verticalScroll(rememberScrollState())
) {
val uriHandler = LocalUriHandler.current
val sourceUri = stringResource(R.string.github_source)
val licenseUri = stringResource(R.string.license_link)
val developerUri = stringResource(R.string.developer_uri)
Ripple(
onClick = { uriHandler.openUri(licenseUri) },
modifier = Modifier.fillMaxSize(),
content = {
Column(
verticalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.verticalScroll(rememberScrollState()),
content = {
Image(
painter = painterResource(id = R.drawable.ic_gplv3),
contentDescription = stringResource(id = R.string.gplv3_image_description),
modifier = Modifier
.padding(32.dp)
.fillMaxWidth(),
contentScale = ContentScale.FillWidth,
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface)
val uriHandler = LocalUriHandler.current
val sourceUri = stringResource(R.string.github_source)
val licenseUri = stringResource(R.string.license_link)
val developerUri = stringResource(R.string.developer_uri)
Ripple(
onClick = { uriHandler.openUri(licenseUri) },
content = {
Image(
painter = painterResource(id = R.drawable.ic_gplv3),
contentDescription = stringResource(id = R.string.gplv3_image_description),
modifier = Modifier
.padding(32.dp)
.fillMaxWidth(),
contentScale = ContentScale.FillWidth,
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface)
)
}
)
}
)
PersianText(
text = stringResource(R.string.license_header),
modifier = Modifier.fillMaxWidth()
)
Ripple(
onClick = { uriHandler.openUri(sourceUri) },
content = {
Text(
text = sourceUri,
textDecoration = TextDecoration.Underline
PersianText(
text = stringResource(R.string.license_header),
modifier = Modifier.fillMaxWidth()
)
}
)
Ripple(
onClick = { uriHandler.openUri(developerUri) },
content = {
Text(
text = developerUri,
textDecoration = TextDecoration.Underline
Ripple(
onClick = { uriHandler.openUri(sourceUri) },
content = {
Text(
text = sourceUri,
textDecoration = TextDecoration.Underline
)
}
)
Ripple(
onClick = { uriHandler.openUri(developerUri) },
content = {
Text(
text = developerUri,
textDecoration = TextDecoration.Underline
)
}
)
}
)
}
}
)
}
)
}
4 changes: 2 additions & 2 deletions app/src/main/java/io/github/yamin8000/dooz/content/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.preferencesDataStore

val Context.settings: DataStore<Preferences> by preferencesDataStore(name = "settings")
internal val Context.settings: DataStore<Preferences> by preferencesDataStore(name = "settings")

class App : Application()
internal class App : Application()
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.core.view.WindowCompat

class MainActivity : ComponentActivity() {

internal class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent { MainNavigation() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import io.github.yamin8000.dooz.util.Constants
import io.github.yamin8000.dooz.util.DataStoreHelper

@Composable
fun MainNavigation() {
internal fun MainNavigation() {
val context = LocalContext.current
var theme by remember { mutableStateOf(ThemeSetting.System) }
val dataStore = DataStoreHelper(context.settings)
Expand All @@ -55,41 +55,42 @@ fun MainNavigation() {
}
DoozTheme(
isDarkTheme = isDarkTheme(theme, isSystemInDarkTheme()),
isDynamicColor = theme == ThemeSetting.System
) {
Column {
val navController = rememberNavController()
NavHost(
modifier = Modifier.weight(1f),
navController = navController,
startDestination = Nav.Routes.game
) {
composable(Nav.Routes.game) {
GameContent(
onNavigateToSettings = { navController.navigate(Nav.Routes.settings) },
onNavigateToAbout = { navController.navigate(Nav.Routes.about) }
)
}
isDynamicColor = theme == ThemeSetting.System,
content = {
Column {
val navController = rememberNavController()
NavHost(
modifier = Modifier.weight(1f),
navController = navController,
startDestination = Nav.Routes.game,
builder = {
composable(Nav.Routes.game) {
GameContent(
onNavigateToSettings = { navController.navigate(Nav.Routes.settings) },
onNavigateToAbout = { navController.navigate(Nav.Routes.about) }
)
}

composable(Nav.Routes.settings) {
SettingsContent(
onThemeChanged = { newTheme -> theme = newTheme },
onBackClick = { navController.popBackStack() }
)
}
composable(Nav.Routes.settings) {
SettingsContent(
onThemeChanged = { newTheme -> theme = newTheme },
onBackClick = { navController.popBackStack() }
)
}

composable(Nav.Routes.about) { AboutContent(onBackClick = { navController.popBackStack() }) }
composable(Nav.Routes.about) { AboutContent(onBackClick = { navController.popBackStack() }) }
}
)
}
}
}
)
}

private fun isDarkTheme(
themeSetting: ThemeSetting,
isSystemInDarkTheme: Boolean
): Boolean {
if (themeSetting == ThemeSetting.Light) return false
if (themeSetting == ThemeSetting.System) return isSystemInDarkTheme
if (themeSetting == ThemeSetting.Dark) return true
return false
) = when (themeSetting) {
ThemeSetting.Light -> false
ThemeSetting.System -> isSystemInDarkTheme
else -> themeSetting == ThemeSetting.Dark
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import io.github.yamin8000.dooz.ui.composables.PersianText

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MainTopAppBar(
internal fun MainTopAppBar(
scrollBehavior: TopAppBarScrollBehavior,
onSettingsIconClick: () -> Unit,
onAboutIconClick: () -> Unit
Expand All @@ -72,7 +72,7 @@ fun MainTopAppBar(
}

@Composable
fun AboutIcon(
private fun AboutIcon(
onAboutIconClick: () -> Unit
) {
ClickableIcon(
Expand Down
Loading

0 comments on commit 116a95c

Please sign in to comment.