Skip to content

Commit

Permalink
Merge pull request #2540 from fioprotocol/feature/ui2-help-modal
Browse files Browse the repository at this point in the history
Help modal ui2 design.
  • Loading branch information
thehobbit85 committed Apr 22, 2021
2 parents a297e46 + 10a7d85 commit 986b6c3
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 169 deletions.
Binary file modified android/app/src/main/assets/fonts/custom.ttf
100755 → 100644
Binary file not shown.
176 changes: 53 additions & 123 deletions src/assets/vector/config.json

Large diffs are not rendered by default.

160 changes: 127 additions & 33 deletions src/components/modals/HelpModal.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,155 @@
// @flow

import * as React from 'react'
import { Linking, Text } from 'react-native'
import { Image, Linking, View } from 'react-native'
import { getBuildNumber, getVersion } from 'react-native-device-info'
import AntDesignIcon from 'react-native-vector-icons/AntDesign'
import { WebView } from 'react-native-webview'

import edgeLogo from '../../assets/images/edgeLogo/Edge_logo_L.png'
import { Fontello } from '../../assets/vector'
import s from '../../locales/strings.js'
import { PLATFORM } from '../../theme/variables/platform.js'
import { Airship } from '../services/AirshipInstance.js'
import { type AirshipBridge, AirshipModal, ContentArea, dayText, IconCircle, ModalCloseArrow, textSize, THEME } from './modalParts.js'
import { type Theme, type ThemeProps, cacheStyles, withTheme } from '../services/ThemeContext.js'
import { EdgeText } from '../themed/EdgeText'
import { ModalCloseArrow, ModalTitle } from '../themed/ModalParts'
import { SelectableRow } from '../themed/SelectableRow'
import { ThemedModal } from '../themed/ThemedModal'
import { type AirshipBridge } from './modalParts.js'

const buildNumber = getBuildNumber()
const versionNumber = getVersion()
const CONTENT_URI = 'https://edgesecure.co/info.html'
const HELP_URIS = {
knowledgeBase: 'https://support.edge.app/support/home',
support: 'https://support.edge.app/support/tickets/new',
call: '+1-855-346-4974',
site: 'https://edge.app'
}

export function showHelpModal(): Promise<mixed> {
return Airship.show(bridge => <HelpModal bridge={bridge} />)
}
function showWebViewModal(uri: string, title: string): void {
Airship.show(bridge => <HelpWebViewModal bridge={bridge} uri={uri} title={title} />)
}

type Props = {
bridge: AirshipBridge<void>
}

class HelpModal extends React.Component<Props> {
class HelpWebViewModal extends React.Component<Props & { uri: string, title: string }> {
webview: WebView | void
handleClose = () => this.props.bridge.resolve()

render() {
const { bridge, uri, title } = this.props
return (
<ThemedModal bridge={bridge} onCancel={this.handleClose} paddingRem={[1, 0]}>
<ModalTitle center paddingRem={[0, 1, 1]}>
{title}
</ModalTitle>
<WebView ref={element => (this.webview = element)} source={{ uri }} />

<ModalCloseArrow onPress={this.handleClose} />
</ThemedModal>
)
}
}

class HelpModalComponent extends React.Component<Props & ThemeProps> {
handleClose = () => this.props.bridge.resolve()

render() {
const { bridge } = this.props
const { bridge, theme } = this.props
const styles = getStyles(theme)
const versionText = `${s.strings.help_version} ${versionNumber}`
const buildText = `${s.strings.help_build} ${buildNumber}`
const optionMarginRem = [0.75, 0, 0.5, 1]
const optionPaddingRem = [0, 1, 1, 0]

return (
<AirshipModal bridge={bridge} onCancel={() => bridge.resolve()}>
<IconCircle>
<AntDesignIcon name="question" size={THEME.rem(2)} color={THEME.COLORS.SECONDARY} style={{ marginLeft: THEME.rem(0.1) }} />
</IconCircle>

<ContentArea grow>
<Text style={dayText('title')}>{s.strings.help_modal_title}</Text>
<WebView
onNavigationStateChange={event => {
if (!event.url.includes('info.html')) {
if (this.webview) this.webview.stopLoading()
Linking.openURL(event.url)
bridge.resolve()
}
}}
ref={element => (this.webview = element)}
source={{ uri: CONTENT_URI }}
/>
<Text style={[dayText('center', 'small'), { lineHeight: textSize.large }]}>
{s.strings.help_version} {versionNumber}
{'\n'}
{s.strings.help_build} {buildNumber}
</Text>
</ContentArea>

<ModalCloseArrow onPress={() => bridge.resolve()} />
</AirshipModal>
<ThemedModal bridge={bridge} onCancel={this.handleClose} paddingRem={[1, 0]}>
<View style={styles.titleContainer}>
<Image source={edgeLogo} style={styles.logo} resizeMode="contain" />
<ModalTitle center paddingRem={[0, 1, 1]}>
{s.strings.help_modal_title}
</ModalTitle>
</View>

<SelectableRow
icon={<Fontello name="help_idea" color={theme.iconTappable} size={theme.rem(1.5)} />}
title={s.strings.help_knowledge_base}
subTitle={s.strings.help_knowledge_base_text}
onPress={() => showWebViewModal(HELP_URIS.knowledgeBase, s.strings.help_knowledge_base)}
underline
arrowTappable
marginRem={optionMarginRem}
paddingRem={optionPaddingRem}
/>

<SelectableRow
icon={<Fontello name="help_headset" color={theme.iconTappable} size={theme.rem(1.5)} />}
title={s.strings.help_support}
subTitle={s.strings.help_support_text}
onPress={() => showWebViewModal(HELP_URIS.support, s.strings.help_support)}
underline
arrowTappable
marginRem={optionMarginRem}
paddingRem={optionPaddingRem}
/>

<SelectableRow
icon={<Fontello name="help_call" color={theme.iconTappable} size={theme.rem(1.5)} />}
title={s.strings.help_call}
subTitle={s.strings.help_call_text}
onPress={() => Linking.openURL(`tel:${HELP_URIS.call}`)}
underline
arrowTappable
marginRem={optionMarginRem}
paddingRem={optionPaddingRem}
/>

<SelectableRow
icon={<Fontello name="globe" color={theme.iconTappable} size={theme.rem(1.5)} />}
title={s.strings.help_site}
subTitle={s.strings.help_site_text}
onPress={() => showWebViewModal(HELP_URIS.site, s.strings.help_site_text)}
arrowTappable
marginRem={optionMarginRem}
paddingRem={optionPaddingRem}
/>
<View style={styles.footer}>
<EdgeText style={styles.version}>{versionText}</EdgeText>
<EdgeText style={styles.version}>{buildText}</EdgeText>
</View>

<ModalCloseArrow onPress={this.handleClose} />
</ThemedModal>
)
}
}

const getStyles = cacheStyles((theme: Theme) => ({
titleContainer: {
marginTop: theme.rem(0.5),
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center'
},
logo: {
height: theme.rem(2.25)
},
footer: {
marginTop: PLATFORM.deviceHeight < theme.rem(42) ? 0 : theme.rem(1.5),
paddingVertical: PLATFORM.deviceHeight < theme.rem(42) ? theme.rem(0.25) : theme.rem(0.5),
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center'
},
version: {
color: theme.secondaryText,
fontSize: theme.rem(0.75)
}
}))

const HelpModal = withTheme(HelpModalComponent)
37 changes: 31 additions & 6 deletions src/components/themed/ClickableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,30 @@ import * as React from 'react'
import { TouchableHighlight, TouchableOpacity, View } from 'react-native'

import { Gradient } from '../../modules/UI/components/Gradient/Gradient.ui'
import { unpackEdges } from '../../util/edges'
import { type Theme, type ThemeProps, cacheStyles, withTheme } from '../services/ThemeContext.js'

type Props = {
onPress: () => void | (() => Promise<void>),
highlight?: boolean,
gradient?: boolean,
children?: React.Node
children?: React.Node,
underline?: boolean,

marginRem?: number[] | number,
paddingRem?: number[] | number
}

class ClickableRowComponent extends React.PureComponent<Props & ThemeProps> {
renderContent() {
const { gradient, children, theme } = this.props
const { gradient, children, underline, theme } = this.props
const styles = getStyles(theme)
const containerStyles = [styles.rowContainer, spacingStyles(this.props, theme), underline ? styles.underline : null]
if (gradient) {
return <Gradient style={styles.rowContainer}>{children}</Gradient>
return <Gradient style={containerStyles}>{children}</Gradient>
}

return <View style={styles.rowContainer}>{children}</View>
return <View style={containerStyles}>{children}</View>
}

render() {
Expand All @@ -39,13 +45,32 @@ class ClickableRowComponent extends React.PureComponent<Props & ThemeProps> {
}
}

function spacingStyles(props: Props, theme: Theme) {
const marginRem = unpackEdges(props.marginRem || 0)
const paddingRem = unpackEdges(props.paddingRem ?? [0, 1])

return {
marginBottom: theme.rem(marginRem.bottom),
marginLeft: theme.rem(marginRem.left),
marginRight: theme.rem(marginRem.right),
marginTop: theme.rem(marginRem.top),
paddingBottom: theme.rem(paddingRem.bottom),
paddingLeft: theme.rem(paddingRem.left),
paddingRight: theme.rem(paddingRem.right),
paddingTop: theme.rem(paddingRem.top)
}
}

const getStyles = cacheStyles((theme: Theme) => ({
rowContainer: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
height: theme.rem(4.25),
paddingHorizontal: theme.rem(1)
height: theme.rem(4.25)
},
underline: {
borderBottomWidth: theme.thinLineWidth,
borderBottomColor: theme.lineDivider
}
}))

Expand Down
20 changes: 15 additions & 5 deletions src/components/themed/SelectableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,32 @@ type Props = {
title: string,
subTitle: string,
icon?: React.Node,
selected: boolean
selected?: boolean,
arrowTappable?: boolean,
underline?: boolean,

marginRem?: number[] | number,
paddingRem?: number[] | number
}

class SelectableRowComponent extends React.PureComponent<Props & ThemeProps> {
render() {
const { icon, title, subTitle, onPress, theme } = this.props
const { icon, title, subTitle, arrowTappable, underline, marginRem, paddingRem, onPress, theme } = this.props
const styles = getStyles(theme)

return (
<ClickableRow onPress={onPress}>
<ClickableRow onPress={onPress} underline={underline} marginRem={marginRem} paddingRem={paddingRem}>
<View style={styles.rowContainer}>
<View style={styles.iconTitleContainer}>
{icon}
<View style={styles.title}>
<EdgeText>{title}</EdgeText>
<EdgeText style={styles.subTitle}>{subTitle}</EdgeText>
<EdgeText style={styles.subTitle} numberOfLines={2}>
{subTitle}
</EdgeText>
</View>
</View>
<IonIcon size={theme.rem(1.5)} color={this.props.theme.icon} name="chevron-forward-outline" style={styles.iconStyle} />
<IonIcon size={theme.rem(1.5)} color={arrowTappable ? theme.iconTappable : theme.icon} name="chevron-forward-outline" style={styles.iconStyle} />
</View>
</ClickableRow>
)
Expand All @@ -46,14 +53,17 @@ const getStyles = cacheStyles((theme: Theme) => ({
justifyContent: 'space-between'
},
iconTitleContainer: {
flex: 1,
flexDirection: 'row',
alignItems: 'center'
},
title: {
width: '100%',
flexDirection: 'column',
marginLeft: theme.rem(1.25)
},
subTitle: {
maxWidth: '85%',
color: theme.deactivatedText,
fontSize: theme.rem(0.75),
marginTop: theme.rem(0.25)
Expand Down
10 changes: 9 additions & 1 deletion src/locales/en_US.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,16 @@ const strings = {
submit: 'Submit',
login: 'Login',
help_build: 'Build',
help_modal_title: 'Crypto Wallet',
help_modal_title: 'Thanks for using Edge!',
help_version: 'Version',
help_knowledge_base: 'Knowledge Base',
help_knowledge_base_text: 'Commonly asked questions and FAQ',
help_support: 'Submit a Support Ticket',
help_support_text: 'Troubleshooting and technical support',
help_call: 'Call for Assistance',
help_call_text: 'Get in touch by phone',
help_site: 'Visit the Edge App site',
help_site_text: 'More info on Edge and Developer API/SDK',
loading: 'Loading…',
validating: 'Validating…',
mining_fee_custom_label_choice: 'Custom',
Expand Down
10 changes: 9 additions & 1 deletion src/locales/strings/enUS.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,16 @@
"submit": "Submit",
"login": "Login",
"help_build": "Build",
"help_modal_title": "Crypto Wallet",
"help_modal_title": "Thanks for using Edge!",
"help_version": "Version",
"help_knowledge_base": "Knowledge Base",
"help_knowledge_base_text": "Commonly asked questions and FAQ",
"help_support": "Submit a Support Ticket",
"help_support_text": "Troubleshooting and technical support",
"help_call": "Call for Assistance",
"help_call_text": "Get in touch by phone",
"help_site": "Visit the Edge App site",
"help_site_text": "More info on Edge and Developer API/SDK",
"loading": "Loading…",
"validating": "Validating…",
"mining_fee_custom_label_choice": "Custom",
Expand Down

0 comments on commit 986b6c3

Please sign in to comment.