Skip to content

Commit

Permalink
Commit from GitHub Actions (Forui Presubmit)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pante committed Jul 14, 2024
1 parent a431156 commit 32236df
Show file tree
Hide file tree
Showing 18 changed files with 115 additions and 91 deletions.
1 change: 0 additions & 1 deletion forui/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:forui/forui.dart';
import 'package:forui_example/example.dart';


void main() {
runApp(const Application());
}
Expand Down
1 change: 1 addition & 0 deletions forui/lib/src/foundation/inkwell.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';

import 'package:meta/meta.dart';

@internal
Expand Down
4 changes: 3 additions & 1 deletion forui/lib/src/widgets/calendar/calendar.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';

import 'package:sugar/sugar.dart';

import 'package:forui/forui.dart';
import 'package:forui/src/widgets/calendar/day/day_picker.dart';
import 'package:forui/src/widgets/calendar/day/paged_day_picker.dart';
import 'package:forui/src/widgets/calendar/shared/header.dart';
import 'package:forui/src/widgets/calendar/year_month_picker.dart';
import 'package:sugar/sugar.dart';

export 'day/day_picker.dart' show FCalendarDayPickerStyle, FCalendarDayStyle;
export 'shared/entry.dart' show FCalendarEntryStyle;
Expand Down
4 changes: 3 additions & 1 deletion forui/lib/src/widgets/calendar/calendar_controller.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:flutter/widgets.dart';
import 'package:forui/forui.dart';

import 'package:sugar/sugar.dart';

import 'package:forui/forui.dart';

/// A controller that controls date selection in a calendar.
///
/// This class should be extended to customize date selection. By default, the following controllers are provided:
Expand Down
84 changes: 42 additions & 42 deletions forui/lib/src/widgets/calendar/day/day_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import 'dart:collection';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:forui/forui.dart';
import 'package:forui/src/widgets/calendar/shared/entry.dart';

import 'package:meta/meta.dart';
import 'package:sugar/sugar.dart';

import 'package:forui/forui.dart';
import 'package:forui/src/widgets/calendar/shared/entry.dart';

@internal
class DayPicker extends StatefulWidget {
static const maxRows = 7;
static const tileDimension = 42.0;

final FCalendarDayPickerStyle style;
final LocalDate month;
final LocalDate today;
Expand Down Expand Up @@ -91,35 +93,34 @@ class _DayPickerState extends State<DayPicker> {
return (first, last);
}


@override
Widget build(BuildContext context) => SizedBox(
width: DateTime.daysPerWeek * DayPicker.tileDimension,
child: GridView.custom(
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const _GridDelegate(),
childrenDelegate: SliverChildListDelegate(
addRepaintBoundaries: false,
[
..._headers(context),
for (final MapEntry(key: date, value: focusNode) in _days.entries)
Entry.day(
style: widget.style,
date: date,
focusNode: focusNode,
current: date.month == widget.month.month,
today: date == widget.today,
enabled: widget.enabled,
selected: widget.selected,
onPress: widget.onPress,
onLongPress: widget.onLongPress,
),
],
),
),
);
width: DateTime.daysPerWeek * DayPicker.tileDimension,
child: GridView.custom(
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: const _GridDelegate(),
childrenDelegate: SliverChildListDelegate(
addRepaintBoundaries: false,
[
..._headers(context),
for (final MapEntry(key: date, value: focusNode) in _days.entries)
Entry.day(
style: widget.style,
date: date,
focusNode: focusNode,
current: date.month == widget.month.month,
today: date == widget.today,
enabled: widget.enabled,
selected: widget.selected,
onPress: widget.onPress,
onLongPress: widget.onLongPress,
),
],
),
),
);

List<Widget> _headers(BuildContext context) {
final firstDayOfWeek = widget.style.startDayOfWeek ?? DateTime.sunday; // TODO: Localization
Expand Down Expand Up @@ -158,19 +159,18 @@ class _GridDelegate extends SliverGridDelegate {

@override
SliverGridLayout getLayout(SliverConstraints constraints) => SliverGridRegularTileLayout(
childCrossAxisExtent: DayPicker.tileDimension,
childMainAxisExtent: DayPicker.tileDimension,
crossAxisCount: DateTime.daysPerWeek,
crossAxisStride: DayPicker.tileDimension,
mainAxisStride: DayPicker.tileDimension,
reverseCrossAxis: axisDirectionIsReversed(constraints.crossAxisDirection),
);
childCrossAxisExtent: DayPicker.tileDimension,
childMainAxisExtent: DayPicker.tileDimension,
crossAxisCount: DateTime.daysPerWeek,
crossAxisStride: DayPicker.tileDimension,
mainAxisStride: DayPicker.tileDimension,
reverseCrossAxis: axisDirectionIsReversed(constraints.crossAxisDirection),
);

@override
bool shouldRelayout(_GridDelegate oldDelegate) => false;
}


/// A day picker's style.
final class FCalendarDayPickerStyle with Diagnosticable {
/// The text style for the day of th week headers.
Expand Down Expand Up @@ -364,10 +364,10 @@ final class FCalendarDayStyle with Diagnosticable {
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is FCalendarDayStyle &&
runtimeType == other.runtimeType &&
unselectedStyle == other.unselectedStyle &&
selectedStyle == other.selectedStyle;
other is FCalendarDayStyle &&
runtimeType == other.runtimeType &&
unselectedStyle == other.unselectedStyle &&
selectedStyle == other.selectedStyle;

@override
int get hashCode => unselectedStyle.hashCode ^ selectedStyle.hashCode;
Expand Down
6 changes: 4 additions & 2 deletions forui/lib/src/widgets/calendar/day/paged_day_picker.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter/widgets.dart';
import 'package:forui/src/widgets/calendar/day/day_picker.dart';
import 'package:forui/src/widgets/calendar/shared/paged_picker.dart';

import 'package:meta/meta.dart';
import 'package:sugar/sugar.dart';

import 'package:forui/src/widgets/calendar/day/day_picker.dart';
import 'package:forui/src/widgets/calendar/shared/paged_picker.dart';

@internal
class PagedDayPicker extends PagedPicker {
final Predicate<LocalDate> selected;
Expand Down
8 changes: 5 additions & 3 deletions forui/lib/src/widgets/calendar/month/month_picker.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:forui/src/widgets/calendar/shared/entry.dart';
import 'package:forui/src/widgets/calendar/year_month_picker.dart';

import 'package:intl/intl.dart';
import 'package:meta/meta.dart';
import 'package:sugar/sugar.dart';

import 'package:forui/src/widgets/calendar/shared/entry.dart';
import 'package:forui/src/widgets/calendar/year_month_picker.dart';

// ignore: non_constant_identifier_names
final _MMM = DateFormat.MMM();

Expand All @@ -30,7 +32,7 @@ class MonthPicker extends StatefulWidget {
required this.focused,
required this.onPress,
super.key,
}): assert(currentYear == currentYear.truncate(to: DateUnit.years), 'currentYear must be truncated to years');
}) : assert(currentYear == currentYear.truncate(to: DateUnit.years), 'currentYear must be truncated to years');

@override
State<MonthPicker> createState() => _MonthPickerState();
Expand Down
32 changes: 17 additions & 15 deletions forui/lib/src/widgets/calendar/month/paged_month_picker.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:forui/src/widgets/calendar/month/month_picker.dart';
import 'package:forui/src/widgets/calendar/shared/paged_picker.dart';

import 'package:meta/meta.dart';
import 'package:sugar/sugar.dart';

import 'package:forui/src/widgets/calendar/month/month_picker.dart';
import 'package:forui/src/widgets/calendar/shared/paged_picker.dart';

@internal
class PagedMonthPicker extends PagedPicker {
final ValueChanged<LocalDate> onPress;
Expand Down Expand Up @@ -32,14 +34,14 @@ class PagedMonthPicker extends PagedPicker {
class _PagedMonthPickerState extends PagedPickerState<PagedMonthPicker> {
@override
Widget buildItem(BuildContext context, int page) => MonthPicker(
style: widget.style.yearMonthPickerStyle,
currentYear: widget.initial,
start: widget.start,
end: widget.end,
today: widget.today,
focused: focusedDate,
onPress: widget.onPress,
);
style: widget.style.yearMonthPickerStyle,
currentYear: widget.initial,
start: widget.start,
end: widget.end,
today: widget.today,
focused: focusedDate,
onPress: widget.onPress,
);

@override
void onPageChange(int page) {} // Months will only appear on a single page.
Expand Down Expand Up @@ -74,9 +76,9 @@ class _PagedMonthPickerState extends PagedPickerState<PagedMonthPicker> {

@override
Map<TraversalDirection, Period> get directionOffset => const {
TraversalDirection.up: Period(months: -MonthPicker.columns),
TraversalDirection.right: Period(months: 1),
TraversalDirection.down: Period(months: MonthPicker.columns),
TraversalDirection.left: Period(months: -1),
};
TraversalDirection.up: Period(months: -MonthPicker.columns),
TraversalDirection.right: Period(months: 1),
TraversalDirection.down: Period(months: MonthPicker.columns),
TraversalDirection.left: Period(months: -1),
};
}
7 changes: 4 additions & 3 deletions forui/lib/src/widgets/calendar/shared/entry.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:forui/src/foundation/inkwell.dart';
import 'package:forui/src/widgets/calendar/year_month_picker.dart';

import 'package:intl/intl.dart';
import 'package:meta/meta.dart';
import 'package:sugar/sugar.dart';

import 'package:forui/src/foundation/inkwell.dart';
import 'package:forui/src/widgets/calendar/day/day_picker.dart';
import 'package:forui/src/widgets/calendar/year_month_picker.dart';

final _yMMMMd = DateFormat.yMMMMd();

Expand Down Expand Up @@ -71,7 +72,7 @@ abstract class Entry extends StatelessWidget {
required String Function(LocalDate) format,
}) {
final entryStyle = enabled ? style.enabledStyle : style.disabledStyle;

// ignore: avoid_positional_boolean_parameters
Widget builder(BuildContext context, bool focused, Widget? child) => _Content(
style: entryStyle,
Expand Down
6 changes: 4 additions & 2 deletions forui/lib/src/widgets/calendar/shared/header.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:forui/forui.dart';
import 'package:forui/src/foundation/inkwell.dart';

import 'package:intl/intl.dart';
import 'package:meta/meta.dart';
import 'package:sugar/sugar.dart';

import 'package:forui/forui.dart';
import 'package:forui/src/foundation/inkwell.dart';

/// The current picker type.
enum FCalendarPickerType {
/// The day picker.
Expand Down
9 changes: 5 additions & 4 deletions forui/lib/src/widgets/calendar/shared/paged_picker.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:forui/src/widgets/calendar/calendar.dart';
import 'package:forui/src/widgets/calendar/shared/header.dart';

import 'package:meta/meta.dart';
import 'package:sugar/sugar.dart';

import 'package:forui/src/widgets/calendar/calendar.dart';
import 'package:forui/src/widgets/calendar/shared/header.dart';

@internal
abstract class PagedPicker extends StatefulWidget {
final FCalendarStyle style;
Expand All @@ -23,8 +25,7 @@ abstract class PagedPicker extends StatefulWidget {
required this.initial,
Predicate<LocalDate>? enabled,
super.key,
}):
enabled = ((date) => start <= date && date <= end && (enabled?.call(date) ?? true));
}) : enabled = ((date) => start <= date && date <= end && (enabled?.call(date) ?? true));

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
Expand Down
6 changes: 4 additions & 2 deletions forui/lib/src/widgets/calendar/year/paged_year_picker.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:forui/src/widgets/calendar/shared/paged_picker.dart';
import 'package:forui/src/widgets/calendar/year/year_picker.dart';

import 'package:meta/meta.dart';
import 'package:sugar/sugar.dart';

import 'package:forui/src/widgets/calendar/shared/paged_picker.dart';
import 'package:forui/src/widgets/calendar/year/year_picker.dart';

@internal
class PagedYearPicker extends PagedPicker {
final ValueChanged<LocalDate> onPress;
Expand Down
8 changes: 5 additions & 3 deletions forui/lib/src/widgets/calendar/year/year_picker.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:forui/src/widgets/calendar/shared/entry.dart';
import 'package:forui/src/widgets/calendar/year_month_picker.dart';

import 'package:meta/meta.dart';
import 'package:sugar/sugar.dart';

import 'package:forui/src/widgets/calendar/shared/entry.dart';
import 'package:forui/src/widgets/calendar/year_month_picker.dart';

@internal
class YearPicker extends StatefulWidget {
static const columns = 3;
Expand All @@ -28,7 +30,7 @@ class YearPicker extends StatefulWidget {
required this.focused,
required this.onPress,
super.key,
}): assert(startYear == startYear.truncate(to: DateUnit.years), 'startYear must be truncated to years.');
}) : assert(startYear == startYear.truncate(to: DateUnit.years), 'startYear must be truncated to years.');

@override
State<YearPicker> createState() => _YearPickerState();
Expand Down
Loading

0 comments on commit 32236df

Please sign in to comment.