Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

App.js : import { Text, SafeAreaView, StyleSheet } from 'react - native'; import { Card } from 'react - native - paper'; import AssetExample from

App.js : import { Text, SafeAreaView, StyleSheet } from 'react-native';
import { Card } from 'react-native-paper';
import AssetExample from './components/AssetExample';
import Category1 from './components/Category1';
export default function App(){
return (
Welcome to POG
Fresh, High Quality Produce
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
// justifyContent: 'center',
backgroundColor: '#ecf0f1',
padding: 8,
},
headerTitle: {
margin: 14,
fontSize: 38,
fontWeight: 'bold',
textAlign: 'center',
},
subTitle: {
margin: 14,
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
},
});
Component/Category1.js
import React, { useState } from 'react';
import { View, Text, Image, StyleSheet,Button } from 'react-native';
import { Picker } from '@react-native-picker/picker';
export default function Category1(){
const [selectedFruit, setSelectedFruit]= useState('select');
const [selectedQuantity, setSelectedQuantity]= useState('quantity');
const [totalPrice, setTotalPrice]= useState(0);
const fruitPrices ={
apple: 2,
banana: 3,
orange: 3,
grapes: 4,
mango: 5
};
const addToBasket =()=>{
const price = fruitPrices[selectedFruit];
const subtotal = price * selectedQuantity;
const newTotalPrice = totalPrice + subtotal;
setTotalPrice(newTotalPrice);
console.log(`Adding ${selectedQuantity} ${selectedFruit}(s) to the basket. Total cost: $${newTotalPrice}`);
// You can implement the functionality to add to basket here
};
return (
Fruits
setSelectedFruit(itemValue)}
>
setSelectedQuantity(itemValue)}
>
Total Price: ${totalPrice.toFixed(2)}
);
}
const styles = StyleSheet.create({
fruits: {
width: '100%',
height: 200,
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
},
title: {
fontSize: 20,
fontWeight: 'bold',
textAlign: 'center',
paddingVertical: 10,
},
});
import { Text, View, StyleSheet, Image } from 'react-native';
export default function AssetExample(){
return (
);
}
const styles = StyleSheet.create({
container: {
alignItems: 'center',
justifyContent: 'center',
padding: 5,
backgroundColor: '#ecf0f1',
borderColor: '#ecf0f1',
},
logo: {
height: 200,
width: 340,
marginBottom:45
}
});
AssetExample.js
import { Text, View, StyleSheet, Image } from 'react-native';
export default function AssetExample(){
return (
);
}
const styles = StyleSheet.create({
container: {
alignItems: 'center',
justifyContent: 'center',
padding: 5,
backgroundColor: '#ecf0f1',
borderColor: '#ecf0f1',
},
logo: {
height: 200,
width: 340,
marginBottom:45
}
});
How do I enter this code into snack expo?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

Why create a partnership?

Answered: 1 week ago