diff --git a/android/app/build.gradle b/android/app/build.gradle index b1ebe0e..19850b9 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion flutter.compileSdkVersion + compileSdkVersion 33 ndkVersion flutter.ndkVersion compileOptions { @@ -47,7 +47,7 @@ android { applicationId "com.atutechs.multivendor_shop" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. - minSdkVersion 19 + minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/cart.png b/cart.png new file mode 100644 index 0000000..c528126 Binary files /dev/null and b/cart.png differ diff --git a/cart_2.png b/cart_2.png new file mode 100644 index 0000000..bb0108c Binary files /dev/null and b/cart_2.png differ diff --git a/lib/components/search_box.dart b/lib/components/search_box.dart index d0546a6..7eb6558 100644 --- a/lib/components/search_box.dart +++ b/lib/components/search_box.dart @@ -1,41 +1,69 @@ +import 'package:badges/badges.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import '../constants/colors.dart'; +import '../providers/cart.dart'; class SearchBox extends StatelessWidget { const SearchBox({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return TextFormField( - decoration: InputDecoration( - contentPadding: const EdgeInsets.all(10), - prefixIcon: Icon(Icons.search, color: greyLite), - suffixIcon: ElevatedButton( - style: ElevatedButton.styleFrom( - primary: primaryColor, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), + Size size = MediaQuery.of(context).size; + var cartData = Provider.of(context, listen: false); + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + SizedBox( + width: size.width / 1.22, + child: TextFormField( + decoration: InputDecoration( + contentPadding: const EdgeInsets.all(10), + prefixIcon: Icon(Icons.search, color: greyLite), + suffixIcon: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + ), + onPressed: () {}, + child: const Text('Search'), + ), + hintText: 'Type here...', + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: const BorderSide( + width: 1, + color: primaryColor, + ), + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12), + borderSide: const BorderSide( + width: 20, + color: primaryColor, + ), + ), ), ), - onPressed: () {}, - child: const Text('Search'), ), - hintText: 'Type here...', - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(12), - borderSide: const BorderSide( - width: 1, - color: primaryColor, - ), - ), - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(12), - borderSide: const BorderSide( - width: 20, - color: primaryColor, + Consumer(builder: (context, data, child)=> + Badge( + badgeContent: Text( + cartData.cartItemCount.toString(), + style: const TextStyle( + color: primaryColor, + ), + ), + child: const Icon( + Icons.shopping_bag_outlined, + size: 30, + color: primaryColor, + ), ), ), - ), + ], ); } } diff --git a/lib/views/main/customer/cart.dart b/lib/views/main/customer/cart.dart index 14cb9ac..ad9a118 100644 --- a/lib/views/main/customer/cart.dart +++ b/lib/views/main/customer/cart.dart @@ -1,3 +1,4 @@ +import 'package:badges/badges.dart'; import 'package:flutter/material.dart'; import 'package:multivendor_shop/views/main/customer/order.dart'; import 'package:provider/provider.dart'; @@ -145,20 +146,43 @@ class _CartScreenState extends State { Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Center( - child: Wrap( - crossAxisAlignment: WrapCrossAlignment.center, - children: const [ - Icon( - Icons.shopping_cart, - color: primaryColor, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 18.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Center( + child: Wrap( + crossAxisAlignment: WrapCrossAlignment.center, + children: const [ + Icon( + Icons.shopping_cart, + color: primaryColor, + ), + Text( + 'Cart', + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 28, + color: primaryColor, + ), + ), + ], + ), ), - Text( - 'Cart', - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 28, - color: primaryColor, + Consumer( + builder: (context, data, child) => Badge( + badgeContent: Text( + cartData.cartItemCount.toString(), + style: const TextStyle( + color: primaryColor, + ), + ), + child: const Icon( + Icons.shopping_bag_outlined, + size: 30, + color: primaryColor, + ), ), ), ], diff --git a/lib/views/main/customer/customer_bottomNav.dart b/lib/views/main/customer/customer_bottomNav.dart index 85287b0..82257fa 100644 --- a/lib/views/main/customer/customer_bottomNav.dart +++ b/lib/views/main/customer/customer_bottomNav.dart @@ -1,7 +1,10 @@ +import 'package:badges/badges.dart'; import 'package:flutter/material.dart'; import 'package:convex_bottom_bar/convex_bottom_bar.dart'; import 'package:flutter/services.dart'; import 'package:multivendor_shop/constants/colors.dart'; +import 'package:provider/provider.dart'; +import '../../../providers/cart.dart'; import 'cart.dart'; import 'favorites.dart'; import 'home.dart'; @@ -37,6 +40,7 @@ class _CustomerBottomNavState extends State { @override Widget build(BuildContext context) { + var cartData = Provider.of(context, listen: false); SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle( statusBarColor: Colors.transparent, @@ -52,7 +56,7 @@ class _CustomerBottomNavState extends State { activeColor: Colors.white, initialActiveIndex: currentPageIndex, style: TabStyle.reactCircle, - items: const [ + items: [ TabItem( icon: Icons.house_siding, ), @@ -66,7 +70,21 @@ class _CustomerBottomNavState extends State { icon: Icons.storefront, ), TabItem( - icon: Icons.shopping_cart_outlined, + icon: Consumer( + builder: (context, data, child) => Badge( + badgeContent: Text( + cartData.cartItemCount.toString(), + style: const TextStyle( + color: primaryColor, + ), + ), + child: Icon( + Icons.shopping_bag_outlined, + size: currentPageIndex == 4 ? 40 : 25, + color: currentPageIndex == 4 ? primaryColor : Colors.white70, + ), + ), + ), ), TabItem( icon: Icons.person_outline, diff --git a/lib/views/main/customer/home.dart b/lib/views/main/customer/home.dart index 8f9b44d..ba5d359 100644 --- a/lib/views/main/customer/home.dart +++ b/lib/views/main/customer/home.dart @@ -66,6 +66,7 @@ class _HomeScreenState extends State { margin: const EdgeInsets.symmetric(horizontal: 18), child: const SearchBox(), ), + const SizedBox(height: 10), buildCarouselSlider(), const SizedBox(height: 10), diff --git a/lib/views/main/customer/order.dart b/lib/views/main/customer/order.dart index f476c5e..b6ea3f1 100644 --- a/lib/views/main/customer/order.dart +++ b/lib/views/main/customer/order.dart @@ -5,6 +5,7 @@ import 'package:provider/provider.dart'; import '../../../constants/colors.dart'; import '../../../providers/order.dart'; import 'package:intl/intl.dart' as intl; +import 'package:flutter_stripe/flutter_stripe.dart' as stripe; import '../product/details.dart'; @@ -22,8 +23,9 @@ class CustomerOrderScreen extends StatelessWidget { orderData.removeFromOrder(id); } - // payNow - void payNow() { + + // pay through stripe + void payNow() async { // TODO: Implement Pay now } diff --git a/pubspec.lock b/pubspec.lock index 5438a6c..1ba332e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -251,6 +251,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.7" + flutter_stripe: + dependency: "direct main" + description: + name: flutter_stripe + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.0" flutter_swiper_null_safety: dependency: "direct main" description: @@ -275,6 +282,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "10.2.1" + freezed_annotation: + dependency: transitive + description: + name: freezed_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" google_sign_in: dependency: "direct main" description: @@ -609,6 +623,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + stripe_android: + dependency: transitive + description: + name: stripe_android + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.0" + stripe_ios: + dependency: transitive + description: + name: stripe_ios + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.0" + stripe_platform_interface: + dependency: transitive + description: + name: stripe_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.0" term_glyph: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index b2dcd46..cade238 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,6 +54,7 @@ dependencies: font_awesome_flutter: ^10.2.1 provider: ^6.0.3 intl: ^0.17.0 + flutter_stripe: ^5.1.0 dev_dependencies: flutter_test: