Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit e0034dc

Browse files
authored
Merge pull request #13 from yezarela/refactor
v1.1.0
2 parents d6b0cd7 + 3709d7a commit e0034dc

File tree

97 files changed

+2169
-745
lines changed

Some content is hidden

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

97 files changed

+2169
-745
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
npm-debug.log
3-
*js
3+
*.js
4+
demo/platforms

.vscode/settings.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"editor.detectIndentation": false,
3+
"editor.tabSize": 4,
4+
"editor.insertSpaces": false,
5+
"editor.formatOnSave": true,
6+
7+
"prettier.singleQuote": true,
8+
"prettier.printWidth": 120,
9+
"prettier.tabWidth": 4,
10+
"prettier.typescriptEnable": ["typescript", "typescriptreact"],
11+
12+
"search.exclude": {
13+
"**/node_modules": true,
14+
"**/bower_components": true,
15+
".vscode/chrome": true
16+
},
17+
18+
"files.exclude": {
19+
"**/.git": true,
20+
"**/.svn": true,
21+
"**/.hg": true,
22+
"**/CVS": true,
23+
"**/.DS_Store": true,
24+
"**/*.js": { "when": "$(basename).ts" }
25+
}
26+
}

README.md

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,90 +10,93 @@ Nativescript image caching plugin using Fresco for Android and SDWebImageCache f
1010
tns plugin add nativescript-image-cache
1111
```
1212

13-
Support NativeScript 3.0.0 with Angular
13+
Support NativeScript ~3.0.0 with Angular
1414

15-
## Usage
1615

17-
Properties
18-
```
19-
stretch = "aspectFill" | "aspectFit" | "fill" | "none"
20-
src = "res://image"
21-
placeholder = "res://placeholder"
22-
23-
// Android Only
24-
placeholderStretch = "aspectFill" | "aspectFit" | "fill" | "none"
25-
radius = "10"
26-
rounded = "true"
27-
```
16+
## Properties
2817

29-
### Initialization
18+
| Property Name | Value | Platform |
19+
|:----------------------|:----------------------------------|:----------|
20+
| `stretch` | aspectFill, aspectFit, fill, none |ios,android|
21+
| `src` | string |ios,android|
22+
| `placeholder` | string |ios,android|
23+
| `placeholderStretch` | aspectFill, aspectFit, fill, none |android |
24+
| `radius` | number |android |
25+
| `rounded` | boolean |android |
3026

31-
#### Nativescript Angular
3227

33-
```
34-
import {initializeOnAngular} from "nativescript-image-cache";
28+
## Basic Usage
29+
30+
### Nativescript Angular
31+
32+
Initialization
33+
34+
```ts
35+
import { initializeOnAngular } from 'nativescript-image-cache';
36+
3537
export class AppComponent {
36-
constructor(){
37-
initializeOnAngular();
38-
}
38+
constructor () {
39+
initializeOnAngular();
40+
}
3941
}
4042
```
41-
After initialisation, the markup tag <NSImage></NSImage> can be used in templates of components.
4243

43-
```
44-
<NSImage #myImage stretch="aspectFill" radius="20" src="res://logo">
45-
</NSImage>
44+
Example usage:
45+
46+
```html
47+
<NSImage #myImage stretch="aspectFill" radius="20" src="res://logo">
48+
</NSImage>
4649
```
4750

48-
#### Nativescript VanillaJS/Typescript
51+
### Nativescript Vanilla
4952

50-
IF on android, need to initialise the plugin before using or clearing the cache, initialisation not required for iOS**
53+
Initialization (android only)
5154

52-
**Initialising on android - in app.js**
55+
```js
56+
const imageCache = require('nativescript-image-cache');
5357

54-
```
55-
var imageCache = require("nativescript-image-cache");
56-
if (application.android) {
57-
application.on("launch", () => {
58-
imageCache.initialize();
59-
});
60-
}
58+
if (application.android) {
59+
application.on('launch', () => {
60+
imageCache.initialize();
61+
});
62+
}
6163
```
6264

63-
After initialisation, add the namespace attribute `xmlns:IC="nativescript-image-cache"` to the opening page tag of xml. The markup tag `<IC:NSImage></IC:NSImage>` should be used to denote images.
65+
Example usage:
6466

65-
```
66-
<Page xmlns:IC="nativescript-image-cache">
67-
<GridLayout rows='*' columns='*'>
68-
<IC:NSImage stretch="fill" row="0"
69-
col="0" id="my-image-1" placeholder="urlToLocalPlaceholderImage"
70-
src="#image-url">
71-
</IC:NSImage>
72-
</GridLayout>
73-
</Page>
67+
```xml
68+
<Page xmlns:IC="nativescript-image-cache">
69+
<GridLayout rows='*' columns='*'>
70+
<IC:NSImage stretch="fill" row="0"
71+
col="0" placeholder="res://placeholder"
72+
src="res://logo">
73+
</IC:NSImage>
74+
</GridLayout>
75+
</Page>
7476
```
7577

76-
### Caching Image
78+
## Caching Image
7779

7880
Default cache purge time can be specified in number of days.
7981

80-
```
81-
import {setCacheLimit} from "nativescript-image-cache";
82+
```ts
83+
import { setCacheLimit } from 'nativescript-image-cache';
8284

83-
var cacheLimitInDays : number = 7;
85+
const cacheLimitInDays : number = 7;
8486
setCacheLimit(cacheLimitInDays);
8587
```
8688

87-
### Clearing Cache
89+
## Clearing Cache
8890

89-
Import the module, call the method `clearCache()` , default time is for SDWebImageCache is 7 days, and for Fresco is 60 days, after which cache is automatically cleared.
91+
Default cache time for SDWebImageCache is 7 days, and for Fresco is 60 days.
9092

91-
```
92-
import {clearCache} from "nativescript-image-cache";
93-
clearCache();
93+
```ts
94+
import { clearCache } from 'nativescript-image-cache';
95+
96+
clearCache();
9497
```
9598

96-
**for android, you need to initialize in the application onlaunch event before clearing the cache**
99+
**(Android Only), you need to initialize in the application onlaunch event before clearing the cache**
97100

98101

99102
## Credits
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="__PACKAGE__"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
7+
<supports-screens
8+
android:smallScreens="true"
9+
android:normalScreens="true"
10+
android:largeScreens="true"
11+
android:xlargeScreens="true"/>
12+
13+
<uses-sdk
14+
android:minSdkVersion="17"
15+
android:targetSdkVersion="__APILEVEL__"/>
16+
17+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
18+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
19+
<uses-permission android:name="android.permission.INTERNET"/>
20+
21+
<application
22+
android:name="com.tns.NativeScriptApplication"
23+
android:allowBackup="true"
24+
android:icon="@drawable/icon"
25+
android:label="@string/app_name"
26+
android:theme="@style/AppTheme">
27+
28+
<activity
29+
android:name="com.tns.NativeScriptActivity"
30+
android:label="@string/title_activity_kimera"
31+
android:configChanges="keyboardHidden|orientation|screenSize"
32+
android:theme="@style/LaunchScreenTheme">
33+
34+
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
35+
36+
<intent-filter>
37+
<action android:name="android.intent.action.MAIN" />
38+
<category android:name="android.intent.category.LAUNCHER" />
39+
</intent-filter>
40+
</activity>
41+
<activity android:name="com.tns.ErrorReportActivity"/>
42+
</application>
43+
</manifest>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 {
10+
generatedDensities = []
11+
applicationId = "org.nativescript.demo"
12+
}
13+
aaptOptions {
14+
additionalParameters "--no-version-vectors"
15+
}
16+
}
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)