Home.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* Copyright (C) Click & Push Accessibility, Inc - All Rights Reserved
  2. * Unauthorized copying of this file, via any medium is strictly prohibited
  3. * Proprietary and confidential
  4. * Written and maintained by the Click & Push Development team
  5. * <dev@clicknpush.ca>, January 2022
  6. */
  7. import { FontAwesome } from "@expo/vector-icons";
  8. import { format, parseISO } from 'date-fns';
  9. import React, { memo } from "react";
  10. import { SafeAreaView, Text, TouchableOpacity, View } from "react-native";
  11. import { LMComment } from "../hooks/useComments";
  12. import { Landmark } from "../hooks/useLandmarks";
  13. import { authStore } from "../libs/auth/AuthStore";
  14. /**
  15. * Props for the {@link Comment} component.
  16. */
  17. export interface CommentProps {
  18. /**
  19. * The [comment]{@link LMComment} object being displayed by the {@link Comment} component.
  20. */
  21. comment: LMComment
  22. /**
  23. * Whether or not this comment is selected and should be highlighted
  24. */
  25. selected: boolean
  26. focusComment: (id: string) => void
  27. startEditingComment: (comment: LMComment) => void
  28. deleteComment: (id: string) => void
  29. }
  30. /**
  31. * Component that displays a {@link LMComment} object in a clean format.
  32. * @component
  33. */
  34. export const Comment: React.FC<CommentProps> = ({comment, selected, focusComment: selectComment, startEditingComment: startEditingComment, deleteComment}) => {
  35. return (
  36. <TouchableOpacity style={[{paddingHorizontal: 10}, selected ? {backgroundColor: '#E8E8E8'}: null]} onPress={() => selectComment(comment.id)}>
  37. <View style={{paddingTop: 10, flexDirection: 'row', justifyContent: 'space-between'}}>
  38. <Text style={{fontWeight: 'bold'}}>{comment.poster_name}:</Text>
  39. <Text style={{fontSize: 12, color: 'gray'}}>{format(parseISO(comment.timestamp.toString()), "MMMM do, yyyy h:mma")}</Text>
  40. </View>
  41. <View style={{marginVertical: 10}}>
  42. <Text style={{paddingBottom: 10}} >{comment.content}</Text>
  43. <View style={{flexDirection: 'row', alignSelf: 'flex-end'}}>
  44. {comment.edited ? <Text style={{color: 'grey', alignSelf: 'flex-end'}}>Edited</Text> : null}
  45. {selected && comment.poster == authStore.userId ?
  46. <View style={{marginTop: 10, flexDirection: 'row', alignSelf: 'flex-end'}}>
  47. <FontAwesome size={25} name="edit" style={{paddingTop: 1, marginLeft: 20}} onPress={() => startEditingComment(comment)}/>
  48. <FontAwesome color="red" size={25} style={{marginLeft: 15}} name="trash" onPress={() => deleteComment(comment.id)}/>
  49. </View> : null}
  50. </View>
  51. </View>
  52. </TouchableOpacity>
  53. )}
  54. /**
  55. * Props for the {@link LandmarkDetails} component.
  56. */
  57. export interface LandmarkDetailsProps {
  58. /**
  59. * The {@link Landmark} object being displayed/edited in the {@link LandmarkDetails} modal.
  60. */
  61. landmark: Landmark | undefined
  62. /**
  63. * A callback passed from the parent {@link Map} that toggles the visibility of the {@link LandmarkDetails} modal.
  64. */
  65. setVisible: (state: boolean) => void;
  66. /**
  67. * A callback passed from the parent {@link Map} that toggles the ability to edit the {@link Landmark} in {@link LandmarkDetails} modal.
  68. */
  69. setEditing: (state: boolean) => void;
  70. /**
  71. * A flag that determines whether the properties of the {@link Landmark} displayed in the {@link LandmarkDetails} modal can be edited
  72. */
  73. editingEnabled: boolean
  74. }
  75. /**
  76. * Component that renders the details of a selected {@link Landmark} and allows the user to edit those details. Contained within a [react-native-modal]{@link https://github.com/react-native-modal/react-native-modal}.
  77. * @component
  78. * @category Map
  79. */
  80. const Home: React.FC = () => {
  81. return (
  82. <SafeAreaView >
  83. <Text>Home placeholder</Text>
  84. </SafeAreaView>
  85. )
  86. }
  87. export default memo(Home);