From 14960794bc2eed1f12ae3f1ee98b373d77dccd0e Mon Sep 17 00:00:00 2001 From: keplyx Date: Thu, 5 Mar 2020 23:40:50 +0100 Subject: [PATCH] Start using react navigation header --- navigation/MainTabNavigator.js | 27 ++++++++++++++--- screens/Proximo/ProximoAboutScreen.js | 1 - screens/Proximo/ProximoListScreen.js | 43 ++++++++++++++++++++------- screens/Proximo/ProximoMainScreen.js | 21 ++++++++----- 4 files changed, 68 insertions(+), 24 deletions(-) diff --git a/navigation/MainTabNavigator.js b/navigation/MainTabNavigator.js index b9c2152..f6a8e79 100644 --- a/navigation/MainTabNavigator.js +++ b/navigation/MainTabNavigator.js @@ -3,7 +3,6 @@ import {createStackNavigator, TransitionPresets} from '@react-navigation/stack'; import {createMaterialBottomTabNavigator} from "@react-navigation/material-bottom-tabs"; import HomeScreen from '../screens/HomeScreen'; -import PerfHomeScreen from '../screens/PerfHomeScreen'; import PlanningScreen from '../screens/PlanningScreen'; import PlanningDisplayScreen from '../screens/PlanningDisplayScreen'; import ProxiwashScreen from '../screens/Proxiwash/ProxiwashScreen'; @@ -15,6 +14,8 @@ import PlanexScreen from '../screens/Websites/PlanexScreen'; import {MaterialCommunityIcons} from "@expo/vector-icons"; import ThemeManager from "../utils/ThemeManager"; import AsyncStorageManager from "../utils/AsyncStorageManager"; +import {StyleSheet, View} from "react-native"; +import Touchable from "react-native-platform-touchable"; const TAB_ICONS = { Home: 'triangle', @@ -26,13 +27,24 @@ const TAB_ICONS = { const ProximoStack = createStackNavigator(); +const styles = StyleSheet.create({ + header: { + backgroundColor: ThemeManager.getCurrentThemeVariables().brandPrimary, + }, + headerTitle: { + color: "#ffffff", + }, +}); + + function ProximoStackComponent() { return ( @@ -116,7 +135,7 @@ function HomeStackComponent() { { const nav = this.props.navigation; return ( - { break; } this.setupSortIcons(mode, isReverse); - this.sortMenuRef.hide(); + if (this.sortMenuRef !== undefined) + this.sortMenuRef.hide(); } /** * Set the sort mode from state when components are ready */ componentDidMount() { + const button = this.getSortMenu.bind(this); + const title = this.getSearchBar.bind(this); + this.props.navigation.setOptions({ + headerRight: button, + headerTitle: title, + }); this.setSortMode(this.state.currentSortMode, this.state.isSortReversed); } + getSearchBar() { + return ( + + + + + + + ); + } + /** * get color depending on quantity available * @@ -299,7 +328,7 @@ export default class ProximoListScreen extends React.Component { ref={this.onMenuRef} button={ { modalStyle={{backgroundColor: ThemeManager.getCurrentThemeVariables().containerBgColor}}> {this.getModalContent()} - { this.createDataset = this.createDataset.bind(this); } + componentDidMount() { + const button = this.getRightButton.bind(this); + this.props.navigation.setOptions({ + headerRight: button + , + }); + } + static sortFinalData(a: Object, b: Object) { let str1 = a.type.name.toLowerCase(); let str2 = b.type.name.toLowerCase(); @@ -150,7 +157,8 @@ export default class ProximoMainScreen extends React.Component { return ( { render() { const nav = this.props.navigation; return ( - + { fetchUrl={DATA_URL} renderItem={this.getRenderItem} updateErrorText={i18n.t("homeScreen.listUpdateFail")}/> - + ); } }