Skip to content

Commit fa2b2f1

Browse files
committed
feat: upgrade to latest rn
1 parent ec96598 commit fa2b2f1

File tree

4 files changed

+26
-27
lines changed

4 files changed

+26
-27
lines changed

index.d.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react'
22
import {
3-
ViewProperties,
3+
ViewProps,
44
StyleProp,
55
ViewStyle
66
} from "react-native"
@@ -87,26 +87,31 @@ export interface SketchCanvasProps {
8787
onPathsChange?: (pathsCount: number) => void
8888
}
8989

90-
export class SketchCanvas extends React.Component<SketchCanvasProps & ViewProperties> {
90+
export class SketchCanvas extends React.Component<SketchCanvasProps & ViewProps> {
9191
clear(): void
9292
undo(): number
9393
addPath(data: Path): void
9494
deletePath(id: number): void
9595

9696
/**
97-
* @param imageType "png" or "jpg"
98-
* @param includeImage Set to `true` to include the image loaded from `LocalSourceImage`
99-
* @param includeText Set to `true` to include the text drawn from `Text`.
100-
* @param cropToImageSize Set to `true` to crop output image to the image loaded from `LocalSourceImage`
97+
* @param {imageType} imageType "png" or "jpg"
98+
* @param {boolean} transparent
99+
* @param {string} folder
100+
* @param {string} filename
101+
* @param {includeImage} includeImage Set to `true` to include the image loaded from `LocalSourceImage`
102+
* @param {includeText} includeText Set to `true` to include the text drawn from `Text`.
103+
* @param {boolean} cropToImageSize Set to `true` to crop output image to the image loaded from `LocalSourceImage`
101104
*/
102105
save(imageType: ImageType, transparent: boolean, folder: string, filename: string, includeImage: boolean, includeText: boolean, cropToImageSize: boolean): void
103106
getPaths(): Path[]
104107

105108
/**
106-
* @param imageType "png" or "jpg"
107-
* @param includeImage Set to `true` to include the image loaded from `LocalSourceImage`
108-
* @param includeText Set to `true` to include the text drawn from `Text`.
109-
* @param cropToImageSize Set to `true` to crop output image to the image loaded from `LocalSourceImage`
109+
* @param {imageType} imageType "png" or "jpg"
110+
* @param {boolean} transparent
111+
* @param {boolean} includeImage Set to `true` to include the image loaded from `LocalSourceImage`
112+
* @param {boolean} includeText Set to `true` to include the text drawn from `Text`.
113+
* @param {boolean} cropToImageSize Set to `true` to crop output image to the image loaded from `LocalSourceImage`
114+
* @param {*} callback
110115
*/
111116
getBase64(imageType: ImageType, transparent: boolean, includeImage: boolean, includeText: boolean, cropToImageSize: boolean, callback: (error: any, result?: string) => void): void
112117

@@ -156,15 +161,15 @@ export interface RNSketchCanvasProps {
156161
text?: CanvasText[]
157162
/**
158163
* {
159-
* path: string,
160-
* directory: string,
164+
* path: string,
165+
* directory: string,
161166
* mode: 'AspectFill' | 'AspectFit' | 'ScaleToFill'
162167
* }
163168
*/
164169
localSourceImage?: LocalSourceImage
165170
}
166171

167-
export default class RNSketchCanvas extends React.Component<RNSketchCanvasProps & ViewProperties> {
172+
export default class RNSketchCanvas extends React.Component<RNSketchCanvasProps & ViewProps> {
168173
clear(): void
169174
undo(): number
170175
addPath(data: Path): void

index.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3-
import ReactNative, {
4-
View,
5-
Text,
6-
TouchableOpacity,
7-
FlatList,
8-
ViewPropTypes,
9-
} from 'react-native'
3+
import { ViewPropTypes } from 'deprecated-react-native-prop-types'
4+
import { View, TouchableOpacity, FlatList } from 'react-native'
105
import SketchCanvas from './src/SketchCanvas'
116
import { requestPermissions } from './src/handlePermissions';
127

@@ -156,7 +151,7 @@ export default class RNSketchCanvas extends React.Component {
156151
this._sketchCanvas.save(p.imageType, p.transparent, p.folder ? p.folder : '', p.filename, p.includeImage !== false, p.includeText !== false, p.cropToImageSize || false)
157152
} else {
158153
const date = new Date()
159-
this._sketchCanvas.save('png', false, '',
154+
this._sketchCanvas.save('png', false, '',
160155
date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + ('0' + date.getDate()).slice(-2) + ' ' + ('0' + date.getHours()).slice(-2) + '-' + ('0' + date.getMinutes()).slice(-2) + '-' + ('0' + date.getSeconds()).slice(-2),
161156
true, true, false)
162157
}
@@ -282,4 +277,4 @@ RNSketchCanvas.CACHES = SketchCanvas.CACHES;
282277

283278
export {
284279
SketchCanvas
285-
}
280+
}

src/SketchCanvas.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
import React from 'react'
44
import PropTypes from 'prop-types'
5+
import { ViewPropTypes } from 'deprecated-react-native-prop-types'
56
import ReactNative, {
67
requireNativeComponent,
78
NativeModules,
89
UIManager,
910
PanResponder,
1011
PixelRatio,
1112
Platform,
12-
ViewPropTypes,
1313
processColor
1414
} from 'react-native'
1515
import { requestPermissions } from './handlePermissions';

src/handlePermissions.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PermissionsAndroid, Platform } from 'react-native';
1+
import {PermissionsAndroid, Platform} from 'react-native';
22

33
export const requestPermissions = async (permissionDialogTitle, permissionDialogMessage) => {
44
if (Platform.OS === 'android') {
@@ -10,8 +10,7 @@ export const requestPermissions = async (permissionDialogTitle, permissionDialog
1010
// On devices before SDK version 23, the permissions are automatically granted if they appear in the manifest,
1111
// so check and request should always be true.
1212
// https://github.com/facebook/react-native-website/blob/master/docs/permissionsandroid.md
13-
const isAuthorized = Platform.Version >= 23 ? granted === PermissionsAndroid.RESULTS.GRANTED : granted === true;
14-
return isAuthorized;
13+
return Platform.Version >= 23 ? granted === PermissionsAndroid.RESULTS.GRANTED : granted === true;
1514
}
1615
return true;
17-
}
16+
}

0 commit comments

Comments
 (0)