Skip to content

Commit 9dab149

Browse files
authored
Merge pull request #8 from novemberfiveco-engineering/master
Convert to Typescript, Fix thread issue
2 parents 3fcb8cb + b0de8c8 commit 9dab149

File tree

4 files changed

+47
-32
lines changed

4 files changed

+47
-32
lines changed

index.js

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

index.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { NativeModules } from 'react-native';
2+
3+
const { RNPalette } = NativeModules;
4+
5+
export enum ISwatchType {
6+
vibrant = 'Vibrant',
7+
vibrantDark = 'Vibrant Dark',
8+
vibrantLight = 'Vibrant Light',
9+
muted = 'Video',
10+
mutedDark = 'Muted Dark',
11+
mutedLight = 'Muted Light',
12+
}
13+
14+
export interface ISwatch {
15+
color: string;
16+
}
17+
18+
export interface IPalette {
19+
[key: string]: ISwatch;
20+
}
21+
22+
const TAG = '[Palette]';
23+
export default class Palette {
24+
static getNamedSwatchesFromUrl(url: string): IPalette {
25+
__DEV__ && console.debug(TAG, 'getNamedSwatchesFromUrl', url);
26+
return RNPalette.getNamedSwatchesFromUrl(url);
27+
}
28+
29+
static getAllSwatchesFromUrl(url: string): ISwatch[] {
30+
__DEV__ && console.debug(TAG, 'getAllSwatchesFromUrl', url);
31+
return RNPalette.getAllSwatchesFromUrl(url);
32+
}
33+
34+
static getNamedSwatches(path: string): IPalette {
35+
__DEV__ && console.debug(TAG, 'getNamedSwatches', path);
36+
return RNPalette.getNamedSwatches(path);
37+
}
38+
39+
static getAllSwatches(path: string): ISwatch[] {
40+
__DEV__ && console.debug(TAG, 'getAllSwatches', path);
41+
return RNPalette.getAllSwatches(path);
42+
}
43+
}

ios/palette/Palette.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ - (void)startToAnalyzeForTargetMode:(PaletteTargetMode)mode withCallBack:(GetCol
366366

367367
- (void)startToAnalyzeImage{
368368

369-
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
369+
@synchronized (self) {
370370

371371
[self clearHistArray];
372372

@@ -458,7 +458,7 @@ - (void)startToAnalyzeImage{
458458
[self findMaxPopulation];
459459

460460
[self getSwatchForTarget];
461-
});
461+
};
462462

463463
}
464464

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
21
{
32
"name": "react-native-palette-full",
4-
"version": "1.0.6",
3+
"version": "1.0.8",
54
"description": "",
6-
"main": "index.js",
5+
"main": "index.ts",
76
"repository": {
87
"type": "git",
98
"url": "https://github.com/jerson/react-native-palette-full"

0 commit comments

Comments
 (0)