|
1 | 1 | import { setFrame, getFrame, deleteFrame } from '../../util/frame'
|
2 | 2 | import { extend } from 'shared/util'
|
| 3 | +import { isAndroid } from 'tns-core-modules/platform' |
3 | 4 |
|
4 | 5 | let idCounter = 1
|
5 | 6 |
|
6 |
| -const propMap = { |
7 |
| - transition: 'transition', |
8 |
| - 'ios:transition': 'transitioniOS', |
9 |
| - 'android:transition': 'transitionAndroid' |
10 |
| -} |
11 |
| - |
12 | 7 | export default {
|
13 | 8 | props: {
|
14 | 9 | id: {
|
15 | 10 | default: 'default'
|
16 | 11 | },
|
17 | 12 | transition: {
|
18 | 13 | type: [String, Object],
|
19 |
| - default: _ => ({ name: 'slide', duration: 200 }) |
| 14 | + required: false, |
| 15 | + default: null |
20 | 16 | },
|
21 | 17 | 'ios:transition': {
|
22 | 18 | type: [String, Object],
|
23 |
| - default: '' |
| 19 | + required: false, |
| 20 | + default: null |
24 | 21 | },
|
25 | 22 | 'android:transition': {
|
26 | 23 | type: [String, Object],
|
27 |
| - default: '' |
| 24 | + required: false, |
| 25 | + default: null |
28 | 26 | },
|
29 | 27 | // injected by the template compiler
|
30 | 28 | hasRouterView: {
|
@@ -60,49 +58,33 @@ export default {
|
60 | 58 | this.$slots.default
|
61 | 59 | )
|
62 | 60 | },
|
63 |
| - // computed: { |
64 |
| - // history() { |
65 |
| - // return (this.$router && this.$router.history) || {} |
66 |
| - // }, |
67 |
| - // |
68 |
| - // store() { |
69 |
| - // return this.history.store || {} |
70 |
| - // }, |
71 |
| - // |
72 |
| - // replacing() { |
73 |
| - // return this.store.operation === 'replace' |
74 |
| - // }, |
75 |
| - // |
76 |
| - // isGoingBack() { |
77 |
| - // return this.store && this.store.isGoingBack |
78 |
| - // ? ios |
79 |
| - // ? undefined |
80 |
| - // : true |
81 |
| - // : false |
82 |
| - // } |
83 |
| - // }, |
84 | 61 | methods: {
|
85 | 62 | _getFrame() {
|
86 | 63 | return this.$el.nativeView
|
87 | 64 | },
|
88 | 65 |
|
89 |
| - _composeTransition() { |
90 |
| - const result = {} |
91 |
| - |
92 |
| - for (const prop in propMap) { |
93 |
| - if (this[prop]) { |
94 |
| - const name = propMap[prop] |
95 |
| - result[name] = {} |
| 66 | + _ensureTransitionObject(transition) { |
| 67 | + if (typeof transition === 'string') { |
| 68 | + return { name: transition } |
| 69 | + } |
| 70 | + return transition |
| 71 | + }, |
96 | 72 |
|
97 |
| - if (typeof this[prop] === 'string') { |
98 |
| - result[name].name = this[prop] |
99 |
| - } else { |
100 |
| - extend(result[name], this[prop]) |
101 |
| - } |
102 |
| - } |
| 73 | + _composeTransition(entry) { |
| 74 | + const platformEntryProp = `transition${isAndroid ? 'Android' : 'iOS'}` |
| 75 | + const entryProp = entry[platformEntryProp] |
| 76 | + ? platformEntryProp |
| 77 | + : 'transition' |
| 78 | + const platformProp = `${isAndroid ? 'android' : 'ios'}:transition` |
| 79 | + const prop = this[platformProp] ? platformProp : 'transition' |
| 80 | + |
| 81 | + if (entry[entryProp]) { |
| 82 | + entry[entryProp] = this._ensureTransitionObject(entry[entryProp]) |
| 83 | + } else if (this[prop]) { |
| 84 | + entry[entryProp] = this._ensureTransitionObject(this[prop]) |
103 | 85 | }
|
104 | 86 |
|
105 |
| - return result |
| 87 | + return entry |
106 | 88 | },
|
107 | 89 |
|
108 | 90 | notifyPageMounted(pageVm) {
|
@@ -138,8 +120,7 @@ export default {
|
138 | 120 |
|
139 | 121 | entry.create = () => page
|
140 | 122 |
|
141 |
| - Object.assign(entry, this._composeTransition()) |
142 |
| - |
| 123 | + this._composeTransition(entry) |
143 | 124 | frame.navigate(entry)
|
144 | 125 | },
|
145 | 126 |
|
|
0 commit comments