@momo-kits/native-kits 0.157.1-skill.3-debug → 0.157.1-skill.6-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/momo-native-kits-skills/README.md +52 -0
- package/.claude/skills/momo-native-kits-skills/SKILL.md +32 -0
- package/.claude/skills/momo-native-kits-skills/data-display/SKILL.md +42 -0
- package/.claude/skills/momo-native-kits-skills/feedback/SKILL.md +43 -0
- package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/feedback}/references/popup.md +3 -10
- package/.claude/skills/momo-native-kits-skills/form-controls/SKILL.md +42 -0
- package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/form-controls}/references/button.md +2 -3
- package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/form-controls}/references/input.md +3 -7
- package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/form-controls}/references/radio.md +9 -9
- package/.claude/skills/momo-native-kits-skills/layout/SKILL.md +39 -0
- package/.claude/skills/momo-native-kits-skills/navigation/SKILL.md +38 -0
- package/.claude/skills/momo-native-kits-skills/output/test-report.json +12 -0
- package/.claude/skills/momo-native-kits-skills/output/validation-result.json +108 -0
- package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills}/references/constants.md +81 -6
- package/.claude/skills/momo-native-kits-skills/references/design-guidelines.md +130 -0
- package/.claude/skills/momo-native-kits-skills/references/developer/android-compose.md +29 -0
- package/.claude/skills/momo-native-kits-skills/references/developer/code-convention.md +118 -0
- package/.claude/skills/momo-native-kits-skills/references/developer/compose-multiplatform.md +29 -0
- package/.claude/skills/momo-native-kits-skills/scripts/logger.js +63 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/badge.js +32 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/bottomtab.js +19 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/button.js +32 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/card.js +32 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/checkbox.js +32 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/chip.js +59 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/divider.js +19 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/global.js +61 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/index.js +54 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/input.js +32 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/navigation.js +48 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/popup.js +45 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/radio.js +105 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/skeleton.js +20 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/snackbar.js +32 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/state.js +21 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/switch.js +45 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/text.js +19 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/tooltip.js +45 -0
- package/.claude/skills/momo-native-kits-skills/scripts/rules/trustbanner.js +22 -0
- package/.claude/skills/momo-native-kits-skills/scripts/test-on-device.sh +117 -0
- package/.claude/skills/momo-native-kits-skills/scripts/test-runner.js +167 -0
- package/.claude/skills/momo-native-kits-skills/scripts/validate-kits.js +131 -0
- package/.momo-agent.json +13 -0
- package/compose/build.gradle.kts +1 -1
- package/gradle.properties +1 -1
- package/package.json +1 -1
- package/.claude/momo-native-kits-skill/SKILL.md +0 -51
- package/.claude/momo-native-kits-skill/evals/evals.json +0 -95
- package/.claude/momo-native-kits-skill/workspace/iteration-1/benchmark.json +0 -20
- package/.claude/momo-native-kits-skill/workspace/iteration-1/benchmark.md +0 -13
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-0-button/eval_metadata.json +0 -6
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-0-button/with_skill/outputs/ButtonExample.kt +0 -55
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-0-button/without_skill/outputs/ButtonExample.kt +0 -45
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-1-input/eval_metadata.json +0 -6
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-1-input/with_skill/outputs/InputPhoneExample.kt +0 -40
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-1-input/without_skill/outputs/InputPhoneExample.kt +0 -42
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-2-bottomtab/eval_metadata.json +0 -6
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-2-bottomtab/with_skill/outputs/BottomTabExample.kt +0 -236
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-2-bottomtab/without_skill/outputs/BottomTabExample.kt +0 -152
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-3-checkbox/eval_metadata.json +0 -6
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-3-checkbox/with_skill/outputs/CheckBoxExample.kt +0 -49
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-3-checkbox/without_skill/outputs/CheckBoxExample.kt +0 -123
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-4-datetimepicker/eval_metadata.json +0 -6
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-4-datetimepicker/with_skill/outputs/DateTimePickerExample.kt +0 -318
- package/.claude/momo-native-kits-skill/workspace/iteration-1/eval-4-datetimepicker/without_skill/outputs/DateTimePickerExample.kt +0 -330
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-card/with_skill/outputs/CardExample.kt +0 -124
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-card/without_skill/outputs/CardExample.kt +0 -71
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-loginform/with_skill/outputs/LoginFormExample.kt +0 -134
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-loginform/without_skill/outputs/LoginFormExample.kt +0 -199
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-navcontainer/with_skill/outputs/NavigationContainerExample.kt +0 -224
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-navcontainer/without_skill/outputs/NavigationContainerExample.kt +0 -225
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-popup/with_skill/outputs/PopupExample.kt +0 -79
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-popup/without_skill/outputs/PopupExample.kt +0 -169
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-setoptions/eval_metadata.json +0 -6
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-setoptions/with_skill/outputs/SetOptionsExample.kt +0 -255
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-setoptions/without_skill/outputs/SetOptionsExample.kt +0 -212
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-skeleton/with_skill/outputs/SkeletonExample.kt +0 -199
- package/.claude/momo-native-kits-skill/workspace/iteration-2/eval-skeleton/without_skill/outputs/SkeletonExample.kt +0 -229
- package/.claude/momo-native-kits-skill/workspace/iteration-3/benchmark.json +0 -20
- package/.claude/momo-native-kits-skill/workspace/iteration-3/benchmark.md +0 -13
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-button/eval_metadata.json +0 -22
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-button/with_skill/outputs/PrimaryButtonExample.kt +0 -38
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-button/with_skill/timing.json +0 -5
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-button/without_skill/outputs/PrimaryButtonExample.kt +0 -83
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-button/without_skill/timing.json +0 -5
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-navcontainer/eval_metadata.json +0 -22
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-navcontainer/with_skill/outputs/NavigationContainerExample.kt +0 -547
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-navcontainer/with_skill/timing.json +0 -5
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-navcontainer/without_skill/outputs/MoMoNavigationContainer.kt +0 -519
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-navcontainer/without_skill/timing.json +0 -5
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-setoptions/eval_metadata.json +0 -27
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-setoptions/with_skill/outputs/SetOptionsExample.kt +0 -429
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-setoptions/with_skill/timing.json +0 -5
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-setoptions/without_skill/outputs/SetOptionsExample.kt +0 -353
- package/.claude/momo-native-kits-skill/workspace/iteration-3/eval-setoptions/without_skill/timing.json +0 -5
- package/.claude/settings.local.json +0 -41
- package/local.properties +0 -8
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/data-display}/references/badge.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/data-display}/references/chip.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/data-display}/references/skeleton.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/data-display}/references/text.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/feedback}/references/snackbar.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/feedback}/references/tooltip.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/feedback}/references/trustbanner.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/form-controls}/references/checkbox.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/form-controls}/references/switch.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/layout}/references/card.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/layout}/references/divider.md +0 -0
- /package/.claude/{momo-native-kits-skill → skills/momo-native-kits-skills/navigation}/references/navigation.md +0 -0
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
package com.example
|
|
2
|
-
|
|
3
|
-
import androidx.compose.foundation.layout.Box
|
|
4
|
-
import androidx.compose.foundation.layout.fillMaxSize
|
|
5
|
-
import androidx.compose.runtime.Composable
|
|
6
|
-
import androidx.compose.runtime.getValue
|
|
7
|
-
import androidx.compose.runtime.mutableStateOf
|
|
8
|
-
import androidx.compose.runtime.remember
|
|
9
|
-
import androidx.compose.runtime.setValue
|
|
10
|
-
import androidx.compose.ui.Modifier
|
|
11
|
-
import vn.momo.kits.components.PopupNotify
|
|
12
|
-
import vn.momo.kits.components.PopupNotifyProps
|
|
13
|
-
import vn.momo.kits.components.PopupNotifyType
|
|
14
|
-
import vn.momo.kits.components.PopupAction
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Example: Show a popup notification for success message in MoMo Native Kits
|
|
18
|
-
*
|
|
19
|
-
* This demonstrates how to display a success popup using PopupNotify component
|
|
20
|
-
* with the type SUCCESS to show a green checkmark icon and success styling.
|
|
21
|
-
*/
|
|
22
|
-
@Composable
|
|
23
|
-
fun SuccessPopupExample() {
|
|
24
|
-
var showPopup by remember { mutableStateOf(true) }
|
|
25
|
-
|
|
26
|
-
Box(modifier = Modifier.fillMaxSize()) {
|
|
27
|
-
PopupNotify(
|
|
28
|
-
props = PopupNotifyProps(
|
|
29
|
-
title = "Thành công",
|
|
30
|
-
message = "Giao dịch đã được xử lý thành công!",
|
|
31
|
-
type = PopupNotifyType.SUCCESS,
|
|
32
|
-
onIconClose = { showPopup = false }
|
|
33
|
-
)
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Alternative example: Success popup with action buttons
|
|
40
|
-
*/
|
|
41
|
-
@Composable
|
|
42
|
-
fun SuccessPopupWithActionsExample() {
|
|
43
|
-
var showPopup by remember { mutableStateOf(true) }
|
|
44
|
-
|
|
45
|
-
Box(modifier = Modifier.fillMaxSize()) {
|
|
46
|
-
PopupNotify(
|
|
47
|
-
props = PopupNotifyProps(
|
|
48
|
-
title = "Thành công",
|
|
49
|
-
message = "Bạn đã đăng ký dịch vụ thành công",
|
|
50
|
-
type = PopupNotifyType.SUCCESS,
|
|
51
|
-
primary = PopupAction(
|
|
52
|
-
title = "Xem chi tiết",
|
|
53
|
-
onPress = { /* navigate to details */ }
|
|
54
|
-
),
|
|
55
|
-
secondary = PopupAction(
|
|
56
|
-
title = "Đóng",
|
|
57
|
-
onPress = { showPopup = false }
|
|
58
|
-
),
|
|
59
|
-
onIconClose = { showPopup = false }
|
|
60
|
-
)
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Alternative example: Using SnackBar for success message (lighter weight)
|
|
67
|
-
*
|
|
68
|
-
* SnackBar is better for brief success messages that auto-dismiss,
|
|
69
|
-
* while PopupNotify is better for important messages requiring user attention.
|
|
70
|
-
*/
|
|
71
|
-
@Composable
|
|
72
|
-
fun SuccessSnackBarExample() {
|
|
73
|
-
Box(modifier = Modifier.fillMaxSize()) {
|
|
74
|
-
vn.momo.kits.components.SnackBar(
|
|
75
|
-
message = "Giao dịch thành công",
|
|
76
|
-
duration = vn.momo.kits.components.SnackBarDuration.SHORT
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
package com.momo.example
|
|
2
|
-
|
|
3
|
-
import androidx.compose.foundation.background
|
|
4
|
-
import androidx.compose.foundation.layout.*
|
|
5
|
-
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
6
|
-
import androidx.compose.material3.*
|
|
7
|
-
import androidx.compose.runtime.*
|
|
8
|
-
import androidx.compose.ui.Alignment
|
|
9
|
-
import androidx.compose.ui.Modifier
|
|
10
|
-
import androidx.compose.ui.draw.clip
|
|
11
|
-
import androidx.compose.ui.graphics.Color
|
|
12
|
-
import androidx.compose.ui.text.font.FontWeight
|
|
13
|
-
import androidx.compose.ui.unit.dp
|
|
14
|
-
import androidx.compose.ui.unit.sp
|
|
15
|
-
import androidx.compose.ui.window.Dialog
|
|
16
|
-
import androidx.compose.ui.window.DialogProperties
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* MoMo-style Success Popup Notification Example
|
|
20
|
-
* This demonstrates how to show a popup notification for success messages
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
@Composable
|
|
24
|
-
fun SuccessPopupNotification(
|
|
25
|
-
title: String,
|
|
26
|
-
message: String,
|
|
27
|
-
onDismiss: () -> Unit
|
|
28
|
-
) {
|
|
29
|
-
Dialog(
|
|
30
|
-
onDismissRequest = onDismiss,
|
|
31
|
-
properties = DialogProperties(
|
|
32
|
-
dismissOnBackPress = true,
|
|
33
|
-
dismissOnClickOutside = true
|
|
34
|
-
)
|
|
35
|
-
) {
|
|
36
|
-
Card(
|
|
37
|
-
modifier = Modifier
|
|
38
|
-
.fillMaxWidth()
|
|
39
|
-
.padding(16.dp),
|
|
40
|
-
shape = RoundedCornerShape(16.dp),
|
|
41
|
-
colors = CardDefaults.cardColors(
|
|
42
|
-
containerColor = Color.White
|
|
43
|
-
),
|
|
44
|
-
elevation = CardDefaults.cardElevation(defaultElevation = 8.dp)
|
|
45
|
-
) {
|
|
46
|
-
Column(
|
|
47
|
-
modifier = Modifier
|
|
48
|
-
.fillMaxWidth()
|
|
49
|
-
.padding(24.dp),
|
|
50
|
-
horizontalAlignment = Alignment.CenterHorizontally
|
|
51
|
-
) {
|
|
52
|
-
// Success Icon
|
|
53
|
-
Box(
|
|
54
|
-
modifier = Modifier
|
|
55
|
-
.size(64.dp)
|
|
56
|
-
.clip(RoundedCornerShape(32.dp))
|
|
57
|
-
.background(Color(0xFF00B859)),
|
|
58
|
-
contentAlignment = Alignment.Center
|
|
59
|
-
) {
|
|
60
|
-
Text(
|
|
61
|
-
text = "✓",
|
|
62
|
-
color = Color.White,
|
|
63
|
-
fontSize = 32.sp,
|
|
64
|
-
fontWeight = FontWeight.Bold
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
Spacer(modifier = Modifier.height(16.dp))
|
|
69
|
-
|
|
70
|
-
// Title
|
|
71
|
-
Text(
|
|
72
|
-
text = title,
|
|
73
|
-
fontSize = 20.sp,
|
|
74
|
-
fontWeight = FontWeight.Bold,
|
|
75
|
-
color = Color(0xFF1A1A1A)
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
Spacer(modifier = Modifier.height(8.dp))
|
|
79
|
-
|
|
80
|
-
// Message
|
|
81
|
-
Text(
|
|
82
|
-
text = message,
|
|
83
|
-
fontSize = 14.sp,
|
|
84
|
-
color = Color(0xFF666666),
|
|
85
|
-
modifier = Modifier.padding(horizontal = 8.dp)
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
Spacer(modifier = Modifier.height(24.dp))
|
|
89
|
-
|
|
90
|
-
// Button
|
|
91
|
-
Button(
|
|
92
|
-
onClick = onDismiss,
|
|
93
|
-
modifier = Modifier
|
|
94
|
-
.fillMaxWidth()
|
|
95
|
-
.height(48.dp),
|
|
96
|
-
shape = RoundedCornerShape(24.dp),
|
|
97
|
-
colors = ButtonDefaults.buttonColors(
|
|
98
|
-
containerColor = Color(0xFF00B859)
|
|
99
|
-
)
|
|
100
|
-
) {
|
|
101
|
-
Text(
|
|
102
|
-
text = "OK",
|
|
103
|
-
fontSize = 16.sp,
|
|
104
|
-
fontWeight = FontWeight.SemiBold
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Simpler Snackbar-style success message
|
|
114
|
-
* Can be used with Scaffold and SnackbarHost
|
|
115
|
-
*/
|
|
116
|
-
@Composable
|
|
117
|
-
fun SuccessSnackbar(
|
|
118
|
-
message: String,
|
|
119
|
-
snackbarHostState: SnackbarHostState
|
|
120
|
-
) {
|
|
121
|
-
LaunchedEffect(message) {
|
|
122
|
-
snackbarHostState.showSnackbar(
|
|
123
|
-
message = message,
|
|
124
|
-
duration = SnackbarDuration.Short
|
|
125
|
-
)
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Example usage in a Composable
|
|
131
|
-
*/
|
|
132
|
-
@Composable
|
|
133
|
-
fun PopupExampleScreen() {
|
|
134
|
-
var showSuccessPopup by remember { mutableStateOf(false) }
|
|
135
|
-
val snackbarHostState = remember { SnackbarHostState() }
|
|
136
|
-
|
|
137
|
-
Box(
|
|
138
|
-
modifier = Modifier.fillMaxSize(),
|
|
139
|
-
contentAlignment = Alignment.Center
|
|
140
|
-
) {
|
|
141
|
-
Button(
|
|
142
|
-
onClick = { showSuccessPopup = true },
|
|
143
|
-
colors = ButtonDefaults.buttonColors(
|
|
144
|
-
containerColor = Color(0xFF00B859)
|
|
145
|
-
)
|
|
146
|
-
) {
|
|
147
|
-
Text("Show Success Popup")
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (showSuccessPopup) {
|
|
152
|
-
SuccessPopupNotification(
|
|
153
|
-
title = "Success!",
|
|
154
|
-
message = "Your transaction has been completed successfully.",
|
|
155
|
-
onDismiss = { showSuccessPopup = false }
|
|
156
|
-
)
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Alternative: Toast-style notification (for background operations)
|
|
162
|
-
* This is typically shown using Android Toast API
|
|
163
|
-
*/
|
|
164
|
-
@Composable
|
|
165
|
-
fun ShowSuccessToast(message: String) {
|
|
166
|
-
// In actual implementation, this would call Android Toast
|
|
167
|
-
// Example:
|
|
168
|
-
// Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
|
|
169
|
-
}
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
package vn.momo.kits.navigation.examples
|
|
2
|
-
|
|
3
|
-
import androidx.compose.foundation.layout.Column
|
|
4
|
-
import androidx.compose.foundation.layout.fillMaxSize
|
|
5
|
-
import androidx.compose.foundation.layout.padding
|
|
6
|
-
import androidx.compose.foundation.rememberScrollState
|
|
7
|
-
import androidx.compose.foundation.verticalScroll
|
|
8
|
-
import androidx.compose.material3.MaterialTheme
|
|
9
|
-
import androidx.compose.material3.Text
|
|
10
|
-
import androidx.compose.runtime.Composable
|
|
11
|
-
import androidx.compose.runtime.LaunchedEffect
|
|
12
|
-
import androidx.compose.runtime.getValue
|
|
13
|
-
import androidx.compose.runtime.mutableStateOf
|
|
14
|
-
import androidx.compose.runtime.remember
|
|
15
|
-
import androidx.compose.runtime.setValue
|
|
16
|
-
import androidx.compose.ui.Modifier
|
|
17
|
-
import androidx.compose.ui.unit.dp
|
|
18
|
-
import vn.momo.kits.navigation.LocalNavigation
|
|
19
|
-
import vn.momo.kits.navigation.LocalNavigator
|
|
20
|
-
import vn.momo.kits.navigation.NavigationOptions
|
|
21
|
-
import vn.momo.kits.navigation.component.HeaderTitle
|
|
22
|
-
import vn.momo.kits.navigation.component.HeaderType
|
|
23
|
-
import vn.momo.kits.navigation.component.ScrollData
|
|
24
|
-
import vn.momo.kits.uikit.Button
|
|
25
|
-
import vn.momo.kits.uikit.Input
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* SetOptions Example - How to use setOptions in MoMo Navigation
|
|
29
|
-
*
|
|
30
|
-
* This example demonstrates how to dynamically change header title and other
|
|
31
|
-
* screen options after the screen has been pushed using setOptions.
|
|
32
|
-
*
|
|
33
|
-
* Key Points:
|
|
34
|
-
* - Use LocalNavigation.current to access navigation for setting options
|
|
35
|
-
* - Call setOptions inside LaunchedEffect(Unit) when screen initializes
|
|
36
|
-
* - You can change header title dynamically in response to user actions
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
@Composable
|
|
40
|
-
fun SetOptionsExample() {
|
|
41
|
-
val navigation = LocalNavigation.current
|
|
42
|
-
val navigator = LocalNavigator.current
|
|
43
|
-
|
|
44
|
-
// State for dynamic title change
|
|
45
|
-
var titleInput by remember { mutableStateOf("") }
|
|
46
|
-
|
|
47
|
-
// Set initial options when screen loads
|
|
48
|
-
LaunchedEffect(Unit) {
|
|
49
|
-
navigation.setOptions(
|
|
50
|
-
headerTitle = HeaderTitle.Default("SetOptions Demo"),
|
|
51
|
-
headerType = HeaderType.Default
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Screen content
|
|
56
|
-
Column(
|
|
57
|
-
modifier = Modifier
|
|
58
|
-
.fillMaxSize()
|
|
59
|
-
.padding(16.dp)
|
|
60
|
-
.verticalScroll(rememberScrollState())
|
|
61
|
-
) {
|
|
62
|
-
// Example 1: Dynamic title change on button click
|
|
63
|
-
Text(
|
|
64
|
-
text = "Example 1: Change Header Title Dynamically",
|
|
65
|
-
style = MaterialTheme.typography.titleMedium,
|
|
66
|
-
modifier = Modifier.padding(bottom = 8.dp)
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
Input(
|
|
70
|
-
text = titleInput,
|
|
71
|
-
onChangeText = { titleInput = it },
|
|
72
|
-
placeholder = "Enter new title",
|
|
73
|
-
modifier = Modifier.padding(bottom = 8.dp)
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
Button(
|
|
77
|
-
title = "Update Title",
|
|
78
|
-
onClick = {
|
|
79
|
-
if (titleInput.isNotEmpty()) {
|
|
80
|
-
navigation.setOptions(
|
|
81
|
-
headerTitle = HeaderTitle.Default(titleInput)
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
modifier = Modifier.padding(bottom = 24.dp)
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
// Example 2: Predefined title changes
|
|
89
|
-
Text(
|
|
90
|
-
text = "Example 2: Quick Title Changes",
|
|
91
|
-
style = MaterialTheme.typography.titleMedium,
|
|
92
|
-
modifier = Modifier.padding(bottom = 8.dp)
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
Button(
|
|
96
|
-
title = "Set: My Profile",
|
|
97
|
-
onClick = {
|
|
98
|
-
navigation.setOptions(
|
|
99
|
-
headerTitle = HeaderTitle.Default("My Profile")
|
|
100
|
-
)
|
|
101
|
-
},
|
|
102
|
-
modifier = Modifier.padding(bottom = 8.dp)
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
Button(
|
|
106
|
-
title = "Set: Settings",
|
|
107
|
-
onClick = {
|
|
108
|
-
navigation.setOptions(
|
|
109
|
-
headerTitle = HeaderTitle.Default("Settings")
|
|
110
|
-
)
|
|
111
|
-
},
|
|
112
|
-
modifier = Modifier.padding(bottom = 8.dp)
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
Button(
|
|
116
|
-
title = "Set: Notifications",
|
|
117
|
-
onClick = {
|
|
118
|
-
navigation.setOptions(
|
|
119
|
-
headerTitle = HeaderTitle.Default("Notifications")
|
|
120
|
-
)
|
|
121
|
-
},
|
|
122
|
-
modifier = Modifier.padding(bottom = 24.dp)
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
// Example 3: Change header type dynamically
|
|
126
|
-
Text(
|
|
127
|
-
text = "Example 3: Change Header Type",
|
|
128
|
-
style = MaterialTheme.typography.titleMedium,
|
|
129
|
-
modifier = Modifier.padding(bottom = 8.dp)
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
Button(
|
|
133
|
-
title = "Show Default Header",
|
|
134
|
-
onClick = {
|
|
135
|
-
navigation.setOptions(
|
|
136
|
-
headerType = HeaderType.Default
|
|
137
|
-
)
|
|
138
|
-
},
|
|
139
|
-
modifier = Modifier.padding(bottom = 8.dp)
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
Button(
|
|
143
|
-
title = "Hide Header",
|
|
144
|
-
onClick = {
|
|
145
|
-
navigation.setOptions(
|
|
146
|
-
headerType = HeaderType.None
|
|
147
|
-
)
|
|
148
|
-
},
|
|
149
|
-
modifier = Modifier.padding(bottom = 24.dp)
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
// Example 4: Combine multiple options
|
|
153
|
-
Text(
|
|
154
|
-
text = "Example 4: Update Multiple Options",
|
|
155
|
-
style = MaterialTheme.typography.titleMedium,
|
|
156
|
-
modifier = Modifier.padding(bottom = 8.dp)
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
Button(
|
|
160
|
-
title = "Update Title + Header Type",
|
|
161
|
-
onClick = {
|
|
162
|
-
navigation.setOptions(
|
|
163
|
-
headerTitle = HeaderTitle.Default("Updated Screen"),
|
|
164
|
-
headerType = HeaderType.Default
|
|
165
|
-
)
|
|
166
|
-
},
|
|
167
|
-
modifier = Modifier.padding(bottom = 8.dp)
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
// Example 5: Navigate and set options
|
|
171
|
-
Button(
|
|
172
|
-
title = "Push New Screen with Options",
|
|
173
|
-
onClick = {
|
|
174
|
-
navigator.push(
|
|
175
|
-
content = { DetailScreen() },
|
|
176
|
-
options = NavigationOptions(
|
|
177
|
-
headerTitle = HeaderTitle.Default("Detail Screen")
|
|
178
|
-
)
|
|
179
|
-
)
|
|
180
|
-
},
|
|
181
|
-
modifier = Modifier.padding(bottom = 24.dp)
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
// Example 6: Screen with scroll behavior
|
|
185
|
-
Text(
|
|
186
|
-
text = "Example 5: Scroll Behavior",
|
|
187
|
-
style = MaterialTheme.typography.titleMedium,
|
|
188
|
-
modifier = Modifier.padding(bottom = 8.dp)
|
|
189
|
-
)
|
|
190
|
-
|
|
191
|
-
Text(
|
|
192
|
-
text = "Set scrollData in LaunchedEffect to connect scroll state to header animation",
|
|
193
|
-
modifier = Modifier.padding(bottom = 8.dp)
|
|
194
|
-
)
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Detail screen that demonstrates setOptions on a pushed screen
|
|
200
|
-
*/
|
|
201
|
-
@Composable
|
|
202
|
-
fun DetailScreen() {
|
|
203
|
-
val navigation = LocalNavigation.current
|
|
204
|
-
val scrollState = rememberScrollState()
|
|
205
|
-
|
|
206
|
-
// Set options when this screen loads
|
|
207
|
-
LaunchedEffect(Unit) {
|
|
208
|
-
navigation.setOptions(
|
|
209
|
-
headerTitle = HeaderTitle.Default("Detail"),
|
|
210
|
-
scrollData = ScrollData(
|
|
211
|
-
scrollState = scrollState
|
|
212
|
-
)
|
|
213
|
-
)
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
Column(
|
|
217
|
-
modifier = Modifier
|
|
218
|
-
.fillMaxSize()
|
|
219
|
-
.padding(16.dp)
|
|
220
|
-
.verticalScroll(scrollState)
|
|
221
|
-
) {
|
|
222
|
-
Text(
|
|
223
|
-
text = "This is a detail screen pushed with options.",
|
|
224
|
-
modifier = Modifier.padding(bottom = 16.dp)
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
Button(
|
|
228
|
-
title = "Change Title from Detail",
|
|
229
|
-
onClick = {
|
|
230
|
-
navigation.setOptions(
|
|
231
|
-
headerTitle = HeaderTitle.Default("Updated Detail")
|
|
232
|
-
)
|
|
233
|
-
}
|
|
234
|
-
)
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Summary of setOptions usage:
|
|
240
|
-
*
|
|
241
|
-
* 1. Access navigation: val navigation = LocalNavigation.current
|
|
242
|
-
* 2. Call inside LaunchedEffect(Unit) for initial setup
|
|
243
|
-
* 3. Call from any function to update options dynamically
|
|
244
|
-
*
|
|
245
|
-
* Available options to set:
|
|
246
|
-
* - headerTitle: HeaderTitle.Default("Title") or HeaderTitle.None
|
|
247
|
-
* - headerType: HeaderType.Default, HeaderType.None, HeaderType.Extended(...)
|
|
248
|
-
* - hiddenBack: Boolean - show/hide back button
|
|
249
|
-
* - footerComponent: @Composable () -> Unit - custom footer
|
|
250
|
-
* - scrollData: ScrollData(scrollState) - connect scroll behavior
|
|
251
|
-
* - headerBackProps: HeaderBackProps - configure back button behavior
|
|
252
|
-
*
|
|
253
|
-
* Note: Not all options can be changed dynamically. Some require
|
|
254
|
-
* pushing a new screen with NavigationOptions.
|
|
255
|
-
*/
|