-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathindex.tsx
More file actions
95 lines (88 loc) · 2.47 KB
/
index.tsx
File metadata and controls
95 lines (88 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { Button } from "@/components/button";
import { ThemedText } from "@/components/themed-text";
import { BorderRadius, Spacing } from "@/constants/spacing";
import { useTheme } from "@/hooks/use-theme-color";
import { useSettingsStore } from "@/store/useSettingsStore";
import { showErrorToast } from "@/utils/toast";
import { useAssets } from "expo-asset";
import { Image } from "expo-image";
import { router } from "expo-router";
import { StyleSheet, View } from "react-native";
export default function HomeScreen() {
const [assets] = useAssets([
require("@/assets/images/plus.png"),
require("@/assets/images/gear.png"),
]);
const Theme = useTheme();
const { merchantId, isMerchantApiKeySet } = useSettingsStore();
const handleStartPayment = () => {
if (!merchantId || !isMerchantApiKeySet) {
router.push("/settings");
showErrorToast("Merchant information not configured");
return;
}
router.push("/amount");
};
const handleSettingsPress = () => {
router.push("/settings");
};
return (
<View style={styles.container}>
<Button
testID="new-sale-button"
onPress={handleStartPayment}
style={[
styles.actionButton,
{ backgroundColor: Theme["foreground-primary"] },
]}
>
<Image
source={assets?.[0]}
style={styles.actionButtonImage}
cachePolicy="memory-disk"
priority="high"
/>
<ThemedText fontSize={18}>New sale</ThemedText>
</Button>
<Button
testID="settings-button"
onPress={handleSettingsPress}
style={[
styles.actionButton,
{ backgroundColor: Theme["foreground-primary"] },
]}
>
<Image
source={assets?.[1]}
style={styles.actionButtonImage}
cachePolicy="memory-disk"
priority="high"
/>
<ThemedText fontSize={18}>Settings</ThemedText>
</Button>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingHorizontal: Spacing["spacing-5"],
paddingTop: Spacing["spacing-2"],
paddingBottom: Spacing["spacing-7"],
justifyContent: "center",
alignItems: "center",
gap: Spacing["spacing-3"],
},
actionButton: {
flex: 1,
justifyContent: "center",
alignItems: "center",
width: "100%",
borderRadius: BorderRadius["5"],
gap: Spacing["spacing-4"],
},
actionButtonImage: {
width: 32,
height: 32,
},
});