Skip to content

Commit

Permalink
Merge pull request #8 from novemberfiveco-engineering/master
Browse files Browse the repository at this point in the history
Convert to Typescript, Fix thread issue
  • Loading branch information
jerson authored Jun 6, 2019
2 parents 3fcb8cb + b0de8c8 commit 9dab149
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 32 deletions.
27 changes: 0 additions & 27 deletions index.js

This file was deleted.

43 changes: 43 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { NativeModules } from 'react-native';

const { RNPalette } = NativeModules;

export enum ISwatchType {
vibrant = 'Vibrant',
vibrantDark = 'Vibrant Dark',
vibrantLight = 'Vibrant Light',
muted = 'Video',
mutedDark = 'Muted Dark',
mutedLight = 'Muted Light',
}

export interface ISwatch {
color: string;
}

export interface IPalette {
[key: string]: ISwatch;
}

const TAG = '[Palette]';
export default class Palette {
static getNamedSwatchesFromUrl(url: string): IPalette {
__DEV__ && console.debug(TAG, 'getNamedSwatchesFromUrl', url);
return RNPalette.getNamedSwatchesFromUrl(url);
}

static getAllSwatchesFromUrl(url: string): ISwatch[] {
__DEV__ && console.debug(TAG, 'getAllSwatchesFromUrl', url);
return RNPalette.getAllSwatchesFromUrl(url);
}

static getNamedSwatches(path: string): IPalette {
__DEV__ && console.debug(TAG, 'getNamedSwatches', path);
return RNPalette.getNamedSwatches(path);
}

static getAllSwatches(path: string): ISwatch[] {
__DEV__ && console.debug(TAG, 'getAllSwatches', path);
return RNPalette.getAllSwatches(path);
}
}
4 changes: 2 additions & 2 deletions ios/palette/Palette.m
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ - (void)startToAnalyzeForTargetMode:(PaletteTargetMode)mode withCallBack:(GetCol

- (void)startToAnalyzeImage{

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
@synchronized (self) {

[self clearHistArray];

Expand Down Expand Up @@ -458,7 +458,7 @@ - (void)startToAnalyzeImage{
[self findMaxPopulation];

[self getSwatchForTarget];
});
};

}

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

{
"name": "react-native-palette-full",
"version": "1.0.6",
"version": "1.0.8",
"description": "",
"main": "index.js",
"main": "index.ts",
"repository": {
"type": "git",
"url": "https://github.com/jerson/react-native-palette-full"
Expand Down

0 comments on commit 9dab149

Please sign in to comment.