Skip to content
This repository was archived by the owner on Jun 15, 2024. It is now read-only.

Commit 1bf80c7

Browse files
committed
fix(eveyrthing): upgrade to NativeScript 3.0.0
This release is almost a full rewrite and fixes a number of issues as well as being made compatible with NativeScript 3. Close #8, close #15, close #16, close #18. Also related is #17. BREAKING CHANGE: The plugin no longer auto-registers a tag in Angular applications. Instructions to register a `PDFView` element have been added to the project README.
1 parent 18ac92c commit 1bf80c7

File tree

104 files changed

+1581
-932
lines changed

Some content is hidden

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

104 files changed

+1581
-932
lines changed

.gitignore

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
*.js
22
*.js.map
33
*.log
4-
/demo/app/*.js
5-
/demo/*.d.ts
6-
/demo/lib
7-
/demo/platforms
8-
/demo/node_modules
9-
/node_modules
4+
!scripts/*.js
5+
demo/app/*.js
6+
!demo/karma.conf.js
7+
!demo/app/tests/*.js
8+
demo/*.d.ts
9+
!demo/references.d.ts
10+
demo/lib
11+
demo/platforms
12+
demo/node_modules
13+
node_modules

.npmignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
demo/
2+
screenshots/
3+
*.gif
24
*.png
3-
*.log
5+
*.log
6+
*.map
7+
*.ts
8+
!*.d.ts

.vscode/settings.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Place your settings in this file to overwrite default and user settings.
21
{
32
"files.exclude": {
43
"**/*.js": {

AndroidPdfViewer.d.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ declare class Configurator {
3939
pages(...pageNumbers: number[]): this;
4040
enableDoubletap(enable: boolean): this;
4141
enableSwipe(enable: boolean): this;
42-
onLoad(onLoadCompleteListener: pdfviewer.listener.OnLoadCompleteListener): this;
42+
onLoad(
43+
onLoadCompleteListener: pdfviewer.listener.OnLoadCompleteListener
44+
): this;
4345
swipeHorizontal(horizontal: boolean): this;
44-
}
46+
}

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
The MIT License (MIT)
22

33
nativescript-pdf-view
4-
Copyright (c) 2016, Merott Movahedi
4+
Copyright (c) 2017, Merott Movahedi
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in

README.md

+29-34
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,42 @@
1-
# nativescript-pdf-view
1+
# NativeScript PDFView
22

3-
This is a very basic PDF view implementation that does only one thing, and
4-
that is to display PDF files. It conveniently uses the iOS `UIWebView`, but
5-
for Android it uses [AndroidPdfViewer](https://github.com/barteksc/AndroidPdfViewer).
3+
A minimal PDF view implementation that does only one thing, and that is to display PDF files in the simplest way possible. It conveniently uses the iOS `WKWebView`, and for Android it uses [`AndroidPdfViewer`](https://github.com/barteksc/AndroidPdfViewer).
64

7-
This plugin does the bare minimum required to render the PDF, no configuration
8-
options, and no error handling have been built yet. I welcome all Pull Requests!
5+
This plugin does the bare minimum required to render the PDF, no configuration options, and no error handling have been built yet. I welcome all Pull Requests!
96

10-
# Usage
7+
My aim is to keep the features consistent across iOS and Android.
118

12-
##
9+
## Installation
1310

14-
Check out the [demo](./demo) folder for a sample usage.
11+
```
12+
tns plugin add nativescript-pdf-view
13+
```
1514

16-
## Angular 2
15+
## Usage
1716

18-
If you're using the plugin with Angular 2, the plugin automatically registers
19-
`PDFView` as a valid tag for Angular templates. Usage is simple:
17+
### Vanilla NativeScript
2018

21-
1. Make sure to import `nativescript-pdf-view` somewhere in your code, e.g:
19+
```xml
20+
<Page
21+
xmlns="http://schemas.nativescript.org/tns.xsd"
22+
xmlns:pdf="nativescript-pdf-view"
23+
loaded="pageLoaded">
24+
<pdf:PDFView src="{{ pdfUrl }}" load="{{ onLoad }}" />
25+
</Page>
26+
```
2227

23-
```ts
24-
import 'nativescript-pdf-view';
25-
```
28+
### Angular NativeScript
2629

27-
2. Include the tag in your template:
30+
```ts
31+
import { PDFView } from 'nativescript-pdf-view';
32+
import { registerElement } from 'nativescript-angular';
33+
registerElement('PDFView', () => PDFView);
34+
```
2835

29-
```html
30-
<PDFView [src]="src" (load)="onLoad()"></PDFView>
31-
```
36+
```html
37+
<PDFView [src]="src" (load)="onLoad()"></PDFView>
38+
```
3239

33-
# Try the Demo
40+
## Demo
3441

35-
To try the demo, `cd` into the `demo` folder, and run the following commands:
36-
37-
```sh
38-
npm install
39-
40-
# iOS
41-
tns platform add ios
42-
tns run ios
43-
44-
# Android
45-
tns platform add android
46-
tns run android
47-
```
42+
Check out the [demo](./demo) folder for a demo application using this plugin. You can run the demo by executing `npm run demo.ios` and `npm run demo.android` from the root directory of the project.

demo/app/App_Resources/Android/AndroidManifest.xml

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="__PACKAGE__"
3+
package="com.merott.nativescriptpdfviewdemo"
44
android:versionCode="1"
55
android:versionName="1.0">
66

@@ -23,15 +23,18 @@
2323
android:allowBackup="true"
2424
android:icon="@drawable/icon"
2525
android:label="@string/app_name"
26-
android:theme="@style/AppTheme" >
26+
android:theme="@style/AppTheme">
27+
2728
<activity
2829
android:name="com.tns.NativeScriptActivity"
2930
android:label="@string/title_activity_kimera"
30-
android:configChanges="keyboardHidden|orientation|screenSize">
31+
android:configChanges="keyboardHidden|orientation|screenSize"
32+
android:theme="@style/LaunchScreenTheme">
3133

32-
<intent-filter>
33-
<action android:name="android.intent.action.MAIN" />
34+
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
3435

36+
<intent-filter>
37+
<action android:name="android.intent.action.MAIN" />
3538
<category android:name="android.intent.category.LAUNCHER" />
3639
</intent-filter>
3740
</activity>
+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +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-
//}
1+
android {
2+
defaultConfig {
3+
generatedDensities = []
4+
applicationId = "com.merott.nativescriptpdfviewdemo"
5+
}
6+
aaptOptions {
7+
additionalParameters "--no-version-vectors"
8+
}
9+
}
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="fill">
2+
<item>
3+
<bitmap android:gravity="fill" android:src="@drawable/background" />
4+
</item>
5+
<item>
6+
<bitmap android:gravity="center" android:src="@drawable/logo" />
7+
</item>
8+
</layer-list>
Binary file not shown.
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="ns_accent">#3d5afe</color>
4+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<!-- Application theme -->
5+
<style name="AppTheme" parent="AppThemeBase">
6+
<item name="android:datePickerStyle">@style/SpinnerDatePicker</item>
7+
<item name="android:timePickerStyle">@style/SpinnerTimePicker</item>
8+
</style>
9+
10+
<!-- Default style for DatePicker - in spinner mode -->
11+
<style name="SpinnerDatePicker" parent="android:Widget.Material.Light.DatePicker">
12+
<item name="android:datePickerMode">spinner</item>
13+
</style>
14+
15+
<!-- Default style for TimePicker - in spinner mode -->
16+
<style name="SpinnerTimePicker" parent="android:Widget.Material.Light.TimePicker">
17+
<item name="android:timePickerMode">spinner</item>
18+
</style>
19+
20+
<style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
21+
<item name="android:elevation">4dp</item>
22+
</style>
23+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="ns_primary">#F5F5F5</color>
4+
<color name="ns_primaryDark">#757575</color>
5+
<color name="ns_accent">#33B5E5</color>
6+
<color name="ns_blue">#272734</color>
7+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<!-- theme to use FOR launch screen-->
5+
<style name="LaunchScreenThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
6+
<item name="toolbarStyle">@style/NativeScriptToolbarStyle</item>
7+
8+
<item name="colorPrimary">@color/ns_primary</item>
9+
<item name="colorPrimaryDark">@color/ns_primaryDark</item>
10+
<item name="colorAccent">@color/ns_accent</item>
11+
12+
<item name="android:windowBackground">@drawable/splash_screen</item>
13+
14+
<item name="android:windowActionBarOverlay">true</item>
15+
<item name="android:windowTranslucentStatus">true</item>
16+
17+
</style>
18+
19+
<style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
20+
</style>
21+
22+
<!-- theme to use AFTER launch screen is loaded-->
23+
<style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
24+
<item name="toolbarStyle">@style/NativeScriptToolbarStyle</item>
25+
26+
<item name="colorPrimary">@color/ns_primary</item>
27+
<item name="colorPrimaryDark">@color/ns_primaryDark</item>
28+
<item name="colorAccent">@color/ns_accent</item>
29+
30+
</style>
31+
32+
<style name="AppTheme" parent="AppThemeBase">
33+
</style>
34+
35+
<!-- theme for actioon-bar -->
36+
<style name="NativeScriptToolbarStyleBase" parent="Widget.AppCompat.Toolbar">
37+
<item name="android:background">@color/ns_primary</item>
38+
<item name="theme">@style/ThemeOverlay.AppCompat.ActionBar</item>
39+
<item name="popupTheme">@style/ThemeOverlay.AppCompat</item>
40+
41+
</style>
42+
43+
<style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
44+
</style>
45+
</resources>

0 commit comments

Comments
 (0)