-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
342 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
lib/screens/product/widgets/product_info/add_to_cart_button.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class AddToCartButton extends StatelessWidget { | ||
final Function() onPressed; | ||
AddToCartButton({Key key, this.onPressed}) : super(key: key); | ||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(20), | ||
boxShadow: [ | ||
BoxShadow( | ||
color: Theme.of(context).accentColor, | ||
blurRadius: 8, | ||
) | ||
], | ||
), | ||
child: Material( | ||
color: Theme.of(context).accentColor, | ||
shadowColor: Theme.of(context).accentColor, | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(20), | ||
), | ||
child: InkWell( | ||
onTap: onPressed, | ||
splashColor: Colors.white, | ||
borderRadius: BorderRadius.circular(20), | ||
child: Container( | ||
width: 150, | ||
height: 80, | ||
alignment: Alignment.center, | ||
child: Text( | ||
"Add to cart", | ||
style: TextStyle( | ||
color: Colors.white, | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
lib/screens/product/widgets/product_info/favourite_button.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class FavouriteButton extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
height: 50, | ||
width: 50, | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(50), | ||
color: Theme.of(context).accentColor, | ||
boxShadow: [ | ||
BoxShadow( | ||
color: Theme.of(context).accentColor, | ||
blurRadius: 20, | ||
) | ||
], | ||
), | ||
child: Icon( | ||
Icons.favorite, | ||
color: Colors.white, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:shoptronics/data_models/product.dart'; | ||
import 'package:shoptronics/screens/product/widgets/product_info/plus_minus_incrementer.dart'; | ||
import 'package:shoptronics/screens/product/widgets/product_info/rating.dart'; | ||
|
||
class InfoCard extends StatelessWidget { | ||
final Product product; | ||
InfoCard({this.product}); | ||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
height: 380, | ||
width: double.infinity, | ||
decoration: BoxDecoration( | ||
color: Colors.white, | ||
borderRadius: BorderRadius.circular(40), | ||
), | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 32, horizontal: 24), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: <Widget>[ | ||
Flexible( | ||
flex: 1, | ||
child: Text( | ||
product.name, | ||
textAlign: TextAlign.left, | ||
style: TextStyle( | ||
fontSize: 25, | ||
fontWeight: FontWeight.w600, | ||
color: Color(0xFF4209B7), | ||
), | ||
), | ||
), | ||
SizedBox(height: 12), | ||
Flexible( | ||
flex: 1, | ||
child: Text( | ||
product.price, | ||
style: TextStyle( | ||
fontSize: 16, | ||
fontWeight: FontWeight.w400, | ||
color: Colors.black.withAlpha(150), | ||
), | ||
), | ||
), | ||
SizedBox(height: 12), | ||
Flexible( | ||
flex: 1, | ||
child: Rating(rating: 3.5), | ||
), | ||
SizedBox(height: 20), | ||
Flexible( | ||
flex: 5, | ||
child: Text( | ||
product.description, | ||
style: TextStyle( | ||
color: Color(0xFF241D8C), | ||
height: 2, | ||
), | ||
), | ||
), | ||
SizedBox(height: 30), | ||
Flexible( | ||
flex: 2, | ||
child: PlusMinusIncrementer(), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
lib/screens/product/widgets/product_info/plus_minus_incrementer.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:shoptronics/screens/product/widgets/product_info/add_to_cart_button.dart'; | ||
|
||
class PlusMinusIncrementer extends StatefulWidget { | ||
@override | ||
_PlusMinusIncrementerState createState() => _PlusMinusIncrementerState(); | ||
} | ||
|
||
class _PlusMinusIncrementerState extends State<PlusMinusIncrementer> { | ||
int qty; | ||
@override | ||
void initState() { | ||
qty = 0; | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: <Widget>[ | ||
Container( | ||
width: 100, | ||
height: 35, | ||
decoration: BoxDecoration( | ||
color: Colors.grey[100], | ||
borderRadius: BorderRadius.circular(30), | ||
), | ||
child: Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
children: <Widget>[ | ||
// Gesture detector used instead of IconButton to avoid unnecessary padding | ||
GestureDetector( | ||
onTap: () { | ||
if (qty != 0) { | ||
setState(() => qty--); | ||
} | ||
}, | ||
child: Icon( | ||
Icons.remove, | ||
color: Colors.grey[400], | ||
size: 18, | ||
), | ||
), | ||
Text( | ||
"$qty", | ||
style: TextStyle( | ||
color: Color(0xFF4209B7), fontWeight: FontWeight.w500), | ||
), | ||
GestureDetector( | ||
onTap: () { | ||
setState(() => qty++); | ||
}, | ||
child: Icon( | ||
Icons.add, | ||
color: Colors.grey[400], | ||
size: 18, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
AddToCartButton( | ||
onPressed: () { | ||
setState(() => qty = 0); | ||
}, | ||
), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.