upd: home
Deskripsi: - update carousel home No Issues
This commit is contained in:
@@ -2,8 +2,8 @@ import Styles from "@/constants/Styles";
|
|||||||
import { apiGetBanner } from "@/lib/api";
|
import { apiGetBanner } from "@/lib/api";
|
||||||
import { setEntities } from "@/lib/bannerSlice";
|
import { setEntities } from "@/lib/bannerSlice";
|
||||||
import { useAuthSession } from "@/providers/AuthProvider";
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
import React from "react";
|
import React, { useEffect } from "react";
|
||||||
import { Dimensions, Text, View } from "react-native";
|
import { Dimensions, Image, View } from "react-native";
|
||||||
import { useSharedValue } from "react-native-reanimated";
|
import { useSharedValue } from "react-native-reanimated";
|
||||||
import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel";
|
import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
@@ -12,16 +12,19 @@ export default function CaraouselHome() {
|
|||||||
const { decryptToken, token } = useAuthSession()
|
const { decryptToken, token } = useAuthSession()
|
||||||
const ref = React.useRef<ICarouselInstance>(null);
|
const ref = React.useRef<ICarouselInstance>(null);
|
||||||
const width = Dimensions.get("window").width;
|
const width = Dimensions.get("window").width;
|
||||||
const data = [...new Array(6).keys()];
|
|
||||||
const progress = useSharedValue<number>(0);
|
const progress = useSharedValue<number>(0);
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const entities = useSelector((state: any) => state.banner)
|
const entities = useSelector((state: any) => state.banner)
|
||||||
|
|
||||||
async function handleBannerView() {
|
async function handleBannerView() {
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
apiGetBanner({ user: hasil }).then((data) => dispatch(setEntities(data.data)));
|
apiGetBanner({ user: hasil }).then((data) => dispatch(setEntities(data.data)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleBannerView()
|
||||||
|
}, [dispatch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[Styles.mv15]}>
|
<View style={[Styles.mv15]}>
|
||||||
<Carousel
|
<Carousel
|
||||||
@@ -34,13 +37,10 @@ export default function CaraouselHome() {
|
|||||||
autoPlayInterval={5000}
|
autoPlayInterval={5000}
|
||||||
onProgressChange={progress}
|
onProgressChange={progress}
|
||||||
renderItem={({ index }) => (
|
renderItem={({ index }) => (
|
||||||
// <Image
|
<Image
|
||||||
// source={require("../../assets/images/user.jpg")}
|
source={{ uri: `https://wibu-storage.wibudev.com/api/files/${entities[index].image}` }}
|
||||||
// style={[Styles.caraoselContent]}
|
style={[Styles.caraoselContent]}
|
||||||
// />
|
/>
|
||||||
<View style={Styles.caraoselContent} >
|
|
||||||
<Text style={{ textAlign: "center", color: "white", fontWeight: 'bold' }}>BANNER DARMASABA</Text>
|
|
||||||
</View>
|
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -251,7 +251,6 @@ const Styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
caraoselContent: {
|
caraoselContent: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
borderWidth: 1,
|
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
marginHorizontal: 15,
|
marginHorizontal: 15,
|
||||||
borderRadius: 15,
|
borderRadius: 15,
|
||||||
|
|||||||
Reference in New Issue
Block a user