Skip to content

Commit dc54851

Browse files
Add files via upload
1 parent 7b1ffd8 commit dc54851

14 files changed

+265
-71
lines changed

app/components/AppPicker.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import React, { useState } from "react";
2+
import {
3+
View,
4+
StyleSheet,
5+
TouchableWithoutFeedback,
6+
Modal,
7+
Button,
8+
FlatList,
9+
} from "react-native";
10+
import { MaterialCommunityIcons } from "@expo/vector-icons";
11+
12+
import AppText from "./AppText";
13+
import Screen from "./Screen";
14+
import defaultStyles from "../config/styles";
15+
import PickerItem from "./PickerItem";
16+
17+
function AppPicker({ icon, items, onSelectItem, placeholder, selectedItem }) {
18+
const [modalVisible, setModalVisible] = useState(false);
19+
20+
return (
21+
<>
22+
<TouchableWithoutFeedback onPress={() => setModalVisible(true)}>
23+
<View style={styles.container}>
24+
{icon && (
25+
<MaterialCommunityIcons
26+
name={icon}
27+
size={20}
28+
color={defaultStyles.colors.medium}
29+
style={styles.icon}
30+
/>
31+
)}
32+
<AppText style={styles.text}>
33+
{selectedItem ? selectedItem.label : placeholder}
34+
</AppText>
35+
<MaterialCommunityIcons
36+
name="chevron-down"
37+
size={20}
38+
color={defaultStyles.colors.medium}
39+
/>
40+
</View>
41+
</TouchableWithoutFeedback>
42+
<Modal visible={modalVisible} animationType="slide">
43+
<Screen>
44+
<Button title="Close" onPress={() => setModalVisible(false)} />
45+
<FlatList
46+
data={items}
47+
keyExtractor={(item) => item.value.toString()}
48+
renderItem={({ item }) => (
49+
<PickerItem
50+
label={item.label}
51+
onPress={() => {
52+
setModalVisible(false);
53+
onSelectItem(item);
54+
}}
55+
/>
56+
)}
57+
/>
58+
</Screen>
59+
</Modal>
60+
</>
61+
);
62+
}
63+
64+
const styles = StyleSheet.create({
65+
container: {
66+
backgroundColor: defaultStyles.colors.light,
67+
borderRadius: 25,
68+
flexDirection: "row",
69+
width: "100%",
70+
padding: 15,
71+
marginVertical: 10,
72+
},
73+
icon: {
74+
marginRight: 10,
75+
},
76+
text: {
77+
flex: 1,
78+
},
79+
});
80+
81+
export default AppPicker;

app/components/AppText.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from "react";
2-
import { Text, StyleSheet, Platform } from "react-native";
3-
import defaultStyles from '../config/styles'
4-
function AppText({ children, style }) {
5-
return <Text style={[defaultStyles, style]}>{children}</Text>;
6-
}
2+
import { Text } from "react-native";
73

4+
import defaultStyles from "../config/styles";
85

6+
function AppText({ children, style }) {
7+
return <Text style={[defaultStyles.text, style]}>{children}</Text>;
8+
}
99

1010
export default AppText;

app/components/AppTextInput.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
import React from "react";
2-
import { View, StyleSheet, TextInput } from "react-native";
2+
import { View, TextInput, StyleSheet } from "react-native";
33
import { MaterialCommunityIcons } from "@expo/vector-icons";
4-
import colors from "../config/colors";
5-
import defaultStyles from "../config/styles"
4+
5+
import defaultStyles from "../config/styles";
6+
67
function AppTextInput({ icon, ...otherProps }) {
78
return (
8-
<View styles={styles.container}>
9+
<View style={styles.container}>
910
{icon && (
1011
<MaterialCommunityIcons
1112
name={icon}
1213
size={20}
13-
color={colors.medium}
14+
color={defaultStyles.colors.medium}
1415
style={styles.icon}
1516
/>
1617
)}
1718
<TextInput style={defaultStyles.text} {...otherProps} />
1819
</View>
1920
);
2021
}
22+
2123
const styles = StyleSheet.create({
2224
container: {
23-
backgroundColor: colors.light,
25+
backgroundColor: defaultStyles.colors.light,
2426
borderRadius: 25,
2527
flexDirection: "row",
2628
width: "100%",
@@ -31,4 +33,5 @@ const styles = StyleSheet.create({
3133
marginRight: 10,
3234
},
3335
});
36+
3437
export default AppTextInput;

app/components/Icon.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react";
2-
import {View} from "react-native";
3-
import {MaterialCommunityIcons} from "@expo/vector-icons";
2+
import { View } from "react-native";
3+
import { MaterialCommunityIcons } from "@expo/vector-icons";
4+
45
function Icon({
56
name,
67
size = 40,
@@ -18,7 +19,6 @@ function Icon({
1819
alignItems: "center",
1920
}}
2021
>
21-
2222
<MaterialCommunityIcons name={name} color={iconColor} size={size * 0.5} />
2323
</View>
2424
);

app/components/ListItem.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,25 @@ import {
77
TouchableHighlight,
88
} from "react-native";
99
import AppText from "./AppText";
10+
import Swipeable from "react-native-gesture-handler/Swipeable";
1011

1112
import colors from "../config/colors";
12-
import Swipeable from "react-native-gesture-handler/Swipeable";
13+
1314
function ListItem({
1415
title,
1516
subTitle,
1617
image,
18+
IconComponent,
1719
onPress,
1820
renderRightActions,
19-
ImageComponent
2021
}) {
2122
return (
2223
<Swipeable renderRightActions={renderRightActions}>
23-
<TouchableHighlight onPress={onPress} underlayColor={colors.light}>
24+
<TouchableHighlight underlayColor={colors.light} onPress={onPress}>
2425
<View style={styles.container}>
25-
{ImageComponent}
26+
{IconComponent}
2627
{image && <Image style={styles.image} source={image} />}
27-
<View style={styles.detailContainer}>
28+
<View style={styles.detailsContainer}>
2829
<AppText style={styles.title}>{title}</AppText>
2930
{subTitle && <AppText style={styles.subTitle}>{subTitle}</AppText>}
3031
</View>
@@ -40,6 +41,10 @@ const styles = StyleSheet.create({
4041
padding: 15,
4142
backgroundColor: colors.white,
4243
},
44+
detailsContainer: {
45+
marginLeft: 10,
46+
justifyContent: "center",
47+
},
4348
image: {
4449
width: 70,
4550
height: 70,
@@ -51,10 +56,6 @@ const styles = StyleSheet.create({
5156
title: {
5257
fontWeight: "500",
5358
},
54-
detailContainer: {
55-
marginLeft: 10,
56-
justifyContent: "center",
57-
},
5859
});
5960

6061
export default ListItem;
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
import React from "react";
22
import { View, StyleSheet, TouchableWithoutFeedback } from "react-native";
3-
import colors from "../config/colors";
43
import { MaterialCommunityIcons } from "@expo/vector-icons";
4+
5+
import colors from "../config/colors";
6+
57
function ListItemDeleteAction({ onPress }) {
68
return (
79
<TouchableWithoutFeedback onPress={onPress}>
8-
<View
9-
styles={{
10-
backgroundColor: "red",
11-
width: 70,
12-
}}
13-
>
10+
<View style={styles.container}>
1411
<MaterialCommunityIcons
1512
name="trash-can"
1613
size={35}
17-
color={colors.black}
14+
color={colors.white}
1815
/>
1916
</View>
2017
</TouchableWithoutFeedback>
2118
);
2219
}
23-
const styles = StyleSheet.create({});
20+
21+
const styles = StyleSheet.create({
22+
container: {
23+
backgroundColor: colors.danger,
24+
width: 70,
25+
justifyContent: "center",
26+
alignItems: "center",
27+
},
28+
});
29+
2430
export default ListItemDeleteAction;

app/components/ListItemSeparator.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from "react";
2+
import { StyleSheet, View } from "react-native";
3+
4+
import colors from "../config/colors";
5+
6+
function ListItemSeparator() {
7+
return <View style={styles.separator} />;
8+
}
9+
10+
const styles = StyleSheet.create({
11+
separator: {
12+
width: "100%",
13+
height: 1,
14+
backgroundColor: colors.light,
15+
},
16+
});
17+
18+
export default ListItemSeparator;

app/components/PickerItem.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from "react";
2+
import { TouchableOpacity, StyleSheet } from "react-native";
3+
import AppText from "./AppText";
4+
5+
function PickerItem({ label, onPress }) {
6+
return (
7+
<TouchableOpacity onPress={onPress}>
8+
<AppText style={styles.text}>{label}</AppText>
9+
</TouchableOpacity>
10+
);
11+
}
12+
13+
const styles = StyleSheet.create({
14+
text: {
15+
padding: 20,
16+
},
17+
});
18+
19+
export default PickerItem;

app/components/Screen.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import React from "react";
22
import Constants from "expo-constants";
3-
import { SafeAreaView, StyleSheet, View } from "react-native";
3+
import { StyleSheet, SafeAreaView, View } from "react-native";
4+
45
function Screen({ children, style }) {
56
return (
67
<SafeAreaView style={[styles.screen, style]}>
7-
<View>{children}</View>
8+
<View style={style}>{children}</View>
89
</SafeAreaView>
910
);
1011
}
12+
1113
const styles = StyleSheet.create({
1214
screen: {
1315
paddingTop: Constants.statusBarHeight,
1416
flex: 1,
1517
},
1618
});
19+
1720
export default Screen;

app/config/colors.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
black: "#000",
55
white: "#fff",
66
medium: "#6e6969",
7-
light : "#f8f4f4",
8-
danger :"red",
9-
dark:"#0c0c0c"
7+
light: "#f8f4f4",
8+
dark: "#0c0c0c",
9+
danger: "#ff5252",
1010
};

0 commit comments

Comments
 (0)