LCOV - code coverage report
Current view: top level - lib/design/form - date_range_input.dart Coverage Total Hit
Test: lcov.info Lines: 13.0 % 23 3
Test Date: 2026-11-14 15:08:11 Functions: - 0 0

            Line data    Source code
       1              : // Copyright 2023 The terCAD team. All rights reserved.
       2              : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
       3              : 
       4              : import 'package:app_finance/_classes/herald/app_locale.dart';
       5              : import 'package:app_finance/_ext/build_context_ext.dart';
       6              : import 'package:app_finance/design/form/date_input.dart';
       7              : import 'package:custom_date_range_picker/custom_date_range_picker.dart';
       8              : import 'package:material_ui/material_ui.dart';
       9              : import 'package:intl/intl.dart';
      10              : 
      11              : class DateRangeInput extends DateInput {
      12              :   final DateTime? valueFrom;
      13              : 
      14            1 :   const DateRangeInput({super.key, required super.setState, required super.value, required this.valueFrom});
      15              : 
      16            1 :   @override
      17            1 :   DateRangeInputState createState() => DateRangeInputState();
      18              : }
      19              : 
      20              : class DateRangeInputState extends DateInputState<DateRangeInput> {
      21            0 :   @override
      22              :   Future<void> onTap(BuildContext context) async {
      23            0 :     showCustomDateRangePicker(
      24              :       context,
      25              :       dismissible: true,
      26            0 :       minimumDate: DateTime.now().subtract(const Duration(days: 365 * 5)), // 5 years back
      27            0 :       maximumDate: DateTime.now().add(const Duration(days: 30)),
      28            0 :       endDate: widget.value,
      29            0 :       startDate: widget.valueFrom,
      30            0 :       backgroundColor: context.colorScheme.surface,
      31            0 :       primaryColor: context.colorScheme.primary,
      32            0 :       onApplyClick: (start, end) {
      33            0 :         widget.setState(start, end);
      34            0 :         focusController.onEditingComplete(this);
      35              :       },
      36            0 :       onCancelClick: () => widget.setState(null, null),
      37              :     );
      38              :   }
      39              : 
      40            0 :   @override
      41              :   String formatDate(DateTime? date) {
      42            0 :     final DateFormat formatter = DateFormat.yMd(AppLocale.code);
      43            0 :     if (date == null && widget.valueFrom == null) {
      44              :       return '';
      45              :     }
      46            0 :     if (date == null && widget.valueFrom != null) {
      47            0 :       return '${formatter.format(widget.valueFrom!)} ...';
      48              :     }
      49            0 :     if (date != null && widget.valueFrom == null) {
      50            0 :       return '... ${formatter.format(date)}';
      51              :     }
      52            0 :     return '${formatter.format(widget.valueFrom!)} ... ${formatter.format(date!)}';
      53              :   }
      54              : }
        

Generated by: LCOV version 2.0-1