Skip to content

Commit

Permalink
feat(mobile): add onboarding ble
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha Froment <sfroment42@gmail.com>
  • Loading branch information
sfroment committed Feb 1, 2019
1 parent c7314ad commit be96631
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 1 deletion.
@@ -0,0 +1,37 @@
import React from 'react'
import { Text, View, ScrollView, NativeModules } from 'react-native'
import { Flex } from '../../../Library'
import { withNavigation } from 'react-navigation'
import * as onboardingStyle from './style'
import { NextButton, SkipButton } from './Button'
import { withNamespaces } from 'react-i18next'
import { RelayContext } from '../../../../relay'
import colors from '../../../../constants/colors'

const Bluetooth = ({ navigation, t }) =>
<View style={{ backgroundColor: colors.white, flex: 1 }}>
<RelayContext.Consumer>{context =>
<ScrollView alwaysBounceVertical={false}>
<Flex.Rows style={onboardingStyle.view}>
<Text style={onboardingStyle.title}>{t('onboarding.bluetooth.title')}</Text>
<Text style={onboardingStyle.help}>{t('onboarding.bluetooth.help')}</Text>
<Text style={onboardingStyle.disclaimer}>
{t('onboarding.bluetooth.disclaimer')}
</Text>
<View style={{ height: 60, flexDirection: 'row' }}>
<SkipButton
onPress={() => navigation.navigate('onboarding/contacts')}>{t('skip')}</SkipButton>
<NextButton onPress={async () => {
let json = await NativeModules.CoreModule.getNetworkConfig()
let currentConfig = JSON.parse(json)
currentConfig.BluetoothTransport = true
await NativeModules.CoreModule.updateNetworkConfig(JSON.stringify(currentConfig))
navigation.navigate('onboarding/contacts')
}}>{t('onboarding.bluetooth.enable')}</NextButton>
</View>
</Flex.Rows>
</ScrollView>
}</RelayContext.Consumer>
</View>

export default withNamespaces()(withNavigation(Bluetooth))
Expand Up @@ -25,7 +25,7 @@ const Notifications = ({ navigation, t }) =>
onPress={() => navigation.navigate('onboarding/contacts')}>{t('skip')}</SkipButton>
<NextButton onPress={async () => {
await enableNativeNotifications({ context })
navigation.navigate('onboarding/contacts')
navigation.navigate('onboarding/bluetooth')
}}>{t('onboarding.notifications.enable')}</NextButton>
</View>
</Flex.Rows>
Expand Down
@@ -1,6 +1,7 @@
import { createMaterialTopTabNavigator } from 'react-navigation'
import Welcome from './Welcome'
import Notifications from './Notifications'
import Bluetooth from './Bluetooth'
import Contacts from './Contacts'
import Ready from './Ready'
import { tabIcon } from '../../../../helpers/views'
Expand All @@ -23,6 +24,13 @@ export default createMaterialTopTabNavigator(
title: I18n.t('onboarding.notifications.tab'),
}),
},
'onboarding/bluetooth': {
screen: Bluetooth,
navigationOptions: () => ({
tabBarIcon: tabIcon('bluetooth'),
title: I18n.t('onboarding.bluetooth.tab'),
}),
},
'onboarding/contacts': {
screen: Contacts,
navigationOptions: () => ({
Expand Down
7 changes: 7 additions & 0 deletions client/react-native/common/i18n/en/messages.json
Expand Up @@ -29,6 +29,13 @@
"disclaimer-google": "Your messages will be encrypted and sent through Berty and Google servers. Neither Berty nor Google will have access to your messages, but some metadata can be deduced.",
"enable": "Enable notifications"
},
"bluetooth": {
"tab": "Bluetooth",
"title": "Offline message delivery",
"help": "You can receive and send messages even without the internet.",
"disclaimer": "Your messages will be send through bluetooth.",
"enable": "Enable bluetooth"
},
"contacts": {
"tab": "Contacts",
"title": "Talk securely with the people that matters to you",
Expand Down
8 changes: 8 additions & 0 deletions client/react-native/gomobile/core/config.go
@@ -1,5 +1,7 @@
package core

import "runtime"

// This file contain the configuration by default

// Initial configs will be used to set default settings in state DB
Expand All @@ -19,6 +21,12 @@ var (
initiallocalGRPC = false
)

func init() {
if runtime.GOOS == "android" {
initialNetConf.BluetoothTransport = false
}
}

// Default configs will be used to set default settings but not saved in state DB
const (
defaultLoggerName = "client.rn.gomobile"
Expand Down

0 comments on commit be96631

Please sign in to comment.