Skip to content

Commit e116892

Browse files
committed
feat: typeing & docs fix #54
1 parent 99511c1 commit e116892

File tree

2 files changed

+67
-9
lines changed

2 files changed

+67
-9
lines changed

README.MD

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,30 @@ pod 'RNImageMarker', :path => '../node_modules/react-native-image-marker'
5555
|`saveFormat`| `png` or `jpg` |
5656
|`textBackgroundStyle` | text background style |
5757

58+
```typescript
59+
export type TextMarkOption = {
60+
// image src, local image
61+
src: ImageSourcePropType,
62+
text: string,
63+
// if you set position you don't need to set X and Y
64+
X?: number,
65+
Y?: number,
66+
// eg. '#aacc22'
67+
color: string,
68+
fontName: string,
69+
fontSize: number,
70+
// scale image
71+
scale: number,
72+
// image quality
73+
quality: number,
74+
position?: Position,
75+
filename?: string,
76+
shadowStyle: ShadowLayerStyle,
77+
textBackgroundStyle: TextBackgroundStyle,
78+
saveFormat?: ImageFormat,
79+
}
80+
```
81+
5882
* `ImageMarkOption`
5983
6084
|name|description|
@@ -70,6 +94,24 @@ pod 'RNImageMarker', :path => '../node_modules/react-native-image-marker'
7094
|`filename` | set filename for the result |
7195
|`saveFormat`| `png` or `jpg`, default is `jpg` |
7296
97+
```typescript
98+
export type ImageMarkOption = {
99+
// image src, local image
100+
src: ImageSourcePropType,
101+
markerSrc: ImageSourcePropType,
102+
X?: number,
103+
Y?: number,
104+
// marker scale
105+
markerScale: number,
106+
// image scale
107+
scale: number,
108+
quality: number,
109+
position?: Position,
110+
filename?: string,
111+
saveFormat?: ImageFormat,
112+
}
113+
```
114+
73115
* `ShadowStyle`
74116
75117
|name|description|
@@ -79,6 +121,15 @@ pod 'RNImageMarker', :path => '../node_modules/react-native-image-marker'
79121
|`dy`| y offset|
80122
|`color`| shadow color |
81123
124+
```typescript
125+
export type ShadowLayerStyle = {
126+
'dx': number,
127+
'dy': number,
128+
'radius': number,
129+
'color': string
130+
}
131+
```
132+
82133
* `textBackgroundStyle`
83134
84135
> thanks [@onka13](https://github.com/onka13) for [#38](https://github.com/JimmyDaddy/react-native-image-marker/pull/38)
@@ -90,6 +141,13 @@ pod 'RNImageMarker', :path => '../node_modules/react-native-image-marker'
90141
|`type`| default is fit the text, `stretchX` stretch to fill width, `stretchY` stretch to fill height |
91142
|`color`| bg color |
92143
144+
```typescript
145+
export enum TextBackgroundType {
146+
stretchX = 'stretchX',
147+
stretchY = 'stretchY'
148+
}
149+
```
150+
93151
## Usage
94152

95153
```javascript

example/markerExample/App.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { TouchableOpacity, Image, View, Text, Platform, Dimensions, StyleSheet, ScrollView } from 'react-native'
3-
import Marker from 'react-native-image-marker'
3+
import Marker, { Position, ImageFormat } from 'react-native-image-marker'
44
import Picker from 'react-native-image-picker'
55
const icon = require('./icon.jpeg')
66
// const iconTP = require('./tpimage.png')
@@ -127,43 +127,43 @@ export default class MarkerTest extends React.Component {
127127
</TouchableOpacity>
128128
<TouchableOpacity
129129
style={s.btn}
130-
onPress={() => this._markByPosition('topLeft')}
130+
onPress={() => this._markByPosition(Position.topLeft)}
131131
>
132132
<Text style={s.text} >TopLeft</Text>
133133
</TouchableOpacity>
134134
<TouchableOpacity
135135
style={s.btn}
136-
onPress={() => this._markByPosition('topCenter')}
136+
onPress={() => this._markByPosition(Position.topCenter)}
137137
>
138138
<Text style={s.text} >topCenter</Text>
139139
</TouchableOpacity>
140140
<TouchableOpacity
141141
style={s.btn}
142-
onPress={() => this._markByPosition('topRight')}
142+
onPress={() => this._markByPosition(Position.topRight)}
143143
>
144144
<Text style={s.text} >topRight</Text>
145145
</TouchableOpacity>
146146
<TouchableOpacity
147147
style={s.btn}
148-
onPress={() => this._markByPosition('center')}
148+
onPress={() => this._markByPosition(Position.center)}
149149
>
150150
<Text style={s.text} >Center</Text>
151151
</TouchableOpacity>
152152
<TouchableOpacity
153153
style={s.btn}
154-
onPress={() => this._markByPosition('bottomLeft')}
154+
onPress={() => this._markByPosition(Position.bottomLeft)}
155155
>
156156
<Text style={s.text} >bottomLeft</Text>
157157
</TouchableOpacity>
158158
<TouchableOpacity
159159
style={s.btn}
160-
onPress={() => this._markByPosition('bottomCenter')}
160+
onPress={() => this._markByPosition(Position.bottomCenter)}
161161
>
162162
<Text style={s.text} >bottomCenter</Text>
163163
</TouchableOpacity>
164164
<TouchableOpacity
165165
style={s.btn}
166-
onPress={() => this._markByPosition('bottomRight')}
166+
onPress={() => this._markByPosition(Position.bottomRight)}
167167
>
168168
<Text style={s.text} >bottomRight</Text>
169169
</TouchableOpacity>
@@ -233,7 +233,7 @@ export default class MarkerTest extends React.Component {
233233
scale: 1,
234234
markerScale: 1,
235235
quality: 100,
236-
saveFormat: 'jpg'
236+
saveFormat: ImageFormat.jpg
237237
}).then((path) => {
238238
console.log('====================================')
239239
console.log(path)

0 commit comments

Comments
 (0)