Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Nov 9, 2023
2 parents 81398e2 + 40d7e33 commit 4e40ae0
Show file tree
Hide file tree
Showing 6 changed files with 352 additions and 289 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/com/machiav3lli/backup/pages/SplashPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.machiav3lli.backup.pages

import android.annotation.SuppressLint
import android.app.Activity
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -148,6 +149,9 @@ fun LockPage(launchMain: () -> Unit) {
}
}
) {
BackHandler {
OABX.main?.finishAffinity()
}
Box(modifier = Modifier.fillMaxSize()) {}
}
}
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/java/com/machiav3lli/backup/ui/compose/extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@ import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.layout
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.unit.dp
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.machiav3lli.backup.traceFlows
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
Expand Down Expand Up @@ -60,6 +65,26 @@ fun SelectionContainerX(modifier: Modifier = Modifier, content: @Composable () -
//content()
}

@Composable
fun <T> ObservedEffect(flow: Flow<T?>, onChange: (T?) -> Unit) {
val lcOwner = LocalLifecycleOwner.current
LaunchedEffect(flow, lcOwner.lifecycle) {
lcOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
flow.collect(onChange)
}
}
}

@Composable
fun ObservedEffect(onChange: () -> Unit) {
val lcOwner = LocalLifecycleOwner.current
LaunchedEffect(lcOwner.lifecycle) {
lcOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
onChange()
}
}
}


class MutableComposableSharedFlow<T>(
var initial: T,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,9 @@ fun NavGraphBuilder.fadeComposable(
composable(it)
}
}

fun NavHostController.clearBackStack() {
while (this.currentBackStack.value.isNotEmpty()) {
popBackStack()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -166,6 +167,7 @@ fun RowScope.NavBarItem(
Row(
modifier = modifier
.padding(vertical = 8.dp)
.clip(MaterialTheme.shapes.extraLarge)
.clickable { onClick() }
.background(
background,
Expand Down
Loading

0 comments on commit 4e40ae0

Please sign in to comment.