NoelOsiro / cowtrack

0 stars 0 forks source link

OnboardingScreen #10

Closed NoelOsiro closed 2 weeks ago

NoelOsiro commented 2 weeks ago

Starting with onboarding in an Expo app is a great idea to give users a smooth entry experience. Here’s a step-by-step outline of how the onboarding flow could look:

1. Welcome Screen

2. Onboarding Carousel Screens

3. Registration / Login Screen

4. Profile Setup (Optional)

5. Permission Requests (If needed)

6. Final Welcome Screen

Implementing Onboarding Flow in Expo

You could use libraries like react-navigation for screen navigation and react-native-snap-carousel for the onboarding carousel. Here’s a simple approach to get started in Expo:

Step 1: Install Dependencies

In your Expo project, run:

expo install @react-navigation/native @react-navigation/stack react-native-gesture-handler react-native-snap-carousel

Step 2: Set Up Navigation

Create a basic stack navigator in App.js or navigation.js:

import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import WelcomeScreen from './screens/WelcomeScreen';
import OnboardingScreen from './screens/OnboardingScreen';
import LoginScreen from './screens/LoginScreen';
import DashboardScreen from './screens/DashboardScreen';

const Stack = createStackNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator initialRouteName="Welcome">
        <Stack.Screen name="Welcome" component={WelcomeScreen} options={{ headerShown: false }} />
        <Stack.Screen name="Onboarding" component={OnboardingScreen} options={{ headerShown: false }} />
        <Stack.Screen name="Login" component={LoginScreen} />
        <Stack.Screen name="Dashboard" component={DashboardScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

Step 3: Create the Onboarding Carousel

In OnboardingScreen.js:

import React from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';
import Carousel from 'react-native-snap-carousel';

const data = [
  { title: 'Track Your Herd', text: 'Easily keep count of all your animals in one place.' },
  { title: 'Batch Counting', text: 'Quickly count animals passing through with RFID.' },
  { title: 'Health & Feeding Logs', text: 'Record health checks and feeding schedules.' },
  { title: 'Detailed Reports', text: 'Get insights to manage your livestock better.' },
];

export default function OnboardingScreen({ navigation }) {
  const renderItem = ({ item }) => (
    <View style={styles.slide}>
      <Text style={styles.title}>{item.title}</Text>
      <Text style={styles.text}>{item.text}</Text>
    </View>
  );

  return (
    <View style={styles.container}>
      <Carousel
        data={data}
        renderItem={renderItem}
        sliderWidth={300}
        itemWidth={250}
      />
      <Button title="Get Started" onPress={() => navigation.navigate('Login')} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: { flex: 1, justifyContent: 'center', alignItems: 'center' },
  slide: { padding: 20, borderRadius: 10, backgroundColor: '#fff' },
  title: { fontSize: 24, fontWeight: 'bold' },
  text: { fontSize: 16, textAlign: 'center' },
});

This structure will provide a smooth onboarding experience and guide the farmer through essential app features. Does this look good, or would you like to adjust any part?

NoelOsiro commented 2 weeks ago

Onboarding screen complete