diff --git a/apps/mobile/packages/core/lib/src/routing/client/navigator.dart b/apps/mobile/packages/core/lib/src/routing/client/navigator.dart index 4c7bcd34..1c3c7c6e 100644 --- a/apps/mobile/packages/core/lib/src/routing/client/navigator.dart +++ b/apps/mobile/packages/core/lib/src/routing/client/navigator.dart @@ -137,35 +137,47 @@ extension ClientNavigator on IModularNavigator { /// Pushes the order creation flow entry page. /// /// This is the starting point for all order creation flows. - void toCreateOrder() { - pushNamed(ClientPaths.createOrder); + void toCreateOrder({Object? arguments}) { + navigate(ClientPaths.createOrder, arguments: arguments); } /// Pushes the rapid order creation flow. /// /// Quick shift creation with simplified inputs for urgent needs. - void toCreateOrderRapid() { - pushNamed(ClientPaths.createOrderRapid); + void toCreateOrderRapid({Object? arguments}) { + pushNamed(ClientPaths.createOrderRapid, arguments: arguments); } /// Pushes the one-time order creation flow. /// /// Create a shift that occurs once at a specific date and time. - void toCreateOrderOneTime() { - pushNamed(ClientPaths.createOrderOneTime); + void toCreateOrderOneTime({Object? arguments}) { + pushNamed(ClientPaths.createOrderOneTime, arguments: arguments); } /// Pushes the recurring order creation flow. /// /// Create shifts that repeat on a defined schedule (daily, weekly, etc.). - void toCreateOrderRecurring() { - pushNamed(ClientPaths.createOrderRecurring); + void toCreateOrderRecurring({Object? arguments}) { + pushNamed(ClientPaths.createOrderRecurring, arguments: arguments); } /// Pushes the permanent order creation flow. /// /// Create a long-term or permanent staffing position. - void toCreateOrderPermanent() { - pushNamed(ClientPaths.createOrderPermanent); + void toCreateOrderPermanent({Object? arguments}) { + pushNamed(ClientPaths.createOrderPermanent, arguments: arguments); + } + + // ========================================================================== + // VIEW ORDER + // ========================================================================== + + /// Navigates to the order details page to a specific date. + void toOrdersSpecificDate(DateTime date) { + navigate( + ClientPaths.orders, + arguments: {'initialDate': date}, + ); } } diff --git a/apps/mobile/packages/core/lib/src/routing/staff/navigator.dart b/apps/mobile/packages/core/lib/src/routing/staff/navigator.dart index 5da83e16..f8761802 100644 --- a/apps/mobile/packages/core/lib/src/routing/staff/navigator.dart +++ b/apps/mobile/packages/core/lib/src/routing/staff/navigator.dart @@ -29,7 +29,7 @@ extension StaffNavigator on IModularNavigator { // ========================================================================== /// Navigates to the root get started/authentication screen. - /// + /// /// This effectively logs out the user by navigating to root. /// Used when signing out or session expires. void toInitialPage() { @@ -37,7 +37,7 @@ extension StaffNavigator on IModularNavigator { } /// Navigates to the get started page. - /// + /// /// This is the landing page for unauthenticated users, offering login/signup options. void toGetStartedPage() { navigate(StaffPaths.getStarted); @@ -64,7 +64,7 @@ extension StaffNavigator on IModularNavigator { /// This is typically called after successful phone verification for new /// staff members. Uses pushReplacement to prevent going back to verification. void toProfileSetup() { - pushReplacementNamed(StaffPaths.profileSetup); + pushNamed(StaffPaths.profileSetup); } // ========================================================================== @@ -76,7 +76,7 @@ extension StaffNavigator on IModularNavigator { /// This is the main landing page for authenticated staff members. /// Displays shift cards, quick actions, and notifications. void toStaffHome() { - pushNamed(StaffPaths.home); + pushNamedAndRemoveUntil(StaffPaths.home, (_) => false); } /// Navigates to the staff main shell. @@ -84,7 +84,7 @@ extension StaffNavigator on IModularNavigator { /// This is the container with bottom navigation. Navigates to home tab /// by default. Usually you'd navigate to a specific tab instead. void toStaffMain() { - navigate('${StaffPaths.main}/home/'); + pushNamedAndRemoveUntil('${StaffPaths.main}/home/', (_) => false); } // ========================================================================== @@ -113,31 +113,28 @@ extension StaffNavigator on IModularNavigator { if (refreshAvailable == true) { args['refreshAvailable'] = true; } - navigate( - StaffPaths.shifts, - arguments: args.isEmpty ? null : args, - ); + navigate(StaffPaths.shifts, arguments: args.isEmpty ? null : args); } /// Navigates to the Payments tab. /// /// View payment history, earnings breakdown, and tax information. void toPayments() { - navigate(StaffPaths.payments); + pushNamedAndRemoveUntil(StaffPaths.payments, (_) => false); } /// Navigates to the Clock In tab. /// /// Access time tracking interface for active shifts. void toClockIn() { - navigate(StaffPaths.clockIn); + pushNamedAndRemoveUntil(StaffPaths.clockIn, (_) => false); } /// Navigates to the Profile tab. /// /// Manage personal information, documents, and preferences. void toProfile() { - navigate(StaffPaths.profile); + pushNamedAndRemoveUntil(StaffPaths.profile, (_) => false); } // ========================================================================== @@ -155,22 +152,7 @@ extension StaffNavigator on IModularNavigator { /// The shift object is passed as an argument and can be retrieved /// in the details page. void toShiftDetails(Shift shift) { - navigate( - StaffPaths.shiftDetails(shift.id), - arguments: shift, - ); - } - - /// Pushes the shift details page (alternative method). - /// - /// Same as [toShiftDetails] but using pushNamed instead of navigate. - /// Use this when you want to add the details page to the stack rather - /// than replacing the current route. - void pushShiftDetails(Shift shift) { - pushNamed( - StaffPaths.shiftDetails(shift.id), - arguments: shift, - ); + navigate(StaffPaths.shiftDetails(shift.id), arguments: shift); } // ========================================================================== diff --git a/apps/mobile/packages/core_localization/lib/src/l10n/en.i18n.json b/apps/mobile/packages/core_localization/lib/src/l10n/en.i18n.json index 19e2ed7d..e29e862d 100644 --- a/apps/mobile/packages/core_localization/lib/src/l10n/en.i18n.json +++ b/apps/mobile/packages/core_localization/lib/src/l10n/en.i18n.json @@ -104,7 +104,7 @@ "client_authentication": { "get_started_page": { "title": "Take Control of Your\nShifts and Events", - "subtitle": "Streamline your operations with powerful tools to manage schedules, track performance, and keep your team on the same page—all in one place", + "subtitle": "Streamline your operations with powerful tools to manage schedules, track performance, and keep your team on the same page\u2014all in one place", "sign_in_button": "Sign In", "create_account_button": "Create Account" }, @@ -452,7 +452,7 @@ }, "empty_states": { "no_shifts_today": "No shifts scheduled for today", - "find_shifts_cta": "Find shifts →", + "find_shifts_cta": "Find shifts \u2192", "no_shifts_tomorrow": "No shifts for tomorrow", "no_recommended_shifts": "No recommended shifts" }, @@ -462,7 +462,7 @@ "amount": "$amount" }, "recommended_card": { - "act_now": "• ACT NOW", + "act_now": "\u2022 ACT NOW", "one_day": "One Day", "today": "Today", "applied_for": "Applied for $title", @@ -695,7 +695,7 @@ "eta_label": "$min min", "locked_desc": "Most app features are locked while commute mode is on. You'll be able to clock in once you arrive.", "turn_off": "Turn Off Commute Mode", - "arrived_title": "You've Arrived! 🎉", + "arrived_title": "You've Arrived! \ud83c\udf89", "arrived_desc": "You're at the shift location. Ready to clock in?" }, "swipe": { @@ -967,16 +967,16 @@ "required": "REQUIRED", "add_photo": "Add Photo", "added": "Added", - "pending": "⏳ Pending verification" + "pending": "\u23f3 Pending verification" }, "attestation": "I certify that I own these items and will wear them to my shifts. I understand that items are pending manager verification at my first shift.", "actions": { "save": "Save Attire" }, "validation": { - "select_required": "✓ Select all required items", - "upload_required": "✓ Upload photos of required items", - "accept_attestation": "✓ Accept attestation" + "select_required": "\u2713 Select all required items", + "upload_required": "\u2713 Upload photos of required items", + "accept_attestation": "\u2713 Accept attestation" } }, "staff_shifts": { @@ -1095,8 +1095,18 @@ }, "card": { "cancelled": "CANCELLED", - "compensation": "• 4hr compensation" + "compensation": "\u2022 4hr compensation" } + }, + "find_shifts": { + "search_hint": "Search jobs, location...", + "filter_all": "All Jobs", + "filter_one_day": "One Day", + "filter_multi_day": "Multi-Day", + "filter_long_term": "Long Term", + "no_jobs_title": "No jobs available", + "no_jobs_subtitle": "Check back later", + "application_submitted": "Shift application submitted!" } }, "staff_time_card": { @@ -1218,11 +1228,11 @@ }, "total_spend": { "label": "Total Spend", - "badge": "↓ 8% vs last week" + "badge": "\u2193 8% vs last week" }, "fill_rate": { "label": "Fill Rate", - "badge": "↑ 2% improvement" + "badge": "\u2191 2% improvement" }, "avg_fill_time": { "label": "Avg Fill Time", @@ -1364,9 +1374,9 @@ "target_prefix": "Target: ", "target_hours": "$hours hrs", "target_percent": "$percent%", - "met": "✓ Met", - "close": "→ Close", - "miss": "✗ Miss" + "met": "\u2713 Met", + "close": "\u2192 Close", + "miss": "\u2717 Miss" }, "additional_metrics_title": "ADDITIONAL METRICS", "additional_metrics": { diff --git a/apps/mobile/packages/core_localization/lib/src/l10n/es.i18n.json b/apps/mobile/packages/core_localization/lib/src/l10n/es.i18n.json index e96442da..968bf050 100644 --- a/apps/mobile/packages/core_localization/lib/src/l10n/es.i18n.json +++ b/apps/mobile/packages/core_localization/lib/src/l10n/es.i18n.json @@ -13,139 +13,139 @@ "staff_authentication": { "get_started_page": { "title_part1": "Trabaja, Crece, ", - "title_part2": "Elévate", - "subtitle": "Construye tu carrera en hostelería con \nflexibilidad y libertad.", + "title_part2": "El\u00e9vate", + "subtitle": "Construye tu carrera en hosteler\u00eda con \nflexibilidad y libertad.", "sign_up_button": "Registrarse", - "log_in_button": "Iniciar sesión" + "log_in_button": "Iniciar sesi\u00f3n" }, "phone_verification_page": { - "validation_error": "Por favor, ingresa un número de teléfono válido de 10 dígitos", - "send_code_button": "Enviar código", - "enter_code_title": "Ingresa el código de verificación", - "code_sent_message": "Enviamos un código de 6 dígitos a ", - "code_sent_instruction": ". Ingrésalo a continuación para verificar tu cuenta." + "validation_error": "Por favor, ingresa un n\u00famero de tel\u00e9fono v\u00e1lido de 10 d\u00edgitos", + "send_code_button": "Enviar c\u00f3digo", + "enter_code_title": "Ingresa el c\u00f3digo de verificaci\u00f3n", + "code_sent_message": "Enviamos un c\u00f3digo de 6 d\u00edgitos a ", + "code_sent_instruction": ". Ingr\u00e9salo a continuaci\u00f3n para verificar tu cuenta." }, "phone_input": { - "title": "Verifica tu número de teléfono", - "subtitle": "Te enviaremos un código de verificación para comenzar.", - "label": "Número de teléfono", - "hint": "Ingresa tu número" + "title": "Verifica tu n\u00famero de tel\u00e9fono", + "subtitle": "Te enviaremos un c\u00f3digo de verificaci\u00f3n para comenzar.", + "label": "N\u00famero de tel\u00e9fono", + "hint": "Ingresa tu n\u00famero" }, "otp_verification": { - "did_not_get_code": "¿No recibiste el código?", + "did_not_get_code": "\u00bfNo recibiste el c\u00f3digo?", "resend_in": "Reenviar en $seconds s", - "resend_code": "Reenviar código" + "resend_code": "Reenviar c\u00f3digo" }, "profile_setup_page": { "step_indicator": "Paso $current de $total", - "error_occurred": "Ocurrió un error", - "complete_setup_button": "Completar configuración", + "error_occurred": "Ocurri\u00f3 un error", + "complete_setup_button": "Completar configuraci\u00f3n", "steps": { - "basic": "Información básica", - "location": "Ubicación", + "basic": "Informaci\u00f3n b\u00e1sica", + "location": "Ubicaci\u00f3n", "experience": "Experiencia" }, "basic_info": { - "title": "Conozcámonos", - "subtitle": "Cuéntanos un poco sobre ti", + "title": "Conozc\u00e1monos", + "subtitle": "Cu\u00e9ntanos un poco sobre ti", "full_name_label": "Nombre completo *", - "full_name_hint": "Juan Pérez", - "bio_label": "Biografía corta", - "bio_hint": "Profesional experimentado en hostelería..." + "full_name_hint": "Juan P\u00e9rez", + "bio_label": "Biograf\u00eda corta", + "bio_hint": "Profesional experimentado en hosteler\u00eda..." }, "location": { - "title": "¿Dónde quieres trabajar?", + "title": "\u00bfD\u00f3nde quieres trabajar?", "subtitle": "Agrega tus ubicaciones de trabajo preferidas", "full_name_label": "Nombre completo", - "add_location_label": "Agregar ubicación *", - "add_location_hint": "Ciudad o código postal", + "add_location_label": "Agregar ubicaci\u00f3n *", + "add_location_hint": "Ciudad o c\u00f3digo postal", "add_button": "Agregar", - "max_distance": "Distancia máxima: $distance millas", + "max_distance": "Distancia m\u00e1xima: $distance millas", "min_dist_label": "5 mi", "max_dist_label": "50 mi" }, "experience": { - "title": "¿Cuáles son tus habilidades?", + "title": "\u00bfCu\u00e1les son tus habilidades?", "subtitle": "Selecciona todas las que correspondan", "skills_label": "Habilidades *", "industries_label": "Industrias preferidas", "skills": { "food_service": "Servicio de comida", - "bartending": "Preparación de bebidas", - "warehouse": "Almacén", + "bartending": "Preparaci\u00f3n de bebidas", + "warehouse": "Almac\u00e9n", "retail": "Venta minorista", "events": "Eventos", "customer_service": "Servicio al cliente", "cleaning": "Limpieza", "security": "Seguridad", - "driving": "Conducción", + "driving": "Conducci\u00f3n", "cooking": "Cocina", "cashier": "Cajero", "server": "Mesero", "barista": "Barista", - "host_hostess": "Anfitrión", + "host_hostess": "Anfitri\u00f3n", "busser": "Ayudante de mesero" }, "industries": { - "hospitality": "Hostelería", + "hospitality": "Hosteler\u00eda", "food_service": "Servicio de comida", - "warehouse": "Almacén", + "warehouse": "Almac\u00e9n", "events": "Eventos", "retail": "Venta minorista", - "healthcare": "Atención médica" + "healthcare": "Atenci\u00f3n m\u00e9dica" } } }, "common": { - "trouble_question": "¿Tienes problemas? ", + "trouble_question": "\u00bfTienes problemas? ", "contact_support": "Contactar a soporte" } }, "client_authentication": { "get_started_page": { "title": "Toma el control de tus\nturnos y eventos", - "subtitle": "Optimiza tus operaciones con potentes herramientas para gestionar horarios, realizar un seguimiento del rendimiento y mantener a tu equipo en la misma página, todo en un solo lugar", - "sign_in_button": "Iniciar sesión", + "subtitle": "Optimiza tus operaciones con potentes herramientas para gestionar horarios, realizar un seguimiento del rendimiento y mantener a tu equipo en la misma p\u00e1gina, todo en un solo lugar", + "sign_in_button": "Iniciar sesi\u00f3n", "create_account_button": "Crear cuenta" }, "sign_in_page": { "title": "Bienvenido de nuevo", - "subtitle": "Inicia sesión para gestionar tus turnos y trabajadores", - "email_label": "Correo electrónico", - "email_hint": "Ingresa tu correo electrónico", - "password_label": "Contraseña", - "password_hint": "Ingresa tu contraseña", - "forgot_password": "¿Olvidaste tu contraseña?", - "sign_in_button": "Iniciar sesión", + "subtitle": "Inicia sesi\u00f3n para gestionar tus turnos y trabajadores", + "email_label": "Correo electr\u00f3nico", + "email_hint": "Ingresa tu correo electr\u00f3nico", + "password_label": "Contrase\u00f1a", + "password_hint": "Ingresa tu contrase\u00f1a", + "forgot_password": "\u00bfOlvidaste tu contrase\u00f1a?", + "sign_in_button": "Iniciar sesi\u00f3n", "or_divider": "o", - "social_apple": "Iniciar sesión con Apple", - "social_google": "Iniciar sesión con Google", - "no_account": "¿No tienes una cuenta? ", - "sign_up_link": "Regístrate" + "social_apple": "Iniciar sesi\u00f3n con Apple", + "social_google": "Iniciar sesi\u00f3n con Google", + "no_account": "\u00bfNo tienes una cuenta? ", + "sign_up_link": "Reg\u00edstrate" }, "sign_up_page": { "title": "Crear cuenta", "subtitle": "Comienza con Krow para tu negocio", "company_label": "Nombre de la empresa", "company_hint": "Ingresa el nombre de la empresa", - "email_label": "Correo electrónico", - "email_hint": "Ingresa tu correo electrónico", - "password_label": "Contraseña", - "password_hint": "Crea una contraseña", - "confirm_password_label": "Confirmar contraseña", - "confirm_password_hint": "Confirma tu contraseña", + "email_label": "Correo electr\u00f3nico", + "email_hint": "Ingresa tu correo electr\u00f3nico", + "password_label": "Contrase\u00f1a", + "password_hint": "Crea una contrase\u00f1a", + "confirm_password_label": "Confirmar contrase\u00f1a", + "confirm_password_hint": "Confirma tu contrase\u00f1a", "create_account_button": "Crear cuenta", "or_divider": "o", - "social_apple": "Regístrate con Apple", - "social_google": "Regístrate con Google", - "has_account": "¿Ya tienes una cuenta? ", - "sign_in_link": "Iniciar sesión" + "social_apple": "Reg\u00edstrate con Apple", + "social_google": "Reg\u00edstrate con Google", + "has_account": "\u00bfYa tienes una cuenta? ", + "sign_in_link": "Iniciar sesi\u00f3n" } }, "client_home": { "dashboard": { "welcome_back": "Bienvenido de nuevo", - "edit_mode_active": "Modo Edición Activo", + "edit_mode_active": "Modo Edici\u00f3n Activo", "drag_instruction": "Arrastra para reordenar, cambia la visibilidad", "reset": "Restablecer", "todays_coverage": "COBERTURA DE HOY", @@ -155,24 +155,24 @@ "metric_open": "Abierto", "spending": { "this_week": "Esta Semana", - "next_7_days": "Próximos 7 Días", + "next_7_days": "Pr\u00f3ximos 7 D\u00edas", "shifts_count": "$count turnos", "scheduled_count": "$count programados" }, "view_all": "Ver todo", "insight_lightbulb": "Ahorra $amount/mes", - "insight_tip": "Reserva con 48h de antelación para mejores tarifas" + "insight_tip": "Reserva con 48h de antelaci\u00f3n para mejores tarifas" }, "widgets": { - "actions": "Acciones Rápidas", + "actions": "Acciones R\u00e1pidas", "reorder": "Reordenar", "coverage": "Cobertura de Hoy", - "spending": "Información de Gastos", + "spending": "Informaci\u00f3n de Gastos", "live_activity": "Actividad en Vivo" }, "actions": { - "rapid": "RÁPIDO", - "rapid_subtitle": "Urgente mismo día", + "rapid": "R\u00c1PIDO", + "rapid_subtitle": "Urgente mismo d\u00eda", "create_order": "Crear Orden", "create_order_subtitle": "Programar turnos", "hubs": "Hubs", @@ -189,10 +189,10 @@ "review_subtitle": "Revisa y edita los detalles antes de publicar", "date_label": "Fecha *", "date_hint": "mm/dd/aaaa", - "location_label": "Ubicación *", - "location_hint": "Dirección del negocio", + "location_label": "Ubicaci\u00f3n *", + "location_hint": "Direcci\u00f3n del negocio", "positions_title": "Posiciones", - "add_position": "Añadir Posición", + "add_position": "A\u00f1adir Posici\u00f3n", "role_label": "Rol *", "role_hint": "Seleccionar rol", "start_time": "Hora de Inicio *", @@ -207,50 +207,50 @@ "title": "Perfil", "edit_profile": "Editar Perfil", "hubs": "Hubs", - "log_out": "Cerrar sesión", - "quick_links": "Enlaces rápidos", + "log_out": "Cerrar sesi\u00f3n", + "quick_links": "Enlaces r\u00e1pidos", "clock_in_hubs": "Hubs de Marcaje", - "billing_payments": "Facturación y Pagos" + "billing_payments": "Facturaci\u00f3n y Pagos" } }, "client_hubs": { "title": "Hubs", "subtitle": "Gestionar ubicaciones de marcaje", - "add_hub": "Añadir Hub", + "add_hub": "A\u00f1adir Hub", "empty_state": { - "title": "No hay hubs aún", + "title": "No hay hubs a\u00fan", "description": "Crea estaciones de marcaje para tus ubicaciones", - "button": "Añade tu primer Hub" + "button": "A\u00f1ade tu primer Hub" }, "about_hubs": { "title": "Sobre los Hubs", - "description": "Los Hubs son estaciones de marcaje en tus ubicaciones. Asigna etiquetas NFC a cada hub para que los trabajadores puedan marcar entrada/salida rápidamente usando sus teléfonos." + "description": "Los Hubs son estaciones de marcaje en tus ubicaciones. Asigna etiquetas NFC a cada hub para que los trabajadores puedan marcar entrada/salida r\u00e1pidamente usando sus tel\u00e9fonos." }, "hub_card": { "tag_label": "Etiqueta: $id" }, "add_hub_dialog": { - "title": "Añadir Nuevo Hub", + "title": "A\u00f1adir Nuevo Hub", "name_label": "Nombre del Hub *", - "name_hint": "ej., Cocina Principal, Recepción", - "location_label": "Nombre de la Ubicación", + "name_hint": "ej., Cocina Principal, Recepci\u00f3n", + "location_label": "Nombre de la Ubicaci\u00f3n", "location_hint": "ej., Restaurante Centro", - "address_label": "Dirección", - "address_hint": "Dirección completa", + "address_label": "Direcci\u00f3n", + "address_hint": "Direcci\u00f3n completa", "create_button": "Crear Hub" }, "nfc_dialog": { "title": "Identificar Etiqueta NFC", - "instruction": "Acerque su teléfono a la etiqueta NFC para identificarla", + "instruction": "Acerque su tel\u00e9fono a la etiqueta NFC para identificarla", "scan_button": "Escanear Etiqueta NFC", "tag_identified": "Etiqueta Identificada", "assign_button": "Asignar Etiqueta" }, "delete_dialog": { - "title": "Confirmar eliminación de Hub", - "message": "¿Estás seguro de que quieres eliminar \"$hubName\"?", - "undo_warning": "Esta acción no se puede deshacer.", - "dependency_warning": "Ten en cuenta que si hay turnos/órdenes asignados a este hub no deberíamos poder eliminarlo.", + "title": "Confirmar eliminaci\u00f3n de Hub", + "message": "\u00bfEst\u00e1s seguro de que quieres eliminar \"$hubName\"?", + "undo_warning": "Esta acci\u00f3n no se puede deshacer.", + "dependency_warning": "Ten en cuenta que si hay turnos/\u00f3rdenes asignados a este hub no deber\u00edamos poder eliminarlo.", "cancel": "Cancelar", "delete": "Eliminar" }, @@ -259,16 +259,16 @@ "subtitle": "Actualizar detalles del hub", "name_label": "Nombre del Hub", "name_hint": "Ingresar nombre del hub", - "address_label": "Dirección", - "address_hint": "Ingresar dirección", + "address_label": "Direcci\u00f3n", + "address_hint": "Ingresar direcci\u00f3n", "save_button": "Guardar Cambios", - "success": "¡Hub actualizado exitosamente!" + "success": "\u00a1Hub actualizado exitosamente!" }, "hub_details": { "title": "Detalles del Hub", "edit_button": "Editar", "name_label": "Nombre del Hub", - "address_label": "Dirección", + "address_label": "Direcci\u00f3n", "nfc_label": "Etiqueta NFC", "nfc_not_assigned": "No asignada" } @@ -277,21 +277,21 @@ "title": "Crear Orden", "section_title": "TIPO DE ORDEN", "types": { - "rapid": "RÁPIDO", - "rapid_desc": "Cobertura URGENTE mismo día", - "one_time": "Única Vez", - "one_time_desc": "Evento Único o Petición de Turno", + "rapid": "R\u00c1PIDO", + "rapid_desc": "Cobertura URGENTE mismo d\u00eda", + "one_time": "\u00danica Vez", + "one_time_desc": "Evento \u00danico o Petici\u00f3n de Turno", "recurring": "Recurrente", "recurring_desc": "Cobertura Continua Semanal / Mensual", "permanent": "Permanente", - "permanent_desc": "Colocación de Personal a Largo Plazo" + "permanent_desc": "Colocaci\u00f3n de Personal a Largo Plazo" }, "rapid": { - "title": "Orden RÁPIDA", + "title": "Orden R\u00c1PIDA", "subtitle": "Personal de emergencia en minutos", "urgent_badge": "URGENTE", - "tell_us": "Dinos qué necesitas", - "need_staff": "¿Necesitas personal urgentemente?", + "tell_us": "Dinos qu\u00e9 necesitas", + "need_staff": "\u00bfNecesitas personal urgentemente?", "type_or_speak": "Escribe o habla lo que necesitas. Yo me encargo del resto", "example": "Ejemplo: ", "hint": "Escribe o habla... (ej., \"Necesito 5 cocineros YA hasta las 5am\")", @@ -299,35 +299,35 @@ "listening": "Escuchando...", "send": "Enviar Mensaje", "sending": "Enviando...", - "success_title": "¡Solicitud Enviada!", + "success_title": "\u00a1Solicitud Enviada!", "success_message": "Estamos encontrando trabajadores disponibles para ti ahora mismo. Te notificaremos cuando acepten.", - "back_to_orders": "Volver a Órdenes" + "back_to_orders": "Volver a \u00d3rdenes" }, "one_time": { - "title": "Orden Única Vez", - "subtitle": "Evento único o petición de turno", + "title": "Orden \u00danica Vez", + "subtitle": "Evento \u00fanico o petici\u00f3n de turno", "create_your_order": "Crea Tu Orden", "date_label": "Fecha", "date_hint": "Seleccionar fecha", - "location_label": "Ubicación", - "location_hint": "Ingresar dirección", + "location_label": "Ubicaci\u00f3n", + "location_hint": "Ingresar direcci\u00f3n", "positions_title": "Posiciones", - "add_position": "Añadir Posición", - "position_number": "Posición $number", + "add_position": "A\u00f1adir Posici\u00f3n", + "position_number": "Posici\u00f3n $number", "remove": "Eliminar", "select_role": "Seleccionar rol", "start_label": "Inicio", "end_label": "Fin", "workers_label": "Trabajadores", "lunch_break_label": "Descanso para Almuerzo", - "different_location": "Usar ubicación diferente para esta posición", - "different_location_title": "Ubicación Diferente", - "different_location_hint": "Ingresar dirección diferente", + "different_location": "Usar ubicaci\u00f3n diferente para esta posici\u00f3n", + "different_location_title": "Ubicaci\u00f3n Diferente", + "different_location_hint": "Ingresar direcci\u00f3n diferente", "create_order": "Crear Orden", "creating": "Creando...", - "success_title": "¡Orden Creada!", - "success_message": "Tu solicitud de turno ha sido publicada. Los trabajadores comenzarán a postularse pronto.", - "back_to_orders": "Volver a Órdenes", + "success_title": "\u00a1Orden Creada!", + "success_message": "Tu solicitud de turno ha sido publicada. Los trabajadores comenzar\u00e1n a postularse pronto.", + "back_to_orders": "Volver a \u00d3rdenes", "no_break": "Sin descanso", "paid_break": "min (Pagado)", "unpaid_break": "min (No pagado)" @@ -339,26 +339,26 @@ }, "permanent": { "title": "Orden Permanente", - "subtitle": "Colocación de personal a largo plazo", + "subtitle": "Colocaci\u00f3n de personal a largo plazo", "placeholder": "Flujo de Orden Permanente (Trabajo en Progreso)" } }, "client_main": { "tabs": { "coverage": "Cobertura", - "billing": "Facturación", + "billing": "Facturaci\u00f3n", "home": "Inicio", - "orders": "Órdenes", + "orders": "\u00d3rdenes", "reports": "Reportes" } }, "client_view_orders": { - "title": "Órdenes", + "title": "\u00d3rdenes", "post_button": "Publicar", "post_order": "Publicar una Orden", - "no_orders": "No hay órdenes para $date", + "no_orders": "No hay \u00f3rdenes para $date", "tabs": { - "up_next": "Próximos", + "up_next": "Pr\u00f3ximos", "active": "Activos", "completed": "Completados" }, @@ -369,7 +369,7 @@ "in_progress": "EN PROGRESO", "completed": "COMPLETADO", "cancelled": "CANCELADO", - "get_direction": "Obtener dirección", + "get_direction": "Obtener direcci\u00f3n", "total": "Total", "hrs": "Hrs", "workers": "$count trabajadores", @@ -378,42 +378,42 @@ "coverage": "Cobertura", "workers_label": "$filled/$needed Trabajadores", "confirmed_workers": "Trabajadores Confirmados", - "no_workers": "Ningún trabajador confirmado aún.", + "no_workers": "Ning\u00fan trabajador confirmado a\u00fan.", "today": "Hoy", - "tomorrow": "Mañana", + "tomorrow": "Ma\u00f1ana", "workers_needed": "$count Trabajadores Necesarios", "all_confirmed": "Todos los trabajadores confirmados", "confirmed_workers_title": "TRABAJADORES CONFIRMADOS", "message_all": "Mensaje a todos", - "show_more_workers": "Mostrar $count trabajadores más", + "show_more_workers": "Mostrar $count trabajadores m\u00e1s", "checked_in": "Registrado", "call_dialog": { "title": "Llamar", - "message": "¿Quieres llamar a $phone?" + "message": "\u00bfQuieres llamar a $phone?" } } }, "client_billing": { - "title": "Facturación", - "current_period": "Período Actual", + "title": "Facturaci\u00f3n", + "current_period": "Per\u00edodo Actual", "saved_amount": "$amount ahorrado", - "awaiting_approval": "Esperando Aprobación", - "payment_method": "Método de Pago", - "add_payment": "Añadir", + "awaiting_approval": "Esperando Aprobaci\u00f3n", + "payment_method": "M\u00e9todo de Pago", + "add_payment": "A\u00f1adir", "default_badge": "Predeterminado", "expires": "Expira $date", - "period_breakdown": "Desglose de este Período", + "period_breakdown": "Desglose de este Per\u00edodo", "week": "Semana", "month": "Mes", "total": "Total", "hours": "$count horas", - "rate_optimization_title": "Optimización de Tarifas", + "rate_optimization_title": "Optimizaci\u00f3n de Tarifas", "rate_optimization_body": "Ahorra $amount/mes cambiando 3 turnos", "view_details": "Ver Detalles", "invoice_history": "Historial de Facturas", "view_all": "Ver todo", "export_button": "Exportar Todas las Facturas", - "pending_badge": "PENDIENTE APROBACIÓN", + "pending_badge": "PENDIENTE APROBACI\u00d3N", "paid_badge": "PAGADO" }, "staff": { @@ -433,9 +433,9 @@ }, "banners": { "complete_profile_title": "Completa tu Perfil", - "complete_profile_subtitle": "Verifícate para ver más turnos", + "complete_profile_subtitle": "Verif\u00edcate para ver m\u00e1s turnos", "availability_title": "Disponibilidad", - "availability_subtitle": "Actualiza tu disponibilidad para la próxima semana" + "availability_subtitle": "Actualiza tu disponibilidad para la pr\u00f3xima semana" }, "quick_actions": { "find_shifts": "Buscar Turnos", @@ -446,14 +446,14 @@ "sections": { "todays_shift": "Turno de Hoy", "scheduled_count": "$count programados", - "tomorrow": "Mañana", + "tomorrow": "Ma\u00f1ana", "recommended_for_you": "Recomendado para Ti", "view_all": "Ver todo" }, "empty_states": { "no_shifts_today": "No hay turnos programados para hoy", - "find_shifts_cta": "Buscar turnos →", - "no_shifts_tomorrow": "No hay turnos para mañana", + "find_shifts_cta": "Buscar turnos \u2192", + "no_shifts_tomorrow": "No hay turnos para ma\u00f1ana", "no_recommended_shifts": "No hay turnos recomendados" }, "pending_payment": { @@ -462,8 +462,8 @@ "amount": "$amount" }, "recommended_card": { - "act_now": "• ACTÚA AHORA", - "one_day": "Un Día", + "act_now": "\u2022 ACT\u00daA AHORA", + "one_day": "Un D\u00eda", "today": "Hoy", "applied_for": "Postulado para $title", "time_range": "$start - $end" @@ -473,7 +473,7 @@ "view_all": "Ver todo", "hours_label": "horas", "items": { - "sick_days": "Días de Enfermedad", + "sick_days": "D\u00edas de Enfermedad", "vacation": "Vacaciones", "holidays": "Festivos" } @@ -481,20 +481,20 @@ "auto_match": { "title": "Auto-Match", "finding_shifts": "Buscando turnos para ti", - "get_matched": "Sé emparejado automáticamente", + "get_matched": "S\u00e9 emparejado autom\u00e1ticamente", "matching_based_on": "Emparejamiento basado en:", "chips": { - "location": "Ubicación", + "location": "Ubicaci\u00f3n", "availability": "Disponibilidad", "skills": "Habilidades" } }, "improve": { - "title": "Mejórate a ti mismo", + "title": "Mej\u00f3rate a ti mismo", "items": { "training": { - "title": "Sección de Entrenamiento", - "description": "Mejora tus habilidades y obtén certificaciones.", + "title": "Secci\u00f3n de Entrenamiento", + "description": "Mejora tus habilidades y obt\u00e9n certificaciones.", "page": "/krow-university" }, "podcast": { @@ -505,7 +505,7 @@ } }, "more_ways": { - "title": "Más Formas de Usar Krow", + "title": "M\u00e1s Formas de Usar Krow", "items": { "benefits": { "title": "Beneficios de Krow", @@ -521,21 +521,21 @@ "profile": { "header": { "title": "Perfil", - "sign_out": "CERRAR SESIÓN" + "sign_out": "CERRAR SESI\u00d3N" }, "reliability_stats": { "shifts": "Turnos", - "rating": "Calificación", + "rating": "Calificaci\u00f3n", "on_time": "A Tiempo", "no_shows": "Faltas", "cancellations": "Cancel." }, "reliability_score": { - "title": "Puntuación de Confiabilidad", - "description": "Mantén tu puntuación por encima del 45% para continuar aceptando turnos." + "title": "Puntuaci\u00f3n de Confiabilidad", + "description": "Mant\u00e9n tu puntuaci\u00f3n por encima del 45% para continuar aceptando turnos." }, "sections": { - "onboarding": "INCORPORACIÓN", + "onboarding": "INCORPORACI\u00d3N", "compliance": "CUMPLIMIENTO", "level_up": "MEJORAR NIVEL", "finance": "FINANZAS", @@ -543,10 +543,10 @@ "settings": "AJUSTES" }, "menu_items": { - "personal_info": "Información Personal", + "personal_info": "Informaci\u00f3n Personal", "emergency_contact": "Contacto de Emergencia", "emergency_contact_page": { - "save_success": "Contactos de emergencia guardados con éxito", + "save_success": "Contactos de emergencia guardados con \u00e9xito", "save_continue": "Guardar y Continuar" }, "experience": "Experiencia", @@ -556,7 +556,7 @@ "tax_forms": "Formularios Fiscales", "krow_university": "Krow University", "trainings": "Capacitaciones", - "leaderboard": "Tabla de Clasificación", + "leaderboard": "Tabla de Clasificaci\u00f3n", "bank_account": "Cuenta Bancaria", "payments": "Pagos", "timecard": "Tarjeta de Tiempo", @@ -570,14 +570,14 @@ "linked_accounts": "Cuentas Vinculadas", "add_account": "Agregar Cuenta Bancaria", "secure_title": "Seguro y Cifrado", - "secure_subtitle": "Su información bancaria está cifrada y almacenada de forma segura. Nunca compartimos sus detalles.", + "secure_subtitle": "Su informaci\u00f3n bancaria est\u00e1 cifrada y almacenada de forma segura. Nunca compartimos sus detalles.", "add_new_account": "Agregar Nueva Cuenta", "bank_name": "Nombre del Banco", "bank_hint": "Ingrese nombre del banco", - "routing_number": "Número de Ruta", - "routing_hint": "9 dígitos", - "account_number": "Número de Cuenta", - "account_hint": "Ingrese número de cuenta", + "routing_number": "N\u00famero de Ruta", + "routing_hint": "9 d\u00edgitos", + "account_number": "N\u00famero de Cuenta", + "account_hint": "Ingrese n\u00famero de cuenta", "account_type": "Tipo de Cuenta", "checking": "CORRIENTE", "savings": "AHORROS", @@ -585,40 +585,40 @@ "save": "Guardar", "primary": "Principal", "account_ending": "Termina en $last4", - "account_added_success": "¡Cuenta bancaria agregada exitosamente!" + "account_added_success": "\u00a1Cuenta bancaria agregada exitosamente!" }, "logout": { - "button": "Cerrar Sesión" + "button": "Cerrar Sesi\u00f3n" } }, "onboarding": { "personal_info": { - "title": "Información Personal", + "title": "Informaci\u00f3n Personal", "change_photo_hint": "Toca para cambiar foto", "full_name_label": "Nombre Completo", - "email_label": "Correo Electrónico", - "phone_label": "Número de Teléfono", + "email_label": "Correo Electr\u00f3nico", + "phone_label": "N\u00famero de Tel\u00e9fono", "phone_hint": "+1 (555) 000-0000", - "bio_label": "Biografía", - "bio_hint": "Cuéntales a los clientes sobre ti...", + "bio_label": "Biograf\u00eda", + "bio_hint": "Cu\u00e9ntales a los clientes sobre ti...", "languages_label": "Idiomas", - "languages_hint": "Inglés, Español, Francés...", + "languages_hint": "Ingl\u00e9s, Espa\u00f1ol, Franc\u00e9s...", "locations_label": "Ubicaciones Preferidas", "locations_hint": "Centro, Midtown, Brooklyn...", "locations_summary_none": "No configurado", "save_button": "Guardar Cambios", - "save_success": "Información personal guardada exitosamente", + "save_success": "Informaci\u00f3n personal guardada exitosamente", "preferred_locations": { "title": "Ubicaciones Preferidas", - "description": "Elige hasta 5 ubicaciones en los EE.UU. donde prefieres trabajar. Priorizaremos turnos cerca de estas áreas.", - "search_hint": "Buscar una ciudad o área...", + "description": "Elige hasta 5 ubicaciones en los EE.UU. donde prefieres trabajar. Priorizaremos turnos cerca de estas \u00e1reas.", + "search_hint": "Buscar una ciudad o \u00e1rea...", "added_label": "TUS UBICACIONES", - "max_reached": "Has alcanzado el máximo de 5 ubicaciones", - "min_hint": "Agrega al menos 1 ubicación preferida", + "max_reached": "Has alcanzado el m\u00e1ximo de 5 ubicaciones", + "min_hint": "Agrega al menos 1 ubicaci\u00f3n preferida", "save_button": "Guardar Ubicaciones", "save_success": "Ubicaciones preferidas guardadas", - "remove_tooltip": "Eliminar ubicación", - "empty_state": "Aún no has agregado ubicaciones.\nBusca arriba para agregar tus áreas de trabajo preferidas." + "remove_tooltip": "Eliminar ubicaci\u00f3n", + "empty_state": "A\u00fan no has agregado ubicaciones.\nBusca arriba para agregar tus \u00e1reas de trabajo preferidas." } }, "experience": { @@ -626,14 +626,14 @@ "industries_title": "Industrias", "industries_subtitle": "Seleccione las industrias en las que tiene experiencia", "skills_title": "Habilidades", - "skills_subtitle": "Seleccione sus habilidades o añada personalizadas", + "skills_subtitle": "Seleccione sus habilidades o a\u00f1ada personalizadas", "custom_skills_title": "Habilidades personalizadas:", - "custom_skill_hint": "Añadir habilidad...", + "custom_skill_hint": "A\u00f1adir habilidad...", "save_button": "Guardar y continuar", "industries": { - "hospitality": "Hotelería", + "hospitality": "Hoteler\u00eda", "food_service": "Servicio de alimentos", - "warehouse": "Almacén", + "warehouse": "Almac\u00e9n", "events": "Eventos", "retail": "Venta al por menor", "healthcare": "Cuidado de la salud", @@ -643,8 +643,8 @@ "food_service": "Servicio de alimentos", "bartending": "Bartending", "event_setup": "Montaje de eventos", - "hospitality": "Hotelería", - "warehouse": "Almacén", + "hospitality": "Hoteler\u00eda", + "warehouse": "Almac\u00e9n", "customer_service": "Servicio al cliente", "cleaning": "Limpieza", "security": "Seguridad", @@ -653,7 +653,7 @@ "cashier": "Cajero", "server": "Mesero", "barista": "Barista", - "host_hostess": "Anfitrión/Anfitriona", + "host_hostess": "Anfitri\u00f3n/Anfitriona", "busser": "Ayudante de mesero", "driving": "Conducir" } @@ -664,9 +664,9 @@ "your_activity": "Su actividad", "selected_shift_badge": "TURNO SELECCIONADO", "today_shift_badge": "TURNO DE HOY", - "early_title": "¡Ha llegado temprano!", + "early_title": "\u00a1Ha llegado temprano!", "check_in_at": "Entrada disponible a las $time", - "shift_completed": "¡Turno completado!", + "shift_completed": "\u00a1Turno completado!", "great_work": "Buen trabajo hoy", "no_shifts_today": "No hay turnos confirmados para hoy", "accept_shift_cta": "Acepte un turno para registrar su entrada", @@ -677,13 +677,13 @@ "scanned_title": "NFC escaneado", "ready_to_scan": "Listo para escanear", "processing": "Verificando etiqueta...", - "scan_instruction": "Mantenga su teléfono cerca de la etiqueta NFC en el lugar para registrarse.", - "please_wait": "Espere un momento, estamos verificando su ubicación.", + "scan_instruction": "Mantenga su tel\u00e9fono cerca de la etiqueta NFC en el lugar para registrarse.", + "please_wait": "Espere un momento, estamos verificando su ubicaci\u00f3n.", "tap_to_scan": "Tocar para escanear (Simulado)" }, "commute": { - "enable_title": "¿Activar seguimiento de viaje?", - "enable_desc": "Comparta su ubicación 1 hora antes del turno para que su gerente sepa que está en camino.", + "enable_title": "\u00bfActivar seguimiento de viaje?", + "enable_desc": "Comparta su ubicaci\u00f3n 1 hora antes del turno para que su gerente sepa que est\u00e1 en camino.", "not_now": "Ahora no", "enable": "Activar", "on_my_way": "En camino", @@ -693,10 +693,10 @@ "distance_to_site": "Distancia al sitio", "estimated_arrival": "Llegada estimada", "eta_label": "$min min", - "locked_desc": "La mayoría de las funciones de la aplicación están bloqueadas mientras el modo de viaje está activo. Podrá registrar su entrada una vez que llegue.", + "locked_desc": "La mayor\u00eda de las funciones de la aplicaci\u00f3n est\u00e1n bloqueadas mientras el modo de viaje est\u00e1 activo. Podr\u00e1 registrar su entrada una vez que llegue.", "turn_off": "Desactivar modo de viaje", - "arrived_title": "¡Has llegado! 🎉", - "arrived_desc": "Estás en el lugar del turno. ¿Listo para registrar tu entrada?" + "arrived_title": "\u00a1Has llegado! \ud83c\udf89", + "arrived_desc": "Est\u00e1s en el lugar del turno. \u00bfListo para registrar tu entrada?" }, "swipe": { "checking_out": "Registrando salida...", @@ -705,58 +705,58 @@ "nfc_checkin": "NFC Entrada", "swipe_checkout": "Deslizar para registrar salida", "swipe_checkin": "Deslizar para registrar entrada", - "checkout_complete": "¡Salida registrada!", - "checkin_complete": "¡Entrada registrada!" + "checkout_complete": "\u00a1Salida registrada!", + "checkin_complete": "\u00a1Entrada registrada!" }, "lunch_break": { - "title": "¿Tomaste un\nalmuerzo?", + "title": "\u00bfTomaste un\nalmuerzo?", "no": "No", - "yes": "Sí", - "when_title": "¿Cuándo almorzaste?", + "yes": "S\u00ed", + "when_title": "\u00bfCu\u00e1ndo almorzaste?", "start": "Inicio", "end": "Fin", - "why_no_lunch": "¿Por qué no almorzaste?", + "why_no_lunch": "\u00bfPor qu\u00e9 no almorzaste?", "reasons": [ "Flujos de trabajo impredecibles", - "Mala gestión del tiempo", + "Mala gesti\u00f3n del tiempo", "Falta de cobertura o poco personal", - "No hay área de almuerzo", + "No hay \u00e1rea de almuerzo", "Otro (especifique)" ], "additional_notes": "Notas adicionales", - "notes_placeholder": "Añade cualquier detalle...", + "notes_placeholder": "A\u00f1ade cualquier detalle...", "next": "Siguiente", "submit": "Enviar", - "success_title": "¡Descanso registrado!", + "success_title": "\u00a1Descanso registrado!", "close": "Cerrar" } }, "availability": { "title": "Mi disponibilidad", - "quick_set_title": "Establecer disponibilidad rápida", + "quick_set_title": "Establecer disponibilidad r\u00e1pida", "all_week": "Toda la semana", - "weekdays": "Días laborables", + "weekdays": "D\u00edas laborables", "weekends": "Fines de semana", "clear_all": "Borrar todo", - "available_status": "Está disponible", + "available_status": "Est\u00e1 disponible", "not_available_status": "No disponible", "auto_match_title": "Auto-Match usa su disponibilidad", - "auto_match_description": "Cuando esté activado, solo se le asignarán turnos durante sus horarios disponibles." + "auto_match_description": "Cuando est\u00e9 activado, solo se le asignar\u00e1n turnos durante sus horarios disponibles." } }, "staff_compliance": { "tax_forms": { "w4": { "title": "Formulario W-4", - "subtitle": "Certificado de Retención del Empleado", - "submitted_title": "¡Formulario W-4 enviado!", - "submitted_desc": "Su certificado de retención ha sido enviado a su empleador.", + "subtitle": "Certificado de Retenci\u00f3n del Empleado", + "submitted_title": "\u00a1Formulario W-4 enviado!", + "submitted_desc": "Su certificado de retenci\u00f3n ha sido enviado a su empleador.", "back_to_docs": "Volver a Documentos", "step_label": "Paso $current de $total", "steps": { - "personal": "Información Personal", - "filing": "Estado Civil para Efectos de la Declaración", - "multiple_jobs": "Múltiples Trabajos", + "personal": "Informaci\u00f3n Personal", + "filing": "Estado Civil para Efectos de la Declaraci\u00f3n", + "multiple_jobs": "M\u00faltiples Trabajos", "dependents": "Dependientes", "adjustments": "Otros Ajustes", "review": "Revisar y Firmar" @@ -764,56 +764,56 @@ "fields": { "first_name": "Nombre *", "last_name": "Apellido *", - "ssn": "Número de Seguro Social *", - "address": "Dirección *", - "city_state_zip": "Ciudad, Estado, Código Postal", + "ssn": "N\u00famero de Seguro Social *", + "address": "Direcci\u00f3n *", + "city_state_zip": "Ciudad, Estado, C\u00f3digo Postal", "placeholder_john": "Juan", - "placeholder_smith": "Pérez", + "placeholder_smith": "P\u00e9rez", "placeholder_ssn": "XXX-XX-XXXX", "placeholder_address": "Calle Principal 123", - "placeholder_csz": "Ciudad de México, CDMX 01000", - "filing_info": "Su estado civil determina su deducción estándar y tasas de impuestos.", - "single": "Soltero o Casado que presenta la declaración por separado", - "married": "Casado que presenta una declaración conjunta o Cónyuge sobreviviente calificado", + "placeholder_csz": "Ciudad de M\u00e9xico, CDMX 01000", + "filing_info": "Su estado civil determina su deducci\u00f3n est\u00e1ndar y tasas de impuestos.", + "single": "Soltero o Casado que presenta la declaraci\u00f3n por separado", + "married": "Casado que presenta una declaraci\u00f3n conjunta o C\u00f3nyuge sobreviviente calificado", "head": "Jefe de familia", - "head_desc": "Marque solo si es soltero y paga más de la mitad de los costos de mantenimiento de un hogar", - "multiple_jobs_title": "¿Cuándo completar este paso?", - "multiple_jobs_desc": "Complete este paso solo si tiene más de un trabajo a la vez, o si está casado y presenta una declaración conjunta y su cónyuge también trabaja.", - "multiple_jobs_check": "Tengo múltiples trabajos o mi cónyuge trabaja", + "head_desc": "Marque solo si es soltero y paga m\u00e1s de la mitad de los costos de mantenimiento de un hogar", + "multiple_jobs_title": "\u00bfCu\u00e1ndo completar este paso?", + "multiple_jobs_desc": "Complete este paso solo si tiene m\u00e1s de un trabajo a la vez, o si est\u00e1 casado y presenta una declaraci\u00f3n conjunta y su c\u00f3nyuge tambi\u00e9n trabaja.", + "multiple_jobs_check": "Tengo m\u00faltiples trabajos o mi c\u00f3nyuge trabaja", "two_jobs_desc": "Marque esta casilla si solo hay dos trabajos en total", "multiple_jobs_not_apply": "Si esto no se aplica, puede continuar al siguiente paso", - "dependents_info": "Si su ingreso total será de $ 200,000 o menos ($ 400,000 si está casado y presenta una declaración conjunta), puede reclamar créditos por dependientes.", - "children_under_17": "Hijos calificados menores de 17 años", + "dependents_info": "Si su ingreso total ser\u00e1 de $ 200,000 o menos ($ 400,000 si est\u00e1 casado y presenta una declaraci\u00f3n conjunta), puede reclamar cr\u00e9ditos por dependientes.", + "children_under_17": "Hijos calificados menores de 17 a\u00f1os", "children_each": "$ 2,000 cada uno", "other_dependents": "Otros dependientes", "other_each": "$ 500 cada uno", - "total_credits": "Créditos totales (Paso 3)", + "total_credits": "Cr\u00e9ditos totales (Paso 3)", "adjustments_info": "Estos ajustes son opcionales. Puede omitirlos si no se aplican.", "other_income": "4(a) Otros ingresos (no provenientes de trabajos)", - "other_income_desc": "Incluya intereses, dividendos, ingresos de jubilación", + "other_income_desc": "Incluya intereses, dividendos, ingresos de jubilaci\u00f3n", "deductions": "4(b) Deducciones", - "deductions_desc": "Si espera reclamar deducciones distintas de la deducción estándar", - "extra_withholding": "4(c) Retención adicional", - "extra_withholding_desc": "Cualquier impuesto adicional que desee que se le retenga en cada período de pago", + "deductions_desc": "Si espera reclamar deducciones distintas de la deducci\u00f3n est\u00e1ndar", + "extra_withholding": "4(c) Retenci\u00f3n adicional", + "extra_withholding_desc": "Cualquier impuesto adicional que desee que se le retenga en cada per\u00edodo de pago", "summary_title": "Su Resumen de W-4", "summary_name": "Nombre", "summary_ssn": "SSN", "summary_filing": "Estado Civil", - "summary_credits": "Créditos", - "perjury_declaration": "Bajo pena de perjurio, declaro que este certificado, según mi leal saber y entender, es verdadero, correcto y completo.", + "summary_credits": "Cr\u00e9ditos", + "perjury_declaration": "Bajo pena de perjurio, declaro que este certificado, seg\u00fan mi leal saber y entender, es verdadero, correcto y completo.", "signature_label": "Firma (escriba su nombre completo) *", "signature_hint": "Escriba su nombre completo", "date_label": "Fecha", "status_single": "Soltero/a", "status_married": "Casado/a", "status_head": "Cabeza de familia", - "back": "Atrás", + "back": "Atr\u00e1s", "continue": "Continuar", "submit": "Enviar Formulario", "step_counter": "Paso {current} de {total}", "hints": { "first_name": "Juan", - "last_name": "Pérez", + "last_name": "P\u00e9rez", "ssn": "XXX-XX-XXXX", "zero": "$ 0", "email": "juan.perez@ejemplo.com", @@ -823,22 +823,22 @@ }, "i9": { "title": "Formulario I-9", - "subtitle": "Verificación de Elegibilidad de Empleo", - "submitted_title": "¡Formulario I-9 enviado!", - "submitted_desc": "Su verificación de elegibilidad de empleo ha sido enviada.", - "back": "Atrás", + "subtitle": "Verificaci\u00f3n de Elegibilidad de Empleo", + "submitted_title": "\u00a1Formulario I-9 enviado!", + "submitted_desc": "Su verificaci\u00f3n de elegibilidad de empleo ha sido enviada.", + "back": "Atr\u00e1s", "continue": "Continuar", "submit": "Enviar Formulario", "step_label": "Paso $current de $total", "steps": { - "personal": "Información Personal", + "personal": "Informaci\u00f3n Personal", "personal_sub": "Nombre y detalles de contacto", - "address": "Dirección", - "address_sub": "Su dirección actual", - "citizenship": "Estado de Ciudadanía", - "citizenship_sub": "Verificación de autorización de trabajo", + "address": "Direcci\u00f3n", + "address_sub": "Su direcci\u00f3n actual", + "citizenship": "Estado de Ciudadan\u00eda", + "citizenship_sub": "Verificaci\u00f3n de autorizaci\u00f3n de trabajo", "review": "Revisar y Firmar", - "review_sub": "Confirme su información" + "review_sub": "Confirme su informaci\u00f3n" }, "fields": { "first_name": "Nombre *", @@ -847,41 +847,41 @@ "other_last_names": "Otros apellidos", "maiden_name": "Apellido de soltera (si hay)", "dob": "Fecha de Nacimiento *", - "ssn": "Número de Seguro Social *", - "email": "Correo electrónico", - "phone": "Número de teléfono", - "address_long": "Dirección (Número y nombre de la calle) *", - "apt": "Núm. de apartamento", + "ssn": "N\u00famero de Seguro Social *", + "email": "Correo electr\u00f3nico", + "phone": "N\u00famero de tel\u00e9fono", + "address_long": "Direcci\u00f3n (N\u00famero y nombre de la calle) *", + "apt": "N\u00fam. de apartamento", "city": "Ciudad o Pueblo *", "state": "Estado *", - "zip": "Código Postal *", + "zip": "C\u00f3digo Postal *", "attestation": "Doy fe, bajo pena de perjurio, de que soy (marque una de las siguientes casillas):", "citizen": "1. Ciudadano de los Estados Unidos", "noncitizen": "2. Nacional no ciudadano de los Estados Unidos", "permanent_resident": "3. Residente permanente legal", - "uscis_number_label": "Número USCIS", + "uscis_number_label": "N\u00famero USCIS", "alien": "4. Un extranjero autorizado para trabajar", - "admission_number": "Número USCIS/Admisión", - "passport": "Número de pasaporte extranjero", - "country": "País de emisión", + "admission_number": "N\u00famero USCIS/Admisi\u00f3n", + "passport": "N\u00famero de pasaporte extranjero", + "country": "Pa\u00eds de emisi\u00f3n", "summary_title": "Resumen", "summary_name": "Nombre", - "summary_address": "Dirección", + "summary_address": "Direcci\u00f3n", "summary_ssn": "SSN", - "summary_citizenship": "Ciudadanía", + "summary_citizenship": "Ciudadan\u00eda", "status_us_citizen": "Ciudadano de los EE. UU.", "status_noncitizen": "Nacional no ciudadano", "status_permanent_resident": "Residente permanente", "status_alien": "Extranjero autorizado para trabajar", "status_unknown": "Desconocido", - "preparer": "Utilicé un preparador o traductor", - "warning": "Soy consciente de que la ley federal prevé penas de prisión y/o multas por declaraciones falsas o uso de documentos falsos en relación con la cumplimentación de este formulario.", + "preparer": "Utilic\u00e9 un preparador o traductor", + "warning": "Soy consciente de que la ley federal prev\u00e9 penas de prisi\u00f3n y/o multas por declaraciones falsas o uso de documentos falsos en relaci\u00f3n con la cumplimentaci\u00f3n de este formulario.", "signature_label": "Firma (escriba su nombre completo) *", "signature_hint": "Escriba su nombre completo", "date_label": "Fecha", "hints": { "first_name": "Juan", - "last_name": "Pérez", + "last_name": "P\u00e9rez", "middle_initial": "J", "dob": "MM/DD/YYYY", "ssn": "XXX-XX-XXXX", @@ -900,7 +900,7 @@ "staff_documents": { "title": "Documentos", "verification_card": { - "title": "Verificación de Documentos", + "title": "Verificaci\u00f3n de Documentos", "progress": "$completed/$total Completado" }, "list": { @@ -925,16 +925,16 @@ "active": "Cumplimiento Activo" }, "card": { - "expires_in_days": "Expira en $days días - Renovar ahora", + "expires_in_days": "Expira en $days d\u00edas - Renovar ahora", "expired": "Expirado - Renovar ahora", "verified": "Verificado", "expiring_soon": "Expira Pronto", "exp": "Exp: $date", "upload_button": "Subir Certificado", - "edit_expiry": "Editar Fecha de Expiración", + "edit_expiry": "Editar Fecha de Expiraci\u00f3n", "remove": "Eliminar Certificado", "renew": "Renovar", - "opened_snackbar": "Certificado abierto en nueva pestaña" + "opened_snackbar": "Certificado abierto en nueva pesta\u00f1a" }, "add_more": { "title": "Agregar Otro Certificado", @@ -942,7 +942,7 @@ }, "upload_modal": { "title": "Subir Certificado", - "expiry_label": "Fecha de Expiración (Opcional)", + "expiry_label": "Fecha de Expiraci\u00f3n (Opcional)", "select_date": "Seleccionar fecha", "upload_file": "Subir Archivo", "drag_drop": "Arrastra y suelta o haz clic para subir", @@ -951,8 +951,8 @@ "save": "Guardar Certificado" }, "delete_modal": { - "title": "¿Eliminar Certificado?", - "message": "Esta acción no se puede deshacer.", + "title": "\u00bfEliminar Certificado?", + "message": "Esta acci\u00f3n no se puede deshacer.", "cancel": "Cancelar", "confirm": "Eliminar" } @@ -961,22 +961,22 @@ "title": "Vestimenta", "info_card": { "title": "Tu Vestuario", - "description": "Selecciona los artículos de vestimenta que posees. Esto nos ayuda a asignarte turnos que se ajusten a tu vestuario." + "description": "Selecciona los art\u00edculos de vestimenta que posees. Esto nos ayuda a asignarte turnos que se ajusten a tu vestuario." }, "status": { "required": "REQUERIDO", - "add_photo": "Añadir Foto", - "added": "Añadido", - "pending": "⏳ Verificación pendiente" + "add_photo": "A\u00f1adir Foto", + "added": "A\u00f1adido", + "pending": "\u23f3 Verificaci\u00f3n pendiente" }, - "attestation": "Certifico que poseo estos artículos y los usaré en mis turnos. Entiendo que los artículos están pendientes de verificación por el gerente en mi primer turno.", + "attestation": "Certifico que poseo estos art\u00edculos y los usar\u00e9 en mis turnos. Entiendo que los art\u00edculos est\u00e1n pendientes de verificaci\u00f3n por el gerente en mi primer turno.", "actions": { "save": "Guardar Vestimenta" }, "validation": { - "select_required": "✓ Seleccionar todos los artículos requeridos", - "upload_required": "✓ Subir fotos de artículos requeridos", - "accept_attestation": "✓ Aceptar certificación" + "select_required": "\u2713 Seleccionar todos los art\u00edculos requeridos", + "upload_required": "\u2713 Subir fotos de art\u00edculos requeridos", + "accept_attestation": "\u2713 Aceptar certificaci\u00f3n" } }, "staff_shifts": { @@ -994,17 +994,17 @@ }, "filter": { "all": "Todos los Empleos", - "one_day": "Un Día", - "multi_day": "Multidía", + "one_day": "Un D\u00eda", + "multi_day": "Multid\u00eda", "long_term": "Largo Plazo" }, "status": { "confirmed": "CONFIRMADO", - "act_now": "ACTÚA AHORA", + "act_now": "ACT\u00daA AHORA", "swap_requested": "INTERCAMBIO SOLICITADO", "completed": "COMPLETADO", - "no_show": "NO ASISTIÓ", - "pending_warning": "Por favor confirma la asignación" + "no_show": "NO ASISTI\u00d3", + "pending_warning": "Por favor confirma la asignaci\u00f3n" }, "action": { "decline": "Rechazar", @@ -1013,7 +1013,7 @@ }, "details": { "additional": "DETALLES ADICIONALES", - "days": "$days Días", + "days": "$days D\u00edas", "exp_total": "(total est. \\$$amount)", "pending_time": "Pendiente hace $time" }, @@ -1028,12 +1028,12 @@ "start_time": "HORA DE INICIO", "end_time": "HORA DE FIN", "base_rate": "Tarifa base", - "duration": "Duración", + "duration": "Duraci\u00f3n", "est_total": "Total est.", "hours_label": "$count horas", - "location": "UBICACIÓN", + "location": "UBICACI\u00d3N", "tbd": "TBD", - "get_direction": "Obtener dirección", + "get_direction": "Obtener direcci\u00f3n", "break_title": "DESCANSO", "paid": "Pagado", "unpaid": "No pagado", @@ -1041,7 +1041,7 @@ "hourly_rate": "Tarifa por hora", "hours": "Horas", "open_in_maps": "Abrir en Mapas", - "job_description": "DESCRIPCIÓN DEL TRABAJO", + "job_description": "DESCRIPCI\u00d3N DEL TRABAJO", "cancel_shift": "CANCELAR TURNO", "clock_in": "ENTRADA", "decline": "RECHAZAR", @@ -1049,22 +1049,22 @@ "apply_now": "SOLICITAR AHORA", "book_dialog": { "title": "Reservar turno", - "message": "¿Desea reservar este turno al instante?" + "message": "\u00bfDesea reservar este turno al instante?" }, "decline_dialog": { "title": "Rechazar turno", - "message": "¿Está seguro de que desea rechazar este turno? Se ocultará de sus trabajos disponibles." + "message": "\u00bfEst\u00e1 seguro de que desea rechazar este turno? Se ocultar\u00e1 de sus trabajos disponibles." }, "cancel_dialog": { "title": "Cancelar turno", - "message": "¿Está seguro de que desea cancelar este turno?" + "message": "\u00bfEst\u00e1 seguro de que desea cancelar este turno?" }, "applying_dialog": { "title": "Solicitando" } }, "card": { - "just_now": "Recién", + "just_now": "Reci\u00e9n", "assigned": "Asignado hace $time", "accept_shift": "Aceptar turno", "decline_shift": "Rechazar turno" @@ -1072,31 +1072,41 @@ "my_shifts_tab": { "confirm_dialog": { "title": "Aceptar Turno", - "message": "¿Estás seguro de que quieres aceptar este turno?", - "success": "¡Turno confirmado!" + "message": "\u00bfEst\u00e1s seguro de que quieres aceptar este turno?", + "success": "\u00a1Turno confirmado!" }, "decline_dialog": { "title": "Rechazar Turno", - "message": "¿Estás seguro de que quieres rechazar este turno? Esta acción no se puede deshacer.", + "message": "\u00bfEst\u00e1s seguro de que quieres rechazar este turno? Esta acci\u00f3n no se puede deshacer.", "success": "Turno rechazado." }, "sections": { - "awaiting": "Esperando Confirmación", + "awaiting": "Esperando Confirmaci\u00f3n", "cancelled": "Turnos Cancelados", "confirmed": "Turnos Confirmados" }, "empty": { "title": "Sin turnos esta semana", - "subtitle": "Intenta buscar nuevos trabajos en la pestaña Buscar" + "subtitle": "Intenta buscar nuevos trabajos en la pesta\u00f1a Buscar" }, "date": { "today": "Hoy", - "tomorrow": "Mañana" + "tomorrow": "Ma\u00f1ana" }, "card": { "cancelled": "CANCELADO", - "compensation": "• Compensación de 4h" + "compensation": "\u2022 Compensaci\u00f3n de 4h" } + }, + "find_shifts": { + "search_hint": "Buscar trabajos, ubicaci\u00f3n...", + "filter_all": "Todos", + "filter_one_day": "Un d\u00eda", + "filter_multi_day": "Varios d\u00edas", + "filter_long_term": "Largo plazo", + "no_jobs_title": "No hay trabajos disponibles", + "no_jobs_subtitle": "Vuelve m\u00e1s tarde", + "application_submitted": "\u00a1Solicitud de turno enviada!" } }, "staff_time_card": { @@ -1116,34 +1126,34 @@ }, "errors": { "auth": { - "invalid_credentials": "El correo electrónico o la contraseña que ingresaste es incorrecta.", - "account_exists": "Ya existe una cuenta con este correo electrónico. Intenta iniciar sesión.", - "session_expired": "Tu sesión ha expirado. Por favor, inicia sesión de nuevo.", - "user_not_found": "No pudimos encontrar tu cuenta. Por favor, verifica tu correo electrónico e intenta de nuevo.", - "unauthorized_app": "Esta cuenta no está autorizada para esta aplicación.", - "weak_password": "Por favor, elige una contraseña más segura con al menos 8 caracteres.", + "invalid_credentials": "El correo electr\u00f3nico o la contrase\u00f1a que ingresaste es incorrecta.", + "account_exists": "Ya existe una cuenta con este correo electr\u00f3nico. Intenta iniciar sesi\u00f3n.", + "session_expired": "Tu sesi\u00f3n ha expirado. Por favor, inicia sesi\u00f3n de nuevo.", + "user_not_found": "No pudimos encontrar tu cuenta. Por favor, verifica tu correo electr\u00f3nico e intenta de nuevo.", + "unauthorized_app": "Esta cuenta no est\u00e1 autorizada para esta aplicaci\u00f3n.", + "weak_password": "Por favor, elige una contrase\u00f1a m\u00e1s segura con al menos 8 caracteres.", "sign_up_failed": "No pudimos crear tu cuenta. Por favor, intenta de nuevo.", - "sign_in_failed": "No pudimos iniciar sesión. Por favor, intenta de nuevo.", - "not_authenticated": "Por favor, inicia sesión para continuar.", - "passwords_dont_match": "Las contraseñas no coinciden", - "password_mismatch": "Este correo ya está registrado. Por favor, usa la contraseña correcta o toca 'Olvidé mi contraseña' para restablecerla.", - "google_only_account": "Este correo está registrado con Google. Por favor, usa 'Olvidé mi contraseña' para establecer una contraseña, luego intenta registrarte de nuevo con la misma información." + "sign_in_failed": "No pudimos iniciar sesi\u00f3n. Por favor, intenta de nuevo.", + "not_authenticated": "Por favor, inicia sesi\u00f3n para continuar.", + "passwords_dont_match": "Las contrase\u00f1as no coinciden", + "password_mismatch": "Este correo ya est\u00e1 registrado. Por favor, usa la contrase\u00f1a correcta o toca 'Olvid\u00e9 mi contrase\u00f1a' para restablecerla.", + "google_only_account": "Este correo est\u00e1 registrado con Google. Por favor, usa 'Olvid\u00e9 mi contrase\u00f1a' para establecer una contrase\u00f1a, luego intenta registrarte de nuevo con la misma informaci\u00f3n." }, "hub": { - "has_orders": "Este hub tiene órdenes activas y no puede ser eliminado.", + "has_orders": "Este hub tiene \u00f3rdenes activas y no puede ser eliminado.", "not_found": "El hub que buscas no existe.", "creation_failed": "No pudimos crear el hub. Por favor, intenta de nuevo." }, "order": { - "missing_hub": "Por favor, selecciona una ubicación para tu orden.", + "missing_hub": "Por favor, selecciona una ubicaci\u00f3n para tu orden.", "missing_vendor": "Por favor, selecciona un proveedor para tu orden.", "creation_failed": "No pudimos crear tu orden. Por favor, intenta de nuevo.", "shift_creation_failed": "No pudimos programar el turno. Por favor, intenta de nuevo.", - "missing_business": "No se pudo cargar tu perfil de empresa. Por favor, inicia sesión de nuevo." + "missing_business": "No se pudo cargar tu perfil de empresa. Por favor, inicia sesi\u00f3n de nuevo." }, "profile": { - "staff_not_found": "No se pudo cargar tu perfil. Por favor, inicia sesión de nuevo.", - "business_not_found": "No se pudo cargar tu perfil de empresa. Por favor, inicia sesión de nuevo.", + "staff_not_found": "No se pudo cargar tu perfil. Por favor, inicia sesi\u00f3n de nuevo.", + "business_not_found": "No se pudo cargar tu perfil de empresa. Por favor, inicia sesi\u00f3n de nuevo.", "update_failed": "No pudimos actualizar tu perfil. Por favor, intenta de nuevo." }, "shift": { @@ -1152,10 +1162,10 @@ "no_active_shift": "No tienes un turno activo para registrar salida." }, "generic": { - "unknown": "Algo salió mal. Por favor, intenta de nuevo.", - "no_connection": "Sin conexión a internet. Por favor, verifica tu red e intenta de nuevo.", - "server_error": "Error del servidor. Inténtalo de nuevo más tarde.", - "service_unavailable": "El servicio no está disponible actualmente." + "unknown": "Algo sali\u00f3 mal. Por favor, intenta de nuevo.", + "no_connection": "Sin conexi\u00f3n a internet. Por favor, verifica tu red e intenta de nuevo.", + "server_error": "Error del servidor. Int\u00e9ntalo de nuevo m\u00e1s tarde.", + "service_unavailable": "El servicio no est\u00e1 disponible actualmente." } }, "staff_privacy_security": { @@ -1167,13 +1177,13 @@ "subtitle": "Deja que los clientes vean tu perfil" }, "terms_of_service": { - "title": "Términos de Servicio" + "title": "T\u00e9rminos de Servicio" }, "privacy_policy": { - "title": "Política de Privacidad" + "title": "Pol\u00edtica de Privacidad" }, "success": { - "profile_visibility_updated": "¡Visibilidad del perfil actualizada exitosamente!" + "profile_visibility_updated": "\u00a1Visibilidad del perfil actualizada exitosamente!" } }, "staff_faqs": { @@ -1184,19 +1194,19 @@ }, "success": { "hub": { - "created": "¡Hub creado exitosamente!", - "updated": "¡Hub actualizado exitosamente!", - "deleted": "¡Hub eliminado exitosamente!", - "nfc_assigned": "¡Etiqueta NFC asignada exitosamente!" + "created": "\u00a1Hub creado exitosamente!", + "updated": "\u00a1Hub actualizado exitosamente!", + "deleted": "\u00a1Hub eliminado exitosamente!", + "nfc_assigned": "\u00a1Etiqueta NFC asignada exitosamente!" }, "order": { - "created": "¡Orden creada exitosamente!" + "created": "\u00a1Orden creada exitosamente!" }, "profile": { - "updated": "¡Perfil actualizado con éxito!" + "updated": "\u00a1Perfil actualizado con \u00e9xito!" }, "availability": { - "updated": "Disponibilidad actualizada con éxito" + "updated": "Disponibilidad actualizada con \u00e9xito" } }, "client_reports": { @@ -1210,7 +1220,7 @@ "metrics": { "total_hrs": { "label": "Total de Horas", - "badge": "Este período" + "badge": "Este per\u00edodo" }, "ot_hours": { "label": "Horas Extra", @@ -1218,11 +1228,11 @@ }, "total_spend": { "label": "Gasto Total", - "badge": "↓ 8% vs semana pasada" + "badge": "\u2193 8% vs semana pasada" }, "fill_rate": { "label": "Tasa de Cobertura", - "badge": "↑ 2% de mejora" + "badge": "\u2191 2% de mejora" }, "avg_fill_time": { "label": "Tiempo Promedio de Llenado", @@ -1234,15 +1244,15 @@ } }, "quick_reports": { - "title": "Informes Rápidos", + "title": "Informes R\u00e1pidos", "export_all": "Exportar Todo", - "two_click_export": "Exportación en 2 clics", + "two_click_export": "Exportaci\u00f3n en 2 clics", "cards": { "daily_ops": "Informe de Ops Diarias", "spend": "Informe de Gastos", "coverage": "Informe de Cobertura", "no_show": "Informe de Faltas", - "forecast": "Informe de Previsión", + "forecast": "Informe de Previsi\u00f3n", "performance": "Informe de Rendimiento" } }, @@ -1281,45 +1291,45 @@ "completed": "Completado" }, "placeholders": { - "export_message": "Exportando Informe de Ops Diarias (Marcador de posición)" + "export_message": "Exportando Informe de Ops Diarias (Marcador de posici\u00f3n)" } }, "spend_report": { "title": "Informe de Gastos", - "subtitle": "Análisis y desglose de costos", + "subtitle": "An\u00e1lisis y desglose de costos", "summary": { "total_spend": "Gasto Total", "avg_daily": "Promedio Diario", "this_week": "Esta semana", - "per_day": "Por día" + "per_day": "Por d\u00eda" }, "chart_title": "Tendencia de Gasto Diario", "charts": { "mon": "Lun", "tue": "Mar", - "wed": "Mié", + "wed": "Mi\u00e9", "thu": "Jue", "fri": "Vie", - "sat": "Sáb", + "sat": "S\u00e1b", "sun": "Dom" }, "spend_by_industry": "Gasto por Industria", "industries": { - "hospitality": "Hostelería", + "hospitality": "Hosteler\u00eda", "events": "Eventos", "retail": "Venta minorista" }, "percent_total": "$percent% del total", "no_industry_data": "No hay datos de la industria disponibles", "placeholders": { - "export_message": "Exportando Informe de Gastos (Marcador de posición)" + "export_message": "Exportando Informe de Gastos (Marcador de posici\u00f3n)" } }, "forecast_report": { - "title": "Informe de Previsión", - "subtitle": "Proyección próximas 4 semanas", + "title": "Informe de Previsi\u00f3n", + "subtitle": "Proyecci\u00f3n pr\u00f3ximas 4 semanas", "metrics": { - "four_week_forecast": "Previsión 4 Semanas", + "four_week_forecast": "Previsi\u00f3n 4 Semanas", "avg_weekly": "Promedio Semanal", "total_shifts": "Total de Turnos", "total_hours": "Total de Horas" @@ -1330,7 +1340,7 @@ "scheduled": "Programado", "worker_hours": "Horas de trabajo" }, - "chart_title": "Previsión de Gastos", + "chart_title": "Previsi\u00f3n de Gastos", "weekly_breakdown": { "title": "DESGLOSE SEMANAL", "week": "Semana $index", @@ -1343,14 +1353,14 @@ }, "empty_state": "No hay proyecciones disponibles", "placeholders": { - "export_message": "Exportando Informe de Previsión (Marcador de posición)" + "export_message": "Exportando Informe de Previsi\u00f3n (Marcador de posici\u00f3n)" } }, "performance_report": { "title": "Informe de Rendimiento", - "subtitle": "Métricas clave y comparativas", + "subtitle": "M\u00e9tricas clave y comparativas", "overall_score": { - "title": "Puntuación de Rendimiento General", + "title": "Puntuaci\u00f3n de Rendimiento General", "excellent": "Excelente", "good": "Bueno", "needs_work": "Necesita Mejorar" @@ -1358,25 +1368,25 @@ "kpis_title": "INDICADORES CLAVE DE RENDIMIENTO (KPI)", "kpis": { "fill_rate": "Tasa de Llenado", - "completion_rate": "Tasa de Finalización", + "completion_rate": "Tasa de Finalizaci\u00f3n", "on_time_rate": "Tasa de Puntualidad", "avg_fill_time": "Tiempo Promedio de Llenado", "target_prefix": "Objetivo: ", "target_hours": "$hours hrs", "target_percent": "$percent%", - "met": "✓ Cumplido", - "close": "→ Cerca", - "miss": "✗ Fallido" + "met": "\u2713 Cumplido", + "close": "\u2192 Cerca", + "miss": "\u2717 Fallido" }, - "additional_metrics_title": "MÉTRICAS ADICIONALES", + "additional_metrics_title": "M\u00c9TRICAS ADICIONALES", "additional_metrics": { "total_shifts": "Total de Turnos", "no_show_rate": "Tasa de Faltas", "worker_pool": "Grupo de Trabajadores", - "avg_rating": "Calificación Promedio" + "avg_rating": "Calificaci\u00f3n Promedio" }, "placeholders": { - "export_message": "Exportando Informe de Rendimiento (Marcador de posición)" + "export_message": "Exportando Informe de Rendimiento (Marcador de posici\u00f3n)" } }, "no_show_report": { @@ -1389,15 +1399,15 @@ }, "workers_list_title": "TRABAJADORES CON FALTAS", "no_show_count": "$count falta(s)", - "latest_incident": "Último incidente", + "latest_incident": "\u00daltimo incidente", "risks": { "high": "Riesgo Alto", "medium": "Riesgo Medio", "low": "Riesgo Bajo" }, - "empty_state": "No hay trabajadores señalados por faltas", + "empty_state": "No hay trabajadores se\u00f1alados por faltas", "placeholders": { - "export_message": "Exportando Informe de Faltas (Marcador de posición)" + "export_message": "Exportando Informe de Faltas (Marcador de posici\u00f3n)" } }, "coverage_report": { @@ -1408,7 +1418,7 @@ "full": "Completa", "needs_help": "Necesita Ayuda" }, - "next_7_days": "PRÓXIMOS 7 DÍAS", + "next_7_days": "PR\u00d3XIMOS 7 D\u00cdAS", "empty_state": "No hay turnos programados", "shift_item": { "confirmed_workers": "$confirmed/$needed trabajadores confirmados", @@ -1417,7 +1427,7 @@ "fully_staffed": "Totalmente cubierto" }, "placeholders": { - "export_message": "Exportando Informe de Cobertura (Marcador de posición)" + "export_message": "Exportando Informe de Cobertura (Marcador de posici\u00f3n)" } } } diff --git a/apps/mobile/packages/data_connect/lib/krow_data_connect.dart b/apps/mobile/packages/data_connect/lib/krow_data_connect.dart index 55d3782b..378eb395 100644 --- a/apps/mobile/packages/data_connect/lib/krow_data_connect.dart +++ b/apps/mobile/packages/data_connect/lib/krow_data_connect.dart @@ -6,7 +6,6 @@ /// They will implement interfaces defined in feature packages once those are created. library; - export 'src/data_connect_module.dart'; export 'src/session/client_session_store.dart'; @@ -45,10 +44,6 @@ export 'src/connectors/hubs/data/repositories/hubs_connector_repository_impl.dar export 'src/connectors/billing/domain/repositories/billing_connector_repository.dart'; export 'src/connectors/billing/data/repositories/billing_connector_repository_impl.dart'; -// Export Home Connector -export 'src/connectors/home/domain/repositories/home_connector_repository.dart'; -export 'src/connectors/home/data/repositories/home_connector_repository_impl.dart'; - // Export Coverage Connector export 'src/connectors/coverage/domain/repositories/coverage_connector_repository.dart'; -export 'src/connectors/coverage/data/repositories/coverage_connector_repository_impl.dart'; \ No newline at end of file +export 'src/connectors/coverage/data/repositories/coverage_connector_repository_impl.dart'; diff --git a/apps/mobile/packages/data_connect/lib/src/connectors/home/data/repositories/home_connector_repository_impl.dart b/apps/mobile/packages/data_connect/lib/src/connectors/home/data/repositories/home_connector_repository_impl.dart deleted file mode 100644 index 906e39e9..00000000 --- a/apps/mobile/packages/data_connect/lib/src/connectors/home/data/repositories/home_connector_repository_impl.dart +++ /dev/null @@ -1,113 +0,0 @@ -// ignore_for_file: always_specify_types, depend_on_referenced_packages, dead_code, dead_null_aware_expression, unused_local_variable, unused_import, sort_constructors_first, prefer_final_fields, prefer_const_constructors, deprecated_member_use, implicit_call_tearoffs -import 'package:firebase_data_connect/src/core/ref.dart'; -import 'package:krow_data_connect/krow_data_connect.dart' as dc; -import 'package:krow_domain/krow_domain.dart'; -import '../../domain/repositories/home_connector_repository.dart'; - -/// Implementation of [HomeConnectorRepository]. -class HomeConnectorRepositoryImpl implements HomeConnectorRepository { - HomeConnectorRepositoryImpl({ - dc.DataConnectService? service, - }) : _service = service ?? dc.DataConnectService.instance; - - final dc.DataConnectService _service; - - @override - Future getDashboardData({required String businessId}) async { - return _service.run(() async { - final DateTime now = DateTime.now(); - final int daysFromMonday = now.weekday - DateTime.monday; - final DateTime monday = DateTime(now.year, now.month, now.day).subtract(Duration(days: daysFromMonday)); - final DateTime weekRangeStart = monday; - final DateTime weekRangeEnd = monday.add(const Duration(days: 13, hours: 23, minutes: 59, seconds: 59)); - - final QueryResult completedResult = await _service.connector - .getCompletedShiftsByBusinessId( - businessId: businessId, - dateFrom: _service.toTimestamp(weekRangeStart), - dateTo: _service.toTimestamp(weekRangeEnd), - ) - .execute(); - - double weeklySpending = 0.0; - double next7DaysSpending = 0.0; - int weeklyShifts = 0; - int next7DaysScheduled = 0; - - for (final dc.GetCompletedShiftsByBusinessIdShifts shift in completedResult.data.shifts) { - final DateTime? shiftDate = _service.toDateTime(shift.date); - if (shiftDate == null) continue; - - final int offset = shiftDate.difference(weekRangeStart).inDays; - if (offset < 0 || offset > 13) continue; - - final double cost = shift.cost ?? 0.0; - if (offset <= 6) { - weeklySpending += cost; - weeklyShifts += 1; - } else { - next7DaysSpending += cost; - next7DaysScheduled += 1; - } - } - - final DateTime start = DateTime(now.year, now.month, now.day); - final DateTime end = start.add(const Duration(hours: 23, minutes: 59, seconds: 59)); - - final QueryResult result = await _service.connector - .listShiftRolesByBusinessAndDateRange( - businessId: businessId, - start: _service.toTimestamp(start), - end: _service.toTimestamp(end), - ) - .execute(); - - int totalNeeded = 0; - int totalFilled = 0; - for (final dc.ListShiftRolesByBusinessAndDateRangeShiftRoles shiftRole in result.data.shiftRoles) { - totalNeeded += shiftRole.count; - totalFilled += shiftRole.assigned ?? 0; - } - - return HomeDashboardData( - weeklySpending: weeklySpending, - next7DaysSpending: next7DaysSpending, - weeklyShifts: weeklyShifts, - next7DaysScheduled: next7DaysScheduled, - totalNeeded: totalNeeded, - totalFilled: totalFilled, - ); - }); - } - - @override - Future> getRecentReorders({required String businessId}) async { - return _service.run(() async { - final DateTime now = DateTime.now(); - final DateTime start = now.subtract(const Duration(days: 30)); - - final QueryResult result = await _service.connector - .listShiftRolesByBusinessDateRangeCompletedOrders( - businessId: businessId, - start: _service.toTimestamp(start), - end: _service.toTimestamp(now), - ) - .execute(); - - return result.data.shiftRoles.map((dc.ListShiftRolesByBusinessDateRangeCompletedOrdersShiftRoles shiftRole) { - final String location = shiftRole.shift.location ?? shiftRole.shift.locationAddress ?? ''; - final String type = shiftRole.shift.order.orderType.stringValue; - return ReorderItem( - orderId: shiftRole.shift.order.id, - title: '${shiftRole.role.name} - ${shiftRole.shift.title}', - location: location, - hourlyRate: shiftRole.role.costPerHour, - hours: shiftRole.hours ?? 0, - workers: shiftRole.count, - type: type, - ); - }).toList(); - }); - } -} - diff --git a/apps/mobile/packages/data_connect/lib/src/connectors/home/domain/repositories/home_connector_repository.dart b/apps/mobile/packages/data_connect/lib/src/connectors/home/domain/repositories/home_connector_repository.dart deleted file mode 100644 index 365c09b4..00000000 --- a/apps/mobile/packages/data_connect/lib/src/connectors/home/domain/repositories/home_connector_repository.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:krow_domain/krow_domain.dart'; - -/// Repository interface for home connector operations. -/// -/// This acts as a buffer layer between the domain repository and the Data Connect SDK. -abstract interface class HomeConnectorRepository { - /// Fetches dashboard data for a business. - Future getDashboardData({required String businessId}); - - /// Fetches recent reorder items for a business. - Future> getRecentReorders({required String businessId}); -} diff --git a/apps/mobile/packages/data_connect/lib/src/connectors/shifts/data/repositories/shifts_connector_repository_impl.dart b/apps/mobile/packages/data_connect/lib/src/connectors/shifts/data/repositories/shifts_connector_repository_impl.dart index 6877f1d2..cb760a6f 100644 --- a/apps/mobile/packages/data_connect/lib/src/connectors/shifts/data/repositories/shifts_connector_repository_impl.dart +++ b/apps/mobile/packages/data_connect/lib/src/connectors/shifts/data/repositories/shifts_connector_repository_impl.dart @@ -10,9 +10,8 @@ import '../../domain/repositories/shifts_connector_repository.dart'; /// Handles shift-related data operations by interacting with Data Connect. class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { /// Creates a new [ShiftsConnectorRepositoryImpl]. - ShiftsConnectorRepositoryImpl({ - dc.DataConnectService? service, - }) : _service = service ?? dc.DataConnectService.instance; + ShiftsConnectorRepositoryImpl({dc.DataConnectService? service}) + : _service = service ?? dc.DataConnectService.instance; final dc.DataConnectService _service; @@ -23,12 +22,17 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { required DateTime end, }) async { return _service.run(() async { - final dc.GetApplicationsByStaffIdVariablesBuilder query = _service.connector + final dc.GetApplicationsByStaffIdVariablesBuilder query = _service + .connector .getApplicationsByStaffId(staffId: staffId) .dayStart(_service.toTimestamp(start)) .dayEnd(_service.toTimestamp(end)); - final QueryResult response = await query.execute(); + final QueryResult< + dc.GetApplicationsByStaffIdData, + dc.GetApplicationsByStaffIdVariables + > + response = await query.execute(); return _mapApplicationsToShifts(response.data.applications); }); } @@ -45,18 +49,28 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { final String? vendorId = dc.StaffSessionStore.instance.session?.ownerId; if (vendorId == null || vendorId.isEmpty) return []; - final QueryResult response = await _service.connector + final QueryResult< + dc.ListShiftRolesByVendorIdData, + dc.ListShiftRolesByVendorIdVariables + > + response = await _service.connector .listShiftRolesByVendorId(vendorId: vendorId) .execute(); - final List allShiftRoles = response.data.shiftRoles; + final List allShiftRoles = + response.data.shiftRoles; // Fetch current applications to filter out already booked shifts - final QueryResult myAppsResponse = await _service.connector + final QueryResult< + dc.GetApplicationsByStaffIdData, + dc.GetApplicationsByStaffIdVariables + > + myAppsResponse = await _service.connector .getApplicationsByStaffId(staffId: staffId) .execute(); - final Set appliedShiftIds = - myAppsResponse.data.applications.map((dc.GetApplicationsByStaffIdApplications a) => a.shiftId).toSet(); + final Set appliedShiftIds = myAppsResponse.data.applications + .map((dc.GetApplicationsByStaffIdApplications a) => a.shiftId) + .toSet(); final List mappedShifts = []; for (final dc.ListShiftRolesByVendorIdShiftRoles sr in allShiftRoles) { @@ -67,6 +81,34 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { final DateTime? endDt = _service.toDateTime(sr.endTime); final DateTime? createdDt = _service.toDateTime(sr.createdAt); + // Normalise orderType to uppercase for consistent checks in the UI. + // RECURRING → groups shifts into Multi-Day cards. + // PERMANENT → groups shifts into Long Term cards. + final String orderTypeStr = sr.shift.order.orderType.stringValue + .toUpperCase(); + + final dc.ListShiftRolesByVendorIdShiftRolesShiftOrder order = + sr.shift.order; + final DateTime? startDate = _service.toDateTime(order.startDate); + final DateTime? endDate = _service.toDateTime(order.endDate); + + final String startTime = startDt != null + ? DateFormat('HH:mm').format(startDt) + : ''; + final String endTime = endDt != null + ? DateFormat('HH:mm').format(endDt) + : ''; + + final List? schedules = _generateSchedules( + orderType: orderTypeStr, + startDate: startDate, + endDate: endDate, + recurringDays: order.recurringDays, + permanentDays: order.permanentDays, + startTime: startTime, + endTime: endTime, + ); + mappedShifts.add( Shift( id: sr.shiftId, @@ -78,16 +120,25 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { location: sr.shift.location ?? '', locationAddress: sr.shift.locationAddress ?? '', date: shiftDate?.toIso8601String() ?? '', - startTime: startDt != null ? DateFormat('HH:mm').format(startDt) : '', - endTime: endDt != null ? DateFormat('HH:mm').format(endDt) : '', + startTime: startTime, + endTime: endTime, createdDate: createdDt?.toIso8601String() ?? '', status: sr.shift.status?.stringValue.toLowerCase() ?? 'open', description: sr.shift.description, - durationDays: sr.shift.durationDays, + durationDays: sr.shift.durationDays ?? schedules?.length, requiredSlots: sr.count, filledSlots: sr.assigned ?? 0, latitude: sr.shift.latitude, longitude: sr.shift.longitude, + // orderId + orderType power the grouping and type-badge logic in + // FindShiftsTab._groupMultiDayShifts and MyShiftCard._getShiftType. + orderId: sr.shift.orderId, + orderType: orderTypeStr, + startDate: startDate?.toIso8601String(), + endDate: endDate?.toIso8601String(), + recurringDays: sr.shift.order.recurringDays, + permanentDays: sr.shift.order.permanentDays, + schedules: schedules, breakInfo: BreakAdapter.fromData( isPaid: sr.isBreakPaid ?? false, breakTime: sr.breakType?.stringValue, @@ -125,7 +176,8 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { }) async { return _service.run(() async { if (roleId != null && roleId.isNotEmpty) { - final QueryResult roleResult = await _service.connector + final QueryResult + roleResult = await _service.connector .getShiftRoleById(shiftId: shiftId, roleId: roleId) .execute(); final dc.GetShiftRoleByIdShiftRole? sr = roleResult.data.shiftRole; @@ -137,13 +189,22 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { bool hasApplied = false; String status = 'open'; - - final QueryResult appsResponse = await _service.connector + + final QueryResult< + dc.GetApplicationsByStaffIdData, + dc.GetApplicationsByStaffIdVariables + > + appsResponse = await _service.connector .getApplicationsByStaffId(staffId: staffId) .execute(); - - final dc.GetApplicationsByStaffIdApplications? app = appsResponse.data.applications - .where((dc.GetApplicationsByStaffIdApplications a) => a.shiftId == shiftId && a.shiftRole.roleId == roleId) + + final dc.GetApplicationsByStaffIdApplications? app = appsResponse + .data + .applications + .where( + (dc.GetApplicationsByStaffIdApplications a) => + a.shiftId == shiftId && a.shiftRole.roleId == roleId, + ) .firstOrNull; if (app != null) { @@ -181,7 +242,8 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { ); } - final QueryResult result = await _service.connector.getShiftById(id: shiftId).execute(); + final QueryResult result = + await _service.connector.getShiftById(id: shiftId).execute(); final dc.GetShiftByIdShift? s = result.data.shift; if (s == null) return null; @@ -190,17 +252,23 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { Break? breakInfo; try { - final QueryResult rolesRes = await _service.connector + final QueryResult< + dc.ListShiftRolesByShiftIdData, + dc.ListShiftRolesByShiftIdVariables + > + rolesRes = await _service.connector .listShiftRolesByShiftId(shiftId: shiftId) .execute(); if (rolesRes.data.shiftRoles.isNotEmpty) { required = 0; filled = 0; - for (dc.ListShiftRolesByShiftIdShiftRoles r in rolesRes.data.shiftRoles) { + for (dc.ListShiftRolesByShiftIdShiftRoles r + in rolesRes.data.shiftRoles) { required = (required ?? 0) + r.count; filled = (filled ?? 0) + (r.assigned ?? 0); } - final dc.ListShiftRolesByShiftIdShiftRoles firstRole = rolesRes.data.shiftRoles.first; + final dc.ListShiftRolesByShiftIdShiftRoles firstRole = + rolesRes.data.shiftRoles.first; breakInfo = BreakAdapter.fromData( isPaid: firstRole.isBreakPaid ?? false, breakTime: firstRole.breakType?.stringValue, @@ -247,89 +315,188 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { final String targetRoleId = roleId ?? ''; if (targetRoleId.isEmpty) throw Exception('Missing role id.'); - final QueryResult roleResult = await _service.connector - .getShiftRoleById(shiftId: shiftId, roleId: targetRoleId) + // 1. Fetch the initial shift to determine order type + final QueryResult + shiftResult = await _service.connector + .getShiftById(id: shiftId) .execute(); - final dc.GetShiftRoleByIdShiftRole? role = roleResult.data.shiftRole; - if (role == null) throw Exception('Shift role not found'); + final dc.GetShiftByIdShift? initialShift = shiftResult.data.shift; + if (initialShift == null) throw Exception('Shift not found'); - final QueryResult shiftResult = await _service.connector.getShiftById(id: shiftId).execute(); - final dc.GetShiftByIdShift? shift = shiftResult.data.shift; - if (shift == null) throw Exception('Shift not found'); + final dc.EnumValue orderTypeEnum = + initialShift.order.orderType; + final bool isMultiDay = + orderTypeEnum is dc.Known && + (orderTypeEnum.value == dc.OrderType.RECURRING || + orderTypeEnum.value == dc.OrderType.PERMANENT); + final List<_TargetShiftRole> targets = []; - // Validate daily limit - final DateTime? shiftDate = _service.toDateTime(shift.date); - if (shiftDate != null) { - final DateTime dayStartUtc = DateTime.utc(shiftDate.year, shiftDate.month, shiftDate.day); - final DateTime dayEndUtc = dayStartUtc.add(const Duration(days: 1)).subtract(const Duration(microseconds: 1)); - - final QueryResult validationResponse = await _service.connector - .vaidateDayStaffApplication(staffId: staffId) - .dayStart(_service.toTimestamp(dayStartUtc)) - .dayEnd(_service.toTimestamp(dayEndUtc)) + if (isMultiDay) { + // 2. Fetch all shifts for this order to apply to all of them for the same role + final QueryResult< + dc.ListShiftRolesByBusinessAndOrderData, + dc.ListShiftRolesByBusinessAndOrderVariables + > + allRolesRes = await _service.connector + .listShiftRolesByBusinessAndOrder( + businessId: initialShift.order.businessId, + orderId: initialShift.orderId, + ) .execute(); - - if (validationResponse.data.applications.isNotEmpty) { - throw Exception('The user already has a shift that day.'); - } - } - // Check for existing application - final QueryResult existingAppRes = await _service.connector - .getApplicationByStaffShiftAndRole( - staffId: staffId, + for (final role in allRolesRes.data.shiftRoles) { + if (role.roleId == targetRoleId) { + targets.add( + _TargetShiftRole( + shiftId: role.shiftId, + roleId: role.roleId, + count: role.count, + assigned: role.assigned ?? 0, + shiftFilled: role.shift.filled ?? 0, + date: _service.toDateTime(role.shift.date), + ), + ); + } + } + } else { + // Single shift application + final QueryResult + roleResult = await _service.connector + .getShiftRoleById(shiftId: shiftId, roleId: targetRoleId) + .execute(); + final dc.GetShiftRoleByIdShiftRole? role = roleResult.data.shiftRole; + if (role == null) throw Exception('Shift role not found'); + + targets.add( + _TargetShiftRole( shiftId: shiftId, roleId: targetRoleId, - ) - .execute(); - if (existingAppRes.data.applications.isNotEmpty) { - throw Exception('Application already exists.'); + count: role.count, + assigned: role.assigned ?? 0, + shiftFilled: initialShift.filled ?? 0, + date: _service.toDateTime(initialShift.date), + ), + ); } - if ((role.assigned ?? 0) >= role.count) { - throw Exception('This shift is full.'); + if (targets.isEmpty) { + throw Exception('No valid shifts found to apply for.'); } - final int currentAssigned = role.assigned ?? 0; - final int currentFilled = shift.filled ?? 0; + int appliedCount = 0; + final List errors = []; - String? createdAppId; - try { - final OperationResult createRes = await _service.connector.createApplication( - shiftId: shiftId, - staffId: staffId, - roleId: targetRoleId, - status: dc.ApplicationStatus.CONFIRMED, // Matches existing logic - origin: dc.ApplicationOrigin.STAFF, - ).execute(); - - createdAppId = createRes.data.application_insert.id; - - await _service.connector - .updateShiftRole(shiftId: shiftId, roleId: targetRoleId) - .assigned(currentAssigned + 1) - .execute(); - - await _service.connector - .updateShift(id: shiftId) - .filled(currentFilled + 1) - .execute(); - } catch (e) { - // Simple rollback attempt (not guaranteed) - if (createdAppId != null) { - await _service.connector.deleteApplication(id: createdAppId).execute(); + for (final target in targets) { + try { + await _applyToSingleShiftRole(target: target, staffId: staffId); + appliedCount++; + } catch (e) { + // For multi-shift apply, we might want to continue even if some fail due to conflicts + if (targets.length == 1) rethrow; + errors.add('Shift on ${target.date}: ${e.toString()}'); } - rethrow; + } + + if (appliedCount == 0 && targets.length > 1) { + throw Exception('Failed to apply for any shifts: ${errors.join(", ")}'); } }); } - @override - Future acceptShift({ - required String shiftId, + Future _applyToSingleShiftRole({ + required _TargetShiftRole target, required String staffId, - }) { - return _updateApplicationStatus(shiftId, staffId, dc.ApplicationStatus.CONFIRMED); + }) async { + // Validate daily limit + if (target.date != null) { + final DateTime dayStartUtc = DateTime.utc( + target.date!.year, + target.date!.month, + target.date!.day, + ); + final DateTime dayEndUtc = dayStartUtc + .add(const Duration(days: 1)) + .subtract(const Duration(microseconds: 1)); + + final QueryResult< + dc.VaidateDayStaffApplicationData, + dc.VaidateDayStaffApplicationVariables + > + validationResponse = await _service.connector + .vaidateDayStaffApplication(staffId: staffId) + .dayStart(_service.toTimestamp(dayStartUtc)) + .dayEnd(_service.toTimestamp(dayEndUtc)) + .execute(); + + if (validationResponse.data.applications.isNotEmpty) { + throw Exception('The user already has a shift that day.'); + } + } + + // Check for existing application + final QueryResult< + dc.GetApplicationByStaffShiftAndRoleData, + dc.GetApplicationByStaffShiftAndRoleVariables + > + existingAppRes = await _service.connector + .getApplicationByStaffShiftAndRole( + staffId: staffId, + shiftId: target.shiftId, + roleId: target.roleId, + ) + .execute(); + + if (existingAppRes.data.applications.isNotEmpty) { + throw Exception('Application already exists.'); + } + + if (target.assigned >= target.count) { + throw Exception('This shift is full.'); + } + + String? createdAppId; + try { + final OperationResult< + dc.CreateApplicationData, + dc.CreateApplicationVariables + > + createRes = await _service.connector + .createApplication( + shiftId: target.shiftId, + staffId: staffId, + roleId: target.roleId, + status: dc.ApplicationStatus.CONFIRMED, + origin: dc.ApplicationOrigin.STAFF, + ) + .execute(); + + createdAppId = createRes.data.application_insert.id; + + await _service.connector + .updateShiftRole(shiftId: target.shiftId, roleId: target.roleId) + .assigned(target.assigned + 1) + .execute(); + + await _service.connector + .updateShift(id: target.shiftId) + .filled(target.shiftFilled + 1) + .execute(); + } catch (e) { + // Simple rollback attempt (not guaranteed) + if (createdAppId != null) { + await _service.connector.deleteApplication(id: createdAppId).execute(); + } + rethrow; + } + } + + @override + Future acceptShift({required String shiftId, required String staffId}) { + return _updateApplicationStatus( + shiftId, + staffId, + dc.ApplicationStatus.CONFIRMED, + ); } @override @@ -337,7 +504,11 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { required String shiftId, required String staffId, }) { - return _updateApplicationStatus(shiftId, staffId, dc.ApplicationStatus.REJECTED); + return _updateApplicationStatus( + shiftId, + staffId, + dc.ApplicationStatus.REJECTED, + ); } @override @@ -351,18 +522,24 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { @override Future> getHistoryShifts({required String staffId}) async { return _service.run(() async { - final QueryResult response = await _service.connector + final QueryResult< + dc.ListCompletedApplicationsByStaffIdData, + dc.ListCompletedApplicationsByStaffIdVariables + > + response = await _service.connector .listCompletedApplicationsByStaffId(staffId: staffId) .execute(); - + final List shifts = []; - for (final dc.ListCompletedApplicationsByStaffIdApplications app in response.data.applications) { + for (final dc.ListCompletedApplicationsByStaffIdApplications app + in response.data.applications) { final String roleName = app.shiftRole.role.name; - final String orderName = (app.shift.order.eventName ?? '').trim().isNotEmpty + final String orderName = + (app.shift.order.eventName ?? '').trim().isNotEmpty ? app.shift.order.eventName! : app.shift.order.business.businessName; final String title = '$roleName - $orderName'; - + final DateTime? shiftDate = _service.toDateTime(app.shift.date); final DateTime? startDt = _service.toDateTime(app.shiftRole.startTime); final DateTime? endDt = _service.toDateTime(app.shiftRole.endTime); @@ -379,7 +556,9 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { location: app.shift.location ?? '', locationAddress: app.shift.order.teamHub.hubName, date: shiftDate?.toIso8601String() ?? '', - startTime: startDt != null ? DateFormat('HH:mm').format(startDt) : '', + startTime: startDt != null + ? DateFormat('HH:mm').format(startDt) + : '', endTime: endDt != null ? DateFormat('HH:mm').format(endDt) : '', createdDate: createdDt?.toIso8601String() ?? '', status: 'completed', // Hardcoded as checked out implies completion @@ -406,7 +585,8 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { List _mapApplicationsToShifts(List apps) { return apps.map((app) { final String roleName = app.shiftRole.role.name; - final String orderName = (app.shift.order.eventName ?? '').trim().isNotEmpty + final String orderName = + (app.shift.order.eventName ?? '').trim().isNotEmpty ? app.shift.order.eventName! : app.shift.order.business.businessName; final String title = '$roleName - $orderName'; @@ -418,7 +598,7 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { final bool hasCheckIn = app.checkInTime != null; final bool hasCheckOut = app.checkOutTime != null; - + String status; if (hasCheckOut) { status = 'completed'; @@ -479,12 +659,20 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { ) async { return _service.run(() async { // First try to find the application - final QueryResult appsResponse = await _service.connector + final QueryResult< + dc.GetApplicationsByStaffIdData, + dc.GetApplicationsByStaffIdVariables + > + appsResponse = await _service.connector .getApplicationsByStaffId(staffId: staffId) .execute(); - - final dc.GetApplicationsByStaffIdApplications? app = appsResponse.data.applications - .where((dc.GetApplicationsByStaffIdApplications a) => a.shiftId == shiftId) + + final dc.GetApplicationsByStaffIdApplications? app = appsResponse + .data + .applications + .where( + (dc.GetApplicationsByStaffIdApplications a) => a.shiftId == shiftId, + ) .firstOrNull; if (app != null) { @@ -494,24 +682,116 @@ class ShiftsConnectorRepositoryImpl implements ShiftsConnectorRepository { .execute(); } else if (newStatus == dc.ApplicationStatus.REJECTED) { // If declining but no app found, create a rejected application - final QueryResult rolesRes = await _service.connector + final QueryResult< + dc.ListShiftRolesByShiftIdData, + dc.ListShiftRolesByShiftIdVariables + > + rolesRes = await _service.connector .listShiftRolesByShiftId(shiftId: shiftId) .execute(); - + if (rolesRes.data.shiftRoles.isNotEmpty) { - final dc.ListShiftRolesByShiftIdShiftRoles firstRole = rolesRes.data.shiftRoles.first; - await _service.connector.createApplication( - shiftId: shiftId, - staffId: staffId, - roleId: firstRole.id, - status: dc.ApplicationStatus.REJECTED, - origin: dc.ApplicationOrigin.STAFF, - ).execute(); + final dc.ListShiftRolesByShiftIdShiftRoles firstRole = + rolesRes.data.shiftRoles.first; + await _service.connector + .createApplication( + shiftId: shiftId, + staffId: staffId, + roleId: firstRole.id, + status: dc.ApplicationStatus.REJECTED, + origin: dc.ApplicationOrigin.STAFF, + ) + .execute(); } } else { throw Exception("Application not found for shift $shiftId"); } }); } + + /// Generates a list of [ShiftSchedule] for RECURRING or PERMANENT orders. + List? _generateSchedules({ + required String orderType, + required DateTime? startDate, + required DateTime? endDate, + required List? recurringDays, + required List? permanentDays, + required String startTime, + required String endTime, + }) { + if (orderType != 'RECURRING' && orderType != 'PERMANENT') return null; + if (startDate == null || endDate == null) return null; + + final List? daysToInclude = orderType == 'RECURRING' + ? recurringDays + : permanentDays; + if (daysToInclude == null || daysToInclude.isEmpty) return null; + + final List schedules = []; + final Set targetWeekdayIndex = daysToInclude + .map((String day) { + switch (day.toUpperCase()) { + case 'MONDAY': + return DateTime.monday; + case 'TUESDAY': + return DateTime.tuesday; + case 'WEDNESDAY': + return DateTime.wednesday; + case 'THURSDAY': + return DateTime.thursday; + case 'FRIDAY': + return DateTime.friday; + case 'SATURDAY': + return DateTime.saturday; + case 'SUNDAY': + return DateTime.sunday; + default: + return -1; + } + }) + .where((int idx) => idx != -1) + .toSet(); + + DateTime current = startDate; + while (current.isBefore(endDate) || + current.isAtSameMomentAs(endDate) || + // Handle cases where the time component might differ slightly by checking date equality + (current.year == endDate.year && + current.month == endDate.month && + current.day == endDate.day)) { + if (targetWeekdayIndex.contains(current.weekday)) { + schedules.add( + ShiftSchedule( + date: current.toIso8601String(), + startTime: startTime, + endTime: endTime, + ), + ); + } + current = current.add(const Duration(days: 1)); + + // Safety break to prevent infinite loops if dates are messed up + if (schedules.length > 365) break; + } + + return schedules; + } } +class _TargetShiftRole { + final String shiftId; + final String roleId; + final int count; + final int assigned; + final int shiftFilled; + final DateTime? date; + + _TargetShiftRole({ + required this.shiftId, + required this.roleId, + required this.count, + required this.assigned, + required this.shiftFilled, + this.date, + }); +} diff --git a/apps/mobile/packages/data_connect/lib/src/data_connect_module.dart b/apps/mobile/packages/data_connect/lib/src/data_connect_module.dart index 0f234576..53b9428f 100644 --- a/apps/mobile/packages/data_connect/lib/src/data_connect_module.dart +++ b/apps/mobile/packages/data_connect/lib/src/data_connect_module.dart @@ -7,8 +7,6 @@ import 'connectors/hubs/domain/repositories/hubs_connector_repository.dart'; import 'connectors/hubs/data/repositories/hubs_connector_repository_impl.dart'; import 'connectors/billing/domain/repositories/billing_connector_repository.dart'; import 'connectors/billing/data/repositories/billing_connector_repository_impl.dart'; -import 'connectors/home/domain/repositories/home_connector_repository.dart'; -import 'connectors/home/data/repositories/home_connector_repository_impl.dart'; import 'connectors/coverage/domain/repositories/coverage_connector_repository.dart'; import 'connectors/coverage/data/repositories/coverage_connector_repository_impl.dart'; import 'services/data_connect_service.dart'; @@ -32,9 +30,6 @@ class DataConnectModule extends Module { i.addLazySingleton( BillingConnectorRepositoryImpl.new, ); - i.addLazySingleton( - HomeConnectorRepositoryImpl.new, - ); i.addLazySingleton( CoverageConnectorRepositoryImpl.new, ); diff --git a/apps/mobile/packages/data_connect/lib/src/services/data_connect_service.dart b/apps/mobile/packages/data_connect/lib/src/services/data_connect_service.dart index 6865eefe..8e79de80 100644 --- a/apps/mobile/packages/data_connect/lib/src/services/data_connect_service.dart +++ b/apps/mobile/packages/data_connect/lib/src/services/data_connect_service.dart @@ -13,8 +13,6 @@ import '../connectors/hubs/domain/repositories/hubs_connector_repository.dart'; import '../connectors/hubs/data/repositories/hubs_connector_repository_impl.dart'; import '../connectors/billing/domain/repositories/billing_connector_repository.dart'; import '../connectors/billing/data/repositories/billing_connector_repository_impl.dart'; -import '../connectors/home/domain/repositories/home_connector_repository.dart'; -import '../connectors/home/data/repositories/home_connector_repository_impl.dart'; import '../connectors/coverage/domain/repositories/coverage_connector_repository.dart'; import '../connectors/coverage/data/repositories/coverage_connector_repository_impl.dart'; import '../connectors/staff/domain/repositories/staff_connector_repository.dart'; @@ -39,7 +37,6 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin { ShiftsConnectorRepository? _shiftsRepository; HubsConnectorRepository? _hubsRepository; BillingConnectorRepository? _billingRepository; - HomeConnectorRepository? _homeRepository; CoverageConnectorRepository? _coverageRepository; StaffConnectorRepository? _staffRepository; @@ -63,14 +60,11 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin { return _billingRepository ??= BillingConnectorRepositoryImpl(service: this); } - /// Gets the home connector repository. - HomeConnectorRepository getHomeRepository() { - return _homeRepository ??= HomeConnectorRepositoryImpl(service: this); - } - /// Gets the coverage connector repository. CoverageConnectorRepository getCoverageRepository() { - return _coverageRepository ??= CoverageConnectorRepositoryImpl(service: this); + return _coverageRepository ??= CoverageConnectorRepositoryImpl( + service: this, + ); } /// Gets the staff connector repository. @@ -84,14 +78,14 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin { /// Helper to get the current staff ID from the session. Future getStaffId() async { - String? staffId = dc.StaffSessionStore.instance.session?.ownerId; - + String? staffId = dc.StaffSessionStore.instance.session?.staff?.id; + if (staffId == null || staffId.isEmpty) { // Attempt to recover session if user is signed in final user = auth.currentUser; if (user != null) { await _loadSession(user.uid); - staffId = dc.StaffSessionStore.instance.session?.ownerId; + staffId = dc.StaffSessionStore.instance.session?.staff?.id; } } @@ -128,12 +122,14 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin { // Load Staff Session if applicable if (role == 'STAFF' || role == 'BOTH') { - final response = await connector.getStaffByUserId(userId: userId).execute(); + final response = await connector + .getStaffByUserId(userId: userId) + .execute(); if (response.data.staffs.isNotEmpty) { final s = response.data.staffs.first; dc.StaffSessionStore.instance.setSession( dc.StaffSession( - ownerId: s.id, + ownerId: s.ownerId, staff: domain.Staff( id: s.id, authProviderId: s.userId, @@ -151,7 +147,9 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin { // Load Client Session if applicable if (role == 'BUSINESS' || role == 'BOTH') { - final response = await connector.getBusinessesByUserId(userId: userId).execute(); + final response = await connector + .getBusinessesByUserId(userId: userId) + .execute(); if (response.data.businesses.isNotEmpty) { final b = response.data.businesses.first; dc.ClientSessionStore.instance.setSession( @@ -173,16 +171,23 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin { } } - /// Converts a Data Connect [Timestamp] to a Dart [DateTime]. + /// Converts a Data Connect [Timestamp] to a Dart [DateTime] in local time. + /// + /// Firebase Data Connect always stores and returns timestamps in UTC. + /// Calling [toLocal] ensures the result reflects the device's timezone so + /// that shift dates, start/end times, and formatted strings are correct for + /// the end user. DateTime? toDateTime(dynamic timestamp) { if (timestamp == null) return null; if (timestamp is fdc.Timestamp) { - return timestamp.toDateTime(); + return timestamp.toDateTime().toLocal(); } return null; } /// Converts a Dart [DateTime] to a Data Connect [Timestamp]. + /// + /// Converts the [DateTime] to UTC before creating the [Timestamp]. fdc.Timestamp toTimestamp(DateTime dateTime) { final DateTime utc = dateTime.toUtc(); final int millis = utc.millisecondsSinceEpoch; @@ -225,7 +230,6 @@ class DataConnectService with DataErrorHandler, SessionHandlerMixin { _shiftsRepository = null; _hubsRepository = null; _billingRepository = null; - _homeRepository = null; _coverageRepository = null; _staffRepository = null; diff --git a/apps/mobile/packages/design_system/lib/src/ui_icons.dart b/apps/mobile/packages/design_system/lib/src/ui_icons.dart index 55a7841b..2be98401 100644 --- a/apps/mobile/packages/design_system/lib/src/ui_icons.dart +++ b/apps/mobile/packages/design_system/lib/src/ui_icons.dart @@ -28,6 +28,9 @@ class UiIcons { /// Calendar icon for shifts or schedules static const IconData calendar = _IconLib.calendar; + /// Calender check icon for shifts or schedules + static const IconData calendarCheck = _IconLib.calendarCheck; + /// Briefcase icon for jobs static const IconData briefcase = _IconLib.briefcase; diff --git a/apps/mobile/packages/design_system/lib/src/ui_typography.dart b/apps/mobile/packages/design_system/lib/src/ui_typography.dart index b2224b11..b12fd24a 100644 --- a/apps/mobile/packages/design_system/lib/src/ui_typography.dart +++ b/apps/mobile/packages/design_system/lib/src/ui_typography.dart @@ -221,6 +221,14 @@ class UiTypography { color: UiColors.textPrimary, ); + /// Headline 4 Bold - Font: Instrument Sans, Size: 20, Height: 1.5 (#121826) + static final TextStyle headline4b = _primaryBase.copyWith( + fontWeight: FontWeight.w600, + fontSize: 18, + height: 1.5, + color: UiColors.textPrimary, + ); + /// Headline 5 Regular - Font: Instrument Sans, Size: 18, Height: 1.5 (#121826) static final TextStyle headline5r = _primaryBase.copyWith( fontWeight: FontWeight.w400, diff --git a/apps/mobile/packages/design_system/lib/src/widgets/ui_app_bar.dart b/apps/mobile/packages/design_system/lib/src/widgets/ui_app_bar.dart index b6a70e3e..4394bb7e 100644 --- a/apps/mobile/packages/design_system/lib/src/widgets/ui_app_bar.dart +++ b/apps/mobile/packages/design_system/lib/src/widgets/ui_app_bar.dart @@ -1,12 +1,14 @@ +import 'package:design_system/design_system.dart'; +import 'package:design_system/src/ui_typography.dart'; import 'package:flutter/material.dart'; import '../ui_icons.dart'; +import 'ui_icon_button.dart'; /// A custom AppBar for the Krow UI design system. /// /// This widget provides a consistent look and feel for top app bars across the application. class UiAppBar extends StatelessWidget implements PreferredSizeWidget { - const UiAppBar({ super.key, this.title, @@ -14,11 +16,12 @@ class UiAppBar extends StatelessWidget implements PreferredSizeWidget { this.leading, this.actions, this.height = kToolbarHeight, - this.centerTitle = true, + this.centerTitle = false, this.onLeadingPressed, this.showBackButton = true, this.bottom, }); + /// The title text to display in the app bar. final String? title; @@ -52,17 +55,19 @@ class UiAppBar extends StatelessWidget implements PreferredSizeWidget { @override Widget build(BuildContext context) { return AppBar( - title: titleWidget ?? - (title != null - ? Text( - title!, - ) - : null), - leading: leading ?? + title: + titleWidget ?? + (title != null ? Text(title!, style: UiTypography.headline4b) : null), + leading: + leading ?? (showBackButton - ? IconButton( - icon: const Icon(UiIcons.chevronLeft, size: 20), - onPressed: onLeadingPressed ?? () => Navigator.of(context).pop(), + ? UiIconButton( + icon: UiIcons.chevronLeft, + onTap: onLeadingPressed ?? () => Navigator.of(context).pop(), + backgroundColor: UiColors.transparent, + iconColor: UiColors.iconThird, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(UiConstants.radiusBase), ) : null), actions: actions, @@ -72,5 +77,6 @@ class UiAppBar extends StatelessWidget implements PreferredSizeWidget { } @override - Size get preferredSize => Size.fromHeight(height + (bottom?.preferredSize.height ?? 0.0)); + Size get preferredSize => + Size.fromHeight(height + (bottom?.preferredSize.height ?? 0.0)); } diff --git a/apps/mobile/packages/design_system/lib/src/widgets/ui_chip.dart b/apps/mobile/packages/design_system/lib/src/widgets/ui_chip.dart index 0c01afb2..1bd3a289 100644 --- a/apps/mobile/packages/design_system/lib/src/widgets/ui_chip.dart +++ b/apps/mobile/packages/design_system/lib/src/widgets/ui_chip.dart @@ -29,7 +29,6 @@ enum UiChipVariant { /// A custom chip widget with supports for different sizes, themes, and icons. class UiChip extends StatelessWidget { - /// Creates a [UiChip]. const UiChip({ super.key, @@ -42,6 +41,7 @@ class UiChip extends StatelessWidget { this.onTrailingIconTap, this.isSelected = false, }); + /// The text label to display. final String label; @@ -99,7 +99,7 @@ class UiChip extends StatelessWidget { padding: padding, decoration: BoxDecoration( color: backgroundColor, - borderRadius: UiConstants.radiusFull, + borderRadius: UiConstants.radiusMd, border: _getBorder(), ), child: content, diff --git a/apps/mobile/packages/design_system/lib/src/widgets/ui_icon_button.dart b/apps/mobile/packages/design_system/lib/src/widgets/ui_icon_button.dart index bfa717e5..dca4aff9 100644 --- a/apps/mobile/packages/design_system/lib/src/widgets/ui_icon_button.dart +++ b/apps/mobile/packages/design_system/lib/src/widgets/ui_icon_button.dart @@ -16,6 +16,8 @@ class UiIconButton extends StatelessWidget { required this.iconColor, this.useBlur = false, this.onTap, + this.shape = BoxShape.circle, + this.borderRadius, }); /// Creates a primary variant icon button with solid background. @@ -25,6 +27,8 @@ class UiIconButton extends StatelessWidget { this.size = 40, this.iconSize = 20, this.onTap, + this.shape = BoxShape.circle, + this.borderRadius, }) : backgroundColor = UiColors.primary, iconColor = UiColors.white, useBlur = false; @@ -36,6 +40,8 @@ class UiIconButton extends StatelessWidget { this.size = 40, this.iconSize = 20, this.onTap, + this.shape = BoxShape.circle, + this.borderRadius, }) : backgroundColor = UiColors.primary.withAlpha(96), iconColor = UiColors.primary, useBlur = true; @@ -60,13 +66,23 @@ class UiIconButton extends StatelessWidget { /// Callback when the button is tapped. final VoidCallback? onTap; + /// The shape of the button (circle or rectangle). + final BoxShape shape; + + /// The border radius for rectangle shape. + final BorderRadius? borderRadius; + @override /// Builds the icon button UI. Widget build(BuildContext context) { final Widget button = Container( width: size, height: size, - decoration: BoxDecoration(color: backgroundColor, shape: BoxShape.circle), + decoration: BoxDecoration( + color: backgroundColor, + shape: shape, + borderRadius: shape == BoxShape.rectangle ? borderRadius : null, + ), child: Icon(icon, color: iconColor, size: iconSize), ); diff --git a/apps/mobile/packages/domain/lib/krow_domain.dart b/apps/mobile/packages/domain/lib/krow_domain.dart index e1ca4d10..15a1b2e4 100644 --- a/apps/mobile/packages/domain/lib/krow_domain.dart +++ b/apps/mobile/packages/domain/lib/krow_domain.dart @@ -34,14 +34,15 @@ export 'src/entities/shifts/break/break.dart'; export 'src/adapters/shifts/break/break_adapter.dart'; // Orders & Requests -export 'src/entities/orders/order_type.dart'; export 'src/entities/orders/one_time_order.dart'; export 'src/entities/orders/one_time_order_position.dart'; export 'src/entities/orders/recurring_order.dart'; export 'src/entities/orders/recurring_order_position.dart'; export 'src/entities/orders/permanent_order.dart'; export 'src/entities/orders/permanent_order_position.dart'; +export 'src/entities/orders/order_type.dart'; export 'src/entities/orders/order_item.dart'; +export 'src/entities/orders/reorder_data.dart'; // Skills & Certs export 'src/entities/skills/skill.dart'; diff --git a/apps/mobile/packages/domain/lib/src/entities/home/reorder_item.dart b/apps/mobile/packages/domain/lib/src/entities/home/reorder_item.dart index 7d9e22a3..d13a80bd 100644 --- a/apps/mobile/packages/domain/lib/src/entities/home/reorder_item.dart +++ b/apps/mobile/packages/domain/lib/src/entities/home/reorder_item.dart @@ -1,46 +1,51 @@ import 'package:equatable/equatable.dart'; -/// Summary of a completed shift role used for reorder suggestions. +/// Summary of a completed order used for reorder suggestions. class ReorderItem extends Equatable { const ReorderItem({ required this.orderId, required this.title, required this.location, - required this.hourlyRate, - required this.hours, + required this.totalCost, required this.workers, required this.type, + this.hourlyRate = 0, + this.hours = 0, }); - /// Parent order id for the completed shift. + /// Unique identifier of the order. final String orderId; - /// Display title (role + shift title). + /// Display title of the order (e.g., event name or first shift title). final String title; - /// Location from the shift. + /// Location of the order (e.g., first shift location). final String location; - /// Hourly rate from the role. - final double hourlyRate; + /// Total calculated cost for the order. + final double totalCost; - /// Total hours for the shift role. - final double hours; - - /// Worker count for the shift role. + /// Total number of workers required for the order. final int workers; - /// Order type (e.g., ONE_TIME). + /// The type of order (e.g., ONE_TIME, RECURRING). final String type; + /// Average or primary hourly rate (optional, for display). + final double hourlyRate; + + /// Total hours for the order (optional, for display). + final double hours; + @override List get props => [ orderId, title, location, - hourlyRate, - hours, + totalCost, workers, type, + hourlyRate, + hours, ]; } diff --git a/apps/mobile/packages/domain/lib/src/entities/orders/order_item.dart b/apps/mobile/packages/domain/lib/src/entities/orders/order_item.dart index 8dea0ee5..b9ab956f 100644 --- a/apps/mobile/packages/domain/lib/src/entities/orders/order_item.dart +++ b/apps/mobile/packages/domain/lib/src/entities/orders/order_item.dart @@ -1,5 +1,7 @@ import 'package:equatable/equatable.dart'; +import 'order_type.dart'; + /// Represents a customer's view of an order or shift. /// /// This entity captures the details necessary for the dashboard/view orders screen, @@ -9,6 +11,7 @@ class OrderItem extends Equatable { const OrderItem({ required this.id, required this.orderId, + required this.orderType, required this.title, required this.clientName, required this.status, @@ -20,6 +23,7 @@ class OrderItem extends Equatable { required this.filled, required this.workersNeeded, required this.hourlyRate, + required this.eventName, this.hours = 0, this.totalValue = 0, this.confirmedApps = const >[], @@ -31,6 +35,9 @@ class OrderItem extends Equatable { /// Parent order identifier. final String orderId; + /// The type of order (e.g., ONE_TIME, PERMANENT). + final OrderType orderType; + /// Title or name of the role. final String title; @@ -70,6 +77,9 @@ class OrderItem extends Equatable { /// Total value for the shift role. final double totalValue; + /// Name of the event. + final String eventName; + /// List of confirmed worker applications. final List> confirmedApps; @@ -77,6 +87,7 @@ class OrderItem extends Equatable { List get props => [ id, orderId, + orderType, title, clientName, status, @@ -90,6 +101,7 @@ class OrderItem extends Equatable { hourlyRate, hours, totalValue, + eventName, confirmedApps, ]; } diff --git a/apps/mobile/packages/domain/lib/src/entities/orders/order_type.dart b/apps/mobile/packages/domain/lib/src/entities/orders/order_type.dart index e1448be7..f4385b5b 100644 --- a/apps/mobile/packages/domain/lib/src/entities/orders/order_type.dart +++ b/apps/mobile/packages/domain/lib/src/entities/orders/order_type.dart @@ -1,25 +1,30 @@ -import 'package:equatable/equatable.dart'; +/// Defines the type of an order. +enum OrderType { + /// A single occurrence shift. + oneTime, -/// Represents a type of order that can be created (e.g., Rapid, One-Time). -/// -/// This entity defines the identity and display metadata (keys) for the order type. -/// UI-specific properties like colors and icons are handled by the presentation layer. -class OrderType extends Equatable { + /// A long-term or permanent staffing position. + permanent, - const OrderType({ - required this.id, - required this.titleKey, - required this.descriptionKey, - }); - /// Unique identifier for the order type. - final String id; + /// Shifts that repeat on a defined schedule. + recurring, - /// Translation key for the title. - final String titleKey; + /// A quickly created shift. + rapid; - /// Translation key for the description. - final String descriptionKey; - - @override - List get props => [id, titleKey, descriptionKey]; + /// Creates an [OrderType] from a string value (typically from the backend). + static OrderType fromString(String value) { + switch (value.toUpperCase()) { + case 'ONE_TIME': + return OrderType.oneTime; + case 'PERMANENT': + return OrderType.permanent; + case 'RECURRING': + return OrderType.recurring; + case 'RAPID': + return OrderType.rapid; + default: + return OrderType.oneTime; + } + } } diff --git a/apps/mobile/packages/domain/lib/src/entities/orders/reorder_data.dart b/apps/mobile/packages/domain/lib/src/entities/orders/reorder_data.dart new file mode 100644 index 00000000..2f325d3a --- /dev/null +++ b/apps/mobile/packages/domain/lib/src/entities/orders/reorder_data.dart @@ -0,0 +1,76 @@ +import 'package:equatable/equatable.dart'; +import 'one_time_order.dart'; +import 'order_type.dart'; + +/// Represents the full details of an order retrieved for reordering. +class ReorderData extends Equatable { + const ReorderData({ + required this.orderId, + required this.orderType, + required this.eventName, + required this.vendorId, + required this.hub, + required this.positions, + this.date, + this.startDate, + this.endDate, + this.recurringDays = const [], + this.permanentDays = const [], + }); + + final String orderId; + final OrderType orderType; + final String eventName; + final String? vendorId; + final OneTimeOrderHubDetails hub; + final List positions; + + // One-time specific + final DateTime? date; + + // Recurring/Permanent specific + final DateTime? startDate; + final DateTime? endDate; + final List recurringDays; + final List permanentDays; + + @override + List get props => [ + orderId, + orderType, + eventName, + vendorId, + hub, + positions, + date, + startDate, + endDate, + recurringDays, + permanentDays, + ]; +} + +class ReorderPosition extends Equatable { + const ReorderPosition({ + required this.roleId, + required this.count, + required this.startTime, + required this.endTime, + this.lunchBreak = 'NO_BREAK', + }); + + final String roleId; + final int count; + final String startTime; + final String endTime; + final String lunchBreak; + + @override + List get props => [ + roleId, + count, + startTime, + endTime, + lunchBreak, + ]; +} diff --git a/apps/mobile/packages/domain/lib/src/entities/shifts/shift.dart b/apps/mobile/packages/domain/lib/src/entities/shifts/shift.dart index 92fec9a0..a6d6fdeb 100644 --- a/apps/mobile/packages/domain/lib/src/entities/shifts/shift.dart +++ b/apps/mobile/packages/domain/lib/src/entities/shifts/shift.dart @@ -34,6 +34,10 @@ class Shift extends Equatable { this.breakInfo, this.orderId, this.orderType, + this.startDate, + this.endDate, + this.recurringDays, + this.permanentDays, this.schedules, }); @@ -68,6 +72,10 @@ class Shift extends Equatable { final Break? breakInfo; final String? orderId; final String? orderType; + final String? startDate; + final String? endDate; + final List? recurringDays; + final List? permanentDays; final List? schedules; @override @@ -103,6 +111,10 @@ class Shift extends Equatable { breakInfo, orderId, orderType, + startDate, + endDate, + recurringDays, + permanentDays, schedules, ]; } diff --git a/apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/get_order_types_usecase.dart b/apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/get_order_types_usecase.dart deleted file mode 100644 index 7fb0cc5a..00000000 --- a/apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/get_order_types_usecase.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:krow_core/core.dart'; -import 'package:krow_domain/krow_domain.dart'; -import '../repositories/client_create_order_repository_interface.dart'; - -/// Use case for retrieving the available order types for a client. -/// -/// This use case fetches the list of supported staffing order types -/// from the [ClientCreateOrderRepositoryInterface]. -class GetOrderTypesUseCase implements NoInputUseCase> { - /// Creates a [GetOrderTypesUseCase]. - /// - /// Requires a [ClientCreateOrderRepositoryInterface] to interact with the data layer. - const GetOrderTypesUseCase(this._repository); - final ClientCreateOrderRepositoryInterface _repository; - - @override - Future> call() { - return _repository.getOrderTypes(); - } -} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/client_create_order_bloc.dart b/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/client_create_order_bloc.dart deleted file mode 100644 index f414d6f4..00000000 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/client_create_order_bloc.dart +++ /dev/null @@ -1,32 +0,0 @@ -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:krow_core/core.dart'; -import 'package:krow_domain/krow_domain.dart'; -import '../../domain/usecases/get_order_types_usecase.dart'; -import 'client_create_order_event.dart'; -import 'client_create_order_state.dart'; - -/// BLoC for managing the list of available order types. -class ClientCreateOrderBloc - extends Bloc - with BlocErrorHandler { - ClientCreateOrderBloc(this._getOrderTypesUseCase) - : super(const ClientCreateOrderInitial()) { - on(_onTypesRequested); - } - final GetOrderTypesUseCase _getOrderTypesUseCase; - - Future _onTypesRequested( - ClientCreateOrderTypesRequested event, - Emitter emit, - ) async { - await handleError( - emit: emit.call, - action: () async { - final List types = await _getOrderTypesUseCase(); - emit(ClientCreateOrderLoadSuccess(types)); - }, - onError: (String errorKey) => ClientCreateOrderLoadFailure(errorKey), - ); - } -} - diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/client_create_order_event.dart b/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/client_create_order_event.dart deleted file mode 100644 index a3328da4..00000000 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/client_create_order_event.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:equatable/equatable.dart'; - -abstract class ClientCreateOrderEvent extends Equatable { - const ClientCreateOrderEvent(); - - @override - List get props => []; -} - -class ClientCreateOrderTypesRequested extends ClientCreateOrderEvent { - const ClientCreateOrderTypesRequested(); -} - -class ClientCreateOrderTypeSelected extends ClientCreateOrderEvent { - const ClientCreateOrderTypeSelected(this.typeId); - final String typeId; - - @override - List get props => [typeId]; -} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/client_create_order_state.dart b/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/client_create_order_state.dart deleted file mode 100644 index 8def2d1b..00000000 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/client_create_order_state.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:equatable/equatable.dart'; -import 'package:krow_domain/krow_domain.dart'; - -/// Base state for the [ClientCreateOrderBloc]. -abstract class ClientCreateOrderState extends Equatable { - const ClientCreateOrderState(); - - @override - List get props => []; -} - -/// Initial state when order types haven't been loaded yet. -class ClientCreateOrderInitial extends ClientCreateOrderState { - const ClientCreateOrderInitial(); -} - -/// State representing successfully loaded order types from the repository. -class ClientCreateOrderLoadSuccess extends ClientCreateOrderState { - const ClientCreateOrderLoadSuccess(this.orderTypes); - - /// The list of available order types retrieved from the domain. - final List orderTypes; - - @override - List get props => [orderTypes]; -} - -/// State representing a failure to load order types. -class ClientCreateOrderLoadFailure extends ClientCreateOrderState { - const ClientCreateOrderLoadFailure(this.error); - - final String error; - - @override - List get props => [error]; -} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/create_order_page.dart b/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/create_order_page.dart deleted file mode 100644 index 641363e2..00000000 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/create_order_page.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_modular/flutter_modular.dart'; -import '../blocs/client_create_order_bloc.dart'; -import '../blocs/client_create_order_event.dart'; -import '../widgets/create_order/create_order_view.dart'; - -/// Main entry page for the client create order flow. -/// -/// This page initializes the [ClientCreateOrderBloc] and displays the [CreateOrderView]. -/// It follows the Krow Clean Architecture by being a [StatelessWidget] and -/// delegating its state and UI to other components. -class ClientCreateOrderPage extends StatelessWidget { - /// Creates a [ClientCreateOrderPage]. - const ClientCreateOrderPage({super.key}); - - @override - Widget build(BuildContext context) { - return BlocProvider( - create: (BuildContext context) => - Modular.get() - ..add(const ClientCreateOrderTypesRequested()), - child: const CreateOrderView(), - ); - } -} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/one_time_order_page.dart b/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/one_time_order_page.dart deleted file mode 100644 index a5c6202f..00000000 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/one_time_order_page.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_modular/flutter_modular.dart'; -import '../blocs/one_time_order_bloc.dart'; -import '../widgets/one_time_order/one_time_order_view.dart'; - -/// Page for creating a one-time staffing order. -/// Users can specify the date, location, and multiple staff positions required. -/// -/// This page initializes the [OneTimeOrderBloc] and displays the [OneTimeOrderView]. -/// It follows the Krow Clean Architecture by being a [StatelessWidget] and -/// delegating its state and UI to other components. -class OneTimeOrderPage extends StatelessWidget { - /// Creates a [OneTimeOrderPage]. - const OneTimeOrderPage({super.key}); - - @override - Widget build(BuildContext context) { - return BlocProvider( - create: (BuildContext context) => Modular.get(), - child: const OneTimeOrderView(), - ); - } -} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/permanent_order_page.dart b/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/permanent_order_page.dart deleted file mode 100644 index cdcc26e3..00000000 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/permanent_order_page.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_modular/flutter_modular.dart'; -import '../blocs/permanent_order_bloc.dart'; -import '../widgets/permanent_order/permanent_order_view.dart'; - -/// Page for creating a permanent staffing order. -class PermanentOrderPage extends StatelessWidget { - /// Creates a [PermanentOrderPage]. - const PermanentOrderPage({super.key}); - - @override - Widget build(BuildContext context) { - return BlocProvider( - create: (BuildContext context) => Modular.get(), - child: const PermanentOrderView(), - ); - } -} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/recurring_order_page.dart b/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/recurring_order_page.dart deleted file mode 100644 index 009c4d64..00000000 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/recurring_order_page.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_modular/flutter_modular.dart'; -import '../blocs/recurring_order_bloc.dart'; -import '../widgets/recurring_order/recurring_order_view.dart'; - -/// Page for creating a recurring staffing order. -class RecurringOrderPage extends StatelessWidget { - /// Creates a [RecurringOrderPage]. - const RecurringOrderPage({super.key}); - - @override - Widget build(BuildContext context) { - return BlocProvider( - create: (BuildContext context) => Modular.get(), - child: const RecurringOrderView(), - ); - } -} 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 deleted file mode 100644 index 43c83549..00000000 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/create_order/create_order_view.dart +++ /dev/null @@ -1,127 +0,0 @@ -import 'package:core_localization/core_localization.dart'; -import 'package:design_system/design_system.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_modular/flutter_modular.dart'; -import 'package:krow_core/core.dart'; -import 'package:krow_domain/krow_domain.dart'; -import '../../blocs/client_create_order_bloc.dart'; -import '../../blocs/client_create_order_state.dart'; -import '../../ui_entities/order_type_ui_metadata.dart'; -import '../order_type_card.dart'; - -/// Helper to map keys to localized strings. -String _getTranslation({required String key}) { - if (key == 'client_create_order.types.rapid') { - return t.client_create_order.types.rapid; - } else if (key == 'client_create_order.types.rapid_desc') { - return t.client_create_order.types.rapid_desc; - } else if (key == 'client_create_order.types.one_time') { - return t.client_create_order.types.one_time; - } else if (key == 'client_create_order.types.one_time_desc') { - return t.client_create_order.types.one_time_desc; - } else if (key == 'client_create_order.types.recurring') { - return t.client_create_order.types.recurring; - } else if (key == 'client_create_order.types.recurring_desc') { - return t.client_create_order.types.recurring_desc; - } else if (key == 'client_create_order.types.permanent') { - return t.client_create_order.types.permanent; - } else if (key == 'client_create_order.types.permanent_desc') { - return t.client_create_order.types.permanent_desc; - } - return key; -} - -/// The main content of the Create Order page. -class CreateOrderView extends StatelessWidget { - /// Creates a [CreateOrderView]. - const CreateOrderView({super.key}); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: UiAppBar( - title: t.client_create_order.title, - onLeadingPressed: () => Modular.to.toClientHome(), - ), - body: SafeArea( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: UiConstants.space5, - vertical: UiConstants.space6, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - 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, - ), - ), - ), - Expanded( - child: BlocBuilder( - builder: - (BuildContext context, ClientCreateOrderState state) { - if (state is ClientCreateOrderLoadSuccess) { - return GridView.builder( - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - mainAxisSpacing: UiConstants.space4, - crossAxisSpacing: UiConstants.space4, - childAspectRatio: 1, - ), - itemCount: state.orderTypes.length, - itemBuilder: (BuildContext context, int index) { - final OrderType type = state.orderTypes[index]; - final OrderTypeUiMetadata ui = - OrderTypeUiMetadata.fromId(id: type.id); - - return OrderTypeCard( - icon: ui.icon, - title: _getTranslation(key: type.titleKey), - description: _getTranslation( - key: type.descriptionKey, - ), - backgroundColor: ui.backgroundColor, - borderColor: ui.borderColor, - iconBackgroundColor: ui.iconBackgroundColor, - iconColor: ui.iconColor, - textColor: ui.textColor, - descriptionColor: ui.descriptionColor, - onTap: () { - switch (type.id) { - case 'rapid': - Modular.to.toCreateOrderRapid(); - break; - case 'one-time': - Modular.to.toCreateOrderOneTime(); - break; - case 'recurring': - Modular.to.toCreateOrderRecurring(); - break; - case 'permanent': - Modular.to.toCreateOrderPermanent(); - break; - } - }, - ); - }, - ); - } - return const Center(child: CircularProgressIndicator()); - }, - ), - ), - ], - ), - ), - ), - ); - } -} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_view.dart b/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_view.dart deleted file mode 100644 index 3ca59a98..00000000 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_view.dart +++ /dev/null @@ -1,328 +0,0 @@ -import 'package:core_localization/core_localization.dart'; -import 'package:design_system/design_system.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_modular/flutter_modular.dart'; -import 'package:krow_core/core.dart'; -import 'package:krow_domain/krow_domain.dart'; -import '../../blocs/one_time_order_bloc.dart'; -import '../../blocs/one_time_order_event.dart'; -import '../../blocs/one_time_order_state.dart'; -import 'one_time_order_date_picker.dart'; -import 'one_time_order_event_name_input.dart'; -import 'one_time_order_header.dart'; -import 'one_time_order_position_card.dart'; -import 'one_time_order_section_header.dart'; -import 'one_time_order_success_view.dart'; - -/// The main content of the One-Time Order page. -class OneTimeOrderView extends StatelessWidget { - /// Creates a [OneTimeOrderView]. - const OneTimeOrderView({super.key}); - - @override - Widget build(BuildContext context) { - final TranslationsClientCreateOrderOneTimeEn labels = - t.client_create_order.one_time; - - return BlocConsumer( - listener: (BuildContext context, OneTimeOrderState state) { - if (state.status == OneTimeOrderStatus.failure && - state.errorMessage != null) { - UiSnackbar.show( - context, - message: translateErrorKey(state.errorMessage!), - type: UiSnackbarType.error, - margin: const EdgeInsets.only(bottom: 140, left: 16, right: 16), - ); - } - }, - builder: (BuildContext context, OneTimeOrderState state) { - if (state.status == OneTimeOrderStatus.success) { - return OneTimeOrderSuccessView( - title: labels.success_title, - message: labels.success_message, - buttonLabel: labels.back_to_orders, - onDone: () => Modular.to.pushNamedAndRemoveUntil( - ClientPaths.orders, - (_) => false, - arguments: { - 'initialDate': state.date.toIso8601String(), - }, - ), - ); - } - - if (state.vendors.isEmpty && - state.status != OneTimeOrderStatus.loading) { - return Scaffold( - body: Column( - children: [ - OneTimeOrderHeader( - title: labels.title, - subtitle: labels.subtitle, - onBack: () => Modular.to.navigate(ClientPaths.createOrder), - ), - Expanded( - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon( - UiIcons.search, - size: 64, - color: UiColors.iconInactive, - ), - const SizedBox(height: UiConstants.space4), - Text( - 'No Vendors Available', - style: UiTypography.headline3m.textPrimary, - ), - const SizedBox(height: UiConstants.space2), - Text( - 'There are no staffing vendors associated with your account.', - style: UiTypography.body2r.textSecondary, - textAlign: TextAlign.center, - ), - ], - ), - ), - ), - ], - ), - ); - } - - return Scaffold( - body: Column( - children: [ - OneTimeOrderHeader( - title: labels.title, - subtitle: labels.subtitle, - onBack: () => Modular.to.navigate(ClientPaths.createOrder), - ), - Expanded( - child: Stack( - children: [ - _OneTimeOrderForm(state: state), - if (state.status == OneTimeOrderStatus.loading) - const Center(child: CircularProgressIndicator()), - ], - ), - ), - _BottomActionButton( - label: state.status == OneTimeOrderStatus.loading - ? labels.creating - : labels.create_order, - isLoading: state.status == OneTimeOrderStatus.loading, - onPressed: state.isValid - ? () => BlocProvider.of( - context, - ).add(const OneTimeOrderSubmitted()) - : null, - ), - ], - ), - ); - }, - ); - } -} - -class _OneTimeOrderForm extends StatelessWidget { - const _OneTimeOrderForm({required this.state}); - final OneTimeOrderState state; - - @override - Widget build(BuildContext context) { - final TranslationsClientCreateOrderOneTimeEn labels = - t.client_create_order.one_time; - - return ListView( - padding: const EdgeInsets.all(UiConstants.space5), - children: [ - Text( - labels.create_your_order, - style: UiTypography.headline3m.textPrimary, - ), - const SizedBox(height: UiConstants.space4), - - OneTimeOrderEventNameInput( - label: 'ORDER NAME', - value: state.eventName, - onChanged: (String value) => BlocProvider.of( - context, - ).add(OneTimeOrderEventNameChanged(value)), - ), - const SizedBox(height: UiConstants.space4), - - // Vendor Selection - Text('SELECT VENDOR', style: UiTypography.footnote2r.textSecondary), - const SizedBox(height: UiConstants.space2), - Container( - padding: const EdgeInsets.symmetric(horizontal: UiConstants.space3), - height: 48, - decoration: BoxDecoration( - color: UiColors.white, - borderRadius: UiConstants.radiusMd, - border: Border.all(color: UiColors.border), - ), - child: DropdownButtonHideUnderline( - child: DropdownButton( - isExpanded: true, - value: state.selectedVendor, - icon: const Icon( - UiIcons.chevronDown, - size: 18, - color: UiColors.iconSecondary, - ), - onChanged: (Vendor? vendor) { - if (vendor != null) { - BlocProvider.of( - context, - ).add(OneTimeOrderVendorChanged(vendor)); - } - }, - items: state.vendors.map((Vendor vendor) { - return DropdownMenuItem( - value: vendor, - child: Text( - vendor.name, - style: UiTypography.body2m.textPrimary, - ), - ); - }).toList(), - ), - ), - ), - const SizedBox(height: UiConstants.space4), - - OneTimeOrderDatePicker( - label: labels.date_label, - value: state.date, - onChanged: (DateTime date) => BlocProvider.of( - context, - ).add(OneTimeOrderDateChanged(date)), - ), - const SizedBox(height: UiConstants.space4), - - Text('HUB', style: UiTypography.footnote2r.textSecondary), - const SizedBox(height: UiConstants.space2), - Container( - padding: const EdgeInsets.symmetric(horizontal: UiConstants.space3), - height: 48, - decoration: BoxDecoration( - color: UiColors.white, - borderRadius: UiConstants.radiusMd, - border: Border.all(color: UiColors.border), - ), - child: DropdownButtonHideUnderline( - child: DropdownButton( - isExpanded: true, - value: state.selectedHub, - icon: const Icon( - UiIcons.chevronDown, - size: 18, - color: UiColors.iconSecondary, - ), - onChanged: (OneTimeOrderHubOption? hub) { - if (hub != null) { - BlocProvider.of( - context, - ).add(OneTimeOrderHubChanged(hub)); - } - }, - items: state.hubs.map((OneTimeOrderHubOption hub) { - return DropdownMenuItem( - value: hub, - child: Text( - hub.name, - style: UiTypography.body2m.textPrimary, - ), - ); - }).toList(), - ), - ), - ), - const SizedBox(height: UiConstants.space6), - - OneTimeOrderSectionHeader( - title: labels.positions_title, - actionLabel: labels.add_position, - onAction: () => BlocProvider.of( - context, - ).add(const OneTimeOrderPositionAdded()), - ), - const SizedBox(height: UiConstants.space3), - - // Positions List - ...state.positions.asMap().entries.map(( - MapEntry entry, - ) { - final int index = entry.key; - final OneTimeOrderPosition position = entry.value; - return Padding( - padding: const EdgeInsets.only(bottom: UiConstants.space3), - child: OneTimeOrderPositionCard( - index: index, - position: position, - isRemovable: state.positions.length > 1, - positionLabel: labels.positions_title, - roleLabel: labels.select_role, - workersLabel: labels.workers_label, - startLabel: labels.start_label, - endLabel: labels.end_label, - lunchLabel: labels.lunch_break_label, - roles: state.roles, - onUpdated: (OneTimeOrderPosition updated) { - BlocProvider.of( - context, - ).add(OneTimeOrderPositionUpdated(index, updated)); - }, - onRemoved: () { - BlocProvider.of( - context, - ).add(OneTimeOrderPositionRemoved(index)); - }, - ), - ); - }), - ], - ); - } -} - -class _BottomActionButton extends StatelessWidget { - const _BottomActionButton({ - required this.label, - required this.onPressed, - this.isLoading = false, - }); - final String label; - final VoidCallback? onPressed; - final bool isLoading; - - @override - Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.only( - left: UiConstants.space5, - right: UiConstants.space5, - top: UiConstants.space5, - bottom: MediaQuery.of(context).padding.bottom + UiConstants.space5, - ), - decoration: const BoxDecoration( - color: UiColors.white, - border: Border(top: BorderSide(color: UiColors.border)), - ), - child: SizedBox( - width: double.infinity, - child: UiButton.primary( - text: label, - onPressed: isLoading ? null : onPressed, - size: UiButtonSize.large, - ), - ), - ); - } -} diff --git a/apps/mobile/packages/features/client/home/lib/src/data/repositories_impl/home_repository_impl.dart b/apps/mobile/packages/features/client/home/lib/src/data/repositories_impl/home_repository_impl.dart index b477dfd3..11f15feb 100644 --- a/apps/mobile/packages/features/client/home/lib/src/data/repositories_impl/home_repository_impl.dart +++ b/apps/mobile/packages/features/client/home/lib/src/data/repositories_impl/home_repository_impl.dart @@ -1,28 +1,100 @@ -// ignore_for_file: always_specify_types, depend_on_referenced_packages, dead_code, dead_null_aware_expression, unused_local_variable, unused_import, sort_constructors_first, prefer_final_fields, prefer_const_constructors, deprecated_member_use, implicit_call_tearoffs -import 'package:firebase_data_connect/src/core/ref.dart'; +import 'package:firebase_data_connect/firebase_data_connect.dart'; import 'package:krow_data_connect/krow_data_connect.dart' as dc; import 'package:krow_domain/krow_domain.dart'; import '../../domain/repositories/home_repository_interface.dart'; -/// Implementation of [HomeRepositoryInterface] that delegates to [dc.HomeConnectorRepository]. -/// -/// This implementation follows the "Buffer Layer" pattern by using a dedicated -/// connector repository from the data_connect package. +/// Implementation of [HomeRepositoryInterface] that directly interacts with the Data Connect SDK. class HomeRepositoryImpl implements HomeRepositoryInterface { + HomeRepositoryImpl({dc.DataConnectService? service}) + : _service = service ?? dc.DataConnectService.instance; - HomeRepositoryImpl({ - dc.HomeConnectorRepository? connectorRepository, - dc.DataConnectService? service, - }) : _connectorRepository = connectorRepository ?? - dc.DataConnectService.instance.getHomeRepository(), - _service = service ?? dc.DataConnectService.instance; - final dc.HomeConnectorRepository _connectorRepository; final dc.DataConnectService _service; @override Future getDashboardData() async { - final String businessId = await _service.getBusinessId(); - return _connectorRepository.getDashboardData(businessId: businessId); + return _service.run(() async { + final String businessId = await _service.getBusinessId(); + final DateTime now = DateTime.now(); + final int daysFromMonday = now.weekday - DateTime.monday; + final DateTime monday = DateTime( + now.year, + now.month, + now.day, + ).subtract(Duration(days: daysFromMonday)); + final DateTime weekRangeStart = monday; + final DateTime weekRangeEnd = monday.add( + const Duration(days: 13, hours: 23, minutes: 59, seconds: 59), + ); + + final QueryResult< + dc.GetCompletedShiftsByBusinessIdData, + dc.GetCompletedShiftsByBusinessIdVariables + > + completedResult = await _service.connector + .getCompletedShiftsByBusinessId( + businessId: businessId, + dateFrom: _service.toTimestamp(weekRangeStart), + dateTo: _service.toTimestamp(weekRangeEnd), + ) + .execute(); + + double weeklySpending = 0.0; + double next7DaysSpending = 0.0; + int weeklyShifts = 0; + int next7DaysScheduled = 0; + + for (final dc.GetCompletedShiftsByBusinessIdShifts shift + in completedResult.data.shifts) { + final DateTime? shiftDate = _service.toDateTime(shift.date); + if (shiftDate == null) continue; + + final int offset = shiftDate.difference(weekRangeStart).inDays; + if (offset < 0 || offset > 13) continue; + + final double cost = shift.cost ?? 0.0; + if (offset <= 6) { + weeklySpending += cost; + weeklyShifts += 1; + } else { + next7DaysSpending += cost; + next7DaysScheduled += 1; + } + } + + final DateTime start = DateTime(now.year, now.month, now.day); + final DateTime end = start.add( + const Duration(hours: 23, minutes: 59, seconds: 59), + ); + + final QueryResult< + dc.ListShiftRolesByBusinessAndDateRangeData, + dc.ListShiftRolesByBusinessAndDateRangeVariables + > + result = await _service.connector + .listShiftRolesByBusinessAndDateRange( + businessId: businessId, + start: _service.toTimestamp(start), + end: _service.toTimestamp(end), + ) + .execute(); + + int totalNeeded = 0; + int totalFilled = 0; + for (final dc.ListShiftRolesByBusinessAndDateRangeShiftRoles shiftRole + in result.data.shiftRoles) { + totalNeeded += shiftRole.count; + totalFilled += shiftRole.assigned ?? 0; + } + + return HomeDashboardData( + weeklySpending: weeklySpending, + next7DaysSpending: next7DaysSpending, + weeklyShifts: weeklyShifts, + next7DaysScheduled: next7DaysScheduled, + totalNeeded: totalNeeded, + totalFilled: totalFilled, + ); + }); } @override @@ -39,7 +111,8 @@ class HomeRepositoryImpl implements HomeRepositoryInterface { return await _service.run(() async { final String businessId = await _service.getBusinessId(); - final QueryResult businessResult = await _service.connector + final QueryResult + businessResult = await _service.connector .getBusinessById(id: businessId) .execute(); @@ -69,8 +142,67 @@ class HomeRepositoryImpl implements HomeRepositoryInterface { @override Future> getRecentReorders() async { - final String businessId = await _service.getBusinessId(); - return _connectorRepository.getRecentReorders(businessId: businessId); + return _service.run(() async { + final String businessId = await _service.getBusinessId(); + final DateTime now = DateTime.now(); + final DateTime start = now.subtract(const Duration(days: 30)); + + final QueryResult< + dc.ListCompletedOrdersByBusinessAndDateRangeData, + dc.ListCompletedOrdersByBusinessAndDateRangeVariables + > + result = await _service.connector + .listCompletedOrdersByBusinessAndDateRange( + businessId: businessId, + start: _service.toTimestamp(start), + end: _service.toTimestamp(now), + ) + .execute(); + + return result.data.orders.map(( + dc.ListCompletedOrdersByBusinessAndDateRangeOrders order, + ) { + final String title = + order.eventName ?? + (order.shifts_on_order.isNotEmpty + ? order.shifts_on_order[0].title + : 'Order'); + + final String location = order.shifts_on_order.isNotEmpty + ? (order.shifts_on_order[0].location ?? + order.shifts_on_order[0].locationAddress ?? + '') + : ''; + + int totalWorkers = 0; + double totalHours = 0; + double totalRate = 0; + int roleCount = 0; + + for (final dc.ListCompletedOrdersByBusinessAndDateRangeOrdersShiftsOnOrder + shift + in order.shifts_on_order) { + for (final dc.ListCompletedOrdersByBusinessAndDateRangeOrdersShiftsOnOrderShiftRolesOnShift + role + in shift.shiftRoles_on_shift) { + totalWorkers += role.count; + totalHours += role.hours ?? 0; + totalRate += role.role.costPerHour; + roleCount++; + } + } + + return ReorderItem( + orderId: order.id, + title: title, + location: location, + totalCost: order.total ?? 0.0, + workers: totalWorkers, + type: order.orderType.stringValue, + hourlyRate: roleCount > 0 ? totalRate / roleCount : 0.0, + hours: totalHours, + ); + }).toList(); + }); } } - diff --git a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/actions_widget.dart b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/actions_widget.dart index 3af93fc3..0b7eb44b 100644 --- a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/actions_widget.dart +++ b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/actions_widget.dart @@ -1,22 +1,13 @@ import 'package:core_localization/core_localization.dart'; import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_modular/flutter_modular.dart'; +import 'package:krow_core/core.dart'; /// A widget that displays quick actions for the client. class ActionsWidget extends StatelessWidget { /// Creates an [ActionsWidget]. - const ActionsWidget({ - super.key, - required this.onRapidPressed, - required this.onCreateOrderPressed, - this.subtitle, - }); - - /// Callback when RAPID is pressed. - final VoidCallback onRapidPressed; - - /// Callback when Create Order is pressed. - final VoidCallback onCreateOrderPressed; + const ActionsWidget({super.key, this.subtitle}); /// Optional subtitle for the section. final String? subtitle; @@ -40,7 +31,7 @@ class ActionsWidget extends StatelessWidget { iconColor: UiColors.textError, textColor: UiColors.textError, subtitleColor: UiColors.textError.withValues(alpha: 0.8), - onTap: onRapidPressed, + onTap: () => Modular.to.toCreateOrderRapid(), ), ), Expanded( @@ -54,7 +45,7 @@ class ActionsWidget extends StatelessWidget { iconColor: UiColors.primary, textColor: UiColors.textPrimary, subtitleColor: UiColors.textSecondary, - onTap: onCreateOrderPressed, + onTap: () => Modular.to.toCreateOrder(), ), ), ], diff --git a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/dashboard_widget_builder.dart b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/dashboard_widget_builder.dart index 0964f2ee..296b04d8 100644 --- a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/dashboard_widget_builder.dart +++ b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/dashboard_widget_builder.dart @@ -9,14 +9,12 @@ import '../widgets/draggable_widget_wrapper.dart'; import '../widgets/live_activity_widget.dart'; import '../widgets/reorder_widget.dart'; import '../widgets/spending_widget.dart'; -import 'client_home_sheets.dart'; /// A widget that builds dashboard content based on widget ID. /// /// This widget encapsulates the logic for rendering different dashboard /// widgets based on their unique identifiers and current state. class DashboardWidgetBuilder extends StatelessWidget { - /// Creates a [DashboardWidgetBuilder]. const DashboardWidgetBuilder({ required this.id, @@ -24,6 +22,7 @@ class DashboardWidgetBuilder extends StatelessWidget { required this.isEditMode, super.key, }); + /// The unique identifier for the widget to build. final String id; @@ -62,39 +61,9 @@ class DashboardWidgetBuilder extends StatelessWidget { switch (id) { case 'actions': - return ActionsWidget( - onRapidPressed: () => Modular.to.toCreateOrderRapid(), - onCreateOrderPressed: () => Modular.to.toCreateOrder(), - subtitle: subtitle, - ); + return ActionsWidget(subtitle: subtitle); case 'reorder': - return ReorderWidget( - orders: state.reorderItems, - onReorderPressed: (Map data) { - ClientHomeSheets.showOrderFormSheet( - context, - data, - onSubmit: (Map submittedData) { - final String? dateStr = - submittedData['date']?.toString(); - if (dateStr == null || dateStr.isEmpty) { - return; - } - final DateTime? initialDate = DateTime.tryParse(dateStr); - if (initialDate == null) { - return; - } - Modular.to.navigate( - ClientPaths.orders, - arguments: { - 'initialDate': initialDate.toIso8601String(), - }, - ); - }, - ); - }, - subtitle: subtitle, - ); + return ReorderWidget(orders: state.reorderItems, subtitle: subtitle); case 'spending': return SpendingWidget( weeklySpending: state.dashboardData.weeklySpending, diff --git a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/reorder_widget.dart b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/reorder_widget.dart index b3544e48..fb1da7d5 100644 --- a/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/reorder_widget.dart +++ b/apps/mobile/packages/features/client/home/lib/src/presentation/widgets/reorder_widget.dart @@ -1,24 +1,18 @@ import 'package:core_localization/core_localization.dart'; import 'package:design_system/design_system.dart'; 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'; /// A widget that allows clients to reorder recent shifts. class ReorderWidget extends StatelessWidget { - /// Creates a [ReorderWidget]. - const ReorderWidget({ - super.key, - required this.orders, - required this.onReorderPressed, - this.subtitle, - }); + const ReorderWidget({super.key, required this.orders, this.subtitle}); + /// Recent completed orders for reorder. final List orders; - /// Callback when a reorder button is pressed. - final Function(Map shiftData) onReorderPressed; - /// Optional subtitle for the section. final String? subtitle; @@ -55,8 +49,7 @@ class ReorderWidget extends StatelessWidget { const SizedBox(width: UiConstants.space3), itemBuilder: (BuildContext context, int index) { final ReorderItem order = recentOrders[index]; - final double totalCost = - order.hourlyRate * order.hours * order.workers; + final double totalCost = order.totalCost; return Container( width: 260, @@ -155,15 +148,17 @@ class ReorderWidget extends StatelessWidget { leadingIcon: UiIcons.zap, iconSize: 12, fullWidth: true, - onPressed: () => onReorderPressed({ - 'orderId': order.orderId, - 'title': order.title, - 'location': order.location, - 'hourlyRate': order.hourlyRate, - 'hours': order.hours, - 'workers': order.workers, - 'type': order.type, - }), + onPressed: () => + _handleReorderPressed(context, { + 'orderId': order.orderId, + 'title': order.title, + 'location': order.location, + 'hourlyRate': order.hourlyRate, + 'hours': order.hours, + 'workers': order.workers, + 'type': order.type, + 'totalCost': order.totalCost, + }), ), ], ), @@ -174,10 +169,34 @@ class ReorderWidget extends StatelessWidget { ], ); } + + void _handleReorderPressed(BuildContext context, Map data) { + // Override start date with today's date as requested + final Map populatedData = Map.from(data) + ..['startDate'] = DateTime.now(); + + final String? typeStr = populatedData['type']?.toString(); + if (typeStr == null || typeStr.isEmpty) { + return; + } + + final OrderType orderType = OrderType.fromString(typeStr); + switch (orderType) { + case OrderType.recurring: + Modular.to.toCreateOrderRecurring(arguments: populatedData); + break; + case OrderType.permanent: + Modular.to.toCreateOrderPermanent(arguments: populatedData); + break; + case OrderType.oneTime: + default: + Modular.to.toCreateOrderOneTime(arguments: populatedData); + break; + } + } } class _Badge extends StatelessWidget { - const _Badge({ required this.icon, required this.text, diff --git a/apps/mobile/packages/features/client/create_order/lib/client_create_order.dart b/apps/mobile/packages/features/client/orders/create_order/lib/client_create_order.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/client_create_order.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/client_create_order.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/create_order_module.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/create_order_module.dart similarity index 71% rename from apps/mobile/packages/features/client/create_order/lib/src/create_order_module.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/create_order_module.dart index a99521d6..e459dd35 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/create_order_module.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/create_order_module.dart @@ -8,12 +8,8 @@ import 'domain/usecases/create_one_time_order_usecase.dart'; import 'domain/usecases/create_permanent_order_usecase.dart'; import 'domain/usecases/create_recurring_order_usecase.dart'; import 'domain/usecases/create_rapid_order_usecase.dart'; -import 'domain/usecases/get_order_types_usecase.dart'; -import 'presentation/blocs/client_create_order_bloc.dart'; -import 'presentation/blocs/one_time_order_bloc.dart'; -import 'presentation/blocs/permanent_order_bloc.dart'; -import 'presentation/blocs/recurring_order_bloc.dart'; -import 'presentation/blocs/rapid_order_bloc.dart'; +import 'domain/usecases/get_order_details_for_reorder_usecase.dart'; +import 'presentation/blocs/index.dart'; import 'presentation/pages/create_order_page.dart'; import 'presentation/pages/one_time_order_page.dart'; import 'presentation/pages/permanent_order_page.dart'; @@ -32,17 +28,18 @@ class ClientCreateOrderModule extends Module { @override void binds(Injector i) { // Repositories - i.addLazySingleton(ClientCreateOrderRepositoryImpl.new); + i.addLazySingleton( + ClientCreateOrderRepositoryImpl.new, + ); // UseCases - i.addLazySingleton(GetOrderTypesUseCase.new); i.addLazySingleton(CreateOneTimeOrderUseCase.new); i.addLazySingleton(CreatePermanentOrderUseCase.new); i.addLazySingleton(CreateRecurringOrderUseCase.new); i.addLazySingleton(CreateRapidOrderUseCase.new); + i.addLazySingleton(GetOrderDetailsForReorderUseCase.new); // BLoCs - i.add(ClientCreateOrderBloc.new); i.add(RapidOrderBloc.new); i.add(OneTimeOrderBloc.new); i.add(PermanentOrderBloc.new); @@ -56,19 +53,31 @@ class ClientCreateOrderModule extends Module { child: (BuildContext context) => const ClientCreateOrderPage(), ); r.child( - ClientPaths.childRoute(ClientPaths.createOrder, ClientPaths.createOrderRapid), + ClientPaths.childRoute( + ClientPaths.createOrder, + ClientPaths.createOrderRapid, + ), child: (BuildContext context) => const RapidOrderPage(), ); r.child( - ClientPaths.childRoute(ClientPaths.createOrder, ClientPaths.createOrderOneTime), + ClientPaths.childRoute( + ClientPaths.createOrder, + ClientPaths.createOrderOneTime, + ), child: (BuildContext context) => const OneTimeOrderPage(), ); r.child( - ClientPaths.childRoute(ClientPaths.createOrder, ClientPaths.createOrderRecurring), + ClientPaths.childRoute( + ClientPaths.createOrder, + ClientPaths.createOrderRecurring, + ), child: (BuildContext context) => const RecurringOrderPage(), ); r.child( - ClientPaths.childRoute(ClientPaths.createOrder, ClientPaths.createOrderPermanent), + ClientPaths.childRoute( + ClientPaths.createOrder, + ClientPaths.createOrderPermanent, + ), child: (BuildContext context) => const PermanentOrderPage(), ); } diff --git a/apps/mobile/packages/features/client/create_order/lib/src/data/repositories_impl/client_create_order_repository_impl.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/data/repositories_impl/client_create_order_repository_impl.dart similarity index 56% rename from apps/mobile/packages/features/client/create_order/lib/src/data/repositories_impl/client_create_order_repository_impl.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/data/repositories_impl/client_create_order_repository_impl.dart index 221a07a3..aea8a443 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/data/repositories_impl/client_create_order_repository_impl.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/data/repositories_impl/client_create_order_repository_impl.dart @@ -1,4 +1,4 @@ -import 'package:firebase_data_connect/firebase_data_connect.dart' as fdc; +import 'package:firebase_data_connect/firebase_data_connect.dart'; import 'package:intl/intl.dart'; import 'package:krow_data_connect/krow_data_connect.dart' as dc; import 'package:krow_domain/krow_domain.dart' as domain; @@ -11,46 +11,13 @@ import '../../domain/repositories/client_create_order_repository_interface.dart' /// /// It follows the KROW Clean Architecture by keeping the data layer focused /// on delegation and data mapping, without business logic. -class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInterface { - ClientCreateOrderRepositoryImpl({ - required dc.DataConnectService service, - }) : _service = service; +class ClientCreateOrderRepositoryImpl + implements ClientCreateOrderRepositoryInterface { + ClientCreateOrderRepositoryImpl({required dc.DataConnectService service}) + : _service = service; final dc.DataConnectService _service; - @override - Future> getOrderTypes() { - return Future>.value(const [ - 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 - // domain.OrderType( - // id: 'rapid', - // titleKey: 'client_create_order.types.rapid', - // descriptionKey: 'client_create_order.types.rapid_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', - descriptionKey: 'client_create_order.types.permanent_desc', - ), - ]); - } - @override Future createOneTimeOrder(domain.OneTimeOrder order) async { return _service.run(() async { @@ -69,19 +36,19 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte order.date.month, order.date.day, ); - final fdc.Timestamp orderTimestamp = _service.toTimestamp(orderDateOnly); - final fdc.OperationResult orderResult = - await _service.connector - .createOrder( - businessId: businessId, - orderType: dc.OrderType.ONE_TIME, - teamHubId: hub.id, - ) - .vendorId(vendorId) - .eventName(order.eventName) - .status(dc.OrderStatus.POSTED) - .date(orderTimestamp) - .execute(); + final Timestamp orderTimestamp = _service.toTimestamp(orderDateOnly); + final OperationResult + orderResult = await _service.connector + .createOrder( + businessId: businessId, + orderType: dc.OrderType.ONE_TIME, + teamHubId: hub.id, + ) + .vendorId(vendorId) + .eventName(order.eventName) + .status(dc.OrderStatus.POSTED) + .date(orderTimestamp) + .execute(); final String orderId = orderResult.data.order_insert.id; @@ -92,32 +59,34 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte final String shiftTitle = 'Shift 1 ${_formatDate(order.date)}'; final double shiftCost = _calculateShiftCost(order); - final fdc.OperationResult shiftResult = - await _service.connector - .createShift(title: shiftTitle, orderId: orderId) - .date(orderTimestamp) - .location(hub.name) - .locationAddress(hub.address) - .latitude(hub.latitude) - .longitude(hub.longitude) - .placeId(hub.placeId) - .city(hub.city) - .state(hub.state) - .street(hub.street) - .country(hub.country) - .status(dc.ShiftStatus.OPEN) - .workersNeeded(workersNeeded) - .filled(0) - .durationDays(1) - .cost(shiftCost) - .execute(); + final OperationResult + shiftResult = await _service.connector + .createShift(title: shiftTitle, orderId: orderId) + .date(orderTimestamp) + .location(hub.name) + .locationAddress(hub.address) + .latitude(hub.latitude) + .longitude(hub.longitude) + .placeId(hub.placeId) + .city(hub.city) + .state(hub.state) + .street(hub.street) + .country(hub.country) + .status(dc.ShiftStatus.OPEN) + .workersNeeded(workersNeeded) + .filled(0) + .durationDays(1) + .cost(shiftCost) + .execute(); final String shiftId = shiftResult.data.shift_insert.id; for (final domain.OneTimeOrderPosition position in order.positions) { final DateTime start = _parseTime(order.date, position.startTime); final DateTime end = _parseTime(order.date, position.endTime); - final DateTime normalizedEnd = end.isBefore(start) ? end.add(const Duration(days: 1)) : end; + final DateTime normalizedEnd = end.isBefore(start) + ? end.add(const Duration(days: 1)) + : end; final double hours = normalizedEnd.difference(start).inMinutes / 60.0; final double rate = order.roleRates[position.role] ?? 0; final double totalValue = rate * hours * position.count; @@ -139,7 +108,7 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte await _service.connector .updateOrder(id: orderId, teamHubId: hub.id) - .shifts(fdc.AnyValue([shiftId])) + .shifts(AnyValue([shiftId])) .execute(); }); } @@ -162,74 +131,78 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte order.startDate.month, order.startDate.day, ); - final fdc.Timestamp orderTimestamp = _service.toTimestamp(orderDateOnly); - final fdc.Timestamp startTimestamp = orderTimestamp; - final fdc.Timestamp endTimestamp = _service.toTimestamp(order.endDate); + final Timestamp orderTimestamp = _service.toTimestamp(orderDateOnly); + final Timestamp startTimestamp = _service.toTimestamp(order.startDate); + final Timestamp endTimestamp = _service.toTimestamp(order.endDate); - final fdc.OperationResult orderResult = - await _service.connector - .createOrder( - businessId: businessId, - orderType: dc.OrderType.RECURRING, - teamHubId: hub.id, - ) - .vendorId(vendorId) - .eventName(order.eventName) - .status(dc.OrderStatus.POSTED) - .date(orderTimestamp) - .startDate(startTimestamp) - .endDate(endTimestamp) - .recurringDays(order.recurringDays) - .execute(); + final OperationResult + orderResult = await _service.connector + .createOrder( + businessId: businessId, + orderType: dc.OrderType.RECURRING, + teamHubId: hub.id, + ) + .vendorId(vendorId) + .eventName(order.eventName) + .status(dc.OrderStatus.POSTED) + .date(orderTimestamp) + .startDate(startTimestamp) + .endDate(endTimestamp) + .recurringDays(order.recurringDays) + .execute(); final String orderId = orderResult.data.order_insert.id; // NOTE: Recurring orders are limited to 30 days of generated shifts. // Future shifts beyond 30 days should be created by a scheduled job. final DateTime maxEndDate = orderDateOnly.add(const Duration(days: 29)); - final DateTime effectiveEndDate = - order.endDate.isAfter(maxEndDate) ? maxEndDate : order.endDate; + final DateTime effectiveEndDate = order.endDate.isAfter(maxEndDate) + ? maxEndDate + : order.endDate; final Set selectedDays = Set.from(order.recurringDays); final int workersNeeded = order.positions.fold( 0, - (int sum, domain.RecurringOrderPosition position) => sum + position.count, + (int sum, domain.RecurringOrderPosition position) => + sum + position.count, ); final double shiftCost = _calculateRecurringShiftCost(order); final List shiftIds = []; - for (DateTime day = orderDateOnly; - !day.isAfter(effectiveEndDate); - day = day.add(const Duration(days: 1))) { + for ( + DateTime day = orderDateOnly; + !day.isAfter(effectiveEndDate); + day = day.add(const Duration(days: 1)) + ) { final String dayLabel = _weekdayLabel(day); if (!selectedDays.contains(dayLabel)) { continue; } final String shiftTitle = 'Shift ${_formatDate(day)}'; - final fdc.Timestamp dayTimestamp = _service.toTimestamp( + final Timestamp dayTimestamp = _service.toTimestamp( DateTime(day.year, day.month, day.day), ); - final fdc.OperationResult shiftResult = - await _service.connector - .createShift(title: shiftTitle, orderId: orderId) - .date(dayTimestamp) - .location(hub.name) - .locationAddress(hub.address) - .latitude(hub.latitude) - .longitude(hub.longitude) - .placeId(hub.placeId) - .city(hub.city) - .state(hub.state) - .street(hub.street) - .country(hub.country) - .status(dc.ShiftStatus.OPEN) - .workersNeeded(workersNeeded) - .filled(0) - .durationDays(1) - .cost(shiftCost) - .execute(); + final OperationResult + shiftResult = await _service.connector + .createShift(title: shiftTitle, orderId: orderId) + .date(dayTimestamp) + .location(hub.name) + .locationAddress(hub.address) + .latitude(hub.latitude) + .longitude(hub.longitude) + .placeId(hub.placeId) + .city(hub.city) + .state(hub.state) + .street(hub.street) + .country(hub.country) + .status(dc.ShiftStatus.OPEN) + .workersNeeded(workersNeeded) + .filled(0) + .durationDays(1) + .cost(shiftCost) + .execute(); final String shiftId = shiftResult.data.shift_insert.id; shiftIds.add(shiftId); @@ -237,8 +210,9 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte for (final domain.RecurringOrderPosition position in order.positions) { final DateTime start = _parseTime(day, position.startTime); final DateTime end = _parseTime(day, position.endTime); - final DateTime normalizedEnd = - end.isBefore(start) ? end.add(const Duration(days: 1)) : end; + final DateTime normalizedEnd = end.isBefore(start) + ? end.add(const Duration(days: 1)) + : end; final double hours = normalizedEnd.difference(start).inMinutes / 60.0; final double rate = order.roleRates[position.role] ?? 0; final double totalValue = rate * hours * position.count; @@ -261,7 +235,7 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte await _service.connector .updateOrder(id: orderId, teamHubId: hub.id) - .shifts(fdc.AnyValue(shiftIds)) + .shifts(AnyValue(shiftIds)) .execute(); }); } @@ -284,23 +258,23 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte order.startDate.month, order.startDate.day, ); - final fdc.Timestamp orderTimestamp = _service.toTimestamp(orderDateOnly); - final fdc.Timestamp startTimestamp = orderTimestamp; + final Timestamp orderTimestamp = _service.toTimestamp(orderDateOnly); + final Timestamp startTimestamp = _service.toTimestamp(order.startDate); - final fdc.OperationResult orderResult = - await _service.connector - .createOrder( - businessId: businessId, - orderType: dc.OrderType.PERMANENT, - teamHubId: hub.id, - ) - .vendorId(vendorId) - .eventName(order.eventName) - .status(dc.OrderStatus.POSTED) - .date(orderTimestamp) - .startDate(startTimestamp) - .permanentDays(order.permanentDays) - .execute(); + final OperationResult + orderResult = await _service.connector + .createOrder( + businessId: businessId, + orderType: dc.OrderType.PERMANENT, + teamHubId: hub.id, + ) + .vendorId(vendorId) + .eventName(order.eventName) + .status(dc.OrderStatus.POSTED) + .date(orderTimestamp) + .startDate(startTimestamp) + .permanentDays(order.permanentDays) + .execute(); final String orderId = orderResult.data.order_insert.id; @@ -316,38 +290,40 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte final double shiftCost = _calculatePermanentShiftCost(order); final List shiftIds = []; - for (DateTime day = orderDateOnly; - !day.isAfter(maxEndDate); - day = day.add(const Duration(days: 1))) { + for ( + DateTime day = orderDateOnly; + !day.isAfter(maxEndDate); + day = day.add(const Duration(days: 1)) + ) { final String dayLabel = _weekdayLabel(day); if (!selectedDays.contains(dayLabel)) { continue; } final String shiftTitle = 'Shift ${_formatDate(day)}'; - final fdc.Timestamp dayTimestamp = _service.toTimestamp( + final Timestamp dayTimestamp = _service.toTimestamp( DateTime(day.year, day.month, day.day), ); - final fdc.OperationResult shiftResult = - await _service.connector - .createShift(title: shiftTitle, orderId: orderId) - .date(dayTimestamp) - .location(hub.name) - .locationAddress(hub.address) - .latitude(hub.latitude) - .longitude(hub.longitude) - .placeId(hub.placeId) - .city(hub.city) - .state(hub.state) - .street(hub.street) - .country(hub.country) - .status(dc.ShiftStatus.OPEN) - .workersNeeded(workersNeeded) - .filled(0) - .durationDays(1) - .cost(shiftCost) - .execute(); + final OperationResult + shiftResult = await _service.connector + .createShift(title: shiftTitle, orderId: orderId) + .date(dayTimestamp) + .location(hub.name) + .locationAddress(hub.address) + .latitude(hub.latitude) + .longitude(hub.longitude) + .placeId(hub.placeId) + .city(hub.city) + .state(hub.state) + .street(hub.street) + .country(hub.country) + .status(dc.ShiftStatus.OPEN) + .workersNeeded(workersNeeded) + .filled(0) + .durationDays(1) + .cost(shiftCost) + .execute(); final String shiftId = shiftResult.data.shift_insert.id; shiftIds.add(shiftId); @@ -355,8 +331,9 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte for (final domain.OneTimeOrderPosition position in order.positions) { final DateTime start = _parseTime(day, position.startTime); final DateTime end = _parseTime(day, position.endTime); - final DateTime normalizedEnd = - end.isBefore(start) ? end.add(const Duration(days: 1)) : end; + final DateTime normalizedEnd = end.isBefore(start) + ? end.add(const Duration(days: 1)) + : end; final double hours = normalizedEnd.difference(start).inMinutes / 60.0; final double rate = order.roleRates[position.role] ?? 0; final double totalValue = rate * hours * position.count; @@ -379,7 +356,7 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte await _service.connector .updateOrder(id: orderId, teamHubId: hub.id) - .shifts(fdc.AnyValue(shiftIds)) + .shifts(AnyValue(shiftIds)) .execute(); }); } @@ -396,13 +373,76 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte throw UnimplementedError('Reorder functionality is not yet implemented.'); } + @override + Future getOrderDetailsForReorder(String orderId) async { + return _service.run(() async { + final String businessId = await _service.getBusinessId(); + final QueryResult< + dc.ListShiftRolesByBusinessAndOrderData, + dc.ListShiftRolesByBusinessAndOrderVariables + > + result = await _service.connector + .listShiftRolesByBusinessAndOrder( + businessId: businessId, + orderId: orderId, + ) + .execute(); + + final List shiftRoles = + result.data.shiftRoles; + + if (shiftRoles.isEmpty) { + throw Exception('Order not found or has no roles.'); + } + + final dc.ListShiftRolesByBusinessAndOrderShiftRolesShiftOrder order = + shiftRoles.first.shift.order; + + final domain.OrderType orderType = _mapOrderType(order.orderType); + + final dc.ListShiftRolesByBusinessAndOrderShiftRolesShiftOrderTeamHub + teamHub = order.teamHub; + + return domain.ReorderData( + orderId: orderId, + eventName: order.eventName ?? '', + vendorId: order.vendorId ?? '', + orderType: orderType, + hub: domain.OneTimeOrderHubDetails( + id: teamHub.id, + name: teamHub.hubName, + address: teamHub.address, + placeId: teamHub.placeId, + latitude: 0, // Not available in this query + longitude: 0, + ), + positions: shiftRoles.map(( + dc.ListShiftRolesByBusinessAndOrderShiftRoles role, + ) { + return domain.ReorderPosition( + roleId: role.roleId, + count: role.count, + startTime: _formatTimestamp(role.startTime), + endTime: _formatTimestamp(role.endTime), + lunchBreak: _formatBreakDuration(role.breakType), + ); + }).toList(), + startDate: order.startDate?.toDateTime(), + endDate: order.endDate?.toDateTime(), + recurringDays: order.recurringDays ?? const [], + permanentDays: order.permanentDays ?? const [], + ); + }); + } + double _calculateShiftCost(domain.OneTimeOrder order) { double total = 0; for (final domain.OneTimeOrderPosition position in order.positions) { final DateTime start = _parseTime(order.date, position.startTime); final DateTime end = _parseTime(order.date, position.endTime); - final DateTime normalizedEnd = - end.isBefore(start) ? end.add(const Duration(days: 1)) : end; + final DateTime normalizedEnd = end.isBefore(start) + ? end.add(const Duration(days: 1)) + : end; final double hours = normalizedEnd.difference(start).inMinutes / 60.0; final double rate = order.roleRates[position.role] ?? 0; total += rate * hours * position.count; @@ -415,8 +455,9 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte for (final domain.RecurringOrderPosition position in order.positions) { final DateTime start = _parseTime(order.startDate, position.startTime); final DateTime end = _parseTime(order.startDate, position.endTime); - final DateTime normalizedEnd = - end.isBefore(start) ? end.add(const Duration(days: 1)) : end; + final DateTime normalizedEnd = end.isBefore(start) + ? end.add(const Duration(days: 1)) + : end; final double hours = normalizedEnd.difference(start).inMinutes / 60.0; final double rate = order.roleRates[position.role] ?? 0; total += rate * hours * position.count; @@ -429,8 +470,9 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte for (final domain.OneTimeOrderPosition position in order.positions) { final DateTime start = _parseTime(order.startDate, position.startTime); final DateTime end = _parseTime(order.startDate, position.endTime); - final DateTime normalizedEnd = - end.isBefore(start) ? end.add(const Duration(days: 1)) : end; + final DateTime normalizedEnd = end.isBefore(start) + ? end.add(const Duration(days: 1)) + : end; final double hours = normalizedEnd.difference(start).inMinutes / 60.0; final double rate = order.roleRates[position.role] ?? 0; total += rate * hours * position.count; @@ -506,4 +548,49 @@ class ClientCreateOrderRepositoryImpl implements ClientCreateOrderRepositoryInte final String day = dateTime.day.toString().padLeft(2, '0'); return '$year-$month-$day'; } + + String _formatTimestamp(Timestamp? value) { + if (value == null) return ''; + try { + return DateFormat('HH:mm').format(value.toDateTime()); + } catch (_) { + return ''; + } + } + + String _formatBreakDuration(dc.EnumValue? breakType) { + if (breakType is dc.Known) { + switch (breakType.value) { + case dc.BreakDuration.MIN_10: + return 'MIN_10'; + case dc.BreakDuration.MIN_15: + return 'MIN_15'; + case dc.BreakDuration.MIN_30: + return 'MIN_30'; + case dc.BreakDuration.MIN_45: + return 'MIN_45'; + case dc.BreakDuration.MIN_60: + return 'MIN_60'; + case dc.BreakDuration.NO_BREAK: + return 'NO_BREAK'; + } + } + return 'NO_BREAK'; + } + + domain.OrderType _mapOrderType(dc.EnumValue? orderType) { + if (orderType is dc.Known) { + switch (orderType.value) { + case dc.OrderType.ONE_TIME: + return domain.OrderType.oneTime; + case dc.OrderType.RECURRING: + return domain.OrderType.recurring; + case dc.OrderType.PERMANENT: + return domain.OrderType.permanent; + case dc.OrderType.RAPID: + return domain.OrderType.oneTime; + } + } + return domain.OrderType.oneTime; + } } diff --git a/apps/mobile/packages/features/client/create_order/lib/src/domain/arguments/one_time_order_arguments.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/arguments/one_time_order_arguments.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/domain/arguments/one_time_order_arguments.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/domain/arguments/one_time_order_arguments.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/domain/arguments/permanent_order_arguments.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/arguments/permanent_order_arguments.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/domain/arguments/permanent_order_arguments.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/domain/arguments/permanent_order_arguments.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/domain/arguments/rapid_order_arguments.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/arguments/rapid_order_arguments.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/domain/arguments/rapid_order_arguments.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/domain/arguments/rapid_order_arguments.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/domain/arguments/recurring_order_arguments.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/arguments/recurring_order_arguments.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/domain/arguments/recurring_order_arguments.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/domain/arguments/recurring_order_arguments.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/domain/repositories/client_create_order_repository_interface.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/repositories/client_create_order_repository_interface.dart similarity index 79% rename from apps/mobile/packages/features/client/create_order/lib/src/domain/repositories/client_create_order_repository_interface.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/domain/repositories/client_create_order_repository_interface.dart index d7eed014..a2c80cd5 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/domain/repositories/client_create_order_repository_interface.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/repositories/client_create_order_repository_interface.dart @@ -3,15 +3,11 @@ import 'package:krow_domain/krow_domain.dart'; /// Interface for the Client Create Order repository. /// /// This repository is responsible for: -/// 1. Retrieving available order types for the client. -/// 2. Submitting different types of staffing orders (Rapid, One-Time). +/// 1. Submitting different types of staffing orders (Rapid, One-Time, Recurring, Permanent). /// /// It follows the KROW Clean Architecture by defining the contract in the /// domain layer, to be implemented in the data layer. abstract interface class ClientCreateOrderRepositoryInterface { - /// Retrieves the list of available order types (e.g., Rapid, One-Time, Recurring). - Future> getOrderTypes(); - /// Submits a one-time staffing order with specific details. /// /// [order] contains the date, location, and required positions. @@ -33,4 +29,9 @@ abstract interface class ClientCreateOrderRepositoryInterface { /// [previousOrderId] is the ID of the order to reorder. /// [newDate] is the new date for the order. Future reorder(String previousOrderId, DateTime newDate); + + /// Fetches the details of an existing order to be used as a template for a new order. + /// + /// returns [ReorderData] containing the order details and positions. + Future getOrderDetailsForReorder(String orderId); } diff --git a/apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/create_one_time_order_usecase.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/create_one_time_order_usecase.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/create_one_time_order_usecase.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/create_one_time_order_usecase.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/create_permanent_order_usecase.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/create_permanent_order_usecase.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/create_permanent_order_usecase.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/create_permanent_order_usecase.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/create_rapid_order_usecase.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/create_rapid_order_usecase.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/create_rapid_order_usecase.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/create_rapid_order_usecase.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/create_recurring_order_usecase.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/create_recurring_order_usecase.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/create_recurring_order_usecase.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/create_recurring_order_usecase.dart diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/get_order_details_for_reorder_usecase.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/get_order_details_for_reorder_usecase.dart new file mode 100644 index 00000000..9490ccb5 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/get_order_details_for_reorder_usecase.dart @@ -0,0 +1,14 @@ +import 'package:krow_core/core.dart'; +import 'package:krow_domain/krow_domain.dart'; +import '../repositories/client_create_order_repository_interface.dart'; + +/// Use case for fetching order details for reordering. +class GetOrderDetailsForReorderUseCase implements UseCase { + const GetOrderDetailsForReorderUseCase(this._repository); + final ClientCreateOrderRepositoryInterface _repository; + + @override + Future call(String orderId) { + return _repository.getOrderDetailsForReorder(orderId); + } +} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/reorder_usecase.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/reorder_usecase.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/domain/usecases/reorder_usecase.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/domain/usecases/reorder_usecase.dart diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/index.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/index.dart new file mode 100644 index 00000000..36ed5304 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/index.dart @@ -0,0 +1,4 @@ +export 'one_time_order/index.dart'; +export 'rapid_order/index.dart'; +export 'recurring_order/index.dart'; +export 'permanent_order/index.dart'; diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/index.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/index.dart new file mode 100644 index 00000000..c096a4c2 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/index.dart @@ -0,0 +1,3 @@ +export 'one_time_order_bloc.dart'; +export 'one_time_order_event.dart'; +export 'one_time_order_state.dart'; diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/one_time_order_bloc.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_bloc.dart similarity index 63% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/one_time_order_bloc.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_bloc.dart index 6d1b9bfd..9b9891b4 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/one_time_order_bloc.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_bloc.dart @@ -1,18 +1,25 @@ -import 'package:firebase_data_connect/firebase_data_connect.dart'; +import 'package:client_create_order/src/domain/arguments/one_time_order_arguments.dart'; +import 'package:client_create_order/src/domain/usecases/create_one_time_order_usecase.dart'; +import 'package:client_create_order/src/domain/usecases/get_order_details_for_reorder_usecase.dart'; +import 'package:firebase_data_connect/firebase_data_connect.dart' as fdc; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:krow_core/core.dart'; import 'package:krow_data_connect/krow_data_connect.dart' as dc; import 'package:krow_domain/krow_domain.dart'; -import '../../domain/arguments/one_time_order_arguments.dart'; -import '../../domain/usecases/create_one_time_order_usecase.dart'; + import 'one_time_order_event.dart'; import 'one_time_order_state.dart'; /// BLoC for managing the multi-step one-time order creation form. class OneTimeOrderBloc extends Bloc - with BlocErrorHandler, SafeBloc { - OneTimeOrderBloc(this._createOneTimeOrderUseCase, this._service) - : super(OneTimeOrderState.initial()) { + with + BlocErrorHandler, + SafeBloc { + OneTimeOrderBloc( + this._createOneTimeOrderUseCase, + this._getOrderDetailsForReorderUseCase, + this._service, + ) : super(OneTimeOrderState.initial()) { on(_onVendorsLoaded); on(_onVendorChanged); on(_onHubsLoaded); @@ -23,18 +30,22 @@ class OneTimeOrderBloc extends Bloc on(_onPositionRemoved); on(_onPositionUpdated); on(_onSubmitted); + on(_onInitialized); _loadVendors(); _loadHubs(); } final CreateOneTimeOrderUseCase _createOneTimeOrderUseCase; + final GetOrderDetailsForReorderUseCase _getOrderDetailsForReorderUseCase; final dc.DataConnectService _service; Future _loadVendors() async { final List? vendors = await handleErrorWithResult( action: () async { - final QueryResult result = - await _service.connector.listVendors().execute(); + final fdc.QueryResult result = await _service + .connector + .listVendors() + .execute(); return result.data.vendors .map( (dc.ListVendorsVendors vendor) => Vendor( @@ -53,11 +64,19 @@ class OneTimeOrderBloc extends Bloc } } - Future _loadRolesForVendor(String vendorId, Emitter emit) async { + Future _loadRolesForVendor( + String vendorId, + Emitter emit, + ) async { final List? roles = await handleErrorWithResult( action: () async { - final QueryResult - result = await _service.connector.listRolesByVendorId(vendorId: vendorId).execute(); + final fdc.QueryResult< + dc.ListRolesByVendorIdData, + dc.ListRolesByVendorIdVariables + > + result = await _service.connector + .listRolesByVendorId(vendorId: vendorId) + .execute(); return result.data.roles .map( (dc.ListRolesByVendorIdRoles role) => OneTimeOrderRoleOption( @@ -68,7 +87,8 @@ class OneTimeOrderBloc extends Bloc ) .toList(); }, - onError: (_) => emit(state.copyWith(roles: const [])), + onError: (_) => + emit(state.copyWith(roles: const [])), ); if (roles != null) { @@ -80,7 +100,10 @@ class OneTimeOrderBloc extends Bloc final List? hubs = await handleErrorWithResult( action: () async { final String businessId = await _service.getBusinessId(); - final QueryResult + final fdc.QueryResult< + dc.ListTeamHubsByOwnerIdData, + dc.ListTeamHubsByOwnerIdVariables + > result = await _service.connector .listTeamHubsByOwnerId(ownerId: businessId) .execute(); @@ -102,7 +125,8 @@ class OneTimeOrderBloc extends Bloc ) .toList(); }, - onError: (_) => add(const OneTimeOrderHubsLoaded([])), + onError: (_) => + add(const OneTimeOrderHubsLoaded([])), ); if (hubs != null) { @@ -114,13 +138,11 @@ class OneTimeOrderBloc extends Bloc OneTimeOrderVendorsLoaded event, Emitter emit, ) async { - final Vendor? selectedVendor = - event.vendors.isNotEmpty ? event.vendors.first : null; + final Vendor? selectedVendor = event.vendors.isNotEmpty + ? event.vendors.first + : null; emit( - state.copyWith( - vendors: event.vendors, - selectedVendor: selectedVendor, - ), + state.copyWith(vendors: event.vendors, selectedVendor: selectedVendor), ); if (selectedVendor != null) { await _loadRolesForVendor(selectedVendor.id, emit); @@ -139,8 +161,9 @@ class OneTimeOrderBloc extends Bloc OneTimeOrderHubsLoaded event, Emitter emit, ) { - final OneTimeOrderHubOption? selectedHub = - event.hubs.isNotEmpty ? event.hubs.first : null; + final OneTimeOrderHubOption? selectedHub = event.hubs.isNotEmpty + ? event.hubs.first + : null; emit( state.copyWith( hubs: event.hubs, @@ -154,12 +177,7 @@ class OneTimeOrderBloc extends Bloc OneTimeOrderHubChanged event, Emitter emit, ) { - emit( - state.copyWith( - selectedHub: event.hub, - location: event.hub.name, - ), - ); + emit(state.copyWith(selectedHub: event.hub, location: event.hub.name)); } void _onEventNameChanged( @@ -260,4 +278,74 @@ class OneTimeOrderBloc extends Bloc ), ); } + + Future _onInitialized( + OneTimeOrderInitialized event, + Emitter emit, + ) async { + final Map data = event.data; + final String title = data['title']?.toString() ?? ''; + final DateTime? startDate = data['startDate'] as DateTime?; + final String? orderId = data['orderId']?.toString(); + + emit(state.copyWith(eventName: title, date: startDate ?? DateTime.now())); + + if (orderId == null || orderId.isEmpty) return; + + emit(state.copyWith(status: OneTimeOrderStatus.loading)); + + await handleError( + emit: emit.call, + action: () async { + final ReorderData orderDetails = + await _getOrderDetailsForReorderUseCase(orderId); + + // Map positions + final List positions = orderDetails.positions.map( + (ReorderPosition role) { + return OneTimeOrderPosition( + role: role.roleId, + count: role.count, + startTime: role.startTime, + endTime: role.endTime, + lunchBreak: role.lunchBreak, + ); + }, + ).toList(); + + // Update state with order details + final Vendor? selectedVendor = state.vendors + .where((Vendor v) => v.id == orderDetails.vendorId) + .firstOrNull; + + final OneTimeOrderHubOption? selectedHub = state.hubs + .where( + (OneTimeOrderHubOption h) => + h.placeId == orderDetails.hub.placeId, + ) + .firstOrNull; + + emit( + state.copyWith( + eventName: orderDetails.eventName.isNotEmpty + ? orderDetails.eventName + : title, + positions: positions, + selectedVendor: selectedVendor, + selectedHub: selectedHub, + location: selectedHub?.name ?? '', + status: OneTimeOrderStatus.initial, + ), + ); + + if (selectedVendor != null) { + await _loadRolesForVendor(selectedVendor.id, emit); + } + }, + onError: (String errorKey) => state.copyWith( + status: OneTimeOrderStatus.failure, + errorMessage: errorKey, + ), + ); + } } diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/one_time_order_event.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_event.dart similarity index 91% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/one_time_order_event.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_event.dart index 7258c2d0..b6255dab 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/one_time_order_event.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_event.dart @@ -81,3 +81,11 @@ class OneTimeOrderPositionUpdated extends OneTimeOrderEvent { class OneTimeOrderSubmitted extends OneTimeOrderEvent { const OneTimeOrderSubmitted(); } + +class OneTimeOrderInitialized extends OneTimeOrderEvent { + const OneTimeOrderInitialized(this.data); + final Map data; + + @override + List get props => [data]; +} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/one_time_order_state.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_state.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/one_time_order_state.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/one_time_order/one_time_order_state.dart diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/index.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/index.dart new file mode 100644 index 00000000..afc5e109 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/index.dart @@ -0,0 +1,3 @@ +export 'permanent_order_bloc.dart'; +export 'permanent_order_event.dart'; +export 'permanent_order_state.dart'; diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/permanent_order_bloc.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_bloc.dart similarity index 67% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/permanent_order_bloc.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_bloc.dart index 1cd2b4f1..6f173604 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/permanent_order_bloc.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_bloc.dart @@ -1,17 +1,24 @@ -import 'package:firebase_data_connect/firebase_data_connect.dart'; +import 'package:client_create_order/src/domain/usecases/create_permanent_order_usecase.dart'; +import 'package:client_create_order/src/domain/usecases/get_order_details_for_reorder_usecase.dart'; +import 'package:firebase_data_connect/firebase_data_connect.dart' as fdc; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:krow_core/core.dart'; import 'package:krow_data_connect/krow_data_connect.dart' as dc; import 'package:krow_domain/krow_domain.dart' as domain; -import '../../domain/usecases/create_permanent_order_usecase.dart'; + import 'permanent_order_event.dart'; import 'permanent_order_state.dart'; /// BLoC for managing the permanent order creation form. class PermanentOrderBloc extends Bloc - with BlocErrorHandler, SafeBloc { - PermanentOrderBloc(this._createPermanentOrderUseCase, this._service) - : super(PermanentOrderState.initial()) { + with + BlocErrorHandler, + SafeBloc { + PermanentOrderBloc( + this._createPermanentOrderUseCase, + this._getOrderDetailsForReorderUseCase, + this._service, + ) : super(PermanentOrderState.initial()) { on(_onVendorsLoaded); on(_onVendorChanged); on(_onHubsLoaded); @@ -23,12 +30,14 @@ class PermanentOrderBloc extends Bloc on(_onPositionRemoved); on(_onPositionUpdated); on(_onSubmitted); + on(_onInitialized); _loadVendors(); _loadHubs(); } final CreatePermanentOrderUseCase _createPermanentOrderUseCase; + final GetOrderDetailsForReorderUseCase _getOrderDetailsForReorderUseCase; final dc.DataConnectService _service; static const List _dayLabels = [ @@ -44,8 +53,10 @@ class PermanentOrderBloc extends Bloc Future _loadVendors() async { final List? vendors = await handleErrorWithResult( action: () async { - final QueryResult result = - await _service.connector.listVendors().execute(); + final fdc.QueryResult result = await _service + .connector + .listVendors() + .execute(); return result.data.vendors .map( (dc.ListVendorsVendors vendor) => domain.Vendor( @@ -70,10 +81,13 @@ class PermanentOrderBloc extends Bloc ) async { final List? roles = await handleErrorWithResult( action: () async { - final QueryResult - result = await _service.connector - .listRolesByVendorId(vendorId: vendorId) - .execute(); + final fdc.QueryResult< + dc.ListRolesByVendorIdData, + dc.ListRolesByVendorIdVariables + > + result = await _service.connector + .listRolesByVendorId(vendorId: vendorId) + .execute(); return result.data.roles .map( (dc.ListRolesByVendorIdRoles role) => PermanentOrderRoleOption( @@ -84,7 +98,8 @@ class PermanentOrderBloc extends Bloc ) .toList(); }, - onError: (_) => emit(state.copyWith(roles: const [])), + onError: (_) => + emit(state.copyWith(roles: const [])), ); if (roles != null) { @@ -96,10 +111,13 @@ class PermanentOrderBloc extends Bloc final List? hubs = await handleErrorWithResult( action: () async { final String businessId = await _service.getBusinessId(); - final QueryResult - result = await _service.connector - .listTeamHubsByOwnerId(ownerId: businessId) - .execute(); + final fdc.QueryResult< + dc.ListTeamHubsByOwnerIdData, + dc.ListTeamHubsByOwnerIdVariables + > + result = await _service.connector + .listTeamHubsByOwnerId(ownerId: businessId) + .execute(); return result.data.teamHubs .map( (dc.ListTeamHubsByOwnerIdTeamHubs hub) => PermanentOrderHubOption( @@ -118,7 +136,8 @@ class PermanentOrderBloc extends Bloc ) .toList(); }, - onError: (_) => add(const PermanentOrderHubsLoaded([])), + onError: (_) => + add(const PermanentOrderHubsLoaded([])), ); if (hubs != null) { @@ -130,13 +149,11 @@ class PermanentOrderBloc extends Bloc PermanentOrderVendorsLoaded event, Emitter emit, ) async { - final domain.Vendor? selectedVendor = - event.vendors.isNotEmpty ? event.vendors.first : null; + final domain.Vendor? selectedVendor = event.vendors.isNotEmpty + ? event.vendors.first + : null; emit( - state.copyWith( - vendors: event.vendors, - selectedVendor: selectedVendor, - ), + state.copyWith(vendors: event.vendors, selectedVendor: selectedVendor), ); if (selectedVendor != null) { await _loadRolesForVendor(selectedVendor.id, emit); @@ -155,8 +172,9 @@ class PermanentOrderBloc extends Bloc PermanentOrderHubsLoaded event, Emitter emit, ) { - final PermanentOrderHubOption? selectedHub = - event.hubs.isNotEmpty ? event.hubs.first : null; + final PermanentOrderHubOption? selectedHub = event.hubs.isNotEmpty + ? event.hubs.first + : null; emit( state.copyWith( hubs: event.hubs, @@ -170,12 +188,7 @@ class PermanentOrderBloc extends Bloc PermanentOrderHubChanged event, Emitter emit, ) { - emit( - state.copyWith( - selectedHub: event.hub, - location: event.hub.name, - ), - ); + emit(state.copyWith(selectedHub: event.hub, location: event.hub.name)); } void _onEventNameChanged( @@ -225,7 +238,12 @@ class PermanentOrderBloc extends Bloc } else { days.add(label); } - emit(state.copyWith(permanentDays: _sortDays(days), autoSelectedDayIndex: autoIndex)); + emit( + state.copyWith( + permanentDays: _sortDays(days), + autoSelectedDayIndex: autoIndex, + ), + ); } void _onPositionAdded( @@ -324,6 +342,80 @@ class PermanentOrderBloc extends Bloc ); } + Future _onInitialized( + PermanentOrderInitialized event, + Emitter emit, + ) async { + final Map data = event.data; + final String title = data['title']?.toString() ?? ''; + final DateTime? startDate = data['startDate'] as DateTime?; + final String? orderId = data['orderId']?.toString(); + + emit( + state.copyWith(eventName: title, startDate: startDate ?? DateTime.now()), + ); + + if (orderId == null || orderId.isEmpty) return; + + emit(state.copyWith(status: PermanentOrderStatus.loading)); + + await handleError( + emit: emit.call, + action: () async { + final domain.ReorderData orderDetails = + await _getOrderDetailsForReorderUseCase(orderId); + + // Map positions + final List positions = orderDetails.positions + .map((domain.ReorderPosition role) { + return PermanentOrderPosition( + role: role.roleId, + count: role.count, + startTime: role.startTime, + endTime: role.endTime, + lunchBreak: role.lunchBreak, + ); + }) + .toList(); + + // Update state with order details + final domain.Vendor? selectedVendor = state.vendors + .where((domain.Vendor v) => v.id == orderDetails.vendorId) + .firstOrNull; + + final PermanentOrderHubOption? selectedHub = state.hubs + .where( + (PermanentOrderHubOption h) => + h.placeId == orderDetails.hub.placeId, + ) + .firstOrNull; + + emit( + state.copyWith( + eventName: orderDetails.eventName.isNotEmpty + ? orderDetails.eventName + : title, + positions: positions, + selectedVendor: selectedVendor, + selectedHub: selectedHub, + location: selectedHub?.name ?? '', + status: PermanentOrderStatus.initial, + startDate: startDate ?? orderDetails.startDate ?? DateTime.now(), + permanentDays: orderDetails.permanentDays, + ), + ); + + if (selectedVendor != null) { + await _loadRolesForVendor(selectedVendor.id, emit); + } + }, + onError: (String errorKey) => state.copyWith( + status: PermanentOrderStatus.failure, + errorMessage: errorKey, + ), + ); + } + static List _sortDays(List days) { days.sort( (String a, String b) => diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/permanent_order_event.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_event.dart similarity index 92% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/permanent_order_event.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_event.dart index bcf98127..28dcbcd3 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/permanent_order_event.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_event.dart @@ -98,3 +98,11 @@ class PermanentOrderPositionUpdated extends PermanentOrderEvent { class PermanentOrderSubmitted extends PermanentOrderEvent { const PermanentOrderSubmitted(); } + +class PermanentOrderInitialized extends PermanentOrderEvent { + const PermanentOrderInitialized(this.data); + final Map data; + + @override + List get props => [data]; +} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/permanent_order_state.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_state.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/permanent_order_state.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/permanent_order/permanent_order_state.dart diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/index.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/index.dart new file mode 100644 index 00000000..34b84929 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/index.dart @@ -0,0 +1,3 @@ +export 'rapid_order_bloc.dart'; +export 'rapid_order_event.dart'; +export 'rapid_order_state.dart'; diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/rapid_order_bloc.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/rapid_order_bloc.dart similarity index 94% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/rapid_order_bloc.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/rapid_order_bloc.dart index 626b612e..b9fdedf5 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/rapid_order_bloc.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/rapid_order_bloc.dart @@ -1,7 +1,8 @@ +import 'package:client_create_order/src/domain/arguments/rapid_order_arguments.dart'; +import 'package:client_create_order/src/domain/usecases/create_rapid_order_usecase.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:krow_core/core.dart'; -import '../../domain/arguments/rapid_order_arguments.dart'; -import '../../domain/usecases/create_rapid_order_usecase.dart'; + import 'rapid_order_event.dart'; import 'rapid_order_state.dart'; diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/rapid_order_event.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/rapid_order_event.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/rapid_order_event.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/rapid_order_event.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/rapid_order_state.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/rapid_order_state.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/rapid_order_state.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/rapid_order/rapid_order_state.dart diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/index.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/index.dart new file mode 100644 index 00000000..cfcc77f5 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/index.dart @@ -0,0 +1,3 @@ +export 'recurring_order_bloc.dart'; +export 'recurring_order_event.dart'; +export 'recurring_order_state.dart'; diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/recurring_order_bloc.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_bloc.dart similarity index 68% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/recurring_order_bloc.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_bloc.dart index fdc13713..0673531e 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/recurring_order_bloc.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_bloc.dart @@ -1,17 +1,24 @@ -import 'package:firebase_data_connect/firebase_data_connect.dart'; +import 'package:client_create_order/src/domain/usecases/create_recurring_order_usecase.dart'; +import 'package:client_create_order/src/domain/usecases/get_order_details_for_reorder_usecase.dart'; +import 'package:firebase_data_connect/firebase_data_connect.dart' as fdc; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:krow_core/core.dart'; import 'package:krow_data_connect/krow_data_connect.dart' as dc; import 'package:krow_domain/krow_domain.dart' as domain; -import '../../domain/usecases/create_recurring_order_usecase.dart'; + import 'recurring_order_event.dart'; import 'recurring_order_state.dart'; /// BLoC for managing the recurring order creation form. class RecurringOrderBloc extends Bloc - with BlocErrorHandler, SafeBloc { - RecurringOrderBloc(this._createRecurringOrderUseCase, this._service) - : super(RecurringOrderState.initial()) { + with + BlocErrorHandler, + SafeBloc { + RecurringOrderBloc( + this._createRecurringOrderUseCase, + this._getOrderDetailsForReorderUseCase, + this._service, + ) : super(RecurringOrderState.initial()) { on(_onVendorsLoaded); on(_onVendorChanged); on(_onHubsLoaded); @@ -24,12 +31,14 @@ class RecurringOrderBloc extends Bloc on(_onPositionRemoved); on(_onPositionUpdated); on(_onSubmitted); + on(_onInitialized); _loadVendors(); _loadHubs(); } final CreateRecurringOrderUseCase _createRecurringOrderUseCase; + final GetOrderDetailsForReorderUseCase _getOrderDetailsForReorderUseCase; final dc.DataConnectService _service; static const List _dayLabels = [ @@ -45,8 +54,10 @@ class RecurringOrderBloc extends Bloc Future _loadVendors() async { final List? vendors = await handleErrorWithResult( action: () async { - final QueryResult result = - await _service.connector.listVendors().execute(); + final fdc.QueryResult result = await _service + .connector + .listVendors() + .execute(); return result.data.vendors .map( (dc.ListVendorsVendors vendor) => domain.Vendor( @@ -71,10 +82,13 @@ class RecurringOrderBloc extends Bloc ) async { final List? roles = await handleErrorWithResult( action: () async { - final QueryResult - result = await _service.connector - .listRolesByVendorId(vendorId: vendorId) - .execute(); + final fdc.QueryResult< + dc.ListRolesByVendorIdData, + dc.ListRolesByVendorIdVariables + > + result = await _service.connector + .listRolesByVendorId(vendorId: vendorId) + .execute(); return result.data.roles .map( (dc.ListRolesByVendorIdRoles role) => RecurringOrderRoleOption( @@ -85,7 +99,8 @@ class RecurringOrderBloc extends Bloc ) .toList(); }, - onError: (_) => emit(state.copyWith(roles: const [])), + onError: (_) => + emit(state.copyWith(roles: const [])), ); if (roles != null) { @@ -97,10 +112,13 @@ class RecurringOrderBloc extends Bloc final List? hubs = await handleErrorWithResult( action: () async { final String businessId = await _service.getBusinessId(); - final QueryResult - result = await _service.connector - .listTeamHubsByOwnerId(ownerId: businessId) - .execute(); + final fdc.QueryResult< + dc.ListTeamHubsByOwnerIdData, + dc.ListTeamHubsByOwnerIdVariables + > + result = await _service.connector + .listTeamHubsByOwnerId(ownerId: businessId) + .execute(); return result.data.teamHubs .map( (dc.ListTeamHubsByOwnerIdTeamHubs hub) => RecurringOrderHubOption( @@ -119,7 +137,8 @@ class RecurringOrderBloc extends Bloc ) .toList(); }, - onError: (_) => add(const RecurringOrderHubsLoaded([])), + onError: (_) => + add(const RecurringOrderHubsLoaded([])), ); if (hubs != null) { @@ -131,13 +150,11 @@ class RecurringOrderBloc extends Bloc RecurringOrderVendorsLoaded event, Emitter emit, ) async { - final domain.Vendor? selectedVendor = - event.vendors.isNotEmpty ? event.vendors.first : null; + final domain.Vendor? selectedVendor = event.vendors.isNotEmpty + ? event.vendors.first + : null; emit( - state.copyWith( - vendors: event.vendors, - selectedVendor: selectedVendor, - ), + state.copyWith(vendors: event.vendors, selectedVendor: selectedVendor), ); if (selectedVendor != null) { await _loadRolesForVendor(selectedVendor.id, emit); @@ -156,8 +173,9 @@ class RecurringOrderBloc extends Bloc RecurringOrderHubsLoaded event, Emitter emit, ) { - final RecurringOrderHubOption? selectedHub = - event.hubs.isNotEmpty ? event.hubs.first : null; + final RecurringOrderHubOption? selectedHub = event.hubs.isNotEmpty + ? event.hubs.first + : null; emit( state.copyWith( hubs: event.hubs, @@ -171,12 +189,7 @@ class RecurringOrderBloc extends Bloc RecurringOrderHubChanged event, Emitter emit, ) { - emit( - state.copyWith( - selectedHub: event.hub, - location: event.hub.name, - ), - ); + emit(state.copyWith(selectedHub: event.hub, location: event.hub.name)); } void _onEventNameChanged( @@ -242,7 +255,12 @@ class RecurringOrderBloc extends Bloc } else { days.add(label); } - emit(state.copyWith(recurringDays: _sortDays(days), autoSelectedDayIndex: autoIndex)); + emit( + state.copyWith( + recurringDays: _sortDays(days), + autoSelectedDayIndex: autoIndex, + ), + ); } void _onPositionAdded( @@ -343,6 +361,81 @@ class RecurringOrderBloc extends Bloc ); } + Future _onInitialized( + RecurringOrderInitialized event, + Emitter emit, + ) async { + final Map data = event.data; + final String title = data['title']?.toString() ?? ''; + final DateTime? startDate = data['startDate'] as DateTime?; + final String? orderId = data['orderId']?.toString(); + + emit( + state.copyWith(eventName: title, startDate: startDate ?? DateTime.now()), + ); + + if (orderId == null || orderId.isEmpty) return; + + emit(state.copyWith(status: RecurringOrderStatus.loading)); + + await handleError( + emit: emit.call, + action: () async { + final domain.ReorderData orderDetails = + await _getOrderDetailsForReorderUseCase(orderId); + + // Map positions + final List positions = orderDetails.positions + .map((domain.ReorderPosition role) { + return RecurringOrderPosition( + role: role.roleId, + count: role.count, + startTime: role.startTime, + endTime: role.endTime, + lunchBreak: role.lunchBreak, + ); + }) + .toList(); + + // Update state with order details + final domain.Vendor? selectedVendor = state.vendors + .where((domain.Vendor v) => v.id == orderDetails.vendorId) + .firstOrNull; + + final RecurringOrderHubOption? selectedHub = state.hubs + .where( + (RecurringOrderHubOption h) => + h.placeId == orderDetails.hub.placeId, + ) + .firstOrNull; + + emit( + state.copyWith( + eventName: orderDetails.eventName.isNotEmpty + ? orderDetails.eventName + : title, + positions: positions, + selectedVendor: selectedVendor, + selectedHub: selectedHub, + location: selectedHub?.name ?? '', + status: RecurringOrderStatus.initial, + startDate: startDate ?? orderDetails.startDate ?? DateTime.now(), + endDate: orderDetails.endDate ?? DateTime.now(), + recurringDays: orderDetails.recurringDays, + ), + ); + + if (selectedVendor != null) { + await _loadRolesForVendor(selectedVendor.id, emit); + } + }, + onError: (String errorKey) => state.copyWith( + status: RecurringOrderStatus.failure, + errorMessage: errorKey, + ), + ); + } + static List _sortDays(List days) { days.sort( (String a, String b) => diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/recurring_order_event.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_event.dart similarity index 92% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/recurring_order_event.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_event.dart index 3803153a..a04dbdbb 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/recurring_order_event.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_event.dart @@ -107,3 +107,11 @@ class RecurringOrderPositionUpdated extends RecurringOrderEvent { class RecurringOrderSubmitted extends RecurringOrderEvent { const RecurringOrderSubmitted(); } + +class RecurringOrderInitialized extends RecurringOrderEvent { + const RecurringOrderInitialized(this.data); + final Map data; + + @override + List get props => [data]; +} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/recurring_order_state.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_state.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/blocs/recurring_order_state.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/blocs/recurring_order/recurring_order_state.dart diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/create_order_page.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/create_order_page.dart new file mode 100644 index 00000000..7bc1f023 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/create_order_page.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; + +import '../widgets/create_order/create_order_view.dart'; + +/// Main entry page for the client create order flow. +/// +/// This page displays the [CreateOrderView]. +/// It follows the Krow Clean Architecture by being a [StatelessWidget] and +/// delegating its UI to other components. +class ClientCreateOrderPage extends StatelessWidget { + /// Creates a [ClientCreateOrderPage]. + const ClientCreateOrderPage({super.key}); + + @override + Widget build(BuildContext context) { + return const CreateOrderView(); + } +} diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/one_time_order_page.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/one_time_order_page.dart new file mode 100644 index 00000000..899e787b --- /dev/null +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/one_time_order_page.dart @@ -0,0 +1,133 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_modular/flutter_modular.dart'; +import 'package:client_orders_common/client_orders_common.dart'; +import 'package:krow_core/core.dart'; +import 'package:krow_domain/krow_domain.dart'; +import '../blocs/one_time_order/one_time_order_bloc.dart'; +import '../blocs/one_time_order/one_time_order_event.dart'; +import '../blocs/one_time_order/one_time_order_state.dart'; + +/// Page for creating a one-time staffing order. +/// Users can specify the date, location, and multiple staff positions required. +/// +/// This page initializes the [OneTimeOrderBloc] and displays the [OneTimeOrderView] +/// from the common orders package. It follows the Krow Clean Architecture by being +/// a [StatelessWidget] and mapping local BLoC state to generic UI models. +class OneTimeOrderPage extends StatelessWidget { + /// Creates a [OneTimeOrderPage]. + const OneTimeOrderPage({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (BuildContext context) { + final OneTimeOrderBloc bloc = Modular.get(); + final dynamic args = Modular.args.data; + if (args is Map) { + bloc.add(OneTimeOrderInitialized(args)); + } + return bloc; + }, + child: BlocBuilder( + builder: (BuildContext context, OneTimeOrderState state) { + final OneTimeOrderBloc bloc = BlocProvider.of( + context, + ); + + return OneTimeOrderView( + status: _mapStatus(state.status), + errorMessage: state.errorMessage, + eventName: state.eventName, + selectedVendor: state.selectedVendor, + vendors: state.vendors, + date: state.date, + selectedHub: state.selectedHub != null + ? _mapHub(state.selectedHub!) + : null, + hubs: state.hubs.map(_mapHub).toList(), + positions: state.positions.map(_mapPosition).toList(), + roles: state.roles.map(_mapRole).toList(), + isValid: state.isValid, + onEventNameChanged: (String val) => + bloc.add(OneTimeOrderEventNameChanged(val)), + onVendorChanged: (Vendor val) => + bloc.add(OneTimeOrderVendorChanged(val)), + onDateChanged: (DateTime val) => + bloc.add(OneTimeOrderDateChanged(val)), + onHubChanged: (OrderHubUiModel val) { + final OneTimeOrderHubOption originalHub = state.hubs.firstWhere( + (OneTimeOrderHubOption h) => h.id == val.id, + ); + bloc.add(OneTimeOrderHubChanged(originalHub)); + }, + onPositionAdded: () => bloc.add(const OneTimeOrderPositionAdded()), + onPositionUpdated: (int index, OrderPositionUiModel val) { + final OneTimeOrderPosition original = state.positions[index]; + final OneTimeOrderPosition updated = original.copyWith( + role: val.role, + count: val.count, + startTime: val.startTime, + endTime: val.endTime, + lunchBreak: val.lunchBreak, + ); + bloc.add(OneTimeOrderPositionUpdated(index, updated)); + }, + onPositionRemoved: (int index) => + bloc.add(OneTimeOrderPositionRemoved(index)), + onSubmit: () => bloc.add(const OneTimeOrderSubmitted()), + onDone: () => Modular.to.toOrdersSpecificDate(state.date), + onBack: () => Modular.to.pop(), + ); + }, + ), + ); + } + + OrderFormStatus _mapStatus(OneTimeOrderStatus status) { + switch (status) { + case OneTimeOrderStatus.initial: + return OrderFormStatus.initial; + case OneTimeOrderStatus.loading: + return OrderFormStatus.loading; + case OneTimeOrderStatus.success: + return OrderFormStatus.success; + case OneTimeOrderStatus.failure: + return OrderFormStatus.failure; + } + } + + OrderHubUiModel _mapHub(OneTimeOrderHubOption hub) { + return OrderHubUiModel( + id: hub.id, + name: hub.name, + address: hub.address, + placeId: hub.placeId, + latitude: hub.latitude, + longitude: hub.longitude, + city: hub.city, + state: hub.state, + street: hub.street, + country: hub.country, + zipCode: hub.zipCode, + ); + } + + OrderRoleUiModel _mapRole(OneTimeOrderRoleOption role) { + return OrderRoleUiModel( + id: role.id, + name: role.name, + costPerHour: role.costPerHour, + ); + } + + OrderPositionUiModel _mapPosition(OneTimeOrderPosition pos) { + return OrderPositionUiModel( + role: pos.role, + count: pos.count, + startTime: pos.startTime, + endTime: pos.endTime, + lunchBreak: pos.lunchBreak, + ); + } +} diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/permanent_order_page.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/permanent_order_page.dart new file mode 100644 index 00000000..2fb67a03 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/permanent_order_page.dart @@ -0,0 +1,184 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_modular/flutter_modular.dart'; +import 'package:client_orders_common/client_orders_common.dart'; +import 'package:krow_core/core.dart'; +import 'package:krow_domain/krow_domain.dart' hide PermanentOrderPosition; +import '../blocs/permanent_order/permanent_order_bloc.dart'; +import '../blocs/permanent_order/permanent_order_event.dart'; +import '../blocs/permanent_order/permanent_order_state.dart'; + +/// Page for creating a permanent staffing order. +class PermanentOrderPage extends StatelessWidget { + /// Creates a [PermanentOrderPage]. + const PermanentOrderPage({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (BuildContext context) { + final PermanentOrderBloc bloc = Modular.get(); + final dynamic args = Modular.args.data; + if (args is Map) { + bloc.add(PermanentOrderInitialized(args)); + } + return bloc; + }, + child: BlocBuilder( + builder: (BuildContext context, PermanentOrderState state) { + final PermanentOrderBloc bloc = BlocProvider.of( + context, + ); + + return PermanentOrderView( + status: _mapStatus(state.status), + errorMessage: state.errorMessage, + eventName: state.eventName, + selectedVendor: state.selectedVendor, + vendors: state.vendors, + startDate: state.startDate, + permanentDays: state.permanentDays, + selectedHub: state.selectedHub != null + ? _mapHub(state.selectedHub!) + : null, + hubs: state.hubs.map(_mapHub).toList(), + positions: state.positions.map(_mapPosition).toList(), + roles: state.roles.map(_mapRole).toList(), + isValid: state.isValid, + onEventNameChanged: (String val) => + bloc.add(PermanentOrderEventNameChanged(val)), + onVendorChanged: (Vendor val) => + bloc.add(PermanentOrderVendorChanged(val)), + onStartDateChanged: (DateTime val) => + bloc.add(PermanentOrderStartDateChanged(val)), + onDayToggled: (int index) => + bloc.add(PermanentOrderDayToggled(index)), + onHubChanged: (OrderHubUiModel val) { + final PermanentOrderHubOption originalHub = state.hubs.firstWhere( + (PermanentOrderHubOption h) => h.id == val.id, + ); + bloc.add(PermanentOrderHubChanged(originalHub)); + }, + onPositionAdded: () => + bloc.add(const PermanentOrderPositionAdded()), + onPositionUpdated: (int index, OrderPositionUiModel val) { + final PermanentOrderPosition original = state.positions[index]; + final PermanentOrderPosition updated = original.copyWith( + role: val.role, + count: val.count, + startTime: val.startTime, + endTime: val.endTime, + lunchBreak: val.lunchBreak, + ); + bloc.add(PermanentOrderPositionUpdated(index, updated)); + }, + onPositionRemoved: (int index) => + bloc.add(PermanentOrderPositionRemoved(index)), + onSubmit: () => bloc.add(const PermanentOrderSubmitted()), + onDone: () { + final DateTime initialDate = _firstPermanentShiftDate( + state.startDate, + state.permanentDays, + ); + + // Navigate to orders page with the initial date set to the first recurring shift date + Modular.to.toOrdersSpecificDate(initialDate); + }, + onBack: () => Modular.to.pop(), + ); + }, + ), + ); + } + + DateTime _firstPermanentShiftDate( + DateTime startDate, + List permanentDays, + ) { + final DateTime start = DateTime( + startDate.year, + startDate.month, + startDate.day, + ); + final DateTime end = start.add(const Duration(days: 29)); + final Set selected = permanentDays.toSet(); + for ( + DateTime day = start; + !day.isAfter(end); + day = day.add(const Duration(days: 1)) + ) { + if (selected.contains(_weekdayLabel(day))) { + return day; + } + } + return start; + } + + String _weekdayLabel(DateTime date) { + switch (date.weekday) { + case DateTime.monday: + return 'MON'; + case DateTime.tuesday: + return 'TUE'; + case DateTime.wednesday: + return 'WED'; + case DateTime.thursday: + return 'THU'; + case DateTime.friday: + return 'FRI'; + case DateTime.saturday: + return 'SAT'; + case DateTime.sunday: + return 'SUN'; + default: + return 'SUN'; + } + } + + OrderFormStatus _mapStatus(PermanentOrderStatus status) { + switch (status) { + case PermanentOrderStatus.initial: + return OrderFormStatus.initial; + case PermanentOrderStatus.loading: + return OrderFormStatus.loading; + case PermanentOrderStatus.success: + return OrderFormStatus.success; + case PermanentOrderStatus.failure: + return OrderFormStatus.failure; + } + } + + OrderHubUiModel _mapHub(PermanentOrderHubOption hub) { + return OrderHubUiModel( + id: hub.id, + name: hub.name, + address: hub.address, + placeId: hub.placeId, + latitude: hub.latitude, + longitude: hub.longitude, + city: hub.city, + state: hub.state, + street: hub.street, + country: hub.country, + zipCode: hub.zipCode, + ); + } + + OrderRoleUiModel _mapRole(PermanentOrderRoleOption role) { + return OrderRoleUiModel( + id: role.id, + name: role.name, + costPerHour: role.costPerHour, + ); + } + + OrderPositionUiModel _mapPosition(PermanentOrderPosition pos) { + return OrderPositionUiModel( + role: pos.role, + count: pos.count, + startTime: pos.startTime, + endTime: pos.endTime, + lunchBreak: pos.lunchBreak ?? 'NO_BREAK', + ); + } +} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/rapid_order_page.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/rapid_order_page.dart similarity index 94% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/rapid_order_page.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/rapid_order_page.dart index 2bb444cf..46ea23f8 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/pages/rapid_order_page.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/rapid_order_page.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_modular/flutter_modular.dart'; -import '../blocs/rapid_order_bloc.dart'; +import '../blocs/rapid_order/rapid_order_bloc.dart'; import '../widgets/rapid_order/rapid_order_view.dart'; /// Rapid Order Flow Page - Emergency staffing requests. diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/recurring_order_page.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/recurring_order_page.dart new file mode 100644 index 00000000..6954e826 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/pages/recurring_order_page.dart @@ -0,0 +1,196 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_modular/flutter_modular.dart'; +import 'package:client_orders_common/client_orders_common.dart'; +import 'package:krow_core/core.dart'; +import 'package:krow_domain/krow_domain.dart' hide RecurringOrderPosition; +import '../blocs/recurring_order/recurring_order_bloc.dart'; +import '../blocs/recurring_order/recurring_order_event.dart'; +import '../blocs/recurring_order/recurring_order_state.dart'; + +/// Page for creating a recurring staffing order. +class RecurringOrderPage extends StatelessWidget { + /// Creates a [RecurringOrderPage]. + const RecurringOrderPage({super.key}); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (BuildContext context) { + final RecurringOrderBloc bloc = Modular.get(); + final dynamic args = Modular.args.data; + if (args is Map) { + bloc.add(RecurringOrderInitialized(args)); + } + return bloc; + }, + child: BlocBuilder( + builder: (BuildContext context, RecurringOrderState state) { + final RecurringOrderBloc bloc = BlocProvider.of( + context, + ); + + return RecurringOrderView( + status: _mapStatus(state.status), + errorMessage: state.errorMessage, + eventName: state.eventName, + selectedVendor: state.selectedVendor, + vendors: state.vendors, + startDate: state.startDate, + endDate: state.endDate, + recurringDays: state.recurringDays, + selectedHub: state.selectedHub != null + ? _mapHub(state.selectedHub!) + : null, + hubs: state.hubs.map(_mapHub).toList(), + positions: state.positions.map(_mapPosition).toList(), + roles: state.roles.map(_mapRole).toList(), + isValid: state.isValid, + onEventNameChanged: (String val) => + bloc.add(RecurringOrderEventNameChanged(val)), + onVendorChanged: (Vendor val) => + bloc.add(RecurringOrderVendorChanged(val)), + onStartDateChanged: (DateTime val) => + bloc.add(RecurringOrderStartDateChanged(val)), + onEndDateChanged: (DateTime val) => + bloc.add(RecurringOrderEndDateChanged(val)), + onDayToggled: (int index) => + bloc.add(RecurringOrderDayToggled(index)), + onHubChanged: (OrderHubUiModel val) { + final RecurringOrderHubOption originalHub = state.hubs.firstWhere( + (RecurringOrderHubOption h) => h.id == val.id, + ); + bloc.add(RecurringOrderHubChanged(originalHub)); + }, + onPositionAdded: () => + bloc.add(const RecurringOrderPositionAdded()), + onPositionUpdated: (int index, OrderPositionUiModel val) { + final RecurringOrderPosition original = state.positions[index]; + final RecurringOrderPosition updated = original.copyWith( + role: val.role, + count: val.count, + startTime: val.startTime, + endTime: val.endTime, + lunchBreak: val.lunchBreak, + ); + bloc.add(RecurringOrderPositionUpdated(index, updated)); + }, + onPositionRemoved: (int index) => + bloc.add(RecurringOrderPositionRemoved(index)), + onSubmit: () => bloc.add(const RecurringOrderSubmitted()), + onDone: () { + final DateTime maxEndDate = state.startDate.add( + const Duration(days: 29), + ); + final DateTime effectiveEndDate = + state.endDate.isAfter(maxEndDate) + ? maxEndDate + : state.endDate; + final DateTime initialDate = _firstRecurringShiftDate( + state.startDate, + effectiveEndDate, + state.recurringDays, + ); + + // Navigate to orders page with the initial date set to the first recurring shift date + Modular.to.toOrdersSpecificDate(initialDate); + }, + onBack: () => Modular.to.pop(), + ); + }, + ), + ); + } + + DateTime _firstRecurringShiftDate( + DateTime startDate, + DateTime endDate, + List recurringDays, + ) { + final DateTime start = DateTime( + startDate.year, + startDate.month, + startDate.day, + ); + final DateTime end = DateTime(endDate.year, endDate.month, endDate.day); + final Set selected = recurringDays.toSet(); + for ( + DateTime day = start; + !day.isAfter(end); + day = day.add(const Duration(days: 1)) + ) { + if (selected.contains(_weekdayLabel(day))) { + return day; + } + } + return start; + } + + String _weekdayLabel(DateTime date) { + switch (date.weekday) { + case DateTime.monday: + return 'MON'; + case DateTime.tuesday: + return 'TUE'; + case DateTime.wednesday: + return 'WED'; + case DateTime.thursday: + return 'THU'; + case DateTime.friday: + return 'FRI'; + case DateTime.saturday: + return 'SAT'; + case DateTime.sunday: + return 'SUN'; + default: + return 'SUN'; + } + } + + OrderFormStatus _mapStatus(RecurringOrderStatus status) { + switch (status) { + case RecurringOrderStatus.initial: + return OrderFormStatus.initial; + case RecurringOrderStatus.loading: + return OrderFormStatus.loading; + case RecurringOrderStatus.success: + return OrderFormStatus.success; + case RecurringOrderStatus.failure: + return OrderFormStatus.failure; + } + } + + OrderHubUiModel _mapHub(RecurringOrderHubOption hub) { + return OrderHubUiModel( + id: hub.id, + name: hub.name, + address: hub.address, + placeId: hub.placeId, + latitude: hub.latitude, + longitude: hub.longitude, + city: hub.city, + state: hub.state, + street: hub.street, + country: hub.country, + zipCode: hub.zipCode, + ); + } + + OrderRoleUiModel _mapRole(RecurringOrderRoleOption role) { + return OrderRoleUiModel( + id: role.id, + name: role.name, + costPerHour: role.costPerHour, + ); + } + + OrderPositionUiModel _mapPosition(RecurringOrderPosition pos) { + return OrderPositionUiModel( + role: pos.role, + count: pos.count, + startTime: pos.startTime, + endTime: pos.endTime, + lunchBreak: pos.lunchBreak ?? 'NO_BREAK', + ); + } +} diff --git a/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/utils/constants/order_types.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/utils/constants/order_types.dart new file mode 100644 index 00000000..68b48b75 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/utils/constants/order_types.dart @@ -0,0 +1,37 @@ +class UiOrderType { + const UiOrderType({ + required this.id, + required this.titleKey, + required this.descriptionKey, + }); + + final String id; + final String titleKey; + final String descriptionKey; +} + +/// Order type constants for the create order feature +const List orderTypes = [ + /// TODO: FEATURE_NOT_YET_IMPLEMENTED + // UiOrderType( + // id: 'rapid', + // titleKey: 'client_create_order.types.rapid', + // descriptionKey: 'client_create_order.types.rapid_desc', + // ), + UiOrderType( + id: 'one-time', + titleKey: 'client_create_order.types.one_time', + descriptionKey: 'client_create_order.types.one_time_desc', + ), + + UiOrderType( + id: 'recurring', + titleKey: 'client_create_order.types.recurring', + descriptionKey: 'client_create_order.types.recurring_desc', + ), + UiOrderType( + id: 'permanent', + titleKey: 'client_create_order.types.permanent', + descriptionKey: 'client_create_order.types.permanent_desc', + ), +]; diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/ui_entities/order_type_ui_metadata.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/utils/ui_entities/order_type_ui_metadata.dart similarity index 55% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/ui_entities/order_type_ui_metadata.dart rename to apps/mobile/packages/features/client/orders/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/ui_entities/order_type_ui_metadata.dart +++ b/apps/mobile/packages/features/client/orders/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/orders/create_order/lib/src/presentation/widgets/create_order/create_order_view.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/create_order/create_order_view.dart new file mode 100644 index 00000000..0c39efdd --- /dev/null +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/create_order/create_order_view.dart @@ -0,0 +1,112 @@ +import 'package:core_localization/core_localization.dart'; +import 'package:design_system/design_system.dart'; +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/constants/order_types.dart'; +import '../../utils/ui_entities/order_type_ui_metadata.dart'; +import '../order_type_card.dart'; + +/// Helper to map keys to localized strings. +String _getTranslation({required String key}) { + if (key == 'client_create_order.types.rapid') { + return t.client_create_order.types.rapid; + } else if (key == 'client_create_order.types.rapid_desc') { + return t.client_create_order.types.rapid_desc; + } else if (key == 'client_create_order.types.one_time') { + return t.client_create_order.types.one_time; + } else if (key == 'client_create_order.types.one_time_desc') { + return t.client_create_order.types.one_time_desc; + } else if (key == 'client_create_order.types.recurring') { + return t.client_create_order.types.recurring; + } else if (key == 'client_create_order.types.recurring_desc') { + return t.client_create_order.types.recurring_desc; + } else if (key == 'client_create_order.types.permanent') { + return t.client_create_order.types.permanent; + } else if (key == 'client_create_order.types.permanent_desc') { + return t.client_create_order.types.permanent_desc; + } + return key; +} + +/// The main content of the Create Order page. +class CreateOrderView extends StatelessWidget { + /// Creates a [CreateOrderView]. + const CreateOrderView({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: UiAppBar( + title: t.client_create_order.title, + onLeadingPressed: () => Modular.to.toClientHome(), + ), + body: SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: UiConstants.space5, + vertical: UiConstants.space6, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: UiConstants.space6), + child: Text( + t.client_create_order.section_title, + style: UiTypography.body2m.textDescription, + ), + ), + Expanded( + child: GridView.builder( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: UiConstants.space4, + crossAxisSpacing: UiConstants.space4, + childAspectRatio: 1, + ), + itemCount: orderTypes.length, + itemBuilder: (BuildContext context, int index) { + final UiOrderType type = orderTypes[index]; + final OrderTypeUiMetadata ui = OrderTypeUiMetadata.fromId( + id: type.id, + ); + + return OrderTypeCard( + icon: ui.icon, + title: _getTranslation(key: type.titleKey), + description: _getTranslation(key: type.descriptionKey), + backgroundColor: ui.backgroundColor, + borderColor: ui.borderColor, + iconBackgroundColor: ui.iconBackgroundColor, + iconColor: ui.iconColor, + textColor: ui.textColor, + descriptionColor: ui.descriptionColor, + onTap: () { + switch (type.id) { + case 'rapid': + Modular.to.toCreateOrderRapid(); + break; + case 'one-time': + Modular.to.toCreateOrderOneTime(); + break; + case 'recurring': + Modular.to.toCreateOrderRecurring(); + break; + case 'permanent': + Modular.to.toCreateOrderPermanent(); + break; + } + }, + ); + }, + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/order_type_card.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/order_type_card.dart similarity index 93% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/order_type_card.dart rename to apps/mobile/packages/features/client/orders/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/orders/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, diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_example_card.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_example_card.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_example_card.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_example_card.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_header.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_header.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_header.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_header.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_success_view.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_success_view.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_success_view.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_success_view.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_view.dart b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_view.dart similarity index 98% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_view.dart rename to apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_view.dart index da6a5df4..08837105 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_view.dart +++ b/apps/mobile/packages/features/client/orders/create_order/lib/src/presentation/widgets/rapid_order/rapid_order_view.dart @@ -5,9 +5,9 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_modular/flutter_modular.dart'; import 'package:intl/intl.dart'; import 'package:krow_core/core.dart'; -import '../../blocs/rapid_order_bloc.dart'; -import '../../blocs/rapid_order_event.dart'; -import '../../blocs/rapid_order_state.dart'; +import '../../blocs/rapid_order/rapid_order_bloc.dart'; +import '../../blocs/rapid_order/rapid_order_event.dart'; +import '../../blocs/rapid_order/rapid_order_state.dart'; import 'rapid_order_example_card.dart'; import 'rapid_order_header.dart'; import 'rapid_order_success_view.dart'; @@ -295,7 +295,6 @@ class _RapidOrderActions extends StatelessWidget { onPressed: isSubmitting || isMessageEmpty ? null : () { - print('RapidOrder send pressed'); BlocProvider.of( context, ).add(const RapidOrderSubmitted()); diff --git a/apps/mobile/packages/features/client/create_order/pubspec.yaml b/apps/mobile/packages/features/client/orders/create_order/pubspec.yaml similarity index 69% rename from apps/mobile/packages/features/client/create_order/pubspec.yaml rename to apps/mobile/packages/features/client/orders/create_order/pubspec.yaml index b1091732..20a70779 100644 --- a/apps/mobile/packages/features/client/create_order/pubspec.yaml +++ b/apps/mobile/packages/features/client/orders/create_order/pubspec.yaml @@ -15,15 +15,17 @@ dependencies: equatable: ^2.0.5 intl: 0.20.2 design_system: - path: ../../../design_system + path: ../../../../design_system core_localization: - path: ../../../core_localization + path: ../../../../core_localization krow_domain: - path: ../../../domain + path: ../../../../domain krow_core: - path: ../../../core + path: ../../../../core krow_data_connect: - path: ../../../data_connect + path: ../../../../data_connect + client_orders_common: + path: ../orders_common firebase_data_connect: ^0.2.2+2 firebase_auth: ^6.1.4 diff --git a/apps/mobile/packages/features/client/orders/orders_common/.gitignore b/apps/mobile/packages/features/client/orders/orders_common/.gitignore new file mode 100644 index 00000000..3820a95c --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/.gitignore @@ -0,0 +1,45 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.build/ +.buildlog/ +.history +.svn/ +.swiftpm/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ +/coverage/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/apps/mobile/packages/features/client/orders/orders_common/.metadata b/apps/mobile/packages/features/client/orders/orders_common/.metadata new file mode 100644 index 00000000..08c24780 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "3b62efc2a3da49882f43c372e0bc53daef7295a6" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + - platform: android + create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + - platform: ios + create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + - platform: linux + create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + - platform: macos + create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + - platform: web + create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + - platform: windows + create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/apps/mobile/packages/features/client/orders/orders_common/README.md b/apps/mobile/packages/features/client/orders/orders_common/README.md new file mode 100644 index 00000000..7cb622a2 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/README.md @@ -0,0 +1,3 @@ +# orders + +A new Flutter project. diff --git a/apps/mobile/packages/features/client/orders/orders_common/analysis_options.yaml b/apps/mobile/packages/features/client/orders/orders_common/analysis_options.yaml new file mode 100644 index 00000000..f9b30346 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/.gitignore b/apps/mobile/packages/features/client/orders/orders_common/android/.gitignore new file mode 100644 index 00000000..be3943c9 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/.gitignore @@ -0,0 +1,14 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java +.cxx/ + +# Remember to never publicly share your keystore. +# See https://flutter.dev/to/reference-keystore +key.properties +**/*.keystore +**/*.jks diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/build.gradle.kts b/apps/mobile/packages/features/client/orders/orders_common/android/app/build.gradle.kts new file mode 100644 index 00000000..90fe90fe --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/app/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + id("com.android.application") + id("kotlin-android") + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id("dev.flutter.flutter-gradle-plugin") +} + +android { + namespace = "com.example.orders" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId = "com.example.orders" + // You can update the following values to match your application needs. + // For more information, see: https://flutter.dev/to/review-gradle-config. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig = signingConfigs.getByName("debug") + } + } +} + +flutter { + source = "../.." +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/debug/AndroidManifest.xml b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 00000000..399f6981 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/AndroidManifest.xml b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..b5ce4db1 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/kotlin/com/example/orders/MainActivity.kt b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/kotlin/com/example/orders/MainActivity.kt new file mode 100644 index 00000000..35c65d09 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/kotlin/com/example/orders/MainActivity.kt @@ -0,0 +1,5 @@ +package com.example.orders + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity : FlutterActivity() diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/drawable-v21/launch_background.xml b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/drawable/launch_background.xml b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 00000000..304732f8 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 00000000..db77bb4b Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 00000000..17987b79 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 00000000..09d43914 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..d5f1c8d3 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..4d6372ee Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/values-night/styles.xml b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 00000000..06952be7 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/values/styles.xml b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..cb1ef880 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/app/src/profile/AndroidManifest.xml b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 00000000..399f6981 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/build.gradle.kts b/apps/mobile/packages/features/client/orders/orders_common/android/build.gradle.kts new file mode 100644 index 00000000..dbee657b --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/build.gradle.kts @@ -0,0 +1,24 @@ +allprojects { + repositories { + google() + mavenCentral() + } +} + +val newBuildDir: Directory = + rootProject.layout.buildDirectory + .dir("../../build") + .get() +rootProject.layout.buildDirectory.value(newBuildDir) + +subprojects { + val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) + project.layout.buildDirectory.value(newSubprojectBuildDir) +} +subprojects { + project.evaluationDependsOn(":app") +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/gradle.properties b/apps/mobile/packages/features/client/orders/orders_common/android/gradle.properties new file mode 100644 index 00000000..fbee1d8c --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError +android.useAndroidX=true diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/gradle/wrapper/gradle-wrapper.properties b/apps/mobile/packages/features/client/orders/orders_common/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..e4ef43fb --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip diff --git a/apps/mobile/packages/features/client/orders/orders_common/android/settings.gradle.kts b/apps/mobile/packages/features/client/orders/orders_common/android/settings.gradle.kts new file mode 100644 index 00000000..ca7fe065 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/android/settings.gradle.kts @@ -0,0 +1,26 @@ +pluginManagement { + val flutterSdkPath = + run { + val properties = java.util.Properties() + file("local.properties").inputStream().use { properties.load(it) } + val flutterSdkPath = properties.getProperty("flutter.sdk") + require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } + flutterSdkPath + } + + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id("dev.flutter.flutter-plugin-loader") version "1.0.0" + id("com.android.application") version "8.11.1" apply false + id("org.jetbrains.kotlin.android") version "2.2.20" apply false +} + +include(":app") diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/.gitignore b/apps/mobile/packages/features/client/orders/orders_common/ios/.gitignore new file mode 100644 index 00000000..7a7f9873 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Flutter/AppFrameworkInfo.plist b/apps/mobile/packages/features/client/orders/orders_common/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 00000000..1dc6cf76 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 13.0 + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Flutter/Debug.xcconfig b/apps/mobile/packages/features/client/orders/orders_common/ios/Flutter/Debug.xcconfig new file mode 100644 index 00000000..ec97fc6f --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Flutter/Release.xcconfig b/apps/mobile/packages/features/client/orders/orders_common/ios/Flutter/Release.xcconfig new file mode 100644 index 00000000..c4855bfe --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Podfile b/apps/mobile/packages/features/client/orders/orders_common/ios/Podfile new file mode 100644 index 00000000..620e46eb --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Podfile @@ -0,0 +1,43 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '13.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/project.pbxproj b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 00000000..127c2c37 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,616 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C807D294A63A400263BE5 /* Sources */, + 331C807F294A63A400263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.orders; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.orders.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.orders.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.orders.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.orders; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.orders; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 00000000..e3773d42 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcworkspace/contents.xcworkspacedata b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..1d526a16 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/AppDelegate.swift b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/AppDelegate.swift new file mode 100644 index 00000000..62666446 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Flutter +import UIKit + +@main +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..d36b1fab --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 00000000..dc9ada47 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 00000000..7353c41e Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 00000000..797d452e Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 00000000..6ed2d933 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 00000000..4cd7b009 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 00000000..fe730945 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 00000000..321773cd Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 00000000..797d452e Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 00000000..502f463a Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 00000000..0ec30343 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 00000000..0ec30343 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 00000000..e9f5fea2 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 00000000..84ac32ae Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 00000000..8953cba0 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 00000000..0467bf12 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 00000000..0bedcf2f --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 00000000..89c2725b --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Base.lproj/LaunchScreen.storyboard b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..f2e259c7 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Base.lproj/Main.storyboard b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 00000000..f3c28516 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Info.plist b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Info.plist new file mode 100644 index 00000000..29679a5a --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Orders + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + orders + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Runner-Bridging-Header.h b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 00000000..308a2a56 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/apps/mobile/packages/features/client/orders/orders_common/ios/RunnerTests/RunnerTests.swift b/apps/mobile/packages/features/client/orders/orders_common/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 00000000..86a7c3b1 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/lib/client_orders_common.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/client_orders_common.dart new file mode 100644 index 00000000..410be326 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/lib/client_orders_common.dart @@ -0,0 +1,30 @@ +// UI Models +export 'src/presentation/widgets/order_ui_models.dart'; + +// One Time Order Widgets +export 'src/presentation/widgets/one_time_order/one_time_order_date_picker.dart'; +export 'src/presentation/widgets/one_time_order/one_time_order_event_name_input.dart'; +export 'src/presentation/widgets/one_time_order/one_time_order_header.dart'; +export 'src/presentation/widgets/one_time_order/one_time_order_location_input.dart'; +export 'src/presentation/widgets/one_time_order/one_time_order_position_card.dart'; +export 'src/presentation/widgets/one_time_order/one_time_order_section_header.dart'; +export 'src/presentation/widgets/one_time_order/one_time_order_success_view.dart'; +export 'src/presentation/widgets/one_time_order/one_time_order_view.dart'; + +// Permanent Order Widgets +export 'src/presentation/widgets/permanent_order/permanent_order_date_picker.dart'; +export 'src/presentation/widgets/permanent_order/permanent_order_event_name_input.dart'; +export 'src/presentation/widgets/permanent_order/permanent_order_header.dart'; +export 'src/presentation/widgets/permanent_order/permanent_order_position_card.dart'; +export 'src/presentation/widgets/permanent_order/permanent_order_section_header.dart'; +export 'src/presentation/widgets/permanent_order/permanent_order_success_view.dart'; +export 'src/presentation/widgets/permanent_order/permanent_order_view.dart'; + +// Recurring Order Widgets +export 'src/presentation/widgets/recurring_order/recurring_order_date_picker.dart'; +export 'src/presentation/widgets/recurring_order/recurring_order_event_name_input.dart'; +export 'src/presentation/widgets/recurring_order/recurring_order_header.dart'; +export 'src/presentation/widgets/recurring_order/recurring_order_position_card.dart'; +export 'src/presentation/widgets/recurring_order/recurring_order_section_header.dart'; +export 'src/presentation/widgets/recurring_order/recurring_order_success_view.dart'; +export 'src/presentation/widgets/recurring_order/recurring_order_view.dart'; diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_date_picker.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_date_picker.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_date_picker.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_date_picker.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_event_name_input.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_event_name_input.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_event_name_input.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_event_name_input.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_header.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_header.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_header.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_header.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_location_input.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_location_input.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_location_input.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_location_input.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_position_card.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_position_card.dart similarity index 90% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_position_card.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_position_card.dart index babb3e06..b59f81ec 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_position_card.dart +++ b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_position_card.dart @@ -1,13 +1,10 @@ import 'package:core_localization/core_localization.dart'; import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; -import 'package:krow_domain/krow_domain.dart'; -import '../../blocs/one_time_order_state.dart'; +import '../order_ui_models.dart'; /// A card widget for editing a specific position in a one-time order. -/// Matches the prototype layout while using design system tokens. class OneTimeOrderPositionCard extends StatelessWidget { - /// Creates a [OneTimeOrderPositionCard]. const OneTimeOrderPositionCard({ required this.index, required this.position, @@ -24,41 +21,18 @@ class OneTimeOrderPositionCard extends StatelessWidget { super.key, }); - /// The index of the position in the list. final int index; - - /// The position entity data. - final OneTimeOrderPosition position; - - /// Whether this position can be removed (usually if there's more than one). + final OrderPositionUiModel position; final bool isRemovable; - - /// Callback when the position data is updated. - final ValueChanged onUpdated; - - /// Callback when the position is removed. + final ValueChanged onUpdated; final VoidCallback onRemoved; - - /// Label for positions (e.g., "Position"). final String positionLabel; - - /// Label for the role selection. final String roleLabel; - - /// Label for the worker count. final String workersLabel; - - /// Label for the start time. final String startLabel; - - /// Label for the end time. final String endLabel; - - /// Label for the lunch break. final String lunchLabel; - - /// Available roles for the selected vendor. - final List roles; + final List roles; @override Widget build(BuildContext context) { @@ -250,9 +224,7 @@ class OneTimeOrderPositionCard extends StatelessWidget { 'MIN_30', 'MIN_45', 'MIN_60', - ].map(( - String value, - ) { + ].map((String value) { final String label = switch (value) { 'NO_BREAK' => 'No Break', 'MIN_10' => '10 min (Paid)', @@ -321,7 +293,7 @@ class OneTimeOrderPositionCard extends StatelessWidget { List> _buildRoleItems() { final List> items = roles .map( - (OneTimeOrderRoleOption role) => DropdownMenuItem( + (OrderRoleUiModel role) => DropdownMenuItem( value: role.id, child: Text( '${role.name} - \$${role.costPerHour.toStringAsFixed(0)}', @@ -331,7 +303,8 @@ class OneTimeOrderPositionCard extends StatelessWidget { ) .toList(); - final bool hasSelected = roles.any((OneTimeOrderRoleOption role) => role.id == position.role); + final bool hasSelected = + roles.any((OrderRoleUiModel role) => role.id == position.role); if (position.role.isNotEmpty && !hasSelected) { items.add( DropdownMenuItem( diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_section_header.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_section_header.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_section_header.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_section_header.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_success_view.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_success_view.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/one_time_order/one_time_order_success_view.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_success_view.dart diff --git a/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_view.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_view.dart new file mode 100644 index 00000000..ba891dcc --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/one_time_order/one_time_order_view.dart @@ -0,0 +1,388 @@ +import 'package:core_localization/core_localization.dart'; +import 'package:design_system/design_system.dart'; +import 'package:flutter/material.dart'; +import 'package:krow_domain/krow_domain.dart'; +import '../order_ui_models.dart'; +import 'one_time_order_date_picker.dart'; +import 'one_time_order_event_name_input.dart'; +import 'one_time_order_header.dart'; +import 'one_time_order_position_card.dart'; +import 'one_time_order_section_header.dart'; +import 'one_time_order_success_view.dart'; + +/// The main content of the One-Time Order page as a dumb widget. +class OneTimeOrderView extends StatelessWidget { + const OneTimeOrderView({ + required this.status, + required this.errorMessage, + required this.eventName, + required this.selectedVendor, + required this.vendors, + required this.date, + required this.selectedHub, + required this.hubs, + required this.positions, + required this.roles, + required this.isValid, + required this.onEventNameChanged, + required this.onVendorChanged, + required this.onDateChanged, + required this.onHubChanged, + required this.onPositionAdded, + required this.onPositionUpdated, + required this.onPositionRemoved, + required this.onSubmit, + required this.onDone, + required this.onBack, + super.key, + }); + + final OrderFormStatus status; + final String? errorMessage; + final String eventName; + final Vendor? selectedVendor; + final List vendors; + final DateTime date; + final OrderHubUiModel? selectedHub; + final List hubs; + final List positions; + final List roles; + final bool isValid; + + final ValueChanged onEventNameChanged; + final ValueChanged onVendorChanged; + final ValueChanged onDateChanged; + final ValueChanged onHubChanged; + final VoidCallback onPositionAdded; + final void Function(int index, OrderPositionUiModel position) onPositionUpdated; + final void Function(int index) onPositionRemoved; + final VoidCallback onSubmit; + final VoidCallback onDone; + final VoidCallback onBack; + + @override + Widget build(BuildContext context) { + final TranslationsClientCreateOrderOneTimeEn labels = + t.client_create_order.one_time; + + // React to error messages + if (status == OrderFormStatus.failure && errorMessage != null) { + WidgetsBinding.instance.addPostFrameCallback((_) { + UiSnackbar.show( + context, + message: translateErrorKey(errorMessage!), + type: UiSnackbarType.error, + margin: const EdgeInsets.only(bottom: 140, left: 16, right: 16), + ); + }); + } + + if (status == OrderFormStatus.success) { + return OneTimeOrderSuccessView( + title: labels.success_title, + message: labels.success_message, + buttonLabel: labels.back_to_orders, + onDone: onDone, + ); + } + + if (vendors.isEmpty && status != OrderFormStatus.loading) { + return Scaffold( + body: Column( + children: [ + OneTimeOrderHeader( + title: labels.title, + subtitle: labels.subtitle, + onBack: onBack, + ), + Expanded( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon( + UiIcons.search, + size: 64, + color: UiColors.iconInactive, + ), + const SizedBox(height: UiConstants.space4), + Text( + 'No Vendors Available', + style: UiTypography.headline3m.textPrimary, + ), + const SizedBox(height: UiConstants.space2), + Text( + 'There are no staffing vendors associated with your account.', + style: UiTypography.body2r.textSecondary, + textAlign: TextAlign.center, + ), + ], + ), + ), + ), + ], + ), + ); + } + + return Scaffold( + body: Column( + children: [ + OneTimeOrderHeader( + title: labels.title, + subtitle: labels.subtitle, + onBack: onBack, + ), + Expanded( + child: Stack( + children: [ + _OneTimeOrderForm( + eventName: eventName, + selectedVendor: selectedVendor, + vendors: vendors, + date: date, + selectedHub: selectedHub, + hubs: hubs, + positions: positions, + roles: roles, + onEventNameChanged: onEventNameChanged, + onVendorChanged: onVendorChanged, + onDateChanged: onDateChanged, + onHubChanged: onHubChanged, + onPositionAdded: onPositionAdded, + onPositionUpdated: onPositionUpdated, + onPositionRemoved: onPositionRemoved, + ), + if (status == OrderFormStatus.loading) + const Center(child: CircularProgressIndicator()), + ], + ), + ), + _BottomActionButton( + label: status == OrderFormStatus.loading + ? labels.creating + : labels.create_order, + isLoading: status == OrderFormStatus.loading, + onPressed: isValid ? onSubmit : null, + ), + ], + ), + ); + } +} + +class _OneTimeOrderForm extends StatelessWidget { + const _OneTimeOrderForm({ + required this.eventName, + required this.selectedVendor, + required this.vendors, + required this.date, + required this.selectedHub, + required this.hubs, + required this.positions, + required this.roles, + required this.onEventNameChanged, + required this.onVendorChanged, + required this.onDateChanged, + required this.onHubChanged, + required this.onPositionAdded, + required this.onPositionUpdated, + required this.onPositionRemoved, + }); + + final String eventName; + final Vendor? selectedVendor; + final List vendors; + final DateTime date; + final OrderHubUiModel? selectedHub; + final List hubs; + final List positions; + final List roles; + + final ValueChanged onEventNameChanged; + final ValueChanged onVendorChanged; + final ValueChanged onDateChanged; + final ValueChanged onHubChanged; + final VoidCallback onPositionAdded; + final void Function(int index, OrderPositionUiModel position) onPositionUpdated; + final void Function(int index) onPositionRemoved; + + @override + Widget build(BuildContext context) { + final TranslationsClientCreateOrderOneTimeEn labels = + t.client_create_order.one_time; + + return ListView( + padding: const EdgeInsets.all(UiConstants.space5), + children: [ + Text( + labels.create_your_order, + style: UiTypography.headline3m.textPrimary, + ), + const SizedBox(height: UiConstants.space4), + + OneTimeOrderEventNameInput( + label: 'ORDER NAME', + value: eventName, + onChanged: onEventNameChanged, + ), + const SizedBox(height: UiConstants.space4), + + // Vendor Selection + Text('SELECT VENDOR', style: UiTypography.footnote2r.textSecondary), + const SizedBox(height: UiConstants.space2), + Container( + padding: const EdgeInsets.symmetric(horizontal: UiConstants.space3), + height: 48, + decoration: BoxDecoration( + color: UiColors.white, + borderRadius: UiConstants.radiusMd, + border: Border.all(color: UiColors.border), + ), + child: DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: true, + value: selectedVendor, + icon: const Icon( + UiIcons.chevronDown, + size: 18, + color: UiColors.iconSecondary, + ), + onChanged: (Vendor? vendor) { + if (vendor != null) { + onVendorChanged(vendor); + } + }, + items: vendors.map((Vendor vendor) { + return DropdownMenuItem( + value: vendor, + child: Text( + vendor.name, + style: UiTypography.body2m.textPrimary, + ), + ); + }).toList(), + ), + ), + ), + const SizedBox(height: UiConstants.space4), + + OneTimeOrderDatePicker( + label: labels.date_label, + value: date, + onChanged: onDateChanged, + ), + const SizedBox(height: UiConstants.space4), + + Text('HUB', style: UiTypography.footnote2r.textSecondary), + const SizedBox(height: UiConstants.space2), + Container( + padding: const EdgeInsets.symmetric(horizontal: UiConstants.space3), + height: 48, + decoration: BoxDecoration( + color: UiColors.white, + borderRadius: UiConstants.radiusMd, + border: Border.all(color: UiColors.border), + ), + child: DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: true, + value: selectedHub, + icon: const Icon( + UiIcons.chevronDown, + size: 18, + color: UiColors.iconSecondary, + ), + onChanged: (OrderHubUiModel? hub) { + if (hub != null) { + onHubChanged(hub); + } + }, + items: hubs.map((OrderHubUiModel hub) { + return DropdownMenuItem( + value: hub, + child: Text( + hub.name, + style: UiTypography.body2m.textPrimary, + ), + ); + }).toList(), + ), + ), + ), + const SizedBox(height: UiConstants.space6), + + OneTimeOrderSectionHeader( + title: labels.positions_title, + actionLabel: labels.add_position, + onAction: onPositionAdded, + ), + const SizedBox(height: UiConstants.space3), + + // Positions List + ...positions.asMap().entries.map(( + MapEntry entry, + ) { + final int index = entry.key; + final OrderPositionUiModel position = entry.value; + return Padding( + padding: const EdgeInsets.only(bottom: UiConstants.space3), + child: OneTimeOrderPositionCard( + index: index, + position: position, + isRemovable: positions.length > 1, + positionLabel: labels.positions_title, + roleLabel: labels.select_role, + workersLabel: labels.workers_label, + startLabel: labels.start_label, + endLabel: labels.end_label, + lunchLabel: labels.lunch_break_label, + roles: roles, + onUpdated: (OrderPositionUiModel updated) { + onPositionUpdated(index, updated); + }, + onRemoved: () { + onPositionRemoved(index); + }, + ), + ); + }), + ], + ); + } +} + +class _BottomActionButton extends StatelessWidget { + const _BottomActionButton({ + required this.label, + required this.onPressed, + this.isLoading = false, + }); + final String label; + final VoidCallback? onPressed; + final bool isLoading; + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.only( + left: UiConstants.space5, + right: UiConstants.space5, + top: UiConstants.space5, + bottom: MediaQuery.of(context).padding.bottom + UiConstants.space5, + ), + decoration: const BoxDecoration( + color: UiColors.white, + border: Border(top: BorderSide(color: UiColors.border)), + ), + child: SizedBox( + width: double.infinity, + child: UiButton.primary( + text: label, + onPressed: isLoading ? null : onPressed, + size: UiButtonSize.large, + ), + ), + ); + } +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/order_ui_models.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/order_ui_models.dart new file mode 100644 index 00000000..48931710 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/order_ui_models.dart @@ -0,0 +1,96 @@ +import 'package:equatable/equatable.dart'; + +enum OrderFormStatus { initial, loading, success, failure } + +class OrderHubUiModel extends Equatable { + const OrderHubUiModel({ + required this.id, + required this.name, + required this.address, + this.placeId, + this.latitude, + this.longitude, + this.city, + this.state, + this.street, + this.country, + this.zipCode, + }); + + final String id; + final String name; + final String address; + final String? placeId; + final double? latitude; + final double? longitude; + final String? city; + final String? state; + final String? street; + final String? country; + final String? zipCode; + + @override + List get props => [ + id, + name, + address, + placeId, + latitude, + longitude, + city, + state, + street, + country, + zipCode, + ]; +} + +class OrderRoleUiModel extends Equatable { + const OrderRoleUiModel({ + required this.id, + required this.name, + required this.costPerHour, + }); + + final String id; + final String name; + final double costPerHour; + + @override + List get props => [id, name, costPerHour]; +} + +class OrderPositionUiModel extends Equatable { + const OrderPositionUiModel({ + required this.role, + required this.count, + required this.startTime, + required this.endTime, + this.lunchBreak = 'NO_BREAK', + }); + + final String role; + final int count; + final String startTime; + final String endTime; + final String lunchBreak; + + OrderPositionUiModel copyWith({ + String? role, + int? count, + String? startTime, + String? endTime, + String? lunchBreak, + }) { + return OrderPositionUiModel( + role: role ?? this.role, + count: count ?? this.count, + startTime: startTime ?? this.startTime, + endTime: endTime ?? this.endTime, + lunchBreak: lunchBreak ?? this.lunchBreak, + ); + } + + @override + List get props => [role, count, startTime, endTime, lunchBreak]; +} diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_date_picker.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_date_picker.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_date_picker.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_date_picker.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_event_name_input.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_event_name_input.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_event_name_input.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_event_name_input.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_header.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_header.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_header.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_header.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_position_card.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_position_card.dart similarity index 91% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_position_card.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_position_card.dart index eea6cb1a..25b9b02f 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_position_card.dart +++ b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_position_card.dart @@ -1,11 +1,10 @@ import 'package:core_localization/core_localization.dart'; import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; -import '../../blocs/permanent_order_state.dart'; +import '../order_ui_models.dart'; /// A card widget for editing a specific position in a permanent order. class PermanentOrderPositionCard extends StatelessWidget { - /// Creates a [PermanentOrderPositionCard]. const PermanentOrderPositionCard({ required this.index, required this.position, @@ -22,41 +21,18 @@ class PermanentOrderPositionCard extends StatelessWidget { super.key, }); - /// The index of the position in the list. final int index; - - /// The position entity data. - final PermanentOrderPosition position; - - /// Whether this position can be removed (usually if there's more than one). + final OrderPositionUiModel position; final bool isRemovable; - - /// Callback when the position data is updated. - final ValueChanged onUpdated; - - /// Callback when the position is removed. + final ValueChanged onUpdated; final VoidCallback onRemoved; - - /// Label for positions (e.g., "Position"). final String positionLabel; - - /// Label for the role selection. final String roleLabel; - - /// Label for the worker count. final String workersLabel; - - /// Label for the start time. final String startLabel; - - /// Label for the end time. final String endLabel; - - /// Label for the lunch break. final String lunchLabel; - - /// Available roles for the selected vendor. - final List roles; + final List roles; @override Widget build(BuildContext context) { @@ -317,7 +293,7 @@ class PermanentOrderPositionCard extends StatelessWidget { List> _buildRoleItems() { final List> items = roles .map( - (PermanentOrderRoleOption role) => DropdownMenuItem( + (OrderRoleUiModel role) => DropdownMenuItem( value: role.id, child: Text( '${role.name} - \$${role.costPerHour.toStringAsFixed(0)}', @@ -327,7 +303,7 @@ class PermanentOrderPositionCard extends StatelessWidget { ) .toList(); - final bool hasSelected = roles.any((PermanentOrderRoleOption role) => role.id == position.role); + final bool hasSelected = roles.any((OrderRoleUiModel role) => role.id == position.role); if (position.role.isNotEmpty && !hasSelected) { items.add( DropdownMenuItem( diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_section_header.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_section_header.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_section_header.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_section_header.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_success_view.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_success_view.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_success_view.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_success_view.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_view.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_view.dart similarity index 51% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_view.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_view.dart index c5041687..c33d3641 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/permanent_order/permanent_order_view.dart +++ b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/permanent_order/permanent_order_view.dart @@ -1,13 +1,8 @@ import 'package:core_localization/core_localization.dart'; import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_modular/flutter_modular.dart'; -import 'package:krow_core/core.dart'; import 'package:krow_domain/krow_domain.dart' show Vendor; -import '../../blocs/permanent_order_bloc.dart'; -import '../../blocs/permanent_order_event.dart'; -import '../../blocs/permanent_order_state.dart'; +import '../order_ui_models.dart'; import 'permanent_order_date_picker.dart'; import 'permanent_order_event_name_input.dart'; import 'permanent_order_header.dart'; @@ -17,44 +12,57 @@ import 'permanent_order_success_view.dart'; /// The main content of the Permanent Order page. class PermanentOrderView extends StatelessWidget { - /// Creates a [PermanentOrderView]. - const PermanentOrderView({super.key}); + const PermanentOrderView({ + required this.status, + required this.errorMessage, + required this.eventName, + required this.selectedVendor, + required this.vendors, + required this.startDate, + required this.permanentDays, + required this.selectedHub, + required this.hubs, + required this.positions, + required this.roles, + required this.isValid, + required this.onEventNameChanged, + required this.onVendorChanged, + required this.onStartDateChanged, + required this.onDayToggled, + required this.onHubChanged, + required this.onPositionAdded, + required this.onPositionUpdated, + required this.onPositionRemoved, + required this.onSubmit, + required this.onDone, + required this.onBack, + super.key, + }); - DateTime _firstPermanentShiftDate( - DateTime startDate, - List permanentDays, - ) { - final DateTime start = DateTime(startDate.year, startDate.month, startDate.day); - final DateTime end = start.add(const Duration(days: 29)); - final Set selected = permanentDays.toSet(); - for (DateTime day = start; !day.isAfter(end); day = day.add(const Duration(days: 1))) { - if (selected.contains(_weekdayLabel(day))) { - return day; - } - } - return start; - } + final OrderFormStatus status; + final String? errorMessage; + final String eventName; + final Vendor? selectedVendor; + final List vendors; + final DateTime startDate; + final List permanentDays; + final OrderHubUiModel? selectedHub; + final List hubs; + final List positions; + final List roles; + final bool isValid; - String _weekdayLabel(DateTime date) { - switch (date.weekday) { - case DateTime.monday: - return 'MON'; - case DateTime.tuesday: - return 'TUE'; - case DateTime.wednesday: - return 'WED'; - case DateTime.thursday: - return 'THU'; - case DateTime.friday: - return 'FRI'; - case DateTime.saturday: - return 'SAT'; - case DateTime.sunday: - return 'SUN'; - default: - return 'SUN'; - } - } + final ValueChanged onEventNameChanged; + final ValueChanged onVendorChanged; + final ValueChanged onStartDateChanged; + final ValueChanged onDayToggled; + final ValueChanged onHubChanged; + final VoidCallback onPositionAdded; + final void Function(int index, OrderPositionUiModel position) onPositionUpdated; + final void Function(int index) onPositionRemoved; + final VoidCallback onSubmit; + final VoidCallback onDone; + final VoidCallback onBack; @override Widget build(BuildContext context) { @@ -63,118 +71,152 @@ class PermanentOrderView extends StatelessWidget { final TranslationsClientCreateOrderOneTimeEn oneTimeLabels = t.client_create_order.one_time; - return BlocConsumer( - listener: (BuildContext context, PermanentOrderState state) { - if (state.status == PermanentOrderStatus.failure && - state.errorMessage != null) { - final String message = translateErrorKey(state.errorMessage!); - UiSnackbar.show( - context, - message: message, - type: UiSnackbarType.error, - margin: const EdgeInsets.only(bottom: 140, left: 16, right: 16), - ); - } - }, - builder: (BuildContext context, PermanentOrderState state) { - if (state.status == PermanentOrderStatus.success) { - final DateTime initialDate = _firstPermanentShiftDate( - state.startDate, - state.permanentDays, - ); - return PermanentOrderSuccessView( - title: labels.title, - message: labels.subtitle, - buttonLabel: oneTimeLabels.back_to_orders, - onDone: () => Modular.to.pushNamedAndRemoveUntil( - ClientPaths.orders, - (_) => false, - arguments: { - 'initialDate': initialDate.toIso8601String(), - }, - ), - ); - } + if (status == OrderFormStatus.failure && errorMessage != null) { + WidgetsBinding.instance.addPostFrameCallback((_) { + UiSnackbar.show( + context, + message: translateErrorKey(errorMessage!), + type: UiSnackbarType.error, + margin: const EdgeInsets.only(bottom: 140, left: 16, right: 16), + ); + }); + } - if (state.vendors.isEmpty && - state.status != PermanentOrderStatus.loading) { - return Scaffold( - body: Column( - children: [ - PermanentOrderHeader( - title: labels.title, - subtitle: labels.subtitle, - onBack: () => Modular.to.navigate(ClientPaths.createOrder), - ), - Expanded( - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon( - UiIcons.search, - size: 64, - color: UiColors.iconInactive, - ), - const SizedBox(height: UiConstants.space4), - Text( - 'No Vendors Available', - style: UiTypography.headline3m.textPrimary, - ), - const SizedBox(height: UiConstants.space2), - Text( - 'There are no staffing vendors associated with your account.', - style: UiTypography.body2r.textSecondary, - textAlign: TextAlign.center, - ), - ], - ), - ), - ), - ], - ), - ); - } + if (status == OrderFormStatus.success) { + return PermanentOrderSuccessView( + title: labels.title, + message: labels.subtitle, + buttonLabel: oneTimeLabels.back_to_orders, + onDone: onDone, + ); + } - return Scaffold( - body: Column( - children: [ - PermanentOrderHeader( - title: labels.title, - subtitle: labels.subtitle, - onBack: () => Modular.to.navigate(ClientPaths.createOrder), - ), - Expanded( - child: Stack( + if (vendors.isEmpty && status != OrderFormStatus.loading) { + return Scaffold( + body: Column( + children: [ + PermanentOrderHeader( + title: labels.title, + subtitle: labels.subtitle, + onBack: onBack, + ), + Expanded( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ - _PermanentOrderForm(state: state), - if (state.status == PermanentOrderStatus.loading) - const Center(child: CircularProgressIndicator()), + const Icon( + UiIcons.search, + size: 64, + color: UiColors.iconInactive, + ), + const SizedBox(height: UiConstants.space4), + Text( + 'No Vendors Available', + style: UiTypography.headline3m.textPrimary, + ), + const SizedBox(height: UiConstants.space2), + Text( + 'There are no staffing vendors associated with your account.', + style: UiTypography.body2r.textSecondary, + textAlign: TextAlign.center, + ), ], ), ), - _BottomActionButton( - label: state.status == PermanentOrderStatus.loading - ? oneTimeLabels.creating - : oneTimeLabels.create_order, - isLoading: state.status == PermanentOrderStatus.loading, - onPressed: state.isValid - ? () => BlocProvider.of( - context, - ).add(const PermanentOrderSubmitted()) - : null, - ), - ], + ), + ], + ), + ); + } + + return Scaffold( + body: Column( + children: [ + PermanentOrderHeader( + title: labels.title, + subtitle: labels.subtitle, + onBack: onBack, ), - ); - }, + Expanded( + child: Stack( + children: [ + _PermanentOrderForm( + eventName: eventName, + selectedVendor: selectedVendor, + vendors: vendors, + startDate: startDate, + permanentDays: permanentDays, + selectedHub: selectedHub, + hubs: hubs, + positions: positions, + roles: roles, + onEventNameChanged: onEventNameChanged, + onVendorChanged: onVendorChanged, + onStartDateChanged: onStartDateChanged, + onDayToggled: onDayToggled, + onHubChanged: onHubChanged, + onPositionAdded: onPositionAdded, + onPositionUpdated: onPositionUpdated, + onPositionRemoved: onPositionRemoved, + ), + if (status == OrderFormStatus.loading) + const Center(child: CircularProgressIndicator()), + ], + ), + ), + _BottomActionButton( + label: status == OrderFormStatus.loading + ? oneTimeLabels.creating + : oneTimeLabels.create_order, + isLoading: status == OrderFormStatus.loading, + onPressed: isValid ? onSubmit : null, + ), + ], + ), ); } } class _PermanentOrderForm extends StatelessWidget { - const _PermanentOrderForm({required this.state}); - final PermanentOrderState state; + const _PermanentOrderForm({ + required this.eventName, + required this.selectedVendor, + required this.vendors, + required this.startDate, + required this.permanentDays, + required this.selectedHub, + required this.hubs, + required this.positions, + required this.roles, + required this.onEventNameChanged, + required this.onVendorChanged, + required this.onStartDateChanged, + required this.onDayToggled, + required this.onHubChanged, + required this.onPositionAdded, + required this.onPositionUpdated, + required this.onPositionRemoved, + }); + + final String eventName; + final Vendor? selectedVendor; + final List vendors; + final DateTime startDate; + final List permanentDays; + final OrderHubUiModel? selectedHub; + final List hubs; + final List positions; + final List roles; + + final ValueChanged onEventNameChanged; + final ValueChanged onVendorChanged; + final ValueChanged onStartDateChanged; + final ValueChanged onDayToggled; + final ValueChanged onHubChanged; + final VoidCallback onPositionAdded; + final void Function(int index, OrderPositionUiModel position) onPositionUpdated; + final void Function(int index) onPositionRemoved; @override Widget build(BuildContext context) { @@ -194,10 +236,8 @@ class _PermanentOrderForm extends StatelessWidget { PermanentOrderEventNameInput( label: 'ORDER NAME', - value: state.eventName, - onChanged: (String value) => BlocProvider.of( - context, - ).add(PermanentOrderEventNameChanged(value)), + value: eventName, + onChanged: onEventNameChanged, ), const SizedBox(height: UiConstants.space4), @@ -215,7 +255,7 @@ class _PermanentOrderForm extends StatelessWidget { child: DropdownButtonHideUnderline( child: DropdownButton( isExpanded: true, - value: state.selectedVendor, + value: selectedVendor, icon: const Icon( UiIcons.chevronDown, size: 18, @@ -223,12 +263,10 @@ class _PermanentOrderForm extends StatelessWidget { ), onChanged: (Vendor? vendor) { if (vendor != null) { - BlocProvider.of( - context, - ).add(PermanentOrderVendorChanged(vendor)); + onVendorChanged(vendor); } }, - items: state.vendors.map((Vendor vendor) { + items: vendors.map((Vendor vendor) { return DropdownMenuItem( value: vendor, child: Text( @@ -244,20 +282,16 @@ class _PermanentOrderForm extends StatelessWidget { PermanentOrderDatePicker( label: 'Start Date', - value: state.startDate, - onChanged: (DateTime date) => BlocProvider.of( - context, - ).add(PermanentOrderStartDateChanged(date)), + value: startDate, + onChanged: onStartDateChanged, ), const SizedBox(height: UiConstants.space4), Text('Permanent Days', style: UiTypography.footnote2r.textSecondary), const SizedBox(height: UiConstants.space2), _PermanentDaysSelector( - selectedDays: state.permanentDays, - onToggle: (int dayIndex) => BlocProvider.of( - context, - ).add(PermanentOrderDayToggled(dayIndex)), + selectedDays: permanentDays, + onToggle: onDayToggled, ), const SizedBox(height: UiConstants.space4), @@ -272,23 +306,21 @@ class _PermanentOrderForm extends StatelessWidget { border: Border.all(color: UiColors.border), ), child: DropdownButtonHideUnderline( - child: DropdownButton( + child: DropdownButton( isExpanded: true, - value: state.selectedHub, + value: selectedHub, icon: const Icon( UiIcons.chevronDown, size: 18, color: UiColors.iconSecondary, ), - onChanged: (PermanentOrderHubOption? hub) { + onChanged: (OrderHubUiModel? hub) { if (hub != null) { - BlocProvider.of( - context, - ).add(PermanentOrderHubChanged(hub)); + onHubChanged(hub); } }, - items: state.hubs.map((PermanentOrderHubOption hub) { - return DropdownMenuItem( + items: hubs.map((OrderHubUiModel hub) { + return DropdownMenuItem( value: hub, child: Text( hub.name, @@ -304,40 +336,34 @@ class _PermanentOrderForm extends StatelessWidget { PermanentOrderSectionHeader( title: oneTimeLabels.positions_title, actionLabel: oneTimeLabels.add_position, - onAction: () => BlocProvider.of( - context, - ).add(const PermanentOrderPositionAdded()), + onAction: onPositionAdded, ), const SizedBox(height: UiConstants.space3), // Positions List - ...state.positions.asMap().entries.map(( - MapEntry entry, + ...positions.asMap().entries.map(( + MapEntry entry, ) { final int index = entry.key; - final PermanentOrderPosition position = entry.value; + final OrderPositionUiModel position = entry.value; return Padding( padding: const EdgeInsets.only(bottom: UiConstants.space3), child: PermanentOrderPositionCard( index: index, position: position, - isRemovable: state.positions.length > 1, + isRemovable: positions.length > 1, positionLabel: oneTimeLabels.positions_title, roleLabel: oneTimeLabels.select_role, workersLabel: oneTimeLabels.workers_label, startLabel: oneTimeLabels.start_label, endLabel: oneTimeLabels.end_label, lunchLabel: oneTimeLabels.lunch_break_label, - roles: state.roles, - onUpdated: (PermanentOrderPosition updated) { - BlocProvider.of( - context, - ).add(PermanentOrderPositionUpdated(index, updated)); + roles: roles, + onUpdated: (OrderPositionUiModel updated) { + onPositionUpdated(index, updated); }, onRemoved: () { - BlocProvider.of( - context, - ).add(PermanentOrderPositionRemoved(index)); + onPositionRemoved(index); }, ), ); diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_date_picker.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_date_picker.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_date_picker.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_date_picker.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_event_name_input.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_event_name_input.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_event_name_input.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_event_name_input.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_header.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_header.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_header.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_header.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_position_card.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_position_card.dart similarity index 91% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_position_card.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_position_card.dart index f6b94670..d6c038af 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_position_card.dart +++ b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_position_card.dart @@ -1,11 +1,10 @@ import 'package:core_localization/core_localization.dart'; import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; -import '../../blocs/recurring_order_state.dart'; +import '../order_ui_models.dart'; /// A card widget for editing a specific position in a recurring order. class RecurringOrderPositionCard extends StatelessWidget { - /// Creates a [RecurringOrderPositionCard]. const RecurringOrderPositionCard({ required this.index, required this.position, @@ -22,41 +21,18 @@ class RecurringOrderPositionCard extends StatelessWidget { super.key, }); - /// The index of the position in the list. final int index; - - /// The position entity data. - final RecurringOrderPosition position; - - /// Whether this position can be removed (usually if there's more than one). + final OrderPositionUiModel position; final bool isRemovable; - - /// Callback when the position data is updated. - final ValueChanged onUpdated; - - /// Callback when the position is removed. + final ValueChanged onUpdated; final VoidCallback onRemoved; - - /// Label for positions (e.g., "Position"). final String positionLabel; - - /// Label for the role selection. final String roleLabel; - - /// Label for the worker count. final String workersLabel; - - /// Label for the start time. final String startLabel; - - /// Label for the end time. final String endLabel; - - /// Label for the lunch break. final String lunchLabel; - - /// Available roles for the selected vendor. - final List roles; + final List roles; @override Widget build(BuildContext context) { @@ -317,7 +293,7 @@ class RecurringOrderPositionCard extends StatelessWidget { List> _buildRoleItems() { final List> items = roles .map( - (RecurringOrderRoleOption role) => DropdownMenuItem( + (OrderRoleUiModel role) => DropdownMenuItem( value: role.id, child: Text( '${role.name} - \$${role.costPerHour.toStringAsFixed(0)}', @@ -327,7 +303,7 @@ class RecurringOrderPositionCard extends StatelessWidget { ) .toList(); - final bool hasSelected = roles.any((RecurringOrderRoleOption role) => role.id == position.role); + final bool hasSelected = roles.any((OrderRoleUiModel role) => role.id == position.role); if (position.role.isNotEmpty && !hasSelected) { items.add( DropdownMenuItem( diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_section_header.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_section_header.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_section_header.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_section_header.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_success_view.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_success_view.dart similarity index 100% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_success_view.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_success_view.dart diff --git a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_view.dart b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_view.dart similarity index 50% rename from apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_view.dart rename to apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_view.dart index a6f173c8..18c01872 100644 --- a/apps/mobile/packages/features/client/create_order/lib/src/presentation/widgets/recurring_order/recurring_order_view.dart +++ b/apps/mobile/packages/features/client/orders/orders_common/lib/src/presentation/widgets/recurring_order/recurring_order_view.dart @@ -2,12 +2,7 @@ import 'package:core_localization/core_localization.dart'; import 'package:krow_domain/krow_domain.dart' show Vendor; import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_modular/flutter_modular.dart'; -import 'package:krow_core/core.dart'; -import '../../blocs/recurring_order_bloc.dart'; -import '../../blocs/recurring_order_event.dart'; -import '../../blocs/recurring_order_state.dart'; +import '../order_ui_models.dart'; import 'recurring_order_date_picker.dart'; import 'recurring_order_event_name_input.dart'; import 'recurring_order_header.dart'; @@ -17,45 +12,61 @@ import 'recurring_order_success_view.dart'; /// The main content of the Recurring Order page. class RecurringOrderView extends StatelessWidget { - /// Creates a [RecurringOrderView]. - const RecurringOrderView({super.key}); + const RecurringOrderView({ + required this.status, + required this.errorMessage, + required this.eventName, + required this.selectedVendor, + required this.vendors, + required this.startDate, + required this.endDate, + required this.recurringDays, + required this.selectedHub, + required this.hubs, + required this.positions, + required this.roles, + required this.isValid, + required this.onEventNameChanged, + required this.onVendorChanged, + required this.onStartDateChanged, + required this.onEndDateChanged, + required this.onDayToggled, + required this.onHubChanged, + required this.onPositionAdded, + required this.onPositionUpdated, + required this.onPositionRemoved, + required this.onSubmit, + required this.onDone, + required this.onBack, + super.key, + }); - DateTime _firstRecurringShiftDate( - DateTime startDate, - DateTime endDate, - List recurringDays, - ) { - final DateTime start = DateTime(startDate.year, startDate.month, startDate.day); - final DateTime end = DateTime(endDate.year, endDate.month, endDate.day); - final Set selected = recurringDays.toSet(); - for (DateTime day = start; !day.isAfter(end); day = day.add(const Duration(days: 1))) { - if (selected.contains(_weekdayLabel(day))) { - return day; - } - } - return start; - } + final OrderFormStatus status; + final String? errorMessage; + final String eventName; + final Vendor? selectedVendor; + final List vendors; + final DateTime startDate; + final DateTime endDate; + final List recurringDays; + final OrderHubUiModel? selectedHub; + final List hubs; + final List positions; + final List roles; + final bool isValid; - String _weekdayLabel(DateTime date) { - switch (date.weekday) { - case DateTime.monday: - return 'MON'; - case DateTime.tuesday: - return 'TUE'; - case DateTime.wednesday: - return 'WED'; - case DateTime.thursday: - return 'THU'; - case DateTime.friday: - return 'FRI'; - case DateTime.saturday: - return 'SAT'; - case DateTime.sunday: - return 'SUN'; - default: - return 'SUN'; - } - } + final ValueChanged onEventNameChanged; + final ValueChanged onVendorChanged; + final ValueChanged onStartDateChanged; + final ValueChanged onEndDateChanged; + final ValueChanged onDayToggled; + final ValueChanged onHubChanged; + final VoidCallback onPositionAdded; + final void Function(int index, OrderPositionUiModel position) onPositionUpdated; + final void Function(int index) onPositionRemoved; + final VoidCallback onSubmit; + final VoidCallback onDone; + final VoidCallback onBack; @override Widget build(BuildContext context) { @@ -64,125 +75,161 @@ class RecurringOrderView extends StatelessWidget { final TranslationsClientCreateOrderOneTimeEn oneTimeLabels = t.client_create_order.one_time; - return BlocConsumer( - listener: (BuildContext context, RecurringOrderState state) { - if (state.status == RecurringOrderStatus.failure && - state.errorMessage != null) { - final String message = state.errorMessage == 'placeholder' - ? labels.placeholder - : translateErrorKey(state.errorMessage!); - UiSnackbar.show( - context, - message: message, - type: UiSnackbarType.error, - margin: const EdgeInsets.only(bottom: 140, left: 16, right: 16), - ); - } - }, - builder: (BuildContext context, RecurringOrderState state) { - if (state.status == RecurringOrderStatus.success) { - final DateTime maxEndDate = - state.startDate.add(const Duration(days: 29)); - final DateTime effectiveEndDate = - state.endDate.isAfter(maxEndDate) ? maxEndDate : state.endDate; - final DateTime initialDate = _firstRecurringShiftDate( - state.startDate, - effectiveEndDate, - state.recurringDays, - ); - return RecurringOrderSuccessView( - title: labels.title, - message: labels.subtitle, - buttonLabel: oneTimeLabels.back_to_orders, - onDone: () => Modular.to.pushNamedAndRemoveUntil( - ClientPaths.orders, - (_) => false, - arguments: { - 'initialDate': initialDate.toIso8601String(), - }, - ), - ); - } + if (status == OrderFormStatus.failure && errorMessage != null) { + WidgetsBinding.instance.addPostFrameCallback((_) { + final String message = errorMessage == 'placeholder' + ? labels.placeholder + : translateErrorKey(errorMessage!); + UiSnackbar.show( + context, + message: message, + type: UiSnackbarType.error, + margin: const EdgeInsets.only(bottom: 140, left: 16, right: 16), + ); + }); + } - if (state.vendors.isEmpty && - state.status != RecurringOrderStatus.loading) { - return Scaffold( - body: Column( - children: [ - RecurringOrderHeader( - title: labels.title, - subtitle: labels.subtitle, - onBack: () => Modular.to.navigate(ClientPaths.createOrder), - ), - Expanded( - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon( - UiIcons.search, - size: 64, - color: UiColors.iconInactive, - ), - const SizedBox(height: UiConstants.space4), - Text( - 'No Vendors Available', - style: UiTypography.headline3m.textPrimary, - ), - const SizedBox(height: UiConstants.space2), - Text( - 'There are no staffing vendors associated with your account.', - style: UiTypography.body2r.textSecondary, - textAlign: TextAlign.center, - ), - ], - ), - ), - ), - ], - ), - ); - } + if (status == OrderFormStatus.success) { + return RecurringOrderSuccessView( + title: labels.title, + message: labels.subtitle, + buttonLabel: oneTimeLabels.back_to_orders, + onDone: onDone, + ); + } - return Scaffold( - body: Column( - children: [ - RecurringOrderHeader( - title: labels.title, - subtitle: labels.subtitle, - onBack: () => Modular.to.navigate(ClientPaths.createOrder), - ), - Expanded( - child: Stack( + if (vendors.isEmpty && status != OrderFormStatus.loading) { + return Scaffold( + body: Column( + children: [ + RecurringOrderHeader( + title: labels.title, + subtitle: labels.subtitle, + onBack: onBack, + ), + Expanded( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ - _RecurringOrderForm(state: state), - if (state.status == RecurringOrderStatus.loading) - const Center(child: CircularProgressIndicator()), + const Icon( + UiIcons.search, + size: 64, + color: UiColors.iconInactive, + ), + const SizedBox(height: UiConstants.space4), + Text( + 'No Vendors Available', + style: UiTypography.headline3m.textPrimary, + ), + const SizedBox(height: UiConstants.space2), + Text( + 'There are no staffing vendors associated with your account.', + style: UiTypography.body2r.textSecondary, + textAlign: TextAlign.center, + ), ], ), ), - _BottomActionButton( - label: state.status == RecurringOrderStatus.loading - ? oneTimeLabels.creating - : oneTimeLabels.create_order, - isLoading: state.status == RecurringOrderStatus.loading, - onPressed: state.isValid - ? () => BlocProvider.of( - context, - ).add(const RecurringOrderSubmitted()) - : null, - ), - ], + ), + ], + ), + ); + } + + return Scaffold( + body: Column( + children: [ + RecurringOrderHeader( + title: labels.title, + subtitle: labels.subtitle, + onBack: onBack, ), - ); - }, + Expanded( + child: Stack( + children: [ + _RecurringOrderForm( + eventName: eventName, + selectedVendor: selectedVendor, + vendors: vendors, + startDate: startDate, + endDate: endDate, + recurringDays: recurringDays, + selectedHub: selectedHub, + hubs: hubs, + positions: positions, + roles: roles, + onEventNameChanged: onEventNameChanged, + onVendorChanged: onVendorChanged, + onStartDateChanged: onStartDateChanged, + onEndDateChanged: onEndDateChanged, + onDayToggled: onDayToggled, + onHubChanged: onHubChanged, + onPositionAdded: onPositionAdded, + onPositionUpdated: onPositionUpdated, + onPositionRemoved: onPositionRemoved, + ), + if (status == OrderFormStatus.loading) + const Center(child: CircularProgressIndicator()), + ], + ), + ), + _BottomActionButton( + label: status == OrderFormStatus.loading + ? oneTimeLabels.creating + : oneTimeLabels.create_order, + isLoading: status == OrderFormStatus.loading, + onPressed: isValid ? onSubmit : null, + ), + ], + ), ); } } class _RecurringOrderForm extends StatelessWidget { - const _RecurringOrderForm({required this.state}); - final RecurringOrderState state; + const _RecurringOrderForm({ + required this.eventName, + required this.selectedVendor, + required this.vendors, + required this.startDate, + required this.endDate, + required this.recurringDays, + required this.selectedHub, + required this.hubs, + required this.positions, + required this.roles, + required this.onEventNameChanged, + required this.onVendorChanged, + required this.onStartDateChanged, + required this.onEndDateChanged, + required this.onDayToggled, + required this.onHubChanged, + required this.onPositionAdded, + required this.onPositionUpdated, + required this.onPositionRemoved, + }); + + final String eventName; + final Vendor? selectedVendor; + final List vendors; + final DateTime startDate; + final DateTime endDate; + final List recurringDays; + final OrderHubUiModel? selectedHub; + final List hubs; + final List positions; + final List roles; + + final ValueChanged onEventNameChanged; + final ValueChanged onVendorChanged; + final ValueChanged onStartDateChanged; + final ValueChanged onEndDateChanged; + final ValueChanged onDayToggled; + final ValueChanged onHubChanged; + final VoidCallback onPositionAdded; + final void Function(int index, OrderPositionUiModel position) onPositionUpdated; + final void Function(int index) onPositionRemoved; @override Widget build(BuildContext context) { @@ -202,10 +249,8 @@ class _RecurringOrderForm extends StatelessWidget { RecurringOrderEventNameInput( label: 'ORDER NAME', - value: state.eventName, - onChanged: (String value) => BlocProvider.of( - context, - ).add(RecurringOrderEventNameChanged(value)), + value: eventName, + onChanged: onEventNameChanged, ), const SizedBox(height: UiConstants.space4), @@ -223,7 +268,7 @@ class _RecurringOrderForm extends StatelessWidget { child: DropdownButtonHideUnderline( child: DropdownButton( isExpanded: true, - value: state.selectedVendor, + value: selectedVendor, icon: const Icon( UiIcons.chevronDown, size: 18, @@ -231,12 +276,10 @@ class _RecurringOrderForm extends StatelessWidget { ), onChanged: (Vendor? vendor) { if (vendor != null) { - BlocProvider.of( - context, - ).add(RecurringOrderVendorChanged(vendor)); + onVendorChanged(vendor); } }, - items: state.vendors.map((Vendor vendor) { + items: vendors.map((Vendor vendor) { return DropdownMenuItem( value: vendor, child: Text( @@ -252,29 +295,23 @@ class _RecurringOrderForm extends StatelessWidget { RecurringOrderDatePicker( label: 'Start Date', - value: state.startDate, - onChanged: (DateTime date) => BlocProvider.of( - context, - ).add(RecurringOrderStartDateChanged(date)), + value: startDate, + onChanged: onStartDateChanged, ), const SizedBox(height: UiConstants.space4), RecurringOrderDatePicker( label: 'End Date', - value: state.endDate, - onChanged: (DateTime date) => BlocProvider.of( - context, - ).add(RecurringOrderEndDateChanged(date)), + value: endDate, + onChanged: onEndDateChanged, ), const SizedBox(height: UiConstants.space4), Text('Recurring Days', style: UiTypography.footnote2r.textSecondary), const SizedBox(height: UiConstants.space2), _RecurringDaysSelector( - selectedDays: state.recurringDays, - onToggle: (int dayIndex) => BlocProvider.of( - context, - ).add(RecurringOrderDayToggled(dayIndex)), + selectedDays: recurringDays, + onToggle: onDayToggled, ), const SizedBox(height: UiConstants.space4), @@ -289,23 +326,21 @@ class _RecurringOrderForm extends StatelessWidget { border: Border.all(color: UiColors.border), ), child: DropdownButtonHideUnderline( - child: DropdownButton( + child: DropdownButton( isExpanded: true, - value: state.selectedHub, + value: selectedHub, icon: const Icon( UiIcons.chevronDown, size: 18, color: UiColors.iconSecondary, ), - onChanged: (RecurringOrderHubOption? hub) { + onChanged: (OrderHubUiModel? hub) { if (hub != null) { - BlocProvider.of( - context, - ).add(RecurringOrderHubChanged(hub)); + onHubChanged(hub); } }, - items: state.hubs.map((RecurringOrderHubOption hub) { - return DropdownMenuItem( + items: hubs.map((OrderHubUiModel hub) { + return DropdownMenuItem( value: hub, child: Text( hub.name, @@ -321,40 +356,34 @@ class _RecurringOrderForm extends StatelessWidget { RecurringOrderSectionHeader( title: oneTimeLabels.positions_title, actionLabel: oneTimeLabels.add_position, - onAction: () => BlocProvider.of( - context, - ).add(const RecurringOrderPositionAdded()), + onAction: onPositionAdded, ), const SizedBox(height: UiConstants.space3), // Positions List - ...state.positions.asMap().entries.map(( - MapEntry entry, + ...positions.asMap().entries.map(( + MapEntry entry, ) { final int index = entry.key; - final RecurringOrderPosition position = entry.value; + final OrderPositionUiModel position = entry.value; return Padding( padding: const EdgeInsets.only(bottom: UiConstants.space3), child: RecurringOrderPositionCard( index: index, position: position, - isRemovable: state.positions.length > 1, + isRemovable: positions.length > 1, positionLabel: oneTimeLabels.positions_title, roleLabel: oneTimeLabels.select_role, workersLabel: oneTimeLabels.workers_label, startLabel: oneTimeLabels.start_label, endLabel: oneTimeLabels.end_label, lunchLabel: oneTimeLabels.lunch_break_label, - roles: state.roles, - onUpdated: (RecurringOrderPosition updated) { - BlocProvider.of( - context, - ).add(RecurringOrderPositionUpdated(index, updated)); + roles: roles, + onUpdated: (OrderPositionUiModel updated) { + onPositionUpdated(index, updated); }, onRemoved: () { - BlocProvider.of( - context, - ).add(RecurringOrderPositionRemoved(index)); + onPositionRemoved(index); }, ), ); diff --git a/apps/mobile/packages/features/client/orders/orders_common/linux/.gitignore b/apps/mobile/packages/features/client/orders/orders_common/linux/.gitignore new file mode 100644 index 00000000..d3896c98 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/apps/mobile/packages/features/client/orders/orders_common/linux/CMakeLists.txt b/apps/mobile/packages/features/client/orders/orders_common/linux/CMakeLists.txt new file mode 100644 index 00000000..baa70a9b --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/linux/CMakeLists.txt @@ -0,0 +1,128 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.13) +project(runner LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "orders") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.example.orders") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/apps/mobile/packages/features/client/orders/orders_common/linux/flutter/CMakeLists.txt b/apps/mobile/packages/features/client/orders/orders_common/linux/flutter/CMakeLists.txt new file mode 100644 index 00000000..d5bd0164 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/apps/mobile/packages/features/client/orders/orders_common/linux/flutter/generated_plugin_registrant.cc b/apps/mobile/packages/features/client/orders/orders_common/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 00000000..e71a16d2 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/linux/flutter/generated_plugin_registrant.h b/apps/mobile/packages/features/client/orders/orders_common/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 00000000..e0f0a47b --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/apps/mobile/packages/features/client/orders/orders_common/linux/flutter/generated_plugins.cmake b/apps/mobile/packages/features/client/orders/orders_common/linux/flutter/generated_plugins.cmake new file mode 100644 index 00000000..2e1de87a --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/linux/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/apps/mobile/packages/features/client/orders/orders_common/linux/runner/CMakeLists.txt b/apps/mobile/packages/features/client/orders/orders_common/linux/runner/CMakeLists.txt new file mode 100644 index 00000000..e97dabc7 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/linux/runner/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.13) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the application ID. +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") diff --git a/apps/mobile/packages/features/client/orders/orders_common/linux/runner/main.cc b/apps/mobile/packages/features/client/orders/orders_common/linux/runner/main.cc new file mode 100644 index 00000000..e7c5c543 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/linux/runner/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/linux/runner/my_application.cc b/apps/mobile/packages/features/client/orders/orders_common/linux/runner/my_application.cc new file mode 100644 index 00000000..a7314d70 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/linux/runner/my_application.cc @@ -0,0 +1,148 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Called when first Flutter frame received. +static void first_frame_cb(MyApplication* self, FlView* view) { + gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view))); +} + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "orders"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "orders"); + } + + gtk_window_set_default_size(window, 1280, 720); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments( + project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + GdkRGBA background_color; + // Background defaults to black, override it here if necessary, e.g. #00000000 + // for transparent. + gdk_rgba_parse(&background_color, "#000000"); + fl_view_set_background_color(view, &background_color); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + // Show the window when Flutter renders. + // Requires the view to be realized so we can start rendering. + g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), + self); + gtk_widget_realize(GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, + gchar*** arguments, + int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GApplication::startup. +static void my_application_startup(GApplication* application) { + // MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application startup. + + G_APPLICATION_CLASS(my_application_parent_class)->startup(application); +} + +// Implements GApplication::shutdown. +static void my_application_shutdown(GApplication* application) { + // MyApplication* self = MY_APPLICATION(object); + + // Perform any actions required at application shutdown. + + G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = + my_application_local_command_line; + G_APPLICATION_CLASS(klass)->startup = my_application_startup; + G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + // Set the program name to the application ID, which helps various systems + // like GTK and desktop environments map this running application to its + // corresponding .desktop file. This ensures better integration by allowing + // the application to be recognized beyond its binary name. + g_set_prgname(APPLICATION_ID); + + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, "flags", + G_APPLICATION_NON_UNIQUE, nullptr)); +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/linux/runner/my_application.h b/apps/mobile/packages/features/client/orders/orders_common/linux/runner/my_application.h new file mode 100644 index 00000000..db16367a --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/linux/runner/my_application.h @@ -0,0 +1,21 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, + my_application, + MY, + APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/.gitignore b/apps/mobile/packages/features/client/orders/orders_common/macos/.gitignore new file mode 100644 index 00000000..746adbb6 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Flutter/Flutter-Debug.xcconfig b/apps/mobile/packages/features/client/orders/orders_common/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 00000000..4b81f9b2 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Flutter/Flutter-Release.xcconfig b/apps/mobile/packages/features/client/orders/orders_common/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 00000000..5caa9d15 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Flutter/GeneratedPluginRegistrant.swift b/apps/mobile/packages/features/client/orders/orders_common/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 00000000..8bd29968 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,18 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + +import firebase_app_check +import firebase_auth +import firebase_core +import shared_preferences_foundation + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FLTFirebaseAppCheckPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAppCheckPlugin")) + FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) + FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) + SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Podfile b/apps/mobile/packages/features/client/orders/orders_common/macos/Podfile new file mode 100644 index 00000000..ff5ddb3b --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Podfile @@ -0,0 +1,42 @@ +platform :osx, '10.15' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcodeproj/project.pbxproj b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 00000000..f4cee16f --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,705 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* orders.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "orders.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* orders.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* orders.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1510; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.orders.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/orders.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/orders"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.orders.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/orders.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/orders"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.orders.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/orders.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/orders"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 00000000..b4e4c542 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcworkspace/contents.xcworkspacedata b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..1d526a16 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/AppDelegate.swift b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/AppDelegate.swift new file mode 100644 index 00000000..b3c17614 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import Cocoa +import FlutterMacOS + +@main +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..a2ec33f1 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 00000000..82b6f9d9 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 00000000..13b35eba Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 00000000..0a3f5fa4 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 00000000..bdb57226 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 00000000..f083318e Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 00000000..326c0e72 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 00000000..2f1632cf Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Base.lproj/MainMenu.xib b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 00000000..80e867a4 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Configs/AppInfo.xcconfig b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 00000000..816c7290 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = orders + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.orders + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2026 com.example. All rights reserved. diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Configs/Debug.xcconfig b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 00000000..36b0fd94 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Configs/Release.xcconfig b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 00000000..dff4f495 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Configs/Warnings.xcconfig b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 00000000..42bcbf47 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/DebugProfile.entitlements b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/DebugProfile.entitlements new file mode 100644 index 00000000..dddb8a30 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Info.plist b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Info.plist new file mode 100644 index 00000000..4789daa6 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/MainFlutterWindow.swift b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 00000000..3cc05eb2 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Release.entitlements b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Release.entitlements new file mode 100644 index 00000000..852fa1a4 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/macos/RunnerTests/RunnerTests.swift b/apps/mobile/packages/features/client/orders/orders_common/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 00000000..61f3bd1f --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Cocoa +import FlutterMacOS +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/pubspec.yaml b/apps/mobile/packages/features/client/orders/orders_common/pubspec.yaml new file mode 100644 index 00000000..1f17a970 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/pubspec.yaml @@ -0,0 +1,38 @@ +name: client_orders_common +description: Orders management feature for the client application. +version: 0.0.1 +publish_to: none +resolution: workspace + +environment: + sdk: '>=3.10.0 <4.0.0' + flutter: ">=3.0.0" + +dependencies: + flutter: + sdk: flutter + flutter_bloc: ^8.1.0 + flutter_modular: ^6.3.0 + equatable: ^2.0.5 + + # Architecture Packages + design_system: + path: ../../../../design_system + core_localization: + path: ../../../../core_localization + krow_domain: ^0.0.1 + krow_data_connect: ^0.0.1 + krow_core: + path: ../../../../core + + firebase_data_connect: any + intl: any + +dev_dependencies: + flutter_test: + sdk: flutter + bloc_test: ^9.1.0 + mocktail: ^1.0.0 + +flutter: + uses-material-design: true diff --git a/apps/mobile/packages/features/client/orders/orders_common/web/favicon.png b/apps/mobile/packages/features/client/orders/orders_common/web/favicon.png new file mode 100644 index 00000000..8aaa46ac Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/web/favicon.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/web/icons/Icon-192.png b/apps/mobile/packages/features/client/orders/orders_common/web/icons/Icon-192.png new file mode 100644 index 00000000..b749bfef Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/web/icons/Icon-192.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/web/icons/Icon-512.png b/apps/mobile/packages/features/client/orders/orders_common/web/icons/Icon-512.png new file mode 100644 index 00000000..88cfd48d Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/web/icons/Icon-512.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/web/icons/Icon-maskable-192.png b/apps/mobile/packages/features/client/orders/orders_common/web/icons/Icon-maskable-192.png new file mode 100644 index 00000000..eb9b4d76 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/web/icons/Icon-maskable-192.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/web/icons/Icon-maskable-512.png b/apps/mobile/packages/features/client/orders/orders_common/web/icons/Icon-maskable-512.png new file mode 100644 index 00000000..d69c5669 Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/web/icons/Icon-maskable-512.png differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/web/index.html b/apps/mobile/packages/features/client/orders/orders_common/web/index.html new file mode 100644 index 00000000..06ee7e4a --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/web/index.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + orders + + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/web/manifest.json b/apps/mobile/packages/features/client/orders/orders_common/web/manifest.json new file mode 100644 index 00000000..4c83e171 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "orders", + "short_name": "orders", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/.gitignore b/apps/mobile/packages/features/client/orders/orders_common/windows/.gitignore new file mode 100644 index 00000000..d492d0d9 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/CMakeLists.txt b/apps/mobile/packages/features/client/orders/orders_common/windows/CMakeLists.txt new file mode 100644 index 00000000..25685493 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/CMakeLists.txt @@ -0,0 +1,108 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(orders LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "orders") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/flutter/CMakeLists.txt b/apps/mobile/packages/features/client/orders/orders_common/windows/flutter/CMakeLists.txt new file mode 100644 index 00000000..903f4899 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/flutter/CMakeLists.txt @@ -0,0 +1,109 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# Set fallback configurations for older versions of the flutter tool. +if (NOT DEFINED FLUTTER_TARGET_PLATFORM) + set(FLUTTER_TARGET_PLATFORM "windows-x64") +endif() + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + ${FLUTTER_TARGET_PLATFORM} $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/flutter/generated_plugin_registrant.cc b/apps/mobile/packages/features/client/orders/orders_common/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 00000000..d141b74f --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,17 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + +#include +#include + +void RegisterPlugins(flutter::PluginRegistry* registry) { + FirebaseAuthPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); + FirebaseCorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/flutter/generated_plugin_registrant.h b/apps/mobile/packages/features/client/orders/orders_common/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 00000000..dc139d85 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/flutter/generated_plugins.cmake b/apps/mobile/packages/features/client/orders/orders_common/windows/flutter/generated_plugins.cmake new file mode 100644 index 00000000..29944d5b --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/flutter/generated_plugins.cmake @@ -0,0 +1,25 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST + firebase_auth + firebase_core +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/runner/CMakeLists.txt b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/CMakeLists.txt new file mode 100644 index 00000000..394917c0 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/runner/Runner.rc b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/Runner.rc new file mode 100644 index 00000000..e5ad78c0 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "orders" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "orders" "\0" + VALUE "LegalCopyright", "Copyright (C) 2026 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "orders.exe" "\0" + VALUE "ProductName", "orders" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/runner/flutter_window.cpp b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/flutter_window.cpp new file mode 100644 index 00000000..955ee303 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/flutter_window.cpp @@ -0,0 +1,71 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/runner/flutter_window.h b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/flutter_window.h new file mode 100644 index 00000000..6da0652f --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/runner/main.cpp b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/main.cpp new file mode 100644 index 00000000..806da7f4 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"orders", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/runner/resource.h b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/resource.h new file mode 100644 index 00000000..66a65d1e --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/runner/resources/app_icon.ico b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/resources/app_icon.ico new file mode 100644 index 00000000..c04e20ca Binary files /dev/null and b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/resources/app_icon.ico differ diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/runner/runner.exe.manifest b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/runner.exe.manifest new file mode 100644 index 00000000..153653e8 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/runner.exe.manifest @@ -0,0 +1,14 @@ + + + + + PerMonitorV2 + + + + + + + + + diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/runner/utils.cpp b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/utils.cpp new file mode 100644 index 00000000..3a0b4651 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + unsigned int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr) + -1; // remove the trailing null character + int input_length = (int)wcslen(utf16_string); + std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/runner/utils.h b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/utils.h new file mode 100644 index 00000000..3879d547 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/runner/win32_window.cpp b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/win32_window.cpp new file mode 100644 index 00000000..60608d0f --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/apps/mobile/packages/features/client/orders/orders_common/windows/runner/win32_window.h b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/win32_window.h new file mode 100644 index 00000000..e901dde6 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/orders_common/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/data/repositories/view_orders_repository_impl.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/data/repositories/view_orders_repository_impl.dart similarity index 70% rename from apps/mobile/packages/features/client/view_orders/lib/src/data/repositories/view_orders_repository_impl.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/src/data/repositories/view_orders_repository_impl.dart index b0f8446b..e0e79a28 100644 --- a/apps/mobile/packages/features/client/view_orders/lib/src/data/repositories/view_orders_repository_impl.dart +++ b/apps/mobile/packages/features/client/orders/view_orders/lib/src/data/repositories/view_orders_repository_impl.dart @@ -1,4 +1,5 @@ import 'package:firebase_data_connect/firebase_data_connect.dart' as fdc; +import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:krow_data_connect/krow_data_connect.dart' as dc; import 'package:krow_domain/krow_domain.dart' as domain; @@ -6,10 +7,8 @@ import '../../domain/repositories/i_view_orders_repository.dart'; /// Implementation of [IViewOrdersRepository] using Data Connect. class ViewOrdersRepositoryImpl implements IViewOrdersRepository { - - ViewOrdersRepositoryImpl({ - required dc.DataConnectService service, - }) : _service = service; + ViewOrdersRepositoryImpl({required dc.DataConnectService service}) + : _service = service; final dc.DataConnectService _service; @override @@ -20,49 +19,68 @@ class ViewOrdersRepositoryImpl implements IViewOrdersRepository { return _service.run(() async { final String businessId = await _service.getBusinessId(); - final fdc.Timestamp startTimestamp = _service.toTimestamp(_startOfDay(start)); + final fdc.Timestamp startTimestamp = _service.toTimestamp( + _startOfDay(start), + ); final fdc.Timestamp endTimestamp = _service.toTimestamp(_endOfDay(end)); - final fdc.QueryResult result = - await _service.connector - .listShiftRolesByBusinessAndDateRange( - businessId: businessId, - start: startTimestamp, - end: endTimestamp, - ) - .execute(); - print( + final fdc.QueryResult< + dc.ListShiftRolesByBusinessAndDateRangeData, + dc.ListShiftRolesByBusinessAndDateRangeVariables + > + result = await _service.connector + .listShiftRolesByBusinessAndDateRange( + businessId: businessId, + start: startTimestamp, + end: endTimestamp, + ) + .execute(); + debugPrint( 'ViewOrders range start=${start.toIso8601String()} end=${end.toIso8601String()} shiftRoles=${result.data.shiftRoles.length}', ); final String businessName = - dc.ClientSessionStore.instance.session?.business?.businessName ?? 'Your Company'; + dc.ClientSessionStore.instance.session?.business?.businessName ?? + 'Your Company'; - return result.data.shiftRoles.map((dc.ListShiftRolesByBusinessAndDateRangeShiftRoles shiftRole) { - final DateTime? shiftDate = shiftRole.shift.date?.toDateTime().toLocal(); - final String dateStr = shiftDate == null ? '' : DateFormat('yyyy-MM-dd').format(shiftDate); + return result.data.shiftRoles.map(( + dc.ListShiftRolesByBusinessAndDateRangeShiftRoles shiftRole, + ) { + final DateTime? shiftDate = shiftRole.shift.date + ?.toDateTime() + .toLocal(); + final String dateStr = shiftDate == null + ? '' + : DateFormat('yyyy-MM-dd').format(shiftDate); final String startTime = _formatTime(shiftRole.startTime); final String endTime = _formatTime(shiftRole.endTime); final int filled = shiftRole.assigned ?? 0; final int workersNeeded = shiftRole.count; final double hours = shiftRole.hours ?? 0; final double totalValue = shiftRole.totalValue ?? 0; - final double hourlyRate = _hourlyRate(shiftRole.totalValue, shiftRole.hours); + final double hourlyRate = _hourlyRate( + shiftRole.totalValue, + shiftRole.hours, + ); // final String status = filled >= workersNeeded ? 'filled' : 'open'; final String status = shiftRole.shift.status?.stringValue ?? 'OPEN'; - print( + debugPrint( 'ViewOrders item: date=$dateStr status=$status shiftId=${shiftRole.shiftId} ' 'roleId=${shiftRole.roleId} start=${shiftRole.startTime?.toJson()} ' 'end=${shiftRole.endTime?.toJson()} hours=$hours totalValue=$totalValue', ); - final String eventName = shiftRole.shift.order.eventName ?? shiftRole.shift.title; + final String eventName = + shiftRole.shift.order.eventName ?? shiftRole.shift.title; return domain.OrderItem( id: _shiftRoleKey(shiftRole.shiftId, shiftRole.roleId), orderId: shiftRole.shift.order.id, - title: '${shiftRole.role.name} - $eventName', + orderType: domain.OrderType.fromString( + shiftRole.shift.order.orderType.stringValue, + ), + title: shiftRole.role.name, + eventName: eventName, clientName: businessName, status: status, date: dateStr, @@ -90,28 +108,35 @@ class ViewOrdersRepositoryImpl implements IViewOrdersRepository { final fdc.Timestamp dayStart = _service.toTimestamp(_startOfDay(day)); final fdc.Timestamp dayEnd = _service.toTimestamp(_endOfDay(day)); - final fdc.QueryResult result = - await _service.connector - .listAcceptedApplicationsByBusinessForDay( - businessId: businessId, - dayStart: dayStart, - dayEnd: dayEnd, - ) - .execute(); + final fdc.QueryResult< + dc.ListAcceptedApplicationsByBusinessForDayData, + dc.ListAcceptedApplicationsByBusinessForDayVariables + > + result = await _service.connector + .listAcceptedApplicationsByBusinessForDay( + businessId: businessId, + dayStart: dayStart, + dayEnd: dayEnd, + ) + .execute(); print( 'ViewOrders day=${day.toIso8601String()} applications=${result.data.applications.length}', ); - final Map>> grouped = >>{}; - for (final dc.ListAcceptedApplicationsByBusinessForDayApplications application + final Map>> grouped = + >>{}; + for (final dc.ListAcceptedApplicationsByBusinessForDayApplications + application in result.data.applications) { print( 'ViewOrders app: shiftId=${application.shiftId} roleId=${application.roleId} ' 'checkIn=${application.checkInTime?.toJson()} checkOut=${application.checkOutTime?.toJson()}', ); - final String key = _shiftRoleKey(application.shiftId, application.roleId); + final String key = _shiftRoleKey( + application.shiftId, + application.roleId, + ); grouped.putIfAbsent(key, () => >[]); grouped[key]!.add({ 'id': application.id, diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/domain/arguments/orders_day_arguments.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/domain/arguments/orders_day_arguments.dart similarity index 100% rename from apps/mobile/packages/features/client/view_orders/lib/src/domain/arguments/orders_day_arguments.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/src/domain/arguments/orders_day_arguments.dart diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/domain/arguments/orders_range_arguments.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/domain/arguments/orders_range_arguments.dart similarity index 100% rename from apps/mobile/packages/features/client/view_orders/lib/src/domain/arguments/orders_range_arguments.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/src/domain/arguments/orders_range_arguments.dart diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/domain/repositories/i_view_orders_repository.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/domain/repositories/i_view_orders_repository.dart similarity index 100% rename from apps/mobile/packages/features/client/view_orders/lib/src/domain/repositories/i_view_orders_repository.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/src/domain/repositories/i_view_orders_repository.dart diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/domain/usecases/get_accepted_applications_for_day_use_case.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/domain/usecases/get_accepted_applications_for_day_use_case.dart similarity index 100% rename from apps/mobile/packages/features/client/view_orders/lib/src/domain/usecases/get_accepted_applications_for_day_use_case.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/src/domain/usecases/get_accepted_applications_for_day_use_case.dart diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/domain/usecases/get_orders_use_case.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/domain/usecases/get_orders_use_case.dart similarity index 100% rename from apps/mobile/packages/features/client/view_orders/lib/src/domain/usecases/get_orders_use_case.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/src/domain/usecases/get_orders_use_case.dart diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/presentation/blocs/view_orders_cubit.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/blocs/view_orders_cubit.dart similarity index 87% rename from apps/mobile/packages/features/client/view_orders/lib/src/presentation/blocs/view_orders_cubit.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/blocs/view_orders_cubit.dart index 81c3ba32..3ea97a5e 100644 --- a/apps/mobile/packages/features/client/view_orders/lib/src/presentation/blocs/view_orders_cubit.dart +++ b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/blocs/view_orders_cubit.dart @@ -85,11 +85,9 @@ class ViewOrdersCubit extends Cubit final DateTime? selectedDate = state.selectedDate; final DateTime updatedSelectedDate = selectedDate != null && - calendarDays.any( - (DateTime day) => _isSameDay(day, selectedDate), - ) - ? selectedDate - : calendarDays.first; + calendarDays.any((DateTime day) => _isSameDay(day, selectedDate)) + ? selectedDate + : calendarDays.first; emit( state.copyWith( weekOffset: newWeekOffset, @@ -173,12 +171,15 @@ class ViewOrdersCubit extends Cubit } final int filled = confirmed.length; - final String status = - filled >= order.workersNeeded ? 'FILLED' : order.status; + final String status = filled >= order.workersNeeded + ? 'FILLED' + : order.status; return OrderItem( id: order.id, orderId: order.orderId, + orderType: order.orderType, title: order.title, + eventName: order.eventName, clientName: order.clientName, status: status, date: order.date, @@ -223,10 +224,9 @@ class ViewOrdersCubit extends Cubit ).format(state.selectedDate!); // Filter by date - final List ordersOnDate = - state.orders - .where((OrderItem s) => s.date == selectedDateStr) - .toList(); + final List ordersOnDate = state.orders + .where((OrderItem s) => s.date == selectedDateStr) + .toList(); // Sort by start time ordersOnDate.sort( @@ -234,38 +234,35 @@ class ViewOrdersCubit extends Cubit ); if (state.filterTab == 'all') { - final List filtered = - ordersOnDate - .where( - (OrderItem s) => - // TODO(orders): move PENDING to its own tab once available. - [ - 'OPEN', - 'FILLED', - 'CONFIRMED', - 'PENDING', - 'ASSIGNED', - ].contains(s.status), - ) - .toList(); + final List filtered = ordersOnDate + .where( + (OrderItem s) => + // TODO(orders): move PENDING to its own tab once available. + [ + 'OPEN', + 'FILLED', + 'CONFIRMED', + 'PENDING', + 'ASSIGNED', + ].contains(s.status), + ) + .toList(); print( 'ViewOrders tab=all statuses=${ordersOnDate.map((OrderItem s) => s.status).toList()} filtered=${filtered.length}', ); return filtered; } else if (state.filterTab == 'active') { - final List filtered = - ordersOnDate - .where((OrderItem s) => s.status == 'IN_PROGRESS') - .toList(); + final List filtered = ordersOnDate + .where((OrderItem s) => s.status == 'IN_PROGRESS') + .toList(); print( 'ViewOrders tab=active statuses=${ordersOnDate.map((OrderItem s) => s.status).toList()} filtered=${filtered.length}', ); return filtered; } else if (state.filterTab == 'completed') { - final List filtered = - ordersOnDate - .where((OrderItem s) => s.status == 'COMPLETED') - .toList(); + final List filtered = ordersOnDate + .where((OrderItem s) => s.status == 'COMPLETED') + .toList(); print( 'ViewOrders tab=completed statuses=${ordersOnDate.map((OrderItem s) => s.status).toList()} filtered=${filtered.length}', ); @@ -321,4 +318,3 @@ class ViewOrdersCubit extends Cubit .length; } } - diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/presentation/blocs/view_orders_state.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/blocs/view_orders_state.dart similarity index 100% rename from apps/mobile/packages/features/client/view_orders/lib/src/presentation/blocs/view_orders_state.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/blocs/view_orders_state.dart diff --git a/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/pages/view_orders_page.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/pages/view_orders_page.dart new file mode 100644 index 00000000..6c0a8923 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/pages/view_orders_page.dart @@ -0,0 +1,126 @@ +import 'package:design_system/design_system.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_modular/flutter_modular.dart'; + +import 'package:core_localization/core_localization.dart'; +import '../blocs/view_orders_cubit.dart'; +import '../blocs/view_orders_state.dart'; +import 'package:krow_domain/krow_domain.dart'; +import '../widgets/view_orders_header.dart'; +import '../widgets/view_orders_empty_state.dart'; +import '../widgets/view_orders_error_state.dart'; +import '../widgets/view_orders_list.dart'; + +/// The main page for viewing client orders. +/// +/// This page follows the KROW Clean Architecture by: +/// - Being a [StatelessWidget]. +/// - Using [ViewOrdersCubit] for state management. +/// - Adhering to the project's Design System. +class ViewOrdersPage extends StatelessWidget { + /// Creates a [ViewOrdersPage]. + const ViewOrdersPage({super.key, this.initialDate}); + + /// The initial date to display orders for. + final DateTime? initialDate; + + @override + Widget build(BuildContext context) { + return BlocProvider.value( + value: Modular.get(), + child: ViewOrdersView(initialDate: initialDate), + ); + } +} + +/// The internal view implementation for [ViewOrdersPage]. +class ViewOrdersView extends StatefulWidget { + /// Creates a [ViewOrdersView]. + const ViewOrdersView({super.key, this.initialDate}); + + /// The initial date to display orders for. + final DateTime? initialDate; + + @override + State createState() => _ViewOrdersViewState(); +} + +class _ViewOrdersViewState extends State { + bool _didInitialJump = false; + ViewOrdersCubit? _cubit; + + @override + void initState() { + super.initState(); + // Force initialization of cubit immediately + _cubit = BlocProvider.of(context, listen: false); + + if (widget.initialDate != null) { + WidgetsBinding.instance.addPostFrameCallback((_) { + if (!mounted) return; + if (_didInitialJump) return; + _didInitialJump = true; + _cubit?.jumpToDate(widget.initialDate!); + }); + } + } + + @override + void didUpdateWidget(ViewOrdersView oldWidget) { + super.didUpdateWidget(oldWidget); + if (widget.initialDate != oldWidget.initialDate && + widget.initialDate != null) { + _cubit?.jumpToDate(widget.initialDate!); + } + } + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listener: (BuildContext context, ViewOrdersState state) { + if (state.status == ViewOrdersStatus.failure && + state.errorMessage != null) { + UiSnackbar.show( + context, + message: translateErrorKey(state.errorMessage!), + type: UiSnackbarType.error, + ); + } + }, + builder: (BuildContext context, ViewOrdersState state) { + final List calendarDays = state.calendarDays; + final List filteredOrders = state.filteredOrders; + + return Scaffold( + body: SafeArea( + child: Column( + children: [ + // Header + Filter + Calendar (Sticky behavior) + ViewOrdersHeader(state: state, calendarDays: calendarDays), + + // Content List + Expanded( + child: state.status == ViewOrdersStatus.failure + ? ViewOrdersErrorState( + errorMessage: state.errorMessage, + selectedDate: state.selectedDate, + onRetry: () => BlocProvider.of( + context, + ).jumpToDate(state.selectedDate ?? DateTime.now()), + ) + : filteredOrders.isEmpty + ? ViewOrdersEmptyState(selectedDate: state.selectedDate) + : ViewOrdersList( + orders: filteredOrders, + filterTab: state.filterTab, + ), + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/presentation/widgets/view_order_card.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/order_edit_sheet.dart similarity index 65% rename from apps/mobile/packages/features/client/view_orders/lib/src/presentation/widgets/view_order_card.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/order_edit_sheet.dart index e010a8be..7e13f228 100644 --- a/apps/mobile/packages/features/client/view_orders/lib/src/presentation/widgets/view_order_card.dart +++ b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/order_edit_sheet.dart @@ -1,691 +1,10 @@ -import 'package:core_localization/core_localization.dart'; import 'package:design_system/design_system.dart'; import 'package:firebase_auth/firebase_auth.dart' as firebase; import 'package:firebase_data_connect/firebase_data_connect.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:intl/intl.dart'; import 'package:krow_data_connect/krow_data_connect.dart' as dc; import 'package:krow_domain/krow_domain.dart'; -import 'package:url_launcher/url_launcher.dart'; - -import '../blocs/view_orders_cubit.dart'; - -/// A rich card displaying details of a client order/shift. -/// -/// This widget complies with the KROW Design System by using -/// tokens from `package:design_system`. -class ViewOrderCard extends StatefulWidget { - /// Creates a [ViewOrderCard] for the given [order]. - const ViewOrderCard({required this.order, super.key}); - - /// The order item to display. - final OrderItem order; - - @override - State createState() => _ViewOrderCardState(); -} - -class _ViewOrderCardState extends State { - bool _expanded = true; - - void _openEditSheet({required OrderItem order}) { - showModalBottomSheet( - context: context, - isScrollControlled: true, - backgroundColor: UiColors.transparent, - builder: (BuildContext context) => _OrderEditSheet( - order: order, - onUpdated: () => this.context.read().updateWeekOffset(0), - ), - ); - } - - /// Returns the semantic color for the given status. - Color _getStatusColor({required String status}) { - switch (status) { - case 'OPEN': - return UiColors.primary; - case 'FILLED': - case 'CONFIRMED': - return UiColors.textSuccess; - case 'IN_PROGRESS': - return UiColors.textWarning; - case 'COMPLETED': - return UiColors.primary; - case 'CANCELED': - return UiColors.destructive; - default: - return UiColors.textSecondary; - } - } - - /// Returns the localized label for the given status. - String _getStatusLabel({required String status}) { - switch (status) { - case 'OPEN': - return t.client_view_orders.card.open; - case 'FILLED': - return t.client_view_orders.card.filled; - case 'CONFIRMED': - return t.client_view_orders.card.confirmed; - case 'IN_PROGRESS': - return t.client_view_orders.card.in_progress; - case 'COMPLETED': - return t.client_view_orders.card.completed; - case 'CANCELED': - return t.client_view_orders.card.cancelled; - default: - return status.toUpperCase(); - } - } - - /// Formats the time string for display. - String _formatTime({required String timeStr}) { - if (timeStr.isEmpty) return ''; - try { - final List parts = timeStr.split(':'); - int hour = int.parse(parts[0]); - final int minute = int.parse(parts[1]); - final String ampm = hour >= 12 ? 'PM' : 'AM'; - hour = hour % 12; - if (hour == 0) hour = 12; - return '$hour:${minute.toString().padLeft(2, '0')} $ampm'; - } catch (_) { - return timeStr; - } - } - - @override - Widget build(BuildContext context) { - final OrderItem order = widget.order; - final Color statusColor = _getStatusColor(status: order.status); - final String statusLabel = _getStatusLabel(status: order.status); - final int coveragePercent = order.workersNeeded > 0 - ? ((order.filled / order.workersNeeded) * 100).round() - : 0; - - final double hours = order.hours; - final double cost = order.totalValue; - - return Container( - decoration: BoxDecoration( - color: UiColors.white, - borderRadius: UiConstants.radiusLg, - border: Border.all(color: UiColors.border), - boxShadow: [ - BoxShadow( - color: UiColors.black.withValues(alpha: 0.04), - blurRadius: 8, - offset: const Offset(0, 2), - ), - ], - ), - child: Column( - children: [ - Padding( - padding: const EdgeInsets.all(UiConstants.space5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Header Row - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Status Badge - Container( - padding: const EdgeInsets.symmetric( - horizontal: 8, - vertical: 2, - ), - decoration: BoxDecoration( - color: statusColor.withValues(alpha: 0.1), - borderRadius: UiConstants.radiusSm, - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - width: 6, - height: 6, - decoration: BoxDecoration( - color: statusColor, - shape: BoxShape.circle, - ), - ), - const SizedBox(width: UiConstants.space1 + 2), - Text( - statusLabel.toUpperCase(), - style: UiTypography.footnote2b.copyWith( - color: statusColor, - letterSpacing: 0.5, - ), - ), - ], - ), - ), - const SizedBox(height: UiConstants.space3), - // Title - Text( - order.title, - style: UiTypography.headline4m.textPrimary, - ), - const SizedBox(height: UiConstants.space1), - // Client & Date - Row( - children: [ - Text( - order.clientName, - style: UiTypography.body3r.textSecondary, - ), - const SizedBox(width: 0), - ], - ), - const SizedBox(height: UiConstants.space2), - // Location (Hub name + Address) - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Padding( - padding: EdgeInsets.only(top: 2), - child: Icon( - UiIcons.mapPin, - size: 14, - color: UiColors.iconSecondary, - ), - ), - const SizedBox(width: UiConstants.space1), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (order.location.isNotEmpty) - Text( - order.location, - style: UiTypography.footnote1b.textPrimary, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - if (order.locationAddress.isNotEmpty) - Text( - order.locationAddress, - style: UiTypography.footnote2r.textSecondary, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ], - ), - ), - ], - ), - ], - ), - ), - const SizedBox(width: UiConstants.space3), - // Actions - Row( - children: [ - _buildHeaderIconButton( - icon: UiIcons.edit, - color: UiColors.primary, - bgColor: UiColors.primary.withValues(alpha: 0.08), - onTap: () => _openEditSheet(order: order), - ), - const SizedBox(width: UiConstants.space2), - if (order.confirmedApps.isNotEmpty) - _buildHeaderIconButton( - icon: _expanded - ? UiIcons.chevronUp - : UiIcons.chevronDown, - color: UiColors.iconSecondary, - bgColor: UiColors.bgSecondary, - onTap: () => - setState(() => _expanded = !_expanded), - ), - ], - ), - ], - ), - - const SizedBox(height: UiConstants.space4), - const Divider(height: 1, color: UiColors.border), - const SizedBox(height: UiConstants.space4), - - // Stats Row - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - _buildStatItem( - icon: UiIcons.dollar, - value: '\$${cost.round()}', - label: t.client_view_orders.card.total, - ), - _buildStatDivider(), - _buildStatItem( - icon: UiIcons.clock, - value: hours.toStringAsFixed(1), - label: t.client_view_orders.card.hrs, - ), - _buildStatDivider(), - _buildStatItem( - icon: UiIcons.users, - value: '${order.workersNeeded}', - label: t.client_create_order.one_time.workers_label, - ), - ], - ), - - const SizedBox(height: UiConstants.space5), - - // Times Section - Row( - children: [ - Expanded( - child: _buildTimeDisplay( - label: t.client_view_orders.card.clock_in, - time: _formatTime(timeStr: order.startTime), - ), - ), - const SizedBox(width: UiConstants.space3), - Expanded( - child: _buildTimeDisplay( - label: t.client_view_orders.card.clock_out, - time: _formatTime(timeStr: order.endTime), - ), - ), - ], - ), - - const SizedBox(height: UiConstants.space4), - - // Coverage Section - if (order.status != 'completed') ...[ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - if (coveragePercent != 100) - const Icon( - UiIcons.error, - size: 16, - color: UiColors.textError, - ), - if (coveragePercent == 100) - const Icon( - UiIcons.checkCircle, - size: 16, - color: UiColors.textSuccess, - ), - const SizedBox(width: UiConstants.space2), - Text( - coveragePercent == 100 - ? t.client_view_orders.card.all_confirmed - : t.client_view_orders.card.workers_needed(count: order.workersNeeded), - style: UiTypography.body2m.textPrimary, - ), - ], - ), - Text( - '$coveragePercent%', - style: UiTypography.body2b.copyWith( - color: UiColors.primary, - ), - ), - ], - ), - const SizedBox(height: UiConstants.space2 + 2), - ClipRRect( - borderRadius: UiConstants.radiusFull, - child: LinearProgressIndicator( - value: coveragePercent / 100, - backgroundColor: UiColors.bgSecondary, - valueColor: const AlwaysStoppedAnimation( - UiColors.primary, - ), - minHeight: 8, - ), - ), - - // Avatar Stack Preview (if not expanded) - if (!_expanded && order.confirmedApps.isNotEmpty) ...[ - const SizedBox(height: UiConstants.space4), - Row( - children: [ - _buildAvatarStack(order.confirmedApps), - if (order.confirmedApps.length > 3) - Padding( - padding: const EdgeInsets.only(left: 12), - child: Text( - t.client_view_orders.card.show_more_workers(count: order.confirmedApps.length - 3), - style: UiTypography.footnote2r.textSecondary, - ), - ), - ], - ), - ], - ], - ], - ), - ), - - // Assigned Workers (Expanded section) - if (_expanded && order.confirmedApps.isNotEmpty) ...[ - Container( - decoration: const BoxDecoration( - color: UiColors.bgSecondary, - border: Border(top: BorderSide(color: UiColors.border)), - borderRadius: BorderRadius.vertical( - bottom: Radius.circular(UiConstants.radiusBase), - ), - ), - padding: const EdgeInsets.all(UiConstants.space5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - t.client_view_orders.card.confirmed_workers_title, - style: UiTypography.footnote2b.textSecondary, - ), - GestureDetector( - onTap: () {}, - child: Text( - t.client_view_orders.card.message_all, - style: UiTypography.footnote2b.copyWith( - color: UiColors.primary, - ), - ), - ), - ], - ), - const SizedBox(height: UiConstants.space4), - ...order.confirmedApps - .take(5) - .map((Map app) => _buildWorkerRow(app)), - if (order.confirmedApps.length > 5) - Padding( - padding: const EdgeInsets.only(top: 8), - child: Center( - child: TextButton( - onPressed: () {}, - child: Text( - t.client_view_orders.card.show_more_workers(count: order.confirmedApps.length - 5), - style: UiTypography.body2m.copyWith( - color: UiColors.primary, - ), - ), - ), - ), - ), - ], - ), - ), - ], - ], - ), - ); - } - - Widget _buildStatDivider() { - return Container(width: 1, height: 24, color: UiColors.border); - } - - Widget _buildTimeDisplay({required String label, required String time}) { - return Container( - padding: const EdgeInsets.all(UiConstants.space3), - decoration: BoxDecoration( - color: UiColors.bgSecondary, - borderRadius: UiConstants.radiusMd, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - label.toUpperCase(), - style: UiTypography.titleUppercase4m.textSecondary, - ), - const SizedBox(height: UiConstants.space1), - Text(time, style: UiTypography.body1b.textPrimary), - ], - ), - ); - } - - /// Builds a stacked avatar UI for a list of applications. - Widget _buildAvatarStack(List> apps) { - const double size = 32.0; - const double overlap = 22.0; - final int count = apps.length > 3 ? 3 : apps.length; - - return SizedBox( - height: size, - width: size + (count - 1) * overlap, - child: Stack( - children: [ - for (int i = 0; i < count; i++) - Positioned( - left: i * overlap, - child: Container( - width: size, - height: size, - decoration: BoxDecoration( - shape: BoxShape.circle, - border: Border.all(color: UiColors.white, width: 2), - color: UiColors.primary.withValues(alpha: 0.1), - ), - child: Center( - child: Text( - (apps[i]['worker_name'] as String)[0], - style: UiTypography.footnote2b.copyWith( - color: UiColors.primary, - ), - ), - ), - ), - ), - ], - ), - ); - } - - /// Builds a detailed row for a worker. - Widget _buildWorkerRow(Map app) { - final String? phone = app['phone'] as String?; - return Container( - margin: const EdgeInsets.only(bottom: UiConstants.space3), - padding: const EdgeInsets.all(UiConstants.space3), - decoration: BoxDecoration( - color: UiColors.white, - borderRadius: UiConstants.radiusMd, - border: Border.all(color: UiColors.border), - ), - child: Row( - children: [ - CircleAvatar( - backgroundColor: UiColors.primary.withValues(alpha: 0.1), - child: Text( - (app['worker_name'] as String)[0], - style: UiTypography.body1b.copyWith(color: UiColors.primary), - ), - ), - const SizedBox(width: UiConstants.space3), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - app['worker_name'] as String, - style: UiTypography.body2m.textPrimary, - ), - const SizedBox(height: UiConstants.space1 / 2), - Row( - children: [ - if ((app['rating'] as num?) != null && - (app['rating'] as num) > 0) ...[ - const Icon( - UiIcons.star, - size: 10, - color: UiColors.accent, - ), - const SizedBox(width: 2), - Text( - (app['rating'] as num).toStringAsFixed(1), - style: UiTypography.footnote2r.textSecondary, - ), - ], - if (app['check_in_time'] != null) ...[ - const SizedBox(width: UiConstants.space2), - Container( - padding: const EdgeInsets.symmetric( - horizontal: 4, - vertical: 1, - ), - decoration: BoxDecoration( - color: UiColors.textSuccess.withValues(alpha: 0.1), - borderRadius: UiConstants.radiusSm, - ), - child: Text( - t.client_view_orders.card.checked_in, - style: UiTypography.titleUppercase4m.copyWith( - color: UiColors.textSuccess, - ), - ), - ), - ] else if ((app['status'] as String?)?.isNotEmpty ?? false) ...[ - const SizedBox(width: UiConstants.space2), - Container( - padding: const EdgeInsets.symmetric( - horizontal: 4, - vertical: 1, - ), - decoration: BoxDecoration( - color: UiColors.bgSecondary, - borderRadius: UiConstants.radiusSm, - ), - child: Text( - (app['status'] as String).toUpperCase(), - style: UiTypography.titleUppercase4m.copyWith( - color: UiColors.textSecondary, - ), - ), - ), - ], - ], - ), - ], - ), - ), - if (phone != null && phone.isNotEmpty) ...[ - _buildActionIconButton( - icon: UiIcons.phone, - onTap: () => _confirmAndCall(phone), - ), - ], - ], - ), - ); - } - - Future _confirmAndCall(String phone) async { - final bool? shouldCall = await showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: Text(t.client_view_orders.card.call_dialog.title), - content: Text(t.client_view_orders.card.call_dialog.message(phone: phone)), - actions: [ - TextButton( - onPressed: () => Navigator.of(context).pop(false), - child: Text(t.common.cancel), - ), - TextButton( - onPressed: () => Navigator.of(context).pop(true), - child: Text(t.client_view_orders.card.call_dialog.title), - ), - ], - ); - }, - ); - - if (shouldCall != true) { - return; - } - - final Uri uri = Uri(scheme: 'tel', path: phone); - await launchUrl(uri); - } - - /// Specialized action button for worker rows. - Widget _buildActionIconButton({ - required IconData icon, - required VoidCallback onTap, - }) { - return GestureDetector( - onTap: onTap, - child: Container( - width: 36, - height: 36, - decoration: BoxDecoration( - color: UiColors.bgSecondary, - borderRadius: BorderRadius.circular(UiConstants.space2), - ), - child: Icon(icon, size: 16, color: UiColors.primary), - ), - ); - } - - /// Builds a small icon button used in row headers. - Widget _buildHeaderIconButton({ - required IconData icon, - required Color color, - required Color bgColor, - required VoidCallback onTap, - }) { - return GestureDetector( - onTap: onTap, - child: Container( - padding: const EdgeInsets.all(10), - decoration: BoxDecoration( - color: bgColor, - borderRadius: UiConstants.radiusSm, - ), - child: Icon(icon, size: 16, color: color), - ), - ); - } - - /// Builds a single stat item (e.g., Cost, Hours, Workers). - Widget _buildStatItem({ - required IconData icon, - required String value, - required String label, - }) { - return Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon(icon, size: 14, color: UiColors.iconSecondary), - const SizedBox(width: 6), - Text(value, style: UiTypography.body1b.textPrimary), - ], - ), - const SizedBox(height: 2), - Text( - label.toUpperCase(), - style: UiTypography.titleUppercase4m.textInactive, - ), - ], - ); - } -} class _RoleOption { const _RoleOption({ @@ -708,20 +27,21 @@ class _ShiftRoleKey { /// A sophisticated bottom sheet for editing an existing order, /// following the Unified Order Flow prototype and matching OneTimeOrderView. -class _OrderEditSheet extends StatefulWidget { - const _OrderEditSheet({ +class OrderEditSheet extends StatefulWidget { + const OrderEditSheet({ required this.order, this.onUpdated, + super.key, }); final OrderItem order; final VoidCallback? onUpdated; @override - State<_OrderEditSheet> createState() => _OrderEditSheetState(); + State createState() => OrderEditSheetState(); } -class _OrderEditSheetState extends State<_OrderEditSheet> { +class OrderEditSheetState extends State { bool _showReview = false; bool _isLoading = false; diff --git a/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_order_card.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_order_card.dart new file mode 100644 index 00000000..0a42dfd9 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_order_card.dart @@ -0,0 +1,735 @@ +import 'package:core_localization/core_localization.dart'; +import 'package:design_system/design_system.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:krow_domain/krow_domain.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../blocs/view_orders_cubit.dart'; + +/// A rich card displaying details of a client order/shift. +/// +/// This widget complies with the KROW Design System by using +/// tokens from `package:design_system`. +import 'order_edit_sheet.dart'; + +class ViewOrderCard extends StatefulWidget { + /// Creates a [ViewOrderCard] for the given [order]. + const ViewOrderCard({required this.order, super.key}); + + /// The order item to display. + final OrderItem order; + + @override + State createState() => _ViewOrderCardState(); +} + +class _ViewOrderCardState extends State { + bool _expanded = true; + + void _openEditSheet({required OrderItem order}) { + showModalBottomSheet( + context: context, + isScrollControlled: true, + backgroundColor: UiColors.transparent, + builder: (BuildContext context) => OrderEditSheet( + order: order, + onUpdated: () => + this.context.read().updateWeekOffset(0), + ), + ); + } + + /// Returns the semantic color for the given status. + Color _getStatusColor({required String status}) { + switch (status) { + case 'OPEN': + return UiColors.primary; + case 'FILLED': + case 'CONFIRMED': + return UiColors.textSuccess; + case 'IN_PROGRESS': + return UiColors.textWarning; + case 'COMPLETED': + return UiColors.primary; + case 'CANCELED': + return UiColors.destructive; + default: + return UiColors.textSecondary; + } + } + + /// Returns the localized label for the given status. + String _getStatusLabel({required String status}) { + switch (status) { + case 'OPEN': + return t.client_view_orders.card.open; + case 'FILLED': + return t.client_view_orders.card.filled; + case 'CONFIRMED': + return t.client_view_orders.card.confirmed; + case 'IN_PROGRESS': + return t.client_view_orders.card.in_progress; + case 'COMPLETED': + return t.client_view_orders.card.completed; + case 'CANCELED': + return t.client_view_orders.card.cancelled; + default: + return status.toUpperCase(); + } + } + + /// Formats the time string for display. + String _formatTime({required String timeStr}) { + if (timeStr.isEmpty) return ''; + try { + final List parts = timeStr.split(':'); + int hour = int.parse(parts[0]); + final int minute = int.parse(parts[1]); + final String ampm = hour >= 12 ? 'PM' : 'AM'; + hour = hour % 12; + if (hour == 0) hour = 12; + return '$hour:${minute.toString().padLeft(2, '0')} $ampm'; + } catch (_) { + return timeStr; + } + } + + String _getOrderTypeLabel(OrderType type) { + switch (type) { + case OrderType.oneTime: + return 'ONE-TIME'; + case OrderType.permanent: + return 'PERMANENT'; + case OrderType.recurring: + return 'RECURRING'; + case OrderType.rapid: + return 'RAPID'; + } + } + + @override + Widget build(BuildContext context) { + final OrderItem order = widget.order; + final Color statusColor = _getStatusColor(status: order.status); + final String statusLabel = _getStatusLabel(status: order.status); + final int coveragePercent = order.workersNeeded > 0 + ? ((order.filled / order.workersNeeded) * 100).round() + : 0; + + final double hours = order.hours; + final double cost = order.totalValue; + + return Container( + decoration: BoxDecoration( + color: UiColors.white, + borderRadius: UiConstants.radiusLg, + border: Border.all(color: UiColors.border), + boxShadow: [ + BoxShadow( + color: UiColors.black.withValues(alpha: 0.04), + blurRadius: 8, + offset: const Offset(0, 2), + ), + ], + ), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(UiConstants.space5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Header Row + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Status and Type Badges + Wrap( + spacing: UiConstants.space2, + children: [ + Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 2, + ), + decoration: BoxDecoration( + color: statusColor.withValues(alpha: 0.1), + borderRadius: UiConstants.radiusSm, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 6, + height: 6, + decoration: BoxDecoration( + color: statusColor, + shape: BoxShape.circle, + ), + ), + const SizedBox( + width: UiConstants.space1 + 2, + ), + Text( + statusLabel.toUpperCase(), + style: UiTypography.footnote2b.copyWith( + color: statusColor, + letterSpacing: 0.5, + ), + ), + ], + ), + ), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 2, + ), + decoration: BoxDecoration( + color: UiColors.bgSecondary, + borderRadius: UiConstants.radiusSm, + ), + child: Text( + _getOrderTypeLabel(order.orderType), + style: UiTypography.footnote2b.textSecondary, + ), + ), + ], + ), + const SizedBox(height: UiConstants.space3), + // Title + Text( + order.title, + style: UiTypography.headline3m.textPrimary, + ), + Row( + spacing: UiConstants.space1, + children: [ + const Icon( + UiIcons.calendarCheck, + size: 14, + color: UiColors.iconSecondary, + ), + Text( + order.eventName, + style: UiTypography.headline5m.textSecondary, + ), + ], + ), + const SizedBox(height: UiConstants.space4), + // Location (Hub name + Address) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Padding( + padding: EdgeInsets.only(top: 2), + child: Icon( + UiIcons.mapPin, + size: 14, + color: UiColors.iconSecondary, + ), + ), + const SizedBox(width: UiConstants.space1), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (order.location.isNotEmpty) + Text( + order.location, + style: + UiTypography.footnote1b.textPrimary, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + if (order.locationAddress.isNotEmpty) + Text( + order.locationAddress, + style: UiTypography + .footnote2r + .textSecondary, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ], + ), + ), + ], + ), + ], + ), + ), + const SizedBox(width: UiConstants.space3), + // Actions + Row( + children: [ + _buildHeaderIconButton( + icon: UiIcons.edit, + color: UiColors.primary, + bgColor: UiColors.primary.withValues(alpha: 0.08), + onTap: () => _openEditSheet(order: order), + ), + const SizedBox(width: UiConstants.space2), + if (order.confirmedApps.isNotEmpty) + _buildHeaderIconButton( + icon: _expanded + ? UiIcons.chevronUp + : UiIcons.chevronDown, + color: UiColors.iconSecondary, + bgColor: UiColors.bgSecondary, + onTap: () => setState(() => _expanded = !_expanded), + ), + ], + ), + ], + ), + + const SizedBox(height: UiConstants.space4), + const Divider(height: 1, color: UiColors.border), + const SizedBox(height: UiConstants.space4), + + // Stats Row + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _buildStatItem( + icon: UiIcons.dollar, + value: '\$${cost.round()}', + label: t.client_view_orders.card.total, + ), + _buildStatDivider(), + _buildStatItem( + icon: UiIcons.clock, + value: hours.toStringAsFixed(1), + label: t.client_view_orders.card.hrs, + ), + _buildStatDivider(), + _buildStatItem( + icon: UiIcons.users, + value: '${order.workersNeeded}', + label: t.client_create_order.one_time.workers_label, + ), + ], + ), + + const SizedBox(height: UiConstants.space5), + + // Times Section + Row( + children: [ + Expanded( + child: _buildTimeDisplay( + label: t.client_view_orders.card.clock_in, + time: _formatTime(timeStr: order.startTime), + ), + ), + const SizedBox(width: UiConstants.space3), + Expanded( + child: _buildTimeDisplay( + label: t.client_view_orders.card.clock_out, + time: _formatTime(timeStr: order.endTime), + ), + ), + ], + ), + + const SizedBox(height: UiConstants.space4), + + // Coverage Section + if (order.status != 'completed') ...[ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + if (coveragePercent != 100) + const Icon( + UiIcons.error, + size: 16, + color: UiColors.textError, + ), + if (coveragePercent == 100) + const Icon( + UiIcons.checkCircle, + size: 16, + color: UiColors.textSuccess, + ), + const SizedBox(width: UiConstants.space2), + Text( + coveragePercent == 100 + ? t.client_view_orders.card.all_confirmed + : t.client_view_orders.card.workers_needed( + count: order.workersNeeded, + ), + style: UiTypography.body2m.textPrimary, + ), + ], + ), + Text( + '$coveragePercent%', + style: UiTypography.body2b.copyWith( + color: UiColors.primary, + ), + ), + ], + ), + const SizedBox(height: UiConstants.space2 + 2), + ClipRRect( + borderRadius: UiConstants.radiusFull, + child: LinearProgressIndicator( + value: coveragePercent / 100, + backgroundColor: UiColors.bgSecondary, + valueColor: const AlwaysStoppedAnimation( + UiColors.primary, + ), + minHeight: 8, + ), + ), + + // Avatar Stack Preview (if not expanded) + if (!_expanded && order.confirmedApps.isNotEmpty) ...[ + const SizedBox(height: UiConstants.space4), + Row( + children: [ + _buildAvatarStack(order.confirmedApps), + if (order.confirmedApps.length > 3) + Padding( + padding: const EdgeInsets.only(left: 12), + child: Text( + t.client_view_orders.card.show_more_workers( + count: order.confirmedApps.length - 3, + ), + style: UiTypography.footnote2r.textSecondary, + ), + ), + ], + ), + ], + ], + ], + ), + ), + + // Assigned Workers (Expanded section) + if (_expanded && order.confirmedApps.isNotEmpty) ...[ + Container( + decoration: const BoxDecoration( + color: UiColors.bgSecondary, + border: Border(top: BorderSide(color: UiColors.border)), + borderRadius: BorderRadius.vertical( + bottom: Radius.circular(UiConstants.radiusBase), + ), + ), + padding: const EdgeInsets.all(UiConstants.space5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + t.client_view_orders.card.confirmed_workers_title, + style: UiTypography.footnote2b.textSecondary, + ), + GestureDetector( + onTap: () {}, + child: Text( + t.client_view_orders.card.message_all, + style: UiTypography.footnote2b.copyWith( + color: UiColors.primary, + ), + ), + ), + ], + ), + const SizedBox(height: UiConstants.space4), + ...order.confirmedApps + .take(5) + .map((Map app) => _buildWorkerRow(app)), + if (order.confirmedApps.length > 5) + Padding( + padding: const EdgeInsets.only(top: 8), + child: Center( + child: TextButton( + onPressed: () {}, + child: Text( + t.client_view_orders.card.show_more_workers( + count: order.confirmedApps.length - 5, + ), + style: UiTypography.body2m.copyWith( + color: UiColors.primary, + ), + ), + ), + ), + ), + ], + ), + ), + ], + ], + ), + ); + } + + Widget _buildStatDivider() { + return Container(width: 1, height: 24, color: UiColors.border); + } + + Widget _buildTimeDisplay({required String label, required String time}) { + return Container( + padding: const EdgeInsets.all(UiConstants.space3), + decoration: BoxDecoration( + color: UiColors.bgSecondary, + borderRadius: UiConstants.radiusMd, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + label.toUpperCase(), + style: UiTypography.titleUppercase4m.textSecondary, + ), + const SizedBox(height: UiConstants.space1), + Text(time, style: UiTypography.body1b.textPrimary), + ], + ), + ); + } + + /// Builds a stacked avatar UI for a list of applications. + Widget _buildAvatarStack(List> apps) { + const double size = 32.0; + const double overlap = 22.0; + final int count = apps.length > 3 ? 3 : apps.length; + + return SizedBox( + height: size, + width: size + (count - 1) * overlap, + child: Stack( + children: [ + for (int i = 0; i < count; i++) + Positioned( + left: i * overlap, + child: Container( + width: size, + height: size, + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all(color: UiColors.white, width: 2), + color: UiColors.primary.withValues(alpha: 0.1), + ), + child: Center( + child: Text( + (apps[i]['worker_name'] as String)[0], + style: UiTypography.footnote2b.copyWith( + color: UiColors.primary, + ), + ), + ), + ), + ), + ], + ), + ); + } + + /// Builds a detailed row for a worker. + Widget _buildWorkerRow(Map app) { + final String? phone = app['phone'] as String?; + return Container( + margin: const EdgeInsets.only(bottom: UiConstants.space3), + padding: const EdgeInsets.all(UiConstants.space3), + decoration: BoxDecoration( + color: UiColors.white, + borderRadius: UiConstants.radiusMd, + border: Border.all(color: UiColors.border), + ), + child: Row( + children: [ + CircleAvatar( + backgroundColor: UiColors.primary.withValues(alpha: 0.1), + child: Text( + (app['worker_name'] as String)[0], + style: UiTypography.body1b.copyWith(color: UiColors.primary), + ), + ), + const SizedBox(width: UiConstants.space3), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + app['worker_name'] as String, + style: UiTypography.body2m.textPrimary, + ), + const SizedBox(height: UiConstants.space1 / 2), + Row( + children: [ + if ((app['rating'] as num?) != null && + (app['rating'] as num) > 0) ...[ + const Icon( + UiIcons.star, + size: 10, + color: UiColors.accent, + ), + const SizedBox(width: 2), + Text( + (app['rating'] as num).toStringAsFixed(1), + style: UiTypography.footnote2r.textSecondary, + ), + ], + if (app['check_in_time'] != null) ...[ + const SizedBox(width: UiConstants.space2), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 4, + vertical: 1, + ), + decoration: BoxDecoration( + color: UiColors.textSuccess.withValues(alpha: 0.1), + borderRadius: UiConstants.radiusSm, + ), + child: Text( + t.client_view_orders.card.checked_in, + style: UiTypography.titleUppercase4m.copyWith( + color: UiColors.textSuccess, + ), + ), + ), + ] else if ((app['status'] as String?)?.isNotEmpty ?? + false) ...[ + const SizedBox(width: UiConstants.space2), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 4, + vertical: 1, + ), + decoration: BoxDecoration( + color: UiColors.bgSecondary, + borderRadius: UiConstants.radiusSm, + ), + child: Text( + (app['status'] as String).toUpperCase(), + style: UiTypography.titleUppercase4m.copyWith( + color: UiColors.textSecondary, + ), + ), + ), + ], + ], + ), + ], + ), + ), + if (phone != null && phone.isNotEmpty) ...[ + _buildActionIconButton( + icon: UiIcons.phone, + onTap: () => _confirmAndCall(phone), + ), + ], + ], + ), + ); + } + + Future _confirmAndCall(String phone) async { + final bool? shouldCall = await showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text(t.client_view_orders.card.call_dialog.title), + content: Text( + t.client_view_orders.card.call_dialog.message(phone: phone), + ), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(false), + child: Text(t.common.cancel), + ), + TextButton( + onPressed: () => Navigator.of(context).pop(true), + child: Text(t.client_view_orders.card.call_dialog.title), + ), + ], + ); + }, + ); + + if (shouldCall != true) { + return; + } + + final Uri uri = Uri(scheme: 'tel', path: phone); + await launchUrl(uri); + } + + /// Specialized action button for worker rows. + Widget _buildActionIconButton({ + required IconData icon, + required VoidCallback onTap, + }) { + return GestureDetector( + onTap: onTap, + child: Container( + width: 36, + height: 36, + decoration: BoxDecoration( + color: UiColors.bgSecondary, + borderRadius: BorderRadius.circular(UiConstants.space2), + ), + child: Icon(icon, size: 16, color: UiColors.primary), + ), + ); + } + + /// Builds a small icon button used in row headers. + Widget _buildHeaderIconButton({ + required IconData icon, + required Color color, + required Color bgColor, + required VoidCallback onTap, + }) { + return GestureDetector( + onTap: onTap, + child: Container( + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + color: bgColor, + borderRadius: UiConstants.radiusSm, + ), + child: Icon(icon, size: 16, color: color), + ), + ); + } + + /// Builds a single stat item (e.g., Cost, Hours, Workers). + Widget _buildStatItem({ + required IconData icon, + required String value, + required String label, + }) { + return Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(icon, size: 14, color: UiColors.iconSecondary), + const SizedBox(width: 6), + Text(value, style: UiTypography.body1b.textPrimary), + ], + ), + const SizedBox(height: 2), + Text( + label.toUpperCase(), + style: UiTypography.titleUppercase4m.textInactive, + ), + ], + ); + } +} diff --git a/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_empty_state.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_empty_state.dart new file mode 100644 index 00000000..24362270 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_empty_state.dart @@ -0,0 +1,54 @@ +import 'package:core_localization/core_localization.dart'; +import 'package:design_system/design_system.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_modular/flutter_modular.dart'; +import 'package:intl/intl.dart'; + +import 'package:krow_core/core.dart'; + +/// A widget that displays an empty state when no orders are found for a specific date. +class ViewOrdersEmptyState extends StatelessWidget { + /// Creates a [ViewOrdersEmptyState]. + const ViewOrdersEmptyState({super.key, required this.selectedDate}); + + /// The currently selected date to display in the empty state message. + final DateTime? selectedDate; + + @override + Widget build(BuildContext context) { + final String dateStr = selectedDate != null + ? _formatDateHeader(selectedDate!) + : 'this date'; + + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon(UiIcons.calendar, size: 48, color: UiColors.iconInactive), + const SizedBox(height: UiConstants.space3), + Text( + t.client_view_orders.no_orders(date: dateStr), + style: UiTypography.body2r.copyWith(color: UiColors.textSecondary), + ), + const SizedBox(height: UiConstants.space4), + UiButton.primary( + text: t.client_view_orders.post_order, + leadingIcon: UiIcons.add, + onPressed: () => Modular.to.toCreateOrder(), + ), + ], + ), + ); + } + + static String _formatDateHeader(DateTime date) { + final DateTime now = DateTime.now(); + final DateTime today = DateTime(now.year, now.month, now.day); + final DateTime tomorrow = today.add(const Duration(days: 1)); + final DateTime checkDate = DateTime(date.year, date.month, date.day); + + if (checkDate == today) return 'Today'; + if (checkDate == tomorrow) return 'Tomorrow'; + return DateFormat('EEE, MMM d').format(date); + } +} diff --git a/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_error_state.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_error_state.dart new file mode 100644 index 00000000..2ff0af22 --- /dev/null +++ b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_error_state.dart @@ -0,0 +1,45 @@ +import 'package:core_localization/core_localization.dart'; +import 'package:design_system/design_system.dart'; +import 'package:flutter/material.dart'; + +/// A widget that displays an error state when orders fail to load. +class ViewOrdersErrorState extends StatelessWidget { + /// Creates a [ViewOrdersErrorState]. + const ViewOrdersErrorState({ + super.key, + required this.errorMessage, + required this.selectedDate, + required this.onRetry, + }); + + /// The error message to display. + final String? errorMessage; + + /// The selected date to retry loading for. + final DateTime? selectedDate; + + /// Callback to trigger a retry. + final VoidCallback onRetry; + + @override + Widget build(BuildContext context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon(UiIcons.error, size: 48, color: UiColors.error), + const SizedBox(height: UiConstants.space4), + Text( + errorMessage != null + ? translateErrorKey(errorMessage!) + : 'An error occurred', + style: UiTypography.body1m.textError, + textAlign: TextAlign.center, + ), + const SizedBox(height: UiConstants.space4), + UiButton.secondary(text: 'Retry', onPressed: onRetry), + ], + ), + ); + } +} diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/presentation/widgets/view_orders_filter_tab.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_filter_tab.dart similarity index 100% rename from apps/mobile/packages/features/client/view_orders/lib/src/presentation/widgets/view_orders_filter_tab.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_filter_tab.dart diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/presentation/widgets/view_orders_header.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_header.dart similarity index 100% rename from apps/mobile/packages/features/client/view_orders/lib/src/presentation/widgets/view_orders_header.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_header.dart diff --git a/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_list.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_list.dart new file mode 100644 index 00000000..a4a5974b --- /dev/null +++ b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_list.dart @@ -0,0 +1,66 @@ +import 'package:design_system/design_system.dart'; +import 'package:flutter/material.dart'; +import 'package:krow_domain/krow_domain.dart'; + +import 'view_order_card.dart'; +import 'view_orders_list_section_header.dart'; +import 'package:core_localization/core_localization.dart'; + +/// A widget that displays the list of filtered orders. +class ViewOrdersList extends StatelessWidget { + /// Creates a [ViewOrdersList]. + const ViewOrdersList({ + super.key, + required this.orders, + required this.filterTab, + }); + + /// The list of orders to display. + final List orders; + + /// The currently selected filter tab to determine the section title and dot color. + final String filterTab; + + @override + Widget build(BuildContext context) { + if (orders.isEmpty) { + return const SizedBox.shrink(); + } + + String sectionTitle = ''; + Color dotColor = UiColors.transparent; + + if (filterTab == 'all') { + sectionTitle = t.client_view_orders.tabs.up_next; + dotColor = UiColors.primary; + } else if (filterTab == 'active') { + sectionTitle = t.client_view_orders.tabs.active; + dotColor = UiColors.textWarning; + } else if (filterTab == 'completed') { + sectionTitle = t.client_view_orders.tabs.completed; + dotColor = UiColors.primary; + } + + return ListView( + padding: const EdgeInsets.fromLTRB( + UiConstants.space5, + UiConstants.space4, + UiConstants.space5, + 100, + ), + children: [ + ViewOrdersListSectionHeader( + title: sectionTitle, + dotColor: dotColor, + count: orders.length, + ), + ...orders.map( + (OrderItem order) => Padding( + padding: const EdgeInsets.only(bottom: UiConstants.space3), + child: ViewOrderCard(order: order), + ), + ), + ], + ); + } +} diff --git a/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_list_section_header.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_list_section_header.dart new file mode 100644 index 00000000..775ee6ba --- /dev/null +++ b/apps/mobile/packages/features/client/orders/view_orders/lib/src/presentation/widgets/view_orders_list_section_header.dart @@ -0,0 +1,54 @@ +import 'package:design_system/design_system.dart'; +import 'package:flutter/material.dart'; + +/// A widget that displays the section header for the orders list. +/// +/// Includes a status indicator dot, the section title, and the count of orders. +class ViewOrdersListSectionHeader extends StatelessWidget { + /// Creates a [ViewOrdersListSectionHeader]. + const ViewOrdersListSectionHeader({ + super.key, + required this.title, + required this.dotColor, + required this.count, + }); + + /// The title of the section (e.g., UP NEXT, ACTIVE, COMPLETED). + final String title; + + /// The color of the status indicator dot. + final Color dotColor; + + /// The number of orders in this section. + final int count; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(bottom: UiConstants.space3), + child: Row( + children: [ + Container( + width: 8, + height: 8, + decoration: BoxDecoration(color: dotColor, shape: BoxShape.circle), + ), + const SizedBox(width: UiConstants.space2), + Text( + title.toUpperCase(), + style: UiTypography.titleUppercase2m.copyWith( + color: UiColors.textPrimary, + ), + ), + const SizedBox(width: UiConstants.space1), + Text( + '($count)', + style: UiTypography.footnote1r.copyWith( + color: UiColors.textSecondary, + ), + ), + ], + ), + ); + } +} diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/view_orders_module.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/src/view_orders_module.dart similarity index 77% rename from apps/mobile/packages/features/client/view_orders/lib/src/view_orders_module.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/src/view_orders_module.dart index b23db650..6ba187d2 100644 --- a/apps/mobile/packages/features/client/view_orders/lib/src/view_orders_module.dart +++ b/apps/mobile/packages/features/client/orders/view_orders/lib/src/view_orders_module.dart @@ -27,7 +27,7 @@ class ViewOrdersModule extends Module { i.add(GetAcceptedApplicationsForDayUseCase.new); // BLoCs - i.add(ViewOrdersCubit.new); + i.addSingleton(ViewOrdersCubit.new); } @override @@ -37,9 +37,11 @@ class ViewOrdersModule extends Module { child: (BuildContext context) { final Object? args = Modular.args.data; DateTime? initialDate; + + // Try parsing from args.data first if (args is DateTime) { initialDate = args; - } else if (args is Map) { + } else if (args is Map && args['initialDate'] != null) { final Object? rawDate = args['initialDate']; if (rawDate is DateTime) { initialDate = rawDate; @@ -47,6 +49,15 @@ class ViewOrdersModule extends Module { initialDate = DateTime.tryParse(rawDate); } } + + // Fallback to query params + if (initialDate == null) { + final String? queryDate = Modular.args.queryParams['initialDate']; + if (queryDate != null && queryDate.isNotEmpty) { + initialDate = DateTime.tryParse(queryDate); + } + } + return ViewOrdersPage(initialDate: initialDate); }, ); diff --git a/apps/mobile/packages/features/client/view_orders/lib/view_orders.dart b/apps/mobile/packages/features/client/orders/view_orders/lib/view_orders.dart similarity index 100% rename from apps/mobile/packages/features/client/view_orders/lib/view_orders.dart rename to apps/mobile/packages/features/client/orders/view_orders/lib/view_orders.dart diff --git a/apps/mobile/packages/features/client/view_orders/pubspec.yaml b/apps/mobile/packages/features/client/orders/view_orders/pubspec.yaml similarity index 79% rename from apps/mobile/packages/features/client/view_orders/pubspec.yaml rename to apps/mobile/packages/features/client/orders/view_orders/pubspec.yaml index 5e0b85d4..0628bce9 100644 --- a/apps/mobile/packages/features/client/view_orders/pubspec.yaml +++ b/apps/mobile/packages/features/client/orders/view_orders/pubspec.yaml @@ -18,15 +18,15 @@ dependencies: # Shared packages design_system: - path: ../../../design_system + path: ../../../../design_system core_localization: - path: ../../../core_localization + path: ../../../../core_localization krow_domain: - path: ../../../domain + path: ../../../../domain krow_core: - path: ../../../core + path: ../../../../core krow_data_connect: - path: ../../../data_connect + path: ../../../../data_connect # UI intl: ^0.20.1 url_launcher: ^6.3.1 diff --git a/apps/mobile/packages/features/client/view_orders/lib/src/presentation/pages/view_orders_page.dart b/apps/mobile/packages/features/client/view_orders/lib/src/presentation/pages/view_orders_page.dart deleted file mode 100644 index d2f972e8..00000000 --- a/apps/mobile/packages/features/client/view_orders/lib/src/presentation/pages/view_orders_page.dart +++ /dev/null @@ -1,255 +0,0 @@ -import 'package:design_system/design_system.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_modular/flutter_modular.dart'; -import 'package:intl/intl.dart'; - -import 'package:core_localization/core_localization.dart'; -import 'package:krow_core/core.dart'; -import '../blocs/view_orders_cubit.dart'; -import '../blocs/view_orders_state.dart'; -import 'package:krow_domain/krow_domain.dart'; -import '../widgets/view_order_card.dart'; -import '../widgets/view_orders_header.dart'; - -/// The main page for viewing client orders. -/// -/// This page follows the KROW Clean Architecture by: -/// - Being a [StatelessWidget]. -/// - Using [ViewOrdersCubit] for state management. -/// - Adhering to the project's Design System. -class ViewOrdersPage extends StatelessWidget { - /// Creates a [ViewOrdersPage]. - const ViewOrdersPage({super.key, this.initialDate}); - - /// The initial date to display orders for. - final DateTime? initialDate; - - @override - Widget build(BuildContext context) { - return BlocProvider( - create: (BuildContext context) => Modular.get(), - child: ViewOrdersView(initialDate: initialDate), - ); - } -} - -/// The internal view implementation for [ViewOrdersPage]. -class ViewOrdersView extends StatefulWidget { - /// Creates a [ViewOrdersView]. - const ViewOrdersView({super.key, this.initialDate}); - - /// The initial date to display orders for. - final DateTime? initialDate; - - @override - State createState() => _ViewOrdersViewState(); -} - -class _ViewOrdersViewState extends State { - bool _didInitialJump = false; - ViewOrdersCubit? _cubit; - - @override - void initState() { - super.initState(); - // Force initialization of cubit immediately - _cubit = BlocProvider.of(context, listen: false); - - if (widget.initialDate != null) { - WidgetsBinding.instance.addPostFrameCallback((_) { - if (!mounted) return; - if (_didInitialJump) return; - _didInitialJump = true; - _cubit?.jumpToDate(widget.initialDate!); - }); - } - } - - @override - Widget build(BuildContext context) { - return BlocConsumer( - listener: (BuildContext context, ViewOrdersState state) { - if (state.status == ViewOrdersStatus.failure && - state.errorMessage != null) { - UiSnackbar.show( - context, - message: translateErrorKey(state.errorMessage!), - type: UiSnackbarType.error, - ); - } - }, - builder: (BuildContext context, ViewOrdersState state) { - final List calendarDays = state.calendarDays; - final List filteredOrders = state.filteredOrders; - - // Header Colors logic from prototype - String sectionTitle = ''; - Color dotColor = UiColors.transparent; - - if (state.filterTab == 'all') { - sectionTitle = t.client_view_orders.tabs.up_next; - dotColor = UiColors.primary; - } else if (state.filterTab == 'active') { - sectionTitle = t.client_view_orders.tabs.active; - dotColor = UiColors.textWarning; - } else if (state.filterTab == 'completed') { - sectionTitle = t.client_view_orders.tabs.completed; - dotColor = - UiColors.primary; // Reverting to primary blue for consistency - } - - return Scaffold( - body: SafeArea( - child: Column( - children: [ - // Header + Filter + Calendar (Sticky behavior) - ViewOrdersHeader( - state: state, - calendarDays: calendarDays, - ), - - // Content List - Expanded( - child: state.status == ViewOrdersStatus.failure - ? _buildErrorState(context: context, state: state) - : filteredOrders.isEmpty - ? _buildEmptyState(context: context, state: state) - : ListView( - padding: const EdgeInsets.fromLTRB( - UiConstants.space5, - UiConstants.space4, - UiConstants.space5, - 100, - ), - children: [ - if (filteredOrders.isNotEmpty) - Padding( - padding: const EdgeInsets.only( - bottom: UiConstants.space3, - ), - child: Row( - children: [ - Container( - width: 8, - height: 8, - decoration: BoxDecoration( - color: dotColor, - shape: BoxShape.circle, - ), - ), - const SizedBox( - width: UiConstants.space2, - ), - Text( - sectionTitle.toUpperCase(), - style: UiTypography.titleUppercase2m - .copyWith( - color: UiColors.textPrimary, - ), - ), - const SizedBox( - width: UiConstants.space1, - ), - Text( - '(${filteredOrders.length})', - style: UiTypography.footnote1r - .copyWith( - color: UiColors.textSecondary, - ), - ), - ], - ), - ), - ...filteredOrders.map( - (OrderItem order) => Padding( - padding: const EdgeInsets.only( - bottom: UiConstants.space3, - ), - child: ViewOrderCard(order: order), - ), - ), - ], - ), - ), - ], - ), - ), - ); - }, - ); - } - - /// Builds the empty state view. - Widget _buildEmptyState({ - required BuildContext context, - required ViewOrdersState state, - }) { - final String dateStr = state.selectedDate != null - ? _formatDateHeader(state.selectedDate!) - : 'this date'; - - return Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon(UiIcons.calendar, size: 48, color: UiColors.iconInactive), - const SizedBox(height: UiConstants.space3), - Text( - t.client_view_orders.no_orders(date: dateStr), - style: UiTypography.body2r.copyWith(color: UiColors.textSecondary), - ), - const SizedBox(height: UiConstants.space4), - UiButton.primary( - text: t.client_view_orders.post_order, - leadingIcon: UiIcons.add, - onPressed: () => Modular.to.toCreateOrder(), - ), - ], - ), - ); - } - - static String _formatDateHeader(DateTime date) { - final DateTime now = DateTime.now(); - final DateTime today = DateTime(now.year, now.month, now.day); - final DateTime tomorrow = today.add(const Duration(days: 1)); - final DateTime checkDate = DateTime(date.year, date.month, date.day); - - if (checkDate == today) return 'Today'; - if (checkDate == tomorrow) return 'Tomorrow'; - return DateFormat('EEE, MMM d').format(date); - } - - Widget _buildErrorState({ - required BuildContext context, - required ViewOrdersState state, - }) { - return Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon( - UiIcons.error, - size: 48, - color: UiColors.error, - ), - const SizedBox(height: UiConstants.space4), - Text( - state.errorMessage != null - ? translateErrorKey(state.errorMessage!) - : 'An error occurred', - style: UiTypography.body1m.textError, - textAlign: TextAlign.center, - ), - const SizedBox(height: UiConstants.space4), - UiButton.secondary( - text: 'Retry', - onPressed: () => BlocProvider.of(context) - .jumpToDate(state.selectedDate ?? DateTime.now()), - ), - ], - ), - ); - } -} diff --git a/apps/mobile/packages/features/staff/home/lib/src/presentation/blocs/home_cubit.dart b/apps/mobile/packages/features/staff/home/lib/src/presentation/blocs/home_cubit.dart index a0e158ee..dec87db2 100644 --- a/apps/mobile/packages/features/staff/home/lib/src/presentation/blocs/home_cubit.dart +++ b/apps/mobile/packages/features/staff/home/lib/src/presentation/blocs/home_cubit.dart @@ -2,6 +2,7 @@ import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:krow_core/core.dart'; import 'package:krow_domain/krow_domain.dart'; +import 'package:krow_data_connect/krow_data_connect.dart'; import 'package:staff_home/src/domain/usecases/get_home_shifts.dart'; import 'package:staff_home/src/domain/repositories/home_repository.dart'; @@ -13,10 +14,19 @@ class HomeCubit extends Cubit with BlocErrorHandler { final GetHomeShifts _getHomeShifts; final HomeRepository _repository; - HomeCubit(HomeRepository repository) - : _getHomeShifts = GetHomeShifts(repository), - _repository = repository, - super(const HomeState.initial()); + /// Use case that checks whether the staff member's personal info is complete. + /// + /// Used to determine whether profile-gated features (such as shift browsing) + /// should be enabled on the home screen. + final GetPersonalInfoCompletionUseCase _getPersonalInfoCompletion; + + HomeCubit({ + required HomeRepository repository, + required GetPersonalInfoCompletionUseCase getPersonalInfoCompletion, + }) : _getHomeShifts = GetHomeShifts(repository), + _repository = repository, + _getPersonalInfoCompletion = getPersonalInfoCompletion, + super(const HomeState.initial()); Future loadShifts() async { if (isClosed) return; @@ -24,29 +34,35 @@ class HomeCubit extends Cubit with BlocErrorHandler { await handleError( emit: emit, action: () async { - final result = await _getHomeShifts.call(); + // Fetch shifts, name, and profile completion status concurrently + final shiftsAndProfile = await Future.wait([ + _getHomeShifts.call(), + _getPersonalInfoCompletion.call(), + ]); + + final homeResult = shiftsAndProfile[0] as HomeShifts; + final isProfileComplete = shiftsAndProfile[1] as bool; final name = await _repository.getStaffName(); + if (isClosed) return; emit( state.copyWith( status: HomeStatus.loaded, - todayShifts: result.today, - tomorrowShifts: result.tomorrow, - recommendedShifts: result.recommended, + todayShifts: homeResult.today, + tomorrowShifts: homeResult.tomorrow, + recommendedShifts: homeResult.recommended, staffName: name, - // Mock profile status for now, ideally fetched from a user repository - isProfileComplete: false, + isProfileComplete: isProfileComplete, ), ); }, onError: (String errorKey) { - if (isClosed) return state; // Avoid state emission if closed, though emit handles it gracefully usually + if (isClosed) return state; return state.copyWith(status: HomeStatus.error, errorMessage: errorKey); }, ); } - void toggleAutoMatch(bool enabled) { emit(state.copyWith(autoMatchEnabled: enabled)); } diff --git a/apps/mobile/packages/features/staff/home/lib/src/presentation/pages/worker_home_page.dart b/apps/mobile/packages/features/staff/home/lib/src/presentation/pages/worker_home_page.dart index 906d45f1..d383c75c 100644 --- a/apps/mobile/packages/features/staff/home/lib/src/presentation/pages/worker_home_page.dart +++ b/apps/mobile/packages/features/staff/home/lib/src/presentation/pages/worker_home_page.dart @@ -63,9 +63,6 @@ class WorkerHomePage extends StatelessWidget { child: Column( children: [ BlocBuilder( - buildWhen: (previous, current) => - previous.isProfileComplete != - current.isProfileComplete, builder: (context, state) { if (state.isProfileComplete) return const SizedBox(); return PlaceholderBanner( diff --git a/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/home_page/pending_payment_card.dart b/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/home_page/pending_payment_card.dart index 4476aecc..77fe1ff1 100644 --- a/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/home_page/pending_payment_card.dart +++ b/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/home_page/pending_payment_card.dart @@ -1,12 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_modular/flutter_modular.dart'; - import 'package:design_system/design_system.dart'; import 'package:core_localization/core_localization.dart'; import 'package:krow_core/core.dart'; - /// Card widget for displaying pending payment information, using design system tokens. class PendingPaymentCard extends StatelessWidget { /// Creates a [PendingPaymentCard]. @@ -21,7 +19,10 @@ class PendingPaymentCard extends StatelessWidget { padding: const EdgeInsets.all(UiConstants.space4), decoration: BoxDecoration( gradient: LinearGradient( - colors: [UiColors.primary.withOpacity(0.08), UiColors.primary.withOpacity(0.04)], + colors: [ + UiColors.primary.withOpacity(0.08), + UiColors.primary.withOpacity(0.04), + ], begin: Alignment.centerLeft, end: Alignment.centerRight, ), @@ -59,7 +60,9 @@ class PendingPaymentCard extends StatelessWidget { ), Text( pendingI18n.subtitle, - style: UiTypography.body3r.copyWith(color: UiColors.mutedForeground), + style: UiTypography.body3r.copyWith( + color: UiColors.mutedForeground, + ), overflow: TextOverflow.ellipsis, ), ], @@ -70,10 +73,7 @@ class PendingPaymentCard extends StatelessWidget { ), Row( children: [ - Text( - '\$285.00', - style: UiTypography.headline4m, - ), + Text('\$285.00', style: UiTypography.headline4m), SizedBox(width: UiConstants.space2), Icon( UiIcons.chevronRight, diff --git a/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/home_page/recommended_shift_card.dart b/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/home_page/recommended_shift_card.dart index e5ead2d2..1dd260f2 100644 --- a/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/home_page/recommended_shift_card.dart +++ b/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/home_page/recommended_shift_card.dart @@ -2,9 +2,8 @@ import 'package:core_localization/core_localization.dart'; import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter_modular/flutter_modular.dart'; -import 'package:krow_domain/krow_domain.dart'; - import 'package:krow_core/core.dart'; +import 'package:krow_domain/krow_domain.dart'; class RecommendedShiftCard extends StatelessWidget { final Shift shift; @@ -17,7 +16,7 @@ class RecommendedShiftCard extends StatelessWidget { return GestureDetector( onTap: () { - Modular.to.pushShiftDetails(shift); + Modular.to.toShiftDetails(shift); }, child: Container( width: 300, @@ -43,7 +42,9 @@ class RecommendedShiftCard extends StatelessWidget { children: [ Text( recI18n.act_now, - style: UiTypography.body3m.copyWith(color: UiColors.textError), + style: UiTypography.body3m.copyWith( + color: UiColors.textError, + ), ), const SizedBox(width: UiConstants.space2), Container( @@ -71,7 +72,9 @@ class RecommendedShiftCard extends StatelessWidget { height: UiConstants.space10, decoration: BoxDecoration( color: UiColors.tagInProgress, - borderRadius: BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), ), child: const Icon( UiIcons.calendar, @@ -128,10 +131,7 @@ class RecommendedShiftCard extends StatelessWidget { color: UiColors.mutedForeground, ), const SizedBox(width: UiConstants.space1), - Text( - recI18n.today, - style: UiTypography.body3r.textSecondary, - ), + Text(recI18n.today, style: UiTypography.body3r.textSecondary), const SizedBox(width: UiConstants.space3), const Icon( UiIcons.clock, diff --git a/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/shift_card.dart b/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/shift_card.dart index f35d97ae..f851225c 100644 --- a/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/shift_card.dart +++ b/apps/mobile/packages/features/staff/home/lib/src/presentation/widgets/shift_card.dart @@ -60,7 +60,8 @@ class _ShiftCardState extends State { final date = DateTime.parse(dateStr); final diff = DateTime.now().difference(date); if (diff.inHours < 1) return t.staff_shifts.card.just_now; - if (diff.inHours < 24) return t.staff_shifts.details.pending_time(time: '${diff.inHours}h'); + if (diff.inHours < 24) + return t.staff_shifts.details.pending_time(time: '${diff.inHours}h'); return t.staff_shifts.details.pending_time(time: '${diff.inDays}d'); } catch (e) { return ''; @@ -75,7 +76,7 @@ class _ShiftCardState extends State { ? null : () { setState(() => isExpanded = !isExpanded); - Modular.to.pushShiftDetails(widget.shift); + Modular.to.toShiftDetails(widget.shift); }, child: Container( margin: const EdgeInsets.only(bottom: UiConstants.space3), @@ -97,17 +98,15 @@ class _ShiftCardState extends State { ), child: widget.shift.logoUrl != null ? ClipRRect( - borderRadius: - BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), child: Image.network( widget.shift.logoUrl!, fit: BoxFit.contain, ), ) - : Icon( - UiIcons.building, - color: UiColors.mutedForeground, - ), + : Icon(UiIcons.building, color: UiColors.mutedForeground), ), const SizedBox(width: UiConstants.space3), Expanded( @@ -129,10 +128,7 @@ class _ShiftCardState extends State { text: '\$${widget.shift.hourlyRate}', style: UiTypography.body1b.textPrimary, children: [ - TextSpan( - text: '/h', - style: UiTypography.body3r, - ), + TextSpan(text: '/h', style: UiTypography.body3r), ], ), ), @@ -186,13 +182,16 @@ class _ShiftCardState extends State { height: UiConstants.space14, decoration: BoxDecoration( color: UiColors.white, - borderRadius: BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), border: Border.all(color: UiColors.border), ), child: widget.shift.logoUrl != null ? ClipRRect( - borderRadius: - BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), child: Image.network( widget.shift.logoUrl!, fit: BoxFit.contain, @@ -251,10 +250,7 @@ class _ShiftCardState extends State { text: '\$${widget.shift.hourlyRate}', style: UiTypography.headline3m.textPrimary, children: [ - TextSpan( - text: '/h', - style: UiTypography.body1r, - ), + TextSpan(text: '/h', style: UiTypography.body1r), ], ), ), @@ -336,8 +332,9 @@ class _ShiftCardState extends State { foregroundColor: UiColors.white, elevation: 0, shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), ), ), child: Text(t.staff_shifts.card.accept_shift), @@ -355,8 +352,9 @@ class _ShiftCardState extends State { color: UiColors.destructive.withValues(alpha: 0.3), ), shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), ), ), child: Text(t.staff_shifts.card.decline_shift), diff --git a/apps/mobile/packages/features/staff/home/lib/src/staff_home_module.dart b/apps/mobile/packages/features/staff/home/lib/src/staff_home_module.dart index 80710549..5add2498 100644 --- a/apps/mobile/packages/features/staff/home/lib/src/staff_home_module.dart +++ b/apps/mobile/packages/features/staff/home/lib/src/staff_home_module.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_modular/flutter_modular.dart'; import 'package:krow_core/core.dart'; +import 'package:krow_data_connect/krow_data_connect.dart'; import 'package:staff_home/src/data/repositories/home_repository_impl.dart'; import 'package:staff_home/src/domain/repositories/home_repository.dart'; import 'package:staff_home/src/presentation/blocs/home_cubit.dart'; @@ -14,11 +15,28 @@ import 'package:staff_home/src/presentation/pages/worker_home_page.dart'; class StaffHomeModule extends Module { @override void binds(Injector i) { - // Repository + // Repository - provides home data (shifts, staff name) i.addLazySingleton(() => HomeRepositoryImpl()); + // StaffConnectorRepository for profile completion queries + i.addLazySingleton( + () => StaffConnectorRepositoryImpl(), + ); + + // Use case for checking personal info profile completion + i.addLazySingleton( + () => GetPersonalInfoCompletionUseCase( + repository: i.get(), + ), + ); + // Presentation layer - Cubit - i.addSingleton(HomeCubit.new); + i.addSingleton( + () => HomeCubit( + repository: i.get(), + getPersonalInfoCompletion: i.get(), + ), + ); } @override diff --git a/apps/mobile/packages/features/staff/profile_sections/onboarding/emergency_contact/lib/src/presentation/pages/emergency_contact_screen.dart b/apps/mobile/packages/features/staff/profile_sections/onboarding/emergency_contact/lib/src/presentation/pages/emergency_contact_screen.dart index c8aab7be..7a00374c 100644 --- a/apps/mobile/packages/features/staff/profile_sections/onboarding/emergency_contact/lib/src/presentation/pages/emergency_contact_screen.dart +++ b/apps/mobile/packages/features/staff/profile_sections/onboarding/emergency_contact/lib/src/presentation/pages/emergency_contact_screen.dart @@ -39,7 +39,6 @@ class EmergencyContactScreen extends StatelessWidget { body: BlocProvider( create: (context) => Modular.get(), child: BlocConsumer( - listener: (context, state) { if (state.status == EmergencyContactStatus.failure) { UiSnackbar.show( @@ -66,12 +65,12 @@ class EmergencyContactScreen extends StatelessWidget { const EmergencyContactInfoBanner(), const SizedBox(height: UiConstants.space6), ...state.contacts.asMap().entries.map( - (entry) => EmergencyContactFormItem( - index: entry.key, - contact: entry.value, - totalContacts: state.contacts.length, - ), - ), + (entry) => EmergencyContactFormItem( + index: entry.key, + contact: entry.value, + totalContacts: state.contacts.length, + ), + ), const EmergencyContactAddButton(), const SizedBox(height: UiConstants.space16), ], diff --git a/apps/mobile/packages/features/staff/profile_sections/onboarding/emergency_contact/lib/src/presentation/widgets/emergency_contact_save_button.dart b/apps/mobile/packages/features/staff/profile_sections/onboarding/emergency_contact/lib/src/presentation/widgets/emergency_contact_save_button.dart index c332ac74..2097d866 100644 --- a/apps/mobile/packages/features/staff/profile_sections/onboarding/emergency_contact/lib/src/presentation/widgets/emergency_contact_save_button.dart +++ b/apps/mobile/packages/features/staff/profile_sections/onboarding/emergency_contact/lib/src/presentation/widgets/emergency_contact_save_button.dart @@ -2,13 +2,17 @@ import 'package:core_localization/core_localization.dart'; import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_modular/flutter_modular.dart'; +import 'package:krow_core/core.dart'; import '../blocs/emergency_contact_bloc.dart'; class EmergencyContactSaveButton extends StatelessWidget { const EmergencyContactSaveButton({super.key}); void _onSave(BuildContext context) { - context.read().add(EmergencyContactsSaved()); + BlocProvider.of( + context, + ).add(EmergencyContactsSaved()); } @override @@ -19,10 +23,13 @@ class EmergencyContactSaveButton extends StatelessWidget { if (state.status == EmergencyContactStatus.saved) { UiSnackbar.show( context, - message: t.staff.profile.menu_items.emergency_contact_page.save_success, + message: + t.staff.profile.menu_items.emergency_contact_page.save_success, type: UiSnackbarType.success, margin: const EdgeInsets.only(bottom: 150, left: 16, right: 16), ); + + Modular.to.toProfile(); } }, builder: (context, state) { @@ -36,8 +43,9 @@ class EmergencyContactSaveButton extends StatelessWidget { child: SafeArea( child: UiButton.primary( fullWidth: true, - onPressed: - state.isValid && !isLoading ? () => _onSave(context) : null, + onPressed: state.isValid && !isLoading + ? () => _onSave(context) + : null, child: isLoading ? const SizedBox( height: 20.0, @@ -49,7 +57,14 @@ class EmergencyContactSaveButton extends StatelessWidget { ), ), ) - : Text(t.staff.profile.menu_items.emergency_contact_page.save_continue), + : Text( + t + .staff + .profile + .menu_items + .emergency_contact_page + .save_continue, + ), ), ), ); diff --git a/apps/mobile/packages/features/staff/profile_sections/onboarding/experience/lib/src/presentation/pages/experience_page.dart b/apps/mobile/packages/features/staff/profile_sections/onboarding/experience/lib/src/presentation/pages/experience_page.dart index d7a77c28..7b42e3d0 100644 --- a/apps/mobile/packages/features/staff/profile_sections/onboarding/experience/lib/src/presentation/pages/experience_page.dart +++ b/apps/mobile/packages/features/staff/profile_sections/onboarding/experience/lib/src/presentation/pages/experience_page.dart @@ -3,6 +3,7 @@ import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_modular/flutter_modular.dart'; +import 'package:krow_core/core.dart'; import 'package:krow_domain/krow_domain.dart'; import '../blocs/experience_bloc.dart'; @@ -13,34 +14,57 @@ class ExperiencePage extends StatelessWidget { String _getIndustryLabel(dynamic node, Industry industry) { switch (industry) { - case Industry.hospitality: return node.hospitality; - case Industry.foodService: return node.food_service; - case Industry.warehouse: return node.warehouse; - case Industry.events: return node.events; - case Industry.retail: return node.retail; - case Industry.healthcare: return node.healthcare; - case Industry.other: return node.other; + case Industry.hospitality: + return node.hospitality; + case Industry.foodService: + return node.food_service; + case Industry.warehouse: + return node.warehouse; + case Industry.events: + return node.events; + case Industry.retail: + return node.retail; + case Industry.healthcare: + return node.healthcare; + case Industry.other: + return node.other; } } String _getSkillLabel(dynamic node, ExperienceSkill skill) { switch (skill) { - case ExperienceSkill.foodService: return node.food_service; - case ExperienceSkill.bartending: return node.bartending; - case ExperienceSkill.eventSetup: return node.event_setup; - case ExperienceSkill.hospitality: return node.hospitality; - case ExperienceSkill.warehouse: return node.warehouse; - case ExperienceSkill.customerService: return node.customer_service; - case ExperienceSkill.cleaning: return node.cleaning; - case ExperienceSkill.security: return node.security; - case ExperienceSkill.retail: return node.retail; - case ExperienceSkill.driving: return node.driving; - case ExperienceSkill.cooking: return node.cooking; - case ExperienceSkill.cashier: return node.cashier; - case ExperienceSkill.server: return node.server; - case ExperienceSkill.barista: return node.barista; - case ExperienceSkill.hostHostess: return node.host_hostess; - case ExperienceSkill.busser: return node.busser; + case ExperienceSkill.foodService: + return node.food_service; + case ExperienceSkill.bartending: + return node.bartending; + case ExperienceSkill.eventSetup: + return node.event_setup; + case ExperienceSkill.hospitality: + return node.hospitality; + case ExperienceSkill.warehouse: + return node.warehouse; + case ExperienceSkill.customerService: + return node.customer_service; + case ExperienceSkill.cleaning: + return node.cleaning; + case ExperienceSkill.security: + return node.security; + case ExperienceSkill.retail: + return node.retail; + case ExperienceSkill.driving: + return node.driving; + case ExperienceSkill.cooking: + return node.cooking; + case ExperienceSkill.cashier: + return node.cashier; + case ExperienceSkill.server: + return node.server; + case ExperienceSkill.barista: + return node.barista; + case ExperienceSkill.hostHostess: + return node.host_hostess; + case ExperienceSkill.busser: + return node.busser; } } @@ -51,39 +75,38 @@ class ExperiencePage extends StatelessWidget { return Scaffold( appBar: UiAppBar( title: i18n.title, - onLeadingPressed: () => Modular.to.pop(), + onLeadingPressed: () => Modular.to.toProfile(), ), body: BlocProvider( create: (context) => Modular.get(), child: BlocConsumer( listener: (context, state) { - if (state.status == ExperienceStatus.success) { - UiSnackbar.show( - context, - message: 'Experience saved successfully', - type: UiSnackbarType.success, - margin: const EdgeInsets.only( - bottom: 120, - left: UiConstants.space4, - right: UiConstants.space4, - ), - ); - Modular.to.pop(); - } else if (state.status == ExperienceStatus.failure) { - UiSnackbar.show( - context, - message: state.errorMessage != null - ? translateErrorKey(state.errorMessage!) - : 'An error occurred', - type: UiSnackbarType.error, - margin: const EdgeInsets.only( - bottom: 120, - left: UiConstants.space4, - right: UiConstants.space4, - ), - ); - } - }, + if (state.status == ExperienceStatus.success) { + UiSnackbar.show( + context, + message: 'Experience saved successfully', + type: UiSnackbarType.success, + margin: const EdgeInsets.only( + bottom: 120, + left: UiConstants.space4, + right: UiConstants.space4, + ), + ); + } else if (state.status == ExperienceStatus.failure) { + UiSnackbar.show( + context, + message: state.errorMessage != null + ? translateErrorKey(state.errorMessage!) + : 'An error occurred', + type: UiSnackbarType.error, + margin: const EdgeInsets.only( + bottom: 120, + left: UiConstants.space4, + right: UiConstants.space4, + ), + ); + } + }, builder: (context, state) { return Column( children: [ @@ -106,15 +129,15 @@ class ExperiencePage extends StatelessWidget { .map( (i) => UiChip( label: _getIndustryLabel(i18n.industries, i), - isSelected: - state.selectedIndustries.contains(i), - onTap: () => - BlocProvider.of(context) - .add(ExperienceIndustryToggled(i)), - variant: - state.selectedIndustries.contains(i) - ? UiChipVariant.primary - : UiChipVariant.secondary, + isSelected: state.selectedIndustries.contains( + i, + ), + onTap: () => BlocProvider.of( + context, + ).add(ExperienceIndustryToggled(i)), + variant: state.selectedIndustries.contains(i) + ? UiChipVariant.primary + : UiChipVariant.secondary, ), ) .toList(), @@ -133,15 +156,16 @@ class ExperiencePage extends StatelessWidget { .map( (s) => UiChip( label: _getSkillLabel(i18n.skills, s), - isSelected: - state.selectedSkills.contains(s.value), - onTap: () => - BlocProvider.of(context) - .add(ExperienceSkillToggled(s.value)), + isSelected: state.selectedSkills.contains( + s.value, + ), + onTap: () => BlocProvider.of( + context, + ).add(ExperienceSkillToggled(s.value)), variant: state.selectedSkills.contains(s.value) - ? UiChipVariant.primary - : UiChipVariant.secondary, + ? UiChipVariant.primary + : UiChipVariant.secondary, ), ) .toList(), @@ -177,10 +201,7 @@ class ExperiencePage extends StatelessWidget { spacing: UiConstants.space2, runSpacing: UiConstants.space2, children: customSkills.map((skill) { - return UiChip( - label: skill, - variant: UiChipVariant.accent, - ); + return UiChip(label: skill, variant: UiChipVariant.accent); }).toList(), ), ], @@ -202,8 +223,9 @@ class ExperiencePage extends StatelessWidget { child: UiButton.primary( onPressed: state.status == ExperienceStatus.loading ? null - : () => BlocProvider.of(context) - .add(ExperienceSubmitted()), + : () => BlocProvider.of( + context, + ).add(ExperienceSubmitted()), fullWidth: true, text: state.status == ExperienceStatus.loading ? null diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/blocs/shifts/shifts_bloc.dart b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/blocs/shifts/shifts_bloc.dart index 2b42b3de..2d2a9f8c 100644 --- a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/blocs/shifts/shifts_bloc.dart +++ b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/blocs/shifts/shifts_bloc.dart @@ -32,7 +32,7 @@ class ShiftsBloc extends Bloc required this.getCancelledShifts, required this.getHistoryShifts, required this.getProfileCompletion, - }) : super(ShiftsInitial()) { + }) : super(const ShiftsState()) { on(_onLoadShifts); on(_onLoadHistoryShifts); on(_onLoadAvailableShifts); @@ -46,8 +46,8 @@ class ShiftsBloc extends Bloc LoadShiftsEvent event, Emitter emit, ) async { - if (state is! ShiftsLoaded) { - emit(ShiftsLoading()); + if (state.status != ShiftsStatus.loaded) { + emit(state.copyWith(status: ShiftsStatus.loading)); } await handleError( @@ -58,22 +58,26 @@ class ShiftsBloc extends Bloc GetMyShiftsArguments(start: days.first, end: days.last), ); - emit(ShiftsLoaded( - myShifts: myShiftsResult, - pendingShifts: const [], - cancelledShifts: const [], - availableShifts: const [], - historyShifts: const [], - availableLoading: false, - availableLoaded: false, - historyLoading: false, - historyLoaded: false, - myShiftsLoaded: true, - searchQuery: '', - jobType: 'all', - )); + emit( + state.copyWith( + status: ShiftsStatus.loaded, + myShifts: myShiftsResult, + pendingShifts: const [], + cancelledShifts: const [], + availableShifts: const [], + historyShifts: const [], + availableLoading: false, + availableLoaded: false, + historyLoading: false, + historyLoaded: false, + myShiftsLoaded: true, + searchQuery: '', + jobType: 'all', + ), + ); }, - onError: (String errorKey) => ShiftsError(errorKey), + onError: (String errorKey) => + state.copyWith(status: ShiftsStatus.error, errorMessage: errorKey), ); } @@ -81,27 +85,29 @@ class ShiftsBloc extends Bloc LoadHistoryShiftsEvent event, Emitter emit, ) async { - final currentState = state; - if (currentState is! ShiftsLoaded) return; - if (currentState.historyLoading || currentState.historyLoaded) return; + if (state.status != ShiftsStatus.loaded) return; + if (state.historyLoading || state.historyLoaded) return; - emit(currentState.copyWith(historyLoading: true)); + emit(state.copyWith(historyLoading: true)); await handleError( emit: emit.call, action: () async { final historyResult = await getHistoryShifts(); - emit(currentState.copyWith( - myShiftsLoaded: true, - historyShifts: historyResult, - historyLoading: false, - historyLoaded: true, - )); + emit( + state.copyWith( + myShiftsLoaded: true, + historyShifts: historyResult, + historyLoading: false, + historyLoaded: true, + ), + ); }, onError: (String errorKey) { - if (state is ShiftsLoaded) { - return (state as ShiftsLoaded).copyWith(historyLoading: false); - } - return ShiftsError(errorKey); + return state.copyWith( + historyLoading: false, + status: ShiftsStatus.error, + errorMessage: errorKey, + ); }, ); } @@ -110,33 +116,32 @@ class ShiftsBloc extends Bloc LoadAvailableShiftsEvent event, Emitter emit, ) async { - final currentState = state; - if (currentState is! ShiftsLoaded) return; - if (!event.force && - (currentState.availableLoading || currentState.availableLoaded)) { + if (state.status != ShiftsStatus.loaded) return; + if (!event.force && (state.availableLoading || state.availableLoaded)) { return; } - emit(currentState.copyWith( - availableLoading: true, - availableLoaded: false, - )); + emit(state.copyWith(availableLoading: true, availableLoaded: false)); await handleError( emit: emit.call, action: () async { - final availableResult = - await getAvailableShifts(const GetAvailableShiftsArguments()); - emit(currentState.copyWith( - availableShifts: _filterPastShifts(availableResult), - availableLoading: false, - availableLoaded: true, - )); + final availableResult = await getAvailableShifts( + const GetAvailableShiftsArguments(), + ); + emit( + state.copyWith( + availableShifts: _filterPastShifts(availableResult), + availableLoading: false, + availableLoaded: true, + ), + ); }, onError: (String errorKey) { - if (state is ShiftsLoaded) { - return (state as ShiftsLoaded).copyWith(availableLoading: false); - } - return ShiftsError(errorKey); + return state.copyWith( + availableLoading: false, + status: ShiftsStatus.error, + errorMessage: errorKey, + ); }, ); } @@ -145,62 +150,51 @@ class ShiftsBloc extends Bloc LoadFindFirstEvent event, Emitter emit, ) async { - if (state is! ShiftsLoaded) { - emit(const ShiftsLoaded( - myShifts: [], - pendingShifts: [], - cancelledShifts: [], - availableShifts: [], - historyShifts: [], - availableLoading: false, - availableLoaded: false, - historyLoading: false, - historyLoaded: false, - myShiftsLoaded: false, - searchQuery: '', - jobType: 'all', - )); + if (state.status != ShiftsStatus.loaded) { + emit( + state.copyWith( + status: ShiftsStatus.loading, + myShifts: const [], + pendingShifts: const [], + cancelledShifts: const [], + availableShifts: const [], + historyShifts: const [], + availableLoading: false, + availableLoaded: false, + historyLoading: false, + historyLoaded: false, + myShiftsLoaded: false, + searchQuery: '', + jobType: 'all', + ), + ); } - final currentState = state is ShiftsLoaded ? state as ShiftsLoaded : null; - if (currentState != null && currentState.availableLoaded) return; + if (state.availableLoaded) return; - if (currentState != null) { - emit(currentState.copyWith(availableLoading: true)); - } + emit(state.copyWith(availableLoading: true)); await handleError( emit: emit.call, action: () async { - final availableResult = - await getAvailableShifts(const GetAvailableShiftsArguments()); - final loadedState = state is ShiftsLoaded - ? state as ShiftsLoaded - : const ShiftsLoaded( - myShifts: [], - pendingShifts: [], - cancelledShifts: [], - availableShifts: [], - historyShifts: [], - availableLoading: true, - availableLoaded: false, - historyLoading: false, - historyLoaded: false, - myShiftsLoaded: false, - searchQuery: '', - jobType: 'all', - ); - emit(loadedState.copyWith( - availableShifts: _filterPastShifts(availableResult), - availableLoading: false, - availableLoaded: true, - )); + final availableResult = await getAvailableShifts( + const GetAvailableShiftsArguments(), + ); + emit( + state.copyWith( + status: ShiftsStatus.loaded, + availableShifts: _filterPastShifts(availableResult), + availableLoading: false, + availableLoaded: true, + ), + ); }, onError: (String errorKey) { - if (state is ShiftsLoaded) { - return (state as ShiftsLoaded).copyWith(availableLoading: false); - } - return ShiftsError(errorKey); + return state.copyWith( + availableLoading: false, + status: ShiftsStatus.error, + errorMessage: errorKey, + ); }, ); } @@ -216,31 +210,16 @@ class ShiftsBloc extends Bloc GetMyShiftsArguments(start: event.start, end: event.end), ); - if (state is ShiftsLoaded) { - final currentState = state as ShiftsLoaded; - emit(currentState.copyWith( + emit( + state.copyWith( + status: ShiftsStatus.loaded, myShifts: myShiftsResult, myShiftsLoaded: true, - )); - return; - } - - emit(ShiftsLoaded( - myShifts: myShiftsResult, - pendingShifts: const [], - cancelledShifts: const [], - availableShifts: const [], - historyShifts: const [], - availableLoading: false, - availableLoaded: false, - historyLoading: false, - historyLoaded: false, - myShiftsLoaded: true, - searchQuery: '', - jobType: 'all', - )); + ), + ); }, - onError: (String errorKey) => ShiftsError(errorKey), + onError: (String errorKey) => + state.copyWith(status: ShiftsStatus.error, errorMessage: errorKey), ); } @@ -248,9 +227,8 @@ class ShiftsBloc extends Bloc FilterAvailableShiftsEvent event, Emitter emit, ) async { - final currentState = state; - if (currentState is ShiftsLoaded) { - if (!currentState.availableLoaded && !currentState.availableLoading) { + if (state.status == ShiftsStatus.loaded) { + if (!state.availableLoaded && !state.availableLoading) { add(LoadAvailableShiftsEvent()); return; } @@ -258,21 +236,26 @@ class ShiftsBloc extends Bloc await handleError( emit: emit.call, action: () async { - final result = await getAvailableShifts(GetAvailableShiftsArguments( - query: event.query ?? currentState.searchQuery, - type: event.jobType ?? currentState.jobType, - )); + final result = await getAvailableShifts( + GetAvailableShiftsArguments( + query: event.query ?? state.searchQuery, + type: event.jobType ?? state.jobType, + ), + ); - emit(currentState.copyWith( - availableShifts: _filterPastShifts(result), - searchQuery: event.query ?? currentState.searchQuery, - jobType: event.jobType ?? currentState.jobType, - )); + emit( + state.copyWith( + availableShifts: _filterPastShifts(result), + searchQuery: event.query ?? state.searchQuery, + jobType: event.jobType ?? state.jobType, + ), + ); }, onError: (String errorKey) { - // Stay on current state for filtering errors, maybe show a snackbar? - // For now just logging is enough via handleError mixin. - return currentState; + return state.copyWith( + status: ShiftsStatus.error, + errorMessage: errorKey, + ); }, ); } @@ -282,17 +265,14 @@ class ShiftsBloc extends Bloc CheckProfileCompletionEvent event, Emitter emit, ) async { - final currentState = state; - if (currentState is! ShiftsLoaded) return; - await handleError( emit: emit.call, action: () async { final bool isComplete = await getProfileCompletion(); - emit(currentState.copyWith(profileComplete: isComplete)); + emit(state.copyWith(profileComplete: isComplete)); }, onError: (String errorKey) { - return currentState.copyWith(profileComplete: false); + return state.copyWith(profileComplete: false); }, ); } diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/blocs/shifts/shifts_state.dart b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/blocs/shifts/shifts_state.dart index 48e2eefe..f9e108d5 100644 --- a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/blocs/shifts/shifts_state.dart +++ b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/blocs/shifts/shifts_state.dart @@ -1,18 +1,9 @@ part of 'shifts_bloc.dart'; -@immutable -sealed class ShiftsState extends Equatable { - const ShiftsState(); - - @override - List get props => []; -} +enum ShiftsStatus { initial, loading, loaded, error } -class ShiftsInitial extends ShiftsState {} - -class ShiftsLoading extends ShiftsState {} - -class ShiftsLoaded extends ShiftsState { +class ShiftsState extends Equatable { + final ShiftsStatus status; final List myShifts; final List pendingShifts; final List cancelledShifts; @@ -26,24 +17,28 @@ class ShiftsLoaded extends ShiftsState { final String searchQuery; final String jobType; final bool? profileComplete; + final String? errorMessage; - const ShiftsLoaded({ - required this.myShifts, - required this.pendingShifts, - required this.cancelledShifts, - required this.availableShifts, - required this.historyShifts, - required this.availableLoading, - required this.availableLoaded, - required this.historyLoading, - required this.historyLoaded, - required this.myShiftsLoaded, - required this.searchQuery, - required this.jobType, + const ShiftsState({ + this.status = ShiftsStatus.initial, + this.myShifts = const [], + this.pendingShifts = const [], + this.cancelledShifts = const [], + this.availableShifts = const [], + this.historyShifts = const [], + this.availableLoading = false, + this.availableLoaded = false, + this.historyLoading = false, + this.historyLoaded = false, + this.myShiftsLoaded = false, + this.searchQuery = '', + this.jobType = 'all', this.profileComplete, + this.errorMessage, }); - ShiftsLoaded copyWith({ + ShiftsState copyWith({ + ShiftsStatus? status, List? myShifts, List? pendingShifts, List? cancelledShifts, @@ -57,8 +52,10 @@ class ShiftsLoaded extends ShiftsState { String? searchQuery, String? jobType, bool? profileComplete, + String? errorMessage, }) { - return ShiftsLoaded( + return ShiftsState( + status: status ?? this.status, myShifts: myShifts ?? this.myShifts, pendingShifts: pendingShifts ?? this.pendingShifts, cancelledShifts: cancelledShifts ?? this.cancelledShifts, @@ -72,32 +69,26 @@ class ShiftsLoaded extends ShiftsState { searchQuery: searchQuery ?? this.searchQuery, jobType: jobType ?? this.jobType, profileComplete: profileComplete ?? this.profileComplete, + errorMessage: errorMessage ?? this.errorMessage, ); } @override - List get props => [ - myShifts, - pendingShifts, - cancelledShifts, - availableShifts, - historyShifts, - availableLoading, - availableLoaded, - historyLoading, - historyLoaded, - myShiftsLoaded, - searchQuery, - jobType, - profileComplete ?? '', - ]; -} - -class ShiftsError extends ShiftsState { - final String message; - - const ShiftsError(this.message); - - @override - List get props => [message]; + List get props => [ + status, + myShifts, + pendingShifts, + cancelledShifts, + availableShifts, + historyShifts, + availableLoading, + availableLoaded, + historyLoading, + historyLoaded, + myShiftsLoaded, + searchQuery, + jobType, + profileComplete, + errorMessage, + ]; } diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/pages/shift_details_page.dart b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/pages/shift_details_page.dart index b2a17a60..c5fc15d3 100644 --- a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/pages/shift_details_page.dart +++ b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/pages/shift_details_page.dart @@ -16,6 +16,7 @@ import '../widgets/shift_details/shift_description_section.dart'; import '../widgets/shift_details/shift_details_bottom_bar.dart'; import '../widgets/shift_details/shift_details_header.dart'; import '../widgets/shift_details/shift_location_section.dart'; +import '../widgets/shift_details/shift_schedule_summary_section.dart'; import '../widgets/shift_details/shift_stats_row.dart'; class ShiftDetailsPage extends StatefulWidget { @@ -95,7 +96,7 @@ class _ShiftDetailsPageState extends State { ); Modular.to.toShifts( selectedDate: state.shiftDate, - initialTab: 'find', + initialTab: 'myshifts', refreshAvailable: true, ); } else if (state is ShiftDetailsError) { @@ -116,8 +117,7 @@ class _ShiftDetailsPageState extends State { ); } - final Shift displayShift = - state is ShiftDetailsLoaded ? state.shift : widget.shift; + final Shift displayShift = widget.shift; final i18n = Translations.of(context).staff_shifts.shift_details; final duration = _calculateDuration(displayShift); @@ -149,6 +149,7 @@ class _ShiftDetailsPageState extends State { const Divider(height: 1, thickness: 0.5), ShiftDateTimeSection( date: displayShift.date, + endDate: displayShift.endDate, startTime: displayShift.startTime, endTime: displayShift.endTime, shiftDateLabel: i18n.shift_date, @@ -156,6 +157,8 @@ class _ShiftDetailsPageState extends State { clockOutLabel: i18n.end_time, ), const Divider(height: 1, thickness: 0.5), + ShiftScheduleSummarySection(shift: displayShift), + const Divider(height: 1, thickness: 0.5), if (displayShift.breakInfo != null && displayShift.breakInfo!.duration != BreakDuration.none) ...[ diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/pages/shifts_page.dart b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/pages/shifts_page.dart index ceda2b68..b515c21f 100644 --- a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/pages/shifts_page.dart +++ b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/pages/shifts_page.dart @@ -5,12 +5,13 @@ import 'package:design_system/design_system.dart'; import 'package:core_localization/core_localization.dart'; import 'package:krow_domain/krow_domain.dart'; import '../blocs/shifts/shifts_bloc.dart'; +import '../utils/shift_tab_type.dart'; import '../widgets/tabs/my_shifts_tab.dart'; import '../widgets/tabs/find_shifts_tab.dart'; import '../widgets/tabs/history_shifts_tab.dart'; class ShiftsPage extends StatefulWidget { - final String? initialTab; + final ShiftTabType? initialTab; final DateTime? selectedDate; final bool refreshAvailable; const ShiftsPage({ @@ -25,7 +26,7 @@ class ShiftsPage extends StatefulWidget { } class _ShiftsPageState extends State { - late String _activeTab; + late ShiftTabType _activeTab; DateTime? _selectedDate; bool _prioritizeFind = false; bool _refreshAvailable = false; @@ -35,9 +36,9 @@ class _ShiftsPageState extends State { @override void initState() { super.initState(); - _activeTab = widget.initialTab ?? 'myshifts'; + _activeTab = widget.initialTab ?? ShiftTabType.find; _selectedDate = widget.selectedDate; - _prioritizeFind = widget.initialTab == 'find'; + _prioritizeFind = _activeTab == ShiftTabType.find; _refreshAvailable = widget.refreshAvailable; _pendingAvailableRefresh = widget.refreshAvailable; if (_prioritizeFind) { @@ -45,16 +46,15 @@ class _ShiftsPageState extends State { } else { _bloc.add(LoadShiftsEvent()); } - if (_activeTab == 'history') { + if (_activeTab == ShiftTabType.history) { _bloc.add(LoadHistoryShiftsEvent()); } - if (_activeTab == 'find') { + if (_activeTab == ShiftTabType.find) { if (!_prioritizeFind) { - _bloc.add( - LoadAvailableShiftsEvent(force: _refreshAvailable), - ); + _bloc.add(LoadAvailableShiftsEvent(force: _refreshAvailable)); } } + // Check profile completion _bloc.add(const CheckProfileCompletionEvent()); } @@ -65,7 +65,7 @@ class _ShiftsPageState extends State { if (widget.initialTab != null && widget.initialTab != _activeTab) { setState(() { _activeTab = widget.initialTab!; - _prioritizeFind = widget.initialTab == 'find'; + _prioritizeFind = _activeTab == ShiftTabType.find; }); } if (widget.selectedDate != null && widget.selectedDate != _selectedDate) { @@ -86,57 +86,37 @@ class _ShiftsPageState extends State { value: _bloc, child: BlocConsumer( listener: (context, state) { - if (state is ShiftsError) { + if (state.status == ShiftsStatus.error && + state.errorMessage != null) { UiSnackbar.show( context, - message: translateErrorKey(state.message), + message: translateErrorKey(state.errorMessage!), type: UiSnackbarType.error, ); } }, builder: (context, state) { - if (_pendingAvailableRefresh && state is ShiftsLoaded) { + if (_pendingAvailableRefresh && state.status == ShiftsStatus.loaded) { _pendingAvailableRefresh = false; _bloc.add(const LoadAvailableShiftsEvent(force: true)); } - final bool baseLoaded = state is ShiftsLoaded; - final List myShifts = (state is ShiftsLoaded) - ? state.myShifts - : []; - final List availableJobs = (state is ShiftsLoaded) - ? state.availableShifts - : []; - final bool availableLoading = (state is ShiftsLoaded) - ? state.availableLoading - : false; - final bool availableLoaded = (state is ShiftsLoaded) - ? state.availableLoaded - : false; - final List pendingAssignments = (state is ShiftsLoaded) - ? state.pendingShifts - : []; - final List cancelledShifts = (state is ShiftsLoaded) - ? state.cancelledShifts - : []; - final List historyShifts = (state is ShiftsLoaded) - ? state.historyShifts - : []; - final bool historyLoading = (state is ShiftsLoaded) - ? state.historyLoading - : false; - final bool historyLoaded = (state is ShiftsLoaded) - ? state.historyLoaded - : false; - final bool myShiftsLoaded = (state is ShiftsLoaded) - ? state.myShiftsLoaded - : false; + final bool baseLoaded = state.status == ShiftsStatus.loaded; + final List myShifts = state.myShifts; + final List availableJobs = state.availableShifts; + final bool availableLoading = state.availableLoading; + final bool availableLoaded = state.availableLoaded; + final List pendingAssignments = state.pendingShifts; + final List cancelledShifts = state.cancelledShifts; + final List historyShifts = state.historyShifts; + final bool historyLoading = state.historyLoading; + final bool historyLoaded = state.historyLoaded; + final bool myShiftsLoaded = state.myShiftsLoaded; final bool blockTabsForFind = _prioritizeFind && !availableLoaded; // Note: "filteredJobs" logic moved to FindShiftsTab // Note: Calendar logic moved to MyShiftsTab return Scaffold( - backgroundColor: UiColors.background, body: Column( children: [ // Header (Blue) @@ -160,44 +140,47 @@ class _ShiftsPageState extends State { // Tabs Row( children: [ - if (state is ShiftsLoaded && state.profileComplete != false) + if (state.profileComplete != false) Expanded( child: _buildTab( - "myshifts", + ShiftTabType.myShifts, t.staff_shifts.tabs.my_shifts, UiIcons.calendar, myShifts.length, showCount: myShiftsLoaded, - enabled: !blockTabsForFind && (state.profileComplete ?? false), + enabled: + !blockTabsForFind && + (state.profileComplete ?? false), ), ) else const SizedBox.shrink(), - if (state is ShiftsLoaded && state.profileComplete != false) + if (state.profileComplete != false) const SizedBox(width: UiConstants.space2) else const SizedBox.shrink(), _buildTab( - "find", + ShiftTabType.find, t.staff_shifts.tabs.find_work, UiIcons.search, availableJobs.length, showCount: availableLoaded, enabled: baseLoaded, ), - if (state is ShiftsLoaded && state.profileComplete != false) + if (state.profileComplete != false) const SizedBox(width: UiConstants.space2) else const SizedBox.shrink(), - if (state is ShiftsLoaded && state.profileComplete != false) + if (state.profileComplete != false) Expanded( child: _buildTab( - "history", + ShiftTabType.history, t.staff_shifts.tabs.history, UiIcons.clock, historyShifts.length, showCount: historyLoaded, - enabled: !blockTabsForFind && + enabled: + !blockTabsForFind && baseLoaded && (state.profileComplete ?? false), ), @@ -212,9 +195,9 @@ class _ShiftsPageState extends State { // Body Content Expanded( - child: state is ShiftsLoading + child: state.status == ShiftsStatus.loading ? const Center(child: CircularProgressIndicator()) - : state is ShiftsError + : state.status == ShiftsStatus.error ? Center( child: Padding( padding: const EdgeInsets.all(UiConstants.space5), @@ -222,7 +205,7 @@ class _ShiftsPageState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - translateErrorKey(state.message), + translateErrorKey(state.errorMessage ?? ''), style: UiTypography.body2r.textSecondary, textAlign: TextAlign.center, ), @@ -258,47 +241,45 @@ class _ShiftsPageState extends State { bool historyLoading, ) { switch (_activeTab) { - case 'myshifts': + case ShiftTabType.myShifts: return MyShiftsTab( myShifts: myShifts, pendingAssignments: pendingAssignments, cancelledShifts: cancelledShifts, initialDate: _selectedDate, ); - case 'find': + case ShiftTabType.find: if (availableLoading) { return const Center(child: CircularProgressIndicator()); } return FindShiftsTab(availableJobs: availableJobs); - case 'history': + case ShiftTabType.history: if (historyLoading) { return const Center(child: CircularProgressIndicator()); } return HistoryShiftsTab(historyShifts: historyShifts); - default: - return const SizedBox.shrink(); } } Widget _buildTab( - String id, + ShiftTabType type, String label, IconData icon, int count, { bool showCount = true, bool enabled = true, }) { - final isActive = _activeTab == id; + final isActive = _activeTab == type; return Expanded( child: GestureDetector( onTap: !enabled ? null : () { - setState(() => _activeTab = id); - if (id == 'history') { + setState(() => _activeTab = type); + if (type == ShiftTabType.history) { _bloc.add(LoadHistoryShiftsEvent()); } - if (id == 'find') { + if (type == ShiftTabType.find) { _bloc.add(LoadAvailableShiftsEvent()); } }, diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/utils/shift_tab_type.dart b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/utils/shift_tab_type.dart new file mode 100644 index 00000000..16576408 --- /dev/null +++ b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/utils/shift_tab_type.dart @@ -0,0 +1,30 @@ +enum ShiftTabType { + myShifts, + find, + history; + + static ShiftTabType fromString(String? value) { + if (value == null) return ShiftTabType.find; + switch (value.toLowerCase()) { + case 'myshifts': + return ShiftTabType.myShifts; + case 'find': + return ShiftTabType.find; + case 'history': + return ShiftTabType.history; + default: + return ShiftTabType.find; + } + } + + String get id { + switch (this) { + case ShiftTabType.myShifts: + return 'myshifts'; + case ShiftTabType.find: + return 'find'; + case ShiftTabType.history: + return 'history'; + } + } +} diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/my_shift_card.dart b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/my_shift_card.dart index 03f20b49..10f68a6f 100644 --- a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/my_shift_card.dart +++ b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/my_shift_card.dart @@ -27,7 +27,6 @@ class MyShiftCard extends StatefulWidget { } class _MyShiftCardState extends State { - String _formatTime(String time) { if (time.isEmpty) return ''; try { @@ -77,22 +76,23 @@ class _MyShiftCardState extends State { String _getShiftType() { // Handling potential localization key availability try { - final String orderType = (widget.shift.orderType ?? '').toUpperCase(); - if (orderType == 'PERMANENT') { - return t.staff_shifts.filter.long_term; - } - if (orderType == 'RECURRING') { - return t.staff_shifts.filter.multi_day; - } - if (widget.shift.durationDays != null && widget.shift.durationDays! > 30) { - return t.staff_shifts.filter.long_term; - } - if (widget.shift.durationDays != null && widget.shift.durationDays! > 1) { - return t.staff_shifts.filter.multi_day; - } - return t.staff_shifts.filter.one_day; + final String orderType = (widget.shift.orderType ?? '').toUpperCase(); + if (orderType == 'PERMANENT') { + return t.staff_shifts.filter.long_term; + } + if (orderType == 'RECURRING') { + return t.staff_shifts.filter.multi_day; + } + if (widget.shift.durationDays != null && + widget.shift.durationDays! > 30) { + return t.staff_shifts.filter.long_term; + } + if (widget.shift.durationDays != null && widget.shift.durationDays! > 1) { + return t.staff_shifts.filter.multi_day; + } + return t.staff_shifts.filter.one_day; } catch (_) { - return "One Day"; + return "One Day"; } } @@ -110,34 +110,34 @@ class _MyShiftCardState extends State { // Fallback localization if keys missing try { - if (status == 'confirmed') { - statusText = t.staff_shifts.status.confirmed; - statusColor = UiColors.textLink; - statusBg = UiColors.primary; - } else if (status == 'checked_in') { - statusText = 'Checked in'; - statusColor = UiColors.textSuccess; - statusBg = UiColors.iconSuccess; - } else if (status == 'pending' || status == 'open') { - statusText = t.staff_shifts.status.act_now; - statusColor = UiColors.destructive; - statusBg = UiColors.destructive; - } else if (status == 'swap') { - statusText = t.staff_shifts.status.swap_requested; - statusColor = UiColors.textWarning; - statusBg = UiColors.textWarning; - statusIcon = UiIcons.swap; - } else if (status == 'completed') { - statusText = t.staff_shifts.status.completed; - statusColor = UiColors.textSuccess; - statusBg = UiColors.iconSuccess; - } else if (status == 'no_show') { - statusText = t.staff_shifts.status.no_show; - statusColor = UiColors.destructive; - statusBg = UiColors.destructive; - } + if (status == 'confirmed') { + statusText = t.staff_shifts.status.confirmed; + statusColor = UiColors.textLink; + statusBg = UiColors.primary; + } else if (status == 'checked_in') { + statusText = 'Checked in'; + statusColor = UiColors.textSuccess; + statusBg = UiColors.iconSuccess; + } else if (status == 'pending' || status == 'open') { + statusText = t.staff_shifts.status.act_now; + statusColor = UiColors.destructive; + statusBg = UiColors.destructive; + } else if (status == 'swap') { + statusText = t.staff_shifts.status.swap_requested; + statusColor = UiColors.textWarning; + statusBg = UiColors.textWarning; + statusIcon = UiIcons.swap; + } else if (status == 'completed') { + statusText = t.staff_shifts.status.completed; + statusColor = UiColors.textSuccess; + statusBg = UiColors.iconSuccess; + } else if (status == 'no_show') { + statusText = t.staff_shifts.status.no_show; + statusColor = UiColors.destructive; + statusBg = UiColors.destructive; + } } catch (_) { - statusText = status?.toUpperCase() ?? ""; + statusText = status?.toUpperCase() ?? ""; } final schedules = widget.shift.schedules ?? []; @@ -145,8 +145,9 @@ class _MyShiftCardState extends State { final List visibleSchedules = schedules.length <= 5 ? schedules : schedules.take(3).toList(); - final int remainingSchedules = - schedules.length <= 5 ? 0 : schedules.length - 3; + final int remainingSchedules = schedules.length <= 5 + ? 0 + : schedules.length - 3; final String scheduleRange = hasSchedules ? () { final first = schedules.first.date; @@ -160,10 +161,7 @@ class _MyShiftCardState extends State { return GestureDetector( onTap: () { - Modular.to.pushNamed( - StaffPaths.shiftDetails(widget.shift.id), - arguments: widget.shift, - ); + Modular.to.toShiftDetails(widget.shift); }, child: Container( margin: const EdgeInsets.only(bottom: UiConstants.space3), @@ -171,28 +169,26 @@ class _MyShiftCardState extends State { color: UiColors.white, borderRadius: UiConstants.radiusLg, border: Border.all(color: UiColors.border), - boxShadow: [ - BoxShadow( - color: UiColors.black.withValues(alpha: 0.05), - blurRadius: 2, - offset: const Offset(0, 1), - ), - ], ), child: Padding( padding: const EdgeInsets.all(UiConstants.space4), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Status Badge - if (statusText.isNotEmpty) - Padding( - padding: const EdgeInsets.only(bottom: UiConstants.space2), - child: Row( - children: [ + // Badge row: shows the status label and the shift-type chip. + // The type chip (One Day / Multi-Day / Long Term) is always + // rendered when orderType is present — even for "open" find-shifts + // cards that may have no meaningful status text. + Padding( + padding: const EdgeInsets.only(bottom: UiConstants.space2), + child: Row( + children: [ + if (statusText.isNotEmpty) ...[ if (statusIcon != null) Padding( - padding: const EdgeInsets.only(right: UiConstants.space2), + padding: const EdgeInsets.only( + right: UiConstants.space2, + ), child: Icon( statusIcon, size: UiConstants.iconXs, @@ -203,7 +199,9 @@ class _MyShiftCardState extends State { Container( width: 8, height: 8, - margin: const EdgeInsets.only(right: UiConstants.space2), + margin: const EdgeInsets.only( + right: UiConstants.space2, + ), decoration: BoxDecoration( color: statusBg, shape: BoxShape.circle, @@ -216,30 +214,31 @@ class _MyShiftCardState extends State { letterSpacing: 0.5, ), ), - // Shift Type Badge (Order type) - if ((widget.shift.orderType ?? '').isNotEmpty) ...[ - const SizedBox(width: UiConstants.space2), - Container( - padding: const EdgeInsets.symmetric( - horizontal: UiConstants.space2, - vertical: 2, - ), - decoration: BoxDecoration( - color: UiColors.background, - borderRadius: UiConstants.radiusSm, - border: Border.all(color: UiColors.border), - ), - child: Text( - _getShiftType(), - style: UiTypography.footnote2m.copyWith( - color: UiColors.textSecondary, - ), - ), - ), - ], + const SizedBox(width: UiConstants.space2), ], - ), + // Type badge — driven by RECURRING / PERMANENT / one-day + // order data and always visible so users can filter + // Find Shifts cards at a glance. + Container( + padding: const EdgeInsets.symmetric( + horizontal: UiConstants.space2, + vertical: 2, + ), + decoration: BoxDecoration( + color: UiColors.background, + borderRadius: UiConstants.radiusSm, + border: Border.all(color: UiColors.border), + ), + child: Text( + _getShiftType(), + style: UiTypography.footnote2m.copyWith( + color: UiColors.textSecondary, + ), + ), + ), + ], ), + ), Row( crossAxisAlignment: CrossAxisAlignment.start, @@ -257,14 +256,18 @@ class _MyShiftCardState extends State { begin: Alignment.topLeft, end: Alignment.bottomRight, ), - borderRadius: BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), border: Border.all( color: UiColors.primary.withValues(alpha: 0.09), ), ), child: widget.shift.logoUrl != null ? ClipRRect( - borderRadius: BorderRadius.circular(UiConstants.radiusBase), + borderRadius: BorderRadius.circular( + UiConstants.radiusBase, + ), child: Image.network( widget.shift.logoUrl!, fit: BoxFit.contain, @@ -290,8 +293,7 @@ class _MyShiftCardState extends State { children: [ Expanded( child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( widget.shift.title, @@ -330,29 +332,31 @@ class _MyShiftCardState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( + crossAxisAlignment: CrossAxisAlignment.center, children: [ const Icon( UiIcons.clock, size: UiConstants.iconXs, - color: UiColors.primary, + color: UiColors.iconSecondary, ), const SizedBox(width: UiConstants.space1), Text( - '${schedules.length} schedules', - style: UiTypography.footnote2m.copyWith( - color: UiColors.primary, - ), + scheduleRange, + style: + UiTypography.footnote2r.textSecondary, ), ], ), - const SizedBox(height: UiConstants.space1), - Padding( - padding: const EdgeInsets.only(bottom: 2), - child: Text( - scheduleRange, - style: UiTypography.footnote2r.copyWith(color: UiColors.primary), - ), + + const SizedBox(height: UiConstants.space2), + + Text( + '${schedules.length} schedules', + style: UiTypography.footnote2m.copyWith( + color: UiColors.primary, + ), ), + const SizedBox(height: UiConstants.space1), ...visibleSchedules.map( (schedule) => Padding( padding: const EdgeInsets.only(bottom: 2), @@ -368,7 +372,9 @@ class _MyShiftCardState extends State { Text( '+$remainingSchedules more schedules', style: UiTypography.footnote2r.copyWith( - color: UiColors.primary.withOpacity(0.7), + color: UiColors.primary.withValues( + alpha: 0.7, + ), ), ), ], @@ -410,10 +416,11 @@ class _MyShiftCardState extends State { Text( '... +${widget.shift.durationDays! - 1} more days', style: UiTypography.footnote2r.copyWith( - color: - UiColors.primary.withOpacity(0.7), + color: UiColors.primary.withValues( + alpha: 0.7, + ), ), - ) + ), ], ), ] else ...[ diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/shift_details/shift_date_time_section.dart b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/shift_details/shift_date_time_section.dart index 47eded2f..76dec5f5 100644 --- a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/shift_details/shift_date_time_section.dart +++ b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/shift_details/shift_date_time_section.dart @@ -6,19 +6,22 @@ import 'package:intl/intl.dart'; class ShiftDateTimeSection extends StatelessWidget { /// The ISO string of the date. final String date; - + + /// The end date string (ISO). + final String? endDate; + /// The start time string (HH:mm). final String startTime; - + /// The end time string (HH:mm). final String endTime; - + /// Localization string for shift date. final String shiftDateLabel; - + /// Localization string for clock in time. final String clockInLabel; - + /// Localization string for clock out time. final String clockOutLabel; @@ -26,6 +29,7 @@ class ShiftDateTimeSection extends StatelessWidget { const ShiftDateTimeSection({ super.key, required this.date, + required this.endDate, required this.startTime, required this.endTime, required this.shiftDateLabel, @@ -63,41 +67,63 @@ class ShiftDateTimeSection extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - shiftDateLabel, - style: UiTypography.titleUppercase4b.textSecondary, - ), - const SizedBox(height: UiConstants.space2), - Row( + Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Icon( - UiIcons.calendar, - size: 20, - color: UiColors.primary, - ), - const SizedBox(width: UiConstants.space2), Text( - _formatDate(date), - style: UiTypography.headline5m.textPrimary, + shiftDateLabel, + style: UiTypography.titleUppercase4b.textSecondary, + ), + const SizedBox(height: UiConstants.space2), + Row( + children: [ + const Icon( + UiIcons.calendar, + size: 20, + color: UiColors.primary, + ), + const SizedBox(width: UiConstants.space2), + Text( + _formatDate(date), + style: UiTypography.headline5m.textPrimary, + ), + ], ), ], ), + if (endDate != null) ...[ + const SizedBox(height: UiConstants.space4), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + shiftDateLabel, + style: UiTypography.titleUppercase4b.textSecondary, + ), + const SizedBox(height: UiConstants.space2), + Row( + children: [ + const Icon( + UiIcons.calendar, + size: 20, + color: UiColors.primary, + ), + const SizedBox(width: UiConstants.space2), + Text( + _formatDate(endDate!), + style: UiTypography.headline5m.textPrimary, + ), + ], + ), + ], + ), + ], const SizedBox(height: UiConstants.space4), Row( children: [ - Expanded( - child: _buildTimeBox( - clockInLabel, - startTime, - ), - ), + Expanded(child: _buildTimeBox(clockInLabel, startTime)), const SizedBox(width: UiConstants.space4), - Expanded( - child: _buildTimeBox( - clockOutLabel, - endTime, - ), - ), + Expanded(child: _buildTimeBox(clockOutLabel, endTime)), ], ), ], diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/shift_details/shift_details_bottom_bar.dart b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/shift_details/shift_details_bottom_bar.dart index 00eb9578..ccfeae3b 100644 --- a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/shift_details/shift_details_bottom_bar.dart +++ b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/shift_details/shift_details_bottom_bar.dart @@ -1,21 +1,21 @@ +import 'package:core_localization/core_localization.dart'; import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter_modular/flutter_modular.dart'; -import 'package:krow_domain/krow_domain.dart'; -import 'package:core_localization/core_localization.dart'; import 'package:krow_core/core.dart'; +import 'package:krow_domain/krow_domain.dart'; /// A bottom action bar containing contextual buttons based on shift status. class ShiftDetailsBottomBar extends StatelessWidget { /// The current shift. final Shift shift; - + /// Callback for applying/booking a shift. final VoidCallback onApply; - + /// Callback for declining a shift. final VoidCallback onDecline; - + /// Callback for accepting a shift. final VoidCallback onAccept; @@ -57,21 +57,10 @@ class ShiftDetailsBottomBar extends StatelessWidget { Widget _buildButtons(String status, dynamic i18n, BuildContext context) { if (status == 'confirmed') { - return SizedBox( - width: double.infinity, - child: ElevatedButton( - onPressed: () => Modular.to.toClockIn(), - style: ElevatedButton.styleFrom( - backgroundColor: UiColors.success, - foregroundColor: UiColors.white, - padding: const EdgeInsets.symmetric(vertical: UiConstants.space4), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(UiConstants.radiusBase), - ), - elevation: 0, - ), - child: Text(i18n.clock_in, style: UiTypography.body2b.white), - ), + return UiButton.primary( + onPressed: () => Modular.to.toClockIn(), + fullWidth: true, + child: Text(i18n.clock_in, style: UiTypography.body2b.white), ); } @@ -79,36 +68,15 @@ class ShiftDetailsBottomBar extends StatelessWidget { return Row( children: [ Expanded( - child: OutlinedButton( + child: UiButton.secondary( onPressed: onDecline, - style: OutlinedButton.styleFrom( - foregroundColor: UiColors.destructive, - padding: const EdgeInsets.symmetric( - vertical: UiConstants.space4, - ), - side: const BorderSide(color: UiColors.destructive), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(UiConstants.radiusBase), - ), - ), child: Text(i18n.decline, style: UiTypography.body2b.textError), ), ), const SizedBox(width: UiConstants.space4), Expanded( - child: ElevatedButton( + child: UiButton.primary( onPressed: onAccept, - style: ElevatedButton.styleFrom( - backgroundColor: UiColors.primary, - foregroundColor: UiColors.white, - padding: const EdgeInsets.symmetric( - vertical: UiConstants.space4, - ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(UiConstants.radiusBase), - ), - elevation: 0, - ), child: Text(i18n.accept_shift, style: UiTypography.body2b.white), ), ), @@ -117,17 +85,9 @@ class ShiftDetailsBottomBar extends StatelessWidget { } if (status == 'open' || status == 'available') { - return ElevatedButton( + return UiButton.primary( onPressed: onApply, - style: ElevatedButton.styleFrom( - backgroundColor: UiColors.primary, - foregroundColor: UiColors.white, - padding: const EdgeInsets.symmetric(vertical: UiConstants.space4), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(UiConstants.radiusBase), - ), - elevation: 0, - ), + fullWidth: true, child: Text(i18n.apply_now, style: UiTypography.body2b.white), ); } diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/shift_details/shift_schedule_summary_section.dart b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/shift_details/shift_schedule_summary_section.dart new file mode 100644 index 00000000..2600c302 --- /dev/null +++ b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/shift_details/shift_schedule_summary_section.dart @@ -0,0 +1,162 @@ +import 'package:core_localization/core_localization.dart'; +import 'package:design_system/design_system.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:krow_domain/krow_domain.dart'; + +/// A section displaying the shift type, date range, and weekday schedule summary. +class ShiftScheduleSummarySection extends StatelessWidget { + /// The shift entity. + final Shift shift; + + /// Creates a [ShiftScheduleSummarySection]. + const ShiftScheduleSummarySection({super.key, required this.shift}); + + String _getShiftTypeLabel(Translations t) { + final String type = (shift.orderType ?? '').toUpperCase(); + if (type == 'PERMANENT') { + return t.staff_shifts.filter.long_term; + } + if (type == 'RECURRING') { + return t.staff_shifts.filter.multi_day; + } + return t.staff_shifts.filter.one_day; + } + + bool _isMultiDayOrLongTerm() { + final String type = (shift.orderType ?? '').toUpperCase(); + return type == 'RECURRING' || type == 'PERMANENT'; + } + + @override + Widget build(BuildContext context) { + final t = Translations.of(context); + final isMultiDay = _isMultiDayOrLongTerm(); + final typeLabel = _getShiftTypeLabel(t); + final String orderType = (shift.orderType ?? '').toUpperCase(); + + return Padding( + padding: const EdgeInsets.all(UiConstants.space5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Shift Type Title + UiChip(label: typeLabel, variant: UiChipVariant.secondary), + const SizedBox(height: UiConstants.space2), + + if (isMultiDay) ...[ + // Date Range + if (shift.startDate != null && shift.endDate != null) + Row( + children: [ + const Icon( + UiIcons.calendar, + size: 16, + color: UiColors.textSecondary, + ), + const SizedBox(width: UiConstants.space2), + Text( + '${_formatDate(shift.startDate!)} – ${_formatDate(shift.endDate!)}', + style: UiTypography.body2m.textPrimary, + ), + ], + ), + + const SizedBox(height: UiConstants.space4), + + // Weekday Circles + _buildWeekdaySchedule(context), + + // Available Shifts Count (Only for RECURRING/Multi-Day) + if (orderType == 'RECURRING' && shift.schedules != null) ...[ + const SizedBox(height: UiConstants.space4), + Row( + children: [ + Container( + width: 8, + height: 8, + decoration: const BoxDecoration( + color: UiColors.success, + shape: BoxShape.circle, + ), + ), + const SizedBox(width: UiConstants.space2), + Text( + '${shift.schedules!.length} available shifts', + style: UiTypography.body2b.copyWith( + color: UiColors.textSuccess, + ), + ), + ], + ), + ], + ], + ], + ), + ); + } + + String _formatDate(String dateStr) { + try { + final date = DateTime.parse(dateStr); + return DateFormat('MMM d, y').format(date); + } catch (_) { + return dateStr; + } + } + + Widget _buildWeekdaySchedule(BuildContext context) { + final List weekDays = ['S', 'M', 'T', 'W', 'T', 'F', 'S']; + final Set activeDays = _getActiveWeekdayIndices(); + + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: List.generate(weekDays.length, (index) { + final bool isActive = activeDays.contains(index); // 1-7 (Mon-Sun) + return Container( + width: 38, + height: 38, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: isActive ? UiColors.primaryInverse : UiColors.bgThird, + border: Border.all( + color: isActive ? UiColors.primary : UiColors.border, + ), + ), + child: Center( + child: Text( + weekDays[index], + style: UiTypography.body2b.copyWith( + color: isActive ? UiColors.primary : UiColors.textSecondary, + ), + ), + ), + ); + }), + ); + } + + Set _getActiveWeekdayIndices() { + final List days = shift.recurringDays ?? shift.permanentDays ?? []; + return days.map((day) { + switch (day.toUpperCase()) { + case 'MON': + return DateTime.monday; + case 'TUE': + return DateTime.tuesday; + case 'WED': + return DateTime.wednesday; + case 'THU': + return DateTime.thursday; + case 'FRI': + return DateTime.friday; + case 'SAT': + return DateTime.saturday; + case 'SUN': + return DateTime.sunday; + default: + return -1; + } + }).toSet(); + } +} diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/tabs/find_shifts_tab.dart b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/tabs/find_shifts_tab.dart index 81e6ac03..d97938db 100644 --- a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/tabs/find_shifts_tab.dart +++ b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/tabs/find_shifts_tab.dart @@ -1,6 +1,7 @@ import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:krow_domain/krow_domain.dart'; +import 'package:core_localization/core_localization.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../blocs/shifts/shifts_bloc.dart'; @@ -85,11 +86,13 @@ class _FindShiftsTabState extends State { final Shift first = group.first; final List schedules = group - .map((s) => ShiftSchedule( - date: s.date, - startTime: s.startTime, - endTime: s.endTime, - )) + .map( + (s) => ShiftSchedule( + date: s.date, + startTime: s.startTime, + endTime: s.endTime, + ), + ) .toList(); result.add( @@ -126,6 +129,8 @@ class _FindShiftsTabState extends State { orderId: first.orderId, orderType: first.orderType, schedules: schedules, + recurringDays: first.recurringDays, + permanentDays: first.permanentDays, ), ); } @@ -229,7 +234,11 @@ class _FindShiftsTabState extends State { setState(() => _searchQuery = v), decoration: InputDecoration( border: InputBorder.none, - hintText: "Search jobs, location...", + hintText: context + .t + .staff_shifts + .find_shifts + .search_hint, hintStyle: UiTypography.body2r.textPlaceholder, ), ), @@ -263,13 +272,25 @@ class _FindShiftsTabState extends State { scrollDirection: Axis.horizontal, child: Row( children: [ - _buildFilterTab('all', 'All Jobs'), + _buildFilterTab( + 'all', + context.t.staff_shifts.find_shifts.filter_all, + ), const SizedBox(width: UiConstants.space2), - _buildFilterTab('one-day', 'One Day'), + _buildFilterTab( + 'one-day', + context.t.staff_shifts.find_shifts.filter_one_day, + ), const SizedBox(width: UiConstants.space2), - _buildFilterTab('multi-day', 'Multi-Day'), + _buildFilterTab( + 'multi-day', + context.t.staff_shifts.find_shifts.filter_multi_day, + ), const SizedBox(width: UiConstants.space2), - _buildFilterTab('long-term', 'Long Term'), + _buildFilterTab( + 'long-term', + context.t.staff_shifts.find_shifts.filter_long_term, + ), ], ), ), @@ -279,10 +300,10 @@ class _FindShiftsTabState extends State { Expanded( child: filteredJobs.isEmpty - ? const EmptyStateView( + ? EmptyStateView( icon: UiIcons.search, - title: "No jobs available", - subtitle: "Check back later", + title: context.t.staff_shifts.find_shifts.no_jobs_title, + subtitle: context.t.staff_shifts.find_shifts.no_jobs_subtitle, ) : SingleChildScrollView( padding: const EdgeInsets.symmetric( @@ -304,8 +325,11 @@ class _FindShiftsTabState extends State { ); UiSnackbar.show( context, - message: - "Shift application submitted!", // Todo: Localization + message: context + .t + .staff_shifts + .find_shifts + .application_submitted, type: UiSnackbarType.success, ); }, diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/tabs/history_shifts_tab.dart b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/tabs/history_shifts_tab.dart index 6b325194..bc24669a 100644 --- a/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/tabs/history_shifts_tab.dart +++ b/apps/mobile/packages/features/staff/shifts/lib/src/presentation/widgets/tabs/history_shifts_tab.dart @@ -9,10 +9,7 @@ import '../shared/empty_state_view.dart'; class HistoryShiftsTab extends StatelessWidget { final List historyShifts; - const HistoryShiftsTab({ - super.key, - required this.historyShifts, - }); + const HistoryShiftsTab({super.key, required this.historyShifts}); @override Widget build(BuildContext context) { @@ -33,10 +30,8 @@ class HistoryShiftsTab extends StatelessWidget { (shift) => Padding( padding: const EdgeInsets.only(bottom: UiConstants.space3), child: GestureDetector( - onTap: () => Modular.to.pushShiftDetails(shift), - child: MyShiftCard( - shift: shift, - ), + onTap: () => Modular.to.toShiftDetails(shift), + child: MyShiftCard(shift: shift), ), ), ), diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/shift_details_module.dart b/apps/mobile/packages/features/staff/shifts/lib/src/shift_details_module.dart index 78fddf80..f22fc524 100644 --- a/apps/mobile/packages/features/staff/shifts/lib/src/shift_details_module.dart +++ b/apps/mobile/packages/features/staff/shifts/lib/src/shift_details_module.dart @@ -26,6 +26,10 @@ class ShiftDetailsModule extends Module { @override void routes(RouteManager r) { - r.child('/:id', child: (_) => ShiftDetailsPage(shiftId: r.args.params['id'], shift: r.args.data)); + r.child( + '/:id', + child: (_) => + ShiftDetailsPage(shiftId: r.args.params['id'], shift: r.args.data), + ); } } diff --git a/apps/mobile/packages/features/staff/shifts/lib/src/staff_shifts_module.dart b/apps/mobile/packages/features/staff/shifts/lib/src/staff_shifts_module.dart index d9429238..5934588f 100644 --- a/apps/mobile/packages/features/staff/shifts/lib/src/staff_shifts_module.dart +++ b/apps/mobile/packages/features/staff/shifts/lib/src/staff_shifts_module.dart @@ -13,6 +13,7 @@ import 'domain/usecases/apply_for_shift_usecase.dart'; import 'domain/usecases/get_shift_details_usecase.dart'; import 'presentation/blocs/shifts/shifts_bloc.dart'; import 'presentation/blocs/shift_details/shift_details_bloc.dart'; +import 'presentation/utils/shift_tab_type.dart'; import 'presentation/pages/shifts_page.dart'; class StaffShiftsModule extends Module { @@ -45,14 +46,16 @@ class StaffShiftsModule extends Module { i.add(GetShiftDetailsUseCase.new); // Bloc - i.add(() => ShiftsBloc( - getMyShifts: i.get(), - getAvailableShifts: i.get(), - getPendingAssignments: i.get(), - getCancelledShifts: i.get(), - getHistoryShifts: i.get(), - getProfileCompletion: i.get(), - )); + i.add( + () => ShiftsBloc( + getMyShifts: i.get(), + getAvailableShifts: i.get(), + getPendingAssignments: i.get(), + getCancelledShifts: i.get(), + getHistoryShifts: i.get(), + getProfileCompletion: i.get(), + ), + ); i.add(ShiftDetailsBloc.new); } @@ -63,8 +66,9 @@ class StaffShiftsModule extends Module { child: (_) { final args = r.args.data as Map?; final queryParams = r.args.queryParams; + final initialTabStr = queryParams['tab'] ?? args?['initialTab']; return ShiftsPage( - initialTab: queryParams['tab'] ?? args?['initialTab'], + initialTab: ShiftTabType.fromString(initialTabStr), selectedDate: args?['selectedDate'], refreshAvailable: args?['refreshAvailable'] == true, ); diff --git a/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/blocs/staff_main_cubit.dart b/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/blocs/staff_main_cubit.dart index b868c7ca..814b5932 100644 --- a/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/blocs/staff_main_cubit.dart +++ b/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/blocs/staff_main_cubit.dart @@ -8,17 +8,22 @@ import 'package:staff_main/src/presentation/blocs/staff_main_state.dart'; class StaffMainCubit extends Cubit implements Disposable { StaffMainCubit({ required GetProfileCompletionUseCase getProfileCompletionUsecase, - }) : _getProfileCompletionUsecase = getProfileCompletionUsecase, - super(const StaffMainState()) { + }) : _getProfileCompletionUsecase = getProfileCompletionUsecase, + super(const StaffMainState()) { Modular.to.addListener(_onRouteChanged); _onRouteChanged(); - _loadProfileCompletion(); } final GetProfileCompletionUseCase _getProfileCompletionUsecase; + bool _isLoadingCompletion = false; void _onRouteChanged() { if (isClosed) return; + + // Refresh completion status whenever route changes to catch profile updates + // only if it's not already complete. + refreshProfileCompletion(); + final String path = Modular.to.path; int newIndex = state.currentIndex; @@ -41,7 +46,10 @@ class StaffMainCubit extends Cubit implements Disposable { } /// Loads the profile completion status. - Future _loadProfileCompletion() async { + Future refreshProfileCompletion() async { + if (_isLoadingCompletion || isClosed) return; + + _isLoadingCompletion = true; try { final isComplete = await _getProfileCompletionUsecase(); if (!isClosed) { @@ -53,6 +61,8 @@ class StaffMainCubit extends Cubit implements Disposable { if (!isClosed) { emit(state.copyWith(isProfileComplete: true)); } + } finally { + _isLoadingCompletion = false; } } diff --git a/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/pages/placeholder_page.dart b/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/pages/placeholder_page.dart deleted file mode 100644 index b9d993d6..00000000 --- a/apps/mobile/packages/features/staff/staff_main/lib/src/presentation/pages/placeholder_page.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:flutter/material.dart'; - -class PlaceholderPage extends StatelessWidget { - const PlaceholderPage({required this.title, super.key}); - - final String title; - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: Text(title)), - body: Center(child: Text('$title Page')), - ); - } -} diff --git a/apps/mobile/pubspec.yaml b/apps/mobile/pubspec.yaml index bca32555..350e842f 100644 --- a/apps/mobile/pubspec.yaml +++ b/apps/mobile/pubspec.yaml @@ -32,8 +32,9 @@ workspace: - packages/features/client/home - packages/features/client/settings - packages/features/client/hubs - - packages/features/client/create_order - - packages/features/client/view_orders + - packages/features/client/orders/create_order + - packages/features/client/orders/view_orders + - packages/features/client/orders/orders_common - packages/features/client/client_coverage - packages/features/client/client_main - packages/features/client/reports diff --git a/backend/dataconnect/connector/order/queries.gql b/backend/dataconnect/connector/order/queries.gql index c500c595..f3aad90b 100644 --- a/backend/dataconnect/connector/order/queries.gql +++ b/backend/dataconnect/connector/order/queries.gql @@ -433,3 +433,98 @@ query listOrdersByBusinessAndTeamHub( createdBy } } + +# ------------------------------------------------------------ +# GET COMPLETED ORDERS BY BUSINESS AND DATE RANGE +# ------------------------------------------------------------ +query listCompletedOrdersByBusinessAndDateRange( + $businessId: UUID! + $start: Timestamp! + $end: Timestamp! + $offset: Int + $limit: Int +) @auth(level: USER) { + orders( + where: { + businessId: { eq: $businessId } + status: { eq: COMPLETED } + date: { ge: $start, le: $end } + } + offset: $offset + limit: $limit + orderBy: { createdAt: DESC } + ) { + id + eventName + + vendorId + businessId + orderType + status + date + startDate + endDate + duration + lunchBreak + total + assignedStaff + requested + recurringDays + permanentDays + poReference + notes + createdAt + + business { + id + businessName + email + contactName + } + + vendor { + id + companyName + } + + teamHub { + address + placeId + hubName + } + + # Assigned shifts and their roles + shifts_on_order { + id + title + date + startTime + endTime + hours + cost + location + locationAddress + status + workersNeeded + filled + + shiftRoles_on_shift { + id + roleId + count + assigned + startTime + endTime + hours + totalValue + + role { + id + name + costPerHour + } + } + } + } +} + diff --git a/backend/dataconnect/connector/shiftRole/queries.gql b/backend/dataconnect/connector/shiftRole/queries.gql index 6795e79d..37a06b67 100644 --- a/backend/dataconnect/connector/shiftRole/queries.gql +++ b/backend/dataconnect/connector/shiftRole/queries.gql @@ -306,6 +306,8 @@ query listShiftRolesByVendorId( orderType status date + startDate + endDate recurringDays permanentDays notes @@ -399,14 +401,21 @@ query listShiftRolesByBusinessAndOrder( orderId location locationAddress + filled order{ vendorId eventName date + startDate + endDate + recurringDays + permanentDays + orderType #location teamHub { + id address placeId hubName @@ -417,6 +426,29 @@ query listShiftRolesByBusinessAndOrder( } } +query listShiftRolesByOrderAndRole( + $orderId: UUID! + $roleId: UUID! +) @auth(level: USER) { + shiftRoles( + where: { + shift: { orderId: { eq: $orderId } } + roleId: { eq: $roleId } + } + ) { + id + shiftId + roleId + count + assigned + shift { + id + filled + date + } + } +} + #reorder get list by businessId query listShiftRolesByBusinessDateRangeCompletedOrders( $businessId: UUID!