@10play/expo-air 0.13.8 → 0.13.10
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/android/src/main/java/expo/modules/expoair/ExpoAirModule.kt +4 -0
- package/android/src/main/java/expo/modules/expoair/FloatingBubbleManager.kt +32 -6
- package/android/src/main/java/expo/modules/expoair/WidgetRuntime.kt +6 -0
- package/build/ExpoAirModule.d.ts +1 -0
- package/build/ExpoAirModule.d.ts.map +1 -1
- package/build/ExpoAirModule.js.map +1 -1
- package/ios/ExpoAirModule.swift +4 -0
- package/ios/FloatingBubbleManager.swift +9 -1
- package/package.json +1 -1
|
@@ -103,6 +103,10 @@ class ExpoAirModule : Module() {
|
|
|
103
103
|
FloatingBubbleManager.collapse()
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
Function("setServerUrl") { url: String ->
|
|
107
|
+
FloatingBubbleManager.updateServerUrl(url)
|
|
108
|
+
}
|
|
109
|
+
|
|
106
110
|
Function("getServerUrl") {
|
|
107
111
|
val context = appContext.reactContext ?: return@Function ""
|
|
108
112
|
|
|
@@ -19,6 +19,11 @@ object FloatingBubbleManager {
|
|
|
19
19
|
private var widgetRuntime: WidgetRuntime? = null
|
|
20
20
|
private var activityRef: WeakReference<Activity>? = null
|
|
21
21
|
|
|
22
|
+
private var currentSize: Double = 60.0
|
|
23
|
+
private var currentColor: String = "#000000"
|
|
24
|
+
private var currentExpanded: Boolean = false
|
|
25
|
+
private var currentServerUrl: String? = null
|
|
26
|
+
|
|
22
27
|
var onPress: (() -> Unit)? = null
|
|
23
28
|
var onExpand: (() -> Unit)? = null
|
|
24
29
|
var onCollapse: (() -> Unit)? = null
|
|
@@ -40,13 +45,20 @@ object FloatingBubbleManager {
|
|
|
40
45
|
|
|
41
46
|
Log.d(TAG, "show() bundleURL=$bundleURL serverUrl=$serverUrl")
|
|
42
47
|
|
|
48
|
+
currentSize = size.toDouble()
|
|
49
|
+
currentColor = color
|
|
50
|
+
currentExpanded = false
|
|
51
|
+
currentServerUrl = serverUrl
|
|
52
|
+
|
|
43
53
|
val bubble = FloatingBubbleView(activity)
|
|
44
54
|
bubble.onPress = { onPress?.invoke() }
|
|
45
55
|
bubble.onExpand = {
|
|
56
|
+
currentExpanded = true
|
|
46
57
|
onExpand?.invoke()
|
|
47
58
|
widgetRuntime?.emitExpandCollapse(true)
|
|
48
59
|
}
|
|
49
60
|
bubble.onCollapse = {
|
|
61
|
+
currentExpanded = false
|
|
50
62
|
onCollapse?.invoke()
|
|
51
63
|
widgetRuntime?.emitExpandCollapse(false)
|
|
52
64
|
}
|
|
@@ -58,12 +70,7 @@ object FloatingBubbleManager {
|
|
|
58
70
|
widgetRuntime?.start()
|
|
59
71
|
}
|
|
60
72
|
|
|
61
|
-
val initialProps =
|
|
62
|
-
putDouble("size", size.toDouble())
|
|
63
|
-
putString("color", color)
|
|
64
|
-
putBoolean("expanded", false)
|
|
65
|
-
if (serverUrl != null) putString("serverUrl", serverUrl)
|
|
66
|
-
}
|
|
73
|
+
val initialProps = buildSurfaceProps()
|
|
67
74
|
|
|
68
75
|
// Use async surface creation — bundle may still be downloading from Metro
|
|
69
76
|
// Pass Activity context for Fabric's ThemedReactContext (needed for native view mounting)
|
|
@@ -106,4 +113,23 @@ object FloatingBubbleManager {
|
|
|
106
113
|
bubbleView?.collapse()
|
|
107
114
|
}
|
|
108
115
|
}
|
|
116
|
+
|
|
117
|
+
fun updateServerUrl(serverUrl: String) {
|
|
118
|
+
val activity = activityRef?.get() ?: return
|
|
119
|
+
activity.runOnUiThread {
|
|
120
|
+
currentServerUrl = serverUrl
|
|
121
|
+
widgetRuntime?.updateSurfaceProps(buildSurfaceProps())
|
|
122
|
+
android.preference.PreferenceManager.getDefaultSharedPreferences(activity)
|
|
123
|
+
.edit()
|
|
124
|
+
.putString("expo-air-server-url", serverUrl)
|
|
125
|
+
.apply()
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private fun buildSurfaceProps(): Bundle = Bundle().apply {
|
|
130
|
+
putDouble("size", currentSize)
|
|
131
|
+
putString("color", currentColor)
|
|
132
|
+
putBoolean("expanded", currentExpanded)
|
|
133
|
+
currentServerUrl?.let { putString("serverUrl", it) }
|
|
134
|
+
}
|
|
109
135
|
}
|
|
@@ -207,6 +207,12 @@ class WidgetRuntime(
|
|
|
207
207
|
return surfaceView
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
fun updateSurfaceProps(props: Bundle) {
|
|
211
|
+
val currentSurface = surface as? ReactSurfaceImpl ?: return
|
|
212
|
+
currentSurface.updateInitProps(props)
|
|
213
|
+
Log.d(TAG, "Updated surface props: $props")
|
|
214
|
+
}
|
|
215
|
+
|
|
210
216
|
fun emitExpandCollapse(expanded: Boolean) {
|
|
211
217
|
widgetBridge?.emitExpandCollapse(expanded)
|
|
212
218
|
}
|
package/build/ExpoAirModule.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAirModule.d.ts","sourceRoot":"","sources":["../src/ExpoAirModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,OAAO,aAAc,SAAQ,YAAY,CAAC,mBAAmB,CAAC;IACnE,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,IAAI,MAAM;IACf,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3C,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IACvD,IAAI,IAAI,IAAI;IACZ,MAAM,IAAI,IAAI;IACd,QAAQ,IAAI,IAAI;IAChB,YAAY,IAAI,MAAM;CACvB;;AAGD,wBAA6D"}
|
|
1
|
+
{"version":3,"file":"ExpoAirModule.d.ts","sourceRoot":"","sources":["../src/ExpoAirModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,OAAO,aAAc,SAAQ,YAAY,CAAC,mBAAmB,CAAC;IACnE,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,IAAI,MAAM;IACf,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3C,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IACvD,IAAI,IAAI,IAAI;IACZ,MAAM,IAAI,IAAI;IACd,QAAQ,IAAI,IAAI;IAChB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAC/B,YAAY,IAAI,MAAM;CACvB;;AAGD,wBAA6D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoAirModule.js","sourceRoot":"","sources":["../src/ExpoAirModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpoAirModule.js","sourceRoot":"","sources":["../src/ExpoAirModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAgBzD,yDAAyD;AACzD,eAAe,mBAAmB,CAAgB,SAAS,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from \"expo\";\n\nimport { ExpoAirModuleEvents } from \"./ExpoAir.types\";\n\ndeclare class ExpoAirModule extends NativeModule<ExpoAirModuleEvents> {\n PI: number;\n hello(): string;\n setValueAsync(value: string): Promise<void>;\n show(options?: { size?: number; color?: string }): void;\n hide(): void;\n expand(): void;\n collapse(): void;\n setServerUrl(url: string): void;\n getServerUrl(): string;\n}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<ExpoAirModule>(\"ExpoAir\");\n"]}
|
package/ios/ExpoAirModule.swift
CHANGED
|
@@ -90,6 +90,10 @@ public class ExpoAirModule: Module {
|
|
|
90
90
|
FloatingBubbleManager.shared.collapse()
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
Function("setServerUrl") { (url: String) in
|
|
94
|
+
FloatingBubbleManager.shared.updateServerUrl(url)
|
|
95
|
+
}
|
|
96
|
+
|
|
93
97
|
Function("getServerUrl") { () -> String in
|
|
94
98
|
// Check UserDefaults first (may be set by CLI)
|
|
95
99
|
if let cached = UserDefaults.standard.string(forKey: "expo-air-server-url"), !cached.isEmpty {
|
|
@@ -406,7 +406,7 @@ class FloatingBubbleViewController: UIViewController, UIGestureRecognizerDelegat
|
|
|
406
406
|
onCollapse?()
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
-
|
|
409
|
+
func updateSurfaceProps() {
|
|
410
410
|
guard let surfaceView = reactSurfaceView as? RCTSurfaceHostingProxyRootView else { return }
|
|
411
411
|
var props: [String: Any] = [
|
|
412
412
|
"size": bubbleSize,
|
|
@@ -644,4 +644,12 @@ class FloatingBubbleManager {
|
|
|
644
644
|
self.bubbleVC?.collapse()
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
|
+
|
|
648
|
+
func updateServerUrl(_ url: String) {
|
|
649
|
+
DispatchQueue.main.async {
|
|
650
|
+
self.bubbleVC?.serverUrl = url
|
|
651
|
+
self.bubbleVC?.updateSurfaceProps()
|
|
652
|
+
UserDefaults.standard.set(url, forKey: "expo-air-server-url")
|
|
653
|
+
}
|
|
654
|
+
}
|
|
647
655
|
}
|