expo-system-ui 2.0.1 → 2.1.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.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/systemui/SystemUIModule.kt +23 -62
- package/android/src/main/java/expo/modules/systemui/SystemUIPackage.kt +2 -6
- package/android/src/main/java/expo/modules/systemui/SystemUIReactActivityLifecycleListener.kt +1 -0
- package/android/src/main/java/expo/modules/systemui/singletons/SystemUI.kt +1 -1
- package/build/ExpoSystemUI.d.ts +1 -1
- package/build/ExpoSystemUI.d.ts.map +1 -1
- package/build/ExpoSystemUI.js +2 -2
- package/build/ExpoSystemUI.js.map +1 -1
- package/expo-module.config.json +4 -1
- package/package.json +2 -2
- package/plugin/build/withAndroidUserInterfaceStyle.d.ts +1 -1
- package/src/ExpoSystemUI.ts +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 2.1.0 — 2022-12-30
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Migrated Android codebase to use the new Expo modules API. ([#20221](https://github.com/expo/expo/pull/20221) by [@alanhughes](https://github.com/alanjhughes))
|
|
18
|
+
|
|
13
19
|
## 2.0.1 — 2022-10-28
|
|
14
20
|
|
|
15
21
|
_This version does not introduce any user-facing changes._
|
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ For bare React Native projects, ensure that you have the [native `expo` package]
|
|
|
21
21
|
|
|
22
22
|
Contributions are very welcome! Please refer to guidelines described in the [contributing guide][contributing].
|
|
23
23
|
|
|
24
|
-
[docs-main]: https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/system-ui.
|
|
24
|
+
[docs-main]: https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/system-ui.mdx
|
|
25
25
|
[docs-stable]: https://docs.expo.dev/versions/latest/sdk/system-ui/
|
|
26
26
|
[contributing]: https://github.com/expo/expo#contributing
|
|
27
27
|
[expo-modules]: https://docs.expo.dev/bare/installing-expo-modules/
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '2.0
|
|
6
|
+
version = '2.1.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -74,7 +74,7 @@ android {
|
|
|
74
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
75
75
|
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
76
76
|
versionCode 1
|
|
77
|
-
versionName '2.0
|
|
77
|
+
versionName '2.1.0'
|
|
78
78
|
}
|
|
79
79
|
lintOptions {
|
|
80
80
|
abortOnError false
|
|
@@ -1,75 +1,36 @@
|
|
|
1
1
|
package expo.modules.systemui
|
|
2
2
|
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.content.Context
|
|
5
3
|
import android.graphics.Color
|
|
6
4
|
import android.graphics.drawable.ColorDrawable
|
|
7
|
-
import
|
|
8
|
-
import expo.modules.
|
|
9
|
-
import expo.modules.
|
|
10
|
-
import expo.modules.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
private fun safeRunOnUiThread(promise: Promise, block: (activity: Activity) -> Unit) {
|
|
30
|
-
val activity = activityProvider.currentActivity
|
|
31
|
-
if (activity == null) {
|
|
32
|
-
promise.reject(CurrentActivityNotFoundException())
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
activity.runOnUiThread {
|
|
36
|
-
block(activity)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@ExpoMethod
|
|
41
|
-
fun setBackgroundColorAsync(color: Int, promise: Promise) {
|
|
42
|
-
safeRunOnUiThread(promise) {
|
|
43
|
-
var rootView = it.window.decorView
|
|
44
|
-
var colorString = colorToHex(color)
|
|
45
|
-
try {
|
|
46
|
-
val color = Color.parseColor(colorString)
|
|
47
|
-
rootView.setBackgroundColor(color)
|
|
48
|
-
promise.resolve(null)
|
|
49
|
-
} catch (e: Throwable) {
|
|
50
|
-
Log.e(ERROR_TAG, e.toString())
|
|
51
|
-
rootView.setBackgroundColor(Color.WHITE)
|
|
52
|
-
promise.reject(ERROR_TAG, "Invalid color: \"$color\"")
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@ExpoMethod
|
|
58
|
-
fun getBackgroundColorAsync(promise: Promise) {
|
|
59
|
-
safeRunOnUiThread(promise) {
|
|
60
|
-
var mBackground = it.window.decorView.background
|
|
61
|
-
if (mBackground is ColorDrawable) {
|
|
62
|
-
promise.resolve(colorToHex((mBackground.mutate() as ColorDrawable).color))
|
|
5
|
+
import expo.modules.kotlin.exception.Exceptions
|
|
6
|
+
import expo.modules.kotlin.functions.Queues
|
|
7
|
+
import expo.modules.kotlin.modules.Module
|
|
8
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
9
|
+
|
|
10
|
+
class SystemUIModule : Module() {
|
|
11
|
+
private val currentActivity
|
|
12
|
+
get() = appContext.currentActivity ?: throw Exceptions.MissingActivity()
|
|
13
|
+
|
|
14
|
+
override fun definition() = ModuleDefinition {
|
|
15
|
+
Name("ExpoSystemUI")
|
|
16
|
+
|
|
17
|
+
AsyncFunction("setBackgroundColorAsync") { color: Int ->
|
|
18
|
+
val rootView = currentActivity.window.decorView
|
|
19
|
+
val colorInt = Color.parseColor(colorToHex(color))
|
|
20
|
+
rootView.setBackgroundColor(colorInt)
|
|
21
|
+
}.runOnQueue(Queues.MAIN)
|
|
22
|
+
|
|
23
|
+
AsyncFunction("getBackgroundColorAsync") {
|
|
24
|
+
val background = currentActivity.window.decorView.background
|
|
25
|
+
return@AsyncFunction if (background is ColorDrawable) {
|
|
26
|
+
colorToHex((background.mutate() as ColorDrawable).color)
|
|
63
27
|
} else {
|
|
64
|
-
|
|
28
|
+
null
|
|
65
29
|
}
|
|
66
30
|
}
|
|
67
31
|
}
|
|
68
32
|
|
|
69
33
|
companion object {
|
|
70
|
-
private const val NAME = "ExpoSystemUI"
|
|
71
|
-
private const val ERROR_TAG = "ERR_SYSTEM_UI"
|
|
72
|
-
|
|
73
34
|
fun colorToHex(color: Int): String {
|
|
74
35
|
return String.format("#%02x%02x%02x", Color.red(color), Color.green(color), Color.blue(color))
|
|
75
36
|
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
package expo.modules.systemui
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
-
import expo.modules.core.
|
|
5
|
-
import expo.modules.core.ExportedModule
|
|
4
|
+
import expo.modules.core.interfaces.Package
|
|
6
5
|
import expo.modules.core.interfaces.ReactActivityLifecycleListener
|
|
7
6
|
|
|
8
|
-
class SystemUIPackage :
|
|
9
|
-
override fun createExportedModules(context: Context): List<ExportedModule> {
|
|
10
|
-
return listOf(SystemUIModule(context) as ExportedModule)
|
|
11
|
-
}
|
|
7
|
+
class SystemUIPackage : Package {
|
|
12
8
|
override fun createReactActivityLifecycleListeners(activityContext: Context): List<ReactActivityLifecycleListener> {
|
|
13
9
|
return listOf(SystemUIReactActivityLifecycleListener(activityContext))
|
|
14
10
|
}
|
package/build/ExpoSystemUI.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoSystemUI.d.ts","sourceRoot":"","sources":["../src/ExpoSystemUI.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ExpoSystemUI.d.ts","sourceRoot":"","sources":["../src/ExpoSystemUI.ts"],"names":[],"mappings":";AACA,wBAAmD"}
|
package/build/ExpoSystemUI.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default
|
|
1
|
+
import { requireNativeModule } from 'expo-modules-core';
|
|
2
|
+
export default requireNativeModule('ExpoSystemUI');
|
|
3
3
|
//# sourceMappingURL=ExpoSystemUI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoSystemUI.js","sourceRoot":"","sources":["../src/ExpoSystemUI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ExpoSystemUI.js","sourceRoot":"","sources":["../src/ExpoSystemUI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,eAAe,mBAAmB,CAAC,cAAc,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from 'expo-modules-core';\nexport default requireNativeModule('ExpoSystemUI');\n"]}
|
package/expo-module.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-system-ui",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Interact with system UI elements",
|
|
5
5
|
"main": "build/SystemUI.js",
|
|
6
6
|
"types": "build/SystemUI.d.ts",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"expo": "*"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "ba80e8181b79d06e00a245653727f4eaeb80420e"
|
|
48
48
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExpoConfig } from 'expo/config';
|
|
2
2
|
import { AndroidConfig, ConfigPlugin } from 'expo/config-plugins';
|
|
3
|
-
export
|
|
3
|
+
export type Props = {
|
|
4
4
|
userInterfaceStyle?: ExpoConfig['userInterfaceStyle'];
|
|
5
5
|
};
|
|
6
6
|
export declare const withAndroidUserInterfaceStyle: ConfigPlugin<void>;
|
package/src/ExpoSystemUI.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export default NativeModulesProxy.ExpoSystemUI ?? {};
|
|
1
|
+
import { requireNativeModule } from 'expo-modules-core';
|
|
2
|
+
export default requireNativeModule('ExpoSystemUI');
|