react-native-fxdialog 1.0.0-beta05 → 1.0.0-beta07
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/FXDialog.d.ts +70 -18
- package/FXDialog.d.ts.map +1 -1
- package/FXDialog.js +147 -64
- package/FXDialogView.d.ts +24 -10
- package/FXDialogView.d.ts.map +1 -1
- package/FXDialogView.js +155 -94
- package/README.md +190 -34
- package/index.d.ts +4 -2
- package/index.d.ts.map +1 -1
- package/index.js +3 -2
- package/package.json +4 -3
- package/style/FXDialogStyleInterceptor.d.ts +46 -0
- package/style/FXDialogStyleInterceptor.d.ts.map +1 -0
- package/style/FXDialogStyleInterceptor.js +110 -0
- package/style/style.d.ts +82 -0
- package/style/style.d.ts.map +1 -0
- package/{style.js → style/style.js} +18 -94
- package/tool/FXDialogViewUpdateBuilder.d.ts +17 -6
- package/tool/FXDialogViewUpdateBuilder.d.ts.map +1 -1
- package/tool/FXDialogViewUpdateBuilder.js +57 -34
- package/types.d.ts +24 -38
- package/types.d.ts.map +1 -1
- package/types.js +38 -16
- package/style.d.ts +0 -53
- package/style.d.ts.map +0 -1
package/FXDialog.d.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FXDialogViewProps } from "./FXDialogView";
|
|
2
|
+
import { FXDialogAnimationType, FXDialogAction, FXDialogTitle, FXDialogMessage, FXDialogCustomContent, FXDialogCloseType, FXDialogController, FXDialogAnimationImpl, FXDialogUpdateConfig, FXDialogQueueItem, FXDialogContent } from "./types";
|
|
3
|
+
import { FXDialogStyleInterceptor } from "./style/FXDialogStyleInterceptor";
|
|
4
|
+
import { FXDialogAnimation } from "./animation/FXDialogAnimation";
|
|
2
5
|
import { ViewStyle } from "react-native";
|
|
6
|
+
import React from "react";
|
|
3
7
|
/**
|
|
4
8
|
* Dialog 构建器
|
|
5
9
|
*/
|
|
6
10
|
declare class FXDialog {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
protected _fxViewId?: string;
|
|
12
|
+
protected _priority: number;
|
|
13
|
+
protected _didShow?: () => void;
|
|
14
|
+
protected _didClose?: (closeType?: FXDialogCloseType) => void;
|
|
15
|
+
protected _queueItem: FXDialogQueueItem | null;
|
|
16
|
+
protected _enqueue: boolean;
|
|
17
|
+
protected _viewDefaultAnimation: FXDialogAnimation;
|
|
18
|
+
protected _viewConfiguration: FXDialogViewProps;
|
|
19
|
+
protected _styleInterceptor: FXDialogStyleInterceptor;
|
|
15
20
|
/**
|
|
16
21
|
* 设置弹窗类型
|
|
17
22
|
*/
|
|
@@ -34,15 +39,32 @@ declare class FXDialog {
|
|
|
34
39
|
/**
|
|
35
40
|
* 添加自定义视图
|
|
36
41
|
*/
|
|
37
|
-
addCustom(view:
|
|
42
|
+
addCustom(view: FXDialogCustomContent): this;
|
|
43
|
+
/**
|
|
44
|
+
* 添加自定义挂起视图,内部布局是绝对定位,默认样式 position: "absolute",哪怕外部样式设置了类似 position: "relative",也会被忽略
|
|
45
|
+
* @param suspension 自定义挂起视图
|
|
46
|
+
*/
|
|
47
|
+
addSuspension(suspension: React.ReactNode): this;
|
|
48
|
+
/**
|
|
49
|
+
* 添加背景,有默认样式,默认铺满overlay,position: "absolute",传进来的组件带style,会合并默认样式
|
|
50
|
+
* 注意:这里设置style属性最好不要设置布局相关的样式,比如宽高、margin、padding, top/left/right/bottom 等,这些设置不管用,会被默认样式覆盖
|
|
51
|
+
* @param view 自定义背景组件
|
|
52
|
+
*/
|
|
53
|
+
appendBackground(view: React.ReactNode): this;
|
|
38
54
|
/**
|
|
39
55
|
* 设置点击背景是否关闭
|
|
40
56
|
*/
|
|
41
57
|
clickBackgroundClose(enable: boolean): this;
|
|
42
58
|
/**
|
|
43
|
-
*
|
|
59
|
+
* 设置背景样式
|
|
44
60
|
*/
|
|
45
61
|
backgroundStyle(style: ViewStyle): this;
|
|
62
|
+
/**
|
|
63
|
+
* 添加容器背景,有默认样式,默认铺满container,position: "absolute",传进来的组件带style,会合并默认样式
|
|
64
|
+
* 注意:这里设置style属性最好不要设置布局相关的样式,比如宽高、margin、padding, top/left/right/bottom 等,这些设置不管用,会被默认样式覆盖
|
|
65
|
+
* @param view 自定义容器背景组件
|
|
66
|
+
*/
|
|
67
|
+
appendContainer(view: React.ReactNode): this;
|
|
46
68
|
/**
|
|
47
69
|
* 设置容器样式
|
|
48
70
|
*/
|
|
@@ -79,7 +101,7 @@ declare class FXDialog {
|
|
|
79
101
|
*/
|
|
80
102
|
containerScrollMaxHeight(maxHeight: number): this;
|
|
81
103
|
/**
|
|
82
|
-
*
|
|
104
|
+
* 设置弹窗需要滚动时按钮区最小高度
|
|
83
105
|
* @param minHeight 最小高度
|
|
84
106
|
*/
|
|
85
107
|
actionsScrollMinHeight(minHeight: number): this;
|
|
@@ -110,6 +132,41 @@ declare class FXDialog {
|
|
|
110
132
|
* 设置关闭回调
|
|
111
133
|
*/
|
|
112
134
|
didClose(callback: (closeType?: FXDialogCloseType) => void): this;
|
|
135
|
+
/**
|
|
136
|
+
* 更新弹窗内容
|
|
137
|
+
* @param updates 要更新的内容
|
|
138
|
+
*/
|
|
139
|
+
protected update(updates: FXDialogUpdateConfig): void;
|
|
140
|
+
/**
|
|
141
|
+
* 更新弹窗内容
|
|
142
|
+
* @param update 要更新的内容,通过id匹配
|
|
143
|
+
*/
|
|
144
|
+
protected updateContent(update: FXDialogContent): void;
|
|
145
|
+
/**
|
|
146
|
+
* 更新操作按钮
|
|
147
|
+
* @param actions 要更新的操作按钮,通过id匹配
|
|
148
|
+
*/
|
|
149
|
+
protected updateAction(update: FXDialogAction): void;
|
|
150
|
+
/**
|
|
151
|
+
* 更新背景样式
|
|
152
|
+
* @param style 要更新的背景样式
|
|
153
|
+
*/
|
|
154
|
+
protected updateBackgroundStyle(style: ViewStyle): void;
|
|
155
|
+
/**
|
|
156
|
+
* 更新弹窗容器样式
|
|
157
|
+
* @param style 要更新的弹窗容器样式
|
|
158
|
+
*/
|
|
159
|
+
protected updateContainerStyle(style: ViewStyle): void;
|
|
160
|
+
/**
|
|
161
|
+
* 更新弹窗内容容器样式
|
|
162
|
+
* @param style 要更新的弹窗内容容器样式
|
|
163
|
+
*/
|
|
164
|
+
protected updateContentsContainerStyle(style: ViewStyle): void;
|
|
165
|
+
/**
|
|
166
|
+
* 更新弹窗操作按钮容器样式
|
|
167
|
+
* @param style 要更新的弹窗操作按钮容器样式
|
|
168
|
+
*/
|
|
169
|
+
protected updateActionsContainerStyle(style: ViewStyle): void;
|
|
113
170
|
/**
|
|
114
171
|
* 显示弹窗
|
|
115
172
|
*/
|
|
@@ -117,12 +174,7 @@ declare class FXDialog {
|
|
|
117
174
|
/**
|
|
118
175
|
* 触发关闭,关闭弹窗, 转发给 DialogManager
|
|
119
176
|
*/
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* 更新弹窗内容
|
|
123
|
-
* @param updates 要更新的内容
|
|
124
|
-
*/
|
|
125
|
-
private update;
|
|
177
|
+
protected close(closeType?: FXDialogCloseType): void;
|
|
126
178
|
/**
|
|
127
179
|
* 静态函数关闭弹窗,关闭的是最近展示出来的那个。触发关闭弹窗,并不是关闭完成。转发给 DialogManager
|
|
128
180
|
* @param fxViewId 可选,指定要关闭的弹窗的 fxViewId
|
package/FXDialog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FXDialog.d.ts","sourceRoot":"","sources":["FXDialog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FXDialog.d.ts","sourceRoot":"","sources":["FXDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAEL,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAElB,qBAAqB,EAC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IAAI,GAAG,IAAI;IAKjE;;;OAGG;IACH,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,oBAAoB;IAoB9C;;;OAGG;IACH,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,eAAe;IAM/C;;;OAGG;IACH,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,cAAc;IAM7C;;;OAGG;IACH,SAAS,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS;IAMhD;;;OAGG;IACH,SAAS,CAAC,oBAAoB,CAAC,KAAK,EAAE,SAAS;IAM/C;;;OAGG;IACH,SAAS,CAAC,4BAA4B,CAAC,KAAK,EAAE,SAAS;IAMvD;;;OAGG;IACH,SAAS,CAAC,2BAA2B,CAAC,KAAK,EAAE,SAAS;IAQtD;;OAEG;IACH,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI;IAiDlD;;OAEG;IACH,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,iBAAiB;IAU7C;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,iBAAiB;IAW7D;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM;CAIjC;AAED,eAAe,QAAQ,CAAC"}
|
package/FXDialog.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const types_1 = require("./types");
|
|
7
|
+
const FXDialogStyleInterceptor_1 = require("./style/FXDialogStyleInterceptor");
|
|
7
8
|
const FXDialogManager_1 = __importDefault(require("./FXDialogManager"));
|
|
8
9
|
const FXDialogAnimation_1 = require("./animation/FXDialogAnimation");
|
|
9
10
|
const react_native_fxview_1 = require("react-native-fxview");
|
|
@@ -16,12 +17,15 @@ class FXDialog {
|
|
|
16
17
|
// 队列项 调用 show() 时生成,show 之前是 null
|
|
17
18
|
this._queueItem = null;
|
|
18
19
|
this._enqueue = false;
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
20
|
+
this._viewDefaultAnimation = new FXDialogAnimation_1.FXDialogAnimation(types_1.FXDialogAnimationType.Scale, 300, 200);
|
|
21
|
+
this._viewConfiguration = {
|
|
21
22
|
type: types_1.FXDialogType.Alert,
|
|
22
23
|
closeOnClickBackground: true,
|
|
23
|
-
|
|
24
|
+
contents: [],
|
|
25
|
+
actions: [],
|
|
26
|
+
suspensions: [],
|
|
24
27
|
};
|
|
28
|
+
this._styleInterceptor = FXDialogStyleInterceptor_1.FXDialogStyleInterceptorSystem;
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* 设置弹窗类型
|
|
@@ -37,8 +41,8 @@ class FXDialog {
|
|
|
37
41
|
}
|
|
38
42
|
static createDialog(dialogType, animationType) {
|
|
39
43
|
const dialog = new this();
|
|
40
|
-
dialog.
|
|
41
|
-
dialog.
|
|
44
|
+
dialog._viewConfiguration.type = dialogType;
|
|
45
|
+
dialog._viewDefaultAnimation.animationType =
|
|
42
46
|
animationType || types_1.FXDialogAnimationType.Scale;
|
|
43
47
|
return dialog;
|
|
44
48
|
}
|
|
@@ -48,10 +52,7 @@ class FXDialog {
|
|
|
48
52
|
*/
|
|
49
53
|
addTitle(title) {
|
|
50
54
|
var _a;
|
|
51
|
-
(_a = this.
|
|
52
|
-
type: types_1.FXDialogElementType.Title,
|
|
53
|
-
item: title,
|
|
54
|
-
});
|
|
55
|
+
(_a = this._viewConfiguration.contents) === null || _a === void 0 ? void 0 : _a.push(title);
|
|
55
56
|
return this;
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
@@ -59,10 +60,7 @@ class FXDialog {
|
|
|
59
60
|
*/
|
|
60
61
|
addMessage(message) {
|
|
61
62
|
var _a;
|
|
62
|
-
(_a = this.
|
|
63
|
-
type: types_1.FXDialogElementType.Message,
|
|
64
|
-
item: message,
|
|
65
|
-
});
|
|
63
|
+
(_a = this._viewConfiguration.contents) === null || _a === void 0 ? void 0 : _a.push(message);
|
|
66
64
|
return this;
|
|
67
65
|
}
|
|
68
66
|
/**
|
|
@@ -70,10 +68,7 @@ class FXDialog {
|
|
|
70
68
|
*/
|
|
71
69
|
addAction(action) {
|
|
72
70
|
var _a;
|
|
73
|
-
(_a = this.
|
|
74
|
-
type: types_1.FXDialogElementType.Action,
|
|
75
|
-
item: Object.assign(Object.assign({}, action), { type: action.type || types_1.FXDialogActionType.Default }),
|
|
76
|
-
});
|
|
71
|
+
(_a = this._viewConfiguration.actions) === null || _a === void 0 ? void 0 : _a.push(action);
|
|
77
72
|
return this;
|
|
78
73
|
}
|
|
79
74
|
/**
|
|
@@ -81,45 +76,69 @@ class FXDialog {
|
|
|
81
76
|
*/
|
|
82
77
|
addCustom(view) {
|
|
83
78
|
var _a;
|
|
84
|
-
(_a = this.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
(_a = this._viewConfiguration.contents) === null || _a === void 0 ? void 0 : _a.push(view);
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 添加自定义挂起视图,内部布局是绝对定位,默认样式 position: "absolute",哪怕外部样式设置了类似 position: "relative",也会被忽略
|
|
84
|
+
* @param suspension 自定义挂起视图
|
|
85
|
+
*/
|
|
86
|
+
addSuspension(suspension) {
|
|
87
|
+
var _a;
|
|
88
|
+
(_a = this._viewConfiguration.suspensions) === null || _a === void 0 ? void 0 : _a.push(suspension);
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 添加背景,有默认样式,默认铺满overlay,position: "absolute",传进来的组件带style,会合并默认样式
|
|
93
|
+
* 注意:这里设置style属性最好不要设置布局相关的样式,比如宽高、margin、padding, top/left/right/bottom 等,这些设置不管用,会被默认样式覆盖
|
|
94
|
+
* @param view 自定义背景组件
|
|
95
|
+
*/
|
|
96
|
+
appendBackground(view) {
|
|
97
|
+
this._viewConfiguration.appendBackground = view;
|
|
88
98
|
return this;
|
|
89
99
|
}
|
|
90
100
|
/**
|
|
91
101
|
* 设置点击背景是否关闭
|
|
92
102
|
*/
|
|
93
103
|
clickBackgroundClose(enable) {
|
|
94
|
-
this.
|
|
104
|
+
this._viewConfiguration.closeOnClickBackground = enable;
|
|
95
105
|
return this;
|
|
96
106
|
}
|
|
97
107
|
/**
|
|
98
|
-
*
|
|
108
|
+
* 设置背景样式
|
|
99
109
|
*/
|
|
100
110
|
backgroundStyle(style) {
|
|
101
|
-
this.
|
|
111
|
+
this._viewConfiguration.backgroundStyle = Object.assign(Object.assign({}, this._viewConfiguration.backgroundStyle), style);
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 添加容器背景,有默认样式,默认铺满container,position: "absolute",传进来的组件带style,会合并默认样式
|
|
116
|
+
* 注意:这里设置style属性最好不要设置布局相关的样式,比如宽高、margin、padding, top/left/right/bottom 等,这些设置不管用,会被默认样式覆盖
|
|
117
|
+
* @param view 自定义容器背景组件
|
|
118
|
+
*/
|
|
119
|
+
appendContainer(view) {
|
|
120
|
+
this._viewConfiguration.appendContainer = view;
|
|
102
121
|
return this;
|
|
103
122
|
}
|
|
104
123
|
/**
|
|
105
124
|
* 设置容器样式
|
|
106
125
|
*/
|
|
107
126
|
containerStyle(style) {
|
|
108
|
-
this.
|
|
127
|
+
this._viewConfiguration.containerStyle = style;
|
|
109
128
|
return this;
|
|
110
129
|
}
|
|
111
130
|
/**
|
|
112
131
|
* 设置内容区域容器样式 除按钮外的内容区域样式
|
|
113
132
|
*/
|
|
114
133
|
contentsContainerStyle(style) {
|
|
115
|
-
this.
|
|
134
|
+
this._viewConfiguration.contentsContainerStyle = style;
|
|
116
135
|
return this;
|
|
117
136
|
}
|
|
118
137
|
/**
|
|
119
138
|
* 设置按钮区样式
|
|
120
139
|
*/
|
|
121
140
|
actionsContainerStyle(style) {
|
|
122
|
-
this.
|
|
141
|
+
this._viewConfiguration.actionsContainerStyle = style;
|
|
123
142
|
return this;
|
|
124
143
|
}
|
|
125
144
|
/**
|
|
@@ -127,7 +146,7 @@ class FXDialog {
|
|
|
127
146
|
* @param duration 动画时长 ms
|
|
128
147
|
*/
|
|
129
148
|
showAnimationDuration(duration) {
|
|
130
|
-
this.
|
|
149
|
+
this._viewDefaultAnimation.showDuration = duration;
|
|
131
150
|
return this;
|
|
132
151
|
}
|
|
133
152
|
/**
|
|
@@ -135,14 +154,14 @@ class FXDialog {
|
|
|
135
154
|
* @param duration 动画时长 ms
|
|
136
155
|
*/
|
|
137
156
|
closeAnimationDuration(duration) {
|
|
138
|
-
this.
|
|
157
|
+
this._viewDefaultAnimation.closeDuration = duration;
|
|
139
158
|
return this;
|
|
140
159
|
}
|
|
141
160
|
/**
|
|
142
161
|
* 设置动画:支持传入内置类型
|
|
143
162
|
*/
|
|
144
163
|
animationType(animation) {
|
|
145
|
-
this.
|
|
164
|
+
this._viewDefaultAnimation.animationType = animation;
|
|
146
165
|
return this;
|
|
147
166
|
}
|
|
148
167
|
/**
|
|
@@ -150,22 +169,22 @@ class FXDialog {
|
|
|
150
169
|
* @param animator 自定义动画控制器
|
|
151
170
|
*/
|
|
152
171
|
animator(animator) {
|
|
153
|
-
this.
|
|
172
|
+
this._viewConfiguration.animator = animator;
|
|
154
173
|
return this;
|
|
155
174
|
}
|
|
156
175
|
/**
|
|
157
176
|
* 设置弹窗容器最大高度
|
|
158
177
|
*/
|
|
159
178
|
containerScrollMaxHeight(maxHeight) {
|
|
160
|
-
this.
|
|
179
|
+
this._viewConfiguration.containerScrollMaxHeight = maxHeight;
|
|
161
180
|
return this;
|
|
162
181
|
}
|
|
163
182
|
/**
|
|
164
|
-
*
|
|
183
|
+
* 设置弹窗需要滚动时按钮区最小高度
|
|
165
184
|
* @param minHeight 最小高度
|
|
166
185
|
*/
|
|
167
186
|
actionsScrollMinHeight(minHeight) {
|
|
168
|
-
this.
|
|
187
|
+
this._viewConfiguration.actionsScrollMinHeight = minHeight;
|
|
169
188
|
return this;
|
|
170
189
|
}
|
|
171
190
|
/**
|
|
@@ -173,7 +192,7 @@ class FXDialog {
|
|
|
173
192
|
* @param maxHeight 最大高度
|
|
174
193
|
*/
|
|
175
194
|
actionsScrollMaxHeight(maxHeight) {
|
|
176
|
-
this.
|
|
195
|
+
this._viewConfiguration.actionsScrollMaxHeight = maxHeight;
|
|
177
196
|
return this;
|
|
178
197
|
}
|
|
179
198
|
/**
|
|
@@ -210,20 +229,104 @@ class FXDialog {
|
|
|
210
229
|
this._didClose = callback;
|
|
211
230
|
return this;
|
|
212
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* 更新弹窗内容
|
|
234
|
+
* @param updates 要更新的内容
|
|
235
|
+
*/
|
|
236
|
+
update(updates) {
|
|
237
|
+
try {
|
|
238
|
+
react_native_fxview_1.logger.log("Dialog update", this._fxViewId);
|
|
239
|
+
if (this._queueItem) {
|
|
240
|
+
// 通过引用调用DialogView的update方法(只作用于弹窗层)
|
|
241
|
+
const dialogViewRef = this._queueItem.dialogViewRef;
|
|
242
|
+
react_native_fxview_1.logger.log("[Dialog] update", this._queueItem.dialogViewRef);
|
|
243
|
+
if (dialogViewRef && dialogViewRef.current) {
|
|
244
|
+
dialogViewRef.current.update(updates);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
react_native_fxview_1.logger.warn("[Dialog] Cannot update: DialogView ref not available");
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
react_native_fxview_1.logger.warn("[Dialog] Cannot update: dialog not shown yet");
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
react_native_fxview_1.logger.error("[Dialog] Failed to update dialog", error);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* 更新弹窗内容
|
|
260
|
+
* @param update 要更新的内容,通过id匹配
|
|
261
|
+
*/
|
|
262
|
+
updateContent(update) {
|
|
263
|
+
this.update({
|
|
264
|
+
contents: [update],
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* 更新操作按钮
|
|
269
|
+
* @param actions 要更新的操作按钮,通过id匹配
|
|
270
|
+
*/
|
|
271
|
+
updateAction(update) {
|
|
272
|
+
this.update({
|
|
273
|
+
actions: [update],
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* 更新背景样式
|
|
278
|
+
* @param style 要更新的背景样式
|
|
279
|
+
*/
|
|
280
|
+
updateBackgroundStyle(style) {
|
|
281
|
+
this.update({
|
|
282
|
+
backgroundStyle: style,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* 更新弹窗容器样式
|
|
287
|
+
* @param style 要更新的弹窗容器样式
|
|
288
|
+
*/
|
|
289
|
+
updateContainerStyle(style) {
|
|
290
|
+
this.update({
|
|
291
|
+
containerStyle: style,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* 更新弹窗内容容器样式
|
|
296
|
+
* @param style 要更新的弹窗内容容器样式
|
|
297
|
+
*/
|
|
298
|
+
updateContentsContainerStyle(style) {
|
|
299
|
+
this.update({
|
|
300
|
+
contentsContainerStyle: style,
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* 更新弹窗操作按钮容器样式
|
|
305
|
+
* @param style 要更新的弹窗操作按钮容器样式
|
|
306
|
+
*/
|
|
307
|
+
updateActionsContainerStyle(style) {
|
|
308
|
+
this.update({
|
|
309
|
+
actionsContainerStyle: style,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
213
312
|
// region========== 显示方法 ==========
|
|
214
313
|
/**
|
|
215
314
|
* 显示弹窗
|
|
216
315
|
*/
|
|
217
316
|
show(fxViewId) {
|
|
218
317
|
try {
|
|
219
|
-
if (!this.
|
|
220
|
-
this.
|
|
318
|
+
if (!this._viewConfiguration.animator) {
|
|
319
|
+
this._viewConfiguration.animator = this._viewDefaultAnimation;
|
|
320
|
+
}
|
|
321
|
+
if (this._styleInterceptor) {
|
|
322
|
+
this._viewConfiguration = this._styleInterceptor.intercept(this._viewConfiguration);
|
|
221
323
|
}
|
|
324
|
+
react_native_fxview_1.logger.warn("Dialog show", this._styleInterceptor, this._viewConfiguration);
|
|
222
325
|
this._queueItem = FXDialogManager_1.default.getInstance().show({
|
|
223
326
|
fxViewId: fxViewId,
|
|
224
327
|
priority: this._priority,
|
|
225
328
|
enqueue: this._enqueue,
|
|
226
|
-
dialogProps: this.
|
|
329
|
+
dialogProps: this._viewConfiguration,
|
|
227
330
|
didShow: this._didShow,
|
|
228
331
|
didClose: this._didClose,
|
|
229
332
|
});
|
|
@@ -236,6 +339,12 @@ class FXDialog {
|
|
|
236
339
|
return {
|
|
237
340
|
close: this.close.bind(this),
|
|
238
341
|
update: this.update.bind(this),
|
|
342
|
+
updateContent: this.updateContent.bind(this),
|
|
343
|
+
updateAction: this.updateAction.bind(this),
|
|
344
|
+
updateBackgroundStyle: this.updateBackgroundStyle.bind(this),
|
|
345
|
+
updateContainerStyle: this.updateContainerStyle.bind(this),
|
|
346
|
+
updateContentContainerStyle: this.updateContentsContainerStyle.bind(this),
|
|
347
|
+
updateActionsContainerStyle: this.updateActionsContainerStyle.bind(this),
|
|
239
348
|
fxViewId: () => this._fxViewId,
|
|
240
349
|
};
|
|
241
350
|
}
|
|
@@ -253,32 +362,6 @@ class FXDialog {
|
|
|
253
362
|
FXDialogManager_1.default.getInstance().close(this._queueItem, closeType || types_1.FXDialogCloseSystemType.Custom);
|
|
254
363
|
}
|
|
255
364
|
}
|
|
256
|
-
/**
|
|
257
|
-
* 更新弹窗内容
|
|
258
|
-
* @param updates 要更新的内容
|
|
259
|
-
*/
|
|
260
|
-
update(updates) {
|
|
261
|
-
try {
|
|
262
|
-
react_native_fxview_1.logger.log("Dialog update", this._fxViewId);
|
|
263
|
-
if (this._queueItem) {
|
|
264
|
-
// 通过引用调用DialogView的update方法(只作用于弹窗层)
|
|
265
|
-
const dialogViewRef = this._queueItem.dialogViewRef;
|
|
266
|
-
react_native_fxview_1.logger.log("[Dialog] update", this._queueItem.dialogViewRef);
|
|
267
|
-
if (dialogViewRef && dialogViewRef.current) {
|
|
268
|
-
dialogViewRef.current.update(updates);
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
react_native_fxview_1.logger.warn("[Dialog] Cannot update: DialogView ref not available");
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
react_native_fxview_1.logger.warn("[Dialog] Cannot update: dialog not shown yet");
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
catch (error) {
|
|
279
|
-
react_native_fxview_1.logger.error("[Dialog] Failed to update dialog", error);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
365
|
/**
|
|
283
366
|
* 静态函数关闭弹窗,关闭的是最近展示出来的那个。触发关闭弹窗,并不是关闭完成。转发给 DialogManager
|
|
284
367
|
* @param fxViewId 可选,指定要关闭的弹窗的 fxViewId
|
package/FXDialogView.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React, { Component } from "react";
|
|
2
2
|
import { ViewStyle } from "react-native";
|
|
3
|
-
import { FXDialogType, FXDialogAction,
|
|
3
|
+
import { FXDialogType, FXDialogAction, FXDialogAnimationImpl, FXDialogUpdateConfig, FXDialogContent } from "./types";
|
|
4
4
|
export interface FXDialogViewProps {
|
|
5
5
|
type?: FXDialogType;
|
|
6
|
-
|
|
6
|
+
contents?: FXDialogContent[];
|
|
7
|
+
actions?: FXDialogAction[];
|
|
8
|
+
suspensions?: React.ReactNode[];
|
|
7
9
|
backgroundStyle?: ViewStyle;
|
|
8
10
|
containerStyle?: ViewStyle;
|
|
9
11
|
contentsContainerStyle?: ViewStyle;
|
|
10
12
|
actionsContainerStyle?: ViewStyle;
|
|
13
|
+
appendBackground?: React.ReactNode;
|
|
14
|
+
appendContainer?: React.ReactNode;
|
|
11
15
|
animator?: FXDialogAnimationImpl;
|
|
12
16
|
closeOnClickBackground?: boolean;
|
|
13
17
|
actionsScrollMinHeight?: number;
|
|
@@ -20,16 +24,21 @@ interface FXDialogViewState {
|
|
|
20
24
|
hasMeasuredActions: boolean;
|
|
21
25
|
measureContentHeight: number;
|
|
22
26
|
measureActionHeight: number;
|
|
27
|
+
suspensions?: React.ReactNode[];
|
|
23
28
|
contentScrollable: boolean;
|
|
24
29
|
actionsScrollable: boolean;
|
|
25
30
|
adjustedContentHeight: number;
|
|
26
31
|
adjustedActionsHeight: number;
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
displayContents?: FXDialogContent[];
|
|
33
|
+
displayActions?: FXDialogAction[];
|
|
34
|
+
measureContents?: FXDialogContent[];
|
|
35
|
+
measureActions?: FXDialogAction[];
|
|
29
36
|
containerStyle?: ViewStyle;
|
|
30
37
|
backgroundStyle?: ViewStyle;
|
|
31
38
|
contentsContainerStyle?: ViewStyle;
|
|
32
39
|
actionsContainerStyle?: ViewStyle;
|
|
40
|
+
appendBackground?: React.ReactNode;
|
|
41
|
+
appendContainer?: React.ReactNode;
|
|
33
42
|
}
|
|
34
43
|
export declare const FXDialogViewDefaultScrollConfig: {
|
|
35
44
|
layout: {
|
|
@@ -51,7 +60,7 @@ export default class FXDialogView extends Component<FXDialogViewProps, FXDialogV
|
|
|
51
60
|
componentDidMount(): void;
|
|
52
61
|
componentWillUnmount(): void;
|
|
53
62
|
shouldComponentUpdate(nextProps: FXDialogViewProps, nextState: FXDialogViewState): boolean;
|
|
54
|
-
update(updates:
|
|
63
|
+
update(updates: FXDialogUpdateConfig): void;
|
|
55
64
|
private handleContentLayout;
|
|
56
65
|
private handleActionsLayout;
|
|
57
66
|
private checkIfBothMeasured;
|
|
@@ -59,14 +68,19 @@ export default class FXDialogView extends Component<FXDialogViewProps, FXDialogV
|
|
|
59
68
|
private calculateScrollState;
|
|
60
69
|
handleBackdropPress: () => void;
|
|
61
70
|
handleActionPress: (action: FXDialogAction) => void;
|
|
62
|
-
private
|
|
71
|
+
private categorizeContents;
|
|
72
|
+
private allActions;
|
|
63
73
|
private renderTitle;
|
|
64
74
|
private renderMessage;
|
|
65
|
-
private
|
|
66
|
-
private
|
|
75
|
+
private renderCustomContent;
|
|
76
|
+
private renderSingleContent;
|
|
77
|
+
private renderSingleAction;
|
|
78
|
+
renderAppendBackground(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
79
|
+
renderAppendContainer(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
80
|
+
renderSuspensions: () => (React.ReactElement<any, string | React.JSXElementConstructor<any>> | null)[] | undefined;
|
|
67
81
|
renderActions: (actions: FXDialogAction[]) => React.JSX.Element;
|
|
68
|
-
renderContents: (
|
|
69
|
-
renderAllArea: (
|
|
82
|
+
renderContents: (contents: FXDialogContent[]) => React.JSX.Element;
|
|
83
|
+
renderAllArea: (contents: FXDialogContent[], actions: FXDialogAction[]) => React.JSX.Element;
|
|
70
84
|
render(): React.JSX.Element;
|
|
71
85
|
}
|
|
72
86
|
export {};
|
package/FXDialogView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FXDialogView.d.ts","sourceRoot":"","sources":["FXDialogView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAML,SAAS,EAKV,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"FXDialogView.d.ts","sourceRoot":"","sources":["FXDialogView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAML,SAAS,EAKV,MAAM,cAAc,CAAC;AAMtB,OAAO,EACL,YAAY,EACZ,cAAc,EAOd,qBAAqB,EAErB,oBAAoB,EACpB,eAAe,EAGhB,MAAM,SAAS,CAAC;AA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