expo-app-blocker 0.1.32 → 0.1.33
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/ios/ExpoAppBlockerPickerModule.swift +26 -12
- package/package.json +1 -1
- package/src/index.ts +2 -0
|
@@ -22,11 +22,10 @@ public class ExpoAppBlockerPickerModule: Module {
|
|
|
22
22
|
view.setTheme(theme)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// Increment
|
|
26
|
-
//
|
|
27
|
-
// @Binding — setting the backing @Published var resets the SwiftUI view.
|
|
25
|
+
// Increment to clear selection in-process. Applied only after the initial
|
|
26
|
+
// React prop snapshot so mounting with `{ clearTrigger: 0 }` does not wipe state.
|
|
28
27
|
Prop("clearTrigger") { (view: FamilyActivityPickerNativeView, trigger: Int) in
|
|
29
|
-
view.
|
|
28
|
+
view.applyClearTrigger(trigger)
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
}
|
|
@@ -37,7 +36,6 @@ public class ExpoAppBlockerPickerModule: Module {
|
|
|
37
36
|
class FamilyActivityPickerViewModel: ObservableObject {
|
|
38
37
|
@Published var selection = FamilyActivitySelection()
|
|
39
38
|
@Published var colorScheme: ColorScheme? = nil
|
|
40
|
-
@Published var clearCounter: Int = 0
|
|
41
39
|
var didSetInitial = false
|
|
42
40
|
}
|
|
43
41
|
|
|
@@ -47,6 +45,9 @@ class FamilyActivityPickerNativeView: ExpoView {
|
|
|
47
45
|
let onSelectionChange = EventDispatcher()
|
|
48
46
|
let viewModel = FamilyActivityPickerViewModel()
|
|
49
47
|
private var hostingController: UIHostingController<InlinePickerContentView>?
|
|
48
|
+
/// First `clearTrigger` snapshot from React establishes baseline — do not treat as clear.
|
|
49
|
+
private var didSyncClearTriggerFromReact = false
|
|
50
|
+
private var lastAppliedClearTrigger: Int = 0
|
|
50
51
|
|
|
51
52
|
required init(appContext: AppContext? = nil) {
|
|
52
53
|
super.init(appContext: appContext)
|
|
@@ -72,10 +73,25 @@ class FamilyActivityPickerNativeView: ExpoView {
|
|
|
72
73
|
viewModel.selection = selection
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
/// Increments-only: first snapshot records baseline without clearing; higher values clear UI.
|
|
77
|
+
func applyClearTrigger(_ trigger: Int) {
|
|
78
|
+
if !didSyncClearTriggerFromReact {
|
|
79
|
+
didSyncClearTriggerFromReact = true
|
|
80
|
+
lastAppliedClearTrigger = trigger
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
guard trigger > lastAppliedClearTrigger else { return }
|
|
84
|
+
lastAppliedClearTrigger = trigger
|
|
85
|
+
clearSelectionWithoutRemount()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private func clearSelectionWithoutRemount() {
|
|
89
|
+
var transaction = Transaction()
|
|
90
|
+
transaction.disablesAnimations = true
|
|
91
|
+
withTransaction(transaction) {
|
|
92
|
+
viewModel.selection = FamilyActivitySelection()
|
|
93
|
+
}
|
|
77
94
|
viewModel.didSetInitial = false
|
|
78
|
-
viewModel.clearCounter += 1
|
|
79
95
|
}
|
|
80
96
|
|
|
81
97
|
func setTheme(_ theme: String) {
|
|
@@ -139,11 +155,9 @@ struct InlinePickerContentView: View {
|
|
|
139
155
|
var onSelectionChange: (FamilyActivitySelection) -> Void
|
|
140
156
|
|
|
141
157
|
var body: some View {
|
|
142
|
-
// .id
|
|
143
|
-
//
|
|
144
|
-
// binding mutations after initial presentation — recreation is the only reset path.
|
|
158
|
+
// Prefer binding-only resets: recreating FamilyActivityPicker (e.g. via `.id`) causes a visible flash.
|
|
159
|
+
// If a future iOS/SDK build stops syncing empty selections here, reconsider a targeted redraw.
|
|
145
160
|
let picker = FamilyActivityPicker(selection: $viewModel.selection)
|
|
146
|
-
.id(viewModel.clearCounter)
|
|
147
161
|
.onChange(of: viewModel.selection) { newSelection in
|
|
148
162
|
onSelectionChange(newSelection)
|
|
149
163
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-app-blocker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
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",
|
package/src/index.ts
CHANGED
|
@@ -250,6 +250,7 @@ export function FamilyActivityPickerView({
|
|
|
250
250
|
onSelectionChange,
|
|
251
251
|
theme,
|
|
252
252
|
style,
|
|
253
|
+
clearTrigger,
|
|
253
254
|
}: FamilyActivityPickerViewProps) {
|
|
254
255
|
if (!NativePickerView || Platform.OS !== "ios") return null;
|
|
255
256
|
|
|
@@ -259,6 +260,7 @@ export function FamilyActivityPickerView({
|
|
|
259
260
|
onSelectionChange: onSelectionChange
|
|
260
261
|
? (e: any) => onSelectionChange(e.nativeEvent)
|
|
261
262
|
: undefined,
|
|
263
|
+
...(clearTrigger !== undefined ? { clearTrigger } : {}),
|
|
262
264
|
style: [{ minHeight: 400 }, style],
|
|
263
265
|
});
|
|
264
266
|
}
|