diff --git a/app/containers/HeaderButton/Common.tsx b/app/containers/HeaderButton/Common.tsx index 82006f9ef..b9645dcbd 100644 --- a/app/containers/HeaderButton/Common.tsx +++ b/app/containers/HeaderButton/Common.tsx @@ -1,7 +1,8 @@ import React from 'react'; +import { StackActions, useNavigation } from '@react-navigation/native'; -import { isIOS } from '../../lib/methods/helpers'; import I18n from '../../i18n'; +import { isIOS } from '../../lib/methods/helpers'; import Container from './HeaderButtonContainer'; import Item, { IHeaderButtonItem } from './HeaderButtonItem'; @@ -18,13 +19,22 @@ export const Drawer = React.memo( ) ); -export const CloseModal = React.memo( - ({ navigation, testID, onPress = () => navigation?.pop(), ...props }: IHeaderButtonCommon) => ( +export const CloseModal = React.memo(({ testID, onPress, ...props }: IHeaderButtonCommon) => { + const { dispatch } = useNavigation(); + return ( - + { + if (onPress) return onPress(arg); + dispatch(StackActions.pop()); + }} + testID={testID} + {...props} + /> - ) -); + ); +}); export const CancelModal = React.memo(({ onPress, testID, ...props }: IHeaderButtonCommon) => ( diff --git a/app/containers/markdown/index.tsx b/app/containers/markdown/index.tsx index 5243af2ac..1fd04eb36 100644 --- a/app/containers/markdown/index.tsx +++ b/app/containers/markdown/index.tsx @@ -22,14 +22,14 @@ import { formatText } from './formatText'; import { IUserMention, IUserChannel, TOnLinkPress } from './interfaces'; import { TGetCustomEmoji } from '../../definitions/IEmoji'; import { formatHyperlink } from './formatHyperlink'; -import { TSupportedThemes } from '../../theme'; +import { TSupportedThemes, withTheme } from '../../theme'; import { themes } from '../../lib/constants'; export { default as MarkdownPreview } from './Preview'; interface IMarkdownProps { msg?: string | null; - theme: TSupportedThemes; + theme?: TSupportedThemes; md?: MarkdownAST; mentions?: IUserMention[]; getCustomEmoji?: TGetCustomEmoji; @@ -158,9 +158,9 @@ class Markdown extends PureComponent { style={[ { ...styles.codeInline, - color: themes[theme].bodyText, - backgroundColor: themes[theme].bannerBackground, - borderColor: themes[theme].bannerBackground + color: themes[theme!].bodyText, + backgroundColor: themes[theme!].bannerBackground, + borderColor: themes[theme!].bannerBackground }, ...style ]} @@ -177,9 +177,9 @@ class Markdown extends PureComponent { style={[ { ...styles.codeBlock, - color: themes[theme].bodyText, - backgroundColor: themes[theme].bannerBackground, - borderColor: themes[theme].bannerBackground + color: themes[theme!].bodyText, + backgroundColor: themes[theme!].bannerBackground, + borderColor: themes[theme!].bannerBackground }, ...style ]} @@ -200,7 +200,7 @@ class Markdown extends PureComponent { return null; } return ( - + {children} ); @@ -209,7 +209,7 @@ class Markdown extends PureComponent { renderLink = ({ children, href }: any) => { const { theme, onLinkPress } = this.props; return ( - + {children} ); @@ -261,7 +261,7 @@ class Markdown extends PureComponent { // @ts-ignore const textStyle = styles[`heading${level}Text`]; return ( - + {children} ); @@ -289,13 +289,13 @@ class Markdown extends PureComponent { renderBlockQuote = ({ children }: { children: JSX.Element }) => { const { theme } = this.props; - return {children}; + return {children}; }; renderTable = ({ children, numColumns }: { children: JSX.Element; numColumns: number }) => { const { theme } = this.props; return ( - + {children} ); @@ -354,4 +354,4 @@ class Markdown extends PureComponent { } } -export default Markdown; +export default withTheme(Markdown); diff --git a/app/stacks/InsideStack.tsx b/app/stacks/InsideStack.tsx index 982ee4d4d..5c077081c 100644 --- a/app/stacks/InsideStack.tsx +++ b/app/stacks/InsideStack.tsx @@ -282,11 +282,7 @@ const E2ESaveYourPasswordStackNavigator = () => { component={E2ESaveYourPasswordView} options={E2ESaveYourPasswordView.navigationOptions} /> - + ); }; diff --git a/app/stacks/MasterDetailStack/index.tsx b/app/stacks/MasterDetailStack/index.tsx index ec385a649..c740c781f 100644 --- a/app/stacks/MasterDetailStack/index.tsx +++ b/app/stacks/MasterDetailStack/index.tsx @@ -200,7 +200,7 @@ const ModalStackNavigator = React.memo(({ navigation }: INavigation) => { component={E2ESaveYourPasswordView} options={E2ESaveYourPasswordView.navigationOptions} /> - + ; +const E2EHowItWorksView = (): React.ReactElement => { + const { setOptions } = useNavigation(); + const { colors } = useTheme(); + const { params } = useRoute>(); -class E2EHowItWorksView extends React.Component { - static navigationOptions = ({ route, navigation }: Pick) => { - const showCloseModal = route.params?.showCloseModal; - return { + useEffect(() => { + setOptions({ title: I18n.t('How_It_Works'), - headerLeft: showCloseModal ? () => : undefined - }; - }; + headerLeft: params?.showCloseModal ? () => : undefined + }); + }, []); - render() { - const { theme } = this.props; + const infoStyle = [styles.info, { color: colors.bodyText }]; - const infoStyle = [styles.info, { color: themes[theme].bodyText }]; + return ( + + + + + + + ); +}; - return ( - - - - - - - ); - } -} - -export default withTheme(E2EHowItWorksView); +export default E2EHowItWorksView;