@aks-dev/easyui 1.0.52 → 1.0.55

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.
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-25 17:57:29
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-05-31 17:04:47
5
+ * @LastEditTime: 2022-05-31 18:19:20
6
6
  * @FilePath: /@aks-dev/easyui/android/src/main/java/com/easyui/RNEasyuiModule.java
7
7
  */
8
8
 
@@ -12,34 +12,51 @@ import com.facebook.react.bridge.Promise;
12
12
  import com.facebook.react.bridge.ReactApplicationContext;
13
13
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
14
14
  import com.facebook.react.bridge.ReactMethod;
15
- import com.facebook.react.bridge.Callback;
16
15
 
17
16
  public class RNEasyuiModule extends ReactContextBaseJavaModule {
18
17
 
19
- private final ReactApplicationContext context;
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
+ }
20
60
 
21
- public RNEasyuiModule(ReactApplicationContext reactContext) {
22
- super(reactContext);
23
- this.context = reactContext;
24
- }
25
-
26
- @Override
27
- public String getName() {
28
- return "RNEasyui";
29
- }
30
-
31
- @ReactMethod
32
- public void getStatusBarHeight(final Promise promise){
33
-
34
- int status_bar_height = context.getResources().getDimensionPixelSize(context.getResources().getIdentifier("status_bar_height", "dimen", "android"));
35
- promise.resolve(status_bar_height);
36
- }
37
-
38
- @ReactMethod
39
- public void getNavigationBarHeight(final Promise promise){
40
-
41
- int navigation_bar_height = context.getResources().getDimensionPixelSize(context.getResources().getIdentifier("navigation_bar_height", "dimen", "android"));
42
- promise.resolve(navigation_bar_height);
43
- }
44
61
 
45
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
+ }
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-19 10:23:01
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-05-31 17:26:16
5
+ * @LastEditTime: 2022-05-31 18:42:45
6
6
  * @FilePath: /@aks-dev/easyui/jsbridge/RNEasyui.ts
7
7
  */
8
8
 
@@ -19,12 +19,12 @@ export const getStatusBarHeight = () => {
19
19
  const deviceHeight = Dimensions.get('window').height;
20
20
  const isiPhoneX = Platform.OS == 'ios' && (deviceHeight > 736)
21
21
  if (isiPhoneX) return Promise.resolve(44)
22
+ return Promise.resolve(20)
22
23
  }
23
24
 
24
25
  export const getNavigationBarHeight = () => {
25
26
  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)
27
+
28
+ return Promise.resolve(44)
29
+
30
30
  }
package/jsbridge/index.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-19 10:23:01
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-05-31 17:00:25
5
+ * @LastEditTime: 2022-05-31 18:19:53
6
6
  * @FilePath: /@aks-dev/easyui/jsbridge/index.ts
7
- */
7
+ */
8
8
 
9
9
 
10
10
  /**
@@ -12,33 +12,34 @@
12
12
  * @param {*}
13
13
  * @return {*}
14
14
  */
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
- * @description: 获取status_bar_height
36
- * @return {*}
37
- */
38
- export declare const getStatusBarHeight:()=>Promise<number>;
39
-
40
- /**
41
- * @description: 获取navigation_bar_height
42
- * @return {*}
43
- */
44
- export declare const getNavigationBarHeight:()=>Promise<number>;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aks-dev/easyui",
3
- "version": "1.0.52",
3
+ "version": "1.0.55",
4
4
  "description": "爱科森开发工具包(react-native)",
5
5
  "main": "./src/index.ts",
6
6
  "typings": "./src/index.d.ts",
package/screen/index.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-19 10:25:14
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-05-31 17:19:03
5
+ * @LastEditTime: 2022-05-31 18:34:57
6
6
  * @FilePath: /@aks-dev/easyui/screen/index.ts
7
7
  */
8
8
  export declare const deviceWidth: number; //设备的宽度
@@ -19,7 +19,7 @@ export declare const isiPhoneX: boolean;
19
19
  */
20
20
  export declare const statusBarHeight: number;
21
21
  /**
22
- * @description: 顶部导航条的高度
22
+ * @description: 顶部导航条的高度,高度不包含statusBarHeight
23
23
  * @param {*}
24
24
  * @return {*}
25
25
  */
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-15 14:15:07
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-05-31 17:25:13
5
+ * @LastEditTime: 2022-05-31 18:22:50
6
6
  * @FilePath: /@aks-dev/easyui/screen/init-fit.tsx
7
7
  */
8
8
  /**
@@ -59,9 +59,4 @@ TextInput.defaultProps.allowFontScaling = false
59
59
 
60
60
 
61
61
 
62
- import * as RNEasyui from '../jsbridge/RNEasyui';
63
-
64
-
65
- export const statusBarHeight = await RNEasyui.getStatusBarHeight()
66
-
67
- export const navigationBarHeight = await RNEasyui.getNavigationBarHeight()
62
+ import './px2dp'
@@ -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-31 17:22:42
6
- * @FilePath: /@aks-dev/easyui/screen/px2dp.tsx
5
+ * @LastEditTime: 2022-05-31 18:43:44
6
+ * @FilePath: /@aks-dev/easyui/screen/px2dp.ts
7
7
  */
8
- import { Dimensions, Platform } from 'react-native';
8
+ import { Dimensions, Platform, StatusBar } from 'react-native';
9
9
 
10
10
 
11
11
  // 设备宽度,单位 dp
@@ -35,19 +35,23 @@ export const px2dp = (uiElePx: number) => {
35
35
 
36
36
 
37
37
 
38
- // export const statusBarHeight = (() => {
39
- // if (isAndroid) {
40
- // if ((StatusBar.currentHeight || 0) > 20) return 40
41
- // }
42
- // if (isiPhoneX) return 44
43
- // return 20
44
- // })()
38
+ export const statusBarHeight = (() => {
39
+ if (isAndroid) {
40
+ if ((StatusBar.currentHeight || 0) > 20) return 40
41
+ }
42
+ if (isiPhoneX) return 44
43
+ return 20
44
+ })()
45
45
 
46
- // export const navigationBarHeight = (() => {
47
- // if (isAndroid) return statusBarHeight + 44
48
- // if (isiPhoneX) return 88
49
- // return 64
50
- // })()
51
46
 
52
47
 
48
+ export let navigationBarHeight = 44
49
+
50
+
51
+
52
+ import * as RNEasyui from '../jsbridge/RNEasyui';
53
+ ; (async () => {
54
+ navigationBarHeight = await RNEasyui.getNavigationBarHeight();
55
+ })()
56
+
53
57
 
File without changes
package/src/index.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * @Author: shiguo
4
4
  * @Date: 2022-04-13 12:47:34
5
5
  * @LastEditors: shiguo
6
- * @LastEditTime: 2022-05-31 17:24:37
6
+ * @LastEditTime: 2022-05-31 18:22:44
7
7
  * @FilePath: /@aks-dev/easyui/src/index.ts
8
8
  */
9
9
 
@@ -53,8 +53,6 @@ export type { EchartsViewProps } from '../lib/Echarts'
53
53
  /// 全局适配
54
54
  export * from '../screen/px2dp'
55
55
  export * from '../screen/px2sp'
56
- export * from '../screen/init-fit'
57
-
58
56
 
59
57
  /// 工具
60
58
  import * as mode from '../utils/mode'
File without changes
File without changes