diff --git a/lib/add_page/add_butoon.dart b/lib/add_page/add_butoon.dart new file mode 100644 index 0000000..6bf1737 --- /dev/null +++ b/lib/add_page/add_butoon.dart @@ -0,0 +1,53 @@ +import 'package:flutter/material.dart'; + +import '../home_page/books_main/books_model.dart'; + +class AddBookButton extends StatelessWidget { + const AddBookButton({ + Key? key, + required this.nameController, + required this.authorController, + required this.priceController, + required this.rateController, + required this.imageController, + required this.descriptionController, + }) : super(key: key); + + final TextEditingController nameController; + final TextEditingController authorController; + final TextEditingController priceController; + final TextEditingController rateController; + final TextEditingController imageController; + final TextEditingController descriptionController; + + @override + Widget build(BuildContext context) { + return Center( + child: GestureDetector(onTap:(){BookData.add( + nameController.text, + authorController.text, + priceController.text, + double.parse(rateController.text), + imageController.text, + descriptionController.text); + + nameController.clear(); + authorController.clear(); + priceController.clear(); + rateController.clear(); + imageController.clear(); + descriptionController.clear();} , + child: Container(width: 319,height: 60, + margin: EdgeInsets.only(top: 20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8),color: Colors.black + ),child: const Center( + child: Text('Add Book', + style: TextStyle(color: Colors.white, + fontWeight:FontWeight.bold, + fontSize: 16),), + ),), + ), + ); + } +} \ No newline at end of file diff --git a/lib/add_page/add_page_main.dart b/lib/add_page/add_page_main.dart new file mode 100644 index 0000000..66f72bd --- /dev/null +++ b/lib/add_page/add_page_main.dart @@ -0,0 +1,59 @@ +import 'package:flutter/material.dart'; + +import '../home_page/books_main/books_model.dart'; +import 'add_butoon.dart'; +import 'my_text_fields.dart'; + +class AddPage extends StatelessWidget { + AddPage({Key? key,}) : super(key: key); + + TextEditingController nameController = TextEditingController(); + TextEditingController authorController = TextEditingController(); + TextEditingController priceController = TextEditingController(); + TextEditingController rateController = TextEditingController(); + TextEditingController imageController = TextEditingController(); + TextEditingController descriptionController = TextEditingController(); + BookData? bookData; + + @override + Widget build(BuildContext context){ + return MaterialApp( + home: Scaffold( + appBar: AppBar( + backgroundColor: Colors.white.withOpacity(0.1), + elevation: 0, + leading: IconButton(onPressed: (){Navigator.pop(context);}, + icon:const Icon(Icons.arrow_back_ios_new_sharp, + color: Colors.black, size: 25,),), + actions: const [ + Icon(Icons.more_vert_sharp, color: Colors.black, size: 25,) + ], + ), + body: ListView( + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 50), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Add Book',style: TextStyle(fontSize: + 24,fontWeight: FontWeight.bold),), + AddNameField(nameController: nameController), + AddAuthorField(authorController: authorController), + AddPriceField(priceController: priceController), + AddRatingField(rateController: rateController), + AddImageField(imageController: imageController), + AddDescriptionField(descriptionController: descriptionController), + AddBookButton(nameController: nameController, + authorController: authorController, + priceController: priceController, + rateController: rateController, + imageController: imageController, + descriptionController: descriptionController) + ], + ), + ), + ], + ), + ), + ); + }} \ No newline at end of file diff --git a/lib/add_page/my_text_fields.dart b/lib/add_page/my_text_fields.dart new file mode 100644 index 0000000..c0aca15 --- /dev/null +++ b/lib/add_page/my_text_fields.dart @@ -0,0 +1,235 @@ + + +import 'package:flutter/material.dart'; + +class AddNameField extends StatelessWidget { + const AddNameField({ + Key? key, + required this.nameController, + }) : super(key: key); + + final TextEditingController nameController; + + @override + Widget build(BuildContext context) { + return Container(height: 60, + margin: const EdgeInsets.only(top: 40, left: 20, right: 20), + padding: EdgeInsets.symmetric(horizontal: 15), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(196,135,198,.2), + blurRadius: 10, + offset: Offset(0,.1), + ) + ] + ), + child: Center( + child: TextField( + controller: nameController, + decoration: const InputDecoration( + border: InputBorder.none, + hintText: "Book Name", + hintStyle: TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.grey) + ), + ), + ) + ); + } +} + + +class AddAuthorField extends StatelessWidget { + const AddAuthorField({ + Key? key, + required this.authorController, + }) : super(key: key); + + final TextEditingController authorController; + + @override + Widget build(BuildContext context) { + return Container(height: 60, + margin: const EdgeInsets.only(top: 40, left: 20, right: 20), + padding: EdgeInsets.symmetric(horizontal: 15), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(196,135,198,.2), + blurRadius: 10, + offset: Offset(0,.1), + ) + ] + ), + child: Center( + child: TextField( + controller: authorController, + decoration: const InputDecoration( + border: InputBorder.none, + hintText: "Author Name", + hintStyle: TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.grey) + ), + ), + ) + ); + } +} + + +class AddPriceField extends StatelessWidget { + const AddPriceField({ + Key? key, + required this.priceController, + }) : super(key: key); + + final TextEditingController priceController; + + @override + Widget build(BuildContext context) { + return Container(height: 60, + margin: const EdgeInsets.only(top: 40, left: 20, right: 20), + padding: EdgeInsets.symmetric(horizontal: 15), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(196,135,198,.2), + blurRadius: 10, + offset: Offset(0,.1), + ) + ] + ), + child: Center( + child: TextField( + controller: priceController, + decoration: const InputDecoration( + border: InputBorder.none, + hintText: "Price", + hintStyle: TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.grey) + ), + ), + ) + ); + } +} + + +class AddRatingField extends StatelessWidget { + const AddRatingField({ + Key? key, + required this.rateController, + }) : super(key: key); + + final TextEditingController rateController; + + @override + Widget build(BuildContext context) { + return Container(height: 60, + margin: const EdgeInsets.only(top: 40, left: 20, right: 20), + padding: EdgeInsets.symmetric(horizontal: 15), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(196,135,198,.2), + blurRadius: 10, + offset: Offset(0,.1), + ) + ] + ), + child: Center( + child: TextField( + controller: rateController, + decoration: const InputDecoration( + border: InputBorder.none, + hintText: "Rating", + hintStyle: TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.grey) + ), + ), + ) + ); + } +} + + +class AddImageField extends StatelessWidget { + const AddImageField({ + Key? key, + required this.imageController, + }) : super(key: key); + + final TextEditingController imageController; + + @override + Widget build(BuildContext context) { + return Container(height: 60, + margin: const EdgeInsets.only(top: 40, left: 20, right: 20), + padding: EdgeInsets.symmetric(horizontal: 15), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(196,135,198,.2), + blurRadius: 10, + offset: Offset(0,.1), + ) + ] + ), + child: Center( + child: TextField( + controller: imageController, + decoration: const InputDecoration( + border: InputBorder.none, + hintText: "Image link", + hintStyle: TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.grey) + ), + ), + ) + ); + } +} + + +class AddDescriptionField extends StatelessWidget { + const AddDescriptionField({ + Key? key, + required this.descriptionController, + }) : super(key: key); + + final TextEditingController descriptionController; + + @override + Widget build(BuildContext context) { + return Container(height: 100, + margin: const EdgeInsets.only(top: 40, left: 20, right: 20), + padding: EdgeInsets.symmetric(horizontal: 15), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(196,135,198,.2), + blurRadius: 10, + offset: Offset(0,.1), + ) + ] + ), + child: TextField( + controller: descriptionController, + decoration: const InputDecoration( + border: InputBorder.none, + hintText: "Description", + hintStyle: TextStyle(fontSize: 17, + fontWeight: FontWeight.w500, color: Colors.grey) + ), + ) + ); + } +} \ No newline at end of file diff --git a/lib/book_page/book_page_buttons/book_all_buttons.dart b/lib/book_page/book_page_buttons/book_all_buttons.dart new file mode 100644 index 0000000..e6bcf36 --- /dev/null +++ b/lib/book_page/book_page_buttons/book_all_buttons.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; + +import '../../home_page/books_main/books_model.dart'; +import 'book_buy_button.dart'; +import 'book_preview_button.dart'; +import 'book_reviews_button.dart'; + +class BookPageButton extends StatelessWidget { + const BookPageButton({ + Key? key, + required this.book, + }) : super(key: key); + + final BookData book; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Column( + children: [ + Row(mainAxisAlignment: MainAxisAlignment.center, + children: const [ + PreviewButton(), + SizedBox(width: 13,), + ReviewsButton() + ], + ),const SizedBox(height: 34,), + BuyButton(book: book) + ], + ), + ); + } +} \ No newline at end of file diff --git a/lib/book_page/book_page_buttons/book_buy_button.dart b/lib/book_page/book_page_buttons/book_buy_button.dart new file mode 100644 index 0000000..ea269ec --- /dev/null +++ b/lib/book_page/book_page_buttons/book_buy_button.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; + +import '../../home_page/books_main/books_model.dart'; + +class BuyButton extends StatelessWidget { + const BuyButton({ + Key? key, + required this.book, + }) : super(key: key); + + final BookData book; + + @override + Widget build(BuildContext context) { + return GestureDetector(onTap: (){book.isInCart();}, + child: Container(width: 319,height: 60,decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8),color: Colors.black + ),child: Center( + child: Text('Buy Now for ${book.bookPrice}', + style: const TextStyle(color: Colors.white, + fontWeight:FontWeight.bold, + fontSize: 16),), + ),), + ); + } +} \ No newline at end of file diff --git a/lib/book_page/book_page_buttons/book_preview_button.dart b/lib/book_page/book_page_buttons/book_preview_button.dart new file mode 100644 index 0000000..633e660 --- /dev/null +++ b/lib/book_page/book_page_buttons/book_preview_button.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +class PreviewButton extends StatelessWidget { + const PreviewButton({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container(height: 40,width: 152,decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8),color: Colors.white + ),child: + Row(mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon(Icons.list_outlined),SizedBox(width: 15,), + Text('Preview',style: TextStyle(fontWeight: FontWeight.bold),) + ],), + ); + } +} \ No newline at end of file diff --git a/lib/book_page/book_page_buttons/book_reviews_button.dart b/lib/book_page/book_page_buttons/book_reviews_button.dart new file mode 100644 index 0000000..4581ad9 --- /dev/null +++ b/lib/book_page/book_page_buttons/book_reviews_button.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; + +class ReviewsButton extends StatelessWidget { + const ReviewsButton({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container(height: 40,width: 152,decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8),color: Colors.white + ),child:Row(mainAxisAlignment: MainAxisAlignment.center, + children: const [ + Icon(Icons.reviews_outlined),SizedBox(width: 15,), + Text('Reviews',style: TextStyle(fontWeight: FontWeight.bold),) + ],),); + } +} \ No newline at end of file diff --git a/lib/book_page/book_page_image/book_image.dart b/lib/book_page/book_page_image/book_image.dart new file mode 100644 index 0000000..f68b022 --- /dev/null +++ b/lib/book_page/book_page_image/book_image.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +import '../../home_page/books_main/books_model.dart'; + +class BookPageImage extends StatelessWidget { + const BookPageImage({ + Key? key, + required this.book, + }) : super(key: key); + + final BookData book; + + @override + Widget build(BuildContext context) { + return SizedBox(width: 216,height: 320, + child: ClipRRect(borderRadius: BorderRadius.circular(8), + child: Image.network(book.bookImage,fit: BoxFit.fill,))); + } +} \ No newline at end of file diff --git a/lib/book_page/book_page_main.dart b/lib/book_page/book_page_main.dart new file mode 100644 index 0000000..1c23276 --- /dev/null +++ b/lib/book_page/book_page_main.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; +import 'package:get/get_state_manager/get_state_manager.dart'; +import '../home_page/books_main/books_model.dart'; +import 'book_page_buttons/book_all_buttons.dart'; +import 'book_page_image/book_image.dart'; +import 'book_page_texts/book_author.dart'; +import 'book_page_texts/book_descrption.dart'; +import 'book_page_texts/book_name.dart'; +import 'book_page_texts/book_rate.dart'; + +class BookPage extends GetView { + const BookPage({Key? key, required this.book}) : super(key: key); + final BookData book; + + @override + Widget build(BuildContext context){ + return MaterialApp( + home: Scaffold( + backgroundColor: const Color(0xffE5E5E5), + body: Padding( + padding: const EdgeInsets.symmetric(horizontal: 28.0), + child: Center( + child: Column( + children: [ + const SizedBox(height: 100,), + BookPageImage(book: book), + BookPageName(book: book), + BookPageAuthor(book: book), + BookPageRate(book: book), + BookPageDescription(book: book), + Align( + alignment: Alignment.bottomCenter, + child: BookPageButton(book: book),) + ], + ), + ), + ) + ) + ); + } +} \ No newline at end of file diff --git a/lib/book_page/book_page_texts/book_author.dart b/lib/book_page/book_page_texts/book_author.dart new file mode 100644 index 0000000..d7f4a1e --- /dev/null +++ b/lib/book_page/book_page_texts/book_author.dart @@ -0,0 +1,21 @@ +import 'package:flutter/cupertino.dart'; + +import '../../home_page/books_main/books_model.dart'; + +class BookPageAuthor extends StatelessWidget { + const BookPageAuthor({ + Key? key, + required this.book, + }) : super(key: key); + + final BookData book; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 12.0), + child: + Text(book.bookAuthor,style: const TextStyle(fontSize:14)), + ); + } +} \ No newline at end of file diff --git a/lib/book_page/book_page_texts/book_descrption.dart b/lib/book_page/book_page_texts/book_descrption.dart new file mode 100644 index 0000000..6c7bf66 --- /dev/null +++ b/lib/book_page/book_page_texts/book_descrption.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +import '../../home_page/books_main/books_model.dart'; + +class BookPageDescription extends StatelessWidget { + const BookPageDescription({ + Key? key, + required this.book, + }) : super(key: key); + + final BookData book; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 19.0), + child: Text(book.bookDescription,style: const TextStyle(fontSize:16,)), + ); + } +} \ No newline at end of file diff --git a/lib/book_page/book_page_texts/book_name.dart b/lib/book_page/book_page_texts/book_name.dart new file mode 100644 index 0000000..9bb0228 --- /dev/null +++ b/lib/book_page/book_page_texts/book_name.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; + +import '../../home_page/books_main/books_model.dart'; + +class BookPageName extends StatelessWidget { + const BookPageName({ + Key? key, + required this.book, + }) : super(key: key); + + final BookData book; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 22.0), + child: Text(book.bookName, + style: const TextStyle(fontWeight: FontWeight.bold,fontSize:24),), + ); + } +} \ No newline at end of file diff --git a/lib/book_page/book_page_texts/book_rate.dart b/lib/book_page/book_page_texts/book_rate.dart new file mode 100644 index 0000000..0118879 --- /dev/null +++ b/lib/book_page/book_page_texts/book_rate.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; +import '../../home_page/books_main/books_model.dart'; +import '../../home_page/books_main/rating_widget.dart'; + +class BookPageRate extends StatelessWidget { + const BookPageRate({ + Key? key, + required this.book, + }) : super(key: key); + + final BookData book; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 12.0), + child: Row(mainAxisAlignment: MainAxisAlignment.center, + children: [ + StarRating(rating: book.bookRate,), + Text(' ${book.bookRate} / 5.0', + style: const TextStyle(fontWeight: FontWeight.bold,fontSize:14)), + ], + ), + ); + } +} \ No newline at end of file diff --git a/lib/cart_page/cart_main.dart b/lib/cart_page/cart_main.dart new file mode 100644 index 0000000..94fbd08 --- /dev/null +++ b/lib/cart_page/cart_main.dart @@ -0,0 +1,51 @@ +import 'package:book_store_app/home_page/books_main/books_model.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart'; + +import '../home_page/books_main/book_widgets.dart'; +import '../home_page/navigation_bar/navigation_bar_main.dart'; + +class MyCartCard extends StatelessWidget { + const MyCartCard({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return + Scaffold( + + appBar: AppBar( + backgroundColor: Colors.white.withOpacity(0.1), + elevation: 0, + leading: IconButton(onPressed: (){Navigator.pop(context);}, + icon:const Icon(Icons.arrow_back_ios_new_sharp, + color: Colors.black, size: 25,),), + actions: const [ + Icon(Icons.more_vert_sharp, color: Colors.black, size: 25,) + ], + ), + + body: Scaffold( + backgroundColor: const Color(0xffFDFDFD), + body: Column(crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Padding( + padding: EdgeInsets.only(left: 30.0), + child: Text('Cart',style: TextStyle(fontSize: + 24,fontWeight: FontWeight.bold),), + ), + Expanded(child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20.0), + child: Obx(() + {return ListView(children: BookData.books.where((e) =>e.inCart.value) + .map((e) => MyBook(bookData: e)).toList(),);}), + )), + const Align(alignment: Alignment.bottomCenter,child: Padding( + padding: EdgeInsets.only(bottom: 42.0), + child:MyNavigationBar()))] + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/home_page/books_main/book_widgets.dart b/lib/home_page/books_main/book_widgets.dart new file mode 100644 index 0000000..bb47bdf --- /dev/null +++ b/lib/home_page/books_main/book_widgets.dart @@ -0,0 +1,52 @@ +import 'package:book_store_app/home_page/books_main/rating_widget.dart'; +import 'package:flutter/material.dart'; + + +import '../../book_page/book_page_main.dart'; +import '../../main.dart'; +import 'books_model.dart'; + +class MyBook extends StatelessWidget{ + const MyBook({Key? key, required this.bookData}) : super(key: key); + final BookData bookData; + + + @override + Widget build(BuildContext context){ + return GestureDetector(onTap: () + {Navigator.push(context, MaterialPageRoute(builder: (context) => BookPage(book: bookData,)));}, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container(height: 150, width: 21, color: Color(0xffFDFDFD), + child: Row( + children: [ClipRRect(borderRadius:BorderRadius.circular(8) , + child: Image.network(bookData.bookImage, height: 280,width: 100,)), + Padding( + padding: const EdgeInsets.only(left:20), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Text(bookData.bookName,style: const TextStyle( + fontSize: 18,fontWeight: FontWeight.bold + + ),), + ),Text(bookData.bookAuthor,style: const TextStyle( + fontSize: 14, + ),), + + Text(bookData.bookPrice,style: TextStyle( + fontSize: 16,fontWeight: FontWeight.bold),), + Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: StarRating(rating: bookData.bookRate,), + ) + ],), + ), + ], + ),), + ), + ); + } +} diff --git a/lib/home_page/books_main/books_list_bulder.dart b/lib/home_page/books_main/books_list_bulder.dart new file mode 100644 index 0000000..5b06a57 --- /dev/null +++ b/lib/home_page/books_main/books_list_bulder.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:get/get_state_manager/get_state_manager.dart'; +import '../navigation_bar/navigation_bar_main.dart'; +import 'book_widgets.dart'; +import 'books_model.dart'; + + +class MyBooksCard extends StatelessWidget { + const MyBooksCard({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Expanded(child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20.0), + child: Obx(() + {return ListView(children: BookData.books + .map((e) => MyBook(bookData: e)).toList(),);}), + )); + } +} + + diff --git a/lib/home_page/books_main/books_model.dart b/lib/home_page/books_main/books_model.dart new file mode 100644 index 0000000..7305129 --- /dev/null +++ b/lib/home_page/books_main/books_model.dart @@ -0,0 +1,73 @@ +import 'package:get/get.dart'; + +class BookData{ + final String bookName; + final double bookRate; + final String bookAuthor; + final String bookDescription; + final String bookImage; + final String bookPrice; + final RxBool inCart = false.obs; + + BookData({ + required this.bookName, + required this.bookAuthor, + required this.bookPrice, + required this.bookRate, + required this.bookImage, + required this.bookDescription, + }); + + isInCart(){ + inCart.value = true; + } + static add( + String name, + String author, + String price, + double rate, + String link, + String description + ){ + books.add(BookData(bookName: name, + bookAuthor: author, + bookPrice: price, + bookRate: rate, + bookImage: link, + bookDescription: description)); + } + + + static RxList books = [ + BookData(bookName: 'bookName', + bookAuthor: 'bookAuthor', + bookDescription: 'bookDescription', + bookRate: 3.5, + bookImage: 'https://api.lorem.space/image/book?w=150&h=220&hash=B0E33EF4', + bookPrice: '\$ 15'), + BookData(bookName: 'bookName', + bookAuthor: 'bookAuthor', + bookDescription: 'bookDescription', + bookRate: 5, + bookImage: 'https://api.lorem.space/image/book?w=150&h=220&hash=2D297A22', + bookPrice: '\$ 15'), + BookData(bookName: 'bookName', + bookAuthor: 'bookAuthor', + bookDescription: 'bookDescription', + bookRate: 5, + bookImage: 'https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2', + bookPrice: '\$ 15'), + BookData(bookName: 'bookName', + bookAuthor: 'bookAuthor', + bookDescription: 'bookDescription', + bookRate: 1.5, + bookImage: 'https://api.lorem.space/image/book?w=150&h=220&hash=A89D0DE6', + bookPrice: '\$ 15'), + BookData(bookName: 'bookName', + bookAuthor: 'bookAuthor', + bookDescription: 'kmoeiwmfomewomewocmwmecome\noimcoiewmciomweocmokewmciomewiocmewoimcioewmciomewiocmoiewmciomewiocmeiowmcioemwciomewiocmeowmcioewmcioewmoicmewoimcoeiwmcoiewmcoimewoicmewoicm', + bookRate: 5, + bookImage: 'https://api.lorem.space/image/book?w=150&h=220&hash=BDC01094', + bookPrice: '\$ 15') + ].obs; +} diff --git a/lib/home_page/books_main/rating_widget.dart b/lib/home_page/books_main/rating_widget.dart new file mode 100644 index 0000000..0ae26ca --- /dev/null +++ b/lib/home_page/books_main/rating_widget.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; + +typedef RatingChangeCallback = void Function(double rating); + +class StarRating extends StatelessWidget { + final int starCount; + final double rating; + final RatingChangeCallback? onRatingChanged; + final Color color = const Color(0xffffc41f); + + StarRating({Key? key, this.starCount = 5, this.rating = .0, + this.onRatingChanged,}) : super(key: key); + + Widget buildStar(BuildContext context, int index) { + Icon icon; + if (index >= rating) { + icon = const Icon( + Icons.star_border, + color: Colors.black26 + ); + } + else if (index > rating - 1 && index < rating) { + icon = Icon( + Icons.star_half, + color: color + ); + } else { + icon = Icon( + Icons.star, + color: color + ); + } + return InkResponse( + onTap: onRatingChanged == null ? null : () => onRatingChanged!(index + 1.0), + child: icon, + ); + } + + @override + Widget build(BuildContext context) { + return Row(children: List.generate(starCount, (index) => buildStar(context, index))); + } +} \ No newline at end of file diff --git a/lib/home_page/my_app_bar/app_bar_footer.dart b/lib/home_page/my_app_bar/app_bar_footer.dart new file mode 100644 index 0000000..7d91d0e --- /dev/null +++ b/lib/home_page/my_app_bar/app_bar_footer.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class BookListText extends StatelessWidget { + const BookListText({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return const Padding( + padding: EdgeInsets.only(right: 280), + child: Text('Book List',style: TextStyle(fontSize: 24,fontWeight: FontWeight.bold),), + ); + } +} \ No newline at end of file diff --git a/lib/home_page/my_app_bar/search_bar.dart b/lib/home_page/my_app_bar/search_bar.dart new file mode 100644 index 0000000..538683e --- /dev/null +++ b/lib/home_page/my_app_bar/search_bar.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; + +class MySearchBar extends StatelessWidget { + const MySearchBar({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top:30), + child: Column( + children: [ + Container(height: 50,width: 370,alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(196,135,198,.2), + blurRadius: 10, + offset: Offset(0,.1), + ) + ], + color: const Color(0xffFFFFFF)), + child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: const [ + Padding( + padding: EdgeInsets.only(left: 10.0), + child: Text('Search...'), + + ), Padding( + padding: EdgeInsets.only(right: 10.0), + child: Icon(Icons.search), + ) + ],),), + ], + ), + ); + } +} \ No newline at end of file diff --git a/lib/home_page/my_app_bar/user_widget.dart b/lib/home_page/my_app_bar/user_widget.dart new file mode 100644 index 0000000..5f993ae --- /dev/null +++ b/lib/home_page/my_app_bar/user_widget.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; + +class UserName extends StatelessWidget { + const UserName({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return const Text('Hi, Kasm',style: TextStyle(fontWeight: FontWeight.bold,fontSize: 18),); + } +} + +class UserImage extends StatelessWidget { + const UserImage({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return ClipRRect(borderRadius: BorderRadius.circular(8), + child: Image.network('https://api.lorem.space/image/face?w=150&h=150', + height: 50,width: 50,), + ); + } +} \ No newline at end of file diff --git a/lib/home_page/navigation_bar/navigation_bar_data.dart b/lib/home_page/navigation_bar/navigation_bar_data.dart new file mode 100644 index 0000000..4b2edb8 --- /dev/null +++ b/lib/home_page/navigation_bar/navigation_bar_data.dart @@ -0,0 +1,17 @@ +import 'package:book_store_app/home_page/books_main/books_list_bulder.dart'; +import 'package:book_store_app/main.dart'; +import 'package:flutter/material.dart'; +import '../../add_page/add_page_main.dart'; +import '../../cart_page/cart_main.dart'; + +class TabData{ + final IconData icon; + final Widget page; + TabData({required this.page, required this.icon}); + + static List buttons = [ + TabData(icon: Icons.home_outlined, page: MyApp()), + TabData(icon: Icons.shopping_cart_outlined, page: MyCartCard()), + TabData(icon: Icons.add, page: AddPage()), + ]; +} \ No newline at end of file diff --git a/lib/home_page/navigation_bar/navigation_bar_main.dart b/lib/home_page/navigation_bar/navigation_bar_main.dart new file mode 100644 index 0000000..d11de74 --- /dev/null +++ b/lib/home_page/navigation_bar/navigation_bar_main.dart @@ -0,0 +1,30 @@ +import 'package:book_store_app/main.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'navigation_bar_data.dart'; +import 'navigation_bar_widget.dart'; + +class MyNavigationBar extends StatelessWidget { + const MyNavigationBar({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + width: 227, + height: 72, + decoration: + BoxDecoration( + borderRadius: + BorderRadius.circular(20), + color: Color(0xffffffff) + ),child: Padding( + padding: const EdgeInsets.only(top: 25), + child: Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: TabData.buttons.map((e) => GestureDetector(onTap: (){ + Navigator.push(context, MaterialPageRoute(builder: (context)=> e.page)); + },child: MyTab(data: e,))).toList(),)), + ); + } +} \ No newline at end of file diff --git a/lib/home_page/navigation_bar/navigation_bar_widget.dart b/lib/home_page/navigation_bar/navigation_bar_widget.dart new file mode 100644 index 0000000..6541509 --- /dev/null +++ b/lib/home_page/navigation_bar/navigation_bar_widget.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; +import 'navigation_bar_data.dart'; + +class MyTab extends StatelessWidget{ + const MyTab({Key? key, required this.data}) : super(key: key); + final TabData data; + + @override + Widget build(BuildContext context){ + return Column( + children: [ + Icon(data.icon, + color: Colors.black,size: 28,) + ], + ); + } +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index bcc58f7..91745ea 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,10 @@ + import 'package:flutter/material.dart'; +import 'home_page/books_main/books_list_bulder.dart'; +import 'home_page/my_app_bar/app_bar_footer.dart'; +import 'home_page/my_app_bar/search_bar.dart'; +import 'home_page/my_app_bar/user_widget.dart'; +import 'home_page/navigation_bar/navigation_bar_main.dart'; void main() { runApp(const MyApp()); @@ -9,12 +15,108 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return const MaterialApp( + return MaterialApp( home: Scaffold( - body: Center( - child: Text("Book Store App"), + backgroundColor: const Color(0xffFDFDFD), + body:Stack( + children:[ + Column( + children: [ + Padding( + padding: const EdgeInsets.only(top: 50), + child: Row( + children: const [ + SizedBox(width: 10,), + UserImage(), + SizedBox(width: 10,), + UserName(), + SizedBox(width: 240,), + Icon(Icons.more_vert_sharp) + ],), + ), + const MySearchBar(), + const SizedBox(height: 30,), + const BookListText(), + const SizedBox(height: 10,), + const MyBooksCard(), + ], + ),const Align(alignment: Alignment.bottomCenter,child: Padding( + padding: EdgeInsets.only(bottom: 42.0), + child:MyNavigationBar() + ), + )] ), ), ); } } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..ae7cbfd 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: