expo-app-blocker 0.1.30 → 0.1.32
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.
|
@@ -21,6 +21,13 @@ public class ExpoAppBlockerPickerModule: Module {
|
|
|
21
21
|
Prop("theme") { (view: FamilyActivityPickerNativeView, theme: String) in
|
|
22
22
|
view.setTheme(theme)
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
// Increment this value to programmatically clear the picker's selection
|
|
26
|
+
// without remounting. Works because FamilyActivityPicker is driven by a
|
|
27
|
+
// @Binding — setting the backing @Published var resets the SwiftUI view.
|
|
28
|
+
Prop("clearTrigger") { (view: FamilyActivityPickerNativeView, trigger: Int) in
|
|
29
|
+
view.clearSelection()
|
|
30
|
+
}
|
|
24
31
|
}
|
|
25
32
|
}
|
|
26
33
|
}
|
|
@@ -30,6 +37,7 @@ public class ExpoAppBlockerPickerModule: Module {
|
|
|
30
37
|
class FamilyActivityPickerViewModel: ObservableObject {
|
|
31
38
|
@Published var selection = FamilyActivitySelection()
|
|
32
39
|
@Published var colorScheme: ColorScheme? = nil
|
|
40
|
+
@Published var clearCounter: Int = 0
|
|
33
41
|
var didSetInitial = false
|
|
34
42
|
}
|
|
35
43
|
|
|
@@ -64,6 +72,12 @@ class FamilyActivityPickerNativeView: ExpoView {
|
|
|
64
72
|
viewModel.selection = selection
|
|
65
73
|
}
|
|
66
74
|
|
|
75
|
+
func clearSelection() {
|
|
76
|
+
viewModel.selection = FamilyActivitySelection()
|
|
77
|
+
viewModel.didSetInitial = false
|
|
78
|
+
viewModel.clearCounter += 1
|
|
79
|
+
}
|
|
80
|
+
|
|
67
81
|
func setTheme(_ theme: String) {
|
|
68
82
|
switch theme.lowercased() {
|
|
69
83
|
case "light":
|
|
@@ -125,7 +139,11 @@ struct InlinePickerContentView: View {
|
|
|
125
139
|
var onSelectionChange: (FamilyActivitySelection) -> Void
|
|
126
140
|
|
|
127
141
|
var body: some View {
|
|
142
|
+
// .id(clearCounter) forces SwiftUI to destroy and recreate FamilyActivityPicker
|
|
143
|
+
// when clearSelection() is called. The picker does not respond to external
|
|
144
|
+
// binding mutations after initial presentation — recreation is the only reset path.
|
|
128
145
|
let picker = FamilyActivityPicker(selection: $viewModel.selection)
|
|
146
|
+
.id(viewModel.clearCounter)
|
|
129
147
|
.onChange(of: viewModel.selection) { newSelection in
|
|
130
148
|
onSelectionChange(newSelection)
|
|
131
149
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-app-blocker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"description": "Expo module for cross-platform app blocking. Android: UsageStatsManager + Overlay. iOS: Screen Time API (FamilyControls + ManagedSettings + DeviceActivity).",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -80,6 +80,8 @@ export interface FamilyActivityPickerViewProps {
|
|
|
80
80
|
onSelectionChange?: (event: FamilyActivityPickerSelectionEvent) => void;
|
|
81
81
|
/** Forces the picker's color scheme: "light", "dark", or "system" (default) */
|
|
82
82
|
theme?: "light" | "dark" | "system";
|
|
83
|
+
/** Increment to programmatically clear the picker selection without remounting */
|
|
84
|
+
clearTrigger?: number;
|
|
83
85
|
/** Standard React Native style */
|
|
84
86
|
style?: any;
|
|
85
87
|
}
|