Skip to content

Commit

Permalink
task: cart number display
Browse files Browse the repository at this point in the history
  • Loading branch information
Atuoha committed Oct 11, 2022
1 parent 7957685 commit 78139e7
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 44 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
Binary file added cart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cart_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 53 additions & 25 deletions lib/components/search_box.dart
Original file line number Diff line number Diff line change
@@ -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<CartData>(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<CartData>(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,
),
),
),
),
],
);
}
}
50 changes: 37 additions & 13 deletions lib/views/main/customer/cart.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -145,20 +146,43 @@ class _CartScreenState extends State<CartScreen> {
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<CartData>(
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,
),
),
),
],
Expand Down
22 changes: 20 additions & 2 deletions lib/views/main/customer/customer_bottomNav.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -37,6 +40,7 @@ class _CustomerBottomNavState extends State<CustomerBottomNav> {

@override
Widget build(BuildContext context) {
var cartData = Provider.of<CartData>(context, listen: false);
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
Expand All @@ -52,7 +56,7 @@ class _CustomerBottomNavState extends State<CustomerBottomNav> {
activeColor: Colors.white,
initialActiveIndex: currentPageIndex,
style: TabStyle.reactCircle,
items: const [
items: [
TabItem(
icon: Icons.house_siding,
),
Expand All @@ -66,7 +70,21 @@ class _CustomerBottomNavState extends State<CustomerBottomNav> {
icon: Icons.storefront,
),
TabItem(
icon: Icons.shopping_cart_outlined,
icon: Consumer<CartData>(
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,
Expand Down
1 change: 1 addition & 0 deletions lib/views/main/customer/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class _HomeScreenState extends State<HomeScreen> {
margin: const EdgeInsets.symmetric(horizontal: 18),
child: const SearchBox(),
),

const SizedBox(height: 10),
buildCarouselSlider(),
const SizedBox(height: 10),
Expand Down
6 changes: 4 additions & 2 deletions lib/views/main/customer/order.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -22,8 +23,9 @@ class CustomerOrderScreen extends StatelessWidget {
orderData.removeFromOrder(id);
}

// payNow
void payNow() {

// pay through stripe
void payNow() async {
// TODO: Implement Pay now
}

Expand Down
35 changes: 35 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 78139e7

Please sign in to comment.