Skip to content

Commit 18e548c

Browse files
committed
feat(rn): 支持rn modal 嵌套 popup
1 parent 6d27f1c commit 18e548c

6 files changed

Lines changed: 18 additions & 6 deletions

File tree

packages/mpx-cube-ui/lib/components/popup/css.rn.styl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
right 0
1010
top 0
1111
bottom 0
12+
.cube-popup_without_portal
13+
position relative
1214

1315
.cube-popup-show
1416
transform: translateX(0)

packages/mpx-cube-ui/lib/components/popup/index.mpx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</view>
4949
</view>
5050
</block>
51-
<root-portal @_ios|_android|_harmony>
51+
<root-portal @_ios|_android|_harmony enable="{{ !rootPortalDisable }}">
5252
<view
5353
wx:ref="popup"
5454
external-var-context="{{varContext}}"

packages/mpx-cube-ui/lib/components/popup/popup.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ createComponent({
3939
type: String,
4040
value: ''
4141
},
42-
// 透传样式,可用于样式覆盖。其中 mask.visibleOpacity 用于设置遮罩层显示时透明度
42+
// 透传样式,可用于样式覆盖。其中 mask.visibleOpacity 用于设置遮罩层显示时透明度。rootPortal.enable = false 用于rn下套用rn modal 情况
4343
styleConfig: {
4444
type: Object,
4545
value: {}
@@ -77,11 +77,15 @@ createComponent({
7777
}
7878
return style;
7979
},
80+
rootPortalDisable() {
81+
return this.styleConfig.rootPortal?.enable === false;
82+
},
8083
rootClass() {
8184
const cls = {
8285
'cube-popup_mask': this.mask,
8386
'cube-popup_mask_fade_transition': this.maskFadeTransition,
84-
'cube-popup_transition': !!this.transitionClass
87+
'cube-popup_transition': !!this.transitionClass,
88+
'cube-popup_without_portal': this.rootPortalDisable
8589
};
8690
if (this.type) {
8791
cls[`cube-${this.type}`] = true;

packages/mpx-cube-ui/src/components/popup/css.rn.styl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
right 0
1010
top 0
1111
bottom 0
12+
.cube-popup_without_portal
13+
position relative
1214

1315
.cube-popup-show
1416
transform: translateX(0)

packages/mpx-cube-ui/src/components/popup/index.mpx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</view>
4949
</view>
5050
</block>
51-
<root-portal @_ios|_android|_harmony>
51+
<root-portal @_ios|_android|_harmony enable="{{ !rootPortalDisable }}">
5252
<view
5353
wx:ref="popup"
5454
external-var-context="{{varContext}}"

packages/mpx-cube-ui/src/components/popup/popup.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ createComponent({
4545
type: String,
4646
value: ''
4747
},
48-
// 透传样式,可用于样式覆盖。其中 mask.visibleOpacity 用于设置遮罩层显示时透明度
48+
// 透传样式,可用于样式覆盖。其中 mask.visibleOpacity 用于设置遮罩层显示时透明度。rootPortal.enable = false 用于rn下套用rn modal 情况
4949
styleConfig: {
5050
type: Object,
5151
value: {}
@@ -82,11 +82,15 @@ createComponent({
8282
}
8383
return style
8484
},
85+
rootPortalDisable() {
86+
return this.styleConfig.rootPortal?.enable === false
87+
},
8588
rootClass() {
8689
const cls: { [index: string]: boolean } = {
8790
'cube-popup_mask': this.mask,
8891
'cube-popup_mask_fade_transition': this.maskFadeTransition,
89-
'cube-popup_transition': !!this.transitionClass
92+
'cube-popup_transition': !!this.transitionClass,
93+
'cube-popup_without_portal': this.rootPortalDisable
9094
}
9195
if (this.type) {
9296
cls[`cube-${this.type}`] = true

0 commit comments

Comments
 (0)