Skip to content

Commit

Permalink
Fix failing build
Browse files Browse the repository at this point in the history
  • Loading branch information
Pante committed Jul 26, 2024
1 parent 63b69e6 commit ede149c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions docs/pages/docs/calendar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ FCalendar(
<Tabs.Tab>
<Widget name='calendar' variant='unselectable' query={{}} height={500}/>
</Tabs.Tab>
<Tabs.Tab>
```dart
FCalendar(
controller: FCalendarMultiValueController(
Expand Down
2 changes: 1 addition & 1 deletion forui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

### Changes
* Change number of years displayed per page in `FCalendar` from 12 to 15.
* **Breaking:** Move `FCalendar.enabled` to `FCalendarController.canSelect(...)`.
* **Breaking:** Move `FCalendar.enabled` to `FCalendarController.selectable(...)`.

* **Breaking:** Rename `FCalendarController.contains(...)` to `FCalendarController.selected(...)`.
* **Breaking:** Rename `FCalendarController.onPress(...)` to `FCalendarController.select(...)`.
Expand Down
8 changes: 4 additions & 4 deletions forui/lib/src/widgets/calendar/calendar_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ class FCalendarMultiValueController extends FCalendarController<Set<DateTime>> {
/// Throws [AssertionError] if the dates in [initialSelections] are not in UTC timezone.
FCalendarMultiValueController({
Set<DateTime> initialSelections = const {},
Predicate<DateTime>? canSelect,
Predicate<DateTime>? selectable,
}) : assert(initialSelections.every((d) => d.isUtc), 'dates must be in UTC timezone'),
_selectable = canSelect ?? _true,
_selectable = selectable ?? _true,
super(initialSelections);

@override
Expand Down Expand Up @@ -111,7 +111,7 @@ class FCalendarRangeController extends FCalendarController<(DateTime, DateTime)?
/// * the end date is less than start date.
FCalendarRangeController({
(DateTime, DateTime)? initialSelection,
Predicate<DateTime>? canSelect,
Predicate<DateTime>? selectable,
}) : assert(
initialSelection == null || (initialSelection.$1.isUtc && initialSelection.$2.isUtc),
'value must be in UTC timezone',
Expand All @@ -122,7 +122,7 @@ class FCalendarRangeController extends FCalendarController<(DateTime, DateTime)?
initialSelection.$1.isAtSameMomentAs(initialSelection.$2)),
'end date must be greater than or equal to start date',
),
_selectable = canSelect ?? _true,
_selectable = selectable ?? _true,
super(initialSelection);

@override
Expand Down
4 changes: 2 additions & 2 deletions forui/test/src/widgets/calendar/calendar_controller_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void main() {
(DateTime.utc(2024, 5, 4), true),
(DateTime.utc(2024, 5, 5), false),
]) {
test('contains(...) contains date', () {
test('selected(...) contains date', () {
final controller = FCalendarValueController(initialSelection: DateTime.utc(2024, 5, 4));
expect(controller.selected(date), expected);
});
Expand All @@ -37,7 +37,7 @@ void main() {
(DateTime.utc(2024), true),
(DateTime.utc(2025), false),
]) {
test('contains(...)', () {
test('selected(...)', () {
final controller = FCalendarMultiValueController(initialSelections: {DateTime.utc(2024)});
expect(controller.selected(date), expected);
});
Expand Down
2 changes: 1 addition & 1 deletion forui/test/src/widgets/calendar/calendar_golden_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void main() {
child: FCalendar(
controller: FCalendarMultiValueController(
initialSelections: selected,
canSelect: (date) => date != DateTime.utc(2024, 7, 2),
selectable: (date) => date != DateTime.utc(2024, 7, 2),
),
start: DateTime(1900, 1, 8),
end: DateTime(2024, 7, 10),
Expand Down
8 changes: 4 additions & 4 deletions forui/test/src/widgets/calendar/calendar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() {
TestScaffold(
data: FThemes.zinc.light,
child: FCalendar(
controller: FCalendarMultiValueController(canSelect: (date) => date != DateTime.utc(2024, 7, 2)),
controller: FCalendarMultiValueController(selectable: (date) => date != DateTime.utc(2024, 7, 2)),
start: DateTime(1900, 1, 8),
end: DateTime(2024, 7, 10),
today: DateTime(2024, 7, 14),
Expand All @@ -32,7 +32,7 @@ void main() {
TestScaffold(
data: FThemes.zinc.light,
child: FCalendar(
controller: FCalendarMultiValueController(canSelect: (date) => date != DateTime.utc(2024, 7, 2)),
controller: FCalendarMultiValueController(selectable: (date) => date != DateTime.utc(2024, 7, 2)),
start: DateTime(2024, 7),
end: DateTime(2024, 7, 10),
today: DateTime(2024, 7, 14),
Expand All @@ -55,7 +55,7 @@ void main() {
TestScaffold(
data: FThemes.zinc.light,
child: FCalendar(
controller: FCalendarMultiValueController(canSelect: (date) => date != DateTime.utc(2024, 7, 2)),
controller: FCalendarMultiValueController(selectable: (date) => date != DateTime.utc(2024, 7, 2)),
start: DateTime(1900, 1, 8),
end: DateTime(2024, 8, 10),
today: DateTime(2024, 7, 14),
Expand All @@ -76,7 +76,7 @@ void main() {
TestScaffold(
data: FThemes.zinc.light,
child: FCalendar(
controller: FCalendarMultiValueController(canSelect: (date) => date != DateTime.utc(2024, 7, 2)),
controller: FCalendarMultiValueController(selectable: (date) => date != DateTime.utc(2024, 7, 2)),
start: DateTime(2024),
end: DateTime(2024, 7, 10),
today: DateTime(2024, 7, 14),
Expand Down
2 changes: 1 addition & 1 deletion samples/lib/widgets/calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class UnselectableCalendarPage extends SampleScaffold {
Widget child(BuildContext context) => FCalendar(
controller: FCalendarMultiValueController(
initialSelections: {DateTime.utc(2024, 7, 17), DateTime.utc(2024, 7, 20)},
canSelect: (date) => !{DateTime.utc(2024, 7, 18), DateTime.utc(2024, 7, 19)}.contains(date),
selectable: (date) => !{DateTime.utc(2024, 7, 18), DateTime.utc(2024, 7, 19)}.contains(date),
),
start: DateTime.utc(2000),
today: DateTime.utc(2024, 7, 15),
Expand Down

0 comments on commit ede149c

Please sign in to comment.