Skip to content

Commit

Permalink
3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya committed Sep 24, 2021
1 parent f227a0b commit 02222c0
Show file tree
Hide file tree
Showing 10 changed files with 342 additions and 310 deletions.
16 changes: 13 additions & 3 deletions lib/loading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@ class Loading extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Container(
color: const Color(0xFF1a191c),
child: Center(child: Lottie.asset("assets/lottie/loading.json")),
return Scaffold(
backgroundColor: const Color(0xFF1a191c),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Lottie.asset("assets/lottie/loading.json"),
const Text(
'Loading',
style: TextStyle(
color: Color(0xFFF4F5FC), letterSpacing: 2, fontSize: 32),
),
],
),
);
}
}
11 changes: 7 additions & 4 deletions lib/screens/cart_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ class _CartPageState extends State<CartPage> {
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(
color: Colors.black,
));
return const Padding(
padding: EdgeInsets.all(32),
child: Center(
child: CircularProgressIndicator(
color: Colors.black,
)),
);
}
if (snapshot.hasError) {
return Center(child: Text("${snapshot.error}"));
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class _HomeState extends State<Home> {
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
padding: const EdgeInsets.fromLTRB(20, 20, 20, 4),
child: CustomScrollView(
slivers: [
SliverAppBar(
Expand Down Expand Up @@ -53,7 +53,7 @@ class _HomeState extends State<Home> {
),
),
expandedHeight: 120,
pinned: true,
floating: true,
flexibleSpace: FlexibleSpaceBar(
title: (showFavorites)
? const Text("Favorites")
Expand Down
174 changes: 90 additions & 84 deletions lib/screens/product_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,36 @@ class ProductPage extends StatefulWidget {
class _ProductPageState extends State<ProductPage>
with SingleTickerProviderStateMixin {
late final AnimationController _controller;
late Animation<Offset> _animation;
late Animation<Offset> _slideUpAnimation;
late Animation<double> _fadeAnimation;
final _firestoreInstance = FirestoreService();
int selectedSize = 0;
String selectedColor = "";

@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(milliseconds: 1200),
vsync: this,
)..forward();
_slideUpAnimation = Tween<Offset>(
begin: const Offset(0, 1),
end: Offset.zero,
).animate(CurvedAnimation(
parent: _controller,
curve: const Interval(0.4, 0.8, curve: Curves.easeOutSine)));
_fadeAnimation = Tween<double>(begin: 0, end: 1).animate(CurvedAnimation(
parent: _controller,
curve: const Interval(0.8, 1, curve: Curves.easeIn)));
}

@override
void dispose() {
_controller.dispose();
super.dispose();
}

Future showCartItems() async {
List<String> imageUrls = await _firestoreInstance.getLastTwoCartImages();
ScaffoldMessenger.of(context).clearSnackBars();
Expand Down Expand Up @@ -70,28 +95,6 @@ class _ProductPageState extends State<ProductPage>
));
}

@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(milliseconds: 700),
vsync: this,
)..forward();
_animation = Tween<Offset>(
begin: const Offset(0, 1),
end: const Offset(0, 0),
).animate(CurvedAnimation(
parent: _controller,
curve: Curves.easeInCubic,
));
}

@override
void dispose() {
_controller.dispose();
super.dispose();
}

void addToCart() async {
await _firestoreInstance.addToCart(widget.productId,
size: selectedSize, color: selectedColor);
Expand Down Expand Up @@ -119,8 +122,7 @@ class _ProductPageState extends State<ProductPage>
Expanded(
flex: 3,
child: SlideTransition(
position: _animation,
transformHitTests: true,
position: _slideUpAnimation,
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(20),
Expand All @@ -130,71 +132,75 @@ class _ProductPageState extends State<ProductPage>
topLeft: Radius.circular(50),
topRight: Radius.circular(50)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.product.brand,
style: const TextStyle(
fontSize: 24, fontWeight: FontWeight.w600),
),
Text(
widget.product.name,
style: TextStyle(
color: ThemeData.light().hintColor, fontSize: 16),
),
],
),
SizeRow(
sizes: widget.product.sizes,
onSelected: (selected) {
selectedSize = widget.product.sizes![selected];
}),
ColorRow(
colors: widget.product.colors,
onSelected: (selected) {
selectedColor = widget.product.colors![selected];
}),
Container(
height: 70,
width: double.infinity,
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: const Color(0xFFF68A0A),
borderRadius: BorderRadius.circular(35)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
child: FadeTransition(
opacity: _fadeAnimation,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"\$${widget.product.price}",
widget.product.brand,
style: const TextStyle(
fontSize: 18,
color: Color(0xFFF4F5FC),
fontWeight: FontWeight.w600),
fontSize: 24, fontWeight: FontWeight.w600),
),
Text(
widget.product.name,
style: TextStyle(
color: ThemeData.light().hintColor,
fontSize: 16),
),
ElevatedButton.icon(
icon: const Icon(Icons.shopping_cart_outlined,
color: Color(0xFF1A191C)),
onPressed: addToCart,
label: const Text("Add to Cart",
style: TextStyle(
fontSize: 16,
color: Color(0xFF1A191C),
fontWeight: FontWeight.bold,
)),
style: ElevatedButton.styleFrom(
primary: const Color(0xFFF4F5FC),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20))),
)
],
),
),
],
SizeRow(
sizes: widget.product.sizes,
onSelected: (selected) {
selectedSize = widget.product.sizes![selected];
}),
ColorRow(
colors: widget.product.colors,
onSelected: (selected) {
selectedColor = widget.product.colors![selected];
}),
Container(
height: 70,
width: double.infinity,
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: const Color(0xFFF68A0A),
borderRadius: BorderRadius.circular(35)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"\$${widget.product.price}",
style: const TextStyle(
fontSize: 18,
color: Color(0xFFF4F5FC),
fontWeight: FontWeight.w600),
),
ElevatedButton.icon(
icon: const Icon(Icons.shopping_cart_outlined,
color: Color(0xFF1A191C)),
onPressed: addToCart,
label: const Text("Add to Cart",
style: TextStyle(
fontSize: 16,
color: Color(0xFF1A191C),
fontWeight: FontWeight.bold,
)),
style: ElevatedButton.styleFrom(
primary: const Color(0xFFF4F5FC),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20))),
)
],
),
),
],
),
),
),
),
Expand Down
51 changes: 27 additions & 24 deletions lib/screens/profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,24 @@ class _ProfilePageState extends State<ProfilePage> {
void _signOutDialog() {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Sign Out'),
content: const Text("Do you really want to sign out?"),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("Cancel")),
TextButton(
onPressed: () async {
Navigator.pop(context);
await AuthenticationService().signOut();
Navigator.of(context).pop();
},
child: const Text("Yes"))
],
);
});
builder: (context) => AlertDialog(
title: const Text('Sign Out'),
content: const Text("Do you really want to sign out?"),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("Cancel")),
TextButton(
onPressed: () async {
Navigator.pop(context);
await AuthenticationService().signOut();
Navigator.of(context).pop();
},
child: const Text("Yes"))
],
));
}

@override
Expand Down Expand Up @@ -122,10 +120,15 @@ class _ProfilePageState extends State<ProfilePage> {
}

PopupMenuItem<MenuItem> buildItem(MenuItem item) => PopupMenuItem<MenuItem>(
value: item,
child: Row(
children: [Icon(item.icon), const SizedBox(width: 12), Text(item.text)],
));
value: item,
child: Row(
children: [
Icon(item.icon),
const SizedBox(width: 12),
Text(item.text)
],
),
);
void onMenuItemSelected(BuildContext context, MenuItem item) {
switch (item) {
case MenuItems.itemChangePfp:
Expand Down
Loading

0 comments on commit 02222c0

Please sign in to comment.