Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Fix migration alert dialog #88

Merged
merged 3 commits into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 94 additions & 88 deletions lib/components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@
// Frameworks
import React from 'react'
import { connect } from 'react-redux'
import {
StyleSheet,
Text,
TouchableOpacity,
View,
Dimensions
} from 'react-native'
import { StyleSheet, Text, TouchableOpacity, View, Dimensions } from 'react-native'
import { debounce } from 'lodash'

// Components
Expand All @@ -33,10 +27,7 @@ import FAIcon from 'react-native-vector-icons/FontAwesome'
import AvatarNameHeader from './shared/AvatarNameHeader'
import Fab from './shared/Fab'
// Selectors
import {
currentAvatar,
currentName
} from 'uPortMobile/lib/selectors/identities'
import { currentAvatar, currentName } from 'uPortMobile/lib/selectors/identities'

// Styles
import { colors, font } from 'uPortMobile/lib/styles/globalStyles'
Expand All @@ -51,35 +42,33 @@ const styles = StyleSheet.create({
borderRadius: 19,
justifyContent: 'center',
width: 38,
height: 38
height: 38,
},
menuItem: {
alignItems: 'center',
backgroundColor: colors.white,
borderColor: colors.white216,
borderBottomWidth: 1,
flexDirection: 'row',
padding: 28
},
menuItemArrow: {
padding: 28,
},
menuItemArrow: {},
menuItemText: {
color: colors.grey74,
flexGrow: 1,
fontFamily: font,
fontSize: 20,
lineHeight: 27,
marginLeft: 13
}
marginLeft: 13,
},
})

// const analytics = new Analytics('TP9aPQLX69CtFXTtQtRmqGjUjNgRiRo3')

export let rootNavigator = {}

export class Home extends React.Component {

constructor (props) {
constructor(props) {
super()
rootNavigator = props.navigator
NavigationActions.setNavigator(props.navigator)
Expand All @@ -88,136 +77,153 @@ export class Home extends React.Component {
navBarNoBorder: true,
navBarTextColor: colors.grey74,
navBarButtonColor: colors.grey74,
navBarBackgroundColor: colors.white246
navBarBackgroundColor: colors.white246,
})
}
componentDidMount () {
componentDidMount() {
this.props.navigator.setDrawerEnabled({
side: 'right', // the side of the drawer since you can have two, 'left' / 'right'
enabled: false // should the drawer be enabled or disabled (locked closed)
enabled: false, // should the drawer be enabled or disabled (locked closed)
})
Icon.getImageSource('ios-menu', 32, colors.purple).then((menu) => {
Icon.getImageSource('ios-menu', 32, colors.purple).then(menu => {
this.props.navigator.setButtons({
leftButtons: [
{id: 'menu', icon: menu, buttonColor: colors.purple}
],
leftButtons: [{ id: 'menu', icon: menu, buttonColor: colors.purple }],
rightButtons: [
{
id: 'notifications',
id: 'notifications',
component: 'uport.notificationsButton',
}
]
},
],
})
})
}
onNavigatorEvent (event) { // this is the onPress handler for the two buttons together
if (event.type === 'NavBarButtonPress') { // this is the event type for button presses
if (event.id === 'menu') { // this is the same id field from the static navigatorButtons definition
onNavigatorEvent(event) {
// this is the onPress handler for the two buttons together
if (event.type === 'NavBarButtonPress') {
// this is the event type for button presses
if (event.id === 'menu') {
// this is the same id field from the static navigatorButtons definition
this.props.navigator.push({
screen: 'uport.more',
animated: true,
title: 'More'
title: 'More',
})
}
}
}

render () {
render() {
return (
<View style={{
backgroundColor: colors.white,
flex: 1
}}>

<View
style={{
backgroundColor: colors.white,
flex: 1,
}}
>
{/* Avatar Name Row */}
<AvatarNameHeader avatar={this.props.avatar} name={this.props.name} />
<View style={{
justifyContent: 'flex-start',
flex: 0,
flexDirection: 'column',
elevation: 8
}}>
<View
style={{
justifyContent: 'flex-start',
flex: 0,
flexDirection: 'column',
elevation: 8,
}}
>
<View>
<TouchableOpacity onPress={debounce(() => {
this.props.navigator.push({
screen: 'uport.myInfo',
title: 'Identity',
animated: true, // does the push have transition animation or does it happen immediately (optional)
})
}, 1000, {leading: true, trailing: false})}>
<TouchableOpacity
onPress={debounce(
() => {
this.props.navigator.push({
screen: 'uport.myInfo',
title: 'Identity',
animated: true, // does the push have transition animation or does it happen immediately (optional)
})
},
1000,
{ leading: true, trailing: false },
)}
>
<View style={styles.menuItem}>
<View style={styles.iconCircle}>
<Icon name={'md-information'} color={colors.grey130} size={33} style={{height: 33}} />
<Icon name={'md-information'} color={colors.grey130} size={33} style={{ height: 33 }} />
</View>
<Text style={styles.menuItemText}>
Identity
</Text>
<Text style={styles.menuItemText}>Identity</Text>
<Icon name={'ios-arrow-forward'} color={colors.grey216} size={20} style={styles.menuItemArrow} />
</View>
</TouchableOpacity>
</View>
<View>
<TouchableOpacity style={{}} onPress={debounce(() => {
this.props.navigator.push({
screen: 'uport.verifications',
title: 'Verifications',
animated: true,
})
}, 1000, {leading: true, trailing: false})}>
<TouchableOpacity
style={{}}
onPress={debounce(
() => {
this.props.navigator.push({
screen: 'uport.verifications',
title: 'Verifications',
animated: true,
})
},
1000,
{ leading: true, trailing: false },
)}
>
<View style={styles.menuItem}>
<View style={styles.iconCircle}>
<Icon name={'ios-checkmark'} color={colors.grey130} size={33} style={{height: 32}} />
<Icon name={'ios-checkmark'} color={colors.grey130} size={33} style={{ height: 32 }} />
</View>
<Text style={styles.menuItemText}>
Verifications
</Text>
<Text style={styles.menuItemText}>Verifications</Text>
<Icon name={'ios-arrow-forward'} color={colors.grey216} size={20} style={styles.menuItemArrow} />
</View>
</TouchableOpacity>
</View>
<View>
<TouchableOpacity style={{}} onPress={debounce(() => {
this.props.navigator.push({
screen: 'uport.accounts',
title: 'Accounts'
})
}, 1000, {leading: true, trailing: false})}>
<TouchableOpacity
style={{}}
onPress={debounce(
() => {
this.props.navigator.push({
screen: 'uport.accounts',
title: 'Accounts',
})
},
1000,
{ leading: true, trailing: false },
)}
>
<View style={styles.menuItem}>
<View style={styles.iconCircle}>
<FAIcon name={'user-o'} color={colors.grey130} size={22} style={{height: 24}} />
<FAIcon name={'user-o'} color={colors.grey130} size={22} style={{ height: 24 }} />
</View>
<Text style={styles.menuItemText}>
Accounts
</Text>
<Text style={styles.menuItemText}>Accounts</Text>
<Icon name={'ios-arrow-forward'} color={colors.grey216} size={20} style={styles.menuItemArrow} />
</View>
</TouchableOpacity>
</View>
</View>
<Fab
icon='qrcode-scan'
onPress={() => this.props.navigator.push({
screen: 'uport.scanner',
animated: false,
navigatorStyle: {
navBarHidden: true
}
})}
onPress={() =>
this.props.navigator.showModal({
screen: 'uport.scanner',
navigatorStyle: {
navBarHidden: true,
},
})
}
/>
</View>

)
}
}

Home.propTypes = {
}
Home.propTypes = {}

const mapStateToProps = (state, ownProps) => {
return {
...ownProps,
avatar: currentAvatar(state),
name: currentName(state)
name: currentName(state),
}
}

Expand Down
26 changes: 13 additions & 13 deletions lib/components/Scanner/__tests__/Scanner-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ describe('Scanner', () => {
expect(toJson(wrapper)).toMatchSnapshot()
})

it('calls pop on view on Android to close', () => {
Platform.OS = 'android'
const navigator = new FakeNavigator()
navigator.pop = jest.fn()
const wrapper = global.shallow(<Scanner navigator={navigator} />)
wrapper.setState({ scannerEnabled: true, hasCameraPermission: true })
wrapper
.find(TouchableOpacity)
.first()
.props()
.onPress()
expect(navigator.pop).toHaveBeenCalled()
})
// it('calls dismiss on view on Android to close', () => {
// Platform.OS = 'android'
// const navigator = new FakeNavigator()
// navigator.pop = jest.fn()
// const wrapper = global.shallow(<Scanner navigator={navigator} />)
// wrapper.setState({ scannerEnabled: true, hasCameraPermission: true })
// wrapper
// .find(TouchableOpacity)
// .first()
// .props()
// .onPress()
// expect(navigator.dismissModal).toHaveBeenCalled()
// })

it('calls toggleDrawer on IOS to close', () => {
Platform.OS = 'ios'
Expand Down
9 changes: 1 addition & 8 deletions lib/components/Scanner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ export class Scanner extends React.Component {
}

async componentDidMount() {
if (Platform.OS === 'android') {
this.props.navigator.toggleTabs({
to: 'hidden',
animated: false,
})
}

let status = await Permissions.check('camera')
if (status === 'undetermined') {
status = await Permissions.request('camera')
Expand All @@ -119,7 +112,7 @@ export class Scanner extends React.Component {
}

popScreen() {
this.props.navigator.pop()
this.props.navigator.dismissModal()
}

onBarCodeRead(event) {
Expand Down
Loading