@@ -7,22 +7,27 @@ import androidx.compose.foundation.layout.*
7
7
import androidx.compose.foundation.rememberScrollState
8
8
import androidx.compose.foundation.verticalScroll
9
9
import androidx.compose.material.icons.Icons
10
- import androidx.compose.material.icons.rounded.ArrowBack
10
+ import androidx.compose.material.icons.outlined.BreakfastDining
11
+ import androidx.compose.material.icons.rounded.BreakfastDining
11
12
import androidx.compose.material.icons.rounded.Edit
12
13
import androidx.compose.material.icons.rounded.Newspaper
13
14
import androidx.compose.material3.*
14
15
import androidx.compose.runtime.*
16
+ import androidx.compose.runtime.saveable.rememberSaveable
15
17
import androidx.compose.ui.Modifier
18
+ import androidx.compose.ui.draw.alpha
19
+ import androidx.compose.ui.graphics.vector.ImageVector
16
20
import androidx.compose.ui.res.stringResource
17
21
import androidx.compose.ui.text.font.FontWeight
18
22
import androidx.compose.ui.unit.dp
19
23
import com.google.accompanist.flowlayout.FlowCrossAxisAlignment
20
24
import com.google.accompanist.flowlayout.FlowMainAxisAlignment
21
25
import com.google.accompanist.flowlayout.FlowRow
22
26
import ru.tech.cookhelper.R
27
+ import ru.tech.cookhelper.core.constants.Constants.LOREM_IPSUM
23
28
import ru.tech.cookhelper.domain.model.Product
24
29
import ru.tech.cookhelper.domain.model.User
25
- import ru.tech.cookhelper.presentation.app.components.UserState
30
+ import ru.tech.cookhelper.presentation.app.components.*
26
31
import ru.tech.cookhelper.presentation.chat.components.MessageBubbleItem
27
32
import ru.tech.cookhelper.presentation.chat.components.MessageHeader
28
33
import ru.tech.cookhelper.presentation.chat.formatOrNull
@@ -33,15 +38,20 @@ import ru.tech.cookhelper.presentation.recipe_post_creation.components.Expandabl
33
38
import ru.tech.cookhelper.presentation.recipe_post_creation.components.FabSize
34
39
import ru.tech.cookhelper.presentation.recipe_post_creation.components.Separator
35
40
import ru.tech.cookhelper.presentation.ui.theme.SquircleShape
41
+ import ru.tech.cookhelper.presentation.ui.theme.invoke
42
+ import ru.tech.cookhelper.presentation.ui.utils.compose.show
36
43
import ru.tech.cookhelper.presentation.ui.utils.navigation.Screen
44
+ import ru.tech.cookhelper.presentation.ui.utils.provider.LocalToastHostState
37
45
import ru.tech.cookhelper.presentation.ui.widgets.AppBarTitle
38
46
import ru.tech.cookhelper.presentation.ui.widgets.TopAppBar
39
47
import ru.tech.cookhelper.presentation.ui.widgets.TopAppBarSize
40
48
41
49
@OptIn(ExperimentalMaterial3Api ::class , ExperimentalAnimationApi ::class )
42
50
@Composable
43
51
fun ColorSchemePreview () {
44
- var selectedItem by remember { mutableStateOf<Screen >(Screen .Buttons ) }
52
+ var selectedItem by rememberSaveable { mutableStateOf<Screen >(Screen .Buttons ) }
53
+ val toastHost = LocalToastHostState .current
54
+ var showSampleDialog by rememberSaveable { mutableStateOf(false ) }
45
55
46
56
OutlinedCard (
47
57
modifier = Modifier
@@ -65,16 +75,19 @@ fun ColorSchemePreview() {
65
75
},
66
76
topAppBarSize = TopAppBarSize .Centered ,
67
77
navigationIcon = {
68
- IconButton (onClick = {}) {
69
- Icon (Icons .Rounded .ArrowBack , null )
70
- }
78
+ val testMessage = stringResource(R .string.toast_preview)
79
+ Icons .Rounded .BreakfastDining (
80
+ onClick = {
81
+ toastHost.show(Icons .Outlined .BreakfastDining , testMessage)
82
+ }
83
+ )
71
84
},
72
85
windowInsets = WindowInsets (0 .dp),
73
86
background = MaterialTheme .colorScheme.surfaceColorAtElevation(3 .dp),
74
87
actions = {
75
- IconButton (onClick = {}) {
76
- Icon ( Icons . Rounded . Newspaper , null )
77
- }
88
+ Icons . Rounded . Newspaper (
89
+ onClick = { showSampleDialog = true }
90
+ )
78
91
}
79
92
)
80
93
AnimatedContent (selectedItem) {
@@ -99,6 +112,20 @@ fun ColorSchemePreview() {
99
112
windowInsets = WindowInsets (0 .dp),
100
113
onClick = { selectedItem = it })
101
114
}
115
+
116
+ if (showSampleDialog) {
117
+ AlertDialog (
118
+ onDismissRequest = { showSampleDialog = false },
119
+ icon = { Icons .Rounded .Newspaper () },
120
+ confirmButton = {
121
+ TextButton (onClick = { showSampleDialog = false }) {
122
+ Text (stringResource(R .string.ok))
123
+ }
124
+ },
125
+ title = { Text (stringResource(R .string.preview)) },
126
+ text = { Text (LOREM_IPSUM ) }
127
+ )
128
+ }
102
129
}
103
130
104
131
@Composable
@@ -111,7 +138,7 @@ private fun FridgeBlock() {
111
138
}
112
139
Column (
113
140
Modifier
114
- .height(400 .dp)
141
+ .height(300 .dp)
115
142
.verticalScroll(rememberScrollState())
116
143
) {
117
144
Spacer (Modifier .height(8 .dp))
@@ -157,15 +184,15 @@ private fun ChatBlock() {
157
184
Spacer (Modifier .height(4 .dp))
158
185
MessageBubbleItem (
159
186
isMessageFromCurrentUser = true ,
160
- text = stringResource(R .string.hello_world_preview ),
187
+ text = stringResource(R .string.what_we_are_cooking_answer_preview ),
161
188
timestamp = System .currentTimeMillis(),
162
189
cutTopCorner = true ,
163
190
showPointingArrow = true
164
191
)
165
192
Spacer (Modifier .height(4 .dp))
166
193
MessageBubbleItem (
167
194
isMessageFromCurrentUser = false ,
168
- text = stringResource(R .string.hello_world_answer_preview ),
195
+ text = stringResource(R .string.yummy_preview ),
169
196
timestamp = System .currentTimeMillis(),
170
197
cutTopCorner = true ,
171
198
showPointingArrow = true
@@ -249,4 +276,77 @@ private fun ProfileBlock() {
249
276
onStatusUpdate = {}
250
277
)
251
278
Spacer (Modifier .height(8 .dp))
279
+ Divider ()
280
+ Spacer (Modifier .width(8 .dp))
281
+ Row {
282
+ val testMessage = stringResource(R .string.toast_preview)
283
+ Spacer (
284
+ Modifier
285
+ .weight(1f )
286
+ .padding(start = 8 .dp)
287
+ )
288
+ Toast (
289
+ modifier = Modifier
290
+ .heightIn(min = 48 .dp)
291
+ .padding(top = 8 .dp)
292
+ .alpha(0.95f ),
293
+ toastData = object : ToastData {
294
+ override val visuals: ToastVisuals
295
+ get() = object : ToastVisuals {
296
+ override val message: String
297
+ get() = testMessage
298
+ override val icon: ImageVector
299
+ get() = Icons .Outlined .BreakfastDining
300
+ override val duration: ToastDuration
301
+ get() = ToastDuration .Long
302
+ }
303
+
304
+ override fun dismiss () {}
305
+ }
306
+ )
307
+ Spacer (
308
+ Modifier
309
+ .weight(1f )
310
+ .padding(end = 8 .dp)
311
+ )
312
+ }
313
+ Spacer (Modifier .height(8 .dp))
314
+ Divider ()
315
+ Spacer (Modifier .width(8 .dp))
316
+ Row {
317
+ val testMessage = stringResource(R .string.snackbar_preview)
318
+ val ok = stringResource(R .string.ok)
319
+
320
+ Spacer (
321
+ Modifier
322
+ .weight(1f )
323
+ .padding(start = 8 .dp)
324
+ )
325
+ Snackbar (
326
+ snackbarData = object : SnackbarData {
327
+ override val visuals: SnackbarVisuals
328
+ get() = object : SnackbarVisuals {
329
+ override val actionLabel: String
330
+ get() = ok
331
+ override val duration: SnackbarDuration
332
+ get() = SnackbarDuration .Indefinite
333
+ override val message: String
334
+ get() = testMessage
335
+ override val withDismissAction: Boolean
336
+ get() = false
337
+
338
+ }
339
+
340
+ override fun dismiss () {}
341
+
342
+ override fun performAction () {}
343
+ }
344
+ )
345
+ Spacer (
346
+ Modifier
347
+ .weight(1f )
348
+ .padding(end = 8 .dp)
349
+ )
350
+ }
351
+ Spacer (Modifier .width(8 .dp))
252
352
}
0 commit comments