Skip to content

Commit

Permalink
Fix spelling errors and cleanup imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Lloyd Luck committed May 12, 2020
1 parent 394719c commit 626ac99
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 108 deletions.
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_ecommerce_app/src/config/route.dart';
import 'package:flutter_ecommerce_app/src/pages/mainPage.dart';
import 'package:flutter_ecommerce_app/src/pages/product_detail.dart';
import 'package:flutter_ecommerce_app/src/wigets/customRoute.dart';
import 'package:google_fonts/google_fonts.dart';
import 'src/pages/home_page.dart';

import 'src/themes/theme.dart';

void main() => runApp(MyApp());
Expand Down
8 changes: 2 additions & 6 deletions lib/src/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_ecommerce_app/src/model/data.dart';
import 'package:flutter_ecommerce_app/src/model/product.dart';
import 'package:flutter_ecommerce_app/src/themes/light_color.dart';
import 'package:flutter_ecommerce_app/src/themes/theme.dart';
import 'package:flutter_ecommerce_app/src/wigets/BottomNavigationBar/bootom_navigation_bar.dart';
import 'package:flutter_ecommerce_app/src/wigets/prduct_icon.dart';
import 'package:flutter_ecommerce_app/src/wigets/product_card.dart';
import 'package:flutter_ecommerce_app/src/wigets/title_text.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:flutter_ecommerce_app/src/wigets/product_icon.dart';

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
Expand Down Expand Up @@ -42,7 +38,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: ListView(
scrollDirection: Axis.horizontal,
children: AppData.categoryList
.map((category) => ProducIcon(
.map((category) => ProductIcon(
model: category,
))
.toList()),
Expand Down
28 changes: 12 additions & 16 deletions lib/src/pages/mainPage.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_ecommerce_app/src/model/data.dart';
import 'package:flutter_ecommerce_app/src/pages/home_page.dart';
import 'package:flutter_ecommerce_app/src/pages/shoping_cart_page.dart';
import 'package:flutter_ecommerce_app/src/pages/shopping_cart_page.dart';
import 'package:flutter_ecommerce_app/src/themes/light_color.dart';
import 'package:flutter_ecommerce_app/src/themes/theme.dart';
import 'package:flutter_ecommerce_app/src/wigets/BottomNavigationBar/bootom_navigation_bar.dart';
import 'package:flutter_ecommerce_app/src/wigets/prduct_icon.dart';
import 'package:flutter_ecommerce_app/src/wigets/product_card.dart';
import 'package:flutter_ecommerce_app/src/wigets/BottomNavigationBar/bottom_navigation_bar.dart';
import 'package:flutter_ecommerce_app/src/wigets/title_text.dart';

class MainPage extends StatefulWidget {
Expand Down Expand Up @@ -133,17 +130,16 @@ class _MainPageState extends State<MainPage> {
_appBar(),
_title(),
Expanded(
child:AnimatedSwitcher(
duration: Duration(milliseconds: 300),
switchInCurve: Curves.easeInToLinear,
switchOutCurve: Curves.easeOutBack,
child: isHomePageSelected
? MyHomePage()
: Align(
alignment: Alignment.topCenter,
child:ShopingCartPage(),
)
))
child: AnimatedSwitcher(
duration: Duration(milliseconds: 300),
switchInCurve: Curves.easeInToLinear,
switchOutCurve: Curves.easeOutBack,
child: isHomePageSelected
? MyHomePage()
: Align(
alignment: Alignment.topCenter,
child: ShoppingCartPage(),
)))
],
),
),
Expand Down
4 changes: 1 addition & 3 deletions lib/src/pages/product_detail.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_ecommerce_app/src/model/category.dart';
import 'package:flutter_ecommerce_app/src/model/data.dart';
import 'package:flutter_ecommerce_app/src/themes/light_color.dart';
import 'package:flutter_ecommerce_app/src/themes/theme.dart';
import 'package:flutter_ecommerce_app/src/wigets/prduct_icon.dart';
import 'package:flutter_ecommerce_app/src/wigets/title_text.dart';

class ProductDetailPage extends StatefulWidget {
Expand All @@ -23,7 +21,7 @@ class _ProductDetailPageState extends State<ProductDetailPage>
controller =
AnimationController(vsync: this, duration: Duration(milliseconds: 300));
animation = Tween<double>(begin: 0, end: 1).animate(
CurvedAnimation(parent: controller, curve: Curves.easeInToLinear));
CurvedAnimation(parent: controller, curve: Curves.easeInToLinear));
controller.forward();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import 'package:flutter_ecommerce_app/src/themes/light_color.dart';
import 'package:flutter_ecommerce_app/src/themes/theme.dart';
import 'package:flutter_ecommerce_app/src/wigets/title_text.dart';

class ShopingCartPage extends StatelessWidget {
const ShopingCartPage({Key key}) : super(key: key);
class ShoppingCartPage extends StatelessWidget {
const ShoppingCartPage({Key key}) : super(key: key);

Widget _cartItems() {
return Column(children: AppData.cartList.map((x) => _item(x)).toList());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'dart:math' as math;
class CenteredElasticOutCurve extends Curve {

class CenteredElasticOutCurve extends Curve {
final double period;

CenteredElasticOutCurve([this.period = 0.4]);

@override
double transform(double x) {
// Bascially just a slightly modified version of the built in ElasticOutCurve
return math.pow(2.0, -10.0 * x) * math.sin(x * 2.0 * math.pi / period) + 0.5;
return math.pow(2.0, -10.0 * x) * math.sin(x * 2.0 * math.pi / period) +
0.5;
}
}

class CenteredElasticInCurve extends Curve {

final double period;

CenteredElasticInCurve([this.period = 0.4]);

@override
double transform(double x) {
// Bascially just a slightly modified version of the built in ElasticInCurve
return -math.pow(2.0, 10.0 * (x - 1.0)) * math.sin((x - 1.0) * 2.0 * math.pi / period) + 0.5;
return -math.pow(2.0, 10.0 * (x - 1.0)) *
math.sin((x - 1.0) * 2.0 * math.pi / period) +
0.5;
}
}

Expand All @@ -41,5 +43,4 @@ class LinearPointCurve extends Curve {
final upperOffset = 1.0 - upperScale;
return x < pIn ? x * lowerScale : x * upperScale + upperOffset;
}

}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_ecommerce_app/src/model/data.dart';
import 'package:flutter_ecommerce_app/src/model/product.dart';
import 'package:flutter_ecommerce_app/src/themes/light_color.dart';
import 'package:flutter_ecommerce_app/src/themes/theme.dart';
import 'package:flutter_ecommerce_app/src/wigets/title_text.dart';

class ProductCard extends StatefulWidget {
Expand All @@ -28,15 +26,15 @@ class _ProductCardState extends State<ProductCard> {
Navigator.of(context).pushNamed('/detail');
setState(() {
// model.isSelected = !model.isSelected;
// AppData.productList.forEach((x) {
// if (x.id == model.id && x.name == model.name) {
// return;
// }
// x.isSelected = false;
// });
// var m = AppData.productList
// .firstWhere((x) => x.id == model.id && x.name == model.name);
// m.isSelected = !m.isSelected;
// AppData.productList.forEach((x) {
// if (x.id == model.id && x.name == model.name) {
// return;
// }
// x.isSelected = false;
// });
// var m = AppData.productList
// .firstWhere((x) => x.id == model.id && x.name == model.name);
// m.isSelected = !m.isSelected;
});
},
child: Container(
Expand All @@ -54,16 +52,19 @@ class _ProductCardState extends State<ProductCard> {
alignment: Alignment.center,
children: <Widget>[
Positioned(
left: 0,
top: 0,
child: IconButton(
icon: Icon(model.isliked ? Icons.favorite : Icons.favorite_border, color: model.isliked ? LightColor.red : LightColor.iconColor,),
onPressed: (){
setState(() {
model.isliked = !model.isliked ;
});
})
),
left: 0,
top: 0,
child: IconButton(
icon: Icon(
model.isliked ? Icons.favorite : Icons.favorite_border,
color:
model.isliked ? LightColor.red : LightColor.iconColor,
),
onPressed: () {
setState(() {
model.isliked = !model.isliked;
});
})),
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
Expand Down
55 changes: 55 additions & 0 deletions lib/src/widgets/product_icon.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import 'package:flutter/material.dart';
import 'package:flutter_ecommerce_app/src/model/category.dart';
import 'package:flutter_ecommerce_app/src/themes/light_color.dart';
import 'package:flutter_ecommerce_app/src/themes/theme.dart';
import 'package:flutter_ecommerce_app/src/wigets/title_text.dart';

class ProductIcon extends StatelessWidget {
// final String imagePath;
// final String text;
// final bool isSelected;
final Category model;
ProductIcon({Key key, this.model}) : super(key: key);

Widget build(BuildContext context) {
return model.id == null
? Container(
width: 5,
)
: Container(
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 15),
padding: AppTheme.hPadding,
alignment: Alignment.center,
height: 40,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
color:
model.isSelected ? LightColor.background : Colors.transparent,
border: Border.all(
color: model.isSelected ? LightColor.orange : LightColor.grey,
width: model.isSelected ? 2 : 1),
boxShadow: <BoxShadow>[
BoxShadow(
color: model.isSelected ? Color(0xfffbf2ef) : Colors.white,
blurRadius: 10,
spreadRadius: 5,
offset: Offset(5, 5)),
],
),
child: Row(
children: <Widget>[
model.image != null ? Image.asset(model.image) : SizedBox(),
model.name == null
? Container()
: Container(
child: TitleText(
text: model.name,
fontWeight: FontWeight.w700,
fontSize: 15,
),
)
],
),
);
}
}
File renamed without changes.
52 changes: 0 additions & 52 deletions lib/src/wigets/prduct_icon.dart

This file was deleted.

0 comments on commit 626ac99

Please sign in to comment.