mad-pro-cli 1.0.0

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.
Files changed (37) hide show
  1. package/index.js +17 -0
  2. package/lib/commands/init.js +42 -0
  3. package/package.json +26 -0
  4. package/templates/mad-skills/SKILL.md +77 -0
  5. package/templates/mad-skills/references/accessibility.md +63 -0
  6. package/templates/mad-skills/references/adaptive_layouts.md +51 -0
  7. package/templates/mad-skills/references/advanced_performance.md +52 -0
  8. package/templates/mad-skills/references/advanced_ui.md +64 -0
  9. package/templates/mad-skills/references/ai_ml.md +38 -0
  10. package/templates/mad-skills/references/architecture_di.md +63 -0
  11. package/templates/mad-skills/references/automation_cicd.md +53 -0
  12. package/templates/mad-skills/references/clean_architecture.md +80 -0
  13. package/templates/mad-skills/references/cmp_migration.md +56 -0
  14. package/templates/mad-skills/references/concurrency.md +50 -0
  15. package/templates/mad-skills/references/deeplinks.md +42 -0
  16. package/templates/mad-skills/references/design_principles.md +47 -0
  17. package/templates/mad-skills/references/design_systems.md +47 -0
  18. package/templates/mad-skills/references/domain_layer.md +47 -0
  19. package/templates/mad-skills/references/google_play_skills.md +40 -0
  20. package/templates/mad-skills/references/kmp_migration.md +62 -0
  21. package/templates/mad-skills/references/layouts.md +57 -0
  22. package/templates/mad-skills/references/local_data.md +53 -0
  23. package/templates/mad-skills/references/migration_xml_to_compose.md +80 -0
  24. package/templates/mad-skills/references/modifiers.md +46 -0
  25. package/templates/mad-skills/references/modularization.md +70 -0
  26. package/templates/mad-skills/references/multiplatform.md +55 -0
  27. package/templates/mad-skills/references/navigation.md +48 -0
  28. package/templates/mad-skills/references/network_data.md +87 -0
  29. package/templates/mad-skills/references/observability.md +46 -0
  30. package/templates/mad-skills/references/performance.md +51 -0
  31. package/templates/mad-skills/references/security.md +67 -0
  32. package/templates/mad-skills/references/solid_principles.md +61 -0
  33. package/templates/mad-skills/references/state_management.md +46 -0
  34. package/templates/mad-skills/references/testing.md +48 -0
  35. package/templates/mad-skills/references/theming.md +52 -0
  36. package/templates/mad-skills/references/ui_patterns.md +80 -0
  37. package/templates/mad-skills/references/workmanager.md +55 -0
@@ -0,0 +1,80 @@
1
+ # Jetpack Compose UI Patterns
2
+
3
+ Standardizing how you build components ensures consistency across the app and makes the code easier to maintain.
4
+
5
+ ## 1. The Slot API Pattern
6
+
7
+ This is the most powerful pattern in Compose for creating flexible, reusable components. Instead of passing many flags, pass a `@Composable` lambda.
8
+
9
+ ```kotlin
10
+ @Composable
11
+ fun MyStandardCard(
12
+ title: String,
13
+ content: @Composable () -> Unit, // Slot
14
+ actions: @Composable (() -> Unit)? = null // Optional Slot
15
+ ) {
16
+ Card {
17
+ Column {
18
+ Text(title, style = MaterialTheme.typography.titleLarge)
19
+ content()
20
+ actions?.let {
21
+ Row { it() }
22
+ }
23
+ }
24
+ }
25
+ }
26
+ ```
27
+
28
+ ## 2. Stateful vs Stateless Components
29
+
30
+ - **Stateless**: Accepts state as parameters and emits events via lambdas. These are easy to test and reuse.
31
+ - **Stateful**: Owns and manages a `ViewModel` or its own internal state. These are usually "Screen" or "Container" level components.
32
+
33
+ **Pattern**: Always aim to make your UI components stateless and "hoist" the state to a stateful container.
34
+
35
+ ## 3. UI State Patterns (LCE)
36
+
37
+ Use a standard pattern for Loading, Content, and Error states.
38
+
39
+ ```kotlin
40
+ @Composable
41
+ fun <T> LceContainer(
42
+ state: LceState<T>,
43
+ onRetry: () -> Unit,
44
+ content: @Composable (T) -> Unit
45
+ ) {
46
+ when (state) {
47
+ is LceState.Loading -> CircularProgressIndicator()
48
+ is LceState.Error -> ErrorView(state.message, onRetry)
49
+ is LceState.Content -> content(state.data)
50
+ }
51
+ }
52
+ ```
53
+
54
+ ## 4. Derived State for List Headers
55
+
56
+ Use `derivedStateOf` to implement patterns like sticky headers or showing/hiding elements based on scroll position without killing performance.
57
+
58
+ ## 5. CompositionLocal Patterns
59
+
60
+ Use `CompositionLocal` sparingly for values that are "provided" globally down the tree (e.g., `LocalContentColor`, `LocalSpacing`).
61
+
62
+ ```kotlin
63
+ val LocalSpacing = staticCompositionLocalOf { Spacing() }
64
+
65
+ @Composable
66
+ fun MyTheme(content: @Composable () -> Unit) {
67
+ CompositionLocalProvider(LocalSpacing provides Spacing(medium = 16.dp)) {
68
+ content()
69
+ }
70
+ }
71
+ ```
72
+
73
+ ## 6. The "Scaffold" Pattern
74
+
75
+ Every screen should follow a standard structure:
76
+
77
+ 1. `Scaffold` (TopAppBar, SnackbarHost).
78
+ 2. `Box` with `PullRefresh` (if applicable).
79
+ 3. `LazyColumn` for content.
80
+ 4. Error handling via `Snackbar`.
@@ -0,0 +1,55 @@
1
+ # WorkManager & Background Tasks
2
+
3
+ WorkManager is the recommended solution for persistent, deferrable background work that needs to be guaranteed to run.
4
+
5
+ ## 1. Core Concepts
6
+
7
+ - **Worker**: Where you define the actual work to be performed.
8
+ - **WorkRequest**: Defines how and when the work should be run (Constraints, Backoff policy).
9
+ - **WorkManager**: Executes the `WorkRequest` and manages system resources.
10
+
11
+ ## 2. Defining a Worker
12
+
13
+ ```kotlin
14
+ class UploadWorker(
15
+ appContext: Context,
16
+ workerParams: WorkerParameters
17
+ ): CoroutineWorker(appContext, workerParams) {
18
+
19
+ override suspend fun doWork(): Result {
20
+ return try {
21
+ // Perform background sync or upload
22
+ uploadData()
23
+ Result.success()
24
+ } catch (e: Exception) {
25
+ Result.retry()
26
+ }
27
+ }
28
+ }
29
+ ```
30
+
31
+ ## 3. Constraints & Triggers
32
+
33
+ Constraints ensure that work only runs when certain conditions are met:
34
+
35
+ ```kotlin
36
+ val constraints = Constraints.Builder()
37
+ .setRequiredNetworkType(NetworkType.UNMETERED) // Only on Wi-Fi
38
+ .setRequiresBatteryNotLow(true)
39
+ .setRequiresCharging(true)
40
+ .build()
41
+
42
+ val uploadWorkRequest = OneTimeWorkRequestBuilder<UploadWorker>()
43
+ .setConstraints(constraints)
44
+ .setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 10, TimeUnit.MINUTES)
45
+ .build()
46
+
47
+ WorkManager.getInstance(context).enqueue(uploadWorkRequest)
48
+ ```
49
+
50
+ ## 4. Best Practices
51
+
52
+ - **Use CoroutineWorker**: For idiomatic Kotlin integration.
53
+ - **Respect Constraints**: Avoid draining the user's battery or using expensive data.
54
+ - **Avoid Long Running Work**: For immediate or very long foreground-like tasks, use `setForeground()`.
55
+ - **Periodic Work**: Use `PeriodicWorkRequest` for recurring tasks (minimum interval is 15 minutes).