Rewrite App Settings in compose.

This commit is contained in:
Alex Hart
2024-10-25 16:26:46 -03:00
committed by Greyson Parrelli
parent 7f3ceea9fe
commit b979be0cb9
13 changed files with 710 additions and 486 deletions

View File

@@ -7,8 +7,10 @@ package org.thoughtcrime.securesms.banner
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.unit.dp
@@ -60,4 +62,19 @@ class BannerManager @JvmOverloads constructor(
}
}
}
/**
* Displays the current banner.
*/
@Composable
fun Banner() {
val banner by rememberUpdatedState(banners.firstOrNull { it.enabled } as Banner<Any>?)
banner?.let { nonNullBanner ->
val state by nonNullBanner.dataFlow.collectAsStateWithLifecycle(initialValue = null)
state?.let { model ->
nonNullBanner.DisplayBanner(model, PaddingValues(horizontal = 12.dp, vertical = 8.dp))
}
}
}
}