diff --git a/lib/Card/Card_main_page.dart b/lib/Card/Card_main_page.dart new file mode 100644 index 0000000..947c6c7 --- /dev/null +++ b/lib/Card/Card_main_page.dart @@ -0,0 +1,83 @@ +import 'package:book_store_app/page1/ListView.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:get/get_core/src/get_main.dart'; + +import '../model.dart'; +import '../page1/Stack_part.dart'; +import '../page1/Title_OF_list.dart'; +import '../page1/main_page1.dart'; +import '../page2_Add_books/App_bar.dart'; + +class Card1 extends StatefulWidget { + const Card1({Key? key}) : super(key: key); + + @override + State createState() => _Card1State(); +} + +class _Card1State extends State { + late final Books books; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xFFEFEFEF), + body: Padding( + padding: const EdgeInsets.only(left: 30, right: 30, top: 55), + child: Stack( + children: [ + Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: () { + Get.to(Main_page1(), + duration: Duration( + milliseconds: + 200), //duration of transitions, default 1 sec + transition: Transition.fadeIn); + }, + icon: Icon( + Icons.arrow_back_ios, + size: 30, + ), + ), + IconButton( + onPressed: () {}, + icon: Icon( + Icons.more_vert, + size: 30, + ), + ), + ], + ), + Title_OF_list( + title: "Card", + ), + Expanded( + child: ListView( + children: Books.bookList + .where((e) => e.isBuy.value) + .map((e) => books_card( + books: e, + color: Colors.red, + )) + .toList(), + )) + ], + ), + Stack_part( + color_home: Colors.black26, + color_shopping: Colors.black, + color_favorite: Colors.black26, + ) + ], + ), + ), + ); + } +} diff --git a/lib/View_book/Description.dart b/lib/View_book/Description.dart new file mode 100644 index 0000000..b59e3c1 --- /dev/null +++ b/lib/View_book/Description.dart @@ -0,0 +1,28 @@ +import 'package:flutter/cupertino.dart'; + +class Description11 extends StatelessWidget { + const Description11({ + Key? key, + required this.Description1, + }) : super(key: key); + final String Description1; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Container( + + child: Text( + Description1, + style: const TextStyle( + fontWeight: FontWeight.w400, + fontSize: 15, + color: Color(0xFF06070D), + height: 1.6, + ), + ), + ), + ); + } +} diff --git a/lib/View_book/Name+Aother.dart b/lib/View_book/Name+Aother.dart new file mode 100644 index 0000000..9d1659d --- /dev/null +++ b/lib/View_book/Name+Aother.dart @@ -0,0 +1,105 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class books_name extends StatelessWidget { + const books_name({ + Key? key, required this.Books_name, required this.Aother_name, + }) : super(key: key); + final String Books_name; + final String Aother_name; + + @override + Widget build(BuildContext context) { + return Container( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only(top: 22), + child: Text( + Books_name, + style: TextStyle(fontWeight: FontWeight.w600, fontSize: 24), + ), + ), + Padding( + padding: const EdgeInsets.only(top: 12), + child: Text( + Aother_name, + style: TextStyle(fontWeight: FontWeight.w500, fontSize: 14), + ), + ), + star() + ], + ), + ); + } +} + +class star extends StatelessWidget { + const star({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 12,bottom: 10 + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.star, + size: 16, + color: Color(0xFFFFC41F), + ), + Icon( + Icons.star, + size: 16, + color: Color(0xFFFFC41F), + ), + Icon( + Icons.star, + size: 16, + color: Color(0xFFFFC41F), + ), + Icon( + Icons.star, + size: 16, + color: Color(0xFFFFC41F), + ), + HalfFilledIcon( + icon: Icons.star_rate, + size: 16, + color: Color(0xFFFFC41F)), + ], + ), + ); + } +} + +class HalfFilledIcon extends StatelessWidget { + final IconData icon; + final double size; + final Color color; + + HalfFilledIcon({required this.icon, required this.size, required this.color}); + + @override + Widget build(BuildContext context) { + return ShaderMask( + blendMode: BlendMode.srcATop, + shaderCallback: (Rect rect) { + return LinearGradient( + stops: [0, 0.5, 0.5], + colors: [color, color, color.withOpacity(0)], + ).createShader(rect); + }, + child: SizedBox( + width: size, + height: size, + child: Icon(icon, size: size, color: Colors.grey[300]), + ), + ); + } +} \ No newline at end of file diff --git a/lib/View_book/Row_of_button.dart b/lib/View_book/Row_of_button.dart new file mode 100644 index 0000000..e25d880 --- /dev/null +++ b/lib/View_book/Row_of_button.dart @@ -0,0 +1,34 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class Row_of_button extends StatelessWidget { + const Row_of_button({ + Key? key, required this.text, required this.icon, + }) : super(key: key); + final String text; + final Widget icon; + + @override + Widget build(BuildContext context) { + return Container( + width: 160, + height: 40, + child: ElevatedButton.icon( + label: Text(text, + style: TextStyle( + fontSize: 16, fontWeight: FontWeight.w500)), + style: ButtonStyle( + foregroundColor: + MaterialStateProperty.all(Colors.black87), + backgroundColor: + MaterialStateProperty.all(Colors.white), + shape: + MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + )), + ), + onPressed: () {}, + icon: icon)); + } +} diff --git a/lib/View_book/View_book_main_page.dart b/lib/View_book/View_book_main_page.dart new file mode 100644 index 0000000..b5a6d41 --- /dev/null +++ b/lib/View_book/View_book_main_page.dart @@ -0,0 +1,152 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../model.dart'; +import '../page1/main_page1.dart'; +import '../page2_Add_books/App_bar.dart'; +import 'Description.dart'; +import 'Name+Aother.dart'; +import 'Row_of_button.dart'; +import 'View_books.dart'; +import '../page2_Add_books/App_bar.dart'; + +class Veiw_Books extends StatelessWidget { + const Veiw_Books({ + Key? key, + required this.note, + }) : super(key: key); + final Books note; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xFFEFEFEF), + body: Stack( + children: [ + Obx(() { + return Column( + children: [ + Expanded( + child: ListView( + children: Books.bookList + .where((e) => e.isClickted.value) + .map((e) => page_veiw( + books: e, + )) + .toList(), + ), + ), + ], + ); + }), + Padding( + padding: const EdgeInsets.only(left: 30, right: 30, top: 45), + child: App_bar(books: note), + ), + ], + ), + ); + } +} + +class page_veiw extends StatelessWidget { + const page_veiw({ + Key? key, + required this.books, + }) : super(key: key); + + final Books books; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(left: 30, right: 30, top: 50), + child: Column( + children: [ + //App_bar(books: books), + Books_Cover( + links: books.imageLink.value, + ), + books_name( + Books_name: books.bookName.value, + Aother_name: books.authorName.value, + ), + Description11(Description1: books.description.value), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: const [ + Row_of_button( + text: "Preview", + icon: Icon( + Icons.notes, + size: 30, + color: Colors.black, + ), + ), + Row_of_button( + text: "Reviews", + icon: Icon( + Icons.reviews, + size: 24, + color: Colors.black, + ), + ), + ], + ), + Padding( + padding: const EdgeInsets.only(top: 30, bottom: 30), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + width: 200, + height: 60, + child: ElevatedButton( + style: ButtonStyle( + foregroundColor: + MaterialStateProperty.all(Colors.white), + backgroundColor: + MaterialStateProperty.all(Color(0xFF06070D)), + shape: + MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + side: + BorderSide(color: Color(0xFF06070D)))), + ), + onPressed: () { + books.makeBuy(); + }, + child: Text("Buy Now for \$${books.price.value}", + style: TextStyle(fontSize: 18)), + )), + Container( + width: 140, + height: 60, + child: ElevatedButton( + style: ButtonStyle( + foregroundColor: + MaterialStateProperty.all(Colors.white), + backgroundColor: + MaterialStateProperty.all(Colors.red), + shape: + MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + side: BorderSide(color: Colors.red))), + ), + onPressed: () { + books.isBuy.value = false; + }, + child: Text(" Cancel \npurchase ", + style: TextStyle(fontSize: 18)), + )), + ], + ), + ) + ], + ), + ); + } +} diff --git a/lib/View_book/View_books.dart b/lib/View_book/View_books.dart new file mode 100644 index 0000000..45111c9 --- /dev/null +++ b/lib/View_book/View_books.dart @@ -0,0 +1,29 @@ +import 'package:flutter/cupertino.dart'; + +class Books_Cover extends StatelessWidget { + const Books_Cover({ + Key? key, required this.links, + }) : super(key: key); + final String links; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 15), + child: Container( + height: 310, + width: 211, + decoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage( + links + ), + fit: BoxFit.cover), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(5), + bottomLeft: Radius.circular(5), + topRight: Radius.circular(15), + bottomRight: Radius.circular(15)))), + ); + } +} \ No newline at end of file diff --git a/lib/favorite_page/favorite.dart b/lib/favorite_page/favorite.dart new file mode 100644 index 0000000..4b01cad --- /dev/null +++ b/lib/favorite_page/favorite.dart @@ -0,0 +1,80 @@ +import 'package:book_store_app/page1/ListView.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../model.dart'; +import '../page1/Stack_part.dart'; +import '../page1/Title_OF_list.dart'; +import '../page1/main_page1.dart'; +import '../page2_Add_books/App_bar.dart'; + +class Favorite extends StatefulWidget { + const Favorite({Key? key}) : super(key: key); + + @override + State createState() => _FavoriteState(); +} + +class _FavoriteState extends State { + late final Books books; + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xFFEFEFEF), + body: Padding( + padding: const EdgeInsets.only(left: 30, right: 30, top: 55), + child: Stack( + children: [ + Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: () { + Get.to(Main_page1(), + duration: Duration( + milliseconds: + 200), //duration of transitions, default 1 sec + transition: Transition.fadeIn); + }, + icon: const Icon( + Icons.arrow_back_ios, + size: 30, + ), + ), + IconButton( + onPressed: () {}, + icon: Icon( + Icons.more_vert, + size: 30, + ), + ), + ], + ), + Title_OF_list( + title: "Favorite Books", + ), + Obx(() { + return Expanded( + child: ListView( + children: Books.bookList + .where((e) => e.myFavorite.value) + .map((e) => books_card(books: e, color: Colors.red)) + .toList(), + )); + }) + ], + ), + Stack_part( + color_home: Colors.black26, + color_shopping: Colors.black26, + color_favorite: Colors.black87, + ) + ], + ), + ), + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index bcc58f7..82107c2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,23 @@ +import 'package:book_store_app/page1/main_page1.dart'; +import 'package:book_store_app/page2_Add_books/Add_books_main_page.dart'; +import 'package:book_store_app/page2_Add_books/Add_books_main_page.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:get/get.dart'; +import 'package:get/get_navigation/src/root/get_material_app.dart'; + +import 'View_book/View_book_main_page.dart'; void main() { - runApp(const MyApp()); + SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( + statusBarColor: Color(0xFFEFEFEF), + statusBarIconBrightness: Brightness.dark, + statusBarBrightness: Brightness.light, + )); + runApp( + MyApp(), + ); } class MyApp extends StatelessWidget { @@ -9,12 +25,9 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return const MaterialApp( - home: Scaffold( - body: Center( - child: Text("Book Store App"), - ), - ), + return GetMaterialApp( + debugShowCheckedModeBanner: false, + home: Main_page1(), ); } } diff --git a/lib/model.dart b/lib/model.dart new file mode 100644 index 0000000..1104ecc --- /dev/null +++ b/lib/model.dart @@ -0,0 +1,127 @@ +import 'dart:math'; + +import 'package:book_store_app/page1/ListView.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class Books { + static List bookList = [ + Books( + "The Hating Game".obs, + 'Sally Thorne'.obs, + '5.99'.obs, + 'https://i.ibb.co/0ZcdR83/11.jpg'.obs, + 'A spectacular visual journey through 40 years of haute couture from one of the best-known and most trend-setting brands in fashion.' + .obs, + isBuy: false.obs, + isClickted: false.obs, + myFavorite: false.obs), + Books( + 'Shatter Me'.obs, + 'Tahereh M'.obs, + '6.99'.obs, + 'https://i.ibb.co/4p1g3St/22.jpg'.obs, + 'A spectacular visual journey through 40 years of haute couture from one of the best-known and most trend-setting brands in fashion.' + .obs, + isBuy: false.obs, + isClickted: false.obs, + myFavorite: false.obs), + Books( + 'Then She Was Gone'.obs, + 'Lisa Jewell'.obs, + '7.99'.obs, + 'https://i.ibb.co/pR8jV6q/33.png'.obs, + 'A spectacular visual journey through 40 years of haute couture from one of the best-known and most trend-setting brands in fashion.' + .obs, + isBuy: false.obs, + isClickted: false.obs, + myFavorite: false.obs), + Books( + 'HARRY POTTER'.obs, + 'J.K Rowling'.obs, + '6.99'.obs, + 'https://i.ibb.co/ChZx8J8/photo-2022-08-26-03-13-51-2.jpg'.obs, + 'A spectacular visual journey through 40 years of haute couture from one of the best-known and most trend-setting brands in fashion.' + .obs, + isBuy: false.obs, + isClickted: false.obs, + myFavorite: false.obs), + Books( + 'HARRY POTTER'.obs, + 'J.K Rowling'.obs, + '4.99'.obs, + 'https://i.ibb.co/zxSZz3T/photo-2022-08-26-03-13-52.jpg'.obs, + 'A spectacular visual journey through 40 years of haute couture from one of the best-known and most trend-setting brands in fashion.' + .obs, + isBuy: false.obs, + isClickted: false.obs, + myFavorite: false.obs), + Books( + 'Siege and Storm'.obs, + 'Leigh Bardugo'.obs, + '4.99'.obs, + 'https://i.ibb.co/jgs4xWS/44.png'.obs, + 'A spectacular visual journey through 40 years of haute couture from one of the best-known and most trend-setting brands in fashion.' + .obs, + isBuy: false.obs, + isClickted: false.obs, + myFavorite: false.obs), + Books( + 'Dracula'.obs, + 'Bram Stoker'.obs, + '4.99'.obs, + 'https://i.ibb.co/rkLHRbW/55.jpg'.obs, + 'A spectacular visual journey through 40 years of haute couture from one of the best-known and most trend-setting brands in fashion.A spectacular visual journey through 40 years of haute couture from one of the best-known and most trend-setting brands in fashion.A spectacular visual journey through 40 years of haute couture from one of the best-known and most trend-setting brands in fashion.' + .obs, + isBuy: false.obs, + isClickted: false.obs, + myFavorite: false.obs), + ]; + final RxString bookName; + final RxString authorName; + final RxString price; + final RxString imageLink; + final RxString description; + final RxBool isBuy; + final RxBool isClickted; + final RxBool myFavorite; + + Books(this.bookName, this.authorName, this.price, this.imageLink, + this.description, + {required this.isBuy, + required this.isClickted, + required this.myFavorite}); + + static final RxBool isLoading = false.obs; + static final RxString typed = ''.obs; + static final RxBool found = false.obs; + + static Loading() async { + isLoading.value = true; + + typed.value = ''; + isLoading.value = false; + } + + Future sendRequest() async { + await Future.delayed(Duration(seconds: 2)); + if (typed.value.length < 5) return false; + return true; + } + + makeBuy() { + isBuy.value = true; + } + + makeClickted() { + isClickted.value = true; + } + + makeAsDone() { + if (myFavorite.value == false) { + myFavorite.value = true; + } else { + myFavorite.value = false; + } + } +} diff --git a/lib/page1/ListView.dart b/lib/page1/ListView.dart new file mode 100644 index 0000000..8ae41b8 --- /dev/null +++ b/lib/page1/ListView.dart @@ -0,0 +1,106 @@ +import 'dart:math'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../View_book/Name+Aother.dart'; +import '../View_book/View_book_main_page.dart'; +import '../favorite_page/favorite.dart'; +import '../model.dart'; + +class books_card extends StatelessWidget { + const books_card({ + Key? key, + required this.books, + required this.color, + }) : super(key: key); + final Books books; + final Color? color; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(bottom: 30), + child: Obx(() { + return GestureDetector( + onTap: () { + books.isClickted.value = true; + Get.to(Veiw_Books( + note: books, + )); + }, + child: Container( + height: 120, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Container( + height: 120, + width: 80, + decoration: BoxDecoration( + // color: Colors.red, + image: DecorationImage( + image: NetworkImage(books.imageLink.value), + fit: BoxFit.cover), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(5), + bottomLeft: Radius.circular(5), + topRight: Radius.circular(10), + bottomRight: Radius.circular(10)))), + Padding( + padding: const EdgeInsets.only(left: 30), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox( + height: 15, + ), + Text( + books.bookName.value, + style: const TextStyle( + fontSize: 16, fontWeight: FontWeight.w600), + ), + const SizedBox( + height: 10, + ), + Text( + books.authorName.value, + style: const TextStyle( + fontSize: 12, fontWeight: FontWeight.w500), + ), + const SizedBox( + height: 10, + ), + Text( + "\$ ${books.price.value}", + style: const TextStyle( + fontSize: 12, fontWeight: FontWeight.w500), + ), + const Align( + alignment: Alignment.bottomCenter, child: star()) + ], + ), + ), + ], + ), + IconButton( + onPressed: () { + books.makeAsDone(); + }, + icon: Icon(Icons.favorite, + size: 30, + color: books.myFavorite == true + ? Colors.red + : Colors.grey)), + ], + ), + ), + ); + }), + ); + } +} diff --git a/lib/page1/Stack_part.dart b/lib/page1/Stack_part.dart new file mode 100644 index 0000000..42378b7 --- /dev/null +++ b/lib/page1/Stack_part.dart @@ -0,0 +1,95 @@ +import 'package:book_store_app/Card/Card_main_page.dart'; +import 'package:book_store_app/favorite_page/favorite.dart'; +import 'package:book_store_app/page1/main_page1.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:get/get_core/src/get_main.dart'; + +import '../page2_Add_books/Add_books_main_page.dart'; + +class Stack_part extends StatelessWidget { + const Stack_part({ + Key? key, required this.color_home, required this.color_shopping, required this.color_favorite, + }) : super(key: key); + + final Color color_home; + final Color color_shopping; + final Color color_favorite; + + + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.only(bottom: 42), + child: Align( + alignment: Alignment.bottomCenter, + child: Container( + height: 72, + width: 250, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(22), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + IconButton( + onPressed: () { + Get.to( + duration: Duration(milliseconds: 200), //duration of transitions, default 1 sec + transition: Transition.fadeIn, + Main_page1(), + ); + + }, + icon: Icon( + Icons.home_filled, + size: 30, + color: color_home, + )), + IconButton( + onPressed: () { + Get.to(Card1(), + duration: Duration(milliseconds: 200), //duration of transitions, default 1 sec + transition: Transition.fadeIn); + + }, + icon: Icon( + Icons.shopping_cart_outlined, + size: 30, + color: color_shopping + )), + IconButton( + onPressed: () { + Get.to(const Add_books(), + duration: Duration(milliseconds: 200), //duration of transitions, default 1 sec + transition: Transition.fadeIn); + }, + icon: const Icon( + Icons.add, + size: 32, + color: Colors.black26, + )), + + + IconButton( + onPressed: () { + Get.to(const Favorite(), + duration: Duration(milliseconds: 200), //duration of transitions, default 1 sec + transition: Transition.fadeIn); + }, + icon: Icon( + Icons.favorite, + size: 30, + color: color_favorite + )), + + ], + ), + ), + ), + ); + } +} diff --git a/lib/page1/Title_OF_list.dart b/lib/page1/Title_OF_list.dart new file mode 100644 index 0000000..a90b859 --- /dev/null +++ b/lib/page1/Title_OF_list.dart @@ -0,0 +1,25 @@ +import 'package:flutter/cupertino.dart'; + +class Title_OF_list extends StatelessWidget { + const Title_OF_list({ + Key? key, + this.title, + }) : super(key: key); + final title; + + @override + Widget build(BuildContext context) { + return Container( + child: Padding( + padding: const EdgeInsets.only(top: 30), + child: Align( + alignment: Alignment.centerLeft, + child: Text( + title, + style: TextStyle(fontSize: 28, fontWeight: FontWeight.w600), + ), + ), + ), + ); + } +} diff --git a/lib/page1/main_page1.dart b/lib/page1/main_page1.dart new file mode 100644 index 0000000..7db0a36 --- /dev/null +++ b/lib/page1/main_page1.dart @@ -0,0 +1,114 @@ +import 'package:book_store_app/model.dart'; +import 'package:book_store_app/page1/photo_name.dart'; +import 'package:book_store_app/page1/text_field.dart'; +import 'package:book_store_app/page2_Add_books/Add_books_main_page.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart'; +import '../View_book/Name+Aother.dart'; +import 'ListView.dart'; +import 'Stack_part.dart'; +import 'Title_OF_list.dart'; + +class Main_page1 extends StatefulWidget { + const Main_page1({Key? key}) : super(key: key); + + @override + State createState() => _Main_page1State(); +} + +final RxBool isEmpty1 = true.obs; +late final Books books; +final TextEditingController searchController = TextEditingController(); + +class _Main_page1State extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xFFEFEFEF), + body: Padding( + padding: const EdgeInsets.only(left: 30, right: 30, top: 55), + child: Obx(() { + return Stack( + children: [ + Column( + children: [ + page1_up(), + Padding( + padding: const EdgeInsets.only(top: 30), + child: Container( + width: 350, + height: 50, + child: TextField( + controller: searchController, + onChanged: (x) { + Books.typed.value = x; + + if (Books.typed == "") { + isEmpty1.value = true; + } else { + isEmpty1.value = false; + } + }, + style: const TextStyle(fontSize: 20), + maxLines: 1, + minLines: 1, + textInputAction: TextInputAction.newline, + decoration: InputDecoration( + filled: true, + fillColor: Colors.black.withOpacity(0.07), + hintText: 'Search... ', + suffixIcon: Icon( + Icons.search_rounded, + size: 30, + color: Books.typed.isEmpty + ? Colors.grey + : Colors.blue, + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(5), + borderSide: BorderSide.none, + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(5), + borderSide: BorderSide.none, + ), + ), + ), + ), + ), + const Title_OF_list(title: "Book List"), + if (isEmpty1.value == false) + Expanded( + child: ListView( + children: Books.bookList + .where((e) => e.bookName.value + .toLowerCase() + .contains(Books.typed.value.toLowerCase())) + .map((e) => books_card(books: e, color: Colors.red)) + .toList(), + ), + ), + if (isEmpty1.value == true) + Expanded( + child: ListView( + children: Books.bookList + .map((e) => books_card(books: e, color: Colors.red)) + .toList(), + ), + ), + ], + ), + Stack_part( + color_home: Colors.black, + color_shopping: Colors.black26, + color_favorite: Colors.black26, + ) + ], + ); + }), + ), + ); + } +} diff --git a/lib/page1/photo_name.dart b/lib/page1/photo_name.dart new file mode 100644 index 0000000..55b59bc --- /dev/null +++ b/lib/page1/photo_name.dart @@ -0,0 +1,47 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class page1_up extends StatelessWidget { + const page1_up({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + width: 50, + height: 50, + child: ClipRRect( + borderRadius: BorderRadius.circular(15), // Image border + child: SizedBox.fromSize( + size: Size.fromRadius(100), // Image radius + child: Image.network( + 'https://i.ibb.co/sqRnWcX/tamara-bellis-e-DVQw-VMLMg-U-unsplash.jpg', + fit: BoxFit.cover), + ), + )), + SizedBox( + width: 10, + ), + Text( + "Hi, Ibraheem!", + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + ), + ], + ), + Icon( + Icons.more_vert, + size: 30, + ) + ], + ), + ); + } +} diff --git a/lib/page1/text_field.dart b/lib/page1/text_field.dart new file mode 100644 index 0000000..7c48d43 --- /dev/null +++ b/lib/page1/text_field.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; +import 'main_page1.dart'; + +class MyInputField extends StatelessWidget { + const MyInputField({ + Key? key, + required this.MyController, + required this.text, + required this.width, + required this.height, + required this.ICON, + required this.type, this.inputtype, + }) : super(key: key); + + final TextEditingController MyController; + final String text; + final double width; + final double height; + final Widget? ICON; + final TextInputType type; + final TextInputAction? inputtype; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 20), + child: Container( + width: width, + height: height, + child: TextField( + controller: MyController, + onChanged: (x) {}, + + style: const TextStyle(fontSize: 20), + maxLines: 1, + minLines: 1, + keyboardType: type, + textInputAction: inputtype, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + hintText: '$text', + suffixIcon: ICON, + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(5), + borderSide: BorderSide.none, + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(5), + borderSide: BorderSide.none, + ), + + + + + ), + ), + ), + ); + } +} diff --git a/lib/page2_Add_books/Add_books_main_page.dart b/lib/page2_Add_books/Add_books_main_page.dart new file mode 100644 index 0000000..82bc45c --- /dev/null +++ b/lib/page2_Add_books/Add_books_main_page.dart @@ -0,0 +1,127 @@ +import 'package:book_store_app/page1/text_field.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:book_store_app/model.dart'; +import 'package:get/get.dart'; +import 'package:iconsax/iconsax.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import '../page1/Title_OF_list.dart'; +import '../page1/main_page1.dart'; +import 'Add_button.dart'; +import 'App_bar.dart'; + +class Add_books extends StatefulWidget { + const Add_books({Key? key}) : super(key: key); + + @override + State createState() => _Add_booksState(); +} + +final TextEditingController book_name = TextEditingController(); +final TextEditingController auther_name = TextEditingController(); +final TextEditingController price = TextEditingController(); +final TextEditingController link = TextEditingController(); +final TextEditingController Description = TextEditingController(); +late final RxInt booksid1 = 10 as RxInt; + +class _Add_booksState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xFFEFEFEF), + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.only(left: 30, right: 30, top: 55), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: () { + Get.to(Main_page1(), + duration: Duration( + milliseconds: + 200), //duration of transitions, default 1 sec + transition: Transition.fadeIn); + }, + icon: const Icon( + Icons.arrow_back_ios, + size: 30, + ), + ), + IconButton( + onPressed: () {}, + icon: const Icon( + Icons.more_vert, + size: 30, + ), + ), + ], + ), + const Title_OF_list( + title: "Add Book", + ), + MyInputField( + MyController: book_name, + text: "Book Name", + width: 350, + height: 60, + ICON: null, + type: TextInputType.text, + ), + MyInputField( + MyController: auther_name, + text: "Author Name", + width: 350, + height: 60, + ICON: null, + type: TextInputType.text, + ), + MyInputField( + MyController: price, + text: "Price", + width: 350, + height: 60, + ICON: null, + type: TextInputType.text, + ), + MyInputField( + MyController: link, + text: "Image link", + width: 350, + height: 60, + ICON: null, + type: TextInputType.text, + ), + Padding( + padding: const EdgeInsets.only(top: 20, bottom: 5), + child: TextField( + style: const TextStyle(fontSize: 20, height: 1), + keyboardType: TextInputType.text, + controller: Description, + onChanged: (x) {}, + maxLines: 5, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + hintText: 'Description', + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(5), + borderSide: BorderSide.none, + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(5), + borderSide: BorderSide.none, + ), + ), + ), + ), + Add_button() + ], + ), + ), + ), + ); + } +} diff --git a/lib/page2_Add_books/Add_button.dart b/lib/page2_Add_books/Add_button.dart new file mode 100644 index 0000000..88581b2 --- /dev/null +++ b/lib/page2_Add_books/Add_button.dart @@ -0,0 +1,102 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:iconsax/iconsax.dart'; + +import '../model.dart'; +import '../page1/main_page1.dart'; +import 'Add_books_main_page.dart'; + +class Add_button extends StatelessWidget { + const Add_button({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 20), + child: Container( + width: 285, + height: 60, + child: ElevatedButton( + child: Text("Add".toUpperCase(), + style: TextStyle(fontSize: 18)), + style: ButtonStyle( + foregroundColor: + MaterialStateProperty.all(Colors.white), + backgroundColor: + MaterialStateProperty.all(Color(0xFF06070D)), + shape: + MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + side: + BorderSide(color: Color(0xFF06070D)))), + ), + onPressed: () async { + if (book_name.text.obs.isEmpty || + auther_name.text.obs.isEmpty || + price.text.obs.isEmpty || + link.text.obs.isEmpty || + Description.text.obs.isEmpty) { + Get.snackbar( + 'Error', + 'One or more of Text field is Empty', + colorText: Colors.white, + animationDuration: Duration(milliseconds: 500), + barBlur: 100, + backgroundColor: Colors.black, + duration: Duration(seconds: 2), + padding: EdgeInsets.only( + left: 20, top: 20, bottom: 20, right: 50), + icon: const Icon( + Iconsax.warning_24, + color: Colors.amber, + size: 30, + ), + ); + } else { + Books.bookList.add( + Books( + book_name.text.obs, + auther_name.text.obs, + price.text.obs, + link.text.obs, + Description.text.obs, + isBuy: false.obs, + isClickted: false.obs, + myFavorite: false.obs), + ); + Get.snackbar( + 'successful', + 'The book has been added', + colorText: Colors.green, + animationDuration: Duration(milliseconds: 500), + barBlur: 100, + backgroundColor: Colors.white, + duration: Duration(seconds: 2), + padding: EdgeInsets.only( + left: 20, top: 20, bottom: 20, right: 50), + icon: const Icon( + Iconsax.chart_success4, + color: Colors.green, + size: 30, + ), + ); + + await Future.delayed(Duration(seconds: 2)); + + Get.to(Main_page1()); + + Description.text = ""; + link.text = ""; + price.text = ""; + auther_name.text = ""; + book_name.text = ""; + } + }, + )), + ); + } +} diff --git a/lib/page2_Add_books/App_bar.dart b/lib/page2_Add_books/App_bar.dart new file mode 100644 index 0000000..daa30e1 --- /dev/null +++ b/lib/page2_Add_books/App_bar.dart @@ -0,0 +1,50 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../model.dart'; +import '../page1/main_page1.dart'; + +class App_bar extends StatelessWidget { + const App_bar({ + Key? key, + required this.books, + }) : super(key: key); + final Books books; + + @override + Widget build(BuildContext context) { + return Builder(builder: (context) { + return Container( + height: 50, + color: Color(0xFFEFEFEF), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: () { + Get.to(Main_page1(), + duration: Duration( + milliseconds: + 200), //duration of transitions, default 1 sec + transition: Transition.fadeIn); + books.isClickted.value = false; + }, + icon: Icon( + Icons.arrow_back_ios, + size: 30, + ), + ), + IconButton( + onPressed: () {}, + icon: Icon( + Icons.more_vert, + size: 30, + ), + ), + ], + ), + ); + }); + } +} diff --git a/pubspec.lock b/pubspec.lock index 7bc8bdd..64eb6e7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,21 +21,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: @@ -56,7 +49,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -74,6 +67,34 @@ packages: description: flutter source: sdk version: "0.0.0" + font_awesome_flutter: + dependency: "direct main" + description: + name: font_awesome_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "10.1.0" + get: + dependency: "direct main" + description: + name: get + url: "https://pub.dartlang.org" + source: hosted + version: "4.6.5" + iconsax: + dependency: "direct main" + description: + name: iconsax + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.8" + ionicons: + dependency: "direct main" + description: + name: ionicons + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.1" lints: dependency: transitive description: @@ -87,28 +108,28 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" sky_engine: dependency: transitive description: flutter @@ -120,7 +141,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.2" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -141,21 +162,21 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.9" + version: "0.4.12" vector_math: dependency: transitive description: @@ -165,3 +186,4 @@ packages: version: "2.1.2" sdks: dart: ">=2.17.6 <3.0.0" + flutter: ">=1.17.0" diff --git a/pubspec.yaml b/pubspec.yaml index cd0f457..38403aa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,10 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + get: ^4.6.5 + iconsax: ^0.0.8 + ionicons: ^0.2.1 + font_awesome_flutter: ^10.1.0 dev_dependencies: flutter_test: