diff --git a/README.md b/README.md index 037e2ef..6877c70 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,9 @@ -# Task 3 - Book Store App +## Task 3 - Book Store App -Task resolution process: + -- Fork the repo -- Clone the forked repo to your local machine -- Resolve the task -- Commit your solution -- Push to GitHub -- create a pull request + + - -### Task 3: -Build a book store mobile application. The store contain a list of available books with the ability to add custom books to the store as well as view, order them. - -* Don't use pre-made widgets (packges). -* It's ok to use icons packages. -* Use Getx for state management. - -## UI -### Main Page -The main page should contain a list of the available books. When tapping on a book, the second page (Book Details Page) will be navigated. Use Scrollable view for the list of books. ALso there is a simple search on the top of the page. - - -### Cart Page (Optional) -This page can view the ordered books. - -### Details Page -This have the details of the book which is: -- Book name -- Author -- Desciption -- Image -- Rate (constant) - -### Add Page -It is the page where you can add new books to the store. - -## FLow -1. Build the UI (from figma design). -2. seperate the widgets to small and organized files. -3. Build models that contain the book data (You can build one model or more). -4. Try to seperate the logic (Functions and data) from the UI. - -## Figma Design -https://www.figma.com/file/4BGkiFfTPT7b8K9pyFTBD6/Online-Book-Store-App-(2019)-(Community)?node-id=0%3A1 + diff --git a/assets/fonts/Poppins/OFL.txt b/assets/fonts/Poppins/OFL.txt new file mode 100644 index 0000000..246c977 --- /dev/null +++ b/assets/fonts/Poppins/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2020 The Poppins Project Authors (https://github.com/itfoundry/Poppins) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/assets/fonts/Poppins/Poppins-Black.ttf b/assets/fonts/Poppins/Poppins-Black.ttf new file mode 100644 index 0000000..71c0f99 Binary files /dev/null and b/assets/fonts/Poppins/Poppins-Black.ttf differ diff --git a/assets/fonts/Poppins/Poppins-BlackItalic.ttf b/assets/fonts/Poppins/Poppins-BlackItalic.ttf new file mode 100644 index 0000000..7aeb58b Binary files /dev/null and b/assets/fonts/Poppins/Poppins-BlackItalic.ttf differ diff --git a/assets/fonts/Poppins/Poppins-Bold.ttf b/assets/fonts/Poppins/Poppins-Bold.ttf new file mode 100644 index 0000000..00559ee Binary files /dev/null and b/assets/fonts/Poppins/Poppins-Bold.ttf differ diff --git a/assets/fonts/Poppins/Poppins-BoldItalic.ttf b/assets/fonts/Poppins/Poppins-BoldItalic.ttf new file mode 100644 index 0000000..e61e8e8 Binary files /dev/null and b/assets/fonts/Poppins/Poppins-BoldItalic.ttf differ diff --git a/assets/fonts/Poppins/Poppins-ExtraBold.ttf b/assets/fonts/Poppins/Poppins-ExtraBold.ttf new file mode 100644 index 0000000..df70936 Binary files /dev/null and b/assets/fonts/Poppins/Poppins-ExtraBold.ttf differ diff --git a/assets/fonts/Poppins/Poppins-ExtraBoldItalic.ttf b/assets/fonts/Poppins/Poppins-ExtraBoldItalic.ttf new file mode 100644 index 0000000..14d2b37 Binary files /dev/null and b/assets/fonts/Poppins/Poppins-ExtraBoldItalic.ttf differ diff --git a/assets/fonts/Poppins/Poppins-ExtraLight.ttf b/assets/fonts/Poppins/Poppins-ExtraLight.ttf new file mode 100644 index 0000000..e76ec69 Binary files /dev/null and b/assets/fonts/Poppins/Poppins-ExtraLight.ttf differ diff --git a/assets/fonts/Poppins/Poppins-ExtraLightItalic.ttf b/assets/fonts/Poppins/Poppins-ExtraLightItalic.ttf new file mode 100644 index 0000000..89513d9 Binary files /dev/null and b/assets/fonts/Poppins/Poppins-ExtraLightItalic.ttf differ diff --git a/assets/fonts/Poppins/Poppins-Italic.ttf b/assets/fonts/Poppins/Poppins-Italic.ttf new file mode 100644 index 0000000..12b7b3c Binary files /dev/null and b/assets/fonts/Poppins/Poppins-Italic.ttf differ diff --git a/assets/fonts/Poppins/Poppins-Light.ttf b/assets/fonts/Poppins/Poppins-Light.ttf new file mode 100644 index 0000000..bc36bcc Binary files /dev/null and b/assets/fonts/Poppins/Poppins-Light.ttf differ diff --git a/assets/fonts/Poppins/Poppins-LightItalic.ttf b/assets/fonts/Poppins/Poppins-LightItalic.ttf new file mode 100644 index 0000000..9e70be6 Binary files /dev/null and b/assets/fonts/Poppins/Poppins-LightItalic.ttf differ diff --git a/assets/fonts/Poppins/Poppins-Medium.ttf b/assets/fonts/Poppins/Poppins-Medium.ttf new file mode 100644 index 0000000..6bcdcc2 Binary files /dev/null and b/assets/fonts/Poppins/Poppins-Medium.ttf differ diff --git a/assets/fonts/Poppins/Poppins-MediumItalic.ttf b/assets/fonts/Poppins/Poppins-MediumItalic.ttf new file mode 100644 index 0000000..be67410 Binary files /dev/null and b/assets/fonts/Poppins/Poppins-MediumItalic.ttf differ diff --git a/assets/fonts/Poppins/Poppins-Regular.ttf b/assets/fonts/Poppins/Poppins-Regular.ttf new file mode 100644 index 0000000..9f0c71b Binary files /dev/null and b/assets/fonts/Poppins/Poppins-Regular.ttf differ diff --git a/assets/fonts/Poppins/Poppins-SemiBold.ttf b/assets/fonts/Poppins/Poppins-SemiBold.ttf new file mode 100644 index 0000000..74c726e Binary files /dev/null and b/assets/fonts/Poppins/Poppins-SemiBold.ttf differ diff --git a/assets/fonts/Poppins/Poppins-SemiBoldItalic.ttf b/assets/fonts/Poppins/Poppins-SemiBoldItalic.ttf new file mode 100644 index 0000000..3e6c942 Binary files /dev/null and b/assets/fonts/Poppins/Poppins-SemiBoldItalic.ttf differ diff --git a/assets/fonts/Poppins/Poppins-Thin.ttf b/assets/fonts/Poppins/Poppins-Thin.ttf new file mode 100644 index 0000000..03e7366 Binary files /dev/null and b/assets/fonts/Poppins/Poppins-Thin.ttf differ diff --git a/assets/fonts/Poppins/Poppins-ThinItalic.ttf b/assets/fonts/Poppins/Poppins-ThinItalic.ttf new file mode 100644 index 0000000..e26db5d Binary files /dev/null and b/assets/fonts/Poppins/Poppins-ThinItalic.ttf differ diff --git a/assets/images/book_1.jpg b/assets/images/book_1.jpg new file mode 100644 index 0000000..c16ee91 Binary files /dev/null and b/assets/images/book_1.jpg differ diff --git a/assets/images/book_2.jpg b/assets/images/book_2.jpg new file mode 100644 index 0000000..3a819bb Binary files /dev/null and b/assets/images/book_2.jpg differ diff --git a/assets/images/book_3.jpg b/assets/images/book_3.jpg new file mode 100644 index 0000000..20f7a3d Binary files /dev/null and b/assets/images/book_3.jpg differ diff --git a/assets/images/book_4.jpg b/assets/images/book_4.jpg new file mode 100644 index 0000000..ab92eb6 Binary files /dev/null and b/assets/images/book_4.jpg differ diff --git a/assets/images/person.png b/assets/images/person.png new file mode 100644 index 0000000..5b3e321 Binary files /dev/null and b/assets/images/person.png differ diff --git a/assets/images/preview_icon.svg b/assets/images/preview_icon.svg new file mode 100644 index 0000000..9235d82 --- /dev/null +++ b/assets/images/preview_icon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/images/reviews_icon.svg b/assets/images/reviews_icon.svg new file mode 100644 index 0000000..acdc168 --- /dev/null +++ b/assets/images/reviews_icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/search.svg b/assets/images/search.svg new file mode 100644 index 0000000..b7e87e2 --- /dev/null +++ b/assets/images/search.svg @@ -0,0 +1,3 @@ + + + diff --git a/lib/controllers/book_controller.dart b/lib/controllers/book_controller.dart new file mode 100644 index 0000000..3f58e71 --- /dev/null +++ b/lib/controllers/book_controller.dart @@ -0,0 +1,100 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../models/book.dart'; +import '../models/data.dart'; +import '../style.dart'; +import '../views/screens/cart_page.dart'; +import '../views/screens/home_page.dart'; + +class BookController extends GetxController { + RxString searchResult = ('').obs; + String currentPage = 'home page'; + + void successfulBookPurchase(BuildContext context) => Get.snackbar( + 'Successful the book purchase', + 'Go to cart page to view your purchases', + icon: const Icon(CupertinoIcons.shopping_cart), + onTap: (GetSnackBar snackBar) { + Get.closeAllSnackbars(); + Get.to(const CartPage()); + }, + ); + + void addBookSnackBar(BuildContext context, bool isSuccessfulAdd) => Get.snackbar( + isSuccessfulAdd ? 'The book has been successfully added' : 'Failed to add book', + isSuccessfulAdd ? 'Go to the home page to view the book added' : 'You have entered invalid data, please fill in the fields with valid data', + icon: const Icon(CupertinoIcons.add), + onTap: (GetSnackBar snackBar) { + if (isSuccessfulAdd) { + Get.closeAllSnackbars(); + Get.to(const HomePage()); + } + }, + ); + + String get getHeaderText => searchResult.isNotEmpty ? 'Result' : 'Book List'; + Color get getSVGSearchColor => searchResult.isNotEmpty ? blue : hintTextColor; + + bool isBookStoreEmpty() => Data.books.isEmpty; + bool isNotFoundBooks() => filterBooks(searchResult.value).isEmpty; + bool isPurchasedBooksEmpty() => Data.purchasedBooks.isEmpty; + bool isFieldsEmpty(Map map) { + bool isInvaild = false; + for(String value in map.values){ + if(value.contains(',')) isInvaild = true; + } + return map.containsValue('') || isInvaild; + } + + void buyBook(Book book) => Data.purchasedBooks.add(book); + double getCorrectRating(double rating) { + String rate = rating.toString(); + return double.parse(rate.substring(rate.length - 1, rate.length)) < 5 + ? double.parse(rate.substring(0, 1)) + : double.parse('${rate.substring(0, 1)}.5'); + } + + void addBook(Map newBook) { + double rating = getCorrectRating(double.parse(newBook['rating'].toString())); + Data.books.add(Book( + name: newBook['name'].toString(), + author: newBook['author'].toString(), + image: newBook['image'].toString(), + description: newBook['description'].toString(), + price: double.parse(newBook['price'].toString()), + rating: rating > 5 ? 5 : rating, + )); + } + + Color iconcolorCurrentPage(String currentPage) { + return currentPage == this.currentPage ? black : unselectedIconColor; + } + + List filterBooks(String nameBook) { + if (searchResult.isEmpty) return Data.books; + return Data.books + .where((e) => e.name.toLowerCase().contains(nameBook)) + .toList(); + } + + List getBookRating(double rating) { + List icons = []; + + for (int i = 0; i < 5; i++) { + icons.add( + Icon( + (rating-- >= 1.0) + ? (Icons.star) + : (rating == 0.5 || rating == -0.5 + ? Icons.star_half + : Icons.star), + color: rating + 1 > 0 ? (iconsColor) : halfIconColor, + size: 14, + ), + ); + } + return icons; + } +} diff --git a/lib/main.dart b/lib/main.dart index bcc58f7..cce53fc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,18 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:get/get.dart'; + +import 'controllers/book_controller.dart'; +import 'views/screens/home_page.dart'; void main() { + SystemChrome.setSystemUIOverlayStyle( + const SystemUiOverlayStyle( + statusBarColor: Colors.transparent, + statusBarIconBrightness: Brightness.dark, + ), + ); + runApp(const MyApp()); } @@ -9,12 +21,11 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return const MaterialApp( - home: Scaffold( - body: Center( - child: Text("Book Store App"), - ), - ), + Get.put(BookController()); + return const GetMaterialApp( + title: 'Book Store', + debugShowCheckedModeBanner: false, + home: HomePage(), ); } } diff --git a/lib/models/book.dart b/lib/models/book.dart new file mode 100644 index 0000000..70c8b9b --- /dev/null +++ b/lib/models/book.dart @@ -0,0 +1,14 @@ +class Book { + String name, author, image, description; + double price, rating; + + Book({ + required this.name, + required this.author, + required this.image, + required this.description, + required this.price, + required this.rating, + }); + +} diff --git a/lib/models/data.dart b/lib/models/data.dart new file mode 100644 index 0000000..44e7fa3 --- /dev/null +++ b/lib/models/data.dart @@ -0,0 +1,42 @@ +import 'package:get/get.dart'; + +import 'book.dart'; + +class Data{ + static RxList books = [ + Book( + name: 'Life A COMPILATION OF SHORT STORIES AND POETRY', + author: 'ZOE DAVIS', + image: 'assets/images/book_1.jpg', + description: 'Sit cillum aliqua in velit dolore nulla id ullamco occaecat exercitation quis laborum minim. Ea nulla occaecat do duis id et nulla aute officia enim tempor elit. Consequat ea ullamco sit proident sit sit do ea nulla veniam Lorem id. Irure in sint fugiat aliquip. Tempor qui aute quis tempor occaecat nulla id irure minim aute aute dolore esse. Sunt ut magna mollit do duis commodo incididunt ipsum duis enim enim.', + price: 65.99, + rating: 4.5, + ), + Book( + name: 'ULTRALEARNING', + author: 'Scott H. Young', + image: 'assets/images/book_2.jpg', + description: 'Elit magna velit culpa exercitation occaecat duis in eu sit sunt. Ipsum mollit do irure id. Incididunt occaecat nisi veniam occaecat do eiusmod sit.', + price: 69.99, + rating: 5.0, + ), + Book( + name: 'THE PROPHET', + author: 'Kahlil Gibran', + image: 'assets/images/book_3.jpg', + description: 'Duis consequat elit reprehenderit Lorem consequat in esse elit pariatur ut officia id sit sunt. Sit magna voluptate quis sunt ad adipisicing irure labore pariatur Lorem do minim proident irure. Ad quis excepteur ut ea sint ullamco quis nulla proident voluptate laboris. Dolore cupidatat sint nisi sint enim aute amet officia aute.', + price: 44.99, + rating: 4.0, + ), + Book( + name: 'THE POWER OF HABIT', + author: 'Charles Duhigg', + image: 'assets/images/book_4.jpg', + description: 'Et ea dolore proident officia ea elit ea sunt ut ullamco consectetur incididunt. Lorem dolor Lorem nostrud Lorem. In esse deserunt sunt dolore sit dolore est reprehenderit nostrud et. Eu enim ea mollit anim. Veniam aute sunt sunt est commodo fugiat ullamco labore mollit est.', + price: 89.99, + rating: 4.5, + ), + ].obs; + + static RxList purchasedBooks = [].obs; +} \ No newline at end of file diff --git a/lib/style.dart b/lib/style.dart new file mode 100644 index 0000000..8361647 --- /dev/null +++ b/lib/style.dart @@ -0,0 +1,51 @@ +import 'package:flutter/material.dart'; + +const Color white = Colors.white; +const Color black = Colors.black; +const Color blue = Colors.blue; +const Color iconsColor = Color(0xffFFC41F); +const Color hintTextColor = Color(0xff84889E); +const Color halfIconColor = Color(0xffEDEDEF); +const Color unselectedIconColor = Color(0xff9C9EA8); +const Color shadowColor = Color.fromRGBO(7, 8, 14, 0.05); + + +const TextStyle nameUserTextStyle = TextStyle( + color: black, + fontSize: 14, + fontWeight: FontWeight.w600, + fontFamily: 'Poppins-Regular', + fontStyle: FontStyle.normal, +); + +const TextStyle hintTextStyle = TextStyle( + color: hintTextColor, + fontSize: 16, + fontWeight: FontWeight.w400, + fontFamily: 'Poppins', + fontStyle: FontStyle.normal, +); + +const TextStyle headerTextStyle = TextStyle( + color: black, + fontSize: 24, + fontWeight: FontWeight.w600, + fontFamily: 'Poppins', + fontStyle: FontStyle.normal, +); + +const TextStyle titleTextStyle = TextStyle( + color: black, + fontSize: 14, + fontWeight: FontWeight.w500, + fontFamily: 'Poppins', + fontStyle: FontStyle.normal, +); + +const TextStyle buyButtonTextStyle = TextStyle( + color: white, + fontSize: 16, + fontWeight: FontWeight.w500, + fontFamily: 'Poppins', + fontStyle: FontStyle.normal, +); diff --git a/lib/views/screens/add_page.dart b/lib/views/screens/add_page.dart new file mode 100644 index 0000000..a770c50 --- /dev/null +++ b/lib/views/screens/add_page.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../controllers/book_controller.dart'; +import '../../style.dart'; +import '../widgets/add_page/add_new_book.dart'; +import '../widgets/custom_app_bar.dart'; + +class AddPage extends StatefulWidget { + const AddPage({Key? key}) : super(key: key); + + @override + State createState() => _AddPageState(); +} + +class _AddPageState extends State { + late final BookController bookController; + + @override + void initState() { + super.initState(); + bookController = Get.find(); + bookController.currentPage = 'add page'; + } + + // @override + // void dispose() { + // bookController.dispose(); + // super.dispose(); + // } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: white, + appBar: const CoustomAppBar(), + body: SizedBox( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + child: SingleChildScrollView( + physics: const ScrollPhysics(), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: const [ + AddNewBook(), + ], + ), + ), + ), + ); + } +} diff --git a/lib/views/screens/cart_page.dart b/lib/views/screens/cart_page.dart new file mode 100644 index 0000000..d20373e --- /dev/null +++ b/lib/views/screens/cart_page.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../controllers/book_controller.dart'; +import '../../style.dart'; +import '../widgets/cart_page/purchased_list.dart'; +import '../widgets/custom_app_bar.dart'; +import '../widgets/custom_bottom_navigation_bar.dart'; + +class CartPage extends StatefulWidget { + const CartPage({Key? key}) : super(key: key); + + @override + State createState() => _CartPageState(); +} + +class _CartPageState extends State { + late final BookController bookController; + + @override + void initState() { + super.initState(); + bookController = Get.find(); + bookController.currentPage = 'cart page'; + } + + // @override + // void dispose() { + // bookController.dispose(); + // super.dispose(); + // } + + @override + Widget build(BuildContext context) { + return Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: white, + appBar: const CoustomAppBar(), + body: SizedBox( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + child: SingleChildScrollView( + physics: const ScrollPhysics(), + child: Column( + children: const [ + PurchasedList(), + SizedBox(height: 88), + ], + ), + ), + ), + floatingActionButton: const CustomBottomNavigationBar(), + floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, + ); + } +} diff --git a/lib/views/screens/details_page.dart b/lib/views/screens/details_page.dart new file mode 100644 index 0000000..bf2dfc1 --- /dev/null +++ b/lib/views/screens/details_page.dart @@ -0,0 +1,37 @@ +import 'package:flutter/material.dart'; + +import '../../models/book.dart'; +import '../../style.dart'; +import '../widgets/custom_app_bar.dart'; +import '../widgets/details_page/all_deatails.dart'; +import '../widgets/details_page/book_photo.dart'; + +class DetailsPage extends StatelessWidget { + const DetailsPage({Key? key, required this.book}) : super(key: key); + + final Book book; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: white, + appBar: const CoustomAppBar(), + body: Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + color: white, + child: SingleChildScrollView( + physics: const ScrollPhysics(), + child: Column( + children: [ + const SizedBox(height: 12), + BookPhoto(image: book.image), + AllDetails(book: book), + const SizedBox(height: 12), + ], + ), + ), + ), + ); + } +} diff --git a/lib/views/screens/home_page.dart b/lib/views/screens/home_page.dart new file mode 100644 index 0000000..5a063a0 --- /dev/null +++ b/lib/views/screens/home_page.dart @@ -0,0 +1,70 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../controllers/book_controller.dart'; +import '../../style.dart'; +import '../widgets/custom_bottom_navigation_bar.dart'; +import '../widgets/home_page/book_list.dart'; +import '../widgets/home_page/search_field.dart'; +import '../widgets/home_page/user_account.dart'; + +class HomePage extends StatefulWidget { + const HomePage({Key? key}) : super(key: key); + + @override + State createState() => _HomePageState(); +} + +class _HomePageState extends State { + late final BookController bookController; + + @override + void initState() { + super.initState(); + bookController = Get.find(); + bookController.currentPage = 'home page'; + } + + // @override + // void dispose() { + // super.dispose(); + // bookController.dispose(); + // } + + @override + Widget build(BuildContext context) { + return Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: white, + appBar: AppBar( + backgroundColor: white, + leadingWidth: 132, + leading: const UserAccount(), + actions: [ + IconButton( + onPressed: () {}, + icon: const Icon(Icons.more_vert), + color: black, + splashRadius: 20, + ), + ], + toolbarHeight: 64, + elevation: 0, + ), + body: SizedBox( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + child: ListView( + physics: const ScrollPhysics(), + children: const [ + SearchField(), + BookList(), + SizedBox(height: 88), + ], + ), + ), + floatingActionButton: const CustomBottomNavigationBar(), + floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, + ); + } +} diff --git a/lib/views/widgets/add_page/add_new_book.dart b/lib/views/widgets/add_page/add_new_book.dart new file mode 100644 index 0000000..e45e74e --- /dev/null +++ b/lib/views/widgets/add_page/add_new_book.dart @@ -0,0 +1,136 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../../controllers/book_controller.dart'; +import '../../../style.dart'; +import '../primary_button.dart'; +import 'custom_text_field.dart'; + +class AddNewBook extends StatefulWidget { + const AddNewBook({Key? key}) : super(key: key); + + @override + State createState() => _AddNewBookState(); +} + +class _AddNewBookState extends State { + late BookController bookController; + late TextEditingController nameBookController, + authorBookController, + priceBookController, + ratingBookController, + imageBookController, + descripationBookController; + + @override + void initState() { + super.initState(); + bookController = Get.find(); + nameBookController = TextEditingController(); + authorBookController = TextEditingController(); + priceBookController = TextEditingController(); + ratingBookController = TextEditingController(); + imageBookController = TextEditingController(); + descripationBookController = TextEditingController(); + } + + @override + void dispose() { + nameBookController.dispose(); + authorBookController.dispose(); + priceBookController.dispose(); + ratingBookController.dispose(); + imageBookController.dispose(); + descripationBookController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + List> fields = [ + { + 'hintText': 'Book Name', + 'controller': nameBookController, + 'isDescription': false, + 'isTextInput': true, + }, + { + 'hintText': 'Author Name', + 'controller': authorBookController, + 'isDescription': false, + 'isTextInput': true, + }, + { + 'hintText': 'Price', + 'controller': priceBookController, + 'isDescription': false, + 'isTextInput': false, + }, + { + 'hintText': 'Rating', + 'controller': ratingBookController, + 'isDescription': false, + 'isTextInput': false, + }, + { + 'hintText': 'Image link', + 'controller': imageBookController, + 'isDescription': false, + 'isTextInput': true, + }, + { + 'hintText': 'Descripation', + 'controller': descripationBookController, + 'isDescription': true, + 'isTextInput': true, + }, + ]; + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 34, top: 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Add Book', style: headerTextStyle), + const SizedBox(height: 40), + ...fields + .map( + (e) => CustomTextField( + hintText: e['hintText'], + controller: e['controller'], + isDescription: e['isDescription'], + isTextInput: e['isTextInput'], + ), + ) + .toList(), + ], + ), + ), + PrimaryButton( + text: 'Add', + padding: 45, + onPressed: () { + Map map = { + 'name': nameBookController.text, + 'author': authorBookController.text, + 'image': imageBookController.text, + 'description': descripationBookController.text, + 'price': priceBookController.text, + 'rating': ratingBookController.text, + }; + + if (bookController.isFieldsEmpty(map)) { + bookController.addBookSnackBar(context, false); + } else { + bookController.addBook(map); + bookController.addBookSnackBar(context, true); + } + }, + ), + ], + ); + } +} diff --git a/lib/views/widgets/add_page/custom_text_field.dart b/lib/views/widgets/add_page/custom_text_field.dart new file mode 100644 index 0000000..dc24e75 --- /dev/null +++ b/lib/views/widgets/add_page/custom_text_field.dart @@ -0,0 +1,49 @@ +import 'package:flutter/material.dart'; + +import '../../../style.dart'; + +class CustomTextField extends StatelessWidget { + const CustomTextField({ + Key? key, + required this.controller, + required this.hintText, + this.isDescription = false, + this.isTextInput = true, + }) : super(key: key); + + final TextEditingController controller; + final String hintText; + final bool? isDescription, isTextInput; + + @override + Widget build(BuildContext context) { + return Container( + alignment: Alignment.center, + padding: EdgeInsets.only(left: 17, top: 18, bottom: isDescription! ? 88 : 4), + margin: const EdgeInsets.only(left: 9, right: 45, bottom: 22), + height: isDescription! ? 139 : 53, + width: double.infinity, + decoration: BoxDecoration( + color: white, + borderRadius: BorderRadius.circular(8), + boxShadow: const [ + BoxShadow( + color: shadowColor, + offset: Offset(0, 8), + blurRadius: 24, + spreadRadius: 12, + ), + ], + ), + child: TextField( + keyboardType: isTextInput! ? TextInputType.text : TextInputType.number, + controller: controller, + decoration: InputDecoration( + hintText: hintText, + hintStyle: hintTextStyle, + border: InputBorder.none, + ), + ), + ); + } +} diff --git a/lib/views/widgets/book_rating.dart b/lib/views/widgets/book_rating.dart new file mode 100644 index 0000000..3a18321 --- /dev/null +++ b/lib/views/widgets/book_rating.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../controllers/book_controller.dart'; + +class BookRating extends StatelessWidget { + const BookRating({Key? key, required this.rating}) : super(key: key); + + final double rating; + @override + Widget build(BuildContext context) { + final BookController bookController = Get.find(); + return Row(children: bookController.getBookRating(rating)); + } +} diff --git a/lib/views/widgets/cart_page/purchased_list.dart b/lib/views/widgets/cart_page/purchased_list.dart new file mode 100644 index 0000000..37fd9ba --- /dev/null +++ b/lib/views/widgets/cart_page/purchased_list.dart @@ -0,0 +1,36 @@ +import 'package:flutter/cupertino.dart'; +import 'package:get/get.dart'; + +import '../../../controllers/book_controller.dart'; +import '../../../models/data.dart'; +import '../../../style.dart'; +import '../empty_book_store.dart'; +import '../home_page/book_details.dart'; + +class PurchasedList extends StatelessWidget { + const PurchasedList({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final BookController bookController = Get.find(); + + return Padding( + padding: const EdgeInsets.only(left: 34, top: 20), + child: Obx( + () => Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Cart', style: headerTextStyle), + const SizedBox(height: 48), + bookController.isPurchasedBooksEmpty() + ? const EmptyBookStore( + text: 'You don\'t have any purchases', + icon: CupertinoIcons.shopping_cart, + ):const SizedBox(), + ...Data.purchasedBooks.map((e) => BookDetails(book: e)), + ], + ), + ), + ); + } +} diff --git a/lib/views/widgets/custom_app_bar.dart b/lib/views/widgets/custom_app_bar.dart new file mode 100644 index 0000000..c586dbb --- /dev/null +++ b/lib/views/widgets/custom_app_bar.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../style.dart'; + +class CoustomAppBar extends StatelessWidget implements PreferredSizeWidget { + const CoustomAppBar({Key? key}) : super(key: key); + + @override + Size get preferredSize => const Size.fromHeight(56); + + @override + Widget build(BuildContext context) { + return AppBar( + backgroundColor: white, + leading: IconButton( + onPressed: () => Get.back(), + icon: const Icon(Icons.arrow_back_ios_new, color: black, size: 20), + splashRadius: 20, + ), + actions: [ + IconButton( + onPressed: () {}, + icon: const Icon(Icons.more_vert), + color: black, + splashRadius: 20, + ), + const SizedBox(width: 8), + ], + elevation: 0, + ); + } +} diff --git a/lib/views/widgets/custom_bottom_navigation_bar.dart b/lib/views/widgets/custom_bottom_navigation_bar.dart new file mode 100644 index 0000000..793ef9b --- /dev/null +++ b/lib/views/widgets/custom_bottom_navigation_bar.dart @@ -0,0 +1,66 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../controllers/book_controller.dart'; +import '../../style.dart'; +import '../screens/add_page.dart'; +import '../screens/cart_page.dart'; +import '../screens/home_page.dart'; + +class CustomBottomNavigationBar extends StatelessWidget { + const CustomBottomNavigationBar({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final BookController bookController = Get.find(); + + const List> icons = [ + { + 'page': HomePage(), + 'icon': CupertinoIcons.home, + 'namePage': 'home page', + }, + { + 'page': CartPage(), + 'icon': CupertinoIcons.shopping_cart, + 'namePage': 'cart page', + }, + { + 'page': AddPage(), + 'icon': CupertinoIcons.add, + 'namePage': 'add page', + }, + ]; + + return Container( + margin: const EdgeInsets.only(left: 56, right: 66, bottom: 20), + height: 72, + width: 227, + decoration: BoxDecoration( + color: white, + borderRadius: BorderRadius.circular(22), + boxShadow: const [ + BoxShadow( + color: shadowColor, + offset: Offset(0, 8), + blurRadius: 24, + spreadRadius: 12, + ), + ], + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: List.generate( + icons.length, + (index) => IconButton( + onPressed: () => Get.to(icons[index]['page'], preventDuplicates: true), + icon: Icon(icons[index]['icon']), + splashRadius: 24, + color: bookController.iconcolorCurrentPage(icons[index]['namePage']), + ), + ), + ), + ); + } +} diff --git a/lib/views/widgets/details_page/all_deatails.dart b/lib/views/widgets/details_page/all_deatails.dart new file mode 100644 index 0000000..be0467f --- /dev/null +++ b/lib/views/widgets/details_page/all_deatails.dart @@ -0,0 +1,115 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../../controllers/book_controller.dart'; +import '../../../models/book.dart'; +import '../../../style.dart'; +import '../book_rating.dart'; +import '../primary_button.dart'; +import 'custom_button.dart'; + +class AllDetails extends StatelessWidget { + const AllDetails({Key? key, required this.book}) : super(key: key); + + final Book book; + @override + Widget build(BuildContext context) { + BookController bookController = Get.find(); + + return Column( + children: [ + Text( + book.name, + style: headerTextStyle, + textAlign: TextAlign.center, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 4), + Text( + book.author, + style: titleTextStyle.copyWith( + color: black.withOpacity(0.5), + ), + textAlign: TextAlign.center, + ), + const SizedBox(height: 8), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + BookRating(rating: book.rating), + const SizedBox(width: 10), + Text.rich( + TextSpan( + text: '${book.rating}', + style: titleTextStyle, + children: [ + TextSpan( + text: ' / 5.0', + style: titleTextStyle.copyWith( + color: black.withOpacity(0.5), + ), + ), + ], + ), + ), + ], + ), + const SizedBox(height: 18), + Stack( + children: [ + SizedBox( + height: 96, + child: SingleChildScrollView( + physics: const ScrollPhysics(), + padding: const EdgeInsets.symmetric(horizontal: 28.0), + child: Text( + book.description, + style: titleTextStyle.copyWith( + color: black.withOpacity(0.5), + fontWeight: FontWeight.w400, + ), + ), + ), + ), + Container( + padding: const EdgeInsets.symmetric(horizontal: 28), + alignment: Alignment.bottomCenter, + height: 136, + width: double.infinity, + child: Row( + children: const [ + Flexible( + fit: FlexFit.tight, + child: CustomButton( + text: 'Preview', + icon: 'assets/images/preview_icon.svg', + ), + ), + SizedBox(width: 13), + Flexible( + fit: FlexFit.tight, + child: CustomButton( + text: 'Reviews', + icon: 'assets/images/reviews_icon.svg' + ), + ), + ], + ), + ), + ], + ), + const SizedBox(height: 36), + PrimaryButton( + text: 'Buy Now for \$${book.price}', + padding: 28, + onPressed: () { + bookController.buyBook(book); + bookController.successfulBookPurchase(context); + }, + ), + ], + ); + } +} diff --git a/lib/views/widgets/details_page/book_photo.dart b/lib/views/widgets/details_page/book_photo.dart new file mode 100644 index 0000000..13be07d --- /dev/null +++ b/lib/views/widgets/details_page/book_photo.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; + +class BookPhoto extends StatelessWidget { + const BookPhoto({Key? key, required this.image}) : super(key: key); + + final String image; + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.only(left: 91.76, right: 81.66, bottom: 22), + alignment: Alignment.center, + height: 310, + width: 201.58, + decoration: BoxDecoration( + borderRadius: const BorderRadius.only( + topRight: Radius.circular(8), + bottomRight: Radius.circular(8), + ), + image: DecorationImage( + fit: BoxFit.cover, + image: AssetImage(image), + ), + boxShadow: const [ + BoxShadow( + color: Color(0xffC7C7C7), blurRadius: 2, offset: Offset(0, 2)), + BoxShadow( + color: Color(0xffDEDEDE), blurRadius: 24, offset: Offset(0, 8)), + ], + ), + ); + } +} diff --git a/lib/views/widgets/details_page/custom_button.dart b/lib/views/widgets/details_page/custom_button.dart new file mode 100644 index 0000000..3973c40 --- /dev/null +++ b/lib/views/widgets/details_page/custom_button.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; + +import '../../../style.dart'; + +class CustomButton extends StatelessWidget { + const CustomButton({Key? key, required this.icon, required this.text}) + : super(key: key); + + final String text, icon; + @override + Widget build(BuildContext context) { + return Container( + height: 40, + width: 154, + decoration: BoxDecoration( + color: white, + borderRadius: BorderRadius.circular(8), + boxShadow: const [ + BoxShadow( + color: shadowColor, + offset: Offset(0, 8), + blurRadius: 24, + spreadRadius: 12, + ), + ], + ), + child: Material( + color: white, + borderRadius: BorderRadius.circular(8), + child: InkWell( + onTap: (){}, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset(icon), + const SizedBox(width: 8), + Text(text, style: titleTextStyle), + ], + ), + ), + ), + ); + } +} diff --git a/lib/views/widgets/empty_book_store.dart b/lib/views/widgets/empty_book_store.dart new file mode 100644 index 0000000..9497c40 --- /dev/null +++ b/lib/views/widgets/empty_book_store.dart @@ -0,0 +1,32 @@ +import 'package:flutter/cupertino.dart'; + +import '../../style.dart'; + +class EmptyBookStore extends StatelessWidget { + const EmptyBookStore({Key? key, required this.text, required this.icon}) + : super(key: key); + + final String text; + final IconData icon; + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox(height: MediaQuery.of(context).size.height / 8), + Icon(icon, size: 48), + const SizedBox(height: 16), + Text( + text, + style: nameUserTextStyle.copyWith( + fontWeight: FontWeight.w300, + ), + ), + ], + ), + ); + } +} + diff --git a/lib/views/widgets/home_page/book_details.dart b/lib/views/widgets/home_page/book_details.dart new file mode 100644 index 0000000..2e49082 --- /dev/null +++ b/lib/views/widgets/home_page/book_details.dart @@ -0,0 +1,72 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../../models/book.dart'; +import '../../../style.dart'; +import '../../screens/details_page.dart'; +import '../book_rating.dart'; + +class BookDetails extends StatelessWidget { + const BookDetails({Key? key, required this.book}) : super(key: key); + + final Book book; + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(left: 2, bottom: 23), + child: InkWell( + onTap: () => Get.to(DetailsPage(book: book)), + child: Row( + children: [ + Container( + height: 106, + width: 72, + decoration: BoxDecoration( + borderRadius: const BorderRadius.only( + topRight: Radius.circular(8), + bottomRight: Radius.circular(8), + ), + image: DecorationImage( + image: AssetImage(book.image), + ), + ), + ), + const SizedBox(width: 26), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width * 0.6, + child: Text( + book.name, + style: headerTextStyle.copyWith(fontSize: 16), + textAlign: TextAlign.left, + overflow: TextOverflow.ellipsis, + ), + ), + const SizedBox(height: 4), + Text( + book.author, + style: titleTextStyle.copyWith( + color: black.withOpacity(0.5), + fontSize: 12, + ), + textAlign: TextAlign.center, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 7), + Text( + '\$${book.price}', + style: titleTextStyle, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 8), + BookRating(rating: book.rating), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/views/widgets/home_page/book_list.dart b/lib/views/widgets/home_page/book_list.dart new file mode 100644 index 0000000..19be786 --- /dev/null +++ b/lib/views/widgets/home_page/book_list.dart @@ -0,0 +1,43 @@ +import 'package:flutter/cupertino.dart'; +import 'package:get/get.dart'; + +import '../../../controllers/book_controller.dart'; +import '../../../style.dart'; +import '../empty_book_store.dart'; +import 'book_details.dart'; + +class BookList extends StatelessWidget { + const BookList({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final BookController bookController = Get.find(); + + return Padding( + padding: const EdgeInsets.only(left: 34, top: 40), + child: Obx( + () => Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(bookController.getHeaderText, style: headerTextStyle), + const SizedBox(height: 29), + bookController.isBookStoreEmpty() + ? const EmptyBookStore( + text: 'The book store is empty', + icon: CupertinoIcons.book, + ) + : bookController.isNotFoundBooks() + ? const EmptyBookStore( + text: 'No book with this name was found', + icon: CupertinoIcons.book, + ) + : const SizedBox(), + ...bookController + .filterBooks(bookController.searchResult.value) + .map((e) => BookDetails(book: e)), + ], + ), + ), + ); + } +} diff --git a/lib/views/widgets/home_page/search_field.dart b/lib/views/widgets/home_page/search_field.dart new file mode 100644 index 0000000..0ebeb94 --- /dev/null +++ b/lib/views/widgets/home_page/search_field.dart @@ -0,0 +1,50 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:get/get.dart'; + +import '../../../controllers/book_controller.dart'; +import '../../../style.dart'; + +class SearchField extends StatelessWidget { + const SearchField({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final BookController bookController = Get.find(); + + return Container( + padding: const EdgeInsets.only(left: 14, right: 17.69), + margin: const EdgeInsets.only(left: 30, right: 28, top: 24), + height: 47, + width: double.infinity, + decoration: BoxDecoration( + color: white, + borderRadius: BorderRadius.circular(8), + boxShadow: const [ + BoxShadow( + color: shadowColor, + offset: Offset(0, 8), + blurRadius: 24, + spreadRadius: 12, + ), + ], + ), + child: TextField( + scrollPhysics: const ScrollPhysics(), + onChanged: (value) => bookController.searchResult.value = value, + decoration: InputDecoration( + hintText: 'Search...', + hintStyle: hintTextStyle, + suffixIcon: Obx( + () => SvgPicture.asset( + 'assets/images/search.svg', + color: bookController.getSVGSearchColor, + ), + ), + suffixIconConstraints: const BoxConstraints(maxHeight: 20.31, maxWidth: 20.31), + border: InputBorder.none, + ), + ), + ); + } +} diff --git a/lib/views/widgets/home_page/user_account.dart b/lib/views/widgets/home_page/user_account.dart new file mode 100644 index 0000000..f5e8ce5 --- /dev/null +++ b/lib/views/widgets/home_page/user_account.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; + +import '../../../style.dart'; + +class UserAccount extends StatelessWidget { + const UserAccount({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + const SizedBox(width: 28), + Container( + height: 40, + width: 40, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + image: const DecorationImage( + image: AssetImage('assets/images/person.png'), + ), + ), + ), + const SizedBox(width: 12), + const Text( + 'Hi, Ali!', + style: nameUserTextStyle, + textAlign: TextAlign.center, + ), + ], + ); + } +} diff --git a/lib/views/widgets/primary_button.dart b/lib/views/widgets/primary_button.dart new file mode 100644 index 0000000..7b8ec01 --- /dev/null +++ b/lib/views/widgets/primary_button.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; + +import '../../style.dart'; + +class PrimaryButton extends StatelessWidget { + const PrimaryButton({ + Key? key, + required this.text, + required this.padding, + required this.onPressed, + }) : super(key: key); + + final String text; + final int padding; + final Function() onPressed; + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.symmetric(horizontal: padding.toDouble()), + child: ElevatedButton( + onPressed: onPressed, + style: ButtonStyle( + minimumSize: MaterialStateProperty.all(const Size(double.infinity, 60)), + backgroundColor: MaterialStateProperty.all(black), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + ), + ), + child: Text(text, style: buyButtonTextStyle), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 7bc8bdd..a876d4a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -69,11 +69,25 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + flutter_svg: + dependency: "direct main" + description: + name: flutter_svg + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.4" flutter_test: dependency: "direct dev" 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: @@ -109,6 +123,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.1" + path_drawing: + dependency: transitive + description: + name: path_drawing + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + path_parsing: + dependency: transitive + description: + name: path_parsing + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.0" sky_engine: dependency: transitive description: flutter @@ -163,5 +198,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + xml: + dependency: transitive + description: + name: xml + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.0" sdks: dart: ">=2.17.6 <3.0.0" + flutter: ">=2.11.0-0.1.pre" diff --git a/pubspec.yaml b/pubspec.yaml index cd0f457..702cfe5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,8 @@ 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 + flutter_svg: ^1.1.4 + get: ^4.6.5 dev_dependencies: flutter_test: @@ -58,9 +60,16 @@ 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: + - assets/images/person.png + - assets/images/search.svg + - assets/images/book_1.jpg + - assets/images/book_2.jpg + - assets/images/book_3.jpg + - assets/images/book_4.jpg + - assets/images/reviews_icon.svg + - assets/images/preview_icon.svg + # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware @@ -73,12 +82,16 @@ flutter: # "family" key with the font family name, and a "fonts" key with a # list giving the asset and other descriptors for the font. For # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic + fonts: + - family: Poppins + fonts: + - asset: assets/fonts/Poppins/Poppins-Regular.ttf + - asset: assets/fonts/Poppins/Poppins-Medium.ttf + - asset: assets/fonts/Poppins/Poppins-Light.ttf + - asset: assets/fonts/Poppins/Poppins-Bold.ttf + - asset: assets/fonts/Poppins/Poppins-SemiBold.ttf + - asset: assets/fonts/Poppins/Poppins-Thin.ttf + # - family: Trajan Pro # fonts: # - asset: fonts/TrajanPro.ttf diff --git a/test/widget_test.dart b/test/widget_test.dart index 7730be6..0db5edb 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -8,12 +8,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:book_store_app/main.dart'; +// import 'package:book_store_app/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); + // await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget);