Skip to content

Commit 961295f

Browse files
authored
Merge pull request #2 from FinanzRitter/feat/ns7-migration
Feat/ns7 migration
2 parents 15886da + 2b064b9 commit 961295f

38 files changed

+13564
-7070
lines changed

README.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Send/Share files to other apps.
1616

1717
Android Intent, IOS InteractionController:
1818

19-
<img src="https://github.com/braune-digital/nativescript-share-file/blob/master/preview/preview-android.png?raw=true" width="250"> . <img src="https://github.com/braune-digital/nativescript-share-file/blob/master/preview/preview-ios.png?raw=true" width="250">
19+
<img src="https://github.com/FinanzRitter/nativescript-share-file/blob/master/preview/preview-android.png?raw=true" width="250"> . <img src="https://github.com/FinanzRitter/nativescript-share-file/blob/master/preview/preview-ios.png?raw=true" width="250">
2020

2121

2222

@@ -25,48 +25,48 @@ Android Intent, IOS InteractionController:
2525
Install the plugin in your app.
2626

2727
~~~
28-
npm install nativescript-share-file
28+
npm install @finanzritter/nativescript-share-file
2929
~~~
3030

3131
## Usage
3232

3333
Info: Shared files should be in the `documents` path.
3434

3535
```TypeScript
36-
import { ShareFile } from 'nativescript-share-file';
37-
import * as fs from 'tns-core-modules/file-system';
38-
39-
export class TestClass{
40-
41-
shareFile;
42-
fileName;
43-
documents;
44-
path;
45-
file;
46-
47-
constructor() {
48-
49-
this.fileName = 'text.txt';
50-
this.documents = fs.knownFolders.documents();
51-
this.path = fs.path.join(this.documents.path, this.fileName);
52-
this.file = fs.File.fromPath(this.path);
53-
this.shareFile = new ShareFile();
54-
55-
this.shareFile.open( {
56-
path: this.path,
57-
intentTitle: 'Open text file with:', // optional Android
58-
rect: { // optional iPad
59-
x: 110,
60-
y: 110,
61-
width: 0,
62-
height: 0
63-
},
64-
options: true, // optional iOS
65-
animated: true // optional iOS
66-
});
67-
}
68-
}
69-
36+
import { ShareFile } from '@finanzritter/nativescript-share-file';
37+
import { Observable, knownFolders, path, File } from "@nativescript/core";
38+
39+
export class TestClass extends Observable {
40+
shareFile;
41+
fileName;
42+
documents;
43+
path;
44+
file;
45+
46+
constructor() {
47+
super();
48+
49+
this.fileName = 'test.txt';
50+
this.documents = knownFolders.documents();
51+
this.path = path.join(this.documents.path, this.fileName);
52+
this.file = File.fromPath(this.path);
53+
54+
this.shareFile = new ShareFile();
55+
56+
this.shareFile.open({
57+
path: this.path,
58+
intentTitle: 'Open text file with:', // optional Android
59+
rect: { // optional iPad
60+
x: 110,
61+
y: 110,
62+
width: 0,
63+
height: 0
64+
},
65+
options: true, // optional iOS
66+
animated: true // optional iOS
67+
});
68+
}
69+
}
7070
```
7171

7272
### Arguments

demo/.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# NativeScript
2+
hooks/
3+
node_modules/
4+
platforms/
5+
6+
# NativeScript Template
7+
*.js.map
8+
*.js
9+
!webpack.config.js
10+
11+
# Logs
12+
logs
13+
*.log
14+
npm-debug.log*
15+
yarn-debug.log*
16+
yarn-error.log*
17+
18+
# General
19+
.DS_Store
20+
.AppleDouble
21+
.LSOverride
22+
.idea
23+
.cloud
24+
.project
25+
tmp/
26+
typings/
27+
28+
# Visual Studio Code
29+
.vscode/*
30+
!.vscode/settings.json
31+
!.vscode/tasks.json
32+
!.vscode/launch.json
33+
!.vscode/extensions.json
Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
// Add your native dependencies here:
2-
3-
// Uncomment to add recyclerview-v7 dependency
4-
//dependencies {
5-
// compile 'com.android.support:recyclerview-v7:+'
6-
//}
7-
8-
android {
9-
defaultConfig {
1+
android {
2+
defaultConfig {
103
generatedDensities = []
11-
applicationId = "org.nativescript.demo"
12-
}
13-
aaptOptions {
14-
additionalParameters "--no-version-vectors"
15-
}
16-
}
4+
applicationId = "com.finanzritter.nativescript.sharefiledemo"
5+
}
6+
aaptOptions {
7+
additionalParameters "--no-version-vectors"
8+
}
9+
}
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">Share File Demo</string>
4+
<string name="title_activity_kimera">Share File Demo</string>
5+
</resources>

demo/app/App_Resources/iOS/Info.plist

Lines changed: 1 addition & 1 deletion
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>Share File Demo</string>
99
<key>CFBundleExecutable</key>
1010
<string>${EXECUTABLE_NAME}</string>
1111
<key>CFBundleInfoDictionaryVersion</key>

demo/app/app.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
@import '~nativescript-theme-core/css/core.light.css';
1+
@import "~@nativescript/theme/css/core.css";
2+
@import "~@nativescript/theme/css/default.css";

demo/app/app.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
import "./bundle-config";
2-
import * as application from 'tns-core-modules/application';
3-
application.start({ moduleName: "main-page" });
1+
import { Application } from "@nativescript/core";
2+
Application.run({ moduleName: "main-page" });

demo/app/bundle-config.ts

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

demo/app/main-page.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import * as observable from 'tns-core-modules/data/observable';
2-
import * as pages from 'tns-core-modules/ui/page';
3-
import {HelloWorldModel} from './main-view-model';
1+
import { EventData, Page } from "@nativescript/core";
2+
import { HelloWorldModel } from "./main-view-model";
43

54
// Event handler for Page 'loaded' event attached in main-page.xml
6-
export function pageLoaded(args: observable.EventData) {
7-
// Get the event sender
8-
let page = <pages.Page>args.object;
9-
page.bindingContext = new HelloWorldModel();
5+
export function pageLoaded(args: EventData) {
6+
// Get the event sender
7+
let page = <Page>args.object;
8+
page.bindingContext = new HelloWorldModel();
109
}

demo/app/main-view-model.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { Observable } from 'tns-core-modules/data/observable';
2-
import { ShareFile } from 'nativescript-share-file';
3-
import * as fs from 'tns-core-modules/file-system';
1+
import { Observable, knownFolders, path, File } from "@nativescript/core";
2+
import { ShareFile } from "@finanzritter/nativescript-share-file";
43

54
export class HelloWorldModel extends Observable {
65
shareFile: ShareFile;
@@ -12,38 +11,36 @@ export class HelloWorldModel extends Observable {
1211
constructor() {
1312
super();
1413
this.fileName = 'report.txt';
15-
this.documents = fs.knownFolders.documents();
16-
this.path = fs.path.join(this.documents.path, this.fileName);
17-
this.file = fs.File.fromPath(this.path);
14+
this.documents = knownFolders.documents();
15+
this.path = path.join(this.documents.path, this.fileName);
16+
this.file = File.fromPath(this.path);
1817

1918
this.shareFile = new ShareFile();
2019

2120
try {
22-
this.file.writeText('Send this txt to other apps').then( () => {
21+
this.file.writeText('Send this txt to other apps').then(() => {
2322
setTimeout(() => {
2423
this.shareFile.open({
2524
path: this.path,
2625
intentTitle: 'Open text file with:',
2726
rect: {
28-
x: 110,
29-
y: 110,
30-
width: 0,
31-
height: 0
27+
x: 110,
28+
y: 110,
29+
width: 0,
30+
height: 0
3231
},
3332
options: true,
3433
animated: true
3534
});
3635
}, 3000);
3736

38-
} ).catch( (e) => {
37+
}).catch((e) => {
3938
console.log('Creating text file failed');
4039
alert(JSON.stringify(e));
4140
});
4241
} catch (e) {
4342
alert(e);
4443
console.log('Error while creating text file');
4544
}
46-
47-
4845
}
4946
}

0 commit comments

Comments
 (0)