@aks-dev/easyui 1.0.50 → 1.0.53
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/com/easyui/RNEasyuiModule.java +45 -12
- package/android/src/main/java/com/easyui/utils/ScreenUtil.java +17 -0
- package/jsbridge/RNEasyui.ts +30 -0
- package/jsbridge/{UpgradeModule.tsx → UpgradeModule.ts} +0 -0
- package/jsbridge/index.ts +34 -17
- package/package.json +1 -1
- package/screen/index.ts +2 -2
- package/screen/{text-set.tsx → init-fit.tsx} +7 -3
- package/screen/px2dp.tsx +16 -6
- package/src/index.ts +2 -3
- package/jsbridge/RNEasyui.tsx +0 -13
|
@@ -2,28 +2,61 @@
|
|
|
2
2
|
* @Author: shiguo
|
|
3
3
|
* @Date: 2022-04-25 17:57:29
|
|
4
4
|
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-
|
|
6
|
-
* @FilePath: /
|
|
5
|
+
* @LastEditTime: 2022-05-31 18:19:20
|
|
6
|
+
* @FilePath: /@aks-dev/easyui/android/src/main/java/com/easyui/RNEasyuiModule.java
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
package com.easyui;
|
|
10
10
|
|
|
11
|
+
import com.facebook.react.bridge.Promise;
|
|
11
12
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
13
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
13
14
|
import com.facebook.react.bridge.ReactMethod;
|
|
14
|
-
import com.facebook.react.bridge.Callback;
|
|
15
15
|
|
|
16
16
|
public class RNEasyuiModule extends ReactContextBaseJavaModule {
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
private final ReactApplicationContext context;
|
|
19
|
+
|
|
20
|
+
public RNEasyuiModule(ReactApplicationContext reactContext) {
|
|
21
|
+
super(reactContext);
|
|
22
|
+
this.context = reactContext;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
public String getName() {
|
|
27
|
+
return "RNEasyui";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@ReactMethod
|
|
31
|
+
public void getStatusBarHeight(final Promise promise) {
|
|
32
|
+
|
|
33
|
+
// int status_bar_height = context.getResources().getDimensionPixelSize(context.getResources().getIdentifier("status_bar_height", "dimen", "android"));
|
|
34
|
+
// promise.resolve(status_bar_height);
|
|
35
|
+
int result = 0;
|
|
36
|
+
int resId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
|
37
|
+
if (resId > 0) {
|
|
38
|
+
result = context.getResources().getDimensionPixelSize(resId);
|
|
39
|
+
}
|
|
40
|
+
promise.resolve(result);
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@ReactMethod
|
|
45
|
+
public void getNavigationBarHeight(final Promise promise) {
|
|
46
|
+
|
|
47
|
+
// int navigation_bar_height = context.getResources().getDimensionPixelSize(context.getResources().getIdentifier("navigation_bar_height", "dimen", "android"));
|
|
48
|
+
// promise.resolve(navigation_bar_height);
|
|
49
|
+
|
|
50
|
+
int resourceId = 0;
|
|
51
|
+
int rid = context.getResources().getIdentifier("config_showNavigationBar", "bool", "android");
|
|
52
|
+
if (rid != 0) {
|
|
53
|
+
resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
|
|
54
|
+
int result = context.getResources().getDimensionPixelSize(resourceId);
|
|
55
|
+
promise.resolve(result);
|
|
56
|
+
} else {
|
|
57
|
+
promise.resolve(0);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
19
60
|
|
|
20
|
-
public RNEasyuiModule(ReactApplicationContext reactContext) {
|
|
21
|
-
super(reactContext);
|
|
22
|
-
this.reactContext = reactContext;
|
|
23
|
-
}
|
|
24
61
|
|
|
25
|
-
@Override
|
|
26
|
-
public String getName() {
|
|
27
|
-
return "RNEasyui";
|
|
28
|
-
}
|
|
29
62
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.easyui.utils;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
public class ScreenUtil {
|
|
6
|
+
|
|
7
|
+
public static int dp2px(Context context, float dp) {
|
|
8
|
+
final float scale = context.getResources().getDisplayMetrics().density;
|
|
9
|
+
return (int) (dp * scale + 0.5f);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public static int px2dp(Context context, float pxValue) {
|
|
13
|
+
final float scale = context.getResources().getDisplayMetrics().density;
|
|
14
|
+
return (int) (pxValue / scale + 0.5f);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: shiguo
|
|
3
|
+
* @Date: 2022-04-19 10:23:01
|
|
4
|
+
* @LastEditors: shiguo
|
|
5
|
+
* @LastEditTime: 2022-05-31 17:26:16
|
|
6
|
+
* @FilePath: /@aks-dev/easyui/jsbridge/RNEasyui.ts
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Dimensions, NativeModules, Platform } from 'react-native';
|
|
10
|
+
|
|
11
|
+
const { RNEasyui } = NativeModules;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export const getStatusBarHeight = () => {
|
|
17
|
+
if (Platform.OS == 'android') return RNEasyui.getStatusBarHeight();
|
|
18
|
+
|
|
19
|
+
const deviceHeight = Dimensions.get('window').height;
|
|
20
|
+
const isiPhoneX = Platform.OS == 'ios' && (deviceHeight > 736)
|
|
21
|
+
if (isiPhoneX) return Promise.resolve(44)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const getNavigationBarHeight = () => {
|
|
25
|
+
if (Platform.OS == 'android') return RNEasyui.getNavigationBarHeight();
|
|
26
|
+
const deviceHeight = Dimensions.get('window').height;
|
|
27
|
+
const isiPhoneX = Platform.OS == 'ios' && (deviceHeight > 736)
|
|
28
|
+
if (isiPhoneX) return Promise.resolve(88)
|
|
29
|
+
return Promise.resolve(64)
|
|
30
|
+
}
|
|
File without changes
|
package/jsbridge/index.ts
CHANGED
|
@@ -2,27 +2,44 @@
|
|
|
2
2
|
* @Author: shiguo
|
|
3
3
|
* @Date: 2022-04-19 10:23:01
|
|
4
4
|
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-05-
|
|
5
|
+
* @LastEditTime: 2022-05-31 18:19:53
|
|
6
6
|
* @FilePath: /@aks-dev/easyui/jsbridge/index.ts
|
|
7
7
|
*/
|
|
8
|
+
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* @description: 获取App版本号
|
|
10
12
|
* @param {*}
|
|
11
13
|
* @return {*}
|
|
12
14
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
export declare const getAppVersion: () => Promise<string>;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export declare type UpgradeOptions = {
|
|
19
|
+
title?: string;
|
|
20
|
+
version: string;
|
|
21
|
+
downloadUrl: string;
|
|
22
|
+
note: string;
|
|
23
|
+
force: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @description: app升级
|
|
28
|
+
* @return {*}
|
|
29
|
+
*/
|
|
30
|
+
export declare const upgrade: (options: UpgradeOptions) => Promise<string>;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated 测量不准确,已放弃
|
|
36
|
+
* @description: 获取status_bar_height
|
|
37
|
+
* @return {*}
|
|
38
|
+
*/
|
|
39
|
+
export declare const getStatusBarHeight: () => Promise<number>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @description: 获取navigation_bar_height
|
|
43
|
+
* @return {*}
|
|
44
|
+
*/
|
|
45
|
+
export declare const getNavigationBarHeight: () => Promise<number>;
|
package/package.json
CHANGED
package/screen/index.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @Author: shiguo
|
|
3
3
|
* @Date: 2022-04-19 10:25:14
|
|
4
4
|
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-05-
|
|
6
|
-
* @FilePath: /@aks/easyui/screen/index.ts
|
|
5
|
+
* @LastEditTime: 2022-05-31 17:19:03
|
|
6
|
+
* @FilePath: /@aks-dev/easyui/screen/index.ts
|
|
7
7
|
*/
|
|
8
8
|
export declare const deviceWidth: number; //设备的宽度
|
|
9
9
|
export declare const deviceHeight: number; //设备的高度
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @Author: shiguo
|
|
3
3
|
* @Date: 2022-04-15 14:15:07
|
|
4
4
|
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-
|
|
6
|
-
* @FilePath: /@aks/
|
|
5
|
+
* @LastEditTime: 2022-05-31 18:22:50
|
|
6
|
+
* @FilePath: /@aks-dev/easyui/screen/init-fit.tsx
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
9
|
* 全局配置Text
|
|
@@ -55,4 +55,8 @@ TextInput.render = function (...args: any[]) {
|
|
|
55
55
|
if (!Text.defaultProps) Text.defaultProps = {};
|
|
56
56
|
if (!TextInput.defaultProps) TextInput.defaultProps = {};
|
|
57
57
|
Text.defaultProps.allowFontScaling = false
|
|
58
|
-
TextInput.defaultProps.allowFontScaling = false
|
|
58
|
+
TextInput.defaultProps.allowFontScaling = false
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
import './px2dp'
|
package/screen/px2dp.tsx
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* @Author: shiguo
|
|
3
3
|
* @Date: 2022-04-18 14:32:25
|
|
4
4
|
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-05-
|
|
6
|
-
* @FilePath: /@aks/easyui/screen/px2dp.tsx
|
|
5
|
+
* @LastEditTime: 2022-05-31 18:22:35
|
|
6
|
+
* @FilePath: /@aks-dev/easyui/screen/px2dp.tsx
|
|
7
7
|
*/
|
|
8
|
-
import { Dimensions,
|
|
8
|
+
import { Dimensions, Platform, StatusBar } from 'react-native';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
// 设备宽度,单位 dp
|
|
@@ -13,6 +13,7 @@ export const deviceWidth = Dimensions.get('window').width; //设备的宽
|
|
|
13
13
|
export const deviceHeight = Dimensions.get('window').height; //设备的高度
|
|
14
14
|
export const isAndroid = Platform.OS === "android"
|
|
15
15
|
export const isIos = Platform.OS === 'ios'
|
|
16
|
+
export const isiPhoneX = isIos && (deviceHeight > 736)
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* 375px/667px
|
|
@@ -32,8 +33,6 @@ export const px2dp = (uiElePx: number) => {
|
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
|
|
35
|
-
export const isiPhoneX = isIos && (deviceHeight > 736)
|
|
36
|
-
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
export const statusBarHeight = (() => {
|
|
@@ -44,8 +43,19 @@ export const statusBarHeight = (() => {
|
|
|
44
43
|
return 20
|
|
45
44
|
})()
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export let navigationBarHeight = (() => {
|
|
48
49
|
if (isAndroid) return statusBarHeight + 44
|
|
49
50
|
if (isiPhoneX) return 88
|
|
50
51
|
return 64
|
|
51
52
|
})()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
import * as RNEasyui from '../jsbridge/RNEasyui';
|
|
57
|
+
; (async () => {
|
|
58
|
+
navigationBarHeight = await RNEasyui.getNavigationBarHeight() + statusBarHeight;
|
|
59
|
+
})()
|
|
60
|
+
|
|
61
|
+
|
package/src/index.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* @Author: shiguo
|
|
4
4
|
* @Date: 2022-04-13 12:47:34
|
|
5
5
|
* @LastEditors: shiguo
|
|
6
|
-
* @LastEditTime: 2022-05-
|
|
7
|
-
* @FilePath: /@aks/easyui/src/index.ts
|
|
6
|
+
* @LastEditTime: 2022-05-31 18:22:44
|
|
7
|
+
* @FilePath: /@aks-dev/easyui/src/index.ts
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
|
|
@@ -54,7 +54,6 @@ export type { EchartsViewProps } from '../lib/Echarts'
|
|
|
54
54
|
export * from '../screen/px2dp'
|
|
55
55
|
export * from '../screen/px2sp'
|
|
56
56
|
|
|
57
|
-
|
|
58
57
|
/// 工具
|
|
59
58
|
import * as mode from '../utils/mode'
|
|
60
59
|
import * as lazy from '../utils/lazy'
|
package/jsbridge/RNEasyui.tsx
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: shiguo
|
|
3
|
-
* @Date: 2022-04-19 10:23:01
|
|
4
|
-
* @LastEditors: shiguo
|
|
5
|
-
* @LastEditTime: 2022-04-27 09:22:46
|
|
6
|
-
* @FilePath: /easy/jsbridge/index.ts
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { NativeModules } from 'react-native';
|
|
10
|
-
|
|
11
|
-
const { RNEasyui } = NativeModules;
|
|
12
|
-
|
|
13
|
-
export default RNEasyui;
|