8000 feat: updated $showModal · vuejsadmin/nativescript-vue@b2be4bd · GitHub
[go: up one dir, main page]

Skip to content

Commit b2be4bd

Browse files
committed
feat: updated $showModal
1 parent a5085f1 commit b2be4bd

File tree

92 files changed

+191
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+191
-124
lines changed

platform/nativescript/plugins/modal-plugin.js

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,72 @@
1-
import { ensurePage } from '../util'
1+
function _findParentModalEntry(vm) {
2+
if (!vm) {
3+
return false
4+
}
5+
6+
let entry = vm.$parent
7+
while (entry && entry.$options.name !== 'ModalEntry') {
8+
entry = entry.$parent
9+
}
10+
11+
return entry
12+
}
213

314
export default {
415
install(Vue) {
5-
Vue.prototype.$showModal = function(
6-
component,
7-
options = { context: null, fullscreen: false }
8-
) {
16+
Vue.mixin({
17+
created() {
18+
const self = this
19+
this.$modal = {
20+
close(data) {
21+
const entry = _findParentModalEntry(self)
22+
23+
if (entry) {
24+
entry.closeCb(data)
25+
}
26+
}
27+
}
28+
}
29+
})
30+
31+
Vue.prototype.$showModal = function(component, options) {
32+
const defaultOptions = {
33+
fullscreen: false
34+
}
35+
// build options object with defaults
36+
options = Object.assign({}, defaultOptions, options)
37+
938
return new Promise(resolve => {
10-
const contentComponent = Vue.extend(component)
11-
const vm = new contentComponent(options.context)
39+
let resolved = false
40+
const closeCb = data => {
41+
if (resolved) return
1242

13-
vm.$mount()
14-
const modalPage = ensurePage(vm.$el, vm)
43+
resolved = true
44+
resolve(data)
45+
modalPage.closeModal()
1546

16-
contentComponent.prototype.$modal = {
17-
close(data) {
18-
resolve(data)
19-
modalPage.closeModal()
20-
}
47+
// emitted to show up in devtools
48+
// for debugging purposes
49+
navEntryInstance.$emit('modal:close', data)
50+
navEntryInstance.$destroy()
2151
}
2252

23-
this.$root.$el.nativeView.showModal(
53+
const navEntryInstance = new Vue({
54+
name: 'ModalEntry',
55+
parent: this.$root,
56+
methods: {
57+
closeCb
58+
},
59+
render: h =>
60+
h(component, {
61+
props: options.props
62+
})
63+
})
64+
const modalPage = navEntryInstance.$mount().$el.nativeView
65+
66+
this.$el.nativeView.showModal(
2467
modalPage,
2568
null,
26-
vm.$modal.close,
69+
closeCb,
2770
options.fullscreen
2871
)
2972
})

platform/nativescript/plugins/navigator-plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ function _findParentNavigationEntry(vm) {
3434

3535
export default {
3636
install(Vue) {
37-
Vue.prototype.$navigateBack = function(options) {
37+
Vue.prototype.$navigateBack = function(options, backstackEntry = null) {
3838
const navEntry = _findParentNavigationEntry(this)
3939
const defaultOptions = {
4040
frame: navEntry ? navEntry.$options.frame : 'default'
4141
}
4242
options = Object.assign({}, defaultOptions, options)
4343
const frame = getFrameInstance(options.frame)
4444

45-
frame.back()
45+
frame.back(backstackEntry)
4646
}
4747

4848
Vue.prototype.$navigateTo = function(component, options) {

samples/app/App_Resources/Android/AndroidManifest.xml

Lines changed: 0 additions & 43 deletions
This file was deleted.

samples/app/App_Resources/Android/app.gradle

100755100644
Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
// Add your native dependencies here:
22

3-
// Uncomment to add recyclerview-v7 dependency
4-
//dependencies {
5-
// compile 'com.android.support:recyclerview-v7:+'
6-
//}
7-
8-
android {
3+
android {
94
defaultConfig {
105
generatedDensities = []
11-
applicationId = "org.nativescript.vuesample"
12-
13-
//override supported platforms
14-
// ndk {
15-
// abiFilters.clear()
16-
// abiFilters "armeabi-v7a"
17-
// }
18-
19-
}
6+
applicationId = "org.nativescript.application"
7+
}
208
aaptOptions {
219
additionalParameters "--no-version-vectors"
2210
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest
3+
xmlns:android="http://schemas.android.com/apk/res/android" package="__PACKAGE__" android:versionCode="10000" android:versionName="1.0.0">
4+
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
5+
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="__APILEVEL__" />
6+
<uses-permission android:name="android.permission.INTERNET" />
7+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
8+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
9+
<application android:name="com.tns.NativeScriptApplication" android:allowBackup="true" android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/AppTheme">
10+
<activity android:name="com.tns.NativeScriptActivity" android:label="@string/title_activity_kimera" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/LaunchScreenTheme">
11+
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
12+
<intent-filter>
13+
<action android:name="android.intent.action.MAIN" />
14+
<category android:name="android.intent.category.LAUNCHER" />
15+
</intent-filter>
16+
</activity>
17+
<activity android:name="com.tns.ErrorReportActivity" />
18+
</application>
19+
</manifest>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="app_name">NativeScript-Vue Application</string>
4+
<string name="title_activity_kimera">NativeScript-Vue Application</string>
5+
</resources>

samples/app/App_Resources/Android/values-v21/styles.xml renamed to samples/app/App_Resources/Android/src/main/res/values-v21/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919

2020
<style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
2121
<item name="android:elevation">4dp</item>
22-
</style>
22+
</style>
2323
</resources>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="app_name">NativeScript-Vue Application</string>
4+
<string name="title_activity_kimera">NativeScript-Vue Application</string>
5+
</resources>

samples/app/App_Resources/Android/values/styles.xml renamed to samples/app/App_Resources/Android/src/main/res/values/styles.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
<item name="android:windowActionBarOverlay">true</item>
1515
<item name="android:windowTranslucentStatus">true</item>
16-
1716
</style>
1817

1918
<style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
@@ -26,7 +25,6 @@
2625
<item name="colorPrimary">@color/ns_primary</item>
2726
<item name="colorPrimaryDark">@color/ns_primaryDark</item>
2827
<item name="colorAccent">@color/ns_accent</item>
29-
3028
</style>
3129

3230
<style name="AppTheme" parent="AppThemeBase">
@@ -37,9 +35,8 @@
3735
<item name="android:background">@color/ns_primary</item>
3836
<item name="theme">@style/ThemeOverlay.AppCompat.ActionBar</item>
3937
<item name="popupTheme">@style/ThemeOverlay.AppCompat</item>
40-
4138
</style>
4239

4340
<style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
4441
</style>
45-
</resources>
42+
</resources>

samples/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json

100755100644
Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@
3030
"filename" : "icon-40@3x.png",
3131
"scale" : "3x"
3232
},
33-
{
34-
"size" : "57x57",
35-
"idiom" : "iphone",
36-
"filename" : &quo 10000 t;icon-57.png",
37-
"scale" : "1x"
38-
},
39-
{
40-
"size" : "57x57",
41-
"idiom" : "iphone",
42-
"filename" : "icon-57@2x.png",
43-
"scale" : "2x"
44-
},
4533
{
4634
"size" : "60x60",
4735
"idiom" : "iphone",
@@ -78,30 +66,6 @@
7866
"filename" : "icon-40@2x.png",
7967
"scale" : "2x"
8068
},
81-
{
82-
"size" : "50x50",
83-
"idiom" : "ipad",
84-
"filename" : "icon-50.png",
85-
"scale" : "1x"
86-
},
87-
{
88-
"size" : "50x50",
89-
"idiom" : "ipad",
90-
"filename" : "icon-50@2x.png",
91-
"scale" : "2x"
92-
},
93-
{
94-
"size" : "72x72",
95-
"idiom" : "ipad",
96-
"filename" : "icon-72.png",
97-
"scale" : "1x"
98-
},
99-
{
100-
"size" : "72x72",
101-
"idiom" : "ipad",
102-
"filename" : "icon-72@2x.png",
103-
"scale" : "2x"
104-
},
10569
{
10670
"size" : "76x76",
10771
"idiom" : "ipad",
@@ -119,7 +83,13 @@
11983
"idiom" : "ipad",
12084
"filename" : "icon-83.5@2x.png",
12185
"scale" : "2x"
122-
}
86+
},
87+
{
88+
"size" : "1024x1024",
89+
"idiom" : "ios-marketing",
90+
"filename" : "icon-1024.png",
91+
"scale" : "1x"
92+
}
12393
],
12494
"info" : {
12595
"version" : 1,
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

samples/app/App_Resources/iOS/Assets.xcassets/Contents.json

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json

100755100644
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
{
22
"images" : [
3+
{
4+
"extent" : "full-screen",
5+
"idiom" : "iphone",
6+
"subtype" : "2436h",
7+
"filename" : "Default-1125h.png",
8+
"minimum-system-version" : "11.0",
9+
"orientation" : "portrait",
10+
"scale" : "3x"
11+
},
12+
{
13+
"orientation" : "landscape",
14+
"idiom" : "iphone",
15+
"extent" : "full-screen",
16+
"filename" : "Default-Landscape-X.png",
17+
"minimum-system-version" : "11.0",
18+
"subtype" : "2436h",
19+
"scale" : "3x"
20+
},
321
{
422
"extent" : "full-screen",
523
"idiom" : "iphone",

samples/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png

100755100644
File mode changed.

samples/app/App_Resources/iOS/Info.plist

100755100644
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<key>CFBundleDevelopmentRegion</key>
66
<string>en</string>
77
<key>CFBundleDisplayName</key>
8-
<string>${PRODUCT_NAME}</string>
8+
<string>NativeScript-Vue Application</string>
99
<key>CFBundleExecutable</key>
1010
<string>${EXECUTABLE_NAME}</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0</string>
18+
<string>1.0.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>1.0</string>
22+
<string>1.0.0</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UILaunchStoryboardName</key>

samples/app/App_Resources/iOS/LaunchScreen.storyboard

100755100644
File mode changed.

samples/app/App_Resources/iOS/build.xcconfig

100755100644
File mode changed.

0 commit comments

Comments
 (0)
0