upd:banner home
deskripsi: - load banner di halaman home - nb : blm selesai No Issues
This commit is contained in:
@@ -1,14 +1,26 @@
|
||||
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 { useSharedValue } from "react-native-reanimated";
|
||||
import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={[Styles.mv15]}>
|
||||
@@ -16,12 +28,16 @@ export default function CaraouselHome() {
|
||||
ref={ref}
|
||||
width={width}
|
||||
height={width / 2.5}
|
||||
data={data}
|
||||
data={entities}
|
||||
loop={true}
|
||||
autoPlay={true}
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user