-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refresh log on resume to display newly created, deleted or modified e…
…ntries
- Loading branch information
1 parent
bfb6a47
commit 07b4abe
Showing
7 changed files
with
59 additions
and
1 deletion.
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
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
23 changes: 23 additions & 0 deletions
23
shared/src/androidMain/kotlin/com/faltenreich/diaguard/shared/view/LifecycleExtensions.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 com.faltenreich.diaguard.shared.view | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.platform.LocalLifecycleOwner | ||
import androidx.lifecycle.Lifecycle | ||
|
||
@Composable | ||
actual fun rememberLifecycleState(): LifecycleState { | ||
val state by LocalLifecycleOwner.current.lifecycle.currentStateFlow.collectAsState() | ||
return state.toDomain() | ||
} | ||
|
||
private fun Lifecycle.State.toDomain(): LifecycleState { | ||
return when (this) { | ||
Lifecycle.State.DESTROYED -> LifecycleState.DESTROYED | ||
Lifecycle.State.INITIALIZED -> LifecycleState.INITIALIZED | ||
Lifecycle.State.CREATED -> LifecycleState.CREATED | ||
Lifecycle.State.STARTED -> LifecycleState.STARTED | ||
Lifecycle.State.RESUMED -> LifecycleState.RESUMED | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
shared/src/commonMain/kotlin/com/faltenreich/diaguard/shared/view/LifecycleExtensions.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,6 @@ | ||
package com.faltenreich.diaguard.shared.view | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
expect fun rememberLifecycleState(): LifecycleState |
9 changes: 9 additions & 0 deletions
9
shared/src/commonMain/kotlin/com/faltenreich/diaguard/shared/view/LifecycleState.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,9 @@ | ||
package com.faltenreich.diaguard.shared.view | ||
|
||
enum class LifecycleState { | ||
DESTROYED, | ||
INITIALIZED, | ||
CREATED, | ||
STARTED, | ||
RESUMED, | ||
} |
8 changes: 8 additions & 0 deletions
8
shared/src/iosMain/kotlin/com/faltenreich/diaguard/shared/view/LifecycleExtensions.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,8 @@ | ||
package com.faltenreich.diaguard.shared.view | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
actual fun rememberLifecycleState(): LifecycleState { | ||
TODO("Not yet implemented") | ||
} |