upd : tampilan edit komentar
Deskripsi: - menampilkan tulisan edited jika komentar telah di edit - menampilkan modal jika komentar di longpress No Issues
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
|
import AlertKonfirmasi from "@/components/alertKonfirmasi";
|
||||||
import BorderBottomItem from "@/components/borderBottomItem";
|
import BorderBottomItem from "@/components/borderBottomItem";
|
||||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||||
import HeaderRightDiscussionGeneralDetail from "@/components/discussion_general/headerDiscussionDetail";
|
import HeaderRightDiscussionGeneralDetail from "@/components/discussion_general/headerDiscussionDetail";
|
||||||
|
import DrawerBottom from "@/components/drawerBottom";
|
||||||
import ImageUser from "@/components/imageNew";
|
import ImageUser from "@/components/imageNew";
|
||||||
import { InputForm } from "@/components/inputForm";
|
import { InputForm } from "@/components/inputForm";
|
||||||
import LabelStatus from "@/components/labelStatus";
|
import LabelStatus from "@/components/labelStatus";
|
||||||
|
import MenuItemRow from "@/components/menuItemRow";
|
||||||
import Skeleton from "@/components/skeleton";
|
import Skeleton from "@/components/skeleton";
|
||||||
import SkeletonContent from "@/components/skeletonContent";
|
import SkeletonContent from "@/components/skeletonContent";
|
||||||
import Text from '@/components/Text';
|
import Text from '@/components/Text';
|
||||||
@@ -14,7 +17,7 @@ import Styles from "@/constants/Styles";
|
|||||||
import { apiGetDiscussionGeneralOne, apiSendDiscussionGeneralCommentar } from "@/lib/api";
|
import { apiGetDiscussionGeneralOne, apiSendDiscussionGeneralCommentar } from "@/lib/api";
|
||||||
import { getDB } from "@/lib/firebaseDatabase";
|
import { getDB } from "@/lib/firebaseDatabase";
|
||||||
import { useAuthSession } from "@/providers/AuthProvider";
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
import { Ionicons, MaterialIcons } from "@expo/vector-icons";
|
import { Ionicons, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons";
|
||||||
import { ref } from '@react-native-firebase/database';
|
import { ref } from '@react-native-firebase/database';
|
||||||
import { useHeaderHeight } from '@react-navigation/elements';
|
import { useHeaderHeight } from '@react-navigation/elements';
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||||
@@ -39,6 +42,8 @@ type PropsKomentar = {
|
|||||||
idUser: string
|
idUser: string
|
||||||
img: string
|
img: string
|
||||||
username: string
|
username: string
|
||||||
|
isEdited: boolean
|
||||||
|
updatedAt: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function DetailDiscussionGeneral() {
|
export default function DetailDiscussionGeneral() {
|
||||||
@@ -57,6 +62,11 @@ export default function DetailDiscussionGeneral() {
|
|||||||
const headerHeight = useHeaderHeight();
|
const headerHeight = useHeaderHeight();
|
||||||
const [detailMore, setDetailMore] = useState<any>([])
|
const [detailMore, setDetailMore] = useState<any>([])
|
||||||
const [loadingSendKomentar, setLoadingSendKomentar] = useState(false)
|
const [loadingSendKomentar, setLoadingSendKomentar] = useState(false)
|
||||||
|
const [isVisible, setVisible] = useState(false)
|
||||||
|
const [selectKomentar, setSelectKomentar] = useState({
|
||||||
|
id: '',
|
||||||
|
comment: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -138,6 +148,11 @@ export default function DetailDiscussionGeneral() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleMenuKomentar(id: string, comment: string) {
|
||||||
|
setSelectKomentar({ id, comment })
|
||||||
|
setVisible(true)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
@@ -204,6 +219,7 @@ export default function DetailDiscussionGeneral() {
|
|||||||
title={item.username}
|
title={item.username}
|
||||||
rightTopInfo={item.createdAt}
|
rightTopInfo={item.createdAt}
|
||||||
desc={item.comment}
|
desc={item.comment}
|
||||||
|
rightBottomInfo={item.isEdited ? "Edited" : ""}
|
||||||
descEllipsize={detailMore.includes(item.id) ? false : true}
|
descEllipsize={detailMore.includes(item.id) ? false : true}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setDetailMore((prev: any) => {
|
setDetailMore((prev: any) => {
|
||||||
@@ -214,6 +230,9 @@ export default function DetailDiscussionGeneral() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
|
onLongPress={() => {
|
||||||
|
handleMenuKomentar(item.id, item.comment)
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -268,6 +287,29 @@ export default function DetailDiscussionGeneral() {
|
|||||||
</View>
|
</View>
|
||||||
</KeyboardAvoidingView>
|
</KeyboardAvoidingView>
|
||||||
</View >
|
</View >
|
||||||
|
|
||||||
|
<DrawerBottom animation="slide" isVisible={isVisible} setVisible={setVisible} title="Komentar">
|
||||||
|
<View style={Styles.rowItemsCenter}>
|
||||||
|
<MenuItemRow
|
||||||
|
icon={<MaterialCommunityIcons name="pencil-outline" color="black" size={25} />}
|
||||||
|
title="Edit"
|
||||||
|
onPress={() => {
|
||||||
|
setVisible(false)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<MenuItemRow
|
||||||
|
icon={<MaterialIcons name="delete" color="black" size={25} />}
|
||||||
|
title="Hapus"
|
||||||
|
onPress={() => {
|
||||||
|
AlertKonfirmasi({
|
||||||
|
title: 'Konfirmasi',
|
||||||
|
desc: 'Apakah anda yakin ingin menghapus komentar?',
|
||||||
|
onPress: () => { setVisible(false) }
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</DrawerBottom>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ type Props = {
|
|||||||
desc?: string
|
desc?: string
|
||||||
rightTopInfo?: string
|
rightTopInfo?: string
|
||||||
onPress?: () => void
|
onPress?: () => void
|
||||||
|
onLongPress?: () => void
|
||||||
borderType: 'all' | 'bottom' | 'none'
|
borderType: 'all' | 'bottom' | 'none'
|
||||||
leftBottomInfo?: React.ReactNode | string
|
leftBottomInfo?: React.ReactNode | string
|
||||||
rightBottomInfo?: React.ReactNode | string
|
rightBottomInfo?: React.ReactNode | string
|
||||||
@@ -21,13 +22,13 @@ type Props = {
|
|||||||
textColor?: string
|
textColor?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function BorderBottomItem({ title, subtitle, icon, desc, onPress, rightTopInfo, borderType, leftBottomInfo, rightBottomInfo, titleWeight, bgColor, width, descEllipsize, textColor }: Props) {
|
export default function BorderBottomItem({ title, subtitle, icon, desc, onPress, onLongPress, rightTopInfo, borderType, leftBottomInfo, rightBottomInfo, titleWeight, bgColor, width, descEllipsize, textColor }: Props) {
|
||||||
const lebarDim = Dimensions.get("window").width;
|
const lebarDim = Dimensions.get("window").width;
|
||||||
const lebar = width ? lebarDim * width / 100 : 'auto';
|
const lebar = width ? lebarDim * width / 100 : 'auto';
|
||||||
const textColorFix = textColor ? textColor : 'black';
|
const textColorFix = textColor ? textColor : 'black';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable style={[borderType == 'bottom' ? Styles.wrapItemBorderBottom : borderType == 'all' ? Styles.wrapItemBorderAll : Styles.wrapItemBorderNone, bgColor && bgColor == 'white' && ColorsStatus.white]} onPress={onPress}>
|
<Pressable onLongPress={onLongPress} style={[borderType == 'bottom' ? Styles.wrapItemBorderBottom : borderType == 'all' ? Styles.wrapItemBorderAll : Styles.wrapItemBorderNone, bgColor && bgColor == 'white' && ColorsStatus.white]} onPress={onPress}>
|
||||||
<View style={[Styles.rowItemsCenter]}>
|
<View style={[Styles.rowItemsCenter]}>
|
||||||
{icon}
|
{icon}
|
||||||
<View style={[Styles.rowSpaceBetween, width ? { width: lebar } : { width: '88%' }]}>
|
<View style={[Styles.rowSpaceBetween, width ? { width: lebar } : { width: '88%' }]}>
|
||||||
@@ -52,16 +53,16 @@ export default function BorderBottomItem({ title, subtitle, icon, desc, onPress,
|
|||||||
{
|
{
|
||||||
(leftBottomInfo || rightBottomInfo) &&
|
(leftBottomInfo || rightBottomInfo) &&
|
||||||
(
|
(
|
||||||
<View style={[Styles.rowSpaceBetween, Styles.mt10]}>
|
<View style={[rightBottomInfo && !leftBottomInfo ? Styles.rowSpaceBetweenReverse : Styles.rowSpaceBetween, Styles.mt05]}>
|
||||||
{
|
{
|
||||||
typeof leftBottomInfo == 'string' ?
|
typeof leftBottomInfo == 'string' ?
|
||||||
<Text style={[Styles.textInformation, Styles.cGray, { textAlign: 'left' }]}>{leftBottomInfo}</Text>
|
<Text style={[Styles.textInformation, Styles.cGray]}>{leftBottomInfo}</Text>
|
||||||
:
|
:
|
||||||
leftBottomInfo
|
leftBottomInfo
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
typeof rightBottomInfo == 'string' ?
|
typeof rightBottomInfo == 'string' ?
|
||||||
<Text style={[Styles.textInformation, Styles.mt05, Styles.cGray, { textAlign: 'right' }]}>{rightBottomInfo}</Text>
|
<Text style={[Styles.textInformation, Styles.cGray]}>{rightBottomInfo}</Text>
|
||||||
:
|
:
|
||||||
rightBottomInfo
|
rightBottomInfo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,6 +250,10 @@ const Styles = StyleSheet.create({
|
|||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
flexDirection: 'row'
|
flexDirection: 'row'
|
||||||
},
|
},
|
||||||
|
rowSpaceBetweenReverse: {
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
flexDirection: 'row-reverse'
|
||||||
|
},
|
||||||
rowItemsCenter: {
|
rowItemsCenter: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
alignItems: 'center'
|
alignItems: 'center'
|
||||||
|
|||||||
Reference in New Issue
Block a user