-
Notifications
You must be signed in to change notification settings - Fork 7
/
RNDigits.ios.js
52 lines (43 loc) · 1 KB
/
RNDigits.ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @providesModule react-native-digits
* @flow
*/
'use strict';
import React, { Component, PropTypes } from 'react';
import { NativeModules } from 'react-native';
const { RNDigits } = NativeModules
export default class Digits extends Component {
static logout() {
RNDigits.logout()
}
componentWillReceiveProps(props) {
if (props.visible && this.props.visible == false) {
this.show()
}
}
show() {
const { accentColor, backgroundColor } = this.props
const config = { accentColor, backgroundColor }
RNDigits.view(config, (err, session) => {
if (err) {
this.props.onError(err)
} else {
this.props.onLogin(session)
}
})
}
render() {
return false
}
}
Digits.propTypes = {
accentColor: PropTypes.string,
backgroundColor: PropTypes.string,
onError: PropTypes.func,
onLogin: PropTypes.func.isRequired,
visible: PropTypes.bool.isRequired,
}
Digits.defaultProps = {
onError: (err) => console.warn(err),
visible: false,
}