From 8a71f98deb4dae457632d0457a60492ee38d124e Mon Sep 17 00:00:00 2001 From: Achintha Isuru Date: Sat, 21 Feb 2026 18:38:18 -0500 Subject: [PATCH] feat: Refactor order types and update UI metadata for create order feature --- .../utils/{ => constants}/order_types.dart | 19 +++--- .../ui_entities/order_type_ui_metadata.dart | 60 +++++++++---------- .../create_order/create_order_view.dart | 31 ++++------ .../presentation/widgets/order_type_card.dart | 5 +- 4 files changed, 52 insertions(+), 63 deletions(-) rename apps/mobile/packages/features/client/create_order/lib/src/presentation/utils/{ => constants}/order_types.dart (76%) diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/utils/order_types.dart b/apps/mobile/packages/features/client/create_order/lib/src/presentation/utils/constants/order_types.dart similarity index 76% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/utils/order_types.dart rename to apps/mobile/packages/features/client/create_order/lib/src/presentation/utils/constants/order_types.dart index e1f7562c..53564d2e 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/utils/order_types.dart +++ b/apps/mobile/packages/features/client/create_order/lib/src/presentation/utils/constants/order_types.dart @@ -1,29 +1,24 @@ import 'package:krow_domain/krow_domain.dart' as domain; /// Order type constants for the create order feature -final List orderTypes = const [ - domain.OrderType( - id: 'one-time', - titleKey: 'client_create_order.types.one_time', - descriptionKey: 'client_create_order.types.one_time_desc', - ), - +const List orderTypes = [ /// TODO: FEATURE_NOT_YET_IMPLEMENTED // domain.OrderType( // id: 'rapid', // titleKey: 'client_create_order.types.rapid', // descriptionKey: 'client_create_order.types.rapid_desc', // ), + domain.OrderType( + id: 'one-time', + titleKey: 'client_create_order.types.one_time', + descriptionKey: 'client_create_order.types.one_time_desc', + ), + domain.OrderType( id: 'recurring', titleKey: 'client_create_order.types.recurring', descriptionKey: 'client_create_order.types.recurring_desc', ), - // domain.OrderType( - // id: 'permanent', - // titleKey: 'client_create_order.types.permanent', - // descriptionKey: 'client_create_order.types.permanent_desc', - // ), domain.OrderType( id: 'permanent', titleKey: 'client_create_order.types.permanent', diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/utils/ui_entities/order_type_ui_metadata.dart b/apps/mobile/packages/features/client/create_order/lib/src/presentation/utils/ui_entities/order_type_ui_metadata.dart index 0729f4a1..c6ee52b7 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/utils/ui_entities/order_type_ui_metadata.dart +++ b/apps/mobile/packages/features/client/create_order/lib/src/presentation/utils/ui_entities/order_type_ui_metadata.dart @@ -18,44 +18,44 @@ class OrderTypeUiMetadata { factory OrderTypeUiMetadata.fromId({required String id}) { switch (id) { case 'rapid': - return const OrderTypeUiMetadata( + return OrderTypeUiMetadata( icon: UiIcons.zap, - backgroundColor: UiColors.tagPending, - borderColor: UiColors.separatorSpecial, - iconBackgroundColor: UiColors.textWarning, - iconColor: UiColors.white, - textColor: UiColors.textWarning, - descriptionColor: UiColors.textWarning, + backgroundColor: UiColors.iconError.withAlpha(24), + borderColor: UiColors.iconError, + iconBackgroundColor: UiColors.iconError.withAlpha(24), + iconColor: UiColors.iconError, + textColor: UiColors.iconError, + descriptionColor: UiColors.iconError, ); case 'one-time': - return const OrderTypeUiMetadata( + return OrderTypeUiMetadata( icon: UiIcons.calendar, - backgroundColor: UiColors.tagInProgress, - borderColor: UiColors.primaryInverse, - iconBackgroundColor: UiColors.primary, - iconColor: UiColors.white, - textColor: UiColors.textLink, - descriptionColor: UiColors.textLink, + backgroundColor: UiColors.primary.withAlpha(24), + borderColor: UiColors.primary, + iconBackgroundColor: UiColors.primary.withAlpha(24), + iconColor: UiColors.primary, + textColor: UiColors.primary, + descriptionColor: UiColors.primary, ); - case 'recurring': - return const OrderTypeUiMetadata( - icon: UiIcons.rotateCcw, - backgroundColor: UiColors.tagSuccess, - borderColor: UiColors.switchActive, - iconBackgroundColor: UiColors.textSuccess, - iconColor: UiColors.white, + case 'permanent': + return OrderTypeUiMetadata( + icon: UiIcons.users, + backgroundColor: UiColors.textSuccess.withAlpha(24), + borderColor: UiColors.textSuccess, + iconBackgroundColor: UiColors.textSuccess.withAlpha(24), + iconColor: UiColors.textSuccess, textColor: UiColors.textSuccess, descriptionColor: UiColors.textSuccess, ); - case 'permanent': - return const OrderTypeUiMetadata( - icon: UiIcons.briefcase, - backgroundColor: UiColors.tagRefunded, - borderColor: UiColors.primaryInverse, - iconBackgroundColor: UiColors.primary, - iconColor: UiColors.white, - textColor: UiColors.textLink, - descriptionColor: UiColors.textLink, + case 'recurring': + return OrderTypeUiMetadata( + icon: UiIcons.rotateCcw, + backgroundColor: const Color.fromARGB(255, 170, 10, 223).withAlpha(24), + borderColor: const Color.fromARGB(255, 170, 10, 223), + iconBackgroundColor: const Color.fromARGB(255, 170, 10, 223).withAlpha(24), + iconColor: const Color.fromARGB(255, 170, 10, 223), + textColor: const Color.fromARGB(255, 170, 10, 223), + descriptionColor: const Color.fromARGB(255, 170, 10, 223), ); default: return const OrderTypeUiMetadata( diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/create_order/create_order_view.dart b/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/create_order/create_order_view.dart index 505276cf..fff5cd46 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/create_order/create_order_view.dart +++ b/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/create_order/create_order_view.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_modular/flutter_modular.dart'; import 'package:krow_core/core.dart'; import 'package:krow_domain/krow_domain.dart'; -import '../../utils/order_types.dart'; +import '../../utils/constants/order_types.dart'; import '../../utils/ui_entities/order_type_ui_metadata.dart'; import '../order_type_card.dart'; @@ -55,33 +55,28 @@ class CreateOrderView extends StatelessWidget { padding: const EdgeInsets.only(bottom: UiConstants.space6), child: Text( t.client_create_order.section_title, - style: UiTypography.footnote1m.copyWith( - color: UiColors.textDescription, - letterSpacing: 0.5, - ), + style: UiTypography.body2m.textDescription, ), ), Expanded( child: GridView.builder( - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - mainAxisSpacing: UiConstants.space4, - crossAxisSpacing: UiConstants.space4, - childAspectRatio: 1, - ), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: UiConstants.space4, + crossAxisSpacing: UiConstants.space4, + childAspectRatio: 1, + ), itemCount: orderTypes.length, itemBuilder: (BuildContext context, int index) { final OrderType type = orderTypes[index]; - final OrderTypeUiMetadata ui = - OrderTypeUiMetadata.fromId(id: type.id); + final OrderTypeUiMetadata ui = OrderTypeUiMetadata.fromId( + id: type.id, + ); return OrderTypeCard( icon: ui.icon, title: _getTranslation(key: type.titleKey), - description: _getTranslation( - key: type.descriptionKey, - ), + description: _getTranslation(key: type.descriptionKey), backgroundColor: ui.backgroundColor, borderColor: ui.borderColor, iconBackgroundColor: ui.iconBackgroundColor, @@ -114,4 +109,4 @@ class CreateOrderView extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/order_type_card.dart b/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/order_type_card.dart index f9c92f43..3229daf1 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/order_type_card.dart +++ b/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/order_type_card.dart @@ -57,7 +57,7 @@ class OrderTypeCard extends StatelessWidget { decoration: BoxDecoration( color: backgroundColor, borderRadius: BorderRadius.circular(UiConstants.radiusBase), - border: Border.all(color: borderColor, width: 2), + border: Border.all(color: borderColor, width: 0.75), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -73,8 +73,7 @@ class OrderTypeCard extends StatelessWidget { ), child: Icon(icon, color: iconColor, size: 24), ), - Text(title, style: UiTypography.body2b.copyWith(color: textColor)), - const SizedBox(height: UiConstants.space1), + Text(title, style: UiTypography.body1b.copyWith(color: textColor)), Expanded( child: Text( description,