upd: skeleton loading
Deskripsi: - home - list lembaga desa - list jabatan - list member - detail member No Issues
This commit is contained in:
@@ -4,6 +4,7 @@ import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Dimensions, Text, View } from "react-native";
|
||||
import { BarChart } from "react-native-gifted-charts";
|
||||
import Skeleton from "../skeleton";
|
||||
|
||||
type Props = {
|
||||
value: number;
|
||||
@@ -12,6 +13,7 @@ type Props = {
|
||||
}[]
|
||||
|
||||
export default function ChartDokumenHome() {
|
||||
const [loading, setLoading] = useState(true)
|
||||
const { decryptToken, token } = useAuthSession()
|
||||
const [data, setData] = useState<Props>([])
|
||||
const [maxValue, setMaxValue] = useState(5)
|
||||
@@ -24,6 +26,7 @@ export default function ChartDokumenHome() {
|
||||
|
||||
async function handleData() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiGetDataHome({ cat: "dokumen", user: hasil })
|
||||
const maxValue = response.data.reduce((max: number, obj: { value: number; }) => Math.max(max, obj.value), -Infinity);
|
||||
@@ -37,6 +40,8 @@ export default function ChartDokumenHome() {
|
||||
setData(convertedArray)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,28 +52,33 @@ export default function ChartDokumenHome() {
|
||||
return (
|
||||
<View style={[Styles.wrapPaper, Styles.contentItemCenter, Styles.mb15]}>
|
||||
<Text style={[Styles.textSubtitle, Styles.mv15]}>JUMLAH DOKUMEN</Text>
|
||||
<BarChart
|
||||
showFractionalValues={false}
|
||||
showYAxisIndices
|
||||
noOfSections={4}
|
||||
maxValue={maxValue}
|
||||
data={data}
|
||||
isAnimated
|
||||
width={width - 140}
|
||||
barWidth={width * 0.25}
|
||||
renderTooltip={(item: any, index: any) => {
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
width: width * 0.25
|
||||
}}>
|
||||
<Text>{item.value}</Text>
|
||||
</View>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{
|
||||
loading ? <Skeleton width={100} height={200} borderRadius={10} widthType="percent" />
|
||||
:
|
||||
<BarChart
|
||||
showFractionalValues={false}
|
||||
showYAxisIndices
|
||||
noOfSections={4}
|
||||
maxValue={maxValue}
|
||||
data={data}
|
||||
isAnimated
|
||||
width={width - 140}
|
||||
barWidth={width * 0.25}
|
||||
renderTooltip={(item: any, index: any) => {
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
width: width * 0.25
|
||||
}}>
|
||||
<Text>{item.value}</Text>
|
||||
</View>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { PieChart } from "react-native-gifted-charts";
|
||||
import Skeleton from "../skeleton";
|
||||
|
||||
type Props = {
|
||||
value: number;
|
||||
@@ -14,9 +15,11 @@ type Props = {
|
||||
export default function ChartProgresHome() {
|
||||
const { decryptToken, token } = useAuthSession()
|
||||
const [data, setData] = useState<Props>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
async function handleData() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiGetDataHome({ cat: "progress", user: hasil })
|
||||
const convertedArray = response.data.map((item: { color: any; text: any; value: any; }) => ({
|
||||
@@ -27,6 +30,8 @@ export default function ChartProgresHome() {
|
||||
setData(convertedArray)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,44 +42,50 @@ export default function ChartProgresHome() {
|
||||
return (
|
||||
<View style={[Styles.wrapPaper, Styles.contentItemCenter, Styles.mb15]}>
|
||||
<Text style={[Styles.textSubtitle, Styles.mv15]}>PROGRES KEGIATAN</Text>
|
||||
<PieChart
|
||||
data={data}
|
||||
showText
|
||||
showValuesAsTooltipText
|
||||
textColor="black"
|
||||
radius={120}
|
||||
textSize={15}
|
||||
focusOnPress={false}
|
||||
showValuesAsLabels
|
||||
showTextBackground={false}
|
||||
textBackgroundRadius={0}
|
||||
isAnimated
|
||||
/>
|
||||
{
|
||||
loading ? <Skeleton width={100} height={200} borderRadius={10} widthType="percent" />
|
||||
:
|
||||
<>
|
||||
<PieChart
|
||||
data={data}
|
||||
showText
|
||||
showValuesAsTooltipText
|
||||
textColor="black"
|
||||
radius={120}
|
||||
textSize={15}
|
||||
focusOnPress={false}
|
||||
showValuesAsLabels
|
||||
showTextBackground={false}
|
||||
textBackgroundRadius={0}
|
||||
isAnimated
|
||||
/>
|
||||
|
||||
<View style={[Styles.mt15]}>
|
||||
<View style={[Styles.rowSpaceBetween, Styles.w80]}>
|
||||
<View style={[Styles.rowItemsCenter, Styles.w60]}>
|
||||
<View style={[Styles.iconContent, { backgroundColor: '#177AD5' }]}></View>
|
||||
<Text style={[Styles.textInformation, Styles.ml10]}>Segera Dikerjakan</Text>
|
||||
</View>
|
||||
<View style={[Styles.mt15]}>
|
||||
<View style={[Styles.rowSpaceBetween, Styles.w80]}>
|
||||
<View style={[Styles.rowItemsCenter, Styles.w60]}>
|
||||
<View style={[Styles.iconContent, { backgroundColor: '#177AD5' }]}></View>
|
||||
<Text style={[Styles.textInformation, Styles.ml10]}>Segera Dikerjakan</Text>
|
||||
</View>
|
||||
|
||||
<View style={[Styles.rowItemsCenter, Styles.w50]}>
|
||||
<View style={[Styles.iconContent, { backgroundColor: '#92cc76' }]}></View>
|
||||
<Text style={[Styles.textInformation, Styles.ml10]}>Selesai</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View style={[Styles.rowSpaceBetween, Styles.w80, Styles.mt10]}>
|
||||
<View style={[Styles.rowItemsCenter, Styles.w60]}>
|
||||
<View style={[Styles.iconContent, { backgroundColor: '#fac858' }]}></View>
|
||||
<Text style={[Styles.textInformation, Styles.ml10]}>Dikerjakan</Text>
|
||||
</View>
|
||||
<View style={[Styles.rowItemsCenter, Styles.w50]}>
|
||||
<View style={[Styles.iconContent, { backgroundColor: '#92cc76' }]}></View>
|
||||
<Text style={[Styles.textInformation, Styles.ml10]}>Selesai</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View style={[Styles.rowSpaceBetween, Styles.w80, Styles.mt10]}>
|
||||
<View style={[Styles.rowItemsCenter, Styles.w60]}>
|
||||
<View style={[Styles.iconContent, { backgroundColor: '#fac858' }]}></View>
|
||||
<Text style={[Styles.textInformation, Styles.ml10]}>Dikerjakan</Text>
|
||||
</View>
|
||||
|
||||
<View style={[Styles.rowItemsCenter, Styles.w50]}>
|
||||
<View style={[Styles.iconContent, { backgroundColor: '#ED6665' }]}></View>
|
||||
<Text style={[Styles.textInformation, Styles.ml10]}>Dibatalkan</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View style={[Styles.rowItemsCenter, Styles.w50]}>
|
||||
<View style={[Styles.iconContent, { backgroundColor: '#ED6665' }]}></View>
|
||||
<Text style={[Styles.textInformation, Styles.ml10]}>Dibatalkan</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiGetDataHome } from "@/lib/api";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { router } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import DiscussionItem from "../discussionItem";
|
||||
import Skeleton from "../skeleton";
|
||||
|
||||
type Props = {
|
||||
id: string
|
||||
@@ -17,15 +19,19 @@ type Props = {
|
||||
export default function DisccussionHome() {
|
||||
const { decryptToken, token } = useAuthSession()
|
||||
const [data, setData] = useState<Props[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
|
||||
async function handleData() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiGetDataHome({ cat: "discussion", user: hasil })
|
||||
setData(response.data)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,13 +44,19 @@ export default function DisccussionHome() {
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Diskusi</Text>
|
||||
<View style={[Styles.wrapPaper]}>
|
||||
{
|
||||
data.length > 0 ?
|
||||
data.map((item, index) => {
|
||||
return (
|
||||
<DiscussionItem key={index} title={item.desc} user={item.user} date={item.date} />
|
||||
)
|
||||
})
|
||||
: <Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada acara hari ini</Text>
|
||||
loading ?
|
||||
<>
|
||||
<Skeleton width={100} height={70} borderRadius={10} widthType="percent" />
|
||||
<Skeleton width={100} height={70} borderRadius={10} widthType="percent" />
|
||||
</>
|
||||
:
|
||||
data.length > 0 ?
|
||||
data.map((item, index) => {
|
||||
return (
|
||||
<DiscussionItem key={index} title={item.desc} user={item.user} date={item.date} onPress={() => { router.push(`/division/${item.idDivision}/discussion/${item.id}`) }} />
|
||||
)
|
||||
})
|
||||
: <Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada diskusi</Text>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -6,6 +6,7 @@ import React, { useEffect, useState } from "react";
|
||||
import { Dimensions, Text, View } from "react-native";
|
||||
import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel";
|
||||
import PaperGridContent from "../paperGridContent";
|
||||
import Skeleton from "../skeleton";
|
||||
|
||||
type Props = {
|
||||
id: string
|
||||
@@ -18,14 +19,18 @@ export default function DivisionHome() {
|
||||
const ref = React.useRef<ICarouselInstance>(null);
|
||||
const width = Dimensions.get("window").width;
|
||||
const [data, setData] = useState<Props[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
async function handleData() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiGetDataHome({ cat: "division", user: hasil })
|
||||
setData(response.data)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,27 +43,32 @@ export default function DivisionHome() {
|
||||
return (
|
||||
<View style={[Styles.mb15]}>
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Divisi Teraktif</Text>
|
||||
<Carousel
|
||||
ref={ref}
|
||||
style={{ width: "100%" }}
|
||||
width={width * 0.8}
|
||||
height={235}
|
||||
data={data}
|
||||
loop={true}
|
||||
autoPlay={false}
|
||||
autoPlayReverse={false}
|
||||
pagingEnabled={true}
|
||||
snapEnabled={true}
|
||||
vertical={false}
|
||||
renderItem={({ index }) => (
|
||||
<PaperGridContent onPress={() => { router.push(`/division/${data[index].id}`) }} content="carousel" title={data[index].name} headerColor="warning">
|
||||
<View>
|
||||
<Text style={{ fontSize: 50, textAlign: "center", fontWeight: 'bold' }}>{data[index].jumlah}</Text>
|
||||
<Text style={[Styles.textSubtitle, { textAlign: "center" }]}>KEGIATAN</Text>
|
||||
</View>
|
||||
</PaperGridContent>
|
||||
)}
|
||||
/>
|
||||
{
|
||||
loading ? <Skeleton width={100} height={150} borderRadius={10} widthType="percent" />
|
||||
:
|
||||
<Carousel
|
||||
ref={ref}
|
||||
style={{ width: "100%" }}
|
||||
width={width * 0.8}
|
||||
height={235}
|
||||
data={data}
|
||||
loop={true}
|
||||
autoPlay={false}
|
||||
autoPlayReverse={false}
|
||||
pagingEnabled={true}
|
||||
snapEnabled={true}
|
||||
vertical={false}
|
||||
renderItem={({ index }) => (
|
||||
<PaperGridContent onPress={() => { router.push(`/division/${data[index].id}`) }} content="carousel" title={data[index].name} headerColor="warning">
|
||||
<View>
|
||||
<Text style={{ fontSize: 50, textAlign: "center", fontWeight: 'bold' }}>{data[index].jumlah}</Text>
|
||||
<Text style={[Styles.textSubtitle, { textAlign: "center" }]}>KEGIATAN</Text>
|
||||
</View>
|
||||
</PaperGridContent>
|
||||
)}
|
||||
/>
|
||||
}
|
||||
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiGetDataHome } from "@/lib/api";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { router } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import EventItem from "../eventItem";
|
||||
import { router } from "expo-router";
|
||||
import Skeleton from "../skeleton";
|
||||
|
||||
type Props = {
|
||||
id: string
|
||||
@@ -23,14 +24,18 @@ type Props = {
|
||||
export default function EventHome() {
|
||||
const { decryptToken, token } = useAuthSession()
|
||||
const [data, setData] = useState<Props[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
async function handleData() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiGetDataHome({ cat: "event", user: hasil })
|
||||
setData(response.data)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,14 +47,21 @@ export default function EventHome() {
|
||||
<View style={[Styles.mb15]}>
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Acara Hari Ini</Text>
|
||||
<View style={[Styles.wrapPaper]}>
|
||||
|
||||
{
|
||||
data.length > 0 ?
|
||||
data.map((item, index) => {
|
||||
return (
|
||||
<EventItem key={index} category={index % 2 == 0 ? 'purple' : 'orange'} onPress={() => {router.push(`/division/${item.idDivision}/calendar/${item.id}`)}} title={item.title} user={item.user_name} jamAwal={item.timeStart} jamAkhir={item.timeEnd} />
|
||||
)
|
||||
})
|
||||
: <Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada acara hari ini</Text>
|
||||
loading ?
|
||||
<>
|
||||
<Skeleton width={100} height={70} borderRadius={10} widthType="percent" />
|
||||
<Skeleton width={100} height={70} borderRadius={10} widthType="percent" />
|
||||
</>
|
||||
:
|
||||
data.length > 0 ?
|
||||
data.map((item, index) => {
|
||||
return (
|
||||
<EventItem key={index} category={index % 2 == 0 ? 'purple' : 'orange'} onPress={() => { router.push(`/division/${item.idDivision}/calendar/${item.id}`) }} title={item.title} user={item.user_name} jamAwal={item.timeStart} jamAkhir={item.timeEnd} />
|
||||
)
|
||||
})
|
||||
: <Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada acara hari ini</Text>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -8,6 +8,7 @@ import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel";
|
||||
import LabelStatus from "../labelStatus";
|
||||
import PaperGridContent from "../paperGridContent";
|
||||
import ProgressBar from "../progressBar";
|
||||
import Skeleton from "../skeleton";
|
||||
|
||||
type Props = {
|
||||
id: string
|
||||
@@ -23,14 +24,18 @@ export default function ProjectHome() {
|
||||
const ref = React.useRef<ICarouselInstance>(null);
|
||||
const width = Dimensions.get("window").width;
|
||||
const [data, setData] = useState<Props[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
async function handleData() {
|
||||
try {
|
||||
setLoading(true)
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiGetDataHome({ cat: "kegiatan", user: hasil })
|
||||
setData(response.data)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,44 +46,49 @@ export default function ProjectHome() {
|
||||
return (
|
||||
<View style={[Styles.mb15]}>
|
||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Kegiatan Terupdate</Text>
|
||||
<Carousel
|
||||
ref={ref}
|
||||
style={{ width: "100%" }}
|
||||
width={width * 0.8}
|
||||
height={235}
|
||||
data={data}
|
||||
loop={true}
|
||||
autoPlay={false}
|
||||
autoPlayReverse={false}
|
||||
pagingEnabled={true}
|
||||
snapEnabled={true}
|
||||
vertical={false}
|
||||
renderItem={({ index }) => (
|
||||
<PaperGridContent content="carousel" onPress={() => { router.push(`/project/${data[index].id}`) }} title={data[index].title} headerColor="primary">
|
||||
<ProgressBar value={data[index].progress} category="carousel" />
|
||||
<View style={[Styles.rowSpaceBetween]}>
|
||||
<Text style={[Styles.textDefault, Styles.cGray]}>{data[index].createdAt}</Text>
|
||||
<LabelStatus
|
||||
size="default"
|
||||
category={
|
||||
data[index].status === 0 ? 'primary' :
|
||||
data[index].status === 1 ? 'warning' :
|
||||
data[index].status === 2 ? 'success' :
|
||||
data[index].status === 3 ? 'error' :
|
||||
'primary'
|
||||
}
|
||||
text={
|
||||
data[index].status === 0 ? 'SEGERA' :
|
||||
data[index].status === 1 ? 'DIKERJAKAN' :
|
||||
data[index].status === 2 ? 'SELESAI' :
|
||||
data[index].status === 3 ? 'DIBATALKAN' :
|
||||
'SEGERA'
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
</PaperGridContent>
|
||||
)}
|
||||
/>
|
||||
{
|
||||
loading ? (<Skeleton width={100} height={150} borderRadius={10} widthType="percent" />)
|
||||
:
|
||||
<Carousel
|
||||
ref={ref}
|
||||
style={{ width: "100%" }}
|
||||
width={width * 0.8}
|
||||
height={235}
|
||||
data={data}
|
||||
loop={true}
|
||||
autoPlay={false}
|
||||
autoPlayReverse={false}
|
||||
pagingEnabled={true}
|
||||
snapEnabled={true}
|
||||
vertical={false}
|
||||
renderItem={({ index }) => (
|
||||
<PaperGridContent content="carousel" onPress={() => { router.push(`/project/${data[index].id}`) }} title={data[index].title} headerColor="primary">
|
||||
<ProgressBar value={data[index].progress} category="carousel" />
|
||||
<View style={[Styles.rowSpaceBetween]}>
|
||||
<Text style={[Styles.textDefault, Styles.cGray]}>{data[index].createdAt}</Text>
|
||||
<LabelStatus
|
||||
size="default"
|
||||
category={
|
||||
data[index].status === 0 ? 'primary' :
|
||||
data[index].status === 1 ? 'warning' :
|
||||
data[index].status === 2 ? 'success' :
|
||||
data[index].status === 3 ? 'error' :
|
||||
'primary'
|
||||
}
|
||||
text={
|
||||
data[index].status === 0 ? 'SEGERA' :
|
||||
data[index].status === 1 ? 'DIKERJAKAN' :
|
||||
data[index].status === 2 ? 'SELESAI' :
|
||||
data[index].status === 3 ? 'DIBATALKAN' :
|
||||
'SEGERA'
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
</PaperGridContent>
|
||||
)}
|
||||
/>
|
||||
}
|
||||
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { Image } from "react-native";
|
||||
|
||||
type Props = {
|
||||
src: string,
|
||||
size?: 'sm' | 'xs'
|
||||
size?: 'sm' | 'xs' | 'lg'
|
||||
border?: boolean
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default function ImageUser({ src, size }: Props) {
|
||||
return (
|
||||
<Image
|
||||
source={error ? require('../assets/images/user.jpg') : { uri: src }}
|
||||
style={[size == 'xs' ? Styles.userProfileExtraSmall : Styles.userProfileSmall, Styles.borderAll]}
|
||||
style={[size == 'xs' ? Styles.userProfileExtraSmall : size == 'lg' ? Styles.userProfileBig : Styles.userProfileSmall, Styles.borderAll]}
|
||||
onError={() =>
|
||||
setError(true)
|
||||
}
|
||||
|
||||
40
components/skeleton.tsx
Normal file
40
components/skeleton.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import Styles from '@/constants/Styles';
|
||||
import React, { useEffect } from 'react';
|
||||
import { StyleSheet } from 'react-native';
|
||||
import Animated, { Easing, useAnimatedStyle, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';
|
||||
|
||||
const Skeleton = ({ width, height, borderRadius = 0, widthType = 'number' }: { width: number, widthType?: 'number' | 'percent', height: number, borderRadius?: number }) => {
|
||||
const opacity = useSharedValue(0.3);
|
||||
|
||||
useEffect(() => {
|
||||
opacity.value = withRepeat(
|
||||
withTiming(1, { duration: 500, easing: Easing.linear }),
|
||||
-1,
|
||||
true
|
||||
);
|
||||
}, []);
|
||||
|
||||
const animatedStyle = useAnimatedStyle(() => {
|
||||
return {
|
||||
opacity: opacity.value,
|
||||
};
|
||||
});
|
||||
|
||||
return (
|
||||
<Animated.View
|
||||
style={[
|
||||
styles.skeleton,
|
||||
{ width: widthType === 'percent' ? `${width}%` : width, height: height, borderRadius: borderRadius },
|
||||
animatedStyle, Styles.mv05
|
||||
]}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
skeleton: {
|
||||
backgroundColor: '#e0e0e0',
|
||||
},
|
||||
});
|
||||
|
||||
export default Skeleton;
|
||||
14
components/skeletonTwoItem.tsx
Normal file
14
components/skeletonTwoItem.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import Styles from "@/constants/Styles";
|
||||
import { View } from "react-native";
|
||||
import Skeleton from "./skeleton";
|
||||
|
||||
export default function SkeletonTwoItem() {
|
||||
return (
|
||||
<View style={[Styles.rowOnly]}>
|
||||
<Skeleton width={50} height={50} borderRadius={10} />
|
||||
<View style={[{ flex: 1 }, Styles.ph05]}>
|
||||
<Skeleton width={100} widthType="percent" height={50} borderRadius={10} />
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user