diff --git a/example/pages/notify/index.js b/example/pages/notify/index.js
index 10de89fa..c7553e56 100644
--- a/example/pages/notify/index.js
+++ b/example/pages/notify/index.js
@@ -11,7 +11,12 @@ Page({
duration: 1000,
text: '通知内容',
selector: '#custom-selector',
- backgroundColor: '#1989fa'
+ backgroundColor: '#1989fa',
+ safeAreaInsetTop: true
});
+ },
+
+ onClickLeft() {
+ wx.navigateBack();
}
});
diff --git a/example/pages/notify/index.json b/example/pages/notify/index.json
index a0b1d0dc..531b376c 100644
--- a/example/pages/notify/index.json
+++ b/example/pages/notify/index.json
@@ -1,3 +1,4 @@
{
- "navigationBarTitleText": "Notify 消息通知"
+ "navigationBarTitleText": "Notify 消息通知",
+ "navigationStyle": "custom"
}
diff --git a/example/pages/notify/index.wxml b/example/pages/notify/index.wxml
index 469a1bd4..be58b262 100644
--- a/example/pages/notify/index.wxml
+++ b/example/pages/notify/index.wxml
@@ -1,3 +1,10 @@
+
+
显示消息通知
@@ -6,6 +13,5 @@
显示自定义消息通知
-
+
-
\ No newline at end of file
diff --git a/example/pages/popup/index.js b/example/pages/popup/index.js
index d4f03e3b..eaf2549d 100644
--- a/example/pages/popup/index.js
+++ b/example/pages/popup/index.js
@@ -41,5 +41,9 @@ Page({
setTimeout(() => {
this.toggle('top');
}, 2000);
+ },
+
+ onClickLeft() {
+ wx.navigateBack();
}
});
diff --git a/example/pages/popup/index.json b/example/pages/popup/index.json
index ca281fb4..f546244e 100644
--- a/example/pages/popup/index.json
+++ b/example/pages/popup/index.json
@@ -1,3 +1,4 @@
{
- "navigationBarTitleText": "Popup 弹出层"
+ "navigationBarTitleText": "Popup 弹出层",
+ "navigationStyle": "custom"
}
diff --git a/example/pages/popup/index.wxml b/example/pages/popup/index.wxml
index 25b1568c..bca283ac 100644
--- a/example/pages/popup/index.wxml
+++ b/example/pages/popup/index.wxml
@@ -1,3 +1,10 @@
+
+
弹出 Popup
{
- if (isIPhoneX !== null) {
- resolve(isIPhoneX);
- } else {
- wx.getSystemInfo({
- success: ({ model, screenHeight }) => {
- const iphoneX = /iphone x/i.test(model);
- const iphoneNew = /iPhone11/i.test(model) && screenHeight === 812;
- isIPhoneX = iphoneX || iphoneNew;
- resolve(isIPhoneX);
- },
- fail: reject
- });
- }
- });
-}
-
-export const iphonex = Behavior({
- properties: {
- safeAreaInsetBottom: {
- type: Boolean,
- value: true
- }
- },
-
- created() {
- getIsIPhoneX().then(isIPhoneX => {
- this.set({ isIPhoneX });
- });
- }
-});
diff --git a/packages/mixins/safe-area.ts b/packages/mixins/safe-area.ts
new file mode 100644
index 00000000..7d42ec18
--- /dev/null
+++ b/packages/mixins/safe-area.ts
@@ -0,0 +1,47 @@
+let cache = null;
+
+function getSafeArea() {
+ return new Promise((resolve, reject) => {
+ if (cache != null) {
+ resolve(cache);
+ } else {
+ wx.getSystemInfo({
+ success: ({ model, screenHeight, statusBarHeight }) => {
+ const iphoneX = /iphone x/i.test(model);
+ const iphoneNew = /iPhone11/i.test(model) && screenHeight === 812;
+
+ cache = {
+ isIPhoneX: iphoneX || iphoneNew,
+ statusBarHeight
+ };
+
+ resolve(cache);
+ },
+ fail: reject
+ });
+ }
+ });
+}
+
+export const safeArea = ({
+ safeAreaInsetBottom = true,
+ safeAreaInsetTop = false
+} = {}) =>
+ Behavior({
+ properties: {
+ safeAreaInsetTop: {
+ type: Boolean,
+ value: safeAreaInsetTop
+ },
+ safeAreaInsetBottom: {
+ type: Boolean,
+ value: safeAreaInsetBottom
+ }
+ },
+
+ created() {
+ getSafeArea().then(({ isIPhoneX, statusBarHeight }) => {
+ this.set({ isIPhoneX, statusBarHeight });
+ });
+ }
+ });
diff --git a/packages/nav-bar/README.md b/packages/nav-bar/README.md
index 50fa6efa..9765cc67 100644
--- a/packages/nav-bar/README.md
+++ b/packages/nav-bar/README.md
@@ -56,6 +56,7 @@ Page({
| fixed | 是否固定在顶部 | `Boolean` | `false` |
| border | 是否显示下边框 | `Boolean` | `true` |
| z-index | 元素 z-index | `Number` | `1` |
+| safe-area-inset-top | 是否留出顶部安全距离(状态栏高度) | `Boolean` | `true` |
### Slot
@@ -78,9 +79,3 @@ Page({
|-----------|-----------|
| custom-class | 根节点样式类 |
| title-class | 标题样式类 |
-
-### 更新日志
-
-| 版本 | 类型 | 内容 |
-|-----------|-----------|-----------|
-| 0.0.1 | feature | 新增组件 |
diff --git a/packages/nav-bar/index.less b/packages/nav-bar/index.less
index b0eb5121..852a1283 100644
--- a/packages/nav-bar/index.less
+++ b/packages/nav-bar/index.less
@@ -2,8 +2,8 @@
.van-nav-bar {
position: relative;
- height: 46px;
- line-height: 46px;
+ height: @nav-bar-height;
+ line-height: @nav-bar-height;
text-align: center;
background-color: @white;
user-select: none;
diff --git a/packages/nav-bar/index.ts b/packages/nav-bar/index.ts
index 7f04b1af..c405331f 100644
--- a/packages/nav-bar/index.ts
+++ b/packages/nav-bar/index.ts
@@ -1,6 +1,9 @@
import { VantComponent } from '../common/component';
+import { safeArea } from '../mixins/safe-area';
VantComponent({
+ mixins: [safeArea({ safeAreaInsetTop: true })],
+
classes: ['title-class'],
props: {
@@ -15,7 +18,7 @@ VantComponent({
},
zIndex: {
type: Number,
- value: 1
+ value: 120
}
},
diff --git a/packages/nav-bar/index.wxml b/packages/nav-bar/index.wxml
index e1b4fc53..2f235b5a 100644
--- a/packages/nav-bar/index.wxml
+++ b/packages/nav-bar/index.wxml
@@ -1,6 +1,8 @@
+
+
diff --git a/packages/notify/README.md b/packages/notify/README.md
index b9d2f7e1..4a651b39 100644
--- a/packages/notify/README.md
+++ b/packages/notify/README.md
@@ -49,9 +49,4 @@ Notify({
| color | 字体颜色 | `String` | `#fff` | |
| backgroundColor | 背景色 | `String` | `#f44` |
| context | 选择器的选择范围,可以传入自定义组件的 this 作为上下文 | `Object` | 当前页面 |
-
-### 更新日志
-
-| 版本 | 类型 | 内容 |
-|-----------|-----------|-----------|
-| 0.0.1 | feature | 新增组件 |
+| safe-area-inset-top | 是否留出顶部安全距离(状态栏高度 + 导航栏高度) | `Boolean` | `false` |
diff --git a/packages/notify/index.less b/packages/notify/index.less
index ae7aa0f7..265b1305 100644
--- a/packages/notify/index.less
+++ b/packages/notify/index.less
@@ -11,4 +11,8 @@
text-align: center;
word-break: break-all;
box-sizing: border-box;
+
+ &__safe-top {
+ height: @nav-bar-height;
+ }
}
diff --git a/packages/notify/index.ts b/packages/notify/index.ts
index f3604b20..ae34bc33 100644
--- a/packages/notify/index.ts
+++ b/packages/notify/index.ts
@@ -1,7 +1,10 @@
import { VantComponent } from '../common/component';
import { RED } from '../common/color';
+import { safeArea } from '../mixins/safe-area';
VantComponent({
+ mixins: [safeArea()],
+
props: {
text: String,
color: {
diff --git a/packages/notify/index.wxml b/packages/notify/index.wxml
index e55f859f..4f480eaa 100644
--- a/packages/notify/index.wxml
+++ b/packages/notify/index.wxml
@@ -2,7 +2,8 @@
name="slide-down"
show="{{ show }}"
custom-class="van-notify"
- custom-style="background-color:{{ backgroundColor }}; color: {{ color }}"
+ custom-style="background-color:{{ backgroundColor }}; color: {{ color }};"
>
+
{{ text }}
diff --git a/packages/notify/notify.ts b/packages/notify/notify.ts
index f651552e..dcc23b64 100644
--- a/packages/notify/notify.ts
+++ b/packages/notify/notify.ts
@@ -1,9 +1,13 @@
import { isObj } from '../common/utils';
type NotifyOptions = {
- selector?: string;
+ text: string;
+ color?: string;
+ backgroundColor?: string;
duration?: number;
+ selector?: string;
context?: any;
+ safeAreaInsetTop?: boolean;
};
const defaultOptions = {
@@ -11,8 +15,8 @@ const defaultOptions = {
duration: 3000
};
-function parseOptions(text) {
- return isObj(text) ? text : { text };
+function parseOptions(text: NotifyOptions | string): NotifyOptions {
+ return isObj(text) ? text as NotifyOptions : { text } as NotifyOptions;
}
function getContext() {
@@ -20,7 +24,7 @@ function getContext() {
return pages[pages.length - 1];
}
-export default function Notify(options: NotifyOptions = {}) {
+export default function Notify(options: NotifyOptions | string) {
options = Object.assign({}, defaultOptions, parseOptions(options));
const context = options.context || getContext();
diff --git a/packages/popup/README.md b/packages/popup/README.md
index dedb72f3..4a76e24b 100644
--- a/packages/popup/README.md
+++ b/packages/popup/README.md
@@ -54,7 +54,8 @@ Page({
| custom-style | 自定义弹出层样式 | `String` | `` |
| overlay-style | 自定义背景蒙层样式 | `String` | `` |
| close-on-click-overlay | 点击蒙层是否关闭 Popup | `Boolean` | `true` |
-| safe-area-inset-bottom | 是否适配iPhoneX | `Boolean` | `true` |
+| safe-area-inset-bottom | 是否为iPhoneX留出底部安全距离 | `Boolean` | `true` |
+| safe-area-inset-top | 是否留出顶部安全距离(状态栏高度 + 导航栏高度) | `Boolean` | `false` |
### Event
diff --git a/packages/popup/index.less b/packages/popup/index.less
index 8eb1343e..d322ff5f 100644
--- a/packages/popup/index.less
+++ b/packages/popup/index.less
@@ -50,9 +50,20 @@
transform: translate3d(0, -50%, 0);
}
- &--safe {
+ &--bottom&--safe {
padding-bottom: @safe-area-inset-bottom;
}
+
+ &--left &__safe-top,
+ &--right &__safe-top,
+ &--top &__safe-top {
+ height: @nav-bar-height;
+ }
+
+ &--center &__safe-top,
+ &--bottom &__safe-top {
+ padding-top: 0 !important;
+ }
}
.van-scale-enter-active,
diff --git a/packages/popup/index.ts b/packages/popup/index.ts
index da23e5f6..6037e821 100644
--- a/packages/popup/index.ts
+++ b/packages/popup/index.ts
@@ -1,6 +1,6 @@
import { VantComponent } from '../common/component';
import { transition } from '../mixins/transition';
-import { iphonex } from '../mixins/iphonex';
+import { safeArea } from '../mixins/safe-area';
VantComponent({
classes: [
@@ -12,7 +12,7 @@ VantComponent({
'leave-to-class'
],
- mixins: [transition(false), iphonex],
+ mixins: [transition(false), safeArea()],
props: {
transition: {
diff --git a/packages/popup/index.wxml b/packages/popup/index.wxml
index 6d38e13b..9c53b381 100644
--- a/packages/popup/index.wxml
+++ b/packages/popup/index.wxml
@@ -11,9 +11,10 @@
/>
diff --git a/packages/submit-bar/README.md b/packages/submit-bar/README.md
index 869e0423..2d8a829c 100644
--- a/packages/submit-bar/README.md
+++ b/packages/submit-bar/README.md
@@ -74,7 +74,7 @@
| disabled | 是否禁用按钮 | `Boolean` | `false` |
| loading | 是否显示加载中的按钮 | `Boolean` | `false` |
| currency | 货币符号 | `String` | `¥` |
-| safe-area-inset-bottom | 是否适配iPhoneX | `Boolean` | `true` |
+| safe-area-inset-bottom | 是否为iPhoneX留出底部安全距离 | `Boolean` | `true` |
### Event
@@ -98,10 +98,3 @@
| price-class | 价格样式类 |
| button-class | 按钮样式类 |
| bar-class | 订单栏样式类 |
-
-### 更新日志
-
-| 版本 | 类型 | 内容 |
-|-----------|-----------|-----------|
-| 0.3.3 | feature | 新增组件 |
-| 0.3.4 | bugfix | 修复金额为空时仍然显示合计的问题 |
diff --git a/packages/submit-bar/index.ts b/packages/submit-bar/index.ts
index 252fb806..f501762f 100644
--- a/packages/submit-bar/index.ts
+++ b/packages/submit-bar/index.ts
@@ -1,8 +1,8 @@
import { VantComponent } from '../common/component';
-import { iphonex } from '../mixins/iphonex';
+import { safeArea } from '../mixins/safe-area';
VantComponent({
- mixins: [iphonex],
+ mixins: [safeArea()],
classes: [
'bar-class',
diff --git a/packages/tabbar/README.md b/packages/tabbar/README.md
index 98e3c4fa..e34c36cb 100644
--- a/packages/tabbar/README.md
+++ b/packages/tabbar/README.md
@@ -109,7 +109,7 @@ Page({
| active-color | 选中标签的颜色 | `String` | `#1989fa` |
| fixed | 是否固定在底部 | `Boolean` | `true` |
| z-index | 元素 z-index | `Number` | `1` |
-| safe-area-inset-bottom | 是否适配iPhoneX | `Boolean` | `true` |
+| safe-area-inset-bottom | 是否为iPhoneX留出底部安全距离 | `Boolean` | `true` |
### Tabbar Event
diff --git a/packages/tabbar/index.ts b/packages/tabbar/index.ts
index cd95dae1..b85a277a 100644
--- a/packages/tabbar/index.ts
+++ b/packages/tabbar/index.ts
@@ -1,8 +1,8 @@
import { VantComponent } from '../common/component';
-import { iphonex } from '../mixins/iphonex';
+import { safeArea } from '../mixins/safe-area';
VantComponent({
- mixins: [iphonex],
+ mixins: [safeArea()],
relation: {
name: 'tabbar-item',