Skip to content

Commit 5ef3381

Browse files
committed
Completed structure for books list. Need to add storage and redux. Need better cell design and section header design. Need to design App Icon.
1 parent 0284c0e commit 5ef3381

File tree

8 files changed

+228
-55
lines changed

8 files changed

+228
-55
lines changed

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
"react": "16.9.0",
2020
"react-native": "0.61.5",
2121
"react-native-device-info": "^5.5.3",
22+
"react-native-elements": "^1.2.7",
23+
"react-native-extra-dimensions-android": "^1.2.5",
2224
"react-native-gesture-handler": "^1.6.1",
2325
"react-native-progress": "^4.1.2",
2426
"react-native-reanimated": "^1.8.0",
2527
"react-native-safe-area-context": "^0.7.3",
26-
"react-native-screens": "^2.4.0"
28+
"react-native-screens": "^2.4.0",
29+
"react-native-vector-icons": "^6.6.0"
2730
},
2831
"devDependencies": {
2932
"@babel/core": "^7.6.2",

src/components/cell.tsx

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
import * as React from 'react';
2-
import { View, StyleSheet, Image, Text } from "react-native";
2+
import { View, StyleSheet, Image, Text, ImageSourcePropType } from "react-native";
33
import { TouchableHighlight } from "react-native-gesture-handler";
44
import { Colors } from '../assets/';
55
import * as Progress from 'react-native-progress';
6+
import { Divider } from 'react-native-elements';
7+
8+
export interface CellProps {
9+
bookImage: ImageSourcePropType;
10+
title: string;
11+
percentFinished: number;
12+
onPress?: () => void;
13+
}
14+
15+
export function CellDivider() {
16+
return (
17+
<View>
18+
<Divider style={{ height: 0.5, backgroundColor: Colors.slategrey }}/>
19+
</View>
20+
)
21+
}
622

723
export default function Cell (props: any) {
824
const { bookImage, title, percentFinished, onPress } = props
@@ -56,4 +72,4 @@ const styles = StyleSheet.create({
5672
progressBar: {
5773

5874
}
59-
});
75+
});

src/navigation/BookListsStack.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import * as React from 'react';
2-
import Summaries from '../screens/summaries';
2+
import Books from '../screens/books/books';
33
import { createStackNavigator } from "@react-navigation/stack";
44

55
const Stack = createStackNavigator();
6-
// Change this to just have progressBarCell s and have a sorting option based on progess.
76

87
export default function BookListsStack () {
98
return (
109
<Stack.Navigator>
11-
<Stack.Screen name="summaries" component={Summaries}/>
10+
<Stack.Screen name="Books" component={Books}/>
1211
</Stack.Navigator>
1312
);
1413
}

src/screens/books/books.tsx

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import * as React from 'react';
2+
import { SectionList, Text, View, StyleSheet, ShadowPropTypesIOS } from "react-native";
3+
import { Colors, Images } from '../../assets';
4+
import { Divider } from 'react-native-elements';
5+
import Cell, { CellProps, CellDivider } from '../../components/cell';
6+
import EmptyBooks from './emptyBooks';
7+
8+
export default function Books (props: any) {
9+
const renderItem = (item: CellProps) => {
10+
return (
11+
<Cell {...item}/>
12+
)
13+
}
14+
15+
const renderSectionHeader = (title: string) => {
16+
return (
17+
<View style={styles.sectionHeaderContainer}>
18+
<Text style={styles.sectionHeaderTitle}>{title}</Text>
19+
</View>
20+
)
21+
}
22+
23+
const renderSectionSeparator = (title: string) => {
24+
return (
25+
<Divider style={{ height: 0.5, backgroundColor: Colors.blue }}/>
26+
)
27+
}
28+
29+
const data = [];
30+
if(props.currentlyReading) data.push({
31+
'title': 'Currently Reading',
32+
data: props.currentlyReading
33+
})
34+
if(props.wishList) data.push({
35+
'title': 'Wish List',
36+
data: props.wishList
37+
})
38+
if(props.completed) data.push({
39+
'title': 'Completed',
40+
data: props.completed
41+
})
42+
43+
return (
44+
<SectionList
45+
sections={data}
46+
ListEmptyComponent={EmptyBooks}
47+
ItemSeparatorComponent={CellDivider}
48+
renderItem={({ item }) => renderItem(item as CellProps)}
49+
renderSectionHeader={({ section: { title }}) => renderSectionHeader(title)}
50+
SectionSeparatorComponent={({ section: { title } }) => renderSectionSeparator(title)}
51+
stickySectionHeadersEnabled
52+
/>
53+
)
54+
}
55+
56+
const styles = StyleSheet.create({
57+
container: {
58+
flex: 1,
59+
backgroundColor: Colors.white
60+
},
61+
sectionHeaderContainer: {
62+
height: 54,
63+
backgroundColor: Colors.skyblue,
64+
justifyContent: 'center',
65+
paddingLeft: 10
66+
},
67+
sectionHeaderTitle: {
68+
textAlign: 'left',
69+
fontSize: 24
70+
}
71+
});

src/screens/books/emptyBooks.tsx

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as React from 'react';
2+
import { View, Image, StyleSheet } from "react-native";
3+
import { Images } from "../../assets/index";
4+
5+
export default function EmptyBooks() {
6+
return (
7+
<View style={styles.container}>
8+
<Image style={styles.image} source={Images.testImage}/>
9+
</View>
10+
)
11+
}
12+
13+
const styles = StyleSheet.create({
14+
container: {
15+
height: '100%',
16+
justifyContent: 'center',
17+
alignItems: 'center'
18+
},
19+
image:{
20+
height: 400,
21+
width: 250,
22+
marginTop: '30%'
23+
}
24+
});

src/screens/summaries.tsx

-40
This file was deleted.

src/utilities.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import { Platform } from "react-native";
1+
import { Dimensions, Platform } from "react-native";
22
import DeviceInfo from 'react-native-device-info';
33

44
//@ts-ignore
5-
const isAndroid = Platform.OS === "android"
5+
export const isAndroid = Platform.OS === "android"
66
//@ts-ignore
7-
const isIOS = Platform.OS === "ios"
7+
export const isIOS = Platform.OS === "ios"
88
//@ts-ignore
9-
const semanticVersion = DeviceInfo.getReadableVersion().split(".", 3).join(".")
9+
export const semanticVersion = DeviceInfo.getReadableVersion().split(".", 3).join(".")
1010
//@ts-ignore
11-
const isCharging = () => DeviceInfo.isBatteryCharging()
11+
export const isCharging = () => DeviceInfo.isBatteryCharging()
12+
export const deviceHeight = Dimensions.get('window').height;
13+
//@ts-ignore
14+
export const deviceWidth = Dimensions.get('window').width;

0 commit comments

Comments
 (0)