From e4dd4768b703537bc32b897d835331ca72784d3b Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Sat, 28 Mar 2020 16:45:18 +0530 Subject: [PATCH] Style tab navigation. --- App.js | 55 ++++++++++++++++++++++++++++++++++++++++------------ package.json | 3 +++ yarn.lock | 10 ++++++++++ 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/App.js b/App.js index aadbb2b..8476c7c 100644 --- a/App.js +++ b/App.js @@ -1,4 +1,5 @@ import React, { useState } from "react"; +import Color from "color"; import PropTypes from "prop-types"; import { Appbar, @@ -9,12 +10,14 @@ import { Button, Provider, RadioButton, - TouchableRipple + TouchableRipple, + overlay, } from "react-native-paper"; -import { View, StatusBar, StyleSheet } from "react-native"; +import { View, StatusBar, StyleSheet, Text as RNText } from "react-native"; import { NavigationContainer } from "@react-navigation/native"; import { TabView, SceneMap, TabBar } from "react-native-tab-view"; +import Icon from "react-native-vector-icons/MaterialCommunityIcons"; import SubjectsContainer from "./containers/SubjectsContainer"; import TimetableContainer from "./containers/TimetableContainer"; @@ -59,6 +62,27 @@ ThemePicker.propTypes = { }; const App = ({ theme, setTheme }) => { + + function renderLabel({ route, focused, color }) { + return {route.title}; + } + + renderLabel.propTypes = { + route: PropTypes.object, + focused: PropTypes.bool, + color: PropTypes.string, + }; + + function renderIcon({ route, color }) { + return ( + + + + ); + } + + renderIcon.propTypes = renderLabel.propTypes; + const [ pane, setPane ] = useState({ index: 0, routes: [ @@ -79,6 +103,12 @@ const App = ({ theme, setTheme }) => { subjects: SubjectsContainer, }); + const backgroundColor = theme.dark && theme.mode === "adaptive" ? + overlay(4, theme.colors.surface): + theme.colors.primary; + + const activeColor = Color(backgroundColor).isLight() ? "#000" : "#FFF"; + const inactiveColor = Color(backgroundColor).isLight() ? "#222" : "#AAA"; function dialogSelection(theme, idx) { setNewTheme(idx); setTheme(theme.theme); @@ -86,11 +116,7 @@ const App = ({ theme, setTheme }) => { return ( @@ -110,18 +136,23 @@ const App = ({ theme, setTheme }) => { })} renderScene={renderScene} shifting={true} + tabBarPosition="bottom" renderTabBar={props => ( null} />) } - tabBarPosition="bottom" + sceneContainerStyle={{ + backgroundColor: theme.colors.background + }} />