Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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(),
),
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/modules/book_module.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'package:get/get.dart';class BookModule { final Rx<String> nameBook; final Rx<String> authorBook; final Rx<String> descriptionBook; final Rx<String> 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<BookModule> books = <BookModule>[ 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 PrimeA 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 PrimeThe #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;}
Expand Down
1 change: 1 addition & 0 deletions lib/page_add/add_page.dart
Original file line number Diff line number Diff line change
@@ -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(); }, ), ], ), ), ), ); }}
Expand Down
1 change: 1 addition & 0 deletions lib/page_add/button_add.dart
Original file line number Diff line number Diff line change
@@ -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, ), )), ))); }}
Expand Down
1 change: 1 addition & 0 deletions lib/page_add/text_add.dart
Original file line number Diff line number Diff line change
@@ -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, ), ), ), ); }}
Expand Down
1 change: 1 addition & 0 deletions lib/page_cart/cart_page.dart
Original file line number Diff line number Diff line change
@@ -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(), ); }}
Expand Down
1 change: 1 addition & 0 deletions lib/page_cart/list_cart.dart
Original file line number Diff line number Diff line change
@@ -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(), ), ); }), ); }}
Expand Down
1 change: 1 addition & 0 deletions lib/page_description/book_info.dart
Original file line number Diff line number Diff line change
@@ -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), ], ), ), ); }}
Expand Down
1 change: 1 addition & 0 deletions lib/page_description/bottom_button.dart
Original file line number Diff line number Diff line change
@@ -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, ), )), )); }); }}
Expand Down
1 change: 1 addition & 0 deletions lib/page_description/buttons.dart
Original file line number Diff line number Diff line change
@@ -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),), ], ), ), ); }}
Expand Down
1 change: 1 addition & 0 deletions lib/page_description/custom_appbar.dart
Original file line number Diff line number Diff line change
@@ -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, ), ) ], ); }}
Expand Down
1 change: 1 addition & 0 deletions lib/page_description/description.dart
Original file line number Diff line number Diff line change
@@ -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),), ), ), ); }}
Expand Down
1 change: 1 addition & 0 deletions lib/page_description/image_book.dart
Original file line number Diff line number Diff line change
@@ -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, ), ), ), ); }}
Expand Down
Loading