diff --git a/images/one.jfif b/images/one.jfif new file mode 100644 index 0000000..91aaddc Binary files /dev/null and b/images/one.jfif differ diff --git a/lib/main.dart b/lib/main.dart index bcc58f7..43f3ac6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ -import 'package:flutter/material.dart'; +import 'package:book_store_app/modules/home/homeScreen.dart'; +import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } @@ -10,11 +11,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return const MaterialApp( - home: Scaffold( - body: Center( - child: Text("Book Store App"), - ), - ), + home: HomeScreen(), ); } } diff --git a/lib/model/model.dart b/lib/model/model.dart new file mode 100644 index 0000000..0d2a84c --- /dev/null +++ b/lib/model/model.dart @@ -0,0 +1,26 @@ +import 'package:get/get.dart'; +class Book { + final String name; + final String Author_name; + final String price; + final String link; + final String Descrip; + Book(this.name, this.Author_name, this.price, this.link, this.Descrip); + static RxList one = [].obs; + add() { + one.add(this); + } +} + +class BookUser { + final String name; + final String Author_name; + final String price; + final String link; + final String Descrip; + BookUser(this.name, this.Author_name, this.price, this.link, this.Descrip); + static List two = []; + add() { + two.add(this); + } +} diff --git a/lib/modules/aboute/abouteScreen.dart b/lib/modules/aboute/abouteScreen.dart new file mode 100644 index 0000000..612e75a --- /dev/null +++ b/lib/modules/aboute/abouteScreen.dart @@ -0,0 +1,124 @@ +import 'package:book_store_app/modules/add/addbook.dart'; +import 'package:book_store_app/modules/cart/cart.dart'; +import 'package:book_store_app/shared/components/components.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/src/foundation/key.dart'; +import 'package:flutter/src/widgets/framework.dart'; +import 'package:book_store_app/modules/home/homeScreen.dart'; +import 'package:book_store_app/model/model.dart'; + +class AboutBook extends StatelessWidget { + const AboutBook({Key? key, required int this.x}) : super(key: key); + final int x; + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color.fromARGB(255, 236, 229, 229), + appBar: AppBar( + backgroundColor: Color.fromARGB(255, 236, 229, 229), + titleSpacing: 20, + elevation: 0, + title: Row( + children: [ + GestureDetector( + onTap: () { + Navigator.pushReplacement(context, + MaterialPageRoute(builder: (context) { + return HomeScreen(); + })); + }, + child: Icon( + Icons.arrow_back_ios, + color: Colors.black, + ), + ) + ], + ), + actions: [ + Icon( + Icons.more_vert, + color: Colors.black, + ) + ], + ), + body: Container( + padding: EdgeInsets.all(20), + width: double.infinity, + child: Column(crossAxisAlignment: CrossAxisAlignment.center, children: [ + Image.network( + "${Book.one[x].link}", + width: 300, + height: 300, + ), + SizedBox( + height: 20, + ), + Text( + Book.one[x].name, + style: TextStyle( + color: Colors.black, fontSize: 25, fontWeight: FontWeight.bold), + ), + SizedBox( + height: 10, + ), + Text(Book.one[x].Author_name, + style: TextStyle( + color: Color.fromRGBO(104, 104, 104, 1), + fontSize: 15, + )), + SizedBox( + height: 10, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + buildthestar(), + SizedBox( + width: 10, + ), + ], + ), + Container( + height: 100, + padding: EdgeInsets.all(10), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: SingleChildScrollView( + child: Text( + Book.one[x].Descrip, + maxLines: 100, + ), + )) + ]), + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + buildnormal(ic: Icons.list), + SizedBox( + width: 10, + ), + buildnormal(ic: Icons.chat, text: "Reviews"), + ], + ), + SizedBox(height: 30,), + buildbotton( + text: "Buy Now for \$ ${Book.one[x].price}", + onPressed: () { + BookUser(Book.one[x].name, Book.one[x].Author_name, + Book.one[x].price, Book.one[x].link, Book.one[x].Descrip).add(); + Navigator.pushReplacement(context, + MaterialPageRoute(builder: (context) { + screen = 2 ; + return MyCart(); + })); + }) + ]), + ), + ); + } +} diff --git a/lib/modules/add/addbook.dart b/lib/modules/add/addbook.dart new file mode 100644 index 0000000..2fa3d2e --- /dev/null +++ b/lib/modules/add/addbook.dart @@ -0,0 +1,184 @@ +import 'dart:io'; + +import 'package:book_store_app/modules/home/homeScreen.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/src/foundation/key.dart'; +import 'package:flutter/src/widgets/framework.dart'; +import 'package:book_store_app/shared/components/components.dart'; +import "package:book_store_app/model/model.dart"; + +class AddBook extends StatefulWidget { + const AddBook({Key? key}) : super(key: key); + + @override + State createState() => _AddBookState(); +} + +class _AddBookState extends State { + @override + var nameBook = TextEditingController(); + var nameAuthor = TextEditingController(); + var price = TextEditingController(); + var image = TextEditingController(); + var description = TextEditingController(); + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color.fromARGB(255, 236, 229, 229), + appBar: AppBar( + backgroundColor: Color.fromARGB(255, 236, 229, 229), + titleSpacing: 20, + elevation: 0, + title: Row( + children: [ + GestureDetector( + onTap: () { + Navigator.pushReplacement(context, + MaterialPageRoute(builder: (context) { + return HomeScreen(); + })); + }, + child: Icon( + Icons.arrow_back_ios, + color: Colors.black, + ), + ) + ], + ), + actions: [ + Icon( + Icons.more_vert, + color: Colors.black, + ) + ], + ), + body: Container( + padding: EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Add Book", + style: TextStyle( + color: Colors.black, + fontSize: 30, + fontWeight: FontWeight.bold), + ), + SizedBox( + height: 30, + ), + //Form for the information + Expanded( + child: SingleChildScrollView( + child: Container( + margin: EdgeInsets.all(20), + padding: EdgeInsets.all(10), + child: Column( + children: [ + // name book + Container( + padding: EdgeInsets.only( + left: 20, top: 5, right: 5, bottom: 5), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10)), + child: TextFormField( + controller: nameBook, + decoration: InputDecoration( + hintText: "Book Name ", + border: InputBorder.none, + ), + ), + ), + SizedBox( + height: 20, + ), + // Author name + Container( + padding: EdgeInsets.only( + left: 20, top: 5, right: 5, bottom: 5), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10)), + child: TextFormField( + controller: nameAuthor, + decoration: InputDecoration( + hintText: "Author Name ", + border: InputBorder.none, + ), + ), + ), + SizedBox( + height: 20, + ), + //price + Container( + padding: EdgeInsets.only( + left: 20, top: 5, right: 5, bottom: 5), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10)), + child: TextFormField( + controller: price, + decoration: InputDecoration( + hintText: "Price ", + border: InputBorder.none, + ), + ), + ), + SizedBox( + height: 20, + ), + //Image link + Container( + padding: EdgeInsets.only( + left: 20, top: 5, right: 5, bottom: 5), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10)), + child: TextFormField( + controller: image, + decoration: InputDecoration( + hintText: "Image Link ", + border: InputBorder.none, + ), + ), + ), + SizedBox( + height: 20, + ), + //Description + Container( + padding: EdgeInsets.only( + left: 20, top: 5, right: 5, bottom: 5), + height: 200, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10)), + child: TextFormField( + controller: description, + decoration: InputDecoration( + hintText: "Description ", + border: InputBorder.none, + ), + ), + ), + buildbotton(onPressed: () { + Book(nameBook.text, nameAuthor.text, price.text, + image.text, description.text) + .add(); + Navigator.pushReplacement(context, + MaterialPageRoute(builder: (context) { + screen = 1 ; + return HomeScreen(); + })); + }), + ], + ), + ), + )) + ], + ), + ), + ); + } +} diff --git a/lib/modules/cart/cart.dart b/lib/modules/cart/cart.dart new file mode 100644 index 0000000..3e367b7 --- /dev/null +++ b/lib/modules/cart/cart.dart @@ -0,0 +1,146 @@ +import 'package:book_store_app/model/model.dart'; +import 'package:book_store_app/modules/home/homeScreen.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/src/foundation/key.dart'; +import 'package:flutter/src/widgets/framework.dart'; +import 'package:book_store_app/modules/add/addbook.dart'; + +import 'package:book_store_app/shared/components/components.dart'; + +class MyCart extends StatelessWidget { + const MyCart({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color.fromARGB(255, 236, 229, 229), + appBar: AppBar( + backgroundColor: Color.fromARGB(255, 236, 229, 229), + titleSpacing: 20, + elevation: 0, + title: Row( + children: [ + GestureDetector( + onTap: () { + Navigator.pushReplacement(context, + MaterialPageRoute(builder: (context) { + return HomeScreen(); + })); + }, + child: Icon( + Icons.arrow_back_ios, + color: Colors.black, + ), + ) + ], + ), + actions: [ + Icon( + Icons.more_vert, + color: Colors.black, + ) + ], + ), + body: Container( + padding: EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Cart", + style: TextStyle( + color: Colors.black, + fontSize: 30, + fontWeight: FontWeight.bold), + ), + SizedBox( + height: 30, + ), + Expanded( + child: ListView( + children: BookUser.two + .map( + (e) => builsinglepage(e), + ) + .toList()), + ), + buildbcenter(onPressed: () { + Navigator.pushReplacement(context, + MaterialPageRoute(builder: (context) { + screen = 1; + return HomeScreen(); + })); + }, onPressed2: () { + Navigator.pushReplacement(context, + MaterialPageRoute(builder: (context) { + + screen = 2; + return MyCart(); + })); + }, onPressed3: () { + Navigator.pushReplacement(context, + MaterialPageRoute(builder: (context) { + + screen = 3; + return AddBook(); + })); + }), + ], + ), + ), + ); + } + + Widget builsinglepage(BookUser abd) { + return Container( + margin: EdgeInsets.only(top: 20), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + child: Image.network( + "${abd.link}", + height: 100, + width: 90, + fit: BoxFit.cover, + ), + ), + SizedBox( + width: 20, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + abd.name, + style: TextStyle( + color: Colors.black, + fontSize: 25, + fontWeight: FontWeight.bold), + ), + Text(abd.Author_name, + style: TextStyle( + color: Color.fromRGBO(104, 104, 104, 1), + fontSize: 15, + )), + SizedBox( + height: 5, + ), + Text( + '\$ ${abd.price}', + style: TextStyle( + color: Colors.black, + fontSize: 15, + fontWeight: FontWeight.bold), + ), + SizedBox( + height: 5, + ), + buildthestar() + ], + ), + ], + ), + ); + } +} diff --git a/lib/modules/home/homeScreen.dart b/lib/modules/home/homeScreen.dart new file mode 100644 index 0000000..b8faa0b --- /dev/null +++ b/lib/modules/home/homeScreen.dart @@ -0,0 +1,213 @@ +import 'package:book_store_app/modules/add/addbook.dart'; +import 'package:book_store_app/modules/cart/cart.dart'; +import 'package:book_store_app/shared/components/components.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/src/foundation/key.dart'; +import 'package:flutter/src/widgets/framework.dart'; +import 'package:book_store_app/model/model.dart'; +import 'package:book_store_app/modules/aboute/abouteScreen.dart'; +import 'package:get/get.dart'; + +class HomeScreen extends StatefulWidget { + const HomeScreen({Key? key}) : super(key: key); + + @override + State createState() => _HomeScreenState(); +} + +class _HomeScreenState extends State { + final bool x = true; + var search = TextEditingController(); + RxString query = ''.obs; + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color.fromARGB(255, 236, 229, 229), + appBar: AppBar( + backgroundColor: Color.fromARGB(255, 236, 229, 229), + titleSpacing: 20, + title: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Image( + height: 40, + image: AssetImage( + 'images/one.jfif', + ), + // fit: BoxFit.contain, + ), + ), + SizedBox( + width: 10, + ), + Text( + "hi , ali!", + style: TextStyle(color: Colors.black), + ) + ], + ), + actions: [ + Icon( + Icons.more_vert, + color: Colors.black, + ) + ], + elevation: 0, + ), + body: Column( + children: [ + Expanded( + child: Container( + padding: EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + //box Search + Container( + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white, + ), + padding: EdgeInsets.all(5), + child: Row( + children: [ + Expanded( + child: TextFormField( + controller: search, + decoration: InputDecoration( + hintText: "search", + suffixIcon: Icon( + Icons.search, + color: Colors.black, + ), + border: InputBorder.none, + ), + onChanged: (x) { + query.value = x; + + }, + + ), + ), + ], + ), + ), + SizedBox( + height: 20, + ), + Text( + "Book List", + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 30), + ), + SizedBox( + height: 20, + ), + // // single book + + Expanded( + child: Obx(() { + return ListView( + children: Book.one + .where( + (element) => element.name.contains(query)) + .map( + (e) => GestureDetector( + onTap: () { + Navigator.pushReplacement(context, + MaterialPageRoute( + builder: (context) { + return AboutBook( + x: Book.one.indexOf(e), + ); + })); + }, + child: builsinglepage(e)), + ) + .toList()); + }) + ), + ]), + ), + ), + buildbcenter(onPressed: () { + Navigator.pushReplacement(context, + MaterialPageRoute(builder: (context) { + screen = 1; + return HomeScreen(); + })); + }, onPressed2: () { + Navigator.pushReplacement(context, + MaterialPageRoute(builder: (context) { + screen = 2; + return MyCart(); + })); + }, onPressed3: () { + Navigator.pushReplacement(context, + MaterialPageRoute(builder: (context) { + screen = 3; + return AddBook(); + })); + }), + ], + )); + } + + Widget builsinglepage(Book abd) { + return Container( + margin: EdgeInsets.only(top: 20), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + child: Image.network( + "${abd.link}", + height: 100, + width: 90, + fit: BoxFit.cover, + ), + ), + SizedBox( + width: 20, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + abd.name, + style: TextStyle( + color: Colors.black, + fontSize: 25, + fontWeight: FontWeight.bold), + ), + Text(abd.Author_name, + style: TextStyle( + color: Color.fromRGBO(104, 104, 104, 1), + fontSize: 15, + )), + SizedBox( + height: 5, + ), + Text( + '\$ ${abd.price}', + style: TextStyle( + color: Colors.black, + fontSize: 15, + fontWeight: FontWeight.bold), + ), + SizedBox( + height: 5, + ), + buildthestar() + ], + ), + ], + ), + ); + } +} diff --git a/lib/shared/components/components.dart b/lib/shared/components/components.dart new file mode 100644 index 0000000..b8e38e8 --- /dev/null +++ b/lib/shared/components/components.dart @@ -0,0 +1,131 @@ +import 'dart:ffi'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:book_store_app/model/model.dart'; + +// the screen for color of screen +int screen = 1 ; + +// build the botton + +Widget buildbotton( + {Alignment ali = Alignment.center, + double Width = double.infinity, + double Hieght = 40.0, + Color colore = Colors.black, + double border = 10.0, + String text = "Add", + Color textcolor = Colors.white, + FontWeight fontw = FontWeight.bold, + double fontS = 20.0, + required VoidCallback onPressed}) { + return Container( + margin: EdgeInsets.only(top: 10), + child: MaterialButton( + padding: EdgeInsets.all(0), + onPressed: onPressed, + child: Container( + margin: EdgeInsets.all(0), + alignment: ali, + width: Width, + height: Hieght, + decoration: BoxDecoration( + color: colore, borderRadius: BorderRadius.circular(border)), + child: Text( + "${text}", + style: + TextStyle(color: textcolor, fontWeight: fontw, fontSize: fontS), + ), + ), + ), + ); +} + +// build three button center + +Widget buildbcenter({ + double padd = 15.0, + double mabot = 29.0, + double radiu = 20.0, + double Width = 175, + required VoidCallback onPressed, + required VoidCallback onPressed2, + required VoidCallback onPressed3, +}) { + return Align( + alignment: Alignment.bottomCenter, + child: Container( + padding: EdgeInsets.all(padd), + margin: EdgeInsets.only(bottom: mabot), + decoration: BoxDecoration( + color: Color.fromARGB(255, 240, 238, 238), + borderRadius: BorderRadius.circular(radiu)), + width: Width, + child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + GestureDetector( + onTap: onPressed, + child: Icon(Icons.home_outlined , color: screen == 1 ? Colors.black : Colors.grey,), + ), + GestureDetector( + onTap: onPressed2, + child: Icon( + Icons.shopping_bag_outlined, + color: screen == 2 ? Colors.black : Colors.grey, + ), + ), + GestureDetector( + onTap: onPressed3, + child: Icon(Icons.add_outlined, + color: screen == 3 ? Colors.black : Colors.grey, + ), + ), + ]), + ), + ); +} + +//build star +Widget buildthestar() { + return Row( + children: [ + for (int i = 0; i < 5; i++) + Icon( + Icons.star, + size: 15, + color: Colors.amber, + ), + SizedBox( + width: 10, + ), + Text( + "5/5", + style: TextStyle(color: Colors.grey), + ) + ], + ); +} + +// normal button +Widget buildnormal({ + IconData ic = Icons.list, + String text = "Preview", +}) { + return Container( + padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white, + ), + child: Row(children: [ + Icon(ic), + SizedBox( + width: 5, + ), + Text( + "${text}", + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), + ) + ]), + ); +} diff --git a/lib/shared/components/constants.dart b/lib/shared/components/constants.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/shared/styles/colors.dart b/lib/shared/styles/colors.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/shared/styles/styles.dart b/lib/shared/styles/styles.dart new file mode 100644 index 0000000..e69de29 diff --git a/pubspec.lock b/pubspec.lock index 7bc8bdd..62f34da 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -74,6 +74,13 @@ packages: description: flutter source: sdk version: "0.0.0" + get: + dependency: "direct main" + description: + name: get + url: "https://pub.dartlang.org" + source: hosted + version: "4.6.5" lints: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index cd0f457..f878151 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + get: ^4.6.5 dev_dependencies: flutter_test: @@ -58,9 +59,8 @@ flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg + assets: + - images/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware