Skip to content

Commit

Permalink
Update pages
Browse files Browse the repository at this point in the history
  • Loading branch information
theboi committed Mar 12, 2020
1 parent e51ebf5 commit 7c82219
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 41 deletions.
23 changes: 23 additions & 0 deletions src/components/Page/PageHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { Platform, StatusBar } from 'react-native';
import { Text, Layout } from '@ui-kitten/components';

import {HeaderText} from '../../Text/Header';
export const PageHeader = (props: {theme: any, title: string}) => {
return (
<Layout
style={{
flexDirection: 'row',
alignItems: 'center',
marginTop: 40,
marginBottom: 5
}}>
<StatusBar barStyle={props.theme === 'dark' ? 'light-content' : 'dark-content'}/>
<Layout style={{paddingLeft: 20, paddingTop: 30, paddingBottom: 10}}>
<HeaderText>
{props.title}
</HeaderText>
</Layout>
</Layout>
)
}
30 changes: 30 additions & 0 deletions src/components/Shadow/Touchable/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import {TouchableOpacity, ViewStyle} from 'react-native';
import {connect} from 'react-redux';

export const TouchableShadow = (props: {
intensity?: number;
children?: React.ReactNode;
style?: ViewStyle;
onPress?(): void;
theme: String
}) => {
return (
<TouchableOpacity
style={{
elevation: (props.intensity || 2) * 5,
shadowColor: props.theme === 'dark' ? 'black' : 'grey',
shadowOffset: {width: 0, height: 0},
shadowOpacity: 0.5,
shadowRadius: (props.intensity || 1) * 3,
...props.style,
}}
onPress={() => {
if (props.onPress) {
props.onPress();
}
}}>
{props.children}
</TouchableOpacity>
);
};
22 changes: 22 additions & 0 deletions src/components/Shadow/View/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import {ViewStyle, View} from "react-native";

import {ThemeContext} from "../../../functions/theme";

export function ViewShadow(props: {intensity?: number; children?: React.ReactNode; style?: ViewStyle}) {
return (
<ThemeContext.Consumer>
{theme =>
<View style={{
elevation: (props.intensity || 2) * 5,
shadowColor: theme.theme === 'light' ? "gray" : 'black',
shadowOffset: {width: 0, height: 0},
shadowOpacity: 0.5,
shadowRadius: (props.intensity || 1) * 3,
...props.style
}}>
{props.children}
</View>}
</ThemeContext.Consumer>
)
}
23 changes: 23 additions & 0 deletions src/components/Text/Body/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import {Platform} from 'react-native';
import {Text} from '@ui-kitten/components';

export const BodyText = (props: {children?: string}) => {
return (
<Text
style={{
fontSize: 18,
...Platform.select({
android: {
fontFamily: 'Montserrat 500',
},
ios: {
fontFamily: 'Montserrat',
fontWeight: '500',
},
}),
}}>
{props.children ?? ''}
</Text>
);
};
24 changes: 24 additions & 0 deletions src/components/Text/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import {Platform} from 'react-native';
import {Text} from '@ui-kitten/components';

export const HeaderText = (props: {children?: string}) => {
return (
<Text
style={{
lineHeight: 30,
fontSize: 30,
...Platform.select({
android: {
// fontFamily: 'Montserrat 700',
},
ios: {
// fontFamily: 'Montserrat-Regular',
fontWeight: '700',
},
}),
}}>
{props.children ?? ''}
</Text>
);
};
19 changes: 11 additions & 8 deletions src/pages/Find/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import React from 'react';
import { View, Text } from 'react-native';
import { Layout, Text } from '@ui-kitten/components';
import { connect } from 'react-redux';

const FindPageC = () => {
import { TouchableShadow } from '../../components/Shadow/Touchable';
import { PageHeader } from '../../components/Page/PageHeader';

const FindPageC = (props: any) => {
return (
<View>
<Text style={{width: '100%', textAlign: 'center', paddingTop: 100}}>Find</Text>
</View>
<Layout style={{height: '100%'}}>
<PageHeader theme={props.theme} title="Find" />
</Layout>
)
}

const mapStateToProps = (state: Object) => {
const mapStateToProps = (state: any) => {
return {

theme: state.theme,
}
}

const mapDispatchToProps = (dispatch: Object) => {
const mapDispatchToProps = (dispatch: any) => {
return {

}
Expand Down
42 changes: 24 additions & 18 deletions src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
import React from 'react';
import { View, Text } from 'react-native';
import { connect } from 'react-redux';
import {connect} from 'react-redux';
import {Layout, Text} from '@ui-kitten/components';

const HomePageC = () => {
return (
<View>
<Text style={{width: '100%', textAlign: 'center', paddingTop: 100}}>Home</Text>
</View>
)
}

const mapStateToProps = (state: Object) => {
return {
import {PageHeader} from '../../components/Page/PageHeader';
import {TouchableShadow} from '../../components/Shadow/Touchable';

}
}
const HomePageC = (props: any) => {
return (
<Layout style={{height: '100%'}}>
<PageHeader theme={props.theme} title="Home" />
<TouchableShadow theme={props.theme}>
<Layout style={{marginHorizontal: 15}}>
<Text>Hello</Text>
</Layout>
</TouchableShadow>
</Layout>
);
};

const mapDispatchToProps = (dispatch: Object) => {
const mapStateToProps = (state: any) => {
return {
theme: state.theme,
};
};

}
}
const mapDispatchToProps = (dispatch: any) => {
return {};
};

export const HomePage = connect(mapStateToProps, mapDispatchToProps)(HomePageC);
export const HomePage = connect(mapStateToProps, mapDispatchToProps)(HomePageC);
42 changes: 28 additions & 14 deletions src/pages/Settings/index.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
import React from 'react';
import { Layout, Text, List, ListItem } from '@ui-kitten/components';
import { connect } from 'react-redux';
import { SafeAreaView } from 'react-native';
import {Layout, Text, List, ListItem} from '@ui-kitten/components';
import {connect} from 'react-redux';
import {SafeAreaView} from 'react-native';

const data = ['Theme', 'Password']
const SettingsPageC = () => {
const renderItem = ({ item, index }) => (
<ListItem title={`${item} ${index + 1}`}/>
import {PageHeader} from '../../components/Page/PageHeader';

const SettingsPageC = (props: any) => {
const data = [
{
title: 'Toggle theme',
onPress: () => {
props.toggleTheme();
},
},
];

const renderItem = ({item, index}) => (
<ListItem title={`${item.title}`} onPress={item.onPress} />
);
return (
<Layout style={{height: '100%'}}>
<PageHeader title="Settings" theme={props.theme} />
<List data={data} renderItem={renderItem}>
<Text>Hello</Text>
</List>
</Layout>
)
}
);
};

const mapStateToProps = (state: any) => {
console.log(state.theme);
return {
theme: state.theme,
};
};

const mapDispatchToProps = (dispatch: any) => {
return {
toggleTheme: () => dispatch({type: 'TOGGLE_THEME'}),
};
};

}
}

export const SettingsPage = connect(mapStateToProps, mapDispatchToProps)(SettingsPageC);
export const SettingsPage = connect(
mapStateToProps,
mapDispatchToProps,
)(SettingsPageC);
7 changes: 6 additions & 1 deletion src/store/reducer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
const initialState = {
orientation: 'portrait', //portrait/landscape
theme: 'dark', //dark/light
theme: 'light', //dark/light
}

export const reducer = (state = initialState, action) => {
switch (action.type) {
case 'TOGGLE_THEME':
return {
...state,
theme: (state.theme === 'dark') ? 'light' : 'dark'
}
default:
return {
...state
Expand Down

0 comments on commit 7c82219

Please sign in to comment.