-
Notifications
You must be signed in to change notification settings - Fork 0
/
category_screen.dart
64 lines (62 loc) · 2.27 KB
/
category_screen.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:storeapp/common/badge.dart';
import 'package:storeapp/models/cart_manager.dart';
import 'package:storeapp/models/category_manager.dart';
import 'package:storeapp/models/user_manager.dart';
import 'package:storeapp/screens/cart/cart_screen.dart';
import 'package:storeapp/screens/category/category_list_tile.dart';
import 'package:storeapp/screens/category/category_pdts_screen.dart';
class CategoryScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('Category Screen'),
actions: <Widget>[
Consumer<CartManager>(
builder: (context, model, child)=> Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Badge(
value: model.items.length.toString(),
child: child,),
),
child: IconButton(
icon: Icon(Icons.shopping_basket,color: Colors.white,),
onPressed: (){
Navigator.push(context,
MaterialPageRoute(builder: (context)=>CartScreen()));
}
)
),
],
),
body: Consumer<CategoryManager>(
builder: (_,categoryManager,__){
return ListView.builder(
itemCount: categoryManager.allCategories.length,
itemBuilder: (_,index){
return GestureDetector(
onTap: ()async{
await categoryManager.getProductsOfCategory(
category: categoryManager.categories[index].name
);
Navigator.push(context,
MaterialPageRoute(builder: (context)=>
CategoryProductScreen(
categoryModel:categoryManager.categories[index]),
),
);
},
child: CategoryListTile(
categoryManager.allCategories[index],
),
);
}
);
}
),
);
}
}