Colton Idle
08/27/2022, 4:58 AMzt
08/27/2022, 6:52 AMRafs
08/27/2022, 8:01 AMRafs
08/27/2022, 9:31 AMIllegalStateException
. The android view is a TextureView
that i’m using for a webRTC call so I don’t want to restart the whole calling process on config changes. I’m handling configChanges manually as follows
android:configChanges="orientation|smallestScreenSize|screenSize|screenLayout"
And reusing the Surface as follows ()
val context = LocalContext.current
val surface = remember {
MyTexture(context)
}
LaunchedEffect(Unit){
// some legacy webrtc code which initialises call and sends frames to the texture view
callController.initialise(surface)
}
AndroidView(factory = {surface})
The error message says Pending composition has not been applied
initialising the view in the factory method prevents this exception from getting thrown, but that will mean re-building a new call whenever the user rotates their device. I have 2 options now, re-architect a legacy app to work properly in this situation by removing the dependency on the TextureView
during call initialisation or find a way to workaround this problem. I’m currently leaning towards the latter. Posting StackTrace in thread…Arjun Achatz
08/27/2022, 2:41 PModay
08/27/2022, 9:18 PM@AndroidEntryPoint
class MainActivity : ComponentActivity() {
@Inject
lateinit var prefs: SharedPreferences
private val viewModel: MainViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
lifecycleScope.launch {
viewModel.state.collect { uiState ->
when (uiState) {
is MainViewModel.MainState.Loading -> {
Log.d("MainState", "Loading...")
}
is MainViewModel.MainState.Success -> {
setContent {
uiState.user?.let { Home(user = it) }
}
}
is MainViewModel.MainState.Error -> {
setContent {
Authentication()
}
}
}
}
}
}
}
AmrJyniat
08/28/2022, 10:08 AMconstraintSet
and createRefs()
.
Are there any tips about when should I use which and why?Jasmin Fajkic
08/28/2022, 3:43 PMTrevor Hackman
08/28/2022, 5:25 PMephemient
08/29/2022, 1:44 AMAlex
08/29/2022, 6:51 AMBox {
Box {
Composable1() <-- render this "on top of" (higher zIndex) Composable2
}
Composable2()
}
deviant
08/29/2022, 1:08 PMpointerInput
modifier doesn't work with Button
. how can i detect on released
event on a button?Gal Kohen
08/29/2022, 1:10 PMJosh Pollock
08/29/2022, 1:52 PMjossiwolf
08/29/2022, 2:57 PMthresholds
to define custom thresholds based on the origin and/or target?
For example:
Box(Modifier.swipeable(thresholds = { from, to -> if (from == A) FixedThreshold(56.dp) else FractionalThreshold(0.5f) }))
Stylianos Gakis
08/29/2022, 3:10 PMLoney Chou
08/29/2022, 4:04 PMLukasz Kalnik
08/29/2022, 5:12 PMStateFlow
from the ViewModel which contains a boolean property showBottomSheet
.
In my screen's composable, I can then remember (and reinitialize) the bottom sheet state like this:
val modalBottomSheetState = rememberModalBottomSheetState(if (screenState.showBottomSheet) Expanded else Hidden)
That takes care of hiding the bottom sheet.
But how do I keep the showBottomSheet
state in the ViewModel synchronized with the composable, when e.g. the user swipes down the bottom sheet? For this I included a callback in the composable: onBottomSheetDismissed
.
I called this callback in the confirmStateChange
lambda parameter of `rememberModalBottomSheetState()`:
// Composable
val modalBottomSheetState = rememberModalBottomSheetState(
initialValue = if (screenState.showBottomSheet) Expanded else Hidden,
confirmStateChange = {
onBottomSheetDismissed()
true
}
)
// ViewModel
val screenState: StateFlow<ScreenState> = _screenState.asStateFlow()
private val _screenState: MutableStateFlow<ScreenState>
fun onBottomSheetDismissed() {
_screenState.update { it.copy(showBottomSheet = false) }
}
But it appears that this callback is called very early in the dragging process, and my showBottomSheet
variable in the ViewModel gets reset to false
as soon as the user even drags the bottom sheet one pixel down and the bottom sheet immediately disappears (see video in thread)
Is there a better way to handle opening/closing the bottom sheet from a viewmodel and keeping the state synchronized between the two?Paul Woitaschek
08/29/2022, 6:07 PMLucas Mo
08/29/2022, 6:10 PMFontFamily.Default
), but when I change the system's font, it is not updated until I clear the app's data.
Is there any way to "force" it to update?Landry Norris
08/29/2022, 7:48 PMRadoslaw Juszczyk
08/29/2022, 8:13 PMModifier.scale(0.5f)
?adjpd
08/29/2022, 8:20 PMKotlinLeaner
08/29/2022, 8:25 PMJaime
08/30/2022, 12:38 AMLisandro Di Meo
08/30/2022, 1:25 AMKyant
08/30/2022, 4:33 AMdynamicColorScheme()
, and set it to MaterialTheme
. (Don't forget to provide LocalTonalPalettes
first.)
You can also get a dynamic color by using 40.a1 withNight 80.a1
(100 means white, 0 means black), this is very brief.
There's a demo you can play with.Cristina Uroz
08/30/2022, 9:02 AMMustafa İsmail Alkan
08/30/2022, 10:13 AModay
08/30/2022, 11:01 AModay
08/30/2022, 11:01 AM