Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import React, { useState } from 'react';
  2. import { View, StyleSheet, TextInput, Text, ScrollView } from 'react-native';
  3. import { Appbar, Menu, Avatar, useTheme } from 'react-native-paper';
  4. import Icon from 'react-native-vector-icons/MaterialIcons';
  5. import dpuser from "@/assets/images/userdp.png";
  6. const Home = () => {
  7. const { colors, fonts } = useTheme();
  8. const [menuVisible, setMenuVisible] = useState(false);
  9. const [searchInput, setSearchInput] = useState("")
  10. const renderNotification = () => {
  11. return (
  12. <View style={{marginBottom:30, borderBottomWidth:1, borderBottomColor:"rgba(57, 104, 104, 0.3)"}}>
  13. <View style={{ flexDirection: "row", marginBottom: 10 }}>
  14. <Avatar.Image size={60} source={dpuser}></Avatar.Image>
  15. <View style={{ flex: 1, justifyContent: "center", paddingStart: 15, position:"relative", justifyContent:"space-evenly" }}>
  16. <Text style={{ fontWeight: "700", position:"absolute", top:5, right:0, color:"rgba(0,0,0,0.3)" }}>7:55AM</Text>
  17. <Text style={{ fontWeight: "700" }}>Invest Pahang</Text>
  18. <Text style={{ fontWeight: "700" }}>ID No : Ariffudin@PSK</Text>
  19. </View>
  20. </View>
  21. <Text style={{ fontWeight: "700", marginBottom:10 }}>Muhammad Ariffudin is working from home today</Text>
  22. </View>
  23. )
  24. }
  25. return (
  26. <View style={[styles.container, { backgroundColor: colors.background }]}>
  27. <Appbar.Header>
  28. <Avatar.Image size={50} source={dpuser}></Avatar.Image>
  29. <View style={styles.titleContainer}>
  30. <Appbar.Content title="General" titleStyle={[fonts.titleLarge, styles.title]} />
  31. </View>
  32. {/* Menu Component */}
  33. <Menu
  34. visible={menuVisible}
  35. onDismiss={() => setMenuVisible(false)}
  36. anchor={
  37. <Appbar.Action icon="dots-vertical" onPress={() => setMenuVisible(true)} />
  38. }
  39. >
  40. <Menu.Item onPress={() => console.log('Profile Clicked')} title="Profile" />
  41. <Menu.Item onPress={() => console.log('Settings Clicked')} title="Settings" />
  42. <Menu.Item onPress={() => console.log('Logout Clicked')} title="Logout" />
  43. </Menu>
  44. </Appbar.Header>
  45. <View style={styles.tabContainer}>
  46. <Text style={[styles.tabButton, fonts.titleMedium, { fontWeight: "bold" }, { borderBottomWidth: 2, borderBottomColor: colors.secondary, color: colors.secondary }]}>General </Text>
  47. <Text style={[styles.tabButton, { fontWeight: "bold" }, fonts.titleMedium]}>Request <Text style={styles.badge}>1</Text></Text>
  48. </View>
  49. <View style={styles.searchSection}>
  50. <TextInput
  51. style={styles.input}
  52. placeholder="Search"
  53. onChangeText={setSearchInput}
  54. value={searchInput}
  55. underlineColorAndroid="transparent"
  56. placeholderTextColor="#D9D9D9"
  57. />
  58. <Icon name="search" size={20} color="#888" style={styles.icon} />
  59. </View>
  60. <View style={{flex:1}}>
  61. <ScrollView>
  62. <Text style={[fonts.titleMedium, { fontWeight: "bold", marginBottom: 15 }]}>Today</Text>
  63. {[1,2].map(() => renderNotification())}
  64. <Text style={[fonts.titleMedium, { fontWeight: "bold", marginBottom: 15 }]}>Yesterday</Text>
  65. {[1,2].map(() => renderNotification())}
  66. <Text style={[fonts.titleMedium, { fontWeight: "bold", marginBottom: 15 }]}>Older</Text>
  67. {[1,2].map(() => renderNotification())}
  68. </ScrollView>
  69. </View>
  70. </View>
  71. );
  72. };
  73. const styles = StyleSheet.create({
  74. container: {
  75. flex: 1,
  76. padding: 20,
  77. width: '100%',
  78. },
  79. badge: {
  80. backgroundColor: "#BB5C3F",
  81. color: "#FFF",
  82. borderRadius: 100,
  83. paddingVertical: 4,
  84. paddingHorizontal: 6,
  85. fontSize: 10,
  86. fontWeight: "400",
  87. verticalAlign: "middle",
  88. marginStart: 5
  89. },
  90. tabContainer: {
  91. flexDirection: "row",
  92. marginBottom: 20
  93. },
  94. tabButton: {
  95. fontWeight: "bold",
  96. paddingVertical: 15,
  97. width: "50%",
  98. textAlign: "center",
  99. active: {
  100. borderBottomWidth: 2,
  101. }
  102. },
  103. titleContainer: {
  104. flex: 1,
  105. alignItems: 'center',
  106. },
  107. title: {
  108. fontWeight: 'bold',
  109. },
  110. searchSection: {
  111. flexDirection: 'row',
  112. justifyContent: 'center',
  113. alignItems: 'center',
  114. marginBottom: 20
  115. },
  116. icon: {
  117. padding: 10,
  118. position: "absolute",
  119. right: 10,
  120. color: "#D9D9D9"
  121. },
  122. input: {
  123. height: 40,
  124. flex: 1,
  125. borderWidth: 1,
  126. paddingVertical: 10,
  127. paddingHorizontal: 20,
  128. borderRadius: 100,
  129. borderColor: "#C0CFD0"
  130. }
  131. });
  132. export default Home;