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;
/// Order type constants for the create order feature
final List<domain.OrderType> orderTypes = const <domain.OrderType>[
domain.OrderType(
id: 'one-time',
titleKey: 'client_create_order.types.one_time',
descriptionKey: 'client_create_order.types.one_time_desc',
),
const List<domain.OrderType> orderTypes = <domain.OrderType>[
/// 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',

View File

@@ -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(

View File

@@ -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 {
),
);
}
}
}

View File

@@ -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,