From 5e14ece584e971c61f6d2f320f8af0386dbfa0a2 Mon Sep 17 00:00:00 2001 From: zaid443 Date: Wed, 31 Aug 2022 16:39:31 +0300 Subject: [PATCH] done --- lib/main.dart | 29 ++++++++++++++++++++++--- lib/modules/book_module.dart | 1 + lib/page_add/add_page.dart | 1 + lib/page_add/button_add.dart | 1 + lib/page_add/text_add.dart | 1 + lib/page_cart/cart_page.dart | 1 + lib/page_cart/list_cart.dart | 1 + lib/page_description/book_info.dart | 1 + lib/page_description/bottom_button.dart | 1 + lib/page_description/buttons.dart | 1 + lib/page_description/custom_appbar.dart | 1 + lib/page_description/description.dart | 1 + lib/page_description/image_book.dart | 1 + lib/page_main/list_book_layout.dart | 1 + lib/page_main/list_books.dart | 1 + lib/page_main/main_appbar.dart | 1 + lib/page_main/main_page.dart | 1 + lib/page_main/navigation_buttons.dart | 1 + lib/page_main/search_field.dart | 1 + lib/page_main/search_list.dart | 1 + lib/page_main/title_page.dart | 1 + lib/page_save/list_save.dart | 1 + lib/page_save/save_page.dart | 1 + pubspec.lock | 7 ++++++ pubspec.yaml | 1 + 25 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 lib/modules/book_module.dart create mode 100644 lib/page_add/add_page.dart create mode 100644 lib/page_add/button_add.dart create mode 100644 lib/page_add/text_add.dart create mode 100644 lib/page_cart/cart_page.dart create mode 100644 lib/page_cart/list_cart.dart create mode 100644 lib/page_description/book_info.dart create mode 100644 lib/page_description/bottom_button.dart create mode 100644 lib/page_description/buttons.dart create mode 100644 lib/page_description/custom_appbar.dart create mode 100644 lib/page_description/description.dart create mode 100644 lib/page_description/image_book.dart create mode 100644 lib/page_main/list_book_layout.dart create mode 100644 lib/page_main/list_books.dart create mode 100644 lib/page_main/main_appbar.dart create mode 100644 lib/page_main/main_page.dart create mode 100644 lib/page_main/navigation_buttons.dart create mode 100644 lib/page_main/search_field.dart create mode 100644 lib/page_main/search_list.dart create mode 100644 lib/page_main/title_page.dart create mode 100644 lib/page_save/list_save.dart create mode 100644 lib/page_save/save_page.dart diff --git a/lib/main.dart b/lib/main.dart index bcc58f7..16d2158 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,10 @@ +import 'package:book_store_app/page_add/add_page.dart'; +import 'package:book_store_app/page_cart/cart_page.dart'; +import 'package:book_store_app/page_main/navigation_buttons.dart'; +import 'package:book_store_app/page_save/save_page.dart'; +import 'package:get/get.dart'; + +import '../page_main/main_page.dart'; import 'package:flutter/material.dart'; void main() { @@ -7,13 +14,29 @@ void main() { class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); + static PageController controllerPage = PageController(); + static RxInt currentPage = 0.obs; + @override Widget build(BuildContext context) { - return const MaterialApp( + return GetMaterialApp( + debugShowCheckedModeBanner: false, home: Scaffold( - body: Center( - child: Text("Book Store App"), + body: PageView( + controller: controllerPage, + onPageChanged: (x) { + currentPage.value = x; + print('x=${currentPage.value}'); + }, + children: [ + const MainPage(), + const CartPage(), + const SavePage(), + AddPage(), + ], ), + extendBody: true, + bottomNavigationBar: const NavigationButton(), ), ); } diff --git a/lib/modules/book_module.dart b/lib/modules/book_module.dart new file mode 100644 index 0000000..49607ab --- /dev/null +++ b/lib/modules/book_module.dart @@ -0,0 +1 @@ +import 'package:get/get.dart'; class BookModule { final Rx nameBook; final Rx authorBook; final Rx descriptionBook; final Rx priceBook; final String imageBook; final RxBool inCart = false.obs; final RxBool isSaving = false.obs; static final RxBool isSearch = false.obs; BookModule( {required String nameBook, required String authorBook, required String priceBook, required String descriptionBook, required this.imageBook}) : nameBook = nameBook.obs, authorBook = authorBook.obs, priceBook = priceBook.obs, descriptionBook = descriptionBook.obs; inCartChanged() { inCart.value = true; } isSavingChanged() { isSaving.value = true; } static isSearchChanged() { isSearch.value = true; } static RxString search = ''.obs; static add(String name, String author, String price, String description, String image) { BookModule book = BookModule( nameBook: name, authorBook: author, priceBook: price, descriptionBook: description, imageBook: image, ); books.add(book); } static RxList books = [ BookModule( nameBook: 'Overkill', authorBook: 'Sandra Brown', priceBook: '14.99', descriptionBook: '''Former Super Bowl MVP quarterback Zach Bridger hasn’t seen his ex-wife, Rebecca Pratt, for some time—not since their volatile marriage imploded—so he’s shocked to receive a life-altering call about her. Rebecca has been placed on life support after a violent assault, and he—despite their divorce—has medical power-of-attorney. Zach is asked to make an impossible choice: keep her on life support or take her off of it. Buckling under the weight of the responsibility and the glare of public scrutiny, Zach ultimately walks away, letting Rebecca's parents have the final say.''', imageBook: 'https://books.google.com/books/publisher/content/images/frontcover/DZ5kEAAAQBAJ?fife=w240-h345'), BookModule( nameBook: 'Soul Taken', authorBook: 'Patricia Briggs', priceBook: '13.99', descriptionBook: '''The vampire Wulfe is missing. Since he’s deadly, possibly insane, and his current idea of “fun” is stalking me, some may see it as no great loss. But, warned that his disappearance might bring down the carefully constructed alliances that keep our pack safe, my mate and I must find Wulfe—and hope he’s still alive. As alive as a vampire can be, anyway''', imageBook: 'https://books.google.com/books/publisher/content/images/frontcover/YkAyEAAAQBAJ?fife=w240-h345'), BookModule( nameBook: 'Verity', authorBook: 'Colleen Hoover', priceBook: '11.99', descriptionBook: '''Whose truth is the lie? Stay up all night reading the sensational psychological thriller that has readers obsessed, ''', imageBook: 'https://books.google.com/books/publisher/content/images/frontcover/SSRGEAAAQBAJ?fife=w240-h345'), BookModule( nameBook: 'The Terminal List: A Thriller', authorBook: 'Jack Carr', priceBook: '18.99', descriptionBook: '''Take my word for it, James Reece is one rowdy motherf***er. Get ready!”—Chris Pratt, all around great guy and star of The Terminal List, coming to Amazon Prime A Navy SEAL has nothing left to live for and everything to kill for after he discovers that the American government is behind the deaths''', imageBook: 'https://books.google.com/books/publisher/content/images/frontcover/0BwyDwAAQBAJ?fife=w240-h345'), BookModule( nameBook: 'In the Blood: A Thriller', authorBook: 'Jack Carr', priceBook: '14.99', descriptionBook: '''Take my word for it, James Reece is one rowdy motherf***er. Get ready!” —Chris Pratt, star of The Terminal List, coming to Amazon Prime The #1 New York Times bestselling Terminal List series continues as James Reece embarks on a global journey of vengeance. A woman boards a plane in the African country of Burkina Faso having just completed a targeted assassination ''', imageBook: 'https://books.google.com/books/publisher/content/images/frontcover/TFg1EAAAQBAJ?fife=w240-h345'), ].obs; } \ No newline at end of file diff --git a/lib/page_add/add_page.dart b/lib/page_add/add_page.dart new file mode 100644 index 0000000..3f5d8bb --- /dev/null +++ b/lib/page_add/add_page.dart @@ -0,0 +1 @@ +import 'package:book_store_app/modules/book_module.dart'; import 'package:book_store_app/page_add/button_add.dart'; import 'package:book_store_app/page_add/text_add.dart'; import 'package:book_store_app/page_description/custom_appbar.dart'; import 'package:book_store_app/page_main/title_page.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class AddPage extends StatelessWidget { AddPage({Key? key}) : super(key: key); final TextEditingController name = TextEditingController(); final TextEditingController author = TextEditingController(); final TextEditingController price = TextEditingController(); final TextEditingController image = TextEditingController(); final TextEditingController description = TextEditingController(); @override Widget build(BuildContext context) { return Scaffold( appBar: const CustomAppBar(), body: SingleChildScrollView( child: SizedBox( height: 600, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const TitlePage(title: 'Add Book'), TextAdd(controllerAdd: name, hintText: 'Book Name', height: 50), TextAdd( controllerAdd: author, hintText: 'Author Name', height: 50), TextAdd(controllerAdd: price, hintText: 'Price', height: 50), TextAdd(controllerAdd: image, hintText: 'Image Link', height: 50), TextAdd( controllerAdd: description, hintText: 'Description', height: 150), ButtonAdd( addBook: () { BookModule.add( name.text, author.text, price.text, description.text, image.text, ); name.clear(); author.clear(); price.clear(); image.clear(); description.clear(); }, ), ], ), ), ), ); } } \ No newline at end of file diff --git a/lib/page_add/button_add.dart b/lib/page_add/button_add.dart new file mode 100644 index 0000000..734b2cd --- /dev/null +++ b/lib/page_add/button_add.dart @@ -0,0 +1 @@ +import 'package:flutter/material.dart'; import '../modules/book_module.dart'; class ButtonAdd extends StatelessWidget { const ButtonAdd({ Key? key, required this.addBook, }) : super(key: key); final Function addBook; @override Widget build(BuildContext context) { return Center( child: TextButton( onPressed: () { addBook(); }, child: Container( height: 50, width: 280, decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.circular(12), ), child: const Center( child: Text( 'Add', style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, ), )), ))); } } \ No newline at end of file diff --git a/lib/page_add/text_add.dart b/lib/page_add/text_add.dart new file mode 100644 index 0000000..6243b31 --- /dev/null +++ b/lib/page_add/text_add.dart @@ -0,0 +1 @@ +import 'package:flutter/material.dart'; class TextAdd extends StatelessWidget { const TextAdd({ Key? key, required this.controllerAdd, required this.hintText, required this.height, }) : super(key: key); final TextEditingController controllerAdd; final String hintText; final double height; @override Widget build(BuildContext context) { return Container( height: height, margin: const EdgeInsets.only(top: 15, right: 25, left: 25), decoration: BoxDecoration(boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.2), spreadRadius: 1, blurRadius: 9, offset: const Offset(0, 6), // changes position of shadow ), ]), child: TextField( maxLines: 7, controller: controllerAdd, style: const TextStyle( fontSize: 18, ), decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: BorderSide.none, ), filled: true, fillColor: Colors.white, hintText: hintText, contentPadding: const EdgeInsets.only(left: 20.0, bottom: 16.0, top: 16.0), hintStyle: const TextStyle( color: Colors.grey, fontSize: 20, fontStyle: FontStyle.italic, ), ), ), ); } } \ No newline at end of file diff --git a/lib/page_cart/cart_page.dart b/lib/page_cart/cart_page.dart new file mode 100644 index 0000000..6cebf7d --- /dev/null +++ b/lib/page_cart/cart_page.dart @@ -0,0 +1 @@ +import 'package:book_store_app/page_description/custom_appbar.dart'; import 'package:book_store_app/page_main/title_page.dart'; import 'package:flutter/material.dart'; import '../page_main/navigation_buttons.dart'; import 'list_cart.dart'; class CartPage extends StatelessWidget { const CartPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: const CustomAppBar(), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: const [ TitlePage(title: 'Cart'), ListCart(), ], ), extendBody: true, bottomNavigationBar: const NavigationButton(), ); } } \ No newline at end of file diff --git a/lib/page_cart/list_cart.dart b/lib/page_cart/list_cart.dart new file mode 100644 index 0000000..fcc4adb --- /dev/null +++ b/lib/page_cart/list_cart.dart @@ -0,0 +1 @@ +import 'package:book_store_app/modules/book_module.dart'; import 'package:book_store_app/page_description/book_info.dart'; import 'package:book_store_app/page_main/list_book_layout.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class ListCart extends StatelessWidget { const ListCart({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Expanded( child: Obx(() { return Padding( padding: const EdgeInsets.only(left: 20), child: ListView( scrollDirection: Axis.vertical, shrinkWrap: true, children: BookModule.books .where((e) => e.inCart.value) .map((e) => GestureDetector( onTap: () { Get.to(BookInfo(book: e)); }, child: ListBookLayout(book: e), )) .toList(), ), ); }), ); } } \ No newline at end of file diff --git a/lib/page_description/book_info.dart b/lib/page_description/book_info.dart new file mode 100644 index 0000000..542f70b --- /dev/null +++ b/lib/page_description/book_info.dart @@ -0,0 +1 @@ +import 'package:book_store_app/modules/book_module.dart'; import 'package:book_store_app/page_description/bottom_button.dart'; import 'package:book_store_app/page_description/description.dart'; import 'package:book_store_app/page_description/image_book.dart'; import 'package:flutter/material.dart'; import 'custom_appbar.dart'; import 'buttons.dart'; class BookInfo extends StatelessWidget { BookInfo({ Key? key, required this.book, }) : super(key: key); final BookModule book; @override Widget build(BuildContext context) { return Scaffold( appBar: const CustomAppBar(), body: Center( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ ImageBook(book: book), Text( book.nameBook.value, style: const TextStyle(fontSize: 26, fontWeight: FontWeight.bold), ), Text( book.authorBook.value, style: const TextStyle( fontSize: 14, fontWeight: FontWeight.bold, color: Colors.grey), ), Row( mainAxisAlignment: MainAxisAlignment.center, children: List.generate(5, (index) { return Icon( index < 4 ? Icons.star : Icons.star_border, color: Colors.yellow, ); }), ), DescriptionBook(book: book), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: const [ Buttons( iconButton: Icons.short_text_rounded, nameButton: 'Preview', ), Buttons( iconButton: Icons.message_outlined, nameButton: 'Reviews', ), ], ), BottomButton(book: book), ], ), ), ); } } \ No newline at end of file diff --git a/lib/page_description/bottom_button.dart b/lib/page_description/bottom_button.dart new file mode 100644 index 0000000..5e687e9 --- /dev/null +++ b/lib/page_description/bottom_button.dart @@ -0,0 +1 @@ +import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../modules/book_module.dart'; class BottomButton extends StatelessWidget { const BottomButton({ Key? key, required this.book, }) : super(key: key); final BookModule book; @override Widget build(BuildContext context) { return Obx(() { return TextButton( onPressed: () { (book.inCart.value == true) ? book.inCart.value = false : book.inCartChanged(); }, child: Container( height: 50, width: 280, decoration: BoxDecoration( color: Colors.black, borderRadius: BorderRadius.circular(12), ), child: Center( child: Text( (book.inCart.value == false) ? 'Buy Now for \$${book.priceBook}' : 'Remove from Cart', style: const TextStyle( color: Colors.white, fontWeight: FontWeight.bold, ), )), )); }); } } \ No newline at end of file diff --git a/lib/page_description/buttons.dart b/lib/page_description/buttons.dart new file mode 100644 index 0000000..81ceb35 --- /dev/null +++ b/lib/page_description/buttons.dart @@ -0,0 +1 @@ +import 'package:flutter/material.dart'; class Buttons extends StatelessWidget { const Buttons({Key? key, required this.iconButton, required this.nameButton}) : super(key: key); final IconData iconButton; final String nameButton; @override Widget build(BuildContext context) { return TextButton( onPressed: () {}, style: TextButton.styleFrom( backgroundColor: Colors.white, padding: const EdgeInsets.only(left: 25,right: 25,top: 10,bottom: 10), ), child: Center( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Icon(iconButton,color: Colors.black,), SizedBox(width: 8,), Text(nameButton,style: const TextStyle(color: Colors.black,fontSize: 14),), ], ), ), ); } } \ No newline at end of file diff --git a/lib/page_description/custom_appbar.dart b/lib/page_description/custom_appbar.dart new file mode 100644 index 0000000..65e56e5 --- /dev/null +++ b/lib/page_description/custom_appbar.dart @@ -0,0 +1 @@ +import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { const CustomAppBar({Key? key}) : super(key: key); @override Size get preferredSize => const Size.fromHeight(50.0); @override Widget build(BuildContext context) { return AppBar( systemOverlayStyle: const SystemUiOverlayStyle( statusBarColor: Colors.transparent, statusBarIconBrightness: Brightness.dark), elevation: 0, backgroundColor: Colors.white, leading: GestureDetector( child: const Icon( Icons.arrow_back_ios, color: Colors.black, ), onTap: () { Get.back(); }, ), actions: const [ Padding( padding: EdgeInsets.only(right: 15), child: Icon( Icons.more_vert, color: Colors.black, ), ) ], ); } } \ No newline at end of file diff --git a/lib/page_description/description.dart b/lib/page_description/description.dart new file mode 100644 index 0000000..18421a9 --- /dev/null +++ b/lib/page_description/description.dart @@ -0,0 +1 @@ +import 'package:flutter/material.dart'; import '../modules/book_module.dart'; class DescriptionBook extends StatelessWidget { const DescriptionBook({Key? key, required this.book}) : super(key: key); final BookModule book; @override Widget build(BuildContext context) { return SizedBox( height: 100, child: SingleChildScrollView( child: Container( margin: const EdgeInsets.only(right: 25, left: 25), padding: const EdgeInsets.all(15), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10) ), child: Text(book.descriptionBook.value,style: const TextStyle(fontWeight: FontWeight.bold),), ), ), ); } } \ No newline at end of file diff --git a/lib/page_description/image_book.dart b/lib/page_description/image_book.dart new file mode 100644 index 0000000..ca2ac1e --- /dev/null +++ b/lib/page_description/image_book.dart @@ -0,0 +1 @@ +import 'package:flutter/material.dart'; import '../modules/book_module.dart'; class ImageBook extends StatelessWidget { const ImageBook({Key? key, required this.book}) : super(key: key); final BookModule book; @override Widget build(BuildContext context) { return Container( width: 200, height: 300, decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), image: DecorationImage( fit: BoxFit.fill, image: NetworkImage( book.imageBook, ), ), ), ); } } \ No newline at end of file diff --git a/lib/page_main/list_book_layout.dart b/lib/page_main/list_book_layout.dart new file mode 100644 index 0000000..0d25248 --- /dev/null +++ b/lib/page_main/list_book_layout.dart @@ -0,0 +1 @@ +import 'package:book_store_app/modules/book_module.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class ListBookLayout extends StatelessWidget { const ListBookLayout({Key? key, required this.book}) : super(key: key); final BookModule book; @override Widget build(BuildContext context) { return Row( children: [ Container( width: 75, height: 135, margin: const EdgeInsets.only(top: 10), decoration: BoxDecoration( borderRadius: BorderRadius.circular(6), image: DecorationImage( fit: BoxFit.fill, image: NetworkImage( book.imageBook, ), ), ), ), const SizedBox( width: 20, ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( book.nameBook.value, style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), const SizedBox( height: 12, ), Text(book.authorBook.value), const SizedBox( height: 5, ), Text( '\$${book.priceBook.value}', style: const TextStyle(fontWeight: FontWeight.bold), ), const SizedBox(), Row( children: List.generate(5, (index) { return Icon( index < 4 ? Icons.star : Icons.star_border, color: Colors.yellow, ); }), ), ], )), Obx(() { return IconButton( onPressed: () { (book.isSaving.value == true) ? book.isSaving.value = false : book.isSavingChanged(); }, icon: (book.isSaving.value == false) ? const Icon(Icons.bookmark_border_outlined) : const Icon(Icons.bookmark), ); }), const SizedBox( width: 10, ) ], ); } } \ No newline at end of file diff --git a/lib/page_main/list_books.dart b/lib/page_main/list_books.dart new file mode 100644 index 0000000..3fe06d7 --- /dev/null +++ b/lib/page_main/list_books.dart @@ -0,0 +1 @@ +import 'package:book_store_app/modules/book_module.dart'; import 'package:book_store_app/page_description/book_info.dart'; import 'package:book_store_app/page_main/list_book_layout.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class ListBooks extends StatelessWidget { const ListBooks({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Expanded( child: Obx(() { return Padding( padding: const EdgeInsets.only(left: 20), child: ListView( scrollDirection: Axis.vertical, shrinkWrap: true, children: BookModule.books .map( (e) => GestureDetector( onTap: () { Get.to(() => BookInfo(book: e)); }, child: ListBookLayout(book: e), ), ) .toList(), ), ); }), ); } } \ No newline at end of file diff --git a/lib/page_main/main_appbar.dart b/lib/page_main/main_appbar.dart new file mode 100644 index 0000000..4a7ac2e --- /dev/null +++ b/lib/page_main/main_appbar.dart @@ -0,0 +1 @@ +import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class AppBarMain extends StatelessWidget implements PreferredSizeWidget { const AppBarMain({Key? key}) : super(key: key); @override // TODO: implement preferredSize Size get preferredSize => const Size.fromHeight(50); @override Widget build(BuildContext context) { return AppBar( systemOverlayStyle: const SystemUiOverlayStyle( statusBarColor: Colors.transparent, statusBarIconBrightness: Brightness.dark), backgroundColor: Colors.white, elevation: 0, leading: Container( margin: const EdgeInsets.only( left: 10, top: 3, bottom: 3, ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), image: const DecorationImage( fit: BoxFit.fill, image: NetworkImage( 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTE9gCgTvs1TnWOt9Y1Q83CchVzZxz4e-0n1A&usqp=CAU', ), ), ), ), title: const Text( 'Hi,Hasan !', style: TextStyle(color: Colors.black), ), actions: const [ Padding( padding: EdgeInsets.only(right: 15), child: Icon( Icons.more_vert, color: Colors.black, ), ) ], ) ; } } \ No newline at end of file diff --git a/lib/page_main/main_page.dart b/lib/page_main/main_page.dart new file mode 100644 index 0000000..a8becf9 --- /dev/null +++ b/lib/page_main/main_page.dart @@ -0,0 +1 @@ +import 'package:book_store_app/modules/book_module.dart'; import 'package:book_store_app/page_main/list_books.dart'; import 'package:book_store_app/page_main/main_appbar.dart'; import 'package:book_store_app/page_main/navigation_buttons.dart'; import 'package:book_store_app/page_main/search_field.dart'; import 'package:book_store_app/page_main/search_list.dart'; import 'package:book_store_app/page_main/title_page.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class MainPage extends StatelessWidget { const MainPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: const AppBarMain(), backgroundColor: Colors.white, body: Obx(() { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SearchField(), TitlePage( title: (BookModule.isSearch.value == false) ? 'Books List' : 'Result'), (BookModule.isSearch.value == false) ? const ListBooks() : const SearchList(), ], ); }), extendBody: true, bottomNavigationBar: const NavigationButton(), ); } } \ No newline at end of file diff --git a/lib/page_main/navigation_buttons.dart b/lib/page_main/navigation_buttons.dart new file mode 100644 index 0000000..d397856 --- /dev/null +++ b/lib/page_main/navigation_buttons.dart @@ -0,0 +1 @@ +import 'package:book_store_app/main.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class NavigationButton extends StatelessWidget { const NavigationButton({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.only(bottom: 25, left: 85, right: 85), child: Container( width: 200, height: 55, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.5), spreadRadius: 1, blurRadius: 9, offset: const Offset(0, 6), // changes position of shadow ), ]), child: Obx(() { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ IconButton( onPressed: () { MyApp.controllerPage.animateToPage( 0, duration: const Duration(milliseconds: 200), curve: Curves.linear, ); }, icon: (MyApp.currentPage.value == 0) ? const Icon( Icons.home_outlined, size: 30, color: Colors.blue, ) : const Icon(Icons.home_outlined), ), IconButton( onPressed: () { MyApp.controllerPage.animateToPage( 1, duration: const Duration(milliseconds: 200), curve: Curves.linear, ); }, icon: (MyApp.currentPage.value == 1) ? const Icon( Icons.shopping_cart_outlined, size: 30, color: Colors.blue, ) : const Icon(Icons.shopping_cart_outlined), ), IconButton( onPressed: () { MyApp.controllerPage.animateToPage( 2, duration: const Duration(milliseconds: 200), curve: Curves.linear, ); }, icon: (MyApp.currentPage.value == 2) ? const Icon( Icons.bookmark, size: 30, color: Colors.blue, ) : const Icon(Icons.bookmark), ), IconButton( onPressed: () { MyApp.controllerPage.animateToPage( 3, duration: const Duration(milliseconds: 200), curve: Curves.linear, ); }, icon: (MyApp.currentPage.value == 3) ? const Icon( Icons.add, size: 30, color: Colors.blue, ) : const Icon(Icons.add), ), ], ); }), ), ); } } \ No newline at end of file diff --git a/lib/page_main/search_field.dart b/lib/page_main/search_field.dart new file mode 100644 index 0000000..67c199c --- /dev/null +++ b/lib/page_main/search_field.dart @@ -0,0 +1 @@ +import 'package:book_store_app/modules/book_module.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class SearchField extends StatelessWidget { SearchField({Key? key}) : super(key: key); final TextEditingController controllerSearch = TextEditingController(); @override Widget build(BuildContext context) { return Container( height: 50, margin: const EdgeInsets.only(top: 15, right: 25, left: 25), decoration: BoxDecoration(boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.3), spreadRadius: 1, blurRadius: 9, offset: const Offset(0, 6), // changes position of shadow ), ]), child: TextField( controller: controllerSearch, style: const TextStyle( fontSize: 18, ), decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: BorderSide.none, ), suffixIcon: IconButton( onPressed: () { BookModule.search.value=controllerSearch.text; (BookModule.isSearch.value == true) ? BookModule.isSearch.value = false : BookModule.isSearchChanged(); }, icon: const Icon(Icons.search_rounded), iconSize: 35, ), filled: true, fillColor: Colors.white, hintText: 'Search...', contentPadding: const EdgeInsets.only(left: 14.0, bottom: 8.0, top: 8.0), hintStyle: const TextStyle( color: Colors.grey, fontSize: 20, fontStyle: FontStyle.italic, ), ), ), ); } } \ No newline at end of file diff --git a/lib/page_main/search_list.dart b/lib/page_main/search_list.dart new file mode 100644 index 0000000..8db0843 --- /dev/null +++ b/lib/page_main/search_list.dart @@ -0,0 +1 @@ +import 'package:book_store_app/modules/book_module.dart'; import 'package:book_store_app/page_description/book_info.dart'; import 'package:book_store_app/page_main/list_book_layout.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class SearchList extends StatelessWidget { const SearchList({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Expanded( child: Obx(() { return Padding( padding: const EdgeInsets.only(left: 20), child: ListView( scrollDirection: Axis.vertical, shrinkWrap: true, children: BookModule.books .where( (e) => e.nameBook.value.toLowerCase().contains(BookModule.search) == true) .map( (e) => GestureDetector( onTap: () { Get.to(() => BookInfo(book: e)); }, child: ListBookLayout(book: e), ), ) .toList(), ), ); }), ); } } \ No newline at end of file diff --git a/lib/page_main/title_page.dart b/lib/page_main/title_page.dart new file mode 100644 index 0000000..1e8747c --- /dev/null +++ b/lib/page_main/title_page.dart @@ -0,0 +1 @@ +import 'package:flutter/material.dart'; class TitlePage extends StatelessWidget { const TitlePage({Key? key, required this.title}) : super(key: key); final String title; @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.only( top: 15, bottom: 15, left: 30, ), child: Text( title, style: const TextStyle( fontSize: 28, fontWeight: FontWeight.bold, ), ), ); } } \ No newline at end of file diff --git a/lib/page_save/list_save.dart b/lib/page_save/list_save.dart new file mode 100644 index 0000000..dab6992 --- /dev/null +++ b/lib/page_save/list_save.dart @@ -0,0 +1 @@ +import 'package:book_store_app/modules/book_module.dart'; import 'package:book_store_app/page_description/book_info.dart'; import 'package:book_store_app/page_main/list_book_layout.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; class ListSave extends StatelessWidget { const ListSave({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Expanded( child: Obx(() { return Padding( padding: const EdgeInsets.only(left: 20), child: ListView( scrollDirection: Axis.vertical, shrinkWrap: true, children: BookModule.books .where((e) => e.isSaving.value) .map((e) => GestureDetector( onTap: () { Get.to(BookInfo(book: e)); }, child: ListBookLayout(book: e), )) .toList(), ), ); }), ); } } \ No newline at end of file diff --git a/lib/page_save/save_page.dart b/lib/page_save/save_page.dart new file mode 100644 index 0000000..7607fbf --- /dev/null +++ b/lib/page_save/save_page.dart @@ -0,0 +1 @@ +import 'package:book_store_app/page_description/custom_appbar.dart'; import 'package:book_store_app/page_main/title_page.dart'; import 'package:flutter/material.dart'; import '../page_main/navigation_buttons.dart'; import 'list_save.dart'; class SavePage extends StatelessWidget { const SavePage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: const CustomAppBar(), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: const [ TitlePage(title: 'Saved'), ListSave(), ], ), extendBody: true, bottomNavigationBar: const NavigationButton(), ); } } \ No newline at end of file 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..89111a9 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: any dev_dependencies: flutter_test: