Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import { HomeScreen } from '@/components/HomeScreen';
// Keep the splash screen visible while we fetch resources
SplashScreen.preventAutoHideAsync();

// For the global.css file for the nativewind
import "@/global.css"


export default function RootLayout() {
// const colorScheme = useColorScheme();
const [loaded] = useFonts({
Expand Down
Binary file added assets/images/carouselimg/carouselautoi.jpg

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are to use the previous images there

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok i will work on that now

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/carouselimg/carouselautoii.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/carouselimg/carouselautoiii.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/carouselimg/carouselautoiv.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = function (api) {
api.cache(true);
return {
presets: [
["babel-preset-expo", { jsxImportSource: "nativewind" }],
"nativewind/babel",
],
};
};
182 changes: 182 additions & 0 deletions components/Autocarousel.tsx

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wasn't expecting a new component.
you where to work on the existing onboarding.tsx component

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry for that taught i will make a new one let me fix that quickly

Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
import {
View ,
FlatList,
Image,
useWindowDimensions,
Text ,
Pressable ,
StyleSheet} from 'react-native'
import React from 'react'
import Animated, { useAnimatedScrollHandler, useSharedValue , SharedValue , useAnimatedStyle , interpolate , FadeIn, FadeOut} from 'react-native-reanimated'

import { BlurView } from 'expo-blur';
export default function Autocarousel() {
// This are varibles for the height and width of the image
const width = useWindowDimensions().width

// This are the properties for the widths and height
const _imageWidth = width * 0.7;
const _imageHeight = _imageWidth * 1.76;

// Gap spacing for the images since it's horizontal
const _spacing = 12;

// For the buttton to appear
const [button , showButton] = React.useState(false)


type item = any;

const datai = [
{i: require("@/assets/images/carouselimg/carouselautoi.jpg") , id: 1},
{i: require("@/assets/images/carouselimg/carouselautoii.jpg") , id: 2},
{i: require("@/assets/images/carouselimg/carouselautoiii.jpg") , id: 3},
{i: require("@/assets/images/carouselimg/carouselautoiv.jpg") , id: 4}
]

// This is for the auto-Scroll
const flatListRef = React.useRef<FlatList<item>>(null);
const [currentIndex, setCurrentIndex] = React.useState(0);


React.useEffect(() => {
const interval = setInterval(() => {
if (flatListRef.current) {
if (currentIndex < datai.length - 1) {
setCurrentIndex(prevIndex => prevIndex + 1);
flatListRef.current?.scrollToIndex({ index: currentIndex + 1, animated: true})
} else {
clearInterval(interval);
showButton(true)
}
}

return () => clearInterval(interval);

}, 2000); // Auto-scroll every 3 seconds

return () => clearInterval(interval); // Cleanup on unmount
}, [currentIndex]);



const BackdropImages =(
{ items , index , scrollX }:{items : item , index: number , scrollX: SharedValue<number>})=>{

// For the animated stylez
const stylez = useAnimatedStyle(()=>{
return{
opacity: interpolate(
scrollX.value ,
[index -1 ,index, index + 1] ,
[0 , 1 ,0] ,
)
}
})

return(
<BlurView intensity={80} tint='dark'>
<Animated.Image
source={items.i}
style ={[StyleSheet.absoluteFillObject , stylez]}
blurRadius={50}
/>
</BlurView>
)
}

// This is the render for the Flatlist
const renderItems = (
{item , index , scrollX }:
{
item:item ,
index: number ,
scrollX: SharedValue<number>
}
) => {

return(
<View
className={'flex-1 overflow-hidden rounded-xl'}
style={{
width: _imageWidth,
height: _imageHeight
}}
>
<Animated.Image
source={item.i}
className='flex-1'
style={{flex:1 }}
/>
</View>
)
}

// For the smooth animation in the sliding
const scrollX = useSharedValue(0);
const onScroll = useAnimatedScrollHandler((e) =>{
// Giving the exact position the picture index are
scrollX.value = e.contentOffset.x / (_imageWidth + _spacing)
// Show button if at the last item
// if (scrollX.value >= datai.length - 1) {
// showButton(true);
// } else {
// showButton(false);
// }

})
return (
<View className='justify-center items-center bg-white' style={{flex: 1}}>
<View
style ={StyleSheet.absoluteFillObject}
>
{
datai.map((item , index) =>(
<BackdropImages items={item} index={index} scrollX={scrollX}/>
)
)
}
</View>

<Animated.FlatList
ref={flatListRef}
data={datai}
renderItem={({ item , index})=>renderItems({item , index , scrollX})}
keyExtractor={(item, index: number) => index.toString()}
className={'flex-grow-0'}
snapToInterval={_imageWidth + _spacing }
decelerationRate={"fast"}
contentContainerStyle = {{
gap: _spacing ,
paddingHorizontal : (40)
}}
horizontal = {true}
onScroll={onScroll}
scrollEventThrottle={ 1000 / 60 } // 16.6 ms
showsHorizontalScrollIndicator = {false}
/>

{/* {showButton &&
<Button title="Next Step" onPress={() => alert('Button Clicked!')} />
} */}

{
button &&
<Pressable>
<Animated.View
className='bg-blue-600 w-20 h-20 rounded-full items-center justify-center position: absolute top-[60] left-[90]'
entering={FadeIn.duration(300)}
exiting={FadeOut.duration(300)}
>
<Text
className='color-white'
>
Next
</Text>
</Animated.View>
</Pressable>
}

</View>
)
}
3 changes: 3 additions & 0 deletions components/HomeScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';


// This is for the component in Auto-Carousel
import Autocarousel from './Autocarousel';
export function HomeScreen() {
return (
<View style={styles.container}>
Expand Down
5 changes: 5 additions & 0 deletions global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "tailwindcss/base";

@import "tailwindcss/components";

@import "tailwindcss/utilities";
2 changes: 2 additions & 0 deletions metro.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');
const { withNativeWind } = require('nativewind/metro');

/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);

module.exports = config;
module.exports = withNativeWind(config, { input: './global.css' })
3 changes: 3 additions & 0 deletions nativewind-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// <reference types="nativewind/types" />

// NOTE: This file should not be edited and should be committed with your source code. It is generated by NativeWind.
Loading