diff --git a/lib/add_book_page/addBookPage.dart b/lib/add_book_page/addBookPage.dart new file mode 100644 index 0000000..0dd0bc5 --- /dev/null +++ b/lib/add_book_page/addBookPage.dart @@ -0,0 +1,44 @@ +import 'package:book_store_app/add_book_page/input_book_field.dart'; +import 'package:book_store_app/models/myColor.dart'; +import 'package:book_store_app/models/myUiComponent.dart'; +import 'package:flutter/material.dart'; + +class AddBookPage extends StatefulWidget { + const AddBookPage({Key? key}) : super(key: key); + + @override + State createState() => _AddBookPageState(); +} + +class _AddBookPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: MyColor.backgroundColor, + body: Padding( + padding: const EdgeInsets.symmetric(vertical: 55, horizontal: 5), + child: Column( + children: [ + const MyAppBar(), + Padding( + padding: const EdgeInsets.only(left: 20,right: 20,top: 30), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: const[ + Text( + 'Add Book', + style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + ), + InputBookDetails() + + ], + ), + ), + + + ], + ), + ), + ); + } +} diff --git a/lib/add_book_page/input_book_field.dart b/lib/add_book_page/input_book_field.dart new file mode 100644 index 0000000..1625b77 --- /dev/null +++ b/lib/add_book_page/input_book_field.dart @@ -0,0 +1,59 @@ +import 'package:book_store_app/models/myColor.dart'; +import 'package:book_store_app/models/book_data.dart'; +import 'package:flutter/material.dart'; + +import 'inputfields.dart'; + +TextEditingController nameControl = TextEditingController(); +TextEditingController authorControl = TextEditingController(); +TextEditingController priceControl = TextEditingController(); +TextEditingController linkControl = TextEditingController(); +TextEditingController descriptionControl = TextEditingController(); + +class InputBookDetails extends StatelessWidget { + const InputBookDetails({ + Key? key, + }) : super(key: key); + + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 60, left: 15, right: 15), + child: Column( + children: [ + InputField(myControl: nameControl, hint: 'Book Name', errorOn: true, line: 1,), + InputField(myControl: authorControl, hint: 'Author Name', errorOn: true, line: 1,), + InputField(myControl: priceControl, hint: 'Price', errorOn: true, line: 1,), + InputField(myControl: linkControl, hint: 'Image link', errorOn: false, line: 1,), + InputField(myControl: descriptionControl, hint: 'Description', errorOn: false, line: 7,), + Container( + height: 60, + width: double.maxFinite, + decoration: BoxDecoration( + color: MyColor.primaryColor, + borderRadius: BorderRadius.circular(16), + boxShadow: const [ + BoxShadow( + color: Color.fromARGB(10, 7, 8, 14), + spreadRadius: 7, + blurRadius: 32, + offset: Offset(0, 7), + ) + ]), + child: TextButton( + onPressed: () { + BookData.addBook(); + }, + child: const Text( + 'Add', + style: TextStyle(color: Colors.white, fontSize: 16), + )), + ), + + + ], + ), + ); + } +} diff --git a/lib/add_book_page/inputfields.dart b/lib/add_book_page/inputfields.dart new file mode 100644 index 0000000..3828ca9 --- /dev/null +++ b/lib/add_book_page/inputfields.dart @@ -0,0 +1,59 @@ + +import 'package:flutter/material.dart'; +import '../models/myColor.dart'; + +class InputField extends StatefulWidget { + const InputField({ + Key? key, required this.myControl, required this.hint, required this.errorOn, required this.line, + }) : super(key: key); + final String hint; + final TextEditingController myControl; + final bool errorOn; + final int line; + @override + State createState() => _InputFieldState(); +} + +class _InputFieldState extends State { + String? error; + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.only(bottom: 22), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: MyColor.shadowTextFieldColor, + spreadRadius: 7, + blurRadius: 32, + offset: const Offset(0, 7), + ) + ]), + child: TextField( + textInputAction: TextInputAction.next, + maxLines: widget.line, + controller: widget.myControl, + onChanged: (x){ + if(widget.errorOn) { + if (x.isEmpty) { + error = 'Required'; + }else{ + error=null; + } + setState(() {}); + } + }, + decoration: InputDecoration( + hintText: widget.hint, + hintStyle: TextStyle(color: MyColor.hintTextFieldColor), + filled: true, + fillColor: Colors.white, + disabledBorder: InputBorder.none, + border: InputBorder.none, + errorText: error, + ), + ), + ); + } +} diff --git a/lib/assets/images/profile.jpg b/lib/assets/images/profile.jpg new file mode 100644 index 0000000..73e8e33 Binary files /dev/null and b/lib/assets/images/profile.jpg differ diff --git a/lib/book_details_page/action_card.dart b/lib/book_details_page/action_card.dart new file mode 100644 index 0000000..7a76445 --- /dev/null +++ b/lib/book_details_page/action_card.dart @@ -0,0 +1,52 @@ + +import 'package:book_store_app/models/myColor.dart'; +import 'package:flutter/material.dart'; + +class ActionOnBook extends StatelessWidget { + const ActionOnBook({ + Key? key, required this.text, required this.icon, + }) : super(key: key); + + final String text; + final IconData icon; + + @override + Widget build(BuildContext context) { + return Container( + height: 40, + width: 150, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + boxShadow:const [ + BoxShadow( + color: Color.fromARGB(50, 7, 8, 14), + spreadRadius: 7, + blurRadius: 32, + offset: Offset(0, 7), + ) + ]), + child: TextButton( + onPressed: () {}, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(icon, + color: MyColor.primaryColor), + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: Text( + text, + style: TextStyle( + color: MyColor.primaryColor, + fontSize: 14, + fontWeight: FontWeight.bold), + ), + ) + ], + ), + ), + ); + } +} + diff --git a/lib/book_details_page/bookDetalisPage.dart b/lib/book_details_page/bookDetalisPage.dart new file mode 100644 index 0000000..2fbefab --- /dev/null +++ b/lib/book_details_page/bookDetalisPage.dart @@ -0,0 +1,71 @@ +import 'package:book_store_app/book_details_page/action_card.dart'; +import 'package:book_store_app/book_details_page/book_card.dart'; +import 'package:book_store_app/models/book_data.dart'; +import 'package:book_store_app/models/myUiComponent.dart'; +import 'package:book_store_app/models/myColor.dart'; +import 'package:flutter/material.dart'; + +class BookDetailsPage extends StatelessWidget { + const BookDetailsPage({Key? key, required this.myBook}) : super(key: key); + + final BookData myBook; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + backgroundColor: MyColor.backgroundColor, + body: Padding( + padding: const EdgeInsets.symmetric(vertical: 55, horizontal: 20), + child: Stack(children: [ + Column( + children: [const MyAppBar(), BookDetails(data: myBook)], + ), + Align( + alignment: Alignment.bottomCenter, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: const [ + ActionOnBook( + text: 'Preview', icon: Icons.format_align_left), + ActionOnBook(text: 'Reviews', icon: Icons.reviews), + ], + ), + Padding( + padding: const EdgeInsets.only(top: 30), + child: Container( + height: 60, + width: double.maxFinite, + decoration: BoxDecoration( + color: MyColor.primaryColor, + borderRadius: BorderRadius.circular(16), + boxShadow: const [ + BoxShadow( + color: Color.fromARGB(10, 7, 8, 14), + spreadRadius: 7, + blurRadius: 32, + offset: Offset(0, 7), + ) + ]), + child: TextButton( + onPressed: () { + myBook.addBuyList(); + }, + child: Text( + 'Buy Now for \$${myBook.bookPrice}', + style: const TextStyle( + color: Colors.white, fontSize: 16), + )), + )), + ], + ), + ) + ]), + ), + ), + ); + } +} diff --git a/lib/book_details_page/book_card.dart b/lib/book_details_page/book_card.dart new file mode 100644 index 0000000..dfc683c --- /dev/null +++ b/lib/book_details_page/book_card.dart @@ -0,0 +1,109 @@ +import 'package:book_store_app/models/book_data.dart'; +import 'package:book_store_app/models/myColor.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:get/get_core/src/get_main.dart'; + +class BookDetails extends StatelessWidget { + const BookDetails({ + Key? key, + required this.data, + }) : super(key: key); + +//'https://api.lorem.space/image/book?w=216&h=320' + final BookData data; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + SizedBox( + width: 216, + height: 320, + child: Image.network( + data.bookLink, + fit: BoxFit.fitWidth, + width: 216, + height: 320, + errorBuilder: (context, url, error) => const Icon(Icons.error), + )), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: Text(data.bookName, + style: TextStyle( + fontSize: 24, + fontWeight: FontWeight.bold, + color: MyColor.primaryColor)), + ), + Text(data.authorName, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: MyColor.secondColor, + )), + Padding( + padding: const EdgeInsets.symmetric(vertical: 12), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.star, + size: 14, + color: MyColor.yellowStarColor, + ), + Icon( + Icons.star, + size: 14, + color: MyColor.yellowStarColor, + ), + Icon( + Icons.star, + size: 14, + color: MyColor.yellowStarColor, + ), + Icon( + Icons.star, + size: 14, + color: MyColor.yellowStarColor, + ), + Icon( + Icons.star_half_outlined, + size: 14, + color: MyColor.yellowStarColor, + ), + Padding( + padding: const EdgeInsets.only(left: 12), + child: Text( + '4.5', + style: TextStyle( + color: MyColor.primaryColor, + fontSize: 12, + fontWeight: FontWeight.bold), + ), + ), + Text('/5.0', + style: + TextStyle(color: MyColor.fullRateTextColor, fontSize: 12)) + ], + ), + ), + Text(data.bookDescription,maxLines: 3,overflow:TextOverflow.ellipsis, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: MyColor.secondColor, + )), + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: GestureDetector( + onTap: (){ + Get.defaultDialog(title: 'Book Description',middleText:data.bookDescription ,middleTextStyle: TextStyle(fontSize: 14, + fontWeight: FontWeight.bold, + color: MyColor.secondColor,) ); + }, + child: Text('more details click here' ,style: TextStyle(fontSize: 12,color: MyColor.secondColor))), + ) + ], + ); + } +} diff --git a/lib/card_page/cardPage.dart b/lib/card_page/cardPage.dart new file mode 100644 index 0000000..02a642c --- /dev/null +++ b/lib/card_page/cardPage.dart @@ -0,0 +1,54 @@ +import 'package:book_store_app/models/myColor.dart'; +import 'package:book_store_app/models/myLogic.dart'; +import 'package:book_store_app/models/myUiComponent.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart'; + +import '../main_page/main_action_button.dart'; + +class CardPage extends StatelessWidget { + const CardPage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: MyColor.backgroundColor, + body: Stack(children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 55, horizontal: 5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const MyAppBar(), + Expanded( + child: Padding( + padding: const EdgeInsets.only(left: 20, right: 20, top: 30), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Padding( + padding: EdgeInsets.only(bottom: 20), + child: Text( + 'Card', + style: TextStyle( + fontSize: 24, fontWeight: FontWeight.bold), + ), + ), + Expanded( + child: Obx(() { + return ListView( + children: MyFunctions.cardPageViewBooks()); + }), + ), + ], + ), + ), + ), + ], + ), + ), + const MainActionButton(), + ]), + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index bcc58f7..7a8258a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,9 @@ +import 'package:book_store_app/main_page/mainPage.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; void main() { - runApp(const MyApp()); + runApp(const GetMaterialApp(home:MainPage()) ); } class MyApp extends StatelessWidget { diff --git a/lib/main_page/mainPage.dart b/lib/main_page/mainPage.dart new file mode 100644 index 0000000..aa65a15 --- /dev/null +++ b/lib/main_page/mainPage.dart @@ -0,0 +1,60 @@ +import 'package:book_store_app/main_page/main_action_button.dart'; +import 'package:book_store_app/main_page/profileCard.dart'; +import 'package:book_store_app/main_page/searchTextField.dart'; +import 'package:book_store_app/models/myColor.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import '../models/myLogic.dart'; + +class MainPage extends StatefulWidget { + const MainPage({Key? key}) : super(key: key); + + @override + State createState() => _MainPageState(); +} + +class _MainPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: Stack( + children: [ + Padding( + padding: const EdgeInsets.symmetric(vertical: 55, horizontal: 30), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const ProfileCard(), + const Padding( + padding: EdgeInsets.symmetric(vertical: 40), + child: SearchTextField(), + ), + Padding( + padding: const EdgeInsets.only(bottom: 10), + child: Obx(() { + return Text( + search.value.isEmpty + ? 'Book List' + : 'Book with name: ${search.value}', + style: TextStyle( + color: MyColor.primaryColor, + fontWeight: FontWeight.bold, + fontSize: 20, + )); + }), + ), + Expanded( + child: Obx(() { + return ListView( + children: MyFunctions.mainPageViewBook() + );}), + ), + ], + ), + ), + const MainActionButton() + ], + ), + ); + } +} diff --git a/lib/main_page/main_action_button.dart b/lib/main_page/main_action_button.dart new file mode 100644 index 0000000..5e07550 --- /dev/null +++ b/lib/main_page/main_action_button.dart @@ -0,0 +1,69 @@ +import 'package:book_store_app/add_book_page/addBookPage.dart'; +import 'package:book_store_app/card_page/cardPage.dart'; +import 'package:book_store_app/main_page/mainPage.dart'; +import 'package:book_store_app/models/myColor.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../models/myUiComponent.dart'; + +class MainActionButton extends StatelessWidget { + const MainActionButton({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Align( + alignment: Alignment.bottomCenter, + child: Container( + margin:const EdgeInsets.only(bottom:42 ), + width: 227, + height: 72, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(22), + boxShadow: const[ + BoxShadow( + color: Color.fromARGB(50, 7, 8, 14), + spreadRadius: 7, + blurRadius: 32, + offset: Offset(0, 7), + ) + ]), + child: Obx(() { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + IconButton(onPressed:(){ + currentPage.value=0; + Get.to(const MainPage()); + }, + icon:Icon(Icons.home_outlined, + size: 24, + color: currentPage.value==0? MyColor.primaryColor : MyColor.unSelectColor , + )), + IconButton(onPressed:(){ + currentPage.value=1; + Get.to(const CardPage()); + }, + icon:Icon(Icons.shopping_cart_outlined, + size: 20, + color: currentPage.value==1? MyColor.primaryColor : MyColor.unSelectColor , + )), + IconButton(onPressed:(){ + Get.to(const AddBookPage()); + }, + icon:Icon(Icons.add, + size: 26, + color: MyColor.unSelectColor, + )), + + ], + ); + } + ), + ), + ); + } +} diff --git a/lib/main_page/profileCard.dart b/lib/main_page/profileCard.dart new file mode 100644 index 0000000..86f02b4 --- /dev/null +++ b/lib/main_page/profileCard.dart @@ -0,0 +1,38 @@ + +import 'package:book_store_app/models/myColor.dart'; +import 'package:flutter/material.dart'; + +class ProfileCard extends StatelessWidget { + const ProfileCard({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + SizedBox( + height: 40, + width: 40, + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Image.asset( + 'lib/assets/images/profile.jpg', + fit: BoxFit.cover, + ), + ), + ), + Padding( + padding:const EdgeInsets.only(left: 10), + child: Text( + 'Hi, Haider!', + style: TextStyle( + fontSize: 14, fontWeight: FontWeight.bold,color: MyColor.primaryColor), + ), + ), + const Spacer(), + const Icon(Icons.more_vert) + ], + ); + } +} diff --git a/lib/main_page/searchTextField.dart b/lib/main_page/searchTextField.dart new file mode 100644 index 0000000..6eee367 --- /dev/null +++ b/lib/main_page/searchTextField.dart @@ -0,0 +1,45 @@ + +import 'package:book_store_app/models/myColor.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +RxString search=''.obs; + +class SearchTextField extends StatelessWidget { + const SearchTextField({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + color: MyColor.shadowTextFieldColor, + spreadRadius: 7, + blurRadius: 32, + offset:const Offset(0, 7), + ) + ]), + child: TextFormField( + onChanged: (x){ + search.value=x; + }, + decoration: InputDecoration( + hintText: 'Search...', + hintStyle: TextStyle(color: MyColor.hintTextFieldColor), + suffixIcon: Obx(() { + return Icon(Icons.search,color: search.value.isEmpty? MyColor.hintTextFieldColor: Colors.blue ,); + } + ), + filled: true, + fillColor: Colors.white, + disabledBorder:InputBorder.none, + border: InputBorder.none, + ), + ), + ); + } +} diff --git a/lib/models/book_data.dart b/lib/models/book_data.dart new file mode 100644 index 0000000..9095de5 --- /dev/null +++ b/lib/models/book_data.dart @@ -0,0 +1,60 @@ +import 'package:book_store_app/add_book_page/input_book_field.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class BookData { + final String bookName; + final String authorName; + final String bookPrice; + final String bookLink; + final String bookDescription; + final RxBool bookBuy; + + static RxList books = [ + BookData('Games People Play', 'Eric Berne', '17.99', 'https://covers.zlibcdn2.com/covers299/books/de/54/b5/de54b53efafa0ef3f39221fa770fce18.jpg', 'The need for this book was indicated by interested requests from students and lecture audiences for lists of games, or for further elaboration of games mentioned briefly as examples in a general exposition of the principles of transactional analysis.'), + BookData('The Question Book', 'Mikael Krogerus, Roman Tschäppeler', '10.00', 'https://covers.zlibcdn2.com/covers299/books/fb/27/c0/fb27c0342de7846665b68f9bd2c65422.jpg', 'The number one bestselling Decision Book authors return with compulsive questions about every aspect of our lives.What would be your ideal job if you didnt have to worry about money? Would you like to have more responsibility or less? How far would you go for a promotion? When did you last stand up for what you believe in? What are you afraid of? In this unique handbook to your own life and work, there are no right or wrong answers: only honest ones.Featuring sections on subjects everyone can relate to, from the professional (work and finance), to the personal (sex and relationships), The Question Book can be used alone, like a journal; or with a colleague, partner or friend. It will probe and enlighten on everything, including what your boss really thinks about you, whether you are in the right job, and what motivates you to get out of bed every morning. These wide-ranging questions - which provoke short yes or no s as well as open-ended responses that dig deeper - are pertinent, direct, and compulsively fun to answer. In The Question Book, you are under the spotlight. And only you have the answer.'), + BookData('English Grammar in Use, Fifth Edition', 'Raymond Murphy', '5.99', 'https://covers.zlibcdn2.com/covers299/books/db/c1/3a/dbc13ab09234e92e5c169610d1f5e6f6.jpg', 'English Grammar in Use, Fifth Edition The worlds best-selling grammar series for learners of English.Raymond Murphys English Grammar in Use is the world’s best-selling grammar reference and practice book for learners of English at intermediate (B1-B2) level. It’s perfect for self-study, but also ideal for supplementary grammar activities in the classroom.The fifth edition is available as a printed book and ebook with audio, for on-the-go learning. It comes with interactive exercises and integrated audio to help with listening and pronunciation skills. '), + + + ].obs; + + BookData(this.bookName, this.authorName, this.bookPrice, this.bookLink, + this.bookDescription, + [bool? bookBuy]) + : bookBuy = (bookBuy ?? false).obs; + + addBuyList() { + bookBuy.value = true; + } + + removeBuyList() { + bookBuy.value = false; + } + + + static addBook() { + if (nameControl.text.isNotEmpty && + authorControl.text.isNotEmpty && + priceControl.text.isNotEmpty) { + BookData.books.add(BookData( + nameControl.text, + authorControl.text, + priceControl.text, + linkControl.text.isEmpty + ? 'https://api.lorem.space/image/book' + : linkControl.text, + descriptionControl.text.isEmpty? 'There is no description': descriptionControl.text )); + nameControl.text = ''; + authorControl.text = ''; + priceControl.text = ''; + linkControl.text = ''; + descriptionControl.text = ''; + } else { + Get.snackbar('Error', 'Some required field is empty', + backgroundColor: Colors.redAccent.withOpacity(0.4), + duration: const Duration(seconds: 3)); + } + + + } +} diff --git a/lib/models/myColor.dart b/lib/models/myColor.dart new file mode 100644 index 0000000..08a23c5 --- /dev/null +++ b/lib/models/myColor.dart @@ -0,0 +1,17 @@ + +import 'package:flutter/material.dart'; + +class MyColor{ + static Color backgroundColor=const Color(0xffFDFDFD); + static Color primaryColor=const Color(0xff06070D); + static Color secondColor=const Color(0xff06070D).withOpacity(0.5); + static Color yellowStarColor=const Color(0xffFFC41F); + static Color whiteStarColor=const Color(0xffEDEDEF); + static Color fullRateTextColor=const Color(0xff828285); + static Color hintTextFieldColor=const Color(0xff84889E); + static Color shadowTextFieldColor=const Color(0xff07080E).withOpacity(0.10); + static Color priceColor=const Color(0xff191919); + static Color unSelectColor=const Color(0xff9C9EA8); + + +} \ No newline at end of file diff --git a/lib/models/myLogic.dart b/lib/models/myLogic.dart new file mode 100644 index 0000000..cabc627 --- /dev/null +++ b/lib/models/myLogic.dart @@ -0,0 +1,32 @@ +import 'package:book_store_app/main_page/searchTextField.dart'; + +import 'book_data.dart'; +import 'myUiComponent.dart'; + +class MyFunctions { + static mainPageViewBook() => search.value.isEmpty + ? BookData.books + .map((e) => BookView( + book: e, + show: false, + )) + .toList() + : BookData.books + .where((e) => + e.bookName.toLowerCase().contains(search.value.toLowerCase())) + .map((e) => BookView( + book: e, + show: false, + )).toList(); + + + static cardPageViewBooks() => BookData.books + .where((e) => e.bookBuy.value) + .map((e) => BookView( + book: e, + show: true, + )).toList(); + + + +} diff --git a/lib/models/myUiComponent.dart b/lib/models/myUiComponent.dart new file mode 100644 index 0000000..3437362 --- /dev/null +++ b/lib/models/myUiComponent.dart @@ -0,0 +1,146 @@ +import 'package:book_store_app/book_details_page/bookDetalisPage.dart'; +import 'package:book_store_app/models/book_data.dart'; +import 'package:book_store_app/models/myColor.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +Rx currentPage=0.obs; + +class MyAppBar extends StatelessWidget { + const MyAppBar({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + IconButton( + onPressed: () { + Get.back(); + }, + icon:const Icon( + Icons.arrow_back_ios_new_rounded, + size: 20, + color: Colors.black, + ), + ), + const Spacer(), + IconButton( + onPressed: () {}, + icon:const Icon( + Icons.more_vert, + size: 24, + color: Colors.black, + ), + ), + ], + ); + } +} + + + + +class BookView extends StatelessWidget { + const BookView({required this.book, + Key? key, required this.show, + }) : super(key: key); + final BookData book; + final bool show; +//'https://api.lorem.space/image/book?w=72&h=106' + @override + Widget build(BuildContext context) { + return InkWell( + onTap: (){ + Get.to(BookDetailsPage(myBook: book)); + }, + child: Container( + margin:const EdgeInsets.only(bottom: 23), + width: double.maxFinite, + height: 105, + child: Row( + children: [ + SizedBox( + height: 106,width: 72, + child: Image.network( + book.bookLink, + fit: BoxFit.fill, + errorBuilder: (context, url, error) => const Icon(Icons.error), + ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.only( + left: 25, top: 8, bottom: 2), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(book.bookName, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + color: MyColor.primaryColor)), + Text(book.authorName, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: MyColor.secondColor, + )), + Text( + '\$${book.bookPrice}', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: MyColor.priceColor), + ), + Row( + children: [ + Icon( + Icons.star, + size: 14, + color: MyColor.yellowStarColor, + ), + Icon( + Icons.star, + size: 14, + color: MyColor.yellowStarColor, + ), + Icon( + Icons.star, + size: 14, + color: MyColor.yellowStarColor, + ), + Icon( + Icons.star, + size: 14, + color: MyColor.yellowStarColor, + ), + Icon( + Icons.star, + size: 14, + color: MyColor.whiteStarColor, + ), + ], + ) + ], + ), + ), + ), + + Visibility( + visible: show, + child: IconButton(onPressed: (){ + book.removeBuyList(); + }, icon: const Icon(Icons.remove_shopping_cart_outlined,color: Colors.red,), + + ), + ) + ], + ), + ), + ); + } +} + 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..2094ecf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,9 +31,12 @@ dependencies: sdk: flutter + + # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + get: ^4.6.5 dev_dependencies: flutter_test: @@ -46,6 +49,7 @@ dev_dependencies: # rules and activating additional ones. flutter_lints: ^2.0.0 + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec @@ -57,9 +61,10 @@ flutter: # the material Icons class. uses-material-design: true + # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg + assets: + - lib/assets/images/profile.jpg # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see