Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:chicksmore_beta/Pages/Food/product/product.dart';
- import 'package:chicksmore_beta/Widget/big_text.dart';
- import 'package:cloud_firestore/cloud_firestore.dart';
- import 'package:flutter/material.dart';
- class foodPageBodyFood extends StatefulWidget {
- const foodPageBodyFood({Key? key}) : super(key: key);
- @override
- _foodPageBodyFoodState createState() => _foodPageBodyFoodState();
- }
- class _foodPageBodyFoodState extends State<foodPageBodyFood> {
- int _selectedIndex = 0;
- String routeArgs = "";
- String foodCatergory = "";
- @override
- void didChangeDependencies() {
- routeArgs = ModalRoute.of(context)!.settings.arguments.toString();
- //_selectedIndex = int.parse(
- // routeArgs.substring(1, 2),
- //);
- print(routeArgs.toString());
- if (_selectedIndex == 0) {
- setState(() {
- foodCatergory = 'Chop';
- });
- }
- if (_selectedIndex == 1) {
- setState(() {
- foodCatergory = 'Snacks';
- });
- }
- if (_selectedIndex == 2) {
- setState(() {
- foodCatergory = 'Sides';
- });
- }
- if (_selectedIndex == 3) {
- setState(() {
- foodCatergory = 'Noodle';
- });
- }
- if (_selectedIndex == 4) {
- setState(() {
- foodCatergory = 'Rice';
- });
- }
- if (_selectedIndex == 5) {
- setState(() {
- foodCatergory = 'Bucket';
- });
- }
- if (_selectedIndex == 6) {
- setState(() {
- foodCatergory = 'Combo';
- });
- }
- super.didChangeDependencies();
- }
- Widget build(BuildContext context) {
- return Container(
- height: 600,
- child: Row(
- children: [
- LayoutBuilder(
- builder: ((context, constraints) {
- return SingleChildScrollView(
- child: ConstrainedBox(
- constraints: BoxConstraints(minHeight: constraints.maxHeight),
- child: IntrinsicHeight(
- child: NavigationRail(
- labelType: NavigationRailLabelType.all,
- selectedIndex: _selectedIndex,
- onDestinationSelected: (int index) {
- setState(() {
- _selectedIndex = index;
- print(_selectedIndex);
- if (_selectedIndex == 0) {
- setState(() {
- foodCatergory = 'Chop';
- });
- }
- if (_selectedIndex == 1) {
- setState(() {
- foodCatergory = 'Snacks';
- });
- }
- if (_selectedIndex == 2) {
- setState(() {
- foodCatergory = 'Sides';
- });
- }
- if (_selectedIndex == 3) {
- setState(() {
- foodCatergory = 'Noodle';
- });
- }
- if (_selectedIndex == 4) {
- setState(() {
- foodCatergory = 'Rice';
- });
- }
- if (_selectedIndex == 5) {
- setState(() {
- foodCatergory = 'Bucket';
- });
- }
- if (_selectedIndex == 6) {
- setState(() {
- foodCatergory = 'Combo';
- });
- }
- print(foodCatergory);
- });
- },
- destinations: [
- NavigationRailDestination(
- icon: const Icon(Icons.food_bank),
- label: Text("Chop")),
- NavigationRailDestination(
- icon: const Icon(Icons.food_bank),
- label: Text("Snacks")),
- NavigationRailDestination(
- icon: const Icon(Icons.food_bank),
- label: Text("Sides")),
- NavigationRailDestination(
- icon: const Icon(Icons.food_bank),
- label: Text("Noodle")),
- NavigationRailDestination(
- icon: const Icon(Icons.food_bank),
- label: Text("Rice")),
- NavigationRailDestination(
- icon: const Icon(Icons.food_bank),
- label: Text("Bucket")),
- NavigationRailDestination(
- icon: const Icon(Icons.food_bank),
- label: Text("Combo")),
- ],
- ),
- ),
- ),
- );
- }),
- ),
- //ContentSpace(context, foodCatergory),
- ],
- ),
- );
- }
- }
- class ContentSpace extends StatelessWidget {
- final String category;
- ContentSpace(BuildContext context, this.category);
- final CollectionReference _products =
- FirebaseFirestore.instance.collection('foodProduct');
- @override
- Widget build(BuildContext context) {
- return Container(
- child: StreamBuilder(
- stream: _products.snapshots(),
- builder: (context, AsyncSnapshot<QuerySnapshot> streamSnapshot) {
- if (streamSnapshot.hasData) {
- return ListView.builder(
- itemCount: streamSnapshot.data!.docs.length,
- itemBuilder: (context, index) {
- final DocumentSnapshot documentSnapshot =
- streamSnapshot.data!.docs[index];
- return Container(
- margin: const EdgeInsets.all(10),
- child: ListTile(
- title: Text(documentSnapshot['name']),
- subtitle: Text(documentSnapshot['price'].toString()),
- trailing: SizedBox(
- width: 100,
- ),
- ),
- );
- });
- }
- return SizedBox.shrink();
- }),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement