|
1 | 1 | package com.jetpackduba.gitnuro.ui |
2 | 2 |
|
3 | | -import androidx.compose.animation.* |
| 3 | +import androidx.compose.animation.Crossfade |
4 | 4 | import androidx.compose.foundation.background |
5 | | -import androidx.compose.foundation.layout.Box |
6 | | -import androidx.compose.foundation.layout.Column |
7 | | -import androidx.compose.foundation.layout.fillMaxSize |
8 | | -import androidx.compose.foundation.layout.padding |
| 5 | +import androidx.compose.foundation.layout.* |
9 | 6 | import androidx.compose.foundation.shape.RoundedCornerShape |
10 | 7 | import androidx.compose.material.MaterialTheme |
11 | 8 | import androidx.compose.material.Text |
@@ -36,20 +33,15 @@ fun AppTab( |
36 | 33 | val errorManager = tabViewModel.errorsManager |
37 | 34 | val lastError by errorManager.error.collectAsState(null) |
38 | 35 | val showError by tabViewModel.showError.collectAsState() |
39 | | - val notification = errorManager.notification.collectAsState().value |
40 | | - var visibleNotification by remember { mutableStateOf("") } |
41 | | -// val (tabPosition, setTabPosition) = remember { mutableStateOf<LayoutCoordinates?>(null) } |
| 36 | + val notifications = errorManager.notification.collectAsState().value |
| 37 | + .toList() |
| 38 | + .sortedBy { it.first } |
| 39 | + .map { it.second } |
42 | 40 |
|
43 | 41 | val repositorySelectionStatus = tabViewModel.repositorySelectionStatus.collectAsState() |
44 | 42 | val repositorySelectionStatusValue = repositorySelectionStatus.value |
45 | 43 | val processingState = tabViewModel.processing.collectAsState().value |
46 | 44 |
|
47 | | - LaunchedEffect(notification) { |
48 | | - if (notification != null) { |
49 | | - visibleNotification = notification |
50 | | - } |
51 | | - } |
52 | | - |
53 | 45 | LaunchedEffect(tabViewModel) { |
54 | 46 | // Init the tab content when the tab is selected and also remove the "initialPath" to avoid opening the |
55 | 47 | // repository everytime the user changes between tabs |
@@ -135,22 +127,24 @@ fun AppTab( |
135 | 127 | ) |
136 | 128 | } |
137 | 129 |
|
138 | | - AnimatedVisibility( |
139 | | - visible = notification != null, |
140 | | - modifier = Modifier.align(Alignment.BottomCenter), |
141 | | - enter = fadeIn() + slideInVertically { it * 2 }, |
142 | | - exit = fadeOut() + slideOutVertically { it * 2 }, |
| 130 | + Column( |
| 131 | + modifier = Modifier |
| 132 | + .fillMaxWidth() |
| 133 | + .align(Alignment.BottomCenter) |
| 134 | + .padding(bottom = 48.dp), |
| 135 | + horizontalAlignment = Alignment.CenterHorizontally, |
143 | 136 | ) { |
144 | | - Text( |
145 | | - text = visibleNotification, |
146 | | - modifier = Modifier |
147 | | - .padding(bottom = 48.dp) |
148 | | - .clip(RoundedCornerShape(8.dp)) |
149 | | - .background(MaterialTheme.colors.primary) |
150 | | - .padding(8.dp), |
151 | | - color = MaterialTheme.colors.onPrimary, |
152 | | - style = MaterialTheme.typography.body1, |
153 | | - ) |
| 137 | + for (notification in notifications) |
| 138 | + Text( |
| 139 | + text = notification, |
| 140 | + modifier = Modifier |
| 141 | + .padding(bottom = 12.dp) |
| 142 | + .clip(RoundedCornerShape(8.dp)) |
| 143 | + .background(MaterialTheme.colors.primary) |
| 144 | + .padding(8.dp), |
| 145 | + color = MaterialTheme.colors.onPrimary, |
| 146 | + style = MaterialTheme.typography.body1, |
| 147 | + ) |
154 | 148 | } |
155 | 149 | } |
156 | 150 | } |
|
0 commit comments