You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.jsx 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. import React, { useState } from 'react';
  2. import { View, StyleSheet, TextInput, Text, ScrollView, Pressable } from 'react-native';
  3. import { Appbar, Menu, Avatar, useTheme, Button } from 'react-native-paper';
  4. import Icon from 'react-native-vector-icons/MaterialIcons';
  5. import dpuser from "@/assets/images/userdp.png";
  6. import { Link } from 'expo-router';
  7. const Home = () => {
  8. const { colors, fonts } = useTheme();
  9. const [menuVisible, setMenuVisible] = useState(false);
  10. const [searchInput, setSearchInput] = useState("")
  11. const [showRequest, setshowRequest] = useState(false)
  12. const [activeTab, setActiveTab] = useState('General');
  13. const renderNotification = () => {
  14. return (
  15. <Link href={"/home/status"} asChild>
  16. <View style={{ marginBottom: 30, borderBottomWidth: 1, borderBottomColor: "rgba(57, 104, 104, 0.3)" }}>
  17. <View style={{ flexDirection: "row", marginBottom: 10 }}>
  18. <Avatar.Image size={60} source={dpuser}></Avatar.Image>
  19. <View style={{ flex: 1, justifyContent: "center", paddingStart: 15, position: "relative", justifyContent: "space-evenly" }}>
  20. <Text style={{ fontWeight: "700", position: "absolute", top: 5, right: 0, color: "rgba(0,0,0,0.3)" }}>7:55AM</Text>
  21. <Text style={{ fontWeight: "700" }}>Invest Pahang</Text>
  22. <Text style={{ fontWeight: "700" }}>ID No : Ariffudin@PSK</Text>
  23. </View>
  24. </View>
  25. <Text style={{ fontWeight: "700", marginBottom: 10 }}>Muhammad Ariffudin is working from home today</Text>
  26. </View>
  27. </Link>
  28. )
  29. }
  30. const renderNotificationAction = () => {
  31. return (
  32. <View style={{ marginBottom: 30, borderBottomWidth: 1, paddingBottom: 15, borderBottomColor: "rgba(57, 104, 104, 0.3)" }}>
  33. <View style={{ flexDirection: "row", marginBottom: 10 }}>
  34. <Avatar.Image size={60} source={dpuser}></Avatar.Image>
  35. <View style={{ flex: 1, justifyContent: "center", paddingStart: 15, position: "relative", justifyContent: "space-evenly" }}>
  36. <Text style={{ fontWeight: "700", position: "absolute", top: 5, right: 0, color: "rgba(0,0,0,0.3)" }}>7:55AM</Text>
  37. <Text style={{ fontWeight: "700" }}>Invest Pahang</Text>
  38. <Text style={{ fontWeight: "700" }}>ID No : Ariffudin@PSK</Text>
  39. </View>
  40. </View>
  41. <Text style={{ fontWeight: "700", marginBottom: 10 }}>Muhammad Ariffudin is working from home today</Text>
  42. <View style={{ flexDirection: "row", justifyContent: "space-evenly", gap: 10 }}>
  43. <Button mode='outlined' style={{ paddingHorizontal: 35, borderColor: colors.primary }} onPress={() => { console.log("click") }}>Reject</Button>
  44. <Button mode='contained' style={{ paddingHorizontal: 35 }} onPress={() => { console.log("click") }}>Accept</Button>
  45. </View>
  46. </View>
  47. )
  48. }
  49. const renderNotificationResult = (result) => {
  50. return (
  51. <View style={{ marginBottom: 30, borderBottomWidth: 1, paddingBottom: 15, borderBottomColor: "rgba(57, 104, 104, 0.3)" }}>
  52. <View style={{ flexDirection: "row", marginBottom: 10 }}>
  53. <Avatar.Image size={60} source={dpuser}></Avatar.Image>
  54. <View style={{ flex: 1, justifyContent: "center", paddingStart: 15, position: "relative", justifyContent: "space-evenly" }}>
  55. <Text style={{ fontWeight: "700", position: "absolute", top: 5, right: 0, color: "rgba(0,0,0,0.3)" }}>7:55AM</Text>
  56. <Text style={{ fontWeight: "700" }}>Invest Pahang</Text>
  57. <Text style={{ fontWeight: "700" }}>ID No : Ariffudin@PSK</Text>
  58. </View>
  59. </View>
  60. <Text style={{ fontWeight: "700", marginBottom: 10 }}>Muhammad Ariffudin is working from home today</Text>
  61. <View style={{ flexDirection: "row" }}>
  62. {(result) ?
  63. <Text style={[fonts.titleSmall, { color: colors.primary }]}><Icon name="done" size={20} style={{ verticalAlign: "middle", marginEnd: 10 }} />Request Accepted</Text> :
  64. <Text style={[fonts.titleSmall, { color: colors.error }]}><Icon name="close" size={20} style={{ verticalAlign: "middle", marginEnd: 10 }} />Request Decline</Text>
  65. }
  66. </View>
  67. </View>
  68. )
  69. }
  70. return (
  71. <View style={[styles.container, { backgroundColor: colors.background }]}>
  72. <Appbar.Header>
  73. <Avatar.Image size={50} source={dpuser}></Avatar.Image>
  74. <View style={styles.titleContainer}>
  75. <Appbar.Content title="General" titleStyle={[fonts.titleLarge, styles.title]} />
  76. </View>
  77. {/* Menu Component */}
  78. <Menu
  79. visible={menuVisible}
  80. onDismiss={() => setMenuVisible(false)}
  81. anchor={
  82. <Appbar.Action icon="dots-vertical" onPress={() => setMenuVisible(true)} />
  83. }
  84. >
  85. <Menu.Item onPress={() => console.log('Profile Clicked')} title="Profile" />
  86. <Menu.Item onPress={() => console.log('Settings Clicked')} title="Settings" />
  87. <Menu.Item onPress={() => console.log('Logout Clicked')} title="Logout" />
  88. </Menu>
  89. </Appbar.Header>
  90. <View style={styles.tabContainer}>
  91. <Text style={[styles.tabButton, fonts.titleMedium, activeTab === 'General' && styles.activeTab]} onPress={() => { setActiveTab('General') }}>General</Text>
  92. <Text style={[styles.tabButton, fonts.titleMedium, activeTab === 'Request' && styles.activeTab]} onPress={() => { setActiveTab('Request') }}>Request <Text style={styles.badge}>1</Text></Text>
  93. </View>
  94. <View style={styles.searchSection}>
  95. <TextInput
  96. style={styles.input}
  97. placeholder="Search"
  98. onChangeText={setSearchInput}
  99. value={searchInput}
  100. underlineColorAndroid="transparent"
  101. placeholderTextColor="#D9D9D9"
  102. />
  103. <Icon name="search" size={20} color="#888" style={styles.icon} />
  104. </View>
  105. {(activeTab == 'General') && <View style={{ flex: 1 }}>
  106. <ScrollView>
  107. <Text style={[fonts.titleMedium, { fontWeight: "bold", marginBottom: 15 }]}>Today</Text>
  108. {[1, 2].map(() => renderNotification())}
  109. <Text style={[fonts.titleMedium, { fontWeight: "bold", marginBottom: 15 }]}>Yesterday</Text>
  110. {[1, 2].map(() => renderNotification())}
  111. <Text style={[fonts.titleMedium, { fontWeight: "bold", marginBottom: 15 }]}>Older</Text>
  112. {[1, 2].map(() => renderNotification())}
  113. </ScrollView>
  114. </View>}
  115. {(activeTab == 'Request') && <View style={{ flex: 1 }}>
  116. <ScrollView>
  117. {[1, 2].map(() => renderNotificationAction())}
  118. {[1].map(() => renderNotificationResult(true))}
  119. {[1].map(() => renderNotificationResult(false))}
  120. </ScrollView>
  121. </View>}
  122. </View>
  123. );
  124. };
  125. const styles = StyleSheet.create({
  126. container: {
  127. flex: 1,
  128. padding: 20,
  129. width: '100%',
  130. },
  131. badge: {
  132. backgroundColor: "#BB5C3F",
  133. color: "#FFF",
  134. borderRadius: 100,
  135. paddingVertical: 4,
  136. paddingHorizontal: 6,
  137. fontSize: 10,
  138. fontWeight: "400",
  139. verticalAlign: "middle",
  140. marginStart: 5
  141. },
  142. activeTab: {
  143. borderBottomWidth: 2,
  144. borderBottomColor: "#396868",
  145. color: "#396868",
  146. fontWeight: "bold"
  147. },
  148. tabContainer: {
  149. flexDirection: "row",
  150. marginBottom: 20
  151. },
  152. tabButton: {
  153. fontWeight: "bold",
  154. paddingVertical: 15,
  155. width: "50%",
  156. textAlign: "center",
  157. active: {
  158. borderBottomWidth: 2,
  159. }
  160. },
  161. titleContainer: {
  162. flex: 1,
  163. alignItems: 'center',
  164. },
  165. title: {
  166. fontWeight: 'bold',
  167. },
  168. searchSection: {
  169. flexDirection: 'row',
  170. justifyContent: 'center',
  171. alignItems: 'center',
  172. marginBottom: 20
  173. },
  174. icon: {
  175. padding: 10,
  176. position: "absolute",
  177. right: 10,
  178. color: "#D9D9D9"
  179. },
  180. input: {
  181. height: 40,
  182. flex: 1,
  183. borderWidth: 1,
  184. paddingVertical: 10,
  185. paddingHorizontal: 20,
  186. borderRadius: 100,
  187. borderColor: "#C0CFD0"
  188. }
  189. });
  190. export default Home;