-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
174 lines (153 loc) · 4.03 KB
/
App.tsx
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
162
163
164
165
166
167
168
169
170
171
172
173
174
import React, { useState, useRef } from 'react';
import { View, Text, TextInput, SafeAreaView, TouchableOpacity, ScrollView, Modal, Pressable } from 'react-native';
import { StyleSheet } from 'react-native';
function HomeScreen() {
const [count, setCount] = useState(0);
const [history, setHistory] = useState<string[]>([]);
const [modalVisible, setModalVisible] = useState(false);
const descriptionInputRef = useRef(null);
const handleCount = () => {
setCount(count + 1);
};
const handleReset = () => {
setCount(0);
saveHistory(count);
};
const saveHistory = (countValue: number) => {
const historyItem = `Count ${history.length + 1}) ${countValue} times`;
setHistory([...history, historyItem]);
};
const handleHistoryPress = () => {
setModalVisible(true);
};
const handleModalClose = () => {
setModalVisible(false);
};
return (
<SafeAreaView style={styles.container}>
<Text style={styles.header}>Tasbeeh Counter</Text>
<Text style={styles.counter}>{count}</Text>
<View style={styles.buttonContainer}>
<TouchableOpacity onPress={handleCount}>
<Text style={[styles.buttonText, { backgroundColor: '#4CAF50' }]}>COUNT</Text>
</TouchableOpacity>
<TouchableOpacity onPress={handleHistoryPress}>
<Text style={[styles.buttonText, { backgroundColor: '#2196F3' }]}>HISTORY</Text>
</TouchableOpacity>
<TouchableOpacity onPress={handleReset}>
<Text style={[styles.buttonText, { backgroundColor: '#FF5733' }]}>RESET</Text>
</TouchableOpacity>
</View>
<TextInput
ref={descriptionInputRef}
style={styles.messageInput}
placeholder={'Description Add help for using App'}
/>
<Modal
animationType="slide"
transparent={true}
visible={modalVisible}
onRequestClose={handleModalClose}
>
<View style={styles.modalContainer}>
<View style={styles.modalContent}>
<Text style={styles.modalHeader}>History</Text>
<ScrollView style={styles.historyContainer}>
{history.map((item, index) => (
<Text key={index} style={styles.historyItem}>{item}</Text>
))}
</ScrollView>
<Pressable onPress={handleModalClose}>
<Text style={styles.closeButton}>Close</Text>
</Pressable>
</View>
</View>
</Modal>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'black',
},
header: {
fontSize: 35,
color: '#ffffff',
backgroundColor: 'red',
paddingHorizontal: 73,
top:28,
fontWeight: '400'
},
counter: {
fontSize: 40,
fontWeight: 'bold',
backgroundColor: 'yellow',
padding: 10,
paddingHorizontal:30,
borderRadius: 5,
marginTop:165
},
buttonContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginBottom: 170,
},
buttonText: {
color: '#fff',
fontSize: 21,
width: 100,
height: 35,
borderRadius: 7,
textAlign: 'center',
paddingVertical: 5,
margin: 10,
fontWeight:'500',
top: 63,
},
messageInput: {
top: 30,
height: '20%',
width: '100%',
borderWidth: 1,
marginBottom:100,
paddingHorizontal: 10,
backgroundColor:'yellow',
fontWeight:'400',
fontSize: 20,
},
modalContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
modalContent: {
backgroundColor: '#fff',
padding: 20,
borderRadius: 10,
maxHeight: '80%',
width: '80%',
},
modalHeader: {
fontSize: 20,
fontWeight: 'bold',
marginBottom: 10,
},
historyContainer: {
maxHeight: 200,
marginBottom: 10,
},
historyItem: {
fontSize: 18,
marginTop: 5,
},
closeButton: {
fontSize: 18,
color: 'blue',
textAlign: 'center',
},
});
export default HomeScreen;