-
Notifications
You must be signed in to change notification settings - Fork 17
/
DialogsPlayground.kt
162 lines (158 loc) · 6.11 KB
/
DialogsPlayground.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package com.github.terrakok.modo.sample.screens.dialogs
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import com.github.terrakok.modo.ExperimentalModoApi
import com.github.terrakok.modo.Screen
import com.github.terrakok.modo.ScreenKey
import com.github.terrakok.modo.generateScreenKey
import com.github.terrakok.modo.sample.screens.ButtonsState
import com.github.terrakok.modo.sample.screens.GroupedButtonsState
import com.github.terrakok.modo.sample.screens.MainScreen
import com.github.terrakok.modo.sample.screens.ModoButtonSpec
import com.github.terrakok.modo.sample.screens.base.ButtonsScreenContent
import com.github.terrakok.modo.stack.LocalStackNavigation
import com.github.terrakok.modo.stack.StackNavContainer
import com.github.terrakok.modo.stack.forward
import kotlinx.parcelize.Parcelize
@Parcelize
class DialogsPlayground(
private val screenIndex: Int,
override val screenKey: ScreenKey = generateScreenKey()
) : Screen {
@Composable
override fun Content(modifier: Modifier) {
DialogsPlaygroundContent(screenIndex, screenKey)
}
}
@Composable
internal fun DialogsPlaygroundContent(screenIndex: Int, screenKey: ScreenKey, modifier: Modifier = Modifier) {
ButtonsScreenContent(
screenIndex = screenIndex,
screenName = "DialogsPlayground",
screenKey = screenKey,
state = rememberDialogsButtons(LocalStackNavigation.current, screenIndex),
modifier = modifier
)
}
@Suppress("LongMethod")
@OptIn(ExperimentalModoApi::class)
@Composable
internal fun rememberDialogsButtons(
navigation: StackNavContainer,
i: Int
): GroupedButtonsState =
remember {
listOf(
ModoButtonSpec("Forward") { navigation.forward(MainScreen(i + 1)) },
ModoButtonSpec("Forward Dialogs") { navigation.forward(DialogsPlayground(i + 1)) },
ModoButtonSpec("System Dialog") {
navigation.forward(
SampleDialog(
i + 1,
dialogsPlayground = true,
systemDialog = true,
permanentDialog = false
)
)
},
ModoButtonSpec("Custom Dialog") {
navigation.forward(
SampleDialog(
i + 1,
dialogsPlayground = true,
systemDialog = false,
permanentDialog = false
)
)
},
ModoButtonSpec("System Dialog perm") {
navigation.forward(
SampleDialog(
i + 1,
dialogsPlayground = true,
systemDialog = true,
permanentDialog = true
)
)
},
ModoButtonSpec("Custom Dialog perm") {
navigation.forward(
SampleDialog(
i + 1,
dialogsPlayground = true,
systemDialog = false,
permanentDialog = true
)
)
},
ModoButtonSpec("System Dialog Stack") {
navigation.forward(SampleDialogWithStack(i + 1, systemDialog = true, permanentDialog = false))
},
ModoButtonSpec("Custom Dialog Stack") {
navigation.forward(SampleDialogWithStack(i + 1, systemDialog = false, permanentDialog = false))
},
ModoButtonSpec("System Dialog Stack perm") {
navigation.forward(
SampleDialogWithStack(
i + 1,
systemDialog = true,
permanentDialog = true
)
)
},
ModoButtonSpec("Custom Dialog Stack perm") {
navigation.forward(
SampleDialogWithStack(
i + 1,
systemDialog = false,
permanentDialog = true
)
)
},
ModoButtonSpec("System BS") {
navigation.forward(SampleBottomSheet(i + 1, systemDialog = true, permanentDialog = false))
},
ModoButtonSpec("Custom BS") {
navigation.forward(SampleBottomSheet(i + 1, systemDialog = false, permanentDialog = false))
},
ModoButtonSpec("System BS perm") {
navigation.forward(SampleBottomSheet(i + 1, systemDialog = true, permanentDialog = false))
},
ModoButtonSpec("Custom BS perm") {
navigation.forward(SampleBottomSheet(i + 1, systemDialog = false, permanentDialog = false))
},
ModoButtonSpec("System BS Stack") {
navigation.forward(SampleBottomSheetStack(i + 1, systemDialog = true, permanentDialog = false))
},
ModoButtonSpec("Custom BS Stack") {
navigation.forward(SampleBottomSheetStack(i + 1, systemDialog = false, permanentDialog = false))
},
ModoButtonSpec("System BS Stack perm") {
navigation.forward(
SampleBottomSheetStack(
i + 1,
systemDialog = true,
permanentDialog = false
)
)
},
ModoButtonSpec("Custom BS Stack perm") {
navigation.forward(
SampleBottomSheetStack(
i + 1,
systemDialog = false,
permanentDialog = false
)
)
},
ModoButtonSpec("System Dialog random dim") {
navigation.forward(SystemDialogWithCustomDimSample(i + 1))
},
ModoButtonSpec("M3 BottomSheet") {
navigation.forward(M3BottomSheet(i + 1))
},
).let {
ButtonsState(it)
}
}