From 6ae40c3117701f530937e8816d777ceaeb33d98f Mon Sep 17 00:00:00 2001 From: Arthi-chaud Date: Mon, 11 Jul 2022 11:35:46 +0200 Subject: [PATCH] Front: Setup Color Theme w/ React Native Paper --- front/App.test.tsx | 2 +- front/App.tsx | 41 ++++++++++++----------------------------- front/Theme.tsx | 40 +++++++++++++++++----------------------- 3 files changed, 30 insertions(+), 53 deletions(-) diff --git a/front/App.test.tsx b/front/App.test.tsx index 7a7e434..fbbf906 100644 --- a/front/App.test.tsx +++ b/front/App.test.tsx @@ -6,6 +6,6 @@ import { AppContent } from './App'; describe('', () => { it('has 1 child', () => { const tree = TestRenderer.create().toJSON(); - expect(tree.children.length).toBe(10); + expect(tree.children.length).toBe(6); }); }); diff --git a/front/App.tsx b/front/App.tsx index 7c36f58..353a73a 100644 --- a/front/App.tsx +++ b/front/App.tsx @@ -1,7 +1,7 @@ import { StatusBar } from 'expo-status-bar'; -import { StyleSheet, Text, View, ColorValue } from 'react-native'; -import ColorTheme from './Theme'; -import { Provider as PaperProvider } from 'react-native-paper'; +import { Text, View, ColorValue } from 'react-native'; +import { Provider as PaperProvider, useTheme } from 'react-native-paper'; +import Theme from './Theme'; const ExampleBox = (props: { textColor: ColorValue, backgroundColor: ColorValue }) => ( @@ -10,24 +10,15 @@ const ExampleBox = (props: { textColor: ColorValue, backgroundColor: ColorValue ) export function AppContent() { + const { colors } = useTheme(); return ( - - - - - - - - - - - + + + + + + + ); @@ -35,16 +26,8 @@ export function AppContent() { export default function App() { return ( - + ); } - -const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: ColorTheme.backgroundLight, - justifyContent: 'center', - }, -}); diff --git a/front/Theme.tsx b/front/Theme.tsx index 010fd76..65188b4 100644 --- a/front/Theme.tsx +++ b/front/Theme.tsx @@ -1,31 +1,25 @@ /** * Color theme to use thoughout the application * Using the Material Color guidelines - * TODO: integrate with the to-be-determined design framework */ -const ColorTheme = { - primary: '#5db075', - primaryVariant: '#008000', - onPrimary: '#ffffff', - secondary: '#00bdbd', - secondaryVariant: '#008b8c', - onSecondary: '#ffffff', +import { DefaultTheme } from 'react-native-paper'; - backgroundLight: '#F0F0F0', - onBackgroundLight: '#000000', - backgroundDark: '#292929', - onBackgroundDark: '#FFFFFF', - - surface: '#F6F6F6', - onSurface: '#000000', - - placeholder: '#C9C9C9', - - error: '#B00020', - onError: '#FFFFFF', - - divider: "#DDDDDD", +const Theme = { + ...DefaultTheme, + roundness: 10, + colors: { + ...DefaultTheme.colors, + primary: '#5db075', + background: '#F0F0F0', + surface: '#F6F6F6', + accent: '#00bdbd', + error: '#B00020', + text: '#ffffff', + onSurface: '#000000', + placeholder: '#C9C9C9', + notification: '#FF0000' + } }; -export default ColorTheme; \ No newline at end of file +export default Theme; \ No newline at end of file