Skip to content

Commit

Permalink
🐛 Fix back nav icon not visible in preferences (#15)
Browse files Browse the repository at this point in the history
* 🐛 Fix back nav icon not visible in preferences

* 📝 Update CHANGELOG
  • Loading branch information
svenjacobs authored Jun 6, 2021
1 parent 8880825 commit 550bab0
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Version 0.4.1

_2021-06-06_

- Fix back navigation icon not visible in preferences

## Version 0.4.0

_2021-06-03_
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ android {
applicationId = "com.svenjacobs.app.leon"
minSdk = 21
targetSdk = 30
versionCode = 224
versionName = "0.4.0"
versionCode = 225
versionName = "0.4.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
Expand All @@ -37,6 +39,8 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavController
import androidx.navigation.NavDestination.Companion.hierarchy
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
Expand Down Expand Up @@ -74,7 +78,7 @@ fun MainScreen(
Screen.Settings
)

var isBackVisible by remember { mutableStateOf(false) }
val isBackVisible by viewModel.isBackVisible.collectAsState()

AppTheme {
Scaffold(
Expand All @@ -88,18 +92,20 @@ fun MainScreen(
bottomBar = {
BottomNavigation {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute =
navBackStackEntry?.destination?.route ?: Screen.Home.route
val currentDestination = navBackStackEntry?.destination

bottomNavItems.forEach { screen ->
BottomNavigationItem(
icon = { Icon(screen.icon, contentDescription = null) },
label = { Text(stringResource(screen.resourceId)) },
selected = currentRoute == screen.route,
selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true,
onClick = {
navController.navigate(screen.route) {
popUpTo(navController.graph.startDestinationId)
popUpTo(navController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
},
)
Expand All @@ -122,7 +128,7 @@ fun MainScreen(
startDestination = Screen.Home.route,
) {
composable(Screen.Home.route) {
isBackVisible = false
viewModel.setIsBackVisible(false)
HomeScreen(
result = result,
onShareButtonClick = ::onShareButtonClick,
Expand All @@ -131,15 +137,15 @@ fun MainScreen(
}

composable(Screen.Settings.route) { navBackStackEntry ->
isBackVisible = false
viewModel.setIsBackVisible(false)
SettingsScreen(
viewModel = navViewModel(navBackStackEntry),
navController = navController,
)
}

composable(Screen.SettingsParameters.route) { navBackStackEntry ->
isBackVisible = true
viewModel.setIsBackVisible(true)
SettingsParametersScreen(
viewModel = navViewModel(navBackStackEntry),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class MainViewModel @Inject constructor(
private val _result = MutableStateFlow<CleaningResult>(CleaningResult.Failure)
val result = _result.asStateFlow()

private val _isBackVisible = MutableStateFlow(false)
val isBackVisible = _isBackVisible.asStateFlow()

fun setText(text: String?) {
if (text == null && result.value is CleaningResult.Success) return

Expand All @@ -50,6 +53,10 @@ class MainViewModel @Inject constructor(
}
}

fun setIsBackVisible(isBackVisible: Boolean) {
_isBackVisible.value = isBackVisible
}

fun buildIntent(text: String): Intent {
val target = Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/play/release-notes/de-DE/default.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Facebook-Parameter hinzugefügt
Bugfixes
2 changes: 1 addition & 1 deletion app/src/main/play/release-notes/en-US/default.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Add Facebook query parameters
Bugfixes

0 comments on commit 550bab0

Please sign in to comment.