@@ -5,21 +5,21 @@ import { getSafeAreaInset } from 'react-native-pure-navigation-bar';
5
5
import Video from 'react-native-video' ;
6
6
import PageKeys from './PageKeys' ;
7
7
8
- const flashModeOrder = {
9
- off : 'on' ,
10
- on : 'auto' ,
11
- auto : 'off' ,
12
- } ;
13
8
export default class extends React . PureComponent {
14
9
static defaultProps = {
15
10
maxSize : 1 ,
16
11
sideType : RNCamera . Constants . Type . back ,
17
- flashMode : 'auto' ,
12
+ flashMode : 0 ,
18
13
videoQuality : RNCamera . Constants . VideoQuality [ "480p" ]
19
14
} ;
20
15
21
16
constructor ( props ) {
22
17
super ( props ) ;
18
+ this . flashModes = [
19
+ RNCamera . Constants . FlashMode . auto ,
20
+ RNCamera . Constants . FlashMode . off ,
21
+ RNCamera . Constants . FlashMode . on ,
22
+ ] ;
23
23
this . state = {
24
24
data : [ ] ,
25
25
isPreview : false ,
@@ -56,8 +56,17 @@ export default class extends React.PureComponent {
56
56
right : safeArea . right ,
57
57
} ;
58
58
const { flashMode} = this . state ;
59
- const image = flashMode === 'auto' ? require ( './images/flash_auto.png' ) :
60
- flashMode === 'on' ? require ( './images/flash_open.png' ) : require ( './images/flash_close.png' ) ;
59
+ let image ;
60
+ switch ( flashMode ) {
61
+ case 1 :
62
+ image = require ( './images/flash_close.png' ) ;
63
+ break ;
64
+ case 2 :
65
+ image = require ( './images/flash_open.png' ) ;
66
+ break ;
67
+ default :
68
+ image = require ( './images/flash_auto.png' ) ;
69
+ }
61
70
return (
62
71
< View style = { [ styles . top , style ] } >
63
72
{ ! this . props . isVideo && this . _renderTopButton ( image , this . _clickFlashMode ) }
@@ -80,7 +89,7 @@ export default class extends React.PureComponent {
80
89
ref = { cam => this . camera = cam }
81
90
type = { this . state . sideType }
82
91
defaultVideoQuality = { this . props . videoQuality }
83
- flashMode = { this . state . flashMode }
92
+ flashMode = { this . flashModes [ this . state . flashMode ] }
84
93
style = { styles . camera }
85
94
captureAudio = { true }
86
95
fixOrientation = { true }
@@ -260,9 +269,8 @@ export default class extends React.PureComponent {
260
269
} ;
261
270
262
271
_clickFlashMode = ( ) => {
263
- this . setState ( {
264
- flashMode : flashModeOrder [ this . state . flashMode ] ,
265
- } ) ;
272
+ const newMode = ( this . state . flashMode + 1 ) % this . flashModes . length ;
273
+ this . setState ( { flashMode : newMode } ) ;
266
274
} ;
267
275
268
276
_clickPreview = ( ) => {
0 commit comments