expo-app-blocker 0.1.33 → 0.1.35
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 +16 -10
- package/package.json +1 -1
- package/src/index.ts +8 -1
|
@@ -34,7 +34,7 @@ public class ExpoAppBlockerPickerModule: Module {
|
|
|
34
34
|
// MARK: - ViewModel
|
|
35
35
|
|
|
36
36
|
class FamilyActivityPickerViewModel: ObservableObject {
|
|
37
|
-
@Published var selection = FamilyActivitySelection()
|
|
37
|
+
@Published var selection = FamilyActivitySelection(includeEntireCategory: true)
|
|
38
38
|
@Published var colorScheme: ColorScheme? = nil
|
|
39
39
|
var didSetInitial = false
|
|
40
40
|
}
|
|
@@ -70,7 +70,7 @@ class FamilyActivityPickerNativeView: ExpoView {
|
|
|
70
70
|
func setInitialSelection(_ selection: FamilyActivitySelection) {
|
|
71
71
|
guard !viewModel.didSetInitial else { return }
|
|
72
72
|
viewModel.didSetInitial = true
|
|
73
|
-
viewModel.selection = selection
|
|
73
|
+
viewModel.selection = normalizeSelection(selection)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/// Increments-only: first snapshot records baseline without clearing; higher values clear UI.
|
|
@@ -89,11 +89,21 @@ class FamilyActivityPickerNativeView: ExpoView {
|
|
|
89
89
|
var transaction = Transaction()
|
|
90
90
|
transaction.disablesAnimations = true
|
|
91
91
|
withTransaction(transaction) {
|
|
92
|
-
viewModel.selection = FamilyActivitySelection()
|
|
92
|
+
viewModel.selection = FamilyActivitySelection(includeEntireCategory: true)
|
|
93
93
|
}
|
|
94
94
|
viewModel.didSetInitial = false
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
private func normalizeSelection(_ selection: FamilyActivitySelection) -> FamilyActivitySelection {
|
|
98
|
+
// Apple forum reports indicate includeEntireCategory may not survive some encode/decode paths.
|
|
99
|
+
// Rehydrate into a fresh includeEntireCategory=true value so category picks expand to app tokens.
|
|
100
|
+
var normalized = FamilyActivitySelection(includeEntireCategory: true)
|
|
101
|
+
normalized.applicationTokens = selection.applicationTokens
|
|
102
|
+
normalized.categoryTokens = selection.categoryTokens
|
|
103
|
+
normalized.webDomainTokens = selection.webDomainTokens
|
|
104
|
+
return normalized
|
|
105
|
+
}
|
|
106
|
+
|
|
97
107
|
func setTheme(_ theme: String) {
|
|
98
108
|
switch theme.lowercased() {
|
|
99
109
|
case "light":
|
|
@@ -132,15 +142,11 @@ class FamilyActivityPickerNativeView: ExpoView {
|
|
|
132
142
|
}
|
|
133
143
|
|
|
134
144
|
let items = appItems + categoryItems
|
|
135
|
-
let summary: [String: Any] = [
|
|
136
|
-
"type": "summary",
|
|
137
|
-
"totalApps": selection.applicationTokens.count,
|
|
138
|
-
"totalCategories": selection.categoryTokens.count,
|
|
139
|
-
"selectionData": selectionBase64
|
|
140
|
-
]
|
|
141
145
|
|
|
146
|
+
// Do not append a synthetic "summary" row to `items` — JS counts `items.length` for UI and
|
|
147
|
+
// `totalApps` / `totalCategories` / `selectionData` already carry the same metadata.
|
|
142
148
|
onSelectionChange([
|
|
143
|
-
"items": items
|
|
149
|
+
"items": items,
|
|
144
150
|
"totalApps": selection.applicationTokens.count,
|
|
145
151
|
"totalCategories": selection.categoryTokens.count,
|
|
146
152
|
"selectionData": selectionBase64
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-app-blocker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
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
|
@@ -258,7 +258,14 @@ export function FamilyActivityPickerView({
|
|
|
258
258
|
initialSelection: initialSelection || "",
|
|
259
259
|
theme: theme || "system",
|
|
260
260
|
onSelectionChange: onSelectionChange
|
|
261
|
-
? (e: any) =>
|
|
261
|
+
? (e: any) => {
|
|
262
|
+
const ne = e.nativeEvent;
|
|
263
|
+
const items = (ne.items ?? []).filter(
|
|
264
|
+
(item: { type?: string }) =>
|
|
265
|
+
item?.type === "app" || item?.type === "category",
|
|
266
|
+
);
|
|
267
|
+
onSelectionChange({ ...ne, items });
|
|
268
|
+
}
|
|
262
269
|
: undefined,
|
|
263
270
|
...(clearTrigger !== undefined ? { clearTrigger } : {}),
|
|
264
271
|
style: [{ minHeight: 400 }, style],
|