Skip to content

Commit e13306d

Browse files
committed
shopping list added
1 parent e94a9d7 commit e13306d

File tree

11 files changed

+269
-8
lines changed

11 files changed

+269
-8
lines changed

lib/logic/bloc/product_bloc.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import 'dart:async';
2+
3+
import 'package:flutter_uikit/logic/viewmodel/product_view_model.dart';
4+
import 'package:flutter_uikit/model/product.dart';
5+
6+
class ProductBloc {
7+
final ProductViewModel productViewModel = ProductViewModel();
8+
final productController = StreamController<List<Product>>();
9+
Stream<List<Product>> get productItems => productController.stream;
10+
11+
ProductBloc() {
12+
productController.add(productViewModel.getProducts());
13+
}
14+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import 'package:flutter_uikit/model/product.dart';
2+
3+
class ProductViewModel {
4+
List<Product> productsItems;
5+
6+
ProductViewModel({this.productsItems});
7+
8+
getProducts() => <Product>[
9+
Product(
10+
brand: "Levis",
11+
description: "Print T-shirt",
12+
image:
13+
"https://mosaic02.ztat.net/vgs/media/pdp-zoom/LE/22/1D/02/2A/12/LE221D022-A12@16.1.jpg",
14+
name: "THE PERFECT",
15+
price: "£19.99",
16+
rating: 4.0,
17+
totalReviews: 170),
18+
Product(
19+
brand: "adidas Performance",
20+
description: "Pool sliders",
21+
image:
22+
"https://mosaic02.ztat.net/vgs/media/catalog-lg/AD/58/1D/00/9Q/12/AD581D009-Q12@13.jpg",
23+
name: "AQUALETTE",
24+
price: "£13.49",
25+
rating: 5.0,
26+
totalReviews: 10),
27+
Product(
28+
brand: "Produkt",
29+
description: "Men's Shirt",
30+
image:
31+
"https://mosaic01.ztat.net/vgs/media/pdp-zoom/PY/52/2D/01/FG/11/PY522D01F-G11@8.jpg",
32+
name: "ROBI CHECK",
33+
price: "£16.49",
34+
rating: 4.5,
35+
totalReviews: 0),
36+
Product(
37+
brand: "adidas Originals",
38+
description: "Hoodie",
39+
image:
40+
"https://mosaic01.ztat.net/vgs/media/pdp-zoom/AD/12/2S/07/QN/11/AD122S07Q-N11@8.jpg",
41+
name: "TREF OVER HOOD",
42+
price: "£34.99",
43+
rating: 4.0,
44+
totalReviews: 5),
45+
Product(
46+
brand: "ION",
47+
description: "Hydration rucksack",
48+
image:
49+
"https://mosaic01.ztat.net/vgs/media/packshot/pdp-zoom/N1/94/4E/00/4G/11/N1944E004-G11@10.jpg",
50+
name: "BACKPACK VILLAIN 4",
51+
price: "£55.99",
52+
rating: 4.8,
53+
totalReviews: 12),
54+
Product(
55+
brand: "Diesel",
56+
description: "Straight leg jeans",
57+
image:
58+
"https://mosaic01.ztat.net/vgs/media/pdp-gallery/DI/12/2G/0H/5K/11/DI122G0H5-K11@10.jpg",
59+
name: "THYTAN",
60+
price: "£83.99",
61+
rating: 4.2,
62+
totalReviews: 28),
63+
Product(
64+
brand: "YOURTURN",
65+
description: "Watch in budget",
66+
image:
67+
"https://mosaic02.ztat.net/vgs/media/packshot/pdp-zoom/YO/15/2M/00/6Q/11/YO152M006-Q11@6.jpg",
68+
name: "Watch",
69+
price: "£11.99",
70+
rating: 4.7,
71+
totalReviews: 120),
72+
Product(
73+
brand: "Vero Moda",
74+
description: "Day dress - black/off",
75+
image:
76+
"https://mosaic01.ztat.net/vgs/media/pdp-zoom/VE/12/1C/1B/RQ/11/VE121C1BR-Q11@15.jpg",
77+
name: "VMKANA",
78+
price: "£26.59",
79+
rating: 4.0,
80+
totalReviews: 33),
81+
Product(
82+
brand: "ONLY",
83+
description: "A-line skirt",
84+
image:
85+
"https://mosaic01.ztat.net/vgs/media/pdp-zoom/ON/32/1B/0B/JG/11/ON321B0BJ-G11@8.jpg",
86+
name: "ONLTHAI FRILL",
87+
price: "£25.59",
88+
rating: 4.4,
89+
totalReviews: 44),
90+
Product(
91+
brand: "MAI PIÙ SENZA",
92+
description: "Awesome Heels",
93+
image:
94+
"https://mosaic01.ztat.net/vgs/media/pdp-zoom/M6/61/1B/02/9A/11/M6611B029-A11@13.jpg",
95+
name: "HIGH HEELS",
96+
price: "£59.99",
97+
rating: 4.1,
98+
totalReviews: 22),
99+
];
100+
}

lib/model/product.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Product {
2+
String name;
3+
String image;
4+
double rating;
5+
String price;
6+
String brand;
7+
String description;
8+
int totalReviews;
9+
10+
Product(
11+
{this.name,
12+
this.image,
13+
this.brand,
14+
this.price,
15+
this.rating,
16+
this.description,
17+
this.totalReviews});
18+
}

lib/myapp.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_uikit/ui/page/home_page.dart';
3-
import 'package:flutter_uikit/ui/page/notfound_page.dart';
4-
import 'package:flutter_uikit/ui/page/profile_one_page.dart';
5-
import 'package:flutter_uikit/ui/page/settings_one_page.dart';
6-
import 'package:flutter_uikit/ui/page/timeline_one_page.dart';
3+
import 'package:flutter_uikit/ui/page/notfound/notfound_page.dart';
4+
import 'package:flutter_uikit/ui/page/profile/profile_one_page.dart';
5+
import 'package:flutter_uikit/ui/page/settings/settings_one_page.dart';
6+
import 'package:flutter_uikit/ui/page/shopping/shopping_one_page.dart';
7+
import 'package:flutter_uikit/ui/page/timeline/timeline_one_page.dart';
8+
79
import 'package:flutter_uikit/utils/uidata.dart';
810

911
class MyApp extends StatelessWidget {
1012
final materialApp = MaterialApp(
1113
theme: ThemeData(primaryColor: Colors.pink),
1214
debugShowCheckedModeBanner: false,
1315
showPerformanceOverlay: false,
14-
home: SettingsOnePage(),
16+
home: ShoppingOnePage(),
1517
// initialRoute: UIData.notFoundRoute,
1618

1719
//routes
@@ -21,6 +23,7 @@ class MyApp extends StatelessWidget {
2123
UIData.timelineOneRoute: (BuildContext context) => TimelineOnePage(),
2224
UIData.notFoundRoute: (BuildContext context) => NotFoundPage(),
2325
UIData.settingsOneRoute: (BuildContext context) => SettingsOnePage(),
26+
UIData.shoppingOneRoute: (BuildContext context) => ShoppingOnePage(),
2427
},
2528
);
2629

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class NotFoundPage extends StatelessWidget {
3737
return CommonScaffold(
3838
appTitle: appTitle,
3939
bodyData: bodyData(),
40+
showDrawer: false,
4041
showFAB: false,
4142
);
4243
}
File renamed without changes.
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_uikit/logic/bloc/product_bloc.dart';
3+
import 'package:flutter_uikit/model/product.dart';
4+
import 'package:flutter_uikit/ui/widgets/common_scaffold.dart';
5+
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
6+
7+
class ShoppingOnePage extends StatelessWidget {
8+
//stack1
9+
Widget imageStack(String img) => Image.network(
10+
img,
11+
fit: BoxFit.cover,
12+
);
13+
14+
//stack2
15+
Widget descStack(Product product) => Positioned(
16+
bottom: 0.0,
17+
left: 0.0,
18+
right: 0.0,
19+
child: Container(
20+
decoration: BoxDecoration(color: Colors.black.withOpacity(0.5)),
21+
child: Padding(
22+
padding: const EdgeInsets.all(8.0),
23+
child: Row(
24+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
25+
children: <Widget>[
26+
Expanded(
27+
child: Text(
28+
product.name,
29+
softWrap: true,
30+
overflow: TextOverflow.ellipsis,
31+
style: TextStyle(color: Colors.white),
32+
),
33+
),
34+
Text(product.price,
35+
style: TextStyle(
36+
color: Colors.yellow,
37+
fontSize: 18.0,
38+
fontWeight: FontWeight.bold))
39+
],
40+
),
41+
),
42+
),
43+
);
44+
45+
//stack3
46+
Widget ratingStack(double rating) => Positioned(
47+
top: 0.0,
48+
left: 0.0,
49+
child: Container(
50+
padding: EdgeInsets.all(4.0),
51+
decoration: BoxDecoration(
52+
color: Colors.black.withOpacity(0.9),
53+
borderRadius: BorderRadius.only(
54+
topRight: Radius.circular(10.0),
55+
bottomRight: Radius.circular(10.0))),
56+
child: Row(
57+
children: <Widget>[
58+
Icon(
59+
Icons.star,
60+
color: Colors.cyanAccent,
61+
size: 10.0,
62+
),
63+
SizedBox(
64+
width: 2.0,
65+
),
66+
Text(
67+
rating.toString(),
68+
style: TextStyle(color: Colors.white, fontSize: 10.0),
69+
)
70+
],
71+
),
72+
),
73+
);
74+
75+
Widget productGrid(List<Product> products) => GridView.count(
76+
crossAxisCount: 2,
77+
shrinkWrap: true,
78+
children: products
79+
.map((product) => Padding(
80+
padding: const EdgeInsets.all(8.0),
81+
child: InkWell(
82+
splashColor: Colors.yellow,
83+
onTap: () {},
84+
child: Material(
85+
elevation: 2.0,
86+
color: Colors.yellow,
87+
child: Stack(
88+
fit: StackFit.expand,
89+
children: <Widget>[
90+
imageStack(product.image),
91+
descStack(product),
92+
ratingStack(product.rating),
93+
],
94+
),
95+
),
96+
),
97+
))
98+
.toList(),
99+
);
100+
101+
Widget bodyData() {
102+
ProductBloc productBloc = ProductBloc();
103+
return StreamBuilder<List<Product>>(
104+
stream: productBloc.productItems,
105+
builder: (context, snapshot) {
106+
return snapshot.hasData
107+
? productGrid(snapshot.data)
108+
: Center(child: CircularProgressIndicator());
109+
});
110+
}
111+
112+
@override
113+
Widget build(BuildContext context) {
114+
return CommonScaffold(
115+
appTitle: "Products",
116+
showDrawer: true,
117+
showFAB: false,
118+
actionFirstIcon:Icons.shopping_cart,
119+
bodyData: bodyData(),
120+
);
121+
}
122+
}
File renamed without changes.

lib/ui/widgets/common_scaffold.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ class CommonScaffold extends StatelessWidget {
66
final showFAB;
77
final showDrawer;
88
final backGroundColor;
9+
final actionFirstIcon;
910

1011
CommonScaffold(
1112
{this.appTitle,
1213
this.bodyData,
1314
this.showFAB,
14-
this.showDrawer = true,
15-
this.backGroundColor});
15+
this.showDrawer = false,
16+
this.backGroundColor,
17+
this.actionFirstIcon = Icons.search});
1618

1719
@override
1820
Widget build(BuildContext context) {
@@ -27,7 +29,7 @@ class CommonScaffold extends StatelessWidget {
2729
),
2830
IconButton(
2931
onPressed: () {},
30-
icon: Icon(Icons.search),
32+
icon: Icon(actionFirstIcon),
3133
),
3234
IconButton(
3335
onPressed: () {},

0 commit comments

Comments
 (0)