Skip to content

Commit

Permalink
Improve SettingsScreen up arrow logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MateusRodCosta committed Feb 9, 2024
1 parent 881cf58 commit a321927
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.preference.PreferenceManager
import com.mateusrodcosta.apps.share2storage.screens.SettingsScreen

class SettingsActivity : ComponentActivity() {
Expand Down Expand Up @@ -56,7 +55,7 @@ class SettingsActivity : ComponentActivity() {
updateSkipFileDetails = { value: Boolean ->
settingsViewModel.updateSkipFileDetails(value)
},
activity = this
closeActivity = { this.finish() }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package com.mateusrodcosta.apps.share2storage.screens

import android.app.Activity
import android.net.Uri
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -69,7 +68,7 @@ fun SettingsScreenPreview() {
launchFilePicker = {},
clearSaveDirectory = {},
updateSkipFileDetails = { _ -> },
activity = null,
closeActivity = {},
)
}

Expand All @@ -81,7 +80,7 @@ fun SettingsScreen(
launchFilePicker: (() -> Unit),
clearSaveDirectory: (() -> Unit),
updateSkipFileDetails: ((Boolean) -> Unit),
activity: Activity?,
closeActivity: () -> Unit,
) {
val defaultSaveLocation by spDefaultSaveLocation.collectAsState()
val skipFileDetails by spSkipFileDetails.collectAsState()
Expand All @@ -93,7 +92,7 @@ fun SettingsScreen(
TopAppBar(title = { Text(stringResource(R.string.settings)) },
colors = appTopAppBarColors(),
navigationIcon = {
IconButton(onClick = { activity?.finish() }) {
IconButton(onClick = { closeActivity() }) {
Icon(
Icons.AutoMirrored.Filled.ArrowBack,
stringResource(id = R.string.back_arrow)
Expand Down

0 comments on commit a321927

Please sign in to comment.