Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cart UI design #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/biry.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 assets/cake.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 assets/paneer.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions lib/app/core/app_config/app_colors.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';

class AppColors {
AppColors._();


static const black = Color(0xFF000000);
static const rustedOrange = Color(0xfff94700);
static const skyBlue = Color(0xff05d2e3);
static const white = Color(0xffffffff);
static const oliveGreen = Color(0xff44970f);
static const lightGrey = Color(0xffcac4cd);
static const grey = Color(0xffa1a1a1);
static const oliveGreenShade = Color(0xffccd890);
static const rupeeColor = Color(0xff007d1d);
static const rupeeBgColor = Color(0xff007d1d);
static const ratingColor = Color(0xffcf9e05);
static const linkTextColor = Color(0xff00315b);
static const blackColor = Color(0xff0a0a0a);

}
12 changes: 12 additions & 0 deletions lib/app/core/app_config/app_sizes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class AppSizes {
static const x1_50 = 12.0;
static const x2_25 = 18.0;
static const x2_50 = 20.0;
static const x2_75 = 22.0;
static const x3_12= 25.0;
static const x2_00 = 16.0;
static const x3_75 = 30.0;
static const x4_37 = 35.0;
static const x1_75= 100.0;

}
12 changes: 12 additions & 0 deletions lib/app/modules/carts/bindings/carts_binding.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:get/get.dart';

import '../controllers/carts_controller.dart';

class CartsBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<CartsController>(
() => CartsController(),
);
}
}
13 changes: 13 additions & 0 deletions lib/app/modules/carts/controllers/carts_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// ignore_for_file: unnecessary_overrides

import 'package:get/get.dart';

class CartsController extends GetxController {
final blackForestCount = 0.obs;
final biryaniCount = 0.obs;
final paneerCount = 0.obs;
final blackForestCost = 0.obs;
final biryaniCost = 0.obs;
final paneerCost = 0.obs;
final totalprice= 0.obs;
}
154 changes: 154 additions & 0 deletions lib/app/modules/carts/views/carts_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hunger/app/core/app_config/app_sizes.dart';
import 'package:hunger/app/modules/carts/widgets/order_card.dart';

import '../controllers/carts_controller.dart';

class CartsView extends GetView<CartsController> {
const CartsView({super.key});

@override
Widget build(BuildContext context) {
final textTheme = Theme.of(context).textTheme;
return Scaffold(
appBar: AppBar(
leading:
IconButton(onPressed: () {}, icon: const Icon(Icons.arrow_back)),
title: Text(
"Your Order",
style: textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold
),
),
centerTitle: true,
// actions: [
// Icon(
// Icons.question_mark_rounded,
// size: 28.0,
// ),
// SizedBox(
// width: 30.0,
// )
// ],
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Obx(
() => Column(
children: [
OrderCard(
imageUrl: "assets/cake.png",
imageText: "cake",
productCount:
controller.blackForestCount.value.toString(),
productCost: controller.blackForestCost.value.toString(),
add: () {
controller.blackForestCount.value += 1;
controller.blackForestCost.value += 220;
controller.totalprice.value += 220;
},
remove: () {
if (controller.blackForestCount.value > 0) {
controller.blackForestCount.value -= 1;
controller.blackForestCost.value -= 220;
controller.totalprice.value -= 220;
}
},
),
OrderCard(
imageUrl: "assets/biry.png",
imageText: "Biryani",
productCount: controller.biryaniCount.value.toString(),
productCost: controller.biryaniCost.value.toString(),
add: () {
controller.biryaniCount.value += 1;
controller.biryaniCost.value += 180;
controller.totalprice.value += 180;
},
remove: () {
if (controller.biryaniCount.value > 0) {
controller.biryaniCount.value -= 1;
controller.biryaniCost.value -= 180;
controller.totalprice.value -= 180;
}
},
),
OrderCard(
imageUrl: "assets/paneer.jpg",
imageText: "Paneer",
productCount: controller.paneerCount.value.toString(),
productCost: controller.paneerCost.value.toString(),
add: () {
controller.paneerCount.value += 1;
controller.paneerCost.value += 120;
controller.totalprice.value += 120;
},
remove: () {
if (controller.paneerCount.value > 0) {
controller.paneerCount.value -= 1;
controller.paneerCost.value -= 120;
controller.totalprice.value -= 120;
}
},
),
],
),
),
),
),
Obx(
() => Card(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: AppSizes.x3_75),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ListTile(
leading: Text(
"Total price",
style: textTheme.titleMedium?.copyWith(
fontSize: AppSizes.x2_75,
fontWeight: FontWeight.bold),
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.currency_rupee,
size: AppSizes.x2_50,
),
Text(
controller.totalprice.value.toString(),
style: Theme.of(context)
.textTheme
.titleMedium
?.copyWith(
fontSize: AppSizes.x2_50,
fontWeight: FontWeight.bold),
),
],
),
),

// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 8.0),
// child: FilledButton(
// onPressed: () {},
// child: const Text("Add items"),
// ),
// ),
],
),
)),
)
],
),
);
}
}
93 changes: 93 additions & 0 deletions lib/app/modules/carts/widgets/order_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// ignore_for_file: unused_local_variable

import 'package:flutter/material.dart';
import 'package:hunger/app/core/app_config/app_colors.dart';
import 'package:hunger/app/core/app_config/app_sizes.dart';

class OrderCard extends StatelessWidget {
final String imageUrl;
final String imageText;
final String productCount;
final String productCost;
final Function() remove;
final Function() add;

const OrderCard({
super.key,
required this.imageUrl,
required this.imageText,
required this.productCount,
required this.productCost,
required this.remove,
required this.add,
});

@override
Widget build(BuildContext context) {
final textTheme = Theme.of(context).textTheme;
return SizedBox(
height: 100.0,
child: Card(
child: Center(
child: ListTile(
leading: Image.asset(
imageUrl,
// fit: BoxFit.contain,
),
title: Text(
imageText,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontSize: AppSizes.x2_25, fontWeight: FontWeight.bold),
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
height: AppSizes.x4_37,
decoration: BoxDecoration(
color: AppColors.rustedOrange,
borderRadius: BorderRadius.circular(AppSizes.x3_12),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
child: IconButton(
onPressed: remove,
icon: const Icon(
Icons.remove,
color: AppColors.white,
size: AppSizes.x1_50,
),),
),
Text(
productCount,
style:
const TextStyle(color: AppColors.white),
),
InkWell(
child: IconButton(
onPressed: add,
icon: const Icon(Icons.add,
color: AppColors.white, size: AppSizes.x1_50),),
),
],
),
),
const Icon(
Icons.currency_rupee,
size: AppSizes.x2_50,
),
Text(
productCost == "0" ? " 0 " : productCost,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontSize: AppSizes.x2_50, fontWeight: FontWeight.bold),
)
],
),
),
),
),
);
}
}
4 changes: 3 additions & 1 deletion lib/app/modules/home/controllers/home_controller.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// ignore_for_file: unnecessary_overrides

import 'package:get/get.dart';

class HomeController extends GetxController {
//TODO: Implement HomeController


final count = 0.obs;
@override
Expand Down
Loading