2022-11-29 13:16:44 +01:00
|
|
|
// SPDX-FileCopyrightText: 2022 Iconica
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_input_library/src/inputs/date_picker/date_picker_field.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
|
|
|
enum FlutterFormDateTimeType {
|
|
|
|
date,
|
|
|
|
time,
|
|
|
|
dateTime,
|
|
|
|
range,
|
|
|
|
}
|
|
|
|
|
2023-03-26 12:16:25 +02:00
|
|
|
class FlutterFormInputDateTime extends StatelessWidget {
|
2023-03-24 09:49:03 +01:00
|
|
|
const FlutterFormInputDateTime({
|
|
|
|
this.decoration,
|
|
|
|
this.style,
|
|
|
|
Key? key,
|
|
|
|
this.label,
|
|
|
|
this.showIcon = true,
|
|
|
|
required this.inputType,
|
|
|
|
required this.dateFormat,
|
|
|
|
this.firstDate,
|
|
|
|
this.lastDate,
|
|
|
|
this.initialDate,
|
|
|
|
this.initialDateTimeRange,
|
|
|
|
this.icon = Icons.calendar_today,
|
|
|
|
this.initialValue,
|
|
|
|
this.onChanged,
|
|
|
|
this.onSaved,
|
|
|
|
this.validator,
|
|
|
|
this.autovalidateMode = AutovalidateMode.disabled,
|
|
|
|
this.timePickerEntryMode = TimePickerEntryMode.dial,
|
|
|
|
}) : super(
|
2022-11-29 13:16:44 +01:00
|
|
|
key: key,
|
|
|
|
);
|
2023-01-17 14:56:30 +01:00
|
|
|
final TextStyle? style;
|
2023-01-05 11:15:16 +01:00
|
|
|
final InputDecoration? decoration;
|
2022-11-29 13:16:44 +01:00
|
|
|
final Widget? label;
|
|
|
|
final bool showIcon;
|
|
|
|
final FlutterFormDateTimeType inputType;
|
|
|
|
final DateFormat dateFormat;
|
|
|
|
final DateTime? initialDate;
|
|
|
|
final DateTimeRange? initialDateTimeRange;
|
|
|
|
final DateTime? firstDate;
|
|
|
|
final DateTime? lastDate;
|
|
|
|
final IconData icon;
|
|
|
|
final String? initialValue;
|
|
|
|
final String? Function(String?)? validator;
|
|
|
|
final void Function(String?)? onSaved;
|
|
|
|
final void Function(String?)? onChanged;
|
2023-01-16 15:07:01 +01:00
|
|
|
final AutovalidateMode autovalidateMode;
|
2023-03-24 09:49:03 +01:00
|
|
|
final TimePickerEntryMode timePickerEntryMode;
|
2022-11-29 13:16:44 +01:00
|
|
|
|
|
|
|
@override
|
2023-03-26 12:16:25 +02:00
|
|
|
Widget build(BuildContext context) {
|
2022-11-29 13:16:44 +01:00
|
|
|
return DateTimeInputField(
|
2023-01-17 14:56:30 +01:00
|
|
|
style: style,
|
2023-01-05 11:15:16 +01:00
|
|
|
decoration: decoration,
|
2023-01-16 15:07:01 +01:00
|
|
|
autovalidateMode: autovalidateMode,
|
|
|
|
validator: validator,
|
2022-11-29 13:16:44 +01:00
|
|
|
label: label,
|
|
|
|
icon: icon,
|
|
|
|
firstDate: firstDate,
|
|
|
|
lastDate: lastDate,
|
|
|
|
inputType: inputType,
|
|
|
|
dateFormat: dateFormat,
|
|
|
|
initialDate: initialDate,
|
|
|
|
initialDateTimeRange: initialDateTimeRange,
|
|
|
|
initialValue: initialValue,
|
|
|
|
onChanged: (value) => onChanged?.call(value),
|
|
|
|
onSaved: (value) => onSaved?.call(value),
|
|
|
|
showIcon: showIcon,
|
2023-03-24 09:49:03 +01:00
|
|
|
timePickerEntryMode: timePickerEntryMode,
|
2022-11-29 13:16:44 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|