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
38 changes: 38 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Flutter: Attach to Device",
"type": "dart",
"request": "attach"
},
{
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"name": "Launch Extension",
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "npm",
"request": "launch",
"type": "extensionHost"
},
{
"name": "Mohammed-Ali--book_store_app",
"request": "launch",
"type": "dart"
},
{
"name": "Mohammed-Ali--book_store_app (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "Mohammed-Ali--book_store_app (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release"
}
]
}
Binary file added images/book1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/user.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions lib/add_book/addBook_body.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import 'package:book_store_app/add_book/form.dart';

class AddBook_body extends StatelessWidget {
const AddBook_body({
Key? key,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 40),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 28,
),
Text(
'Add Book',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.w600),
),
BookForm(),
],
),
),
);
}
}
33 changes: 33 additions & 0 deletions lib/add_book/book_field.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';

class BookField extends StatelessWidget {
const BookField(
{Key? key, required this.txt, required this.ctrler, this.isDes})
: super(key: key);
final String txt;
final TextEditingController ctrler;
final bool? isDes;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.only(left: 20),
margin: const EdgeInsets.only(bottom: 15.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(32),
),
child: TextField(
textInputAction:
(isDes == null ? TextInputAction.next : TextInputAction.newline),
controller: ctrler,
maxLines: isDes == null ? 1 : 4,
decoration: InputDecoration(
hintStyle: TextStyle(fontSize: 17),
hintText: txt,
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(vertical: 20),
),
),
);
}
}
58 changes: 58 additions & 0 deletions lib/add_book/form.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:book_store_app/add_book/book_field.dart';
import 'package:book_store_app/add_book/main_add.dart';
import 'package:book_store_app/home_page/book_model.dart';
import 'package:get/get.dart';

class BookForm extends StatefulWidget {
const BookForm({Key? key}) : super(key: key);

@override
State<BookForm> createState() => _BookFormState();
}

class _BookFormState extends State<BookForm> {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
reverse: true,
child: Column(
children: [
SizedBox(
height: 56,
),
BookField(txt: 'Book Name', ctrler: bookNameC),
BookField(txt: 'Author Name', ctrler: authorC),
BookField(txt: 'Price', ctrler: pricC),
BookField(txt: 'Image link', ctrler: imgPathC),
BookField(
txt: 'Description',
ctrler: descripC,
isDes: true,
),
ElevatedButton(
onPressed: () {
Book.add(bookNameC.text, authorC.text, pricC.text,
imgPathC.text, descripC.text, false.obs);
bookNameC.text=''; authorC.text=''; pricC.text='';
imgPathC.text=''; descripC.text='';
setState(() {
});
},
style: ElevatedButton.styleFrom(
minimumSize: Size(double.infinity, 55),
//padding: EdgeInsets.symmetric(horizontal: 24,vertical: 8),
primary: Colors.black,
elevation: 0,
),
child: const Text(
'Add',
style: TextStyle(color: Colors.white),
)),
SizedBox(height: 90,),
],
),
);
;
}
}
50 changes: 50 additions & 0 deletions lib/add_book/main_add.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'package:book_store_app/home_page/menu_barr.dart';
import 'addBook_body.dart';
class AddBook extends StatefulWidget {
const AddBook({Key? key}) : super(key: key);
@override
State<AddBook> createState() => _Add_bookState();
}
TextEditingController bookNameC=TextEditingController();
TextEditingController authorC=TextEditingController();
TextEditingController pricC=TextEditingController();
TextEditingController imgPathC=TextEditingController();
TextEditingController descripC=TextEditingController();
class _Add_bookState extends State<AddBook> {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(scaffoldBackgroundColor: Colors.grey.shade100,
primarySwatch: Colors.grey),
home: Scaffold(
appBar: MyAppBar(context),
body: Stack(
children: const [
AddBook_body(),
MenuBar(c3: Colors.black,flag: 'add',)
],
),
)
);
}

}

AppBar MyAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.grey.shade100,
elevation: 0,
leading: TextButton(onPressed: () {
Navigator.pop(context);
},
child:const Icon(Icons.arrow_back,color: Colors.black,) ,),
actions: const [
Padding(padding: EdgeInsets.only(right: 20),
child: Icon(Icons.more_vert_rounded,color: Colors.black,size: 28,),
)

],

);
}
128 changes: 128 additions & 0 deletions lib/book_page/the_book.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import 'package:book_store_app/home_page/book_model.dart';
import 'package:book_store_app/home_page/card_book.dart';
import 'package:flutter/material.dart';
import 'package:book_store_app/add_book/main_add.dart';
import 'package:get/get.dart';
class BookPage extends StatefulWidget {
//final String title,auther,price,desc,imgPath;
final Book book;
const BookPage({Key? key,required this.book}) : super(key: key);
@override
State<BookPage> createState() => _BookPageState();
}

class _BookPageState extends State<BookPage> {

@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(scaffoldBackgroundColor: Colors.grey.shade100,
primarySwatch: Colors.grey),
home: Scaffold(
appBar: MyAppBar(context),
body: Padding(
padding: EdgeInsets.symmetric(horizontal: 40),
child: Center(
child: Column(
//mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SizedBox(height: 12,),
ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(8),bottomRight: Radius.circular(8)),
child: Image(image: NetworkImage(widget.book.imgPath),
width: 210,
)
),
const SizedBox(height: 12,),
Text(widget.book.title.value,style: TextStyle(
fontSize: 24, fontWeight: FontWeight.w600
),),
Text(widget.book.author,style: TextStyle(
fontSize: 14,color: Colors.black54
),),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Rate(),Rate(),Rate(),Rate(),Rate(),
Text('4.0/5.0')
],
),
Padding(
padding: EdgeInsets.all(8.0),
child: Text(widget.book.desc,style: TextStyle(
fontSize: 14,color: Colors.black54,height: 1.6
),),
),
SizedBox(height: 20,),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
BookDetBtn(txt: 'Preview',ic: Icons.preview),
SizedBox(width: 12,),
BookDetBtn(txt: 'Reviews',ic: Icons.reviews_outlined),
],
),
SizedBox(height: 20,),


ElevatedButton(onPressed: (){
if(widget.book.inCart.value==false)
{
widget.book.addToCart();
}
else
{
widget.book.removeFromCart();
}
},
style: ElevatedButton.styleFrom(
minimumSize: Size(double.infinity,70),
padding: EdgeInsets.symmetric(horizontal: 24,vertical: 12),
primary: Colors.black,
elevation: 0,
),
child: Obx(() {
return Text(widget.book.inCart.value?
('Remove From the cart'.obs).value
:('Buy Now for \$${widget.book.price}'.obs).value,style: TextStyle(color: Colors.white),);
}
),
)
],
),
),
),
)
);
}

}

class BookDetBtn extends StatelessWidget {
final String txt;
final IconData ic;
const BookDetBtn({
Key? key, required this.txt, required this.ic,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return Expanded(
child: ElevatedButton(onPressed: (){},
style: ElevatedButton.styleFrom(
//padding: EdgeInsets.symmetric(horizontal: 24,vertical: 12),
minimumSize: Size(150, 50),
primary: Colors.white,
elevation: 0,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Icon(ic),
Text(txt),
],
),
),
);
}
}
31 changes: 31 additions & 0 deletions lib/cart/cart.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

import 'package:flutter/material.dart';
import 'package:book_store_app/home_page/menu_barr.dart';
import 'package:book_store_app/add_book/main_add.dart';
import 'cart_body.dart';
class Cart extends StatefulWidget {
const Cart({Key? key}) : super(key: key);
@override
State<Cart> createState() => _CartState();
}

class _CartState extends State<Cart> {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(scaffoldBackgroundColor: Colors.grey.shade100,
primarySwatch: Colors.grey),
home: Scaffold(
appBar: MyAppBar(context),
body: Stack(
children: const [
CartBody(txtHeader: 'Cart'),
MenuBar(c2: Colors.black, flag: 'cart',)
],
),
)
);
}

}

Loading