From 6d0c033e323d6263789b3d5cc4e701ca5a02c7c4 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 16 May 2017 19:57:09 +0000 Subject: [PATCH] Switched to custom header --- .../src/components/base-screen.js | 8 ++++ .../src/components/screen-header.js | 37 +++++++++++++++++++ .../src/components/screens/folder.js | 8 ++-- .../src/components/screens/folders.js | 12 +++--- .../src/components/screens/login.js | 8 ++-- .../src/components/screens/note.js | 8 ++-- .../src/components/screens/notes.js | 9 +++-- ReactNativeClient/src/root.js | 12 ++---- 8 files changed, 76 insertions(+), 26 deletions(-) create mode 100644 ReactNativeClient/src/components/base-screen.js create mode 100644 ReactNativeClient/src/components/screen-header.js diff --git a/ReactNativeClient/src/components/base-screen.js b/ReactNativeClient/src/components/base-screen.js new file mode 100644 index 000000000..5c74b977b --- /dev/null +++ b/ReactNativeClient/src/components/base-screen.js @@ -0,0 +1,8 @@ +import React, { Component } from 'react'; +import { Log } from 'src/log.js' + +class BaseScreenComponent extends React.Component { + +} + +export { BaseScreenComponent }; \ No newline at end of file diff --git a/ReactNativeClient/src/components/screen-header.js b/ReactNativeClient/src/components/screen-header.js new file mode 100644 index 000000000..c68b4af13 --- /dev/null +++ b/ReactNativeClient/src/components/screen-header.js @@ -0,0 +1,37 @@ +import React, { Component } from 'react'; +import { connect } from 'react-redux' +import { View, Text, Button } from 'react-native'; +import { Log } from 'src/log.js'; +import { _ } from 'src/locale.js'; + +class ScreenHeaderComponent extends Component { + + showBackButton() { + // Note: this is hardcoded for now because navigation.state doesn't tell whether + // it's possible to go back or not. Maybe it's possible to get this information + // from somewhere else. + return this.props.navState.routeName != 'Folders'; + } + + backButton_press = () => { + this.props.dispatch({ type: 'Navigation/BACK' }); + } + + render() { + return ( + + + {_(this.props.navState.routeName)} + + ); + } + +} + +const ScreenHeader = connect( + (state) => { + return {}; + } +)(ScreenHeaderComponent) + +export { ScreenHeader }; \ No newline at end of file diff --git a/ReactNativeClient/src/components/screens/folder.js b/ReactNativeClient/src/components/screens/folder.js index fb473af20..9deb548cb 100644 --- a/ReactNativeClient/src/components/screens/folder.js +++ b/ReactNativeClient/src/components/screens/folder.js @@ -3,12 +3,13 @@ import { View, Button, TextInput } from 'react-native'; import { connect } from 'react-redux' import { Log } from 'src/log.js' import { Folder } from 'src/models/folder.js' +import { ScreenHeader } from 'src/components/screen-header.js'; class FolderScreenComponent extends React.Component { - static navigationOptions = { - title: 'Folder', - }; + static navigationOptions = (options) => { + return { header: null }; + } constructor() { super(); @@ -45,6 +46,7 @@ class FolderScreenComponent extends React.Component { render() { return ( +