feat: redesign section progress, report, link, file, dan cancel pada project & division/task
- SectionProgress: progress bar animated, badge persentase, label status, task count - SectionReport: header ikon, left accent border, TextExpandable dengan label Indonesia - SectionLink: tap langsung buka URL, ikon per domain, long press untuk hapus - SectionFile: icon container konsisten 30×30 di semua section - SectionCancel: card subtle dengan warna error, konsisten dengan visual language baru - TextExpandable: fix bug show/hide tidak muncul setelah content diupdate - Tambah 14 style class baru di Styles.ts untuk menggantikan inline style - Terapkan semua perubahan ke fitur division/task - Fix menu "Edit Tugas" di sectionTanggalTugasTask yang terpotong karena overflow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,12 +19,11 @@ type Props = {
|
||||
onPress?: () => void
|
||||
}
|
||||
|
||||
// estimasi lebar chip berdasarkan panjang teks
|
||||
const CHAR_W = 6.5 // lebar rata-rata per karakter (font size 10)
|
||||
const ICON_W = 17 // icon 13px + margin 4px
|
||||
const PAD_H = 16 // paddingHorizontal 8 * 2
|
||||
const CHAR_W = 6.5
|
||||
const ICON_W = 17
|
||||
const PAD_H = 16
|
||||
const GAP = 6
|
||||
const PLUS_W = 72 // lebar chip "+X lainnya"
|
||||
const PLUS_W = 72
|
||||
|
||||
function estimateChipWidth(label: string) {
|
||||
return PAD_H + ICON_W + label.length * CHAR_W
|
||||
@@ -65,92 +64,90 @@ function getFileIcon(extension: string): keyof typeof MaterialCommunityIcons.gly
|
||||
return 'file-outline'
|
||||
}
|
||||
|
||||
const chipStyle = (colors: any) => ({
|
||||
flexDirection: 'row' as const,
|
||||
alignItems: 'center' as const,
|
||||
backgroundColor: colors.dimmed + '5',
|
||||
borderRadius: 6,
|
||||
borderWidth: 0.5,
|
||||
borderColor: colors.icon + '20',
|
||||
paddingHorizontal: 8,
|
||||
paddingVertical: 4,
|
||||
})
|
||||
|
||||
export default function ItemSectionTanggalTugas({ done, title, dateStart, dateEnd, files = [], onPress }: Props) {
|
||||
const { colors } = useTheme()
|
||||
const { colors, activeTheme } = useTheme()
|
||||
const [containerWidth, setContainerWidth] = useState(0)
|
||||
|
||||
const { visible, extra } = getVisibleChips(files, containerWidth)
|
||||
|
||||
function onRowLayout(e: LayoutChangeEvent) {
|
||||
function onChipsLayout(e: LayoutChangeEvent) {
|
||||
const w = e.nativeEvent.layout.width
|
||||
if (w !== containerWidth) setContainerWidth(w)
|
||||
}
|
||||
|
||||
const dimmed = colors.dimmed.slice(0, 7)
|
||||
const successColor = activeTheme === 'dark' ? '#51CF66' : colors.success
|
||||
const accentColor = done === true ? successColor : dimmed + '80'
|
||||
|
||||
return (
|
||||
<Pressable style={[Styles.mb15, { borderBottomColor: colors.icon + '20', borderBottomWidth: 1 }]} onPress={onPress}>
|
||||
<Pressable
|
||||
onPress={onPress}
|
||||
style={{
|
||||
flexDirection: 'row',
|
||||
borderRadius: 10,
|
||||
overflow: 'hidden',
|
||||
borderWidth: 1,
|
||||
borderColor: colors.icon + '18',
|
||||
backgroundColor: colors.card,
|
||||
marginBottom: 10,
|
||||
}}
|
||||
>
|
||||
{/* Accent bar kiri */}
|
||||
{done !== undefined && (
|
||||
<View style={{ width: 4, backgroundColor: accentColor }} />
|
||||
)}
|
||||
|
||||
{/* Status */}
|
||||
<View style={[Styles.rowItemsCenter]}>
|
||||
{done != undefined && (
|
||||
done ? (
|
||||
<>
|
||||
<MaterialCommunityIcons name="checkbox-marked-circle-outline" size={22} color={colors.text} style={[Styles.mr10]} />
|
||||
<Text>Selesai</Text>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<MaterialCommunityIcons name="checkbox-blank-circle-outline" size={22} color={colors.text} style={[Styles.mr10]} />
|
||||
<Text>Belum Selesai</Text>
|
||||
</>
|
||||
)
|
||||
)}
|
||||
</View>
|
||||
{/* Konten */}
|
||||
<View style={{ flex: 1, padding: 12 }}>
|
||||
|
||||
{/* Judul tugas */}
|
||||
<View style={[Styles.wrapPaper, Styles.noShadow, Styles.borderAll, Styles.mv10, Styles.p10, { backgroundColor: colors.card, borderColor: colors.icon + '20' }]}>
|
||||
<View style={[Styles.rowItemsCenter, { alignItems: 'flex-start' }]}>
|
||||
<MaterialCommunityIcons name="file-table-outline" size={22} color={colors.text} style={[Styles.mr10]} />
|
||||
<View style={[Styles.w90]}>
|
||||
<Text style={[Styles.textDefault]}>{title}</Text>
|
||||
</View>
|
||||
{/* Judul + badge status */}
|
||||
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 8 }}>
|
||||
<Text style={[Styles.textDefault, { flex: 1, marginRight: 8 }]}>{title}</Text>
|
||||
{done !== undefined && (
|
||||
<View style={{
|
||||
backgroundColor: done ? successColor + '25' : dimmed + '18',
|
||||
borderRadius: 20,
|
||||
paddingHorizontal: 8,
|
||||
paddingVertical: 3,
|
||||
alignSelf: 'flex-start',
|
||||
}}>
|
||||
<Text style={[Styles.textSmallSemiBold, { color: done ? successColor : colors.dimmed }]}>
|
||||
{done ? 'Selesai' : 'Belum Selesai'}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* Tanggal */}
|
||||
<View style={[Styles.rowSpaceBetween, Styles.mb15]}>
|
||||
<View style={[{ width: '48%' }]}>
|
||||
<Text style={[Styles.mb05]}>Tanggal Mulai</Text>
|
||||
<View style={[Styles.wrapPaper, Styles.noShadow, Styles.borderAll, Styles.p10, { backgroundColor: colors.card, borderColor: colors.icon + '20' }]}>
|
||||
<Text style={{ textAlign: 'center' }}>{dateStart}</Text>
|
||||
</View>
|
||||
{/* Tanggal */}
|
||||
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: files.length > 0 ? 8 : 0 }}>
|
||||
<MaterialCommunityIcons name="calendar-outline" size={13} color={colors.dimmed} style={{ marginRight: 4 }} />
|
||||
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>{dateStart}</Text>
|
||||
<MaterialCommunityIcons name="arrow-right" size={13} color={colors.dimmed} style={{ marginHorizontal: 4 }} />
|
||||
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>{dateEnd}</Text>
|
||||
</View>
|
||||
<View style={[{ width: '48%' }]}>
|
||||
<Text style={[Styles.mb05]}>Tanggal Berakhir</Text>
|
||||
<View style={[Styles.wrapPaper, Styles.noShadow, Styles.borderAll, Styles.p10, { backgroundColor: colors.card, borderColor: colors.icon + '20' }]}>
|
||||
<Text style={{ textAlign: 'center' }}>{dateEnd}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* Lampiran file */}
|
||||
{files.length > 0 && (
|
||||
<View style={[Styles.mb15]}>
|
||||
<View style={[Styles.rowItemsCenter, Styles.mb05]}>
|
||||
<MaterialCommunityIcons name="paperclip" size={13} color={colors.dimmed} style={[Styles.mr10]} />
|
||||
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>
|
||||
{files.length} Lampiran
|
||||
</Text>
|
||||
</View>
|
||||
{/* Chips lampiran */}
|
||||
{files.length > 0 && (
|
||||
<View
|
||||
style={{ flexDirection: 'row', gap: GAP, overflow: 'hidden' }}
|
||||
onLayout={onRowLayout}
|
||||
onLayout={onChipsLayout}
|
||||
>
|
||||
{visible.map((file, index) => {
|
||||
const label = `${file.name}.${file.extension}`
|
||||
const chipW = Math.min(estimateChipWidth(label), containerWidth * 0.55)
|
||||
return (
|
||||
<View key={index} style={[chipStyle(colors), { width: chipW }]}>
|
||||
<View
|
||||
key={index}
|
||||
style={{
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
backgroundColor: dimmed + '18',
|
||||
borderRadius: 6,
|
||||
paddingHorizontal: 8,
|
||||
paddingVertical: 3,
|
||||
width: chipW,
|
||||
}}
|
||||
>
|
||||
<MaterialCommunityIcons
|
||||
name={getFileIcon(file.extension)}
|
||||
size={13}
|
||||
@@ -168,16 +165,20 @@ export default function ItemSectionTanggalTugas({ done, title, dateStart, dateEn
|
||||
)
|
||||
})}
|
||||
{extra > 0 && (
|
||||
<View style={[chipStyle(colors)]}>
|
||||
<View style={{
|
||||
backgroundColor: dimmed + '18',
|
||||
borderRadius: 6,
|
||||
paddingHorizontal: 8,
|
||||
paddingVertical: 3,
|
||||
}}>
|
||||
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>
|
||||
+{extra} lainnya
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
)}
|
||||
</View>
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
|
||||
100
components/project/itemSectionLink.tsx
Normal file
100
components/project/itemSectionLink.tsx
Normal file
@@ -0,0 +1,100 @@
|
||||
import { urlCompleted } from "@/lib/fun_urlCompleted";
|
||||
import { useTheme } from "@/providers/ThemeProvider";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { Linking, Pressable, View } from "react-native";
|
||||
import Text from "../Text";
|
||||
import Styles from "@/constants/Styles";
|
||||
|
||||
type Props = {
|
||||
link: string
|
||||
canDelete: boolean
|
||||
onLongPress: () => void
|
||||
}
|
||||
|
||||
type DomainConfig = {
|
||||
icon: keyof typeof MaterialCommunityIcons.glyphMap
|
||||
color: string
|
||||
label: string
|
||||
}
|
||||
|
||||
function getDomainConfig(url: string): DomainConfig {
|
||||
try {
|
||||
const hostname = new URL(urlCompleted(url)).hostname.replace('www.', '')
|
||||
if (hostname.includes('youtube.com') || hostname.includes('youtu.be'))
|
||||
return { icon: 'youtube', color: '#FF0000', label: 'YouTube' }
|
||||
if (hostname.includes('drive.google.com'))
|
||||
return { icon: 'google-drive', color: '#4285F4', label: 'Google Drive' }
|
||||
if (hostname.includes('docs.google.com'))
|
||||
return { icon: 'google', color: '#4285F4', label: 'Google Docs' }
|
||||
if (hostname.includes('sheets.google.com'))
|
||||
return { icon: 'google-spreadsheet', color: '#0F9D58', label: 'Google Sheets' }
|
||||
if (hostname.includes('github.com'))
|
||||
return { icon: 'github', color: '#24292E', label: 'GitHub' }
|
||||
if (hostname.includes('wa.me') || hostname.includes('whatsapp.com'))
|
||||
return { icon: 'whatsapp', color: '#25D366', label: 'WhatsApp' }
|
||||
if (hostname.includes('instagram.com'))
|
||||
return { icon: 'instagram', color: '#E1306C', label: 'Instagram' }
|
||||
if (hostname.includes('facebook.com'))
|
||||
return { icon: 'facebook', color: '#1877F2', label: 'Facebook' }
|
||||
if (hostname.includes('figma.com'))
|
||||
return { icon: 'vector-bezier', color: '#F24E1E', label: 'Figma' }
|
||||
if (hostname.includes('notion.so'))
|
||||
return { icon: 'notebook-outline', color: '#000000', label: 'Notion' }
|
||||
return { icon: 'link-variant', color: '#6366F1', label: hostname }
|
||||
} catch {
|
||||
return { icon: 'link-variant', color: '#6366F1', label: url }
|
||||
}
|
||||
}
|
||||
|
||||
function getDisplayUrl(url: string) {
|
||||
try {
|
||||
const full = urlCompleted(url)
|
||||
const parsed = new URL(full)
|
||||
const path = parsed.pathname + parsed.search
|
||||
return path.length > 1 ? path : ''
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
export default function ItemSectionLink({ link, canDelete, onLongPress }: Props) {
|
||||
const { colors, activeTheme } = useTheme()
|
||||
const config = getDomainConfig(link)
|
||||
const displayPath = getDisplayUrl(link)
|
||||
|
||||
const iconBg = activeTheme === 'dark' ? config.color + '25' : config.color + '15'
|
||||
const iconColor = activeTheme === 'dark' && config.color === '#24292E' ? '#ECEDEE' : config.color
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
onPress={() => Linking.openURL(urlCompleted(link))}
|
||||
onLongPress={canDelete ? onLongPress : undefined}
|
||||
style={({ pressed }) => ([
|
||||
Styles.fileCard,
|
||||
{
|
||||
width: '100%',
|
||||
marginBottom: 10,
|
||||
borderColor: colors.icon + '18',
|
||||
backgroundColor: pressed ? colors.icon + '10' : colors.card,
|
||||
},
|
||||
])}
|
||||
>
|
||||
<View style={[Styles.sectionIconBox, { backgroundColor: iconBg }]}>
|
||||
<MaterialCommunityIcons name={config.icon} size={18} color={iconColor} />
|
||||
</View>
|
||||
|
||||
<View style={Styles.flex1}>
|
||||
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]} numberOfLines={1}>
|
||||
{config.label}
|
||||
</Text>
|
||||
{displayPath.length > 0 && (
|
||||
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed, marginTop: 2 }]} numberOfLines={1} ellipsizeMode="tail">
|
||||
{displayPath}
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<MaterialCommunityIcons name="arrow-top-right" size={16} color={colors.dimmed} />
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
@@ -10,19 +10,17 @@ import { startActivityAsync } from 'expo-intent-launcher';
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import * as Sharing from 'expo-sharing';
|
||||
import { useEffect, useState } from "react";
|
||||
import { Alert, Platform, View } from "react-native";
|
||||
import { Alert, Platform, Pressable, View } from "react-native";
|
||||
import * as mime from 'react-native-mime-types';
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ModalConfirmation from "../ModalConfirmation";
|
||||
import BorderBottomItem from "../borderBottomItem";
|
||||
import DrawerBottom from "../drawerBottom";
|
||||
import MenuItemRow from "../menuItemRow";
|
||||
import ModalConfirmation from "../ModalConfirmation";
|
||||
import ModalLoading from "../modalLoading";
|
||||
import Skeleton from "../skeleton";
|
||||
import Text from "../Text";
|
||||
|
||||
|
||||
type Props = {
|
||||
id: string
|
||||
name: string
|
||||
@@ -30,6 +28,28 @@ type Props = {
|
||||
idStorage: string
|
||||
}
|
||||
|
||||
function getFileIcon(extension: string): keyof typeof MaterialCommunityIcons.glyphMap {
|
||||
const ext = extension.toLowerCase()
|
||||
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return 'image-outline'
|
||||
if (ext === 'pdf') return 'file-pdf-box'
|
||||
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return 'video-outline'
|
||||
if (['doc', 'docx'].includes(ext)) return 'file-word-outline'
|
||||
if (['xls', 'xlsx'].includes(ext)) return 'file-excel-outline'
|
||||
if (['zip', 'rar', '7z'].includes(ext)) return 'zip-box-outline'
|
||||
return 'file-outline'
|
||||
}
|
||||
|
||||
function getFileColor(extension: string): string {
|
||||
const ext = extension.toLowerCase()
|
||||
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return '#339AF0'
|
||||
if (ext === 'pdf') return '#F03E3E'
|
||||
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return '#AE3EC9'
|
||||
if (['doc', 'docx'].includes(ext)) return '#1C7ED6'
|
||||
if (['xls', 'xlsx'].includes(ext)) return '#2F9E44'
|
||||
if (['zip', 'rar', '7z'].includes(ext)) return '#E8590C'
|
||||
return '#868E96'
|
||||
}
|
||||
|
||||
export default function SectionFile({ status, member, refreshing }: { status: number | undefined, member: boolean, refreshing?: boolean }) {
|
||||
const { colors } = useTheme();
|
||||
const entityUser = useSelector((state: any) => state.user)
|
||||
@@ -40,7 +60,7 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
|
||||
const update = useSelector((state: any) => state.projectUpdate)
|
||||
const dispatch = useDispatch()
|
||||
const [loading, setLoading] = useState(true)
|
||||
const arrSkeleton = Array.from({ length: 3 })
|
||||
const arrSkeleton = Array.from({ length: 4 })
|
||||
const [selectFile, setSelectFile] = useState<Props | null>(null)
|
||||
const [showDeleteModal, setShowDeleteModal] = useState(false)
|
||||
const [loadingOpen, setLoadingOpen] = useState(false)
|
||||
@@ -49,11 +69,7 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
|
||||
try {
|
||||
setLoading(loading)
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiGetProjectOne({
|
||||
user: hasil,
|
||||
cat: "file",
|
||||
id: id,
|
||||
});
|
||||
const response = await apiGetProjectOne({ user: hasil, cat: "file", id });
|
||||
setData(response.data);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@@ -62,110 +78,90 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
handleLoad(false);
|
||||
}, [update.file]);
|
||||
|
||||
useEffect(() => {
|
||||
if (refreshing)
|
||||
handleLoad(false);
|
||||
}, [refreshing]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
handleLoad(true);
|
||||
}, []);
|
||||
useEffect(() => { handleLoad(false) }, [update.file]);
|
||||
useEffect(() => { if (refreshing) handleLoad(false) }, [refreshing]);
|
||||
useEffect(() => { handleLoad(true) }, []);
|
||||
|
||||
async function handleDelete() {
|
||||
try {
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiDeleteFileProject({ user: hasil }, String(selectFile?.id));
|
||||
if (response.success) {
|
||||
Toast.show({ type: 'small', text1: 'Berhasil menghapus file', })
|
||||
Toast.show({ type: 'small', text1: 'Berhasil menghapus file' })
|
||||
dispatch(setUpdateProject({ ...update, file: !update.file }))
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message, })
|
||||
Toast.show({ type: 'small', text1: response.message })
|
||||
}
|
||||
} catch (error : any ) {
|
||||
console.error(error);
|
||||
const message = error?.response?.data?.message || "Gagal menghapus file"
|
||||
|
||||
Toast.show({ type: 'small', text1: message })
|
||||
} catch (error: any) {
|
||||
Toast.show({ type: 'small', text1: error?.response?.data?.message || "Gagal menghapus file" })
|
||||
} finally {
|
||||
setModal(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const openFile = () => {
|
||||
setModal(false)
|
||||
setLoadingOpen(true)
|
||||
let remoteUrl = ConstEnv.url_storage + '/files/' + selectFile?.idStorage;
|
||||
const fileName = selectFile?.name + '.' + selectFile?.extension;
|
||||
let localPath = `${FileSystem.documentDirectory}/${fileName}`;
|
||||
const remoteUrl = ConstEnv.url_storage + '/files/' + selectFile?.idStorage
|
||||
const fileName = selectFile?.name + '.' + selectFile?.extension
|
||||
const localPath = `${FileSystem.documentDirectory}/${fileName}`
|
||||
const mimeType = mime.lookup(fileName)
|
||||
|
||||
FileSystem.downloadAsync(remoteUrl, localPath).then(async ({ uri }) => {
|
||||
const contentURL = await FileSystem.getContentUriAsync(uri);
|
||||
const contentURL = await FileSystem.getContentUriAsync(uri)
|
||||
try {
|
||||
|
||||
if (Platform.OS == 'android') {
|
||||
// open with android intent
|
||||
await startActivityAsync(
|
||||
'android.intent.action.VIEW',
|
||||
{
|
||||
data: contentURL,
|
||||
flags: 1,
|
||||
type: mimeType as string,
|
||||
}
|
||||
);
|
||||
// or
|
||||
// Sharing.shareAsync(localPath);
|
||||
|
||||
} else if (Platform.OS == 'ios') {
|
||||
Sharing.shareAsync(localPath);
|
||||
if (Platform.OS === 'android') {
|
||||
await startActivityAsync('android.intent.action.VIEW', { data: contentURL, flags: 1, type: mimeType as string })
|
||||
} else {
|
||||
Sharing.shareAsync(localPath)
|
||||
}
|
||||
} catch (error) {
|
||||
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini');
|
||||
} catch {
|
||||
Alert.alert('INFO', 'Gagal membuka file, tidak ada aplikasi yang dapat membuka file ini')
|
||||
} finally {
|
||||
setLoadingOpen(false)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
|
||||
<View style={[Styles.mb15]}>
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
|
||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
||||
{
|
||||
loading ?
|
||||
arrSkeleton.map((item, index) => {
|
||||
return (
|
||||
<Skeleton key={index} width={100} height={40} widthType="percent" borderRadius={10} />
|
||||
)
|
||||
})
|
||||
:
|
||||
data.length > 0 ?
|
||||
data.map((item, index) => {
|
||||
return (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType="all"
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color={colors.text} />}
|
||||
title={item.name + '.' + item.extension}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setSelectFile(item); setModal(true) }}
|
||||
/>
|
||||
)
|
||||
})
|
||||
:
|
||||
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada file</Text>
|
||||
}
|
||||
</View>
|
||||
|
||||
{loading ? (
|
||||
<View style={Styles.fileGrid}>
|
||||
{arrSkeleton.map((_, index) => (
|
||||
<Skeleton key={index} width={48} height={68} widthType="percent" borderRadius={10} />
|
||||
))}
|
||||
</View>
|
||||
) : data.length > 0 ? (
|
||||
<View style={Styles.fileGrid}>
|
||||
{data.map((item, index) => {
|
||||
const iconName = getFileIcon(item.extension)
|
||||
const iconColor = getFileColor(item.extension)
|
||||
return (
|
||||
<Pressable
|
||||
key={index}
|
||||
onPress={() => { setSelectFile(item); setModal(true) }}
|
||||
style={[Styles.fileCard, { backgroundColor: colors.card, borderColor: colors.icon + '18' }]}
|
||||
>
|
||||
<View style={[Styles.sectionIconBox, { backgroundColor: iconColor + '20' }]}>
|
||||
<MaterialCommunityIcons name={iconName} size={18} color={iconColor} />
|
||||
</View>
|
||||
<View style={Styles.flex1}>
|
||||
<Text style={Styles.textDefault} numberOfLines={1}>{item.name}</Text>
|
||||
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>
|
||||
{item.extension.toUpperCase()}
|
||||
</Text>
|
||||
</View>
|
||||
</Pressable>
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
) : (
|
||||
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada file</Text>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||
@@ -173,26 +169,20 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="file-eye" color={colors.text} size={25} />}
|
||||
title="Lihat / Share"
|
||||
onPress={() => {
|
||||
openFile()
|
||||
}}
|
||||
onPress={openFile}
|
||||
/>
|
||||
{
|
||||
!member && (entityUser.role == "user" || entityUser.role == "coadmin") ? <></>
|
||||
:
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||
title="Hapus"
|
||||
disabled={status == 3}
|
||||
onPress={() => {
|
||||
if (status == 3) return
|
||||
setModal(false)
|
||||
setTimeout(() => {
|
||||
setShowDeleteModal(true)
|
||||
}, 600)
|
||||
}}
|
||||
/>
|
||||
}
|
||||
{(!member && (entityUser.role === "user" || entityUser.role === "coadmin")) ? null : (
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||
title="Hapus"
|
||||
disabled={status === 3}
|
||||
onPress={() => {
|
||||
if (status === 3) return
|
||||
setModal(false)
|
||||
setTimeout(() => setShowDeleteModal(true), 600)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
|
||||
@@ -200,14 +190,11 @@ export default function SectionFile({ status, member, refreshing }: { status: nu
|
||||
visible={showDeleteModal}
|
||||
title="Konfirmasi"
|
||||
message="Apakah Anda yakin ingin menghapus file ini? File yang dihapus tidak dapat dikembalikan"
|
||||
onConfirm={() => {
|
||||
setShowDeleteModal(false)
|
||||
handleDelete()
|
||||
}}
|
||||
onConfirm={() => { setShowDeleteModal(false); handleDelete() }}
|
||||
onCancel={() => setShowDeleteModal(false)}
|
||||
confirmText="Hapus"
|
||||
cancelText="Batal"
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiDeleteLinkProject, apiGetProjectOne } from "@/lib/api";
|
||||
import { urlCompleted } from "@/lib/fun_urlCompleted";
|
||||
import { setUpdateProject } from "@/lib/projectUpdate";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { useTheme } from "@/providers/ThemeProvider";
|
||||
import { Feather, Ionicons } from "@expo/vector-icons";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Linking, View } from "react-native";
|
||||
import { View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ModalConfirmation from "../ModalConfirmation";
|
||||
import BorderBottomItem from "../borderBottomItem";
|
||||
import DrawerBottom from "../drawerBottom";
|
||||
import MenuItemRow from "../menuItemRow";
|
||||
import Text from "../Text";
|
||||
import ItemSectionLink from "./itemSectionLink";
|
||||
|
||||
|
||||
type Props = {
|
||||
@@ -87,17 +86,16 @@ export default function SectionLink({ status, member, refreshing }: { status: nu
|
||||
<>
|
||||
<View style={[Styles.mb15]}>
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Link</Text>
|
||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
||||
<View>
|
||||
{
|
||||
data.map((item, index) => {
|
||||
const canDelete = member || (entityUser.role !== "user" && entityUser.role !== "coadmin")
|
||||
return (
|
||||
<BorderBottomItem
|
||||
<ItemSectionLink
|
||||
key={index}
|
||||
borderType="all"
|
||||
icon={<Feather name="link" size={25} color={colors.text} />}
|
||||
title={item.link}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setSelectLink(item); setModal(true) }}
|
||||
link={item.link}
|
||||
canDelete={canDelete && status !== 3}
|
||||
onLongPress={() => { setSelectLink(item); setModal(true) }}
|
||||
/>
|
||||
)
|
||||
})
|
||||
@@ -108,28 +106,13 @@ export default function SectionLink({ status, member, refreshing }: { status: nu
|
||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<Feather name="external-link" color={colors.text} size={25} />}
|
||||
title="Buka Link"
|
||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||
title="Hapus Link"
|
||||
onPress={() => {
|
||||
Linking.openURL(urlCompleted(String(selectLink?.link)))
|
||||
setModal(false)
|
||||
setTimeout(() => setShowDeleteModal(true), 600)
|
||||
}}
|
||||
/>
|
||||
{
|
||||
!member && (entityUser.role == "user" || entityUser.role == "coadmin") ? <></>
|
||||
:
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||
title="Hapus"
|
||||
disabled={status == 3}
|
||||
onPress={() => {
|
||||
if (status == 3) return
|
||||
setModal(false)
|
||||
setTimeout(() => {
|
||||
setShowDeleteModal(true)
|
||||
}, 600)
|
||||
}}
|
||||
/>
|
||||
}
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import Styles from "@/constants/Styles";
|
||||
import { apiGetProjectOne } from "@/lib/api";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { useTheme } from "@/providers/ThemeProvider";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { View } from "react-native";
|
||||
@@ -19,39 +20,37 @@ export default function SectionReportProject({ refreshing }: { refreshing?: bool
|
||||
async function handleLoad() {
|
||||
try {
|
||||
const hasil = await decryptToken(String(token?.current));
|
||||
const response = await apiGetProjectOne({
|
||||
user: hasil,
|
||||
cat: "data",
|
||||
id: id,
|
||||
});
|
||||
const response = await apiGetProjectOne({ user: hasil, cat: "data", id: id });
|
||||
setData(response.data.report);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
handleLoad();
|
||||
}, [update.report]);
|
||||
useEffect(() => { handleLoad() }, [update.report]);
|
||||
useEffect(() => { if (refreshing) handleLoad() }, [refreshing]);
|
||||
|
||||
useEffect(() => {
|
||||
if (refreshing)
|
||||
handleLoad();
|
||||
}, [refreshing]);
|
||||
if (!data || data === "") return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
{
|
||||
data != "" && data != null &&
|
||||
<View style={[Styles.mb15, Styles.mt10]}>
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>
|
||||
Laporan Kegiatan
|
||||
</Text>
|
||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
||||
<TextExpandable content={data} maxLines={2} />
|
||||
</View>
|
||||
<View style={[
|
||||
Styles.wrapPaper,
|
||||
Styles.mb15,
|
||||
Styles.sectionCard,
|
||||
{ backgroundColor: colors.card, borderColor: colors.icon + '18' },
|
||||
]}>
|
||||
<View style={Styles.sectionHeader}>
|
||||
<View style={[Styles.sectionIconBox, Styles.mr10, { backgroundColor: colors.tabActive + '18' }]}>
|
||||
<MaterialCommunityIcons name="text-box-outline" size={18} color={colors.tabActive} />
|
||||
</View>
|
||||
}
|
||||
</>
|
||||
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>
|
||||
Laporan Kegiatan
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View style={[Styles.reportContent, { borderLeftColor: colors.tabActive + '50' }]}>
|
||||
<TextExpandable content={data} maxLines={2} />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ import { useEffect, useState } from "react";
|
||||
import { View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ModalConfirmation from "../ModalConfirmation";
|
||||
import DrawerBottom from "../drawerBottom";
|
||||
import ItemSectionTanggalTugas from "../itemSectionTanggalTugas";
|
||||
import MenuItemRow from "../menuItemRow";
|
||||
import ModalConfirmation from "../ModalConfirmation";
|
||||
import ModalSelect from "../modalSelect";
|
||||
import SkeletonTask from "../skeletonTask";
|
||||
import Text from "../Text";
|
||||
@@ -92,7 +92,7 @@ export default function SectionTanggalTugasProject({ status, member, refreshing
|
||||
setSelect(false);
|
||||
Toast.show({ type: 'small', text1: 'Berhasil mengubah data', })
|
||||
}
|
||||
} catch (error : any ) {
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
const message = error?.response?.data?.message || "Gagal mengubah data"
|
||||
|
||||
@@ -112,7 +112,7 @@ export default function SectionTanggalTugasProject({ status, member, refreshing
|
||||
setModal(false);
|
||||
Toast.show({ type: 'small', text1: 'Berhasil menghapus data', })
|
||||
}
|
||||
} catch (error : any ) {
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
const message = error?.response?.data?.message || "Gagal menghapus data"
|
||||
|
||||
@@ -126,7 +126,7 @@ export default function SectionTanggalTugasProject({ status, member, refreshing
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>
|
||||
Tanggal & Tugas
|
||||
</Text>
|
||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
||||
<View>
|
||||
{
|
||||
loading ?
|
||||
arrSkeleton.map((item, index) => {
|
||||
@@ -166,14 +166,16 @@ export default function SectionTanggalTugasProject({ status, member, refreshing
|
||||
title="Menu"
|
||||
>
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="clock-time-three-outline" color={colors.text} size={25} />}
|
||||
title="Detail Waktu"
|
||||
onPress={() => {
|
||||
setModal(false);
|
||||
setTimeout(() => setModalDetail(true), 600)
|
||||
}}
|
||||
/>
|
||||
{(member || (entityUser.role != "user" && entityUser.role != "coadmin")) && status != 3 && (
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="list-status" color={colors.text} size={25} />}
|
||||
title="Update Status"
|
||||
onPress={() => {
|
||||
setModal(false);
|
||||
setTimeout(() => setSelect(true), 600)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="file-multiple-outline" color={colors.text} size={25} />}
|
||||
title="File Tugas"
|
||||
@@ -182,29 +184,25 @@ export default function SectionTanggalTugasProject({ status, member, refreshing
|
||||
router.push(`/project/${id}/tugas-file/${tugas.id}?member=${member}`);
|
||||
}}
|
||||
/>
|
||||
{(member || (entityUser.role != "user" && entityUser.role != "coadmin")) && status != 3 && (
|
||||
<>
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="list-status" color={colors.text} size={25} />}
|
||||
title="Update Status"
|
||||
onPress={() => {
|
||||
setModal(false);
|
||||
setTimeout(() => setSelect(true), 600)
|
||||
}}
|
||||
/>
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="pencil-outline" color={colors.text} size={25} />}
|
||||
title="Edit Tugas"
|
||||
onPress={() => {
|
||||
setModal(false);
|
||||
router.push(`/project/update/${tugas.id}`);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="clock-time-three-outline" color={colors.text} size={25} />}
|
||||
title="Detail Waktu"
|
||||
onPress={() => {
|
||||
setModal(false);
|
||||
setTimeout(() => setModalDetail(true), 600)
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
{(member || (entityUser.role != "user" && entityUser.role != "coadmin")) && status != 3 && (
|
||||
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="pencil-outline" color={colors.text} size={25} />}
|
||||
title="Edit Tugas"
|
||||
onPress={() => {
|
||||
setModal(false);
|
||||
router.push(`/project/update/${tugas.id}`);
|
||||
}}
|
||||
/>
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||
title="Hapus Tugas"
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { ColorsStatus } from "@/constants/ColorsStatus";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { useTheme } from "@/providers/ThemeProvider";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import Text from "./Text";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { View } from "react-native";
|
||||
import Text from "./Text";
|
||||
|
||||
type Props = {
|
||||
text?: string,
|
||||
text?: string
|
||||
title?: string
|
||||
}
|
||||
|
||||
@@ -14,18 +13,26 @@ export default function SectionCancel({ text, title }: Props) {
|
||||
const { colors } = useTheme();
|
||||
|
||||
return (
|
||||
<View style={[Styles.p10, Styles.round05, Styles.mb15, { backgroundColor: colors.error + '70' }]}>
|
||||
<View style={[Styles.rowItemsCenter]}>
|
||||
<AntDesign name="warning" size={22} style={[Styles.mr10]} color={colors.text} />
|
||||
<Text style={[Styles.textDefaultSemiBold]}>{title ? title : 'Kegiatan Dibatalkan'}</Text>
|
||||
<View style={[
|
||||
Styles.wrapPaper,
|
||||
Styles.mb15,
|
||||
Styles.sectionCard,
|
||||
{ backgroundColor: colors.error + '12', borderColor: colors.error + '40' },
|
||||
]}>
|
||||
<View style={[Styles.sectionHeader, !text && { marginBottom: 0 }]}>
|
||||
<View style={[Styles.sectionIconBox, Styles.mr10, { backgroundColor: colors.error + '20' }]}>
|
||||
<MaterialCommunityIcons name="close-circle-outline" size={18} color={colors.error} />
|
||||
</View>
|
||||
<Text style={[Styles.textDefaultSemiBold, { color: colors.error }]}>
|
||||
{title ?? 'Kegiatan Dibatalkan'}
|
||||
</Text>
|
||||
</View>
|
||||
{
|
||||
text && (
|
||||
<View>
|
||||
<Text style={[Styles.mt05]}>{text}</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
{text && (
|
||||
<View style={[Styles.reportContent, { borderLeftColor: colors.error + '50' }]}>
|
||||
<Text style={[Styles.textDefault, { color: colors.text }]}>{text}</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,87 @@
|
||||
import Styles from "@/constants/Styles";
|
||||
import { useTheme } from "@/providers/ThemeProvider";
|
||||
import { AntDesign } from "@expo/vector-icons";
|
||||
import { View } from "react-native";
|
||||
import ProgressBar from "./progressBar";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { Animated, View } from "react-native";
|
||||
import Text from "./Text";
|
||||
|
||||
type Props = {
|
||||
text: string,
|
||||
progress: number
|
||||
doneCount?: number
|
||||
totalCount?: number
|
||||
}
|
||||
|
||||
export default function SectionProgress({ text, progress }: Props) {
|
||||
export default function SectionProgress({ progress, doneCount, totalCount }: Props) {
|
||||
const { colors } = useTheme();
|
||||
const animatedWidth = useRef(new Animated.Value(0)).current;
|
||||
|
||||
const progressColor = colors.tabActive;
|
||||
|
||||
const statusLabel = progress === 100
|
||||
? 'Selesai'
|
||||
: progress > 0
|
||||
? 'Sedang berlangsung'
|
||||
: 'Belum dimulai';
|
||||
|
||||
useEffect(() => {
|
||||
animatedWidth.setValue(0);
|
||||
Animated.timing(animatedWidth, {
|
||||
toValue: progress,
|
||||
duration: 900,
|
||||
useNativeDriver: false,
|
||||
}).start();
|
||||
}, [progress]);
|
||||
|
||||
return (
|
||||
<View style={[Styles.wrapPaper, Styles.rowItemsCenter, { backgroundColor: colors.card }]}>
|
||||
<View style={[Styles.iconContent]}>
|
||||
<AntDesign name="areachart" size={30} color={'black'} />
|
||||
<View style={[
|
||||
Styles.wrapPaper,
|
||||
Styles.mb15,
|
||||
Styles.sectionCard,
|
||||
{ backgroundColor: colors.card, borderColor: progressColor + '30' },
|
||||
]}>
|
||||
<View style={Styles.sectionHeaderRow}>
|
||||
<View style={Styles.flex1}>
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<View style={[Styles.sectionIconBox, Styles.mr10, { backgroundColor: progressColor + '22' }]}>
|
||||
<MaterialCommunityIcons name="chart-line" size={18} color={progressColor} />
|
||||
</View>
|
||||
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>
|
||||
Kemajuan Kegiatan
|
||||
</Text>
|
||||
</View>
|
||||
<Text style={[Styles.textMediumNormal, { color: colors.dimmed, marginLeft: 42 }]}>
|
||||
{statusLabel}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View style={Styles.badgeCol}>
|
||||
<View style={[Styles.progressBadge, { backgroundColor: progressColor + '18', borderColor: progressColor + '45' }]}>
|
||||
<Text style={[Styles.textProgressPercent, { color: progressColor }]}>
|
||||
{progress}%
|
||||
</Text>
|
||||
</View>
|
||||
{totalCount !== undefined && doneCount !== undefined && (
|
||||
<View style={[Styles.taskCountBadge, { backgroundColor: progressColor + '18' }]}>
|
||||
<Text style={[Styles.textSmallSemiBold, { color: progressColor }]}>
|
||||
{doneCount}/{totalCount} tugas
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
<View style={[Styles.ml10, { flex: 1 }]}>
|
||||
<Text style={[Styles.mb05]}>{text}</Text>
|
||||
<ProgressBar margin={0} category="page" value={progress} />
|
||||
|
||||
<View style={[Styles.progressTrack, { backgroundColor: colors.icon + '20' }]}>
|
||||
<Animated.View style={[
|
||||
Styles.progressFill,
|
||||
{
|
||||
backgroundColor: progressColor,
|
||||
width: animatedWidth.interpolate({
|
||||
inputRange: [0, 100],
|
||||
outputRange: ['0%', '100%'],
|
||||
}),
|
||||
},
|
||||
]} />
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,15 +10,13 @@ import { startActivityAsync } from 'expo-intent-launcher';
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import * as Sharing from 'expo-sharing';
|
||||
import { useEffect, useState } from "react";
|
||||
import { Alert, Platform, View } from "react-native";
|
||||
import { Alert, Platform, Pressable, View } from "react-native";
|
||||
import * as mime from 'react-native-mime-types';
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ModalConfirmation from "../ModalConfirmation";
|
||||
import ButtonMenuHeader from "../buttonMenuHeader";
|
||||
import BorderBottomItem from "../borderBottomItem";
|
||||
import DrawerBottom from "../drawerBottom";
|
||||
import MenuItemRow from "../menuItemRow";
|
||||
import ModalConfirmation from "../ModalConfirmation";
|
||||
import ModalLoading from "../modalLoading";
|
||||
import Skeleton from "../skeleton";
|
||||
import Text from "../Text";
|
||||
@@ -30,6 +28,28 @@ type Props = {
|
||||
idStorage: string
|
||||
}
|
||||
|
||||
function getFileIcon(extension: string): keyof typeof MaterialCommunityIcons.glyphMap {
|
||||
const ext = extension.toLowerCase()
|
||||
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return 'image-outline'
|
||||
if (ext === 'pdf') return 'file-pdf-box'
|
||||
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return 'video-outline'
|
||||
if (['doc', 'docx'].includes(ext)) return 'file-word-outline'
|
||||
if (['xls', 'xlsx'].includes(ext)) return 'file-excel-outline'
|
||||
if (['zip', 'rar', '7z'].includes(ext)) return 'zip-box-outline'
|
||||
return 'file-outline'
|
||||
}
|
||||
|
||||
function getFileColor(extension: string): string {
|
||||
const ext = extension.toLowerCase()
|
||||
if (['jpg', 'jpeg', 'png', 'gif', 'webp', 'heic', 'heif'].includes(ext)) return '#339AF0'
|
||||
if (ext === 'pdf') return '#F03E3E'
|
||||
if (['mp4', 'mov', 'avi', 'mkv'].includes(ext)) return '#AE3EC9'
|
||||
if (['doc', 'docx'].includes(ext)) return '#1C7ED6'
|
||||
if (['xls', 'xlsx'].includes(ext)) return '#2F9E44'
|
||||
if (['zip', 'rar', '7z'].includes(ext)) return '#E8590C'
|
||||
return '#868E96'
|
||||
}
|
||||
|
||||
export default function SectionFileTask({ refreshing, isMemberDivision }: { refreshing: boolean, isMemberDivision: boolean }) {
|
||||
const { colors } = useTheme()
|
||||
const [isModal, setModal] = useState(false)
|
||||
@@ -119,7 +139,7 @@ export default function SectionFileTask({ refreshing, isMemberDivision }: { refr
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message, })
|
||||
}
|
||||
} catch (error : any ) {
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
const message = error?.response?.data?.message || "Gagal menghapus file"
|
||||
|
||||
@@ -134,32 +154,39 @@ export default function SectionFileTask({ refreshing, isMemberDivision }: { refr
|
||||
<ModalLoading isVisible={loadingOpen} setVisible={setLoadingOpen} />
|
||||
<View style={[Styles.mb15]}>
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
|
||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
||||
{
|
||||
loading ?
|
||||
arrSkeleton.map((item, index) => {
|
||||
return (
|
||||
<Skeleton key={index} width={100} height={40} widthType="percent" borderRadius={10} />
|
||||
)
|
||||
})
|
||||
:
|
||||
data.length > 0 ?
|
||||
data.map((item, index) => {
|
||||
return (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType="all"
|
||||
icon={<MaterialCommunityIcons name="file-outline" size={25} color={colors.text} />}
|
||||
title={item.name + '.' + item.extension}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setSelectFile(item); setModal(true) }}
|
||||
/>
|
||||
)
|
||||
})
|
||||
:
|
||||
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada file</Text>
|
||||
}
|
||||
</View>
|
||||
{loading ? (
|
||||
<View style={Styles.fileGrid}>
|
||||
{arrSkeleton.map((_, index) => (
|
||||
<Skeleton key={index} width={48} height={68} widthType="percent" borderRadius={10} />
|
||||
))}
|
||||
</View>
|
||||
) : data.length > 0 ? (
|
||||
<View style={Styles.fileGrid}>
|
||||
{data.map((item, index) => {
|
||||
const iconName = getFileIcon(item.extension)
|
||||
const iconColor = getFileColor(item.extension)
|
||||
return (
|
||||
<Pressable
|
||||
key={index}
|
||||
onPress={() => { setSelectFile(item); setModal(true) }}
|
||||
style={[Styles.fileCard, { backgroundColor: colors.card, borderColor: colors.icon + '18' }]}
|
||||
>
|
||||
<View style={[Styles.sectionIconBox, { backgroundColor: iconColor + '20' }]}>
|
||||
<MaterialCommunityIcons name={iconName} size={18} color={iconColor} />
|
||||
</View>
|
||||
<View style={Styles.flex1}>
|
||||
<Text style={Styles.textDefault} numberOfLines={1}>{item.name}</Text>
|
||||
<Text style={[Styles.textSmallSemiBold, { color: colors.dimmed }]}>
|
||||
{item.extension.toUpperCase()}
|
||||
</Text>
|
||||
</View>
|
||||
</Pressable>
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
) : (
|
||||
<Text style={[Styles.textDefault, { textAlign: 'center', color: colors.dimmed }]}>Tidak ada file</Text>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiDeleteLinkTask, apiGetTaskOne } from "@/lib/api";
|
||||
import { urlCompleted } from "@/lib/fun_urlCompleted";
|
||||
import { setUpdateTask } from "@/lib/taskUpdate";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { useTheme } from "@/providers/ThemeProvider";
|
||||
import { Feather, Ionicons } from "@expo/vector-icons";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Linking, View } from "react-native";
|
||||
import { View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ModalConfirmation from "../ModalConfirmation";
|
||||
import BorderBottomItem from "../borderBottomItem";
|
||||
import DrawerBottom from "../drawerBottom";
|
||||
import MenuItemRow from "../menuItemRow";
|
||||
import Text from "../Text";
|
||||
import ItemSectionLink from "../project/itemSectionLink";
|
||||
|
||||
type Props = {
|
||||
id: string
|
||||
@@ -62,84 +61,60 @@ export default function SectionLinkTask({ refreshing, isMemberDivision }: { refr
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message, })
|
||||
}
|
||||
} catch (error : any ) {
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
const message = error?.response?.data?.message || "Gagal menghapus link"
|
||||
|
||||
Toast.show({ type: 'small', text1: message })
|
||||
} finally {
|
||||
setModal(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (data.length === 0) return null;
|
||||
|
||||
const canDelete = (entityUser.role !== "user" && entityUser.role !== "coadmin") || isMemberDivision;
|
||||
|
||||
return (
|
||||
<>
|
||||
{
|
||||
data.length > 0 &&
|
||||
<>
|
||||
<View style={[Styles.mb15]}>
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Link</Text>
|
||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
||||
{
|
||||
data.map((item, index) => {
|
||||
return (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
borderType="all"
|
||||
icon={<Feather name="link" size={25} color={colors.text} />}
|
||||
title={item.link}
|
||||
titleWeight="normal"
|
||||
onPress={() => { setSelectLink(item); setModal(true) }}
|
||||
/>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
<View style={[Styles.mb15]}>
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Link</Text>
|
||||
<View>
|
||||
{data.map((item, index) => (
|
||||
<ItemSectionLink
|
||||
key={index}
|
||||
link={item.link}
|
||||
canDelete={canDelete}
|
||||
onLongPress={() => { setSelectLink(item); setModal(true) }}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<Feather name="external-link" color={colors.text} size={25} />}
|
||||
title="Buka Link"
|
||||
onPress={() => {
|
||||
Linking.openURL(urlCompleted(String(selectLink?.link)))
|
||||
}}
|
||||
/>
|
||||
{
|
||||
(entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision
|
||||
?
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||
title="Hapus"
|
||||
onPress={() => {
|
||||
setModal(false)
|
||||
setTimeout(() => {
|
||||
setShowDeleteModal(true)
|
||||
}, 600)
|
||||
}}
|
||||
/>
|
||||
:
|
||||
<></>
|
||||
}
|
||||
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
|
||||
<ModalConfirmation
|
||||
visible={showDeleteModal}
|
||||
title="Konfirmasi"
|
||||
message="Apakah Anda yakin ingin menghapus link ini? Link yang dihapus tidak dapat dikembalikan"
|
||||
onConfirm={() => {
|
||||
setShowDeleteModal(false)
|
||||
handleDelete()
|
||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||
title="Hapus Link"
|
||||
onPress={() => {
|
||||
setModal(false)
|
||||
setTimeout(() => setShowDeleteModal(true), 600)
|
||||
}}
|
||||
onCancel={() => setShowDeleteModal(false)}
|
||||
confirmText="Hapus"
|
||||
cancelText="Batal"
|
||||
/>
|
||||
</>
|
||||
}
|
||||
</View>
|
||||
</DrawerBottom>
|
||||
|
||||
<ModalConfirmation
|
||||
visible={showDeleteModal}
|
||||
title="Konfirmasi"
|
||||
message="Apakah Anda yakin ingin menghapus link ini? Link yang dihapus tidak dapat dikembalikan"
|
||||
onConfirm={() => {
|
||||
setShowDeleteModal(false)
|
||||
handleDelete()
|
||||
}}
|
||||
onCancel={() => setShowDeleteModal(false)}
|
||||
confirmText="Hapus"
|
||||
cancelText="Batal"
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import Styles from "@/constants/Styles";
|
||||
import { apiGetTaskOne } from "@/lib/api";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { useTheme } from "@/providers/ThemeProvider";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { View } from "react-native";
|
||||
@@ -9,7 +10,6 @@ import { useSelector } from "react-redux";
|
||||
import Text from "../Text";
|
||||
import TextExpandable from "../textExpandable";
|
||||
|
||||
|
||||
export default function SectionReportTask({ refreshing }: { refreshing: boolean }) {
|
||||
const { colors } = useTheme()
|
||||
const update = useSelector((state: any) => state.taskUpdate)
|
||||
@@ -27,29 +27,30 @@ export default function SectionReportTask({ refreshing }: { refreshing: boolean
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
handleLoad()
|
||||
}, [update.report])
|
||||
|
||||
useEffect(() => {
|
||||
if (refreshing)
|
||||
handleLoad();
|
||||
}, [refreshing]);
|
||||
useEffect(() => { handleLoad() }, [update.report])
|
||||
useEffect(() => { if (refreshing) handleLoad() }, [refreshing])
|
||||
|
||||
if (!data || data === "") return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
{
|
||||
data != "" && data != null &&
|
||||
<View style={[Styles.mb15, Styles.mt10]}>
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>
|
||||
Laporan Kegiatan
|
||||
</Text>
|
||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
||||
<TextExpandable content={data} maxLines={2} />
|
||||
</View>
|
||||
<View style={[
|
||||
Styles.wrapPaper,
|
||||
Styles.mb15,
|
||||
Styles.sectionCard,
|
||||
{ backgroundColor: colors.card, borderColor: colors.icon + '18' },
|
||||
]}>
|
||||
<View style={Styles.sectionHeader}>
|
||||
<View style={[Styles.sectionIconBox, Styles.mr10, { backgroundColor: colors.tabActive + '18' }]}>
|
||||
<MaterialCommunityIcons name="text-box-outline" size={18} color={colors.tabActive} />
|
||||
</View>
|
||||
}
|
||||
</>
|
||||
<Text style={[Styles.textDefaultSemiBold, { color: colors.text }]}>
|
||||
Laporan Kegiatan
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View style={[Styles.reportContent, { borderLeftColor: colors.tabActive + '50' }]}>
|
||||
<TextExpandable content={data} maxLines={2} />
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ import { useEffect, useState } from "react";
|
||||
import { View } from "react-native";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ModalConfirmation from "../ModalConfirmation";
|
||||
import DrawerBottom from "../drawerBottom";
|
||||
import ItemSectionTanggalTugas from "../itemSectionTanggalTugas";
|
||||
import MenuItemRow from "../menuItemRow";
|
||||
import ModalConfirmation from "../ModalConfirmation";
|
||||
import ModalSelect from "../modalSelect";
|
||||
import SkeletonTask from "../skeletonTask";
|
||||
import Text from "../Text";
|
||||
@@ -74,7 +74,7 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message, })
|
||||
}
|
||||
} catch (error : any ) {
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
const message = error?.response?.data?.message || "Gagal mengubah data"
|
||||
|
||||
@@ -112,7 +112,7 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }
|
||||
} else {
|
||||
Toast.show({ type: 'small', text1: response.message, })
|
||||
}
|
||||
} catch (error : any ) {
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
const message = error?.response?.data?.message || "Gagal menghapus data"
|
||||
|
||||
@@ -127,7 +127,7 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }
|
||||
<>
|
||||
<View style={[Styles.mb15, Styles.mt10]}>
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Tanggal & Tugas</Text>
|
||||
<View style={[Styles.wrapPaper, { backgroundColor: colors.card, borderColor: colors.background }]}>
|
||||
<View>
|
||||
{
|
||||
loading ?
|
||||
arrSkeleton.map((item, index) => {
|
||||
@@ -165,22 +165,16 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }
|
||||
|
||||
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={
|
||||
<MaterialCommunityIcons
|
||||
name="clock-time-three-outline"
|
||||
color={colors.text}
|
||||
size={25}
|
||||
/>
|
||||
}
|
||||
title="Detail Waktu"
|
||||
onPress={() => {
|
||||
setModal(false);
|
||||
setTimeout(() => {
|
||||
setModalDetail(true)
|
||||
}, 600)
|
||||
}}
|
||||
/>
|
||||
{((entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision) && (
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="list-status" color={colors.text} size={25} />}
|
||||
title="Update Status"
|
||||
onPress={() => {
|
||||
setModal(false)
|
||||
setTimeout(() => setSelect(true), 600)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="file-multiple-outline" color={colors.text} size={25} />}
|
||||
title="File Tugas"
|
||||
@@ -189,52 +183,35 @@ export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }
|
||||
router.push(`/division/${id}/task/${detail}/tugas-file/${tugas.id}?member=${isMemberDivision}`)
|
||||
}}
|
||||
/>
|
||||
{
|
||||
(entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision
|
||||
?
|
||||
<>
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="list-status" color={colors.text} size={25} />}
|
||||
title="Update Status"
|
||||
onPress={() => {
|
||||
setModal(false)
|
||||
setTimeout(() => {
|
||||
setSelect(true)
|
||||
}, 600);
|
||||
}}
|
||||
/>
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="pencil-outline" color={colors.text} size={25} />}
|
||||
title="Edit Tugas"
|
||||
onPress={() => {
|
||||
setModal(false)
|
||||
router.push(`./update/${tugas.id}`)
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
:
|
||||
<></>
|
||||
}
|
||||
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="clock-time-three-outline" color={colors.text} size={25} />}
|
||||
title="Detail Waktu"
|
||||
onPress={() => {
|
||||
setModal(false);
|
||||
setTimeout(() => setModalDetail(true), 600)
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
{
|
||||
(entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision
|
||||
?
|
||||
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||
title="Hapus Tugas"
|
||||
onPress={() => {
|
||||
setModal(false)
|
||||
setTimeout(() => {
|
||||
setShowDeleteModal(true)
|
||||
}, 600)
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
:
|
||||
<></>
|
||||
}
|
||||
{((entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision) && (
|
||||
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="pencil-outline" color={colors.text} size={25} />}
|
||||
title="Edit Tugas"
|
||||
onPress={() => {
|
||||
setModal(false)
|
||||
router.push(`./update/${tugas.id}`)
|
||||
}}
|
||||
/>
|
||||
<MenuItemRow
|
||||
icon={<Ionicons name="trash-outline" color={colors.text} size={25} />}
|
||||
title="Hapus Tugas"
|
||||
onPress={() => {
|
||||
setModal(false)
|
||||
setTimeout(() => setShowDeleteModal(true), 600)
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</DrawerBottom>
|
||||
|
||||
<ModalConfirmation
|
||||
|
||||
@@ -1,32 +1,38 @@
|
||||
import Styles from "@/constants/Styles";
|
||||
import { useTheme } from "@/providers/ThemeProvider";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { useRef, useState, useEffect } from "react";
|
||||
import { Animated, Pressable, View } from "react-native";
|
||||
import Text from "./Text";
|
||||
|
||||
export default function TextExpandable({ content, maxLines }: { content: string, maxLines: number }) {
|
||||
const { colors } = useTheme();
|
||||
const [isExpanded, setIsExpanded] = useState(false);
|
||||
const [shouldShowMore, setShouldShowMore] = useState(false);
|
||||
const [collapsedHeight, setCollapsedHeight] = useState(0);
|
||||
const [fullHeight, setFullHeight] = useState(0);
|
||||
const animatedHeight = useRef(new Animated.Value(0)).current;
|
||||
|
||||
useEffect(() => {
|
||||
setCollapsedHeight(0);
|
||||
setFullHeight(0);
|
||||
setShouldShowMore(false);
|
||||
setIsExpanded(false);
|
||||
}, [content]);
|
||||
|
||||
const measureCollapsed = (e: any) => {
|
||||
if (collapsedHeight === 0) {
|
||||
setCollapsedHeight(e.nativeEvent.layout.height);
|
||||
animatedHeight.setValue(e.nativeEvent.layout.height);
|
||||
}
|
||||
const h = e.nativeEvent.layout.height;
|
||||
setCollapsedHeight(h);
|
||||
animatedHeight.setValue(h);
|
||||
};
|
||||
|
||||
const measureFull = (e: any) => {
|
||||
if (fullHeight === 0) {
|
||||
setFullHeight(e.nativeEvent.layout.height);
|
||||
}
|
||||
setFullHeight(e.nativeEvent.layout.height);
|
||||
};
|
||||
|
||||
// Cek apakah memang perlu "View More"
|
||||
useEffect(() => {
|
||||
if (collapsedHeight > 0 && fullHeight > 0) {
|
||||
setShouldShowMore(fullHeight > collapsedHeight + 1); // +1 untuk toleransi float
|
||||
setShouldShowMore(fullHeight > collapsedHeight + 1);
|
||||
}
|
||||
}, [collapsedHeight, fullHeight]);
|
||||
|
||||
@@ -41,41 +47,34 @@ export default function TextExpandable({ content, maxLines }: { content: string,
|
||||
|
||||
return (
|
||||
<View>
|
||||
{/* Hidden full text for measurement */}
|
||||
<View style={Styles.hidden}>
|
||||
<Text style={Styles.textDefault} onLayout={measureFull}>
|
||||
{content}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
{/* Collapsed text for measurement */}
|
||||
<View style={Styles.hidden}>
|
||||
<Text
|
||||
numberOfLines={maxLines}
|
||||
style={Styles.textDefault}
|
||||
onLayout={measureCollapsed}
|
||||
ellipsizeMode="tail"
|
||||
>
|
||||
<Text numberOfLines={maxLines} style={Styles.textDefault} onLayout={measureCollapsed} ellipsizeMode="tail">
|
||||
{content}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
{/* Animated visible text */}
|
||||
<Animated.View style={{ height: animatedHeight, overflow: 'hidden' }}>
|
||||
<Text
|
||||
style={Styles.textDefault}
|
||||
numberOfLines={isExpanded ? undefined : maxLines}
|
||||
ellipsizeMode="tail"
|
||||
>
|
||||
<Text style={Styles.textDefault} numberOfLines={isExpanded ? undefined : maxLines} ellipsizeMode="tail">
|
||||
{content}
|
||||
</Text>
|
||||
</Animated.View>
|
||||
|
||||
{shouldShowMore && (
|
||||
<Pressable onPress={toggleExpand}>
|
||||
<Text style={Styles.textLink}>
|
||||
{isExpanded ? 'View Less' : 'View More'}
|
||||
<Pressable onPress={toggleExpand} style={Styles.expandBtn}>
|
||||
<Text style={[Styles.textMediumSemiBold, { color: colors.tabActive }]}>
|
||||
{isExpanded ? 'Sembunyikan' : 'Lihat selengkapnya'}
|
||||
</Text>
|
||||
<MaterialCommunityIcons
|
||||
name={isExpanded ? 'chevron-up' : 'chevron-down'}
|
||||
size={16}
|
||||
color={colors.tabActive}
|
||||
/>
|
||||
</Pressable>
|
||||
)}
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user