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