Skip to content

Commit

Permalink
Merge pull request #2 from FinanzRitter/feat/ns7-migration
Browse files Browse the repository at this point in the history
Feat/ns7 migration
  • Loading branch information
sc85 authored Nov 13, 2020
2 parents 15886da + 2b064b9 commit 961295f
Show file tree
Hide file tree
Showing 38 changed files with 13,564 additions and 7,070 deletions.
72 changes: 36 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Send/Share files to other apps.

Android Intent, IOS InteractionController:

<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">
<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">



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

~~~
npm install nativescript-share-file
npm install @finanzritter/nativescript-share-file
~~~

## Usage

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

```TypeScript
import { ShareFile } from 'nativescript-share-file';
import * as fs from 'tns-core-modules/file-system';

export class TestClass{

shareFile;
fileName;
documents;
path;
file;

constructor() {

this.fileName = 'text.txt';
this.documents = fs.knownFolders.documents();
this.path = fs.path.join(this.documents.path, this.fileName);
this.file = fs.File.fromPath(this.path);
this.shareFile = new ShareFile();

this.shareFile.open( {
path: this.path,
intentTitle: 'Open text file with:', // optional Android
rect: { // optional iPad
x: 110,
y: 110,
width: 0,
height: 0
},
options: true, // optional iOS
animated: true // optional iOS
});
}
}

import { ShareFile } from '@finanzritter/nativescript-share-file';
import { Observable, knownFolders, path, File } from "@nativescript/core";

export class TestClass extends Observable {
shareFile;
fileName;
documents;
path;
file;

constructor() {
super();

this.fileName = 'test.txt';
this.documents = knownFolders.documents();
this.path = path.join(this.documents.path, this.fileName);
this.file = File.fromPath(this.path);

this.shareFile = new ShareFile();

this.shareFile.open({
path: this.path,
intentTitle: 'Open text file with:', // optional Android
rect: { // optional iPad
x: 110,
y: 110,
width: 0,
height: 0
},
options: true, // optional iOS
animated: true // optional iOS
});
}
}
```

### Arguments
Expand Down
33 changes: 33 additions & 0 deletions demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# NativeScript
hooks/
node_modules/
platforms/

# NativeScript Template
*.js.map
*.js
!webpack.config.js

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# General
.DS_Store
.AppleDouble
.LSOverride
.idea
.cloud
.project
tmp/
typings/

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
23 changes: 8 additions & 15 deletions demo/app/App_Resources/Android/app.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Add your native dependencies here:

// Uncomment to add recyclerview-v7 dependency
//dependencies {
// compile 'com.android.support:recyclerview-v7:+'
//}

android {
defaultConfig {
android {
defaultConfig {
generatedDensities = []
applicationId = "org.nativescript.demo"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
applicationId = "com.finanzritter.nativescript.sharefiledemo"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
5 changes: 5 additions & 0 deletions demo/app/App_Resources/Android/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Share File Demo</string>
<string name="title_activity_kimera">Share File Demo</string>
</resources>
2 changes: 1 addition & 1 deletion demo/app/App_Resources/iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<string>Share File Demo</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand Down
3 changes: 2 additions & 1 deletion demo/app/app.css
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import '~nativescript-theme-core/css/core.light.css';
@import "~@nativescript/theme/css/core.css";
@import "~@nativescript/theme/css/default.css";
5 changes: 2 additions & 3 deletions demo/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import "./bundle-config";
import * as application from 'tns-core-modules/application';
application.start({ moduleName: "main-page" });
import { Application } from "@nativescript/core";
Application.run({ moduleName: "main-page" });
9 changes: 0 additions & 9 deletions demo/app/bundle-config.ts

This file was deleted.

13 changes: 6 additions & 7 deletions demo/app/main-page.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import * as observable from 'tns-core-modules/data/observable';
import * as pages from 'tns-core-modules/ui/page';
import {HelloWorldModel} from './main-view-model';
import { EventData, Page } from "@nativescript/core";
import { HelloWorldModel } from "./main-view-model";

// Event handler for Page 'loaded' event attached in main-page.xml
export function pageLoaded(args: observable.EventData) {
// Get the event sender
let page = <pages.Page>args.object;
page.bindingContext = new HelloWorldModel();
export function pageLoaded(args: EventData) {
// Get the event sender
let page = <Page>args.object;
page.bindingContext = new HelloWorldModel();
}
25 changes: 11 additions & 14 deletions demo/app/main-view-model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Observable } from 'tns-core-modules/data/observable';
import { ShareFile } from 'nativescript-share-file';
import * as fs from 'tns-core-modules/file-system';
import { Observable, knownFolders, path, File } from "@nativescript/core";
import { ShareFile } from "@finanzritter/nativescript-share-file";

export class HelloWorldModel extends Observable {
shareFile: ShareFile;
Expand All @@ -12,38 +11,36 @@ export class HelloWorldModel extends Observable {
constructor() {
super();
this.fileName = 'report.txt';
this.documents = fs.knownFolders.documents();
this.path = fs.path.join(this.documents.path, this.fileName);
this.file = fs.File.fromPath(this.path);
this.documents = knownFolders.documents();
this.path = path.join(this.documents.path, this.fileName);
this.file = File.fromPath(this.path);

this.shareFile = new ShareFile();

try {
this.file.writeText('Send this txt to other apps').then( () => {
this.file.writeText('Send this txt to other apps').then(() => {
setTimeout(() => {
this.shareFile.open({
path: this.path,
intentTitle: 'Open text file with:',
rect: {
x: 110,
y: 110,
width: 0,
height: 0
x: 110,
y: 110,
width: 0,
height: 0
},
options: true,
animated: true
});
}, 3000);

} ).catch( (e) => {
}).catch((e) => {
console.log('Creating text file failed');
alert(JSON.stringify(e));
});
} catch (e) {
alert(e);
console.log('Error while creating text file');
}


}
}
108 changes: 0 additions & 108 deletions demo/app/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions demo/app/tests/tests.js

This file was deleted.

9 changes: 0 additions & 9 deletions demo/app/vendor-platform.android.ts

This file was deleted.

3 changes: 0 additions & 3 deletions demo/app/vendor-platform.ios.ts

This file was deleted.

Loading

0 comments on commit 961295f

Please sign in to comment.