Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions e-commerce/config/route.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_ecommerce_app/src/pages/mainPage.dart';

class Routes {
static Map<String, WidgetBuilder> getRoute() {
return <String, WidgetBuilder>{
'/': (_) => MainPage(),
// '/detail': (_) => ProductDetailPage()
};
}
}
1 change: 1 addition & 0 deletions e-commerce/demo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

141 changes: 141 additions & 0 deletions e-commerce/home_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.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/widgets/product_card.dart';
import 'package:flutter_ecommerce_app/src/widgets/product_icon.dart';
import 'package:flutter_ecommerce_app/src/widgets/extentions.dart';

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);

final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
Widget _icon(IconData icon, {Color color = LightColor.iconColor}) {
return Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(13)),
color: Theme.of(context).backgroundColor,
boxShadow: AppTheme.shadow),
child: Icon(
icon,
color: color,
),
).ripple(() {}, borderRadius: BorderRadius.all(Radius.circular(13)));
}

Widget _categoryWidget() {
return Container(
margin: EdgeInsets.symmetric(vertical: 10),
width: AppTheme.fullWidth(context),
height: 80,
child: ListView(
scrollDirection: Axis.horizontal,
children: AppData.categoryList
.map(
(category) => ProductIcon(
model: category,
onSelected: (model) {
setState(() {
AppData.categoryList.forEach((item) {
item.isSelected = false;
});
model.isSelected = true;
});
},
),
)
.toList(),
),
);
}

Widget _productWidget() {
return Container(
margin: EdgeInsets.symmetric(vertical: 10),
width: AppTheme.fullWidth(context),
height: AppTheme.fullWidth(context) * .7,
child: GridView(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
childAspectRatio: 4 / 3,
mainAxisSpacing: 30,
crossAxisSpacing: 20),
padding: EdgeInsets.only(left: 20),
scrollDirection: Axis.horizontal,
children: AppData.productList
.map(
(product) => ProductCard(
product: product,
onSelected: (model) {
setState(() {
AppData.productList.forEach((item) {
item.isSelected = false;
});
model.isSelected = true;
});
},
),
)
.toList(),
),
);
}

Widget _search() {
return Container(
margin: AppTheme.padding,
child: Row(
children: <Widget>[
Expanded(
child: Container(
height: 40,
alignment: Alignment.center,
decoration: BoxDecoration(
color: LightColor.lightGrey.withAlpha(100),
borderRadius: BorderRadius.all(Radius.circular(10))),
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Search Products",
hintStyle: TextStyle(fontSize: 12),
contentPadding:
EdgeInsets.only(left: 10, right: 10, bottom: 0, top: 5),
prefixIcon: Icon(Icons.search, color: Colors.black54)),
),
),
),
SizedBox(width: 20),
_icon(Icons.filter_list, color: Colors.black54)
],
),
);
}

@override
Widget build(BuildContext context) {
return Container(
height: MediaQuery.of(context).size.height - 210,
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
dragStartBehavior: DragStartBehavior.down,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
_search(),
_categoryWidget(),
_productWidget(),
],
),
),
);
}
}
145 changes: 145 additions & 0 deletions e-commerce/login_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import 'package:flutter/material.dart';

void main() => runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
)
);

class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Container(
child: Column(
children: <Widget>[
Container(
height: 400,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/background.png'),
fit: BoxFit.fill
)
),
child: Stack(
children: <Widget>[
Positioned(
left: 30,
width: 80,
height: 200,
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/light-1.png')
)
),
),
),
Positioned(
left: 140,
width: 80,
height: 150,
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/light-2.png')
)
),
)),
Positioned(
right: 40,
top: 40,
width: 80,
height: 150,
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/clock.png')
)
),
)),
Positioned(
child: Container(
margin: EdgeInsets.only(top: 50),
child: Center(
child: Text("Login", style: TextStyle(color: Colors.white, fontSize: 40, fontWeight: FontWeight.bold),),
),
)),
],
),
),
Padding(
padding: EdgeInsets.all(30.0),
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Color.fromRGBO(143, 148, 251, .2),
blurRadius: 20.0,
offset: Offset(0, 10)
)
]
),
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.grey[100]))
),
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Email or Phone number",
hintStyle: TextStyle(color: Colors.grey[400])
),
),
),
Container(
padding: EdgeInsets.all(8.0),
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Password",
hintStyle: TextStyle(color: Colors.grey[400])
),
),
)
],
),
),
SizedBox(height: 30,),
Container(
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
gradient: LinearGradient(
colors: [
Color.fromRGBO(143, 148, 251, 1),
Color.fromRGBO(143, 148, 251, .6),
]
)
),
child: Center(
child: Text("Login", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),),
),
),
SizedBox(height: 70,),
],
),
)
],
),
),
)
);
}
}
Loading