feat: Refactor order types and update UI metadata for create order feature

This commit is contained in:
Achintha Isuru
2026-02-21 18:38:18 -05:00
parent 216076f753
commit 8a71f98deb
4 changed files with 52 additions and 63 deletions

View File

@@ -1,29 +1,24 @@
import 'package:krow_domain/krow_domain.dart' as domain; import 'package:krow_domain/krow_domain.dart' as domain;
/// Order type constants for the create order feature /// Order type constants for the create order feature
final List<domain.OrderType> orderTypes = const <domain.OrderType>[ const List<domain.OrderType> orderTypes = <domain.OrderType>[
domain.OrderType(
id: 'one-time',
titleKey: 'client_create_order.types.one_time',
descriptionKey: 'client_create_order.types.one_time_desc',
),
/// TODO: FEATURE_NOT_YET_IMPLEMENTED /// TODO: FEATURE_NOT_YET_IMPLEMENTED
// domain.OrderType( // domain.OrderType(
// id: 'rapid', // id: 'rapid',
// titleKey: 'client_create_order.types.rapid', // titleKey: 'client_create_order.types.rapid',
// descriptionKey: 'client_create_order.types.rapid_desc', // 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( domain.OrderType(
id: 'recurring', id: 'recurring',
titleKey: 'client_create_order.types.recurring', titleKey: 'client_create_order.types.recurring',
descriptionKey: 'client_create_order.types.recurring_desc', 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( domain.OrderType(
id: 'permanent', id: 'permanent',
titleKey: 'client_create_order.types.permanent', titleKey: 'client_create_order.types.permanent',

View File

@@ -18,44 +18,44 @@ class OrderTypeUiMetadata {
factory OrderTypeUiMetadata.fromId({required String id}) { factory OrderTypeUiMetadata.fromId({required String id}) {
switch (id) { switch (id) {
case 'rapid': case 'rapid':
return const OrderTypeUiMetadata( return OrderTypeUiMetadata(
icon: UiIcons.zap, icon: UiIcons.zap,
backgroundColor: UiColors.tagPending, backgroundColor: UiColors.iconError.withAlpha(24),
borderColor: UiColors.separatorSpecial, borderColor: UiColors.iconError,
iconBackgroundColor: UiColors.textWarning, iconBackgroundColor: UiColors.iconError.withAlpha(24),
iconColor: UiColors.white, iconColor: UiColors.iconError,
textColor: UiColors.textWarning, textColor: UiColors.iconError,
descriptionColor: UiColors.textWarning, descriptionColor: UiColors.iconError,
); );
case 'one-time': case 'one-time':
return const OrderTypeUiMetadata( return OrderTypeUiMetadata(
icon: UiIcons.calendar, icon: UiIcons.calendar,
backgroundColor: UiColors.tagInProgress, backgroundColor: UiColors.primary.withAlpha(24),
borderColor: UiColors.primaryInverse, borderColor: UiColors.primary,
iconBackgroundColor: UiColors.primary, iconBackgroundColor: UiColors.primary.withAlpha(24),
iconColor: UiColors.white, iconColor: UiColors.primary,
textColor: UiColors.textLink, textColor: UiColors.primary,
descriptionColor: UiColors.textLink, descriptionColor: UiColors.primary,
); );
case 'recurring': case 'permanent':
return const OrderTypeUiMetadata( return OrderTypeUiMetadata(
icon: UiIcons.rotateCcw, icon: UiIcons.users,
backgroundColor: UiColors.tagSuccess, backgroundColor: UiColors.textSuccess.withAlpha(24),
borderColor: UiColors.switchActive, borderColor: UiColors.textSuccess,
iconBackgroundColor: UiColors.textSuccess, iconBackgroundColor: UiColors.textSuccess.withAlpha(24),
iconColor: UiColors.white, iconColor: UiColors.textSuccess,
textColor: UiColors.textSuccess, textColor: UiColors.textSuccess,
descriptionColor: UiColors.textSuccess, descriptionColor: UiColors.textSuccess,
); );
case 'permanent': case 'recurring':
return const OrderTypeUiMetadata( return OrderTypeUiMetadata(
icon: UiIcons.briefcase, icon: UiIcons.rotateCcw,
backgroundColor: UiColors.tagRefunded, backgroundColor: const Color.fromARGB(255, 170, 10, 223).withAlpha(24),
borderColor: UiColors.primaryInverse, borderColor: const Color.fromARGB(255, 170, 10, 223),
iconBackgroundColor: UiColors.primary, iconBackgroundColor: const Color.fromARGB(255, 170, 10, 223).withAlpha(24),
iconColor: UiColors.white, iconColor: const Color.fromARGB(255, 170, 10, 223),
textColor: UiColors.textLink, textColor: const Color.fromARGB(255, 170, 10, 223),
descriptionColor: UiColors.textLink, descriptionColor: const Color.fromARGB(255, 170, 10, 223),
); );
default: default:
return const OrderTypeUiMetadata( return const OrderTypeUiMetadata(

View File

@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart'; import 'package:flutter_modular/flutter_modular.dart';
import 'package:krow_core/core.dart'; import 'package:krow_core/core.dart';
import 'package:krow_domain/krow_domain.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 '../../utils/ui_entities/order_type_ui_metadata.dart';
import '../order_type_card.dart'; import '../order_type_card.dart';
@@ -55,33 +55,28 @@ class CreateOrderView extends StatelessWidget {
padding: const EdgeInsets.only(bottom: UiConstants.space6), padding: const EdgeInsets.only(bottom: UiConstants.space6),
child: Text( child: Text(
t.client_create_order.section_title, t.client_create_order.section_title,
style: UiTypography.footnote1m.copyWith( style: UiTypography.body2m.textDescription,
color: UiColors.textDescription,
letterSpacing: 0.5,
),
), ),
), ),
Expanded( Expanded(
child: GridView.builder( child: GridView.builder(
gridDelegate: gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2,
crossAxisCount: 2, mainAxisSpacing: UiConstants.space4,
mainAxisSpacing: UiConstants.space4, crossAxisSpacing: UiConstants.space4,
crossAxisSpacing: UiConstants.space4, childAspectRatio: 1,
childAspectRatio: 1, ),
),
itemCount: orderTypes.length, itemCount: orderTypes.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
final OrderType type = orderTypes[index]; final OrderType type = orderTypes[index];
final OrderTypeUiMetadata ui = final OrderTypeUiMetadata ui = OrderTypeUiMetadata.fromId(
OrderTypeUiMetadata.fromId(id: type.id); id: type.id,
);
return OrderTypeCard( return OrderTypeCard(
icon: ui.icon, icon: ui.icon,
title: _getTranslation(key: type.titleKey), title: _getTranslation(key: type.titleKey),
description: _getTranslation( description: _getTranslation(key: type.descriptionKey),
key: type.descriptionKey,
),
backgroundColor: ui.backgroundColor, backgroundColor: ui.backgroundColor,
borderColor: ui.borderColor, borderColor: ui.borderColor,
iconBackgroundColor: ui.iconBackgroundColor, iconBackgroundColor: ui.iconBackgroundColor,
@@ -114,4 +109,4 @@ class CreateOrderView extends StatelessWidget {
), ),
); );
} }
} }

View File

@@ -57,7 +57,7 @@ class OrderTypeCard extends StatelessWidget {
decoration: BoxDecoration( decoration: BoxDecoration(
color: backgroundColor, color: backgroundColor,
borderRadius: BorderRadius.circular(UiConstants.radiusBase), borderRadius: BorderRadius.circular(UiConstants.radiusBase),
border: Border.all(color: borderColor, width: 2), border: Border.all(color: borderColor, width: 0.75),
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@@ -73,8 +73,7 @@ class OrderTypeCard extends StatelessWidget {
), ),
child: Icon(icon, color: iconColor, size: 24), child: Icon(icon, color: iconColor, size: 24),
), ),
Text(title, style: UiTypography.body2b.copyWith(color: textColor)), Text(title, style: UiTypography.body1b.copyWith(color: textColor)),
const SizedBox(height: UiConstants.space1),
Expanded( Expanded(
child: Text( child: Text(
description, description,