@@ -3,9 +3,24 @@ package des.c5inco.mesh.ui
33import androidx.compose.foundation.background
44import androidx.compose.foundation.gestures.detectDragGestures
55import androidx.compose.foundation.gestures.detectTapGestures
6- import androidx.compose.foundation.layout.*
6+ import androidx.compose.foundation.layout.Box
7+ import androidx.compose.foundation.layout.BoxWithConstraints
8+ import androidx.compose.foundation.layout.Spacer
9+ import androidx.compose.foundation.layout.fillMaxHeight
10+ import androidx.compose.foundation.layout.fillMaxSize
11+ import androidx.compose.foundation.layout.fillMaxWidth
12+ import androidx.compose.foundation.layout.height
13+ import androidx.compose.foundation.layout.padding
14+ import androidx.compose.foundation.layout.width
715import androidx.compose.foundation.shape.RoundedCornerShape
8- import androidx.compose.runtime.*
16+ import androidx.compose.runtime.Composable
17+ import androidx.compose.runtime.LaunchedEffect
18+ import androidx.compose.runtime.collectAsState
19+ import androidx.compose.runtime.derivedStateOf
20+ import androidx.compose.runtime.getValue
21+ import androidx.compose.runtime.mutableStateListOf
22+ import androidx.compose.runtime.mutableStateOf
23+ import androidx.compose.runtime.remember
924import androidx.compose.ui.Alignment
1025import androidx.compose.ui.Modifier
1126import androidx.compose.ui.draw.clip
@@ -51,7 +66,7 @@ fun GradientCanvas(
5166 var canvasWidth by remember { AppState ::canvasWidth }
5267 var canvasHeight by remember { AppState ::canvasHeight }
5368
54- var notificationMessage by remember { mutableStateOf <String ?>( null ) }
69+ val notifications = remember { mutableStateListOf <String >( ) }
5570
5671 val exportSize by derivedStateOf {
5772 mutableStateOf(IntSize (canvasWidth, canvasHeight))
@@ -62,7 +77,7 @@ fun GradientCanvas(
6277 LaunchedEffect (Unit ) {
6378 launch(Dispatchers .Main ) {
6479 AppState .notificationFlow.collectLatest {
65- notificationMessage = it
80+ notifications.addFirst(it)
6681 }
6782 }
6883 }
@@ -256,18 +271,18 @@ fun GradientCanvas(
256271 )
257272 }
258273
259- if (notificationMessage != null ) {
274+ notifications.reversed().forEach {
260275 CanvasSnackbar (
261276 onDismiss = {
262- notificationMessage = null
277+ notifications.removeLast()
263278 println (" dismiss" )
264279 },
265280 modifier = Modifier
266281 .padding(bottom = 16 .dp)
267282 .align(Alignment .BottomCenter )
268283 ) {
269284 Text (
270- text = notificationMessage !! ,
285+ text = it ,
271286 )
272287 }
273288 }
0 commit comments