From d12bc82dc4f87480f9a1d92957df987977a3397f Mon Sep 17 00:00:00 2001 From: devsadeq Date: Sat, 27 Aug 2022 23:25:26 +0300 Subject: [PATCH 01/22] =?UTF-8?q?initial=20commit=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index bcc58f7..c535068 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,7 +12,7 @@ class MyApp extends StatelessWidget { return const MaterialApp( home: Scaffold( body: Center( - child: Text("Book Store App"), + child: Text("Hello World"), ), ), ); From ae4381b2737850144ff042d7f7c975b423217417 Mon Sep 17 00:00:00 2001 From: devsadeq Date: Sun, 28 Aug 2022 21:05:53 +0300 Subject: [PATCH 02/22] prepare store data --- lib/data/data_source.dart | 50 +++++++++++++++++++++++++++++++++++++++ lib/data/models/book.dart | 17 +++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 lib/data/data_source.dart create mode 100644 lib/data/models/book.dart diff --git a/lib/data/data_source.dart b/lib/data/data_source.dart new file mode 100644 index 0000000..fa01224 --- /dev/null +++ b/lib/data/data_source.dart @@ -0,0 +1,50 @@ +import 'package:get/get.dart'; + +import 'models/book.dart'; + +class DataSource { + static RxList localBooks = [ + Book( + title: "A Tale of Two Cities", + author: "Charles Dickens", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2", + rate: 5.0, + price: 99.99, + ), + Book( + title: "The Little Prince", + author: "Antoine de Saint-Exupéry", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2", + rate: 4.3, + price: 46.99, + ), + Book( + title: "Harry Potter and the Philosopher's Stone", + author: "J.K.Rowling", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2", + rate: 3.0, + price: 64.99, + ), + Book( + title: "Mockingjay", + author: "Suzanne Collins", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2", + rate: 4.0, + price: 52.99, + ), + Book( + title: "Me Before You", + author: "Jojo Moyes", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2", + rate: 4.9, + price: 30.99, + ), + Book( + title: "Harry Potter and the Philosopher's Stone", + author: "J.K.Rowling", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2", + rate: 3.0, + price: 64.99, + ), + ].obs; +} diff --git a/lib/data/models/book.dart b/lib/data/models/book.dart new file mode 100644 index 0000000..73334fc --- /dev/null +++ b/lib/data/models/book.dart @@ -0,0 +1,17 @@ +class Book { + String? title; + String? author; + String? cover; + String? description; + double? price; + double rate; + + Book({ + this.title, + this.author, + this.cover, + this.description, + this.price, + this.rate = 0.0, + }); +} From 67bfe27af6a8518c87240c25ce3616584008c602 Mon Sep 17 00:00:00 2001 From: devsadeq Date: Sun, 28 Aug 2022 21:06:36 +0300 Subject: [PATCH 03/22] prepare store theme --- lib/core/theme.dart | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/core/theme.dart diff --git a/lib/core/theme.dart b/lib/core/theme.dart new file mode 100644 index 0000000..13e09ea --- /dev/null +++ b/lib/core/theme.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; + +class AppTheme { + const AppTheme._(); + + // Light Theme Colors. + static Color lightBackgroundColor = const Color(0xffFDFDFD); + static Color lightPrimaryColor = const Color(0xff06070D); + static Color lightSecondaryColor = lightPrimaryColor.withOpacity(0.5); + static Color lightTertiaryColor = const Color(0xff9C9EA8); + static Color lightErrorColor = const Color(0xffe63946); + + static final lightTheme = ThemeData( + brightness: Brightness.light, + backgroundColor: lightBackgroundColor, + errorColor: lightErrorColor, + primaryColor: lightPrimaryColor, + textTheme: _textTheme, + colorScheme: _colorScheme, + visualDensity: VisualDensity.adaptivePlatformDensity, + ); + + static final _textTheme = const TextTheme().copyWith(); + + static final _colorScheme = ColorScheme.light( + secondary: lightSecondaryColor, + tertiary: lightTertiaryColor, + ); +} From 510e42d4012e3a0a6a321ccb260398efc3107752 Mon Sep 17 00:00:00 2001 From: devsadeq Date: Sun, 28 Aug 2022 21:07:05 +0300 Subject: [PATCH 04/22] create home view --- lib/controllers/home_controller.dart | 18 +++ lib/main.dart | 12 +- lib/views/home/home_view.dart | 18 +++ lib/views/home/widgets/body.dart | 30 ++++ lib/views/home/widgets/book_list.dart | 73 +++++++++ lib/views/home/widgets/header.dart | 40 +++++ lib/views/home/widgets/search_bar.dart | 41 +++++ lib/widgets/big_title.dart | 18 +++ lib/widgets/fading_list.dart | 29 ++++ lib/widgets/rate_stars.dart | 38 +++++ macos/Flutter/GeneratedPluginRegistrant.swift | 2 + pubspec.lock | 141 ++++++++++++++++++ pubspec.yaml | 7 +- 13 files changed, 457 insertions(+), 10 deletions(-) create mode 100644 lib/controllers/home_controller.dart create mode 100644 lib/views/home/home_view.dart create mode 100644 lib/views/home/widgets/body.dart create mode 100644 lib/views/home/widgets/book_list.dart create mode 100644 lib/views/home/widgets/header.dart create mode 100644 lib/views/home/widgets/search_bar.dart create mode 100644 lib/widgets/big_title.dart create mode 100644 lib/widgets/fading_list.dart create mode 100644 lib/widgets/rate_stars.dart diff --git a/lib/controllers/home_controller.dart b/lib/controllers/home_controller.dart new file mode 100644 index 0000000..4a86642 --- /dev/null +++ b/lib/controllers/home_controller.dart @@ -0,0 +1,18 @@ +import 'package:get/get.dart'; + +class HomeController extends GetxController { + @override + void onInit() { + super.onInit(); + } + + @override + void onReady() { + super.onReady(); + } + + @override + void onClose() { + super.onClose(); + } +} diff --git a/lib/main.dart b/lib/main.dart index c535068..97ab449 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,5 @@ +import 'package:book_store_app/core/theme.dart'; +import 'package:book_store_app/views/home/home_view.dart'; import 'package:flutter/material.dart'; void main() { @@ -9,12 +11,10 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return const MaterialApp( - home: Scaffold( - body: Center( - child: Text("Hello World"), - ), - ), + return MaterialApp( + debugShowCheckedModeBanner: false, + theme: AppTheme.lightTheme, + home: HomeView(), ); } } diff --git a/lib/views/home/home_view.dart b/lib/views/home/home_view.dart new file mode 100644 index 0000000..05b1592 --- /dev/null +++ b/lib/views/home/home_view.dart @@ -0,0 +1,18 @@ +import 'package:book_store_app/controllers/home_controller.dart'; +import 'package:book_store_app/views/home/widgets/body.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class HomeView extends GetView { + const HomeView({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + backgroundColor: Theme.of(context).backgroundColor, + body: Body(), + ), + ); + } +} diff --git a/lib/views/home/widgets/body.dart b/lib/views/home/widgets/body.dart new file mode 100644 index 0000000..939619b --- /dev/null +++ b/lib/views/home/widgets/body.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +import '../../../widgets/big_title.dart'; +import 'book_list.dart'; +import 'header.dart'; +import 'search_bar.dart'; + +class Body extends StatelessWidget { + const Body({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 40, right: 16, left: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: const [ + Header(), + SizedBox(height: 30), + SearchBar(), + SizedBox(height: 30), + BigTitle(title: 'Book List'), + SizedBox(height: 15), + Expanded(child: BookList()), + ], + ), + ); + } +} diff --git a/lib/views/home/widgets/book_list.dart b/lib/views/home/widgets/book_list.dart new file mode 100644 index 0000000..7854048 --- /dev/null +++ b/lib/views/home/widgets/book_list.dart @@ -0,0 +1,73 @@ +import 'package:book_store_app/widgets/fading_list.dart'; +import 'package:book_store_app/widgets/rate_stars.dart'; +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +import '../../../data/data_source.dart'; + +class BookList extends StatelessWidget { + const BookList({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return FadingListView( + listView: ListView.builder( + shrinkWrap: true, + scrollDirection: Axis.vertical, + itemCount: DataSource.localBooks.length, + physics: const BouncingScrollPhysics(), + itemBuilder: (context, index) => Container( + margin: const EdgeInsets.symmetric(vertical: 10), + child: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(5), + child: Image.network( + "${DataSource.localBooks[index].cover!}$index", + height: 106, + fit: BoxFit.fill, + ), + ), + const SizedBox(width: 20), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + DataSource.localBooks[index].title!, + style: GoogleFonts.poppins( + color: Theme.of(context).primaryColor, + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(height: 4), + Text( + DataSource.localBooks[index].author!, + style: GoogleFonts.poppins( + color: Theme.of(context).colorScheme.secondary, + fontSize: 12, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 8), + Text( + "\$${DataSource.localBooks[index].price}", + style: GoogleFonts.poppins( + color: const Color(0xff191919), + fontSize: 14, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 5), + // Text(DataSource.localBooks[index].rate.toString()), + const RateStars(), + ], + ) + ], + ), + ), + ), + ); + } +} diff --git a/lib/views/home/widgets/header.dart b/lib/views/home/widgets/header.dart new file mode 100644 index 0000000..cd11631 --- /dev/null +++ b/lib/views/home/widgets/header.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +class Header extends StatelessWidget { + const Header({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + SizedBox( + height: 50, + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: + Image.network("https://api.lorem.space/image/face?w=150&h=150"), + ), + ), + const SizedBox(width: 12), + Text( + "Hi, Ali!", + style: GoogleFonts.poppins( + fontWeight: FontWeight.w600, + fontSize: 16, + color: Theme.of(context).primaryColor), + ), + const Spacer(), + IconButton( + padding: EdgeInsets.zero, + constraints: BoxConstraints(), + onPressed: () {}, + icon: Icon( + Icons.more_vert, + color: Theme.of(context).primaryColor, + ), + ), + ], + ); + } +} diff --git a/lib/views/home/widgets/search_bar.dart b/lib/views/home/widgets/search_bar.dart new file mode 100644 index 0000000..eac8a7c --- /dev/null +++ b/lib/views/home/widgets/search_bar.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +class SearchBar extends StatelessWidget { + const SearchBar({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: const Color(0xff07080E).withOpacity(0.05), + spreadRadius: 7, + blurRadius: 32, + offset: const Offset(0, 4), + ) + ], + borderRadius: BorderRadius.circular(8), + ), + child: Padding( + padding: const EdgeInsets.all(15), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Search...", + style: GoogleFonts.poppins( + color: Theme.of(context).colorScheme.secondary, + fontSize: 16, + fontWeight: FontWeight.w400 + ), + ), + const Icon(Icons.search), + ], + ), + ), + ); + } +} diff --git a/lib/widgets/big_title.dart b/lib/widgets/big_title.dart new file mode 100644 index 0000000..2eb840f --- /dev/null +++ b/lib/widgets/big_title.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +class BigTitle extends StatelessWidget { + const BigTitle({Key? key, required this.title}) : super(key: key); + final String title; + + @override + Widget build(BuildContext context) { + return Text( + title, + style: GoogleFonts.poppins( + fontSize: 24, + fontWeight: FontWeight.w600, + color: Theme.of(context).primaryColor), + ); + } +} diff --git a/lib/widgets/fading_list.dart b/lib/widgets/fading_list.dart new file mode 100644 index 0000000..734d4bb --- /dev/null +++ b/lib/widgets/fading_list.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; + +class FadingListView extends StatelessWidget { + const FadingListView({Key? key, required this.listView}) : super(key: key); + final ListView listView; + + @override + Widget build(BuildContext context) { + return Center( + child: ShaderMask( + shaderCallback: (Rect rect) { + return const LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Colors.purple, + Colors.transparent, + Colors.transparent, + Colors.purple + ], + stops: [0.0, 0.07, 1.0, 1.0], + ).createShader(rect); + }, + blendMode: BlendMode.dstOut, + child: listView, + ), + ); + } +} diff --git a/lib/widgets/rate_stars.dart b/lib/widgets/rate_stars.dart new file mode 100644 index 0000000..b1bc937 --- /dev/null +++ b/lib/widgets/rate_stars.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; + +class RateStars extends StatelessWidget { + const RateStars({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Icon( + Icons.star, + color: Color(0xffFFC41F), + size: 20, + ), + Icon( + Icons.star, + color: Color(0xffFFC41F), + size: 20, + ), + Icon( + Icons.star, + color: Color(0xffFFC41F), + size: 20, + ), + Icon( + Icons.star, + color: Color(0xffFFC41F), + size: 20, + ), + Icon( + Icons.star, + color: Color(0xffEDEDEF), + size: 20, + ), + ], + ); + } +} diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index cccf817..0d56f51 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,8 @@ import FlutterMacOS import Foundation +import path_provider_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 7bc8bdd..597974f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -43,6 +43,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.16.0" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" cupertino_icons: dependency: "direct main" description: @@ -57,6 +64,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.4" flutter: dependency: "direct main" description: flutter @@ -74,6 +95,34 @@ 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" + google_fonts: + dependency: "direct main" + description: + name: google_fonts + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.5" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.1" lints: dependency: transitive description: @@ -109,6 +158,76 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.1" + path_provider: + dependency: transitive + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.20" + path_provider_ios: + dependency: transitive + description: + name: path_provider_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.7" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.6" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.2" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" sky_engine: dependency: transitive description: flutter @@ -156,6 +275,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.9" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" vector_math: dependency: transitive description: @@ -163,5 +289,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.7.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0+2" sdks: dart: ">=2.17.6 <3.0.0" + flutter: ">=3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index cd0f457..abfe06b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,11 +29,9 @@ environment: dependencies: flutter: 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 + google_fonts: ^3.0.1 dev_dependencies: flutter_test: @@ -46,6 +44,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 From fec2bbc262de22f7d99d86fdcab8895fc3ca3baa Mon Sep 17 00:00:00 2001 From: devsadeq Date: Mon, 29 Aug 2022 03:19:26 +0300 Subject: [PATCH 05/22] create routers --- lib/main.dart | 8 ++++++-- lib/routes/app_pages.dart | 14 ++++++++++++++ lib/routes/app_routes.dart | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 lib/routes/app_pages.dart create mode 100644 lib/routes/app_routes.dart diff --git a/lib/main.dart b/lib/main.dart index 97ab449..d7f36e8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,9 @@ import 'package:book_store_app/core/theme.dart'; +import 'package:book_store_app/routes/app_pages.dart'; +import 'package:book_store_app/routes/app_routes.dart'; import 'package:book_store_app/views/home/home_view.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; void main() { runApp(const MyApp()); @@ -11,10 +14,11 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialApp( + return GetMaterialApp( debugShowCheckedModeBanner: false, theme: AppTheme.lightTheme, - home: HomeView(), + initialRoute: AppRoutes.DASHBOARD, + getPages: AppPages.list, ); } } diff --git a/lib/routes/app_pages.dart b/lib/routes/app_pages.dart new file mode 100644 index 0000000..62aa0b3 --- /dev/null +++ b/lib/routes/app_pages.dart @@ -0,0 +1,14 @@ +import 'package:book_store_app/bindings/dashboard.dart'; +import 'package:book_store_app/routes/app_routes.dart'; +import 'package:book_store_app/views/dashboard/dashboard_view.dart'; +import 'package:get/get.dart'; + +class AppPages { + static var list = [ + GetPage( + name: AppRoutes.DASHBOARD, + page: () => DashboardView(), + binding: DashboardBinding(), + ), + ]; +} diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart new file mode 100644 index 0000000..86bc040 --- /dev/null +++ b/lib/routes/app_routes.dart @@ -0,0 +1,3 @@ +class AppRoutes { + static const String DASHBOARD = '/'; +} From 9ce1074ed9852c99e66d5b6d0d0f338e35da631a Mon Sep 17 00:00:00 2001 From: devsadeq Date: Mon, 29 Aug 2022 03:20:35 +0300 Subject: [PATCH 06/22] import figma icons --- assets/images/icons/add.svg | 3 +++ assets/images/icons/cart.svg | 3 +++ assets/images/icons/home.svg | 3 +++ assets/images/icons/search.svg | 3 +++ pubspec.lock | 42 ++++++++++++++++++++++++++++++++++ pubspec.yaml | 7 +++--- 6 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 assets/images/icons/add.svg create mode 100644 assets/images/icons/cart.svg create mode 100644 assets/images/icons/home.svg create mode 100644 assets/images/icons/search.svg diff --git a/assets/images/icons/add.svg b/assets/images/icons/add.svg new file mode 100644 index 0000000..8fa6e3b --- /dev/null +++ b/assets/images/icons/add.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/icons/cart.svg b/assets/images/icons/cart.svg new file mode 100644 index 0000000..2c4f130 --- /dev/null +++ b/assets/images/icons/cart.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/icons/home.svg b/assets/images/icons/home.svg new file mode 100644 index 0000000..8ee81c9 --- /dev/null +++ b/assets/images/icons/home.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/icons/search.svg b/assets/images/icons/search.svg new file mode 100644 index 0000000..b7e87e2 --- /dev/null +++ b/assets/images/icons/search.svg @@ -0,0 +1,3 @@ + + + diff --git a/pubspec.lock b/pubspec.lock index 597974f..7575c05 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -90,11 +90,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" + 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: @@ -158,6 +172,20 @@ 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" path_provider: dependency: transitive description: @@ -207,6 +235,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.0" platform: dependency: transitive description: @@ -303,6 +338,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.2.0+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: ">=3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index abfe06b..6587fca 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -32,6 +32,8 @@ dependencies: cupertino_icons: ^1.0.2 get: ^4.6.5 google_fonts: ^3.0.1 + font_awesome_flutter: ^10.1.0 + flutter_svg: ^1.1.4 dev_dependencies: flutter_test: @@ -57,9 +59,8 @@ 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/icons/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware From d3692a0103fa79a03215b75d6673ef1c05e969b3 Mon Sep 17 00:00:00 2001 From: devsadeq Date: Mon, 29 Aug 2022 03:21:31 +0300 Subject: [PATCH 07/22] change search icon --- lib/views/home/widgets/search_bar.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/views/home/widgets/search_bar.dart b/lib/views/home/widgets/search_bar.dart index eac8a7c..96ac3a8 100644 --- a/lib/views/home/widgets/search_bar.dart +++ b/lib/views/home/widgets/search_bar.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_fonts/google_fonts.dart'; class SearchBar extends StatelessWidget { @@ -27,12 +28,11 @@ class SearchBar extends StatelessWidget { Text( "Search...", style: GoogleFonts.poppins( - color: Theme.of(context).colorScheme.secondary, - fontSize: 16, - fontWeight: FontWeight.w400 - ), + color: Theme.of(context).colorScheme.secondary, + fontSize: 16, + fontWeight: FontWeight.w400), ), - const Icon(Icons.search), + SvgPicture.asset("assets/images/icons/search.svg"), ], ), ), From 57c843459fc6ac3a9307f6799bb698e14b4e8b24 Mon Sep 17 00:00:00 2001 From: devsadeq Date: Mon, 29 Aug 2022 03:23:05 +0300 Subject: [PATCH 08/22] create bottom navigation bar --- lib/bindings/dashboard.dart | 11 +++ lib/controllers/dashboard.dart | 10 +++ lib/views/dashboard/dashboard_view.dart | 15 +++++ lib/views/dashboard/widgets/body.dart | 30 +++++++++ lib/views/dashboard/widgets/bottom_nav.dart | 74 +++++++++++++++++++++ 5 files changed, 140 insertions(+) create mode 100644 lib/bindings/dashboard.dart create mode 100644 lib/controllers/dashboard.dart create mode 100644 lib/views/dashboard/dashboard_view.dart create mode 100644 lib/views/dashboard/widgets/body.dart create mode 100644 lib/views/dashboard/widgets/bottom_nav.dart diff --git a/lib/bindings/dashboard.dart b/lib/bindings/dashboard.dart new file mode 100644 index 0000000..b843220 --- /dev/null +++ b/lib/bindings/dashboard.dart @@ -0,0 +1,11 @@ +import 'package:book_store_app/controllers/dashboard.dart'; +import 'package:book_store_app/controllers/home_controller.dart'; +import 'package:get/get.dart'; + +class DashboardBinding extends Bindings { + @override + void dependencies() { + Get.lazyPut(() => DashboardController()); + Get.lazyPut(() => HomeController()); + } +} diff --git a/lib/controllers/dashboard.dart b/lib/controllers/dashboard.dart new file mode 100644 index 0000000..864c0da --- /dev/null +++ b/lib/controllers/dashboard.dart @@ -0,0 +1,10 @@ +import 'package:get/get.dart'; + +class DashboardController extends GetxController { + var tabIndex = 0.obs; + + void changeTabIndex(int index) { + tabIndex.value = index; + // update(); + } +} diff --git a/lib/views/dashboard/dashboard_view.dart b/lib/views/dashboard/dashboard_view.dart new file mode 100644 index 0000000..78821fa --- /dev/null +++ b/lib/views/dashboard/dashboard_view.dart @@ -0,0 +1,15 @@ +import 'package:book_store_app/views/dashboard/widgets/body.dart'; +import 'package:flutter/material.dart'; + +class DashboardView extends StatelessWidget { + const DashboardView({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return const SafeArea( + child: Scaffold( + body: Body(), + ), + ); + } +} diff --git a/lib/views/dashboard/widgets/body.dart b/lib/views/dashboard/widgets/body.dart new file mode 100644 index 0000000..ab406ae --- /dev/null +++ b/lib/views/dashboard/widgets/body.dart @@ -0,0 +1,30 @@ +import 'package:book_store_app/controllers/dashboard.dart'; +import 'package:book_store_app/views/dashboard/widgets/bottom_nav.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../cart/cart_view.dart'; +import '../../home/home_view.dart'; + +class Body extends GetView { + const Body({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Stack( + children: [ + Obx( + () => IndexedStack( + index: controller.tabIndex.value, + children: const [ + HomeView(), + CartView(), + HomeView(), + ], + ), + ), + const CustomBottomNavBar(), + ], + ); + } +} diff --git a/lib/views/dashboard/widgets/bottom_nav.dart b/lib/views/dashboard/widgets/bottom_nav.dart new file mode 100644 index 0000000..02f6764 --- /dev/null +++ b/lib/views/dashboard/widgets/bottom_nav.dart @@ -0,0 +1,74 @@ +import 'package:book_store_app/controllers/dashboard.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:get/get.dart'; + +class CustomBottomNavBar extends GetView { + const CustomBottomNavBar({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Align( + alignment: Alignment.bottomCenter, + child: Container( + margin: const EdgeInsets.only(bottom: 42), + height: 72, + width: 227, + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: const Color(0xff07080E).withOpacity(0.05), + spreadRadius: 7, + blurRadius: 32, + offset: const Offset(0, 4), + ) + ], + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(22), + child: Obx( + () => BottomNavigationBar( + unselectedItemColor: const Color(0xff9C9EA8), + currentIndex: controller.tabIndex.value, + showSelectedLabels: false, + showUnselectedLabels: false, + backgroundColor: Colors.white, + elevation: 0, + onTap: controller.changeTabIndex, + items: [ + _bottomNavigationBarItem( + asset: "assets/images/icons/home.svg", + label: "Home", + index: 0, + ), + _bottomNavigationBarItem( + asset: "assets/images/icons/cart.svg", + label: "Cart", + index: 1, + ), + _bottomNavigationBarItem( + asset: "assets/images/icons/add.svg", + label: "Add", + index: 2, + ), + ], + ), + ), + ), + ), + ); + } + + _bottomNavigationBarItem( + {required String asset, required String label, required int index}) { + return BottomNavigationBarItem( + icon: SvgPicture.asset( + asset, + color: controller.tabIndex.value == index + ? const Color(0xff06070D) + : const Color(0xff9C9EA8), + ), + label: label, + ); + } +} From a6fe5816a655bda1bc3ef43ad50d58036a01f404 Mon Sep 17 00:00:00 2001 From: devsadeq Date: Mon, 29 Aug 2022 04:22:06 +0300 Subject: [PATCH 09/22] create page view --- lib/controllers/dashboard.dart | 20 +++++++++++++++++++- lib/views/dashboard/widgets/body.dart | 17 ++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/lib/controllers/dashboard.dart b/lib/controllers/dashboard.dart index 864c0da..69ab1f5 100644 --- a/lib/controllers/dashboard.dart +++ b/lib/controllers/dashboard.dart @@ -1,10 +1,28 @@ +import 'package:flutter/material.dart'; import 'package:get/get.dart'; class DashboardController extends GetxController { var tabIndex = 0.obs; + late PageController pageController; + + @override + void onInit() { + super.onInit(); + pageController = PageController(); + } + + @override + void onClose() { + super.onClose(); + pageController.dispose(); + } void changeTabIndex(int index) { tabIndex.value = index; - // update(); + pageController.animateToPage( + index, + duration: const Duration(milliseconds: 300), + curve: Curves.linear, + ); } } diff --git a/lib/views/dashboard/widgets/body.dart b/lib/views/dashboard/widgets/body.dart index ab406ae..e8d1acb 100644 --- a/lib/views/dashboard/widgets/body.dart +++ b/lib/views/dashboard/widgets/body.dart @@ -13,15 +13,14 @@ class Body extends GetView { Widget build(BuildContext context) { return Stack( children: [ - Obx( - () => IndexedStack( - index: controller.tabIndex.value, - children: const [ - HomeView(), - CartView(), - HomeView(), - ], - ), + PageView( + controller: controller.pageController, + onPageChanged: controller.changeTabIndex, + children: const [ + HomeView(), + CartView(), + HomeView(), + ], ), const CustomBottomNavBar(), ], From bec1eb38c35162cd9753c23922841b8166ba715d Mon Sep 17 00:00:00 2001 From: devsadeq Date: Mon, 29 Aug 2022 04:24:10 +0300 Subject: [PATCH 10/22] separate the widgets --- lib/views/home/widgets/body.dart | 12 ++--- lib/views/home/widgets/book_list.dart | 73 --------------------------- lib/views/home/widgets/header.dart | 40 --------------- lib/widgets/book_item.dart | 64 +++++++++++++++++++++++ lib/widgets/book_list.dart | 24 +++++++++ lib/widgets/header.dart | 53 +++++++++++++++++++ 6 files changed, 147 insertions(+), 119 deletions(-) delete mode 100644 lib/views/home/widgets/book_list.dart delete mode 100644 lib/views/home/widgets/header.dart create mode 100644 lib/widgets/book_item.dart create mode 100644 lib/widgets/book_list.dart create mode 100644 lib/widgets/header.dart diff --git a/lib/views/home/widgets/body.dart b/lib/views/home/widgets/body.dart index 939619b..f08b5c8 100644 --- a/lib/views/home/widgets/body.dart +++ b/lib/views/home/widgets/body.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; +import '../../../data/data_source.dart'; import '../../../widgets/big_title.dart'; -import 'book_list.dart'; -import 'header.dart'; +import '../../../widgets/book_list.dart'; +import '../../../widgets/header.dart'; import 'search_bar.dart'; class Body extends StatelessWidget { @@ -15,14 +15,14 @@ class Body extends StatelessWidget { padding: const EdgeInsets.only(top: 40, right: 16, left: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: const [ - Header(), + children: [ + Header(isHomeHeader: true), SizedBox(height: 30), SearchBar(), SizedBox(height: 30), BigTitle(title: 'Book List'), SizedBox(height: 15), - Expanded(child: BookList()), + Expanded(child: BookList(books: DataSource.localBooks)), ], ), ); diff --git a/lib/views/home/widgets/book_list.dart b/lib/views/home/widgets/book_list.dart deleted file mode 100644 index 7854048..0000000 --- a/lib/views/home/widgets/book_list.dart +++ /dev/null @@ -1,73 +0,0 @@ -import 'package:book_store_app/widgets/fading_list.dart'; -import 'package:book_store_app/widgets/rate_stars.dart'; -import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; - -import '../../../data/data_source.dart'; - -class BookList extends StatelessWidget { - const BookList({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return FadingListView( - listView: ListView.builder( - shrinkWrap: true, - scrollDirection: Axis.vertical, - itemCount: DataSource.localBooks.length, - physics: const BouncingScrollPhysics(), - itemBuilder: (context, index) => Container( - margin: const EdgeInsets.symmetric(vertical: 10), - child: Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(5), - child: Image.network( - "${DataSource.localBooks[index].cover!}$index", - height: 106, - fit: BoxFit.fill, - ), - ), - const SizedBox(width: 20), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - DataSource.localBooks[index].title!, - style: GoogleFonts.poppins( - color: Theme.of(context).primaryColor, - fontSize: 16, - fontWeight: FontWeight.w600, - ), - ), - const SizedBox(height: 4), - Text( - DataSource.localBooks[index].author!, - style: GoogleFonts.poppins( - color: Theme.of(context).colorScheme.secondary, - fontSize: 12, - fontWeight: FontWeight.w500, - ), - ), - const SizedBox(height: 8), - Text( - "\$${DataSource.localBooks[index].price}", - style: GoogleFonts.poppins( - color: const Color(0xff191919), - fontSize: 14, - fontWeight: FontWeight.w500, - ), - ), - const SizedBox(height: 5), - // Text(DataSource.localBooks[index].rate.toString()), - const RateStars(), - ], - ) - ], - ), - ), - ), - ); - } -} diff --git a/lib/views/home/widgets/header.dart b/lib/views/home/widgets/header.dart deleted file mode 100644 index cd11631..0000000 --- a/lib/views/home/widgets/header.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; - -class Header extends StatelessWidget { - const Header({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Row( - children: [ - SizedBox( - height: 50, - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: - Image.network("https://api.lorem.space/image/face?w=150&h=150"), - ), - ), - const SizedBox(width: 12), - Text( - "Hi, Ali!", - style: GoogleFonts.poppins( - fontWeight: FontWeight.w600, - fontSize: 16, - color: Theme.of(context).primaryColor), - ), - const Spacer(), - IconButton( - padding: EdgeInsets.zero, - constraints: BoxConstraints(), - onPressed: () {}, - icon: Icon( - Icons.more_vert, - color: Theme.of(context).primaryColor, - ), - ), - ], - ); - } -} diff --git a/lib/widgets/book_item.dart b/lib/widgets/book_item.dart new file mode 100644 index 0000000..54fc1ea --- /dev/null +++ b/lib/widgets/book_item.dart @@ -0,0 +1,64 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +import '../data/models/book.dart'; +import 'rate_stars.dart'; + +class BookItem extends StatelessWidget { + const BookItem({Key? key, required this.book}) : super(key: key); + final Book book; + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.symmetric(vertical: 10), + child: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(5), + child: Image.network( + book.cover!, + height: 106, + fit: BoxFit.fill, + ), + ), + const SizedBox(width: 20), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + book.title!, + style: GoogleFonts.poppins( + color: Theme.of(context).primaryColor, + fontSize: 16, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(height: 4), + Text( + book.author!, + style: GoogleFonts.poppins( + color: Theme.of(context).colorScheme.secondary, + fontSize: 12, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 8), + Text( + "\$${book.price}", + style: GoogleFonts.poppins( + color: const Color(0xff191919), + fontSize: 14, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 5), + const RateStars(), + ], + ) + ], + ), + ); + } +} diff --git a/lib/widgets/book_list.dart b/lib/widgets/book_list.dart new file mode 100644 index 0000000..982bd8d --- /dev/null +++ b/lib/widgets/book_list.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; + +import '../data/data_source.dart'; +import '../data/models/book.dart'; +import 'book_item.dart'; +import 'fading_list.dart'; + +class BookList extends StatelessWidget { + const BookList({Key? key, required this.books}) : super(key: key); + final List? books; + + @override + Widget build(BuildContext context) { + return FadingListView( + listView: ListView.builder( + shrinkWrap: true, + scrollDirection: Axis.vertical, + itemCount: DataSource.localBooks.length, + physics: const BouncingScrollPhysics(), + itemBuilder: (context, index) => BookItem(book: books![index]), + ), + ); + } +} diff --git a/lib/widgets/header.dart b/lib/widgets/header.dart new file mode 100644 index 0000000..c424536 --- /dev/null +++ b/lib/widgets/header.dart @@ -0,0 +1,53 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +class Header extends StatelessWidget { + const Header({Key? key, this.isHomeHeader = false}) : super(key: key); + final bool isHomeHeader; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + if (isHomeHeader) + SizedBox( + height: 50, + child: ClipRRect( + borderRadius: BorderRadius.circular(10), + child: Image.network( + "https://api.lorem.space/image/face?w=150&h=150"), + ), + ), + if (isHomeHeader) const SizedBox(width: 12), + if (isHomeHeader) + Text( + "Hi, Ali!", + style: GoogleFonts.poppins( + fontWeight: FontWeight.w600, + fontSize: 16, + color: Theme.of(context).primaryColor), + ), + if (!isHomeHeader) + IconButton( + padding: EdgeInsets.zero, + constraints: const BoxConstraints(), + onPressed: () {}, + icon: Icon( + Icons.arrow_back_ios, + color: Theme.of(context).primaryColor, + ), + ), + const Spacer(), + IconButton( + padding: EdgeInsets.zero, + constraints: const BoxConstraints(), + onPressed: () {}, + icon: Icon( + Icons.more_vert, + color: Theme.of(context).primaryColor, + ), + ), + ], + ); + } +} From cf205fefc131362a7218854d1843f8113ced246a Mon Sep 17 00:00:00 2001 From: devsadeq Date: Mon, 29 Aug 2022 04:24:31 +0300 Subject: [PATCH 11/22] prepare cart view --- lib/views/cart/cart_view.dart | 15 +++++++++++++++ lib/views/cart/widgets/body.dart | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 lib/views/cart/cart_view.dart create mode 100644 lib/views/cart/widgets/body.dart diff --git a/lib/views/cart/cart_view.dart b/lib/views/cart/cart_view.dart new file mode 100644 index 0000000..9baa9ad --- /dev/null +++ b/lib/views/cart/cart_view.dart @@ -0,0 +1,15 @@ +import 'package:book_store_app/views/cart/widgets/body.dart'; +import 'package:flutter/material.dart'; + +class CartView extends StatelessWidget { + const CartView({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + body: Body(), + ), + ); + } +} diff --git a/lib/views/cart/widgets/body.dart b/lib/views/cart/widgets/body.dart new file mode 100644 index 0000000..3558314 --- /dev/null +++ b/lib/views/cart/widgets/body.dart @@ -0,0 +1,27 @@ +import 'package:book_store_app/widgets/book_list.dart'; +import 'package:book_store_app/widgets/big_title.dart'; +import 'package:book_store_app/widgets/header.dart'; +import 'package:flutter/material.dart'; + +import '../../../data/data_source.dart'; + +class Body extends StatelessWidget { + const Body({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 40, right: 16, left: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Header(), + SizedBox(height: 30), + BigTitle(title: "Cart"), + SizedBox(height: 15), + BookList(books: DataSource.localBooks), + ], + ), + ); + } +} From 7c85d4602c6435dd69c647ffacbfc070c504ae00 Mon Sep 17 00:00:00 2001 From: devsadeq Date: Mon, 29 Aug 2022 04:24:52 +0300 Subject: [PATCH 12/22] edit data source --- lib/data/data_source.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/data/data_source.dart b/lib/data/data_source.dart index fa01224..99cd83f 100644 --- a/lib/data/data_source.dart +++ b/lib/data/data_source.dart @@ -7,7 +7,7 @@ class DataSource { Book( title: "A Tale of Two Cities", author: "Charles Dickens", - cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC1", rate: 5.0, price: 99.99, ), @@ -21,28 +21,28 @@ class DataSource { Book( title: "Harry Potter and the Philosopher's Stone", author: "J.K.Rowling", - cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC3", rate: 3.0, price: 64.99, ), Book( title: "Mockingjay", author: "Suzanne Collins", - cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC4", rate: 4.0, price: 52.99, ), Book( title: "Me Before You", author: "Jojo Moyes", - cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC5", rate: 4.9, price: 30.99, ), Book( title: "Harry Potter and the Philosopher's Stone", author: "J.K.Rowling", - cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC6", rate: 3.0, price: 64.99, ), From 74b12c51e5fe116cb8a87b4faa72a2e88896c047 Mon Sep 17 00:00:00 2001 From: devsadeq Date: Thu, 1 Sep 2022 20:00:34 +0300 Subject: [PATCH 13/22] create cart items list --- lib/data/data_source.dart | 17 +++++++++++++++++ lib/main.dart | 1 - lib/views/cart/widgets/body.dart | 2 +- lib/widgets/book_list.dart | 7 +++---- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/data/data_source.dart b/lib/data/data_source.dart index 99cd83f..cf8b237 100644 --- a/lib/data/data_source.dart +++ b/lib/data/data_source.dart @@ -47,4 +47,21 @@ class DataSource { price: 64.99, ), ].obs; + + static RxList cartItems = [ + Book( + title: "Me Before You", + author: "Jojo Moyes", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC5", + rate: 4.9, + price: 30.99, + ), + Book( + title: "Harry Potter and the Philosopher's Stone", + author: "J.K.Rowling", + cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC6", + rate: 3.0, + price: 64.99, + ), + ].obs; } diff --git a/lib/main.dart b/lib/main.dart index d7f36e8..dda936e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,6 @@ import 'package:book_store_app/core/theme.dart'; import 'package:book_store_app/routes/app_pages.dart'; import 'package:book_store_app/routes/app_routes.dart'; -import 'package:book_store_app/views/home/home_view.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; diff --git a/lib/views/cart/widgets/body.dart b/lib/views/cart/widgets/body.dart index 3558314..cc34fc3 100644 --- a/lib/views/cart/widgets/body.dart +++ b/lib/views/cart/widgets/body.dart @@ -19,7 +19,7 @@ class Body extends StatelessWidget { SizedBox(height: 30), BigTitle(title: "Cart"), SizedBox(height: 15), - BookList(books: DataSource.localBooks), + BookList(books: DataSource.cartItems), ], ), ); diff --git a/lib/widgets/book_list.dart b/lib/widgets/book_list.dart index 982bd8d..71197b7 100644 --- a/lib/widgets/book_list.dart +++ b/lib/widgets/book_list.dart @@ -1,13 +1,12 @@ import 'package:flutter/material.dart'; -import '../data/data_source.dart'; import '../data/models/book.dart'; import 'book_item.dart'; import 'fading_list.dart'; class BookList extends StatelessWidget { const BookList({Key? key, required this.books}) : super(key: key); - final List? books; + final List books; @override Widget build(BuildContext context) { @@ -15,9 +14,9 @@ class BookList extends StatelessWidget { listView: ListView.builder( shrinkWrap: true, scrollDirection: Axis.vertical, - itemCount: DataSource.localBooks.length, + itemCount: books.length, physics: const BouncingScrollPhysics(), - itemBuilder: (context, index) => BookItem(book: books![index]), + itemBuilder: (context, index) => BookItem(book: books[index]), ), ); } From f0b6a539d46cdb52403af21a63c966b6b0a0803b Mon Sep 17 00:00:00 2001 From: devsadeq Date: Thu, 1 Sep 2022 20:09:04 +0300 Subject: [PATCH 14/22] prepare addition view --- lib/views/addition/add_view.dart | 15 +++++++++++++++ lib/views/addition/widgets/body.dart | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 lib/views/addition/add_view.dart create mode 100644 lib/views/addition/widgets/body.dart diff --git a/lib/views/addition/add_view.dart b/lib/views/addition/add_view.dart new file mode 100644 index 0000000..15cf894 --- /dev/null +++ b/lib/views/addition/add_view.dart @@ -0,0 +1,15 @@ +import 'widgets/body.dart'; +import 'package:flutter/material.dart'; + +class AddView extends StatelessWidget { + const AddView({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + body: Body(), + ), + ); + } +} diff --git a/lib/views/addition/widgets/body.dart b/lib/views/addition/widgets/body.dart new file mode 100644 index 0000000..9ca8a0a --- /dev/null +++ b/lib/views/addition/widgets/body.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class Body extends StatelessWidget { + const Body({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Center( + child: Text("Addition View"), + ); + } +} From 781f6b5b1cbda1af6afe3aae5e5271933c7b5f91 Mon Sep 17 00:00:00 2001 From: devsadeq Date: Sat, 3 Sep 2022 01:02:50 +0300 Subject: [PATCH 15/22] add more icons --- assets/images/icons/preview.svg | 5 +++++ assets/images/icons/reviews.svg | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 assets/images/icons/preview.svg create mode 100644 assets/images/icons/reviews.svg diff --git a/assets/images/icons/preview.svg b/assets/images/icons/preview.svg new file mode 100644 index 0000000..9235d82 --- /dev/null +++ b/assets/images/icons/preview.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/images/icons/reviews.svg b/assets/images/icons/reviews.svg new file mode 100644 index 0000000..acdc168 --- /dev/null +++ b/assets/images/icons/reviews.svg @@ -0,0 +1,3 @@ + + + From 275564650c2cdf43e9afbd617b4631270392650e Mon Sep 17 00:00:00 2001 From: devsadeq Date: Sat, 3 Sep 2022 01:04:11 +0300 Subject: [PATCH 16/22] create/update some widgets --- lib/widgets/book_item.dart | 95 +++++++++++++++------------- lib/widgets/custom_button.dart | 43 +++++++++++++ lib/widgets/header.dart | 3 +- lib/widgets/small_custom_button.dart | 55 ++++++++++++++++ 4 files changed, 151 insertions(+), 45 deletions(-) create mode 100644 lib/widgets/custom_button.dart create mode 100644 lib/widgets/small_custom_button.dart diff --git a/lib/widgets/book_item.dart b/lib/widgets/book_item.dart index 54fc1ea..bc069b2 100644 --- a/lib/widgets/book_item.dart +++ b/lib/widgets/book_item.dart @@ -1,4 +1,6 @@ +import 'package:book_store_app/views/detail/detail_vew.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; import '../data/models/book.dart'; @@ -10,54 +12,59 @@ class BookItem extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - margin: const EdgeInsets.symmetric(vertical: 10), - child: Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(5), - child: Image.network( - book.cover!, - height: 106, - fit: BoxFit.fill, + return GestureDetector( + onTap: () => Get.to(DetailView( + book: book, + )), + child: Container( + margin: const EdgeInsets.symmetric(vertical: 10), + child: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(5), + child: Image.network( + book.cover!, + height: 106, + fit: BoxFit.fill, + ), ), - ), - const SizedBox(width: 20), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - book.title!, - style: GoogleFonts.poppins( - color: Theme.of(context).primaryColor, - fontSize: 16, - fontWeight: FontWeight.w600, + const SizedBox(width: 20), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + book.title!, + style: GoogleFonts.poppins( + color: Theme.of(context).primaryColor, + fontSize: 16, + fontWeight: FontWeight.w600, + ), ), - ), - const SizedBox(height: 4), - Text( - book.author!, - style: GoogleFonts.poppins( - color: Theme.of(context).colorScheme.secondary, - fontSize: 12, - fontWeight: FontWeight.w500, + const SizedBox(height: 4), + Text( + book.author!, + style: GoogleFonts.poppins( + color: Theme.of(context).colorScheme.secondary, + fontSize: 12, + fontWeight: FontWeight.w500, + ), ), - ), - const SizedBox(height: 8), - Text( - "\$${book.price}", - style: GoogleFonts.poppins( - color: const Color(0xff191919), - fontSize: 14, - fontWeight: FontWeight.w500, + const SizedBox(height: 8), + Text( + "\$${book.price}", + style: GoogleFonts.poppins( + color: const Color(0xff191919), + fontSize: 14, + fontWeight: FontWeight.w500, + ), ), - ), - const SizedBox(height: 5), - const RateStars(), - ], - ) - ], + const SizedBox(height: 5), + const RateStars(), + ], + ) + ], + ), ), ); } diff --git a/lib/widgets/custom_button.dart b/lib/widgets/custom_button.dart new file mode 100644 index 0000000..eb525f1 --- /dev/null +++ b/lib/widgets/custom_button.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +class BigCustomButton extends StatelessWidget { + const BigCustomButton({Key? key, required this.title, required this.onTap}) + : super(key: key); + final String title; + final void Function() onTap; + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + height: 60, + decoration: const BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color(0xff1A07080E), + spreadRadius: 7, + blurRadius: 32, + offset: Offset(0, 4), + ) + ], + ), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: const Color(0xff06070D), + elevation: 0.0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16))), + onPressed: onTap, + child: Text( + title, + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.white, + ), + ), + ), + ); + } +} diff --git a/lib/widgets/header.dart b/lib/widgets/header.dart index c424536..b967faf 100644 --- a/lib/widgets/header.dart +++ b/lib/widgets/header.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:get/get.dart'; import 'package:google_fonts/google_fonts.dart'; class Header extends StatelessWidget { @@ -31,7 +32,7 @@ class Header extends StatelessWidget { IconButton( padding: EdgeInsets.zero, constraints: const BoxConstraints(), - onPressed: () {}, + onPressed: () => Get.back(), icon: Icon( Icons.arrow_back_ios, color: Theme.of(context).primaryColor, diff --git a/lib/widgets/small_custom_button.dart b/lib/widgets/small_custom_button.dart new file mode 100644 index 0000000..b2008ca --- /dev/null +++ b/lib/widgets/small_custom_button.dart @@ -0,0 +1,55 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:google_fonts/google_fonts.dart'; + +class SmallCustomButton extends StatelessWidget { + const SmallCustomButton({Key? key, required this.asset, required this.title}) + : super(key: key); + final String asset; + final String title; + + @override + Widget build(BuildContext context) { + return Container( + height: 40, + decoration: const BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color(0xff0D07080E), + spreadRadius: 7, + blurRadius: 32, + offset: Offset(0, 4), + ) + ], + ), + child: ElevatedButton( + style: ElevatedButton.styleFrom( + elevation: 0.0, + primary: Colors.white, + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 32), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + onPressed: () {}, + child: Row( + children: [ + SvgPicture.asset( + asset, + color: Colors.black, + ), + const SizedBox(width: 15), + Text( + title, + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w500, + color: Theme.of(context).primaryColor, + ), + ) + ], + ), + ), + ); + } +} From b2a3d691ab6b3b4b8b7af3d2dc4fce96b5c0817b Mon Sep 17 00:00:00 2001 From: devsadeq Date: Sat, 3 Sep 2022 01:04:42 +0300 Subject: [PATCH 17/22] update dashboard --- lib/views/dashboard/widgets/body.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/views/dashboard/widgets/body.dart b/lib/views/dashboard/widgets/body.dart index e8d1acb..76482cc 100644 --- a/lib/views/dashboard/widgets/body.dart +++ b/lib/views/dashboard/widgets/body.dart @@ -1,4 +1,5 @@ import 'package:book_store_app/controllers/dashboard.dart'; +import 'package:book_store_app/views/addition/add_view.dart'; import 'package:book_store_app/views/dashboard/widgets/bottom_nav.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -19,7 +20,7 @@ class Body extends GetView { children: const [ HomeView(), CartView(), - HomeView(), + AddView(), ], ), const CustomBottomNavBar(), From 7b82a42dba0f7665f108c81e72f8c90e49c93e76 Mon Sep 17 00:00:00 2001 From: devsadeq Date: Sat, 3 Sep 2022 01:06:08 +0300 Subject: [PATCH 18/22] create book details view --- lib/views/detail/detail_vew.dart | 17 ++++++ lib/views/detail/widgets/body.dart | 23 +++++++ lib/views/detail/widgets/book_content.dart | 70 ++++++++++++++++++++++ lib/views/detail/widgets/footer.dart | 39 ++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 lib/views/detail/detail_vew.dart create mode 100644 lib/views/detail/widgets/body.dart create mode 100644 lib/views/detail/widgets/book_content.dart create mode 100644 lib/views/detail/widgets/footer.dart diff --git a/lib/views/detail/detail_vew.dart b/lib/views/detail/detail_vew.dart new file mode 100644 index 0000000..5000b7e --- /dev/null +++ b/lib/views/detail/detail_vew.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; +import '../../data/models/book.dart'; +import 'widgets/body.dart'; + +class DetailView extends StatelessWidget { + const DetailView({Key? key, required this.book}) : super(key: key); + final Book book; + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + body: Body(book: book), + ), + ); + } +} diff --git a/lib/views/detail/widgets/body.dart b/lib/views/detail/widgets/body.dart new file mode 100644 index 0000000..96d0d4c --- /dev/null +++ b/lib/views/detail/widgets/body.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; + +import '../../../data/models/book.dart'; +import 'book_content.dart'; +import 'footer.dart'; + +class Body extends StatelessWidget { + const Body({Key? key, required this.book}) : super(key: key); + final Book book; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 40, right: 16, left: 16), + child: Stack( + children: [ + BookContent(book: book), + Footer(book: book), + ], + ), + ); + } +} diff --git a/lib/views/detail/widgets/book_content.dart b/lib/views/detail/widgets/book_content.dart new file mode 100644 index 0000000..da8d1d1 --- /dev/null +++ b/lib/views/detail/widgets/book_content.dart @@ -0,0 +1,70 @@ +import 'package:book_store_app/data/models/book.dart'; +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +import '../../../widgets/header.dart'; +import '../../../widgets/rate_stars.dart'; + +class BookContent extends StatelessWidget { + const BookContent({Key? key, required this.book}) : super(key: key); + final Book book; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + const Header(), + ClipRRect( + borderRadius: BorderRadius.circular(5), + child: Image.network( + book.cover!, + fit: BoxFit.contain, + height: 320, + ), + ), + const SizedBox(height: 22), + Text( + book.title!, + style: GoogleFonts.poppins( + fontSize: 24, + fontWeight: FontWeight.w600, + color: Theme.of(context).primaryColor), + ), + const SizedBox(height: 12), + Text( + book.author!, + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w500, + color: Theme.of(context).primaryColor.withOpacity(0.5), + ), + ), + const SizedBox(height: 12), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const RateStars(), + const SizedBox(width: 10), + Text( + "${book.rate}/5.0", + textAlign: TextAlign.center, + style: GoogleFonts.poppins( + color: const Color(0xff06070D), + fontSize: 14, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + const SizedBox(height: 12), + Text( + book.description!, + style: GoogleFonts.poppins( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Theme.of(context).primaryColor.withOpacity(0.5)), + ), + ], + ); + } +} diff --git a/lib/views/detail/widgets/footer.dart b/lib/views/detail/widgets/footer.dart new file mode 100644 index 0000000..efb5d81 --- /dev/null +++ b/lib/views/detail/widgets/footer.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; + +import '../../../data/data_source.dart'; +import '../../../data/models/book.dart'; +import '../../../widgets/custom_button.dart'; +import '../../../widgets/small_custom_button.dart'; + +class Footer extends StatelessWidget { + const Footer({Key? key, required this.book}) : super(key: key); + final Book book; + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.only(bottom: 52), + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: const [ + SmallCustomButton( + asset: 'assets/images/icons/preview.svg', title: 'Preview'), + SmallCustomButton( + asset: 'assets/images/icons/reviews.svg', title: 'Reviews'), + ], + ), + const SizedBox(height: 36), + BigCustomButton( + title: "Buy Now for \$${book.price}", + onTap: () { + DataSource.cartItems.add(book); + }, + ), + ], + ), + ); + } +} From 7aa9a711882d99335551581ee7fc30c71db772ef Mon Sep 17 00:00:00 2001 From: devsadeq Date: Sat, 3 Sep 2022 01:06:42 +0300 Subject: [PATCH 19/22] update data source --- lib/data/data_source.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/data/data_source.dart b/lib/data/data_source.dart index cf8b237..8247847 100644 --- a/lib/data/data_source.dart +++ b/lib/data/data_source.dart @@ -10,6 +10,8 @@ class DataSource { cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC1", rate: 5.0, price: 99.99, + description: + "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.", ), Book( title: "The Little Prince", @@ -17,6 +19,8 @@ class DataSource { cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC2", rate: 4.3, price: 46.99, + description: + "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.", ), Book( title: "Harry Potter and the Philosopher's Stone", @@ -24,6 +28,8 @@ class DataSource { cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC3", rate: 3.0, price: 64.99, + description: + "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.", ), Book( title: "Mockingjay", @@ -31,6 +37,8 @@ class DataSource { cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC4", rate: 4.0, price: 52.99, + description: + "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.", ), Book( title: "Me Before You", @@ -38,6 +46,8 @@ class DataSource { cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC5", rate: 4.9, price: 30.99, + description: + "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.", ), Book( title: "Harry Potter and the Philosopher's Stone", @@ -45,6 +55,8 @@ class DataSource { cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC6", rate: 3.0, price: 64.99, + description: + "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.", ), ].obs; @@ -55,6 +67,8 @@ class DataSource { cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC5", rate: 4.9, price: 30.99, + description: + "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.", ), Book( title: "Harry Potter and the Philosopher's Stone", @@ -62,6 +76,8 @@ class DataSource { cover: "https://api.lorem.space/image/book?w=150&h=220&hash=8B7BCDC6", rate: 3.0, price: 64.99, + description: + "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, written in 45 BC.", ), ].obs; } From dbc50bd2d7472ecf9996b300a43b39ce8b64f500 Mon Sep 17 00:00:00 2001 From: devsadeq Date: Sat, 3 Sep 2022 03:08:33 +0300 Subject: [PATCH 20/22] create custom widget --- lib/widgets/custom_text_form_field.dart | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 lib/widgets/custom_text_form_field.dart diff --git a/lib/widgets/custom_text_form_field.dart b/lib/widgets/custom_text_form_field.dart new file mode 100644 index 0000000..ec8c8b8 --- /dev/null +++ b/lib/widgets/custom_text_form_field.dart @@ -0,0 +1,62 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +class CustomFormField extends StatelessWidget { + const CustomFormField({ + Key? key, + required this.hintText, + this.maxLines, + this.onSaved, + this.onFieldSubmitted, + this.controller, + this.keyboardInputType, + }) : super(key: key); + + final String hintText; + final int? maxLines; + final void Function(String?)? onSaved; + final void Function(String)? onFieldSubmitted; + final TextEditingController? controller; + final TextInputType? keyboardInputType; + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + color: Colors.white, + boxShadow: const [ + BoxShadow( + color: Color(0xff0D07080E), + blurRadius: 32, + offset: Offset(0, 4), + ) + ], + ), + child: Padding( + padding: const EdgeInsets.all(18), + child: TextFormField( + controller: controller, + maxLines: maxLines, + onSaved: onSaved, + keyboardType: keyboardInputType, + onFieldSubmitted: onFieldSubmitted, + cursorColor: Colors.black, + autofocus: true, + decoration: InputDecoration( + isDense: true, + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + hintText: hintText, + focusColor: Colors.red, + hintStyle: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w400, + color: const Color(0xff84889E), + ), + ), + ), + ), + ); + } +} From acf09da88280e69f997700f6973fbdf1614bec0b Mon Sep 17 00:00:00 2001 From: devsadeq Date: Sat, 3 Sep 2022 03:09:37 +0300 Subject: [PATCH 21/22] complete add view --- lib/controllers/add_controller.dart | 49 +++++++++++++++++ lib/views/addition/add_view.dart | 3 +- lib/views/addition/widgets/body.dart | 80 ++++++++++++++++++++++++++-- 3 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 lib/controllers/add_controller.dart diff --git a/lib/controllers/add_controller.dart b/lib/controllers/add_controller.dart new file mode 100644 index 0000000..57bb207 --- /dev/null +++ b/lib/controllers/add_controller.dart @@ -0,0 +1,49 @@ +import 'package:book_store_app/data/data_source.dart'; +import 'package:book_store_app/data/models/book.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class AddController extends GetxController { + late final GlobalKey formKey; + late final TextEditingController nameController; + late final TextEditingController authorController; + late final TextEditingController priceController; + late final TextEditingController imageLinkController; + late final TextEditingController descriptionController; + + @override + void onInit() { + super.onInit(); + formKey = GlobalKey(); + nameController = TextEditingController(); + authorController = TextEditingController(); + priceController = TextEditingController(); + imageLinkController = TextEditingController(); + descriptionController = TextEditingController(); + } + + @override + void onClose() { + nameController.dispose(); + authorController.dispose(); + priceController.dispose(); + imageLinkController.dispose(); + descriptionController.dispose(); + } + + addBook() { + if (formKey.currentState!.validate()) { + DataSource.localBooks.add( + Book( + title: nameController.text, + author: authorController.text, + price: double.parse(priceController.text), + cover: imageLinkController.text, + description: descriptionController.text, + ), + ); + Get.closeCurrentSnackbar(); + Get.snackbar('Book has been added successfully', ''); + } + } +} diff --git a/lib/views/addition/add_view.dart b/lib/views/addition/add_view.dart index 15cf894..d38c89a 100644 --- a/lib/views/addition/add_view.dart +++ b/lib/views/addition/add_view.dart @@ -6,8 +6,9 @@ class AddView extends StatelessWidget { @override Widget build(BuildContext context) { - return SafeArea( + return const SafeArea( child: Scaffold( + resizeToAvoidBottomInset: true, body: Body(), ), ); diff --git a/lib/views/addition/widgets/body.dart b/lib/views/addition/widgets/body.dart index 9ca8a0a..1bc1b2f 100644 --- a/lib/views/addition/widgets/body.dart +++ b/lib/views/addition/widgets/body.dart @@ -1,12 +1,86 @@ +import 'package:book_store_app/controllers/add_controller.dart'; +import 'package:book_store_app/widgets/big_title.dart'; +import 'package:book_store_app/widgets/custom_button.dart'; +import 'package:book_store_app/widgets/header.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; -class Body extends StatelessWidget { +import '../../../widgets/custom_text_form_field.dart'; + +class Body extends GetView { const Body({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return Center( - child: Text("Addition View"), + return Padding( + padding: const EdgeInsets.only(top: 40, right: 16, left: 16), + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Header(), + const SizedBox(height: 53), + const BigTitle(title: 'Add Book'), + Form( + key: controller.formKey, + child: Column( + children: [ + const SizedBox(height: 59), + CustomFormField( + controller: controller.nameController, + hintText: "Book Name", + maxLines: 1, + onSaved: null, + onFieldSubmitted: null, + keyboardInputType: TextInputType.text, + ), + const SizedBox(height: 22), + CustomFormField( + controller: controller.authorController, + hintText: "Author Name", + maxLines: 1, + onSaved: null, + onFieldSubmitted: null, + keyboardInputType: TextInputType.text, + ), + const SizedBox(height: 22), + CustomFormField( + controller: controller.priceController, + hintText: "Price", + maxLines: 1, + onSaved: null, + onFieldSubmitted: null, + keyboardInputType: TextInputType.text, + ), + const SizedBox(height: 22), + CustomFormField( + controller: controller.imageLinkController, + hintText: "Image link", + maxLines: 1, + onSaved: null, + onFieldSubmitted: null, + keyboardInputType: TextInputType.text, + ), + const SizedBox(height: 22), + CustomFormField( + controller: controller.descriptionController, + hintText: "Description", + maxLines: 8, + onSaved: null, + onFieldSubmitted: null, + keyboardInputType: TextInputType.text, + ), + const SizedBox(height: 22), + BigCustomButton( + title: "Add", + onTap: () => controller.addBook(), + ), + ], + ), + ), + ], + ), + ), ); } } From 6a4088cba7ed8b4480cebd2ab6419cf95e2d2485 Mon Sep 17 00:00:00 2001 From: devsadeq Date: Sat, 3 Sep 2022 03:10:08 +0300 Subject: [PATCH 22/22] edits --- lib/bindings/dashboard.dart | 2 ++ lib/controllers/dashboard.dart | 17 +++++++++++------ lib/views/home/widgets/body.dart | 12 ++++++------ lib/widgets/header.dart | 2 +- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/bindings/dashboard.dart b/lib/bindings/dashboard.dart index b843220..cb5a44a 100644 --- a/lib/bindings/dashboard.dart +++ b/lib/bindings/dashboard.dart @@ -1,3 +1,4 @@ +import 'package:book_store_app/controllers/add_controller.dart'; import 'package:book_store_app/controllers/dashboard.dart'; import 'package:book_store_app/controllers/home_controller.dart'; import 'package:get/get.dart'; @@ -7,5 +8,6 @@ class DashboardBinding extends Bindings { void dependencies() { Get.lazyPut(() => DashboardController()); Get.lazyPut(() => HomeController()); + Get.lazyPut(() => AddController()); } } diff --git a/lib/controllers/dashboard.dart b/lib/controllers/dashboard.dart index 69ab1f5..f4353d2 100644 --- a/lib/controllers/dashboard.dart +++ b/lib/controllers/dashboard.dart @@ -1,3 +1,4 @@ +import 'package:book_store_app/views/addition/add_view.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -18,11 +19,15 @@ class DashboardController extends GetxController { } void changeTabIndex(int index) { - tabIndex.value = index; - pageController.animateToPage( - index, - duration: const Duration(milliseconds: 300), - curve: Curves.linear, - ); + if (index != 2) { + tabIndex.value = index; + pageController.animateToPage( + index, + duration: const Duration(milliseconds: 300), + curve: Curves.linear, + ); + } else { + Get.to(const AddView()); + } } } diff --git a/lib/views/home/widgets/body.dart b/lib/views/home/widgets/body.dart index f08b5c8..4e67057 100644 --- a/lib/views/home/widgets/body.dart +++ b/lib/views/home/widgets/body.dart @@ -16,12 +16,12 @@ class Body extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Header(isHomeHeader: true), - SizedBox(height: 30), - SearchBar(), - SizedBox(height: 30), - BigTitle(title: 'Book List'), - SizedBox(height: 15), + const Header(isHomeHeader: true), + const SizedBox(height: 30), + const SearchBar(), + const SizedBox(height: 30), + const BigTitle(title: 'Book List'), + const SizedBox(height: 15), Expanded(child: BookList(books: DataSource.localBooks)), ], ), diff --git a/lib/widgets/header.dart b/lib/widgets/header.dart index b967faf..c1e13e2 100644 --- a/lib/widgets/header.dart +++ b/lib/widgets/header.dart @@ -22,7 +22,7 @@ class Header extends StatelessWidget { if (isHomeHeader) const SizedBox(width: 12), if (isHomeHeader) Text( - "Hi, Ali!", + "Hi, Sadeq!", style: GoogleFonts.poppins( fontWeight: FontWeight.w600, fontSize: 16,