Skip to content

Commit eb70d0c

Browse files
committed
feat: version 7.5.25
1 parent 02b0692 commit eb70d0c

10 files changed

Lines changed: 98 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 7.5.25
4+
- Added the `firstDay` and `lastDay` parameters to `ThemedCalendar` to allow setting a date range for the picker, preventing selection of dates outside the specified range.
5+
- The `firstDay` and `lastDay` parameters are now supported in `ThemedDateRangePicker`, `ThemedDatePicker`, `ThemedDateTimeRangePicker`, `ThemedDateTimeSteppedPicker` and `ThemedDateTimePicker`.
6+
37
## 7.5.24
48

59
- Fixed `ThemedTable2` silent update loss for mid-list edits: reverted `didUpdateWidget` heuristic back to `DeepCollectionEquality` — the heuristic (identical + length + first element) missed edits to non-first elements in same-length lists; with Freezed value-equality objects the O(n) cost is negligible in practice (~4 of 170 telemetry updates actually triggered a reload in production profiling).

example/lib/views/inputs/src/selectors/datetime.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class _DateTimePickersViewState extends State<DateTimePickersView> {
170170
ThemedDateTimeSteppedPicker(
171171
labelText: "Example label",
172172
value: _selectedDateTime,
173+
firstDay: DateTime.now().subtract(const Duration(days: 10)),
174+
lastDay: DateTime.now(),
173175
onChanged: (val) {
174176
_selectedTime = TimeOfDay(hour: val.hour, minute: val.minute);
175177
setState(() => _selectedDateTime = val);

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ packages:
390390
path: ".."
391391
relative: true
392392
source: path
393-
version: "7.5.23"
393+
version: "7.5.25"
394394
leak_tracker:
395395
dependency: transitive
396396
description:

lib/src/inputs/src/pickers/date/range.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ class ThemedDateRangePicker extends StatefulWidget {
8181
/// [emptyListText] is the text to be displayed when the list is empty.
8282
final EdgeInsets? padding;
8383

84+
/// [lastDay] any datetime after this day will be disabled. If null, the calendar will not have a limit.
85+
final DateTime? lastDay;
86+
87+
/// [firstDay] any datetime before this day will be disabled. If null, the calendar will not have a limit.
88+
final DateTime? firstDay;
89+
8490
/// [ThemedDateRangePicker] is a date picker input. It is a wrapper of [ThemedTextInput] with a date picker.
8591
const ThemedDateRangePicker({
8692
super.key,
@@ -112,6 +118,8 @@ class ThemedDateRangePicker extends StatefulWidget {
112118
this.errors = const [],
113119
this.hideDetails = false,
114120
this.padding,
121+
this.firstDay,
122+
this.lastDay,
115123
}) : assert((label == null && labelText != null) || (label != null && labelText == null)),
116124
assert(value.length == 0 || value.length == 2);
117125

@@ -220,6 +228,8 @@ class _ThemedDateRangePickerState extends State<ThemedDateRangePicker> {
220228
smallWeekdays: true,
221229
todayIndicator: false,
222230
todayButton: false,
231+
firstDay: widget.firstDay,
232+
lastDay: widget.lastDay,
223233
onDayTap: (day) {
224234
if (tempDate == null) {
225235
tempDate = day;

lib/src/inputs/src/pickers/date/single.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ class ThemedDatePicker extends StatefulWidget {
8484
/// [emptyListText] is the text to be displayed when the list is empty.
8585
final EdgeInsets? padding;
8686

87+
/// [lastDay] any datetime after this day will be disabled. If null, the calendar will not have a limit.
88+
final DateTime? lastDay;
89+
90+
/// [firstDay] any datetime before this day will be disabled. If null, the calendar will not have a limit.
91+
final DateTime? firstDay;
92+
8793
/// [ThemedDatePicker] is a date picker input. It is a wrapper of [ThemedTextInput] with a date picker.
8894
const ThemedDatePicker({
8995
super.key,
@@ -116,6 +122,8 @@ class ThemedDatePicker extends StatefulWidget {
116122
this.errors = const [],
117123
this.hideDetails = false,
118124
this.padding,
125+
this.firstDay,
126+
this.lastDay,
119127
}) : assert((label == null && labelText != null) || (label != null && labelText == null));
120128

121129
@override
@@ -199,6 +207,8 @@ class _ThemedDatePickerState extends State<ThemedDatePicker> {
199207
showEntries: false,
200208
smallWeekdays: true,
201209
disabledDays: widget.disabledDays,
210+
firstDay: widget.firstDay,
211+
lastDay: widget.lastDay,
202212
onDayTap: (day) {
203213
Navigator.of(context).pop(day);
204214
},

lib/src/inputs/src/pickers/datetime/range.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ class ThemedDateTimeRangePicker extends StatefulWidget {
103103
/// [emptyListText] is the text to be displayed when the list is empty.
104104
final EdgeInsets? padding;
105105

106+
/// [lastDay] any datetime after this day will be disabled. If null, the calendar will not have a limit.
107+
final DateTime? lastDay;
108+
109+
/// [firstDay] any datetime before this day will be disabled. If null, the calendar will not have a limit.
110+
final DateTime? firstDay;
111+
106112
/// [ThemedDateTimeRangePicker] is a date time picker input. It is a wrapper of [ThemedTextInput]
107113
/// with a date time picker.
108114
const ThemedDateTimeRangePicker({
@@ -148,6 +154,8 @@ class ThemedDateTimeRangePicker extends StatefulWidget {
148154
this.errors = const [],
149155
this.hideDetails = false,
150156
this.padding,
157+
this.firstDay,
158+
this.lastDay,
151159
}) : assert((label == null && labelText != null) || (label != null && labelText == null)),
152160
assert(value.length == 0 || value.length == 2);
153161

@@ -245,6 +253,8 @@ class _ThemedDateTimeRangePickerState extends State<ThemedDateTimeRangePicker> w
245253
translations: widget.translations,
246254
overridesLayrzTranslations: widget.overridesLayrzTranslations,
247255
use24HourFormat: widget.use24HourFormat,
256+
firstDay: widget.firstDay,
257+
lastDay: widget.lastDay,
248258
),
249259
);
250260

@@ -276,6 +286,8 @@ class ThemedDateTimeRangeDialog extends StatefulWidget {
276286
final List<DateTime> disabledDays;
277287
final Map<String, String> translations;
278288
final bool overridesLayrzTranslations;
289+
final DateTime? firstDay;
290+
final DateTime? lastDay;
279291
final bool use24HourFormat;
280292

281293
const ThemedDateTimeRangeDialog({
@@ -286,6 +298,8 @@ class ThemedDateTimeRangeDialog extends StatefulWidget {
286298
this.translations = const {},
287299
this.overridesLayrzTranslations = false,
288300
this.use24HourFormat = false,
301+
this.firstDay,
302+
this.lastDay,
289303
});
290304

291305
@override
@@ -383,6 +397,8 @@ class _ThemedDateTimeRangeDialogState extends State<ThemedDateTimeRangeDialog> w
383397
controller: _tabController,
384398
children: [
385399
ThemedCalendar(
400+
firstDay: widget.firstDay,
401+
lastDay: widget.lastDay,
386402
focusDay: tempDate,
387403
focusOnHighlightedDays: tempDate == null,
388404
showEntries: false,

lib/src/inputs/src/pickers/datetime/single.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ class ThemedDateTimePicker extends StatefulWidget {
103103
/// [emptyListText] is the text to be displayed when the list is empty.
104104
final EdgeInsets? padding;
105105

106+
/// [lastDay] any datetime after this day will be disabled. If null, the calendar will not have a limit.
107+
final DateTime? lastDay;
108+
109+
/// [firstDay] any datetime before this day will be disabled. If null, the calendar will not have a limit.
110+
final DateTime? firstDay;
111+
106112
/// [ThemedDateTimePicker] is a date time picker input. It is a wrapper of [ThemedTextInput] with a date time picker.
107113
const ThemedDateTimePicker({
108114
super.key,
@@ -147,6 +153,8 @@ class ThemedDateTimePicker extends StatefulWidget {
147153
this.errors = const [],
148154
this.hideDetails = false,
149155
this.padding,
156+
this.firstDay,
157+
this.lastDay,
150158
}) : assert((label == null && labelText != null) || (label != null && labelText == null));
151159

152160
@override
@@ -304,6 +312,8 @@ class _ThemedDateTimePickerState extends State<ThemedDateTimePicker> with Single
304312
disabledDays: widget.disabledDays,
305313
translations: widget.translations,
306314
overridesLayrzTranslations: widget.overridesLayrzTranslations,
315+
firstDay: widget.firstDay,
316+
lastDay: widget.lastDay,
307317
onDayTap: (newDate) => setState(() => date = newDate),
308318
),
309319
Column(

lib/src/inputs/src/pickers/datetime/single_stepped.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ class ThemedDateTimeSteppedPicker extends StatefulWidget {
105105

106106
final bool disableTimePickerBlink;
107107

108+
/// [lastDay] any datetime after this day will be disabled. If null, the calendar will not have a limit.
109+
final DateTime? lastDay;
110+
111+
/// [firstDay] any datetime before this day will be disabled. If null, the calendar will not have a limit.
112+
final DateTime? firstDay;
113+
108114
/// [ThemedDateTimeSteppedPicker] is a date time stepped picker input. It is a wrapper of [ThemedTextInput] with a date time stepped picker.
109115
const ThemedDateTimeSteppedPicker({
110116
super.key,
@@ -150,6 +156,8 @@ class ThemedDateTimeSteppedPicker extends StatefulWidget {
150156
this.hideDetails = false,
151157
this.padding,
152158
this.disableTimePickerBlink = false,
159+
this.firstDay,
160+
this.lastDay,
153161
}) : assert((label == null && labelText != null) || (label != null && labelText == null));
154162

155163
@override
@@ -241,6 +249,8 @@ class _ThemedDateTimeSteppedPickerState extends State<ThemedDateTimeSteppedPicke
241249
showEntries: false,
242250
smallWeekdays: true,
243251
disabledDays: widget.disabledDays,
252+
lastDay: widget.lastDay,
253+
firstDay: widget.firstDay,
244254
onDayTap: (day) {
245255
Navigator.of(context).pop(day);
246256
},

lib/src/widgets/src/calendar.dart

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ class ThemedCalendar extends StatefulWidget {
113113
/// [focusOnHighlightedDays] allows to focus the calendar in a day between the highlighted days.
114114
final bool focusOnHighlightedDays;
115115

116+
/// [lastDay] any datetime after this day will be disabled. If null, the calendar will not have a limit.
117+
final DateTime? lastDay;
118+
119+
/// [firstDay] any datetime before this day will be disabled. If null, the calendar will not have a limit.
120+
final DateTime? firstDay;
121+
116122
const ThemedCalendar({
117123
super.key,
118124
this.focusDay,
@@ -152,6 +158,8 @@ class ThemedCalendar extends StatefulWidget {
152158
this.todayButton = true,
153159
this.aditionalButtons = const [],
154160
this.focusOnHighlightedDays = false,
161+
this.lastDay,
162+
this.firstDay,
155163
});
156164

157165
@override
@@ -626,10 +634,33 @@ class _ThemedCalendarState extends State<ThemedCalendar> {
626634
})
627635
.contains(now);
628636

629-
if (widget.isHighlightDaysAsRange) {
630-
isFocusDay = false;
631-
isDisabled = false;
637+
if (widget.firstDay != null) {
638+
isDisabled =
639+
isDisabled ||
640+
now.isBefore(
641+
DateTime(
642+
widget.firstDay!.year,
643+
widget.firstDay!.month,
644+
widget.firstDay!.day,
645+
),
646+
);
632647
}
648+
if (widget.lastDay != null) {
649+
isDisabled =
650+
isDisabled ||
651+
now.isAfter(
652+
DateTime(
653+
widget.lastDay!.year,
654+
widget.lastDay!.month,
655+
widget.lastDay!.day,
656+
),
657+
);
658+
}
659+
660+
// if (widget.isHighlightDaysAsRange) {
661+
// isFocusDay = false;
662+
// isDisabled = false;
663+
// }
633664

634665
bool isCurrentMonth = day.month == _dayGenerator.month;
635666

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: layrz_theme
22
description: Layrz standard styling library for Flutter. Widget library following the Material Design 3 guidelines, with a focus on reliavility and functionality.
3-
version: "7.5.24"
3+
version: "7.5.25"
44
homepage: https://theme.layrz.com
55
repository: https://github.com/goldenm-software/layrz_theme
66

0 commit comments

Comments
 (0)