-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDashaScreen.jsx
More file actions
161 lines (148 loc) · 4.6 KB
/
DashaScreen.jsx
File metadata and controls
161 lines (148 loc) · 4.6 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// app/dasha.jsx
import React, { useState, useEffect } from 'react';
import { View, StyleSheet } from 'react-native';
import { Text, Button, Title, Paragraph } from 'react-native-paper';
import { useLocalSearchParams, useRouter } from 'expo-router';
export default function DashaScreen() {
const { dateOfBirth, timeOfBirth, placeOfBirth } = useLocalSearchParams();
const router = useRouter();
// Declare state variables
const [data, setData] = useState(null);
const [currentDasha, setCurrentDasha] = useState(null);
const [currentAntardasha, setCurrentAntardasha] = useState(null);
useEffect(() => {
fetchKundaliData();
}, []);
const fetchKundaliData = async () => {
try {
const response = await fetch('http://192.168.210.8:5000/kundali', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
date_of_birth: dateOfBirth,
time_of_birth: timeOfBirth,
place_of_birth: placeOfBirth,
}),
});
const result = await response.json();
console.log('API Response:', result);
setData(result);
setCurrentDasha(result.current_dasha);
setCurrentAntardasha(result.current_antardasha);
} catch (error) {
console.error('Error fetching Kundali data:', error);
}
};
if (!data) {
return (
<View style={styles.loadingContainer}>
<Text>Loading Dasha Data...</Text>
</View>
);
}
const handleGetPredictions = () => {
router.push({
pathname: '/ChatbotScreen',
params: {
dateOfBirth,
timeOfBirth,
placeOfBirth,
kundaliData: JSON.stringify(data),
},
});
};
return (
<View style={styles.container}>
<Title>Current Mahadasha</Title>
{currentDasha == null ? (
<Paragraph>No Mahadasha Data Available</Paragraph>
) : typeof currentDasha === 'string' ? (
<Paragraph>{currentDasha}</Paragraph>
) : (
<>
<Paragraph>Planet: {currentDasha.Planet}</Paragraph>
<Paragraph>Start Date: {currentDasha['Start Date']}</Paragraph>
<Paragraph>End Date: {currentDasha['End Date']}</Paragraph>
</>
)}
<Title style={styles.sectionTitle}>Current Antardasha</Title>
{currentAntardasha == null ? (
<Paragraph>No Antardasha Data Available</Paragraph>
) : typeof currentAntardasha === 'string' ? (
<Paragraph>{currentAntardasha}</Paragraph>
) : (
<>
<Paragraph>Planet: {currentAntardasha.Planet}</Paragraph>
<Paragraph>Start Date: {currentAntardasha['Start Date']}</Paragraph>
<Paragraph>End Date: {currentAntardasha['End Date']}</Paragraph>
</>
)}
<Button
mode="contained"
onPress={handleGetPredictions}
style={styles.button}
>
Get Predictions
</Button>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingHorizontal: 20,
paddingVertical: 30,
backgroundColor: '#F3F4F6', // Light gray background for a clean look
},
sectionTitle: {
marginTop: 20,
fontSize: 24,
fontWeight: '700',
color: '#4A4A4A', // Darker shade for section titles
textAlign: 'left',
},
mahadashaText: {
fontSize: 18,
fontWeight: 'bold',
color: '#4A4A4A', // Dark color for bold emphasis on Mahadasha
},
antardashaText: {
fontSize: 18,
fontWeight: '300', // Light font weight for Antardasha
color: '#6A1B9A', // Purple to maintain theme consistency
},
button: {
marginTop: 20,
paddingVertical: 14,
paddingHorizontal: 24,
borderRadius: 12, // Rounded corners for a polished look
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#6A1B9A', // Purple color for the button
shadowColor: '#6A1B9A',
shadowOffset: { width: 0, height: 4 },
shadowOpacity: 0.3,
shadowRadius: 6,
elevation: 6, // Elevated effect for standout appearance
},
buttonText: {
color: '#FFFFFF',
fontSize: 18,
fontWeight: 'bold',
letterSpacing: 0.8, // Slight letter spacing for readability
},
loadingContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#FFFFFF',
borderRadius: 12,
padding: 20,
shadowColor: '#000',
shadowOffset: { width: 0, height: 5 },
shadowOpacity: 0.15,
shadowRadius: 10,
elevation: 5, // Elevated look for visual depth
margin: 20,
},
});