Skip to content

Commit

Permalink
improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Macacoazul01 committed Mar 12, 2024
1 parent 6946ac1 commit 81e3721
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/month_picker_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Gianluca & Lorenzo. All rights reserved.
// Copyright 2024 Gianluca & Lorenzo. All rights reserved.
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

Expand Down
5 changes: 5 additions & 0 deletions lib/src/month_picker_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import '/month_picker_dialog.dart';

///The main dialog widget class.
///It needs a `MonthpickerController` controller to be created.
class MonthPickerDialog extends StatefulWidget {
const MonthPickerDialog({required this.controller});
final MonthpickerController controller;
Expand Down Expand Up @@ -121,6 +123,7 @@ class MonthPickerDialogState extends State<MonthPickerDialog> {
);
}

///Function to change the grid to the year selector.
void _onSelectYear() => setState(
() => _selector = YearSelector(
key: widget.controller.yearSelectorState,
Expand All @@ -129,6 +132,7 @@ class MonthPickerDialogState extends State<MonthPickerDialog> {
),
);

///Function to be executed when a year is selected.
void _onYearSelected(final int year) {
setState(
() {
Expand All @@ -142,6 +146,7 @@ class MonthPickerDialogState extends State<MonthPickerDialog> {
);
}

///Function to be executed when a month is selected.
void _onMonthSelected(final DateTime date) => setState(
() {
widget.controller.selectedDate = date;
Expand Down
1 change: 1 addition & 0 deletions lib/src/month_picker_widgets/button_bar.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import '/month_picker_dialog.dart';

///The actions button bar. Where confirmation and cancel button are.
class PickerButtonBar extends StatelessWidget {
const PickerButtonBar({
super.key,
Expand Down
1 change: 1 addition & 0 deletions lib/src/month_picker_widgets/header/header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';

import '/month_picker_dialog.dart';

///The widget that will hold all of the Header widgets.
class PickerHeader extends StatelessWidget {
const PickerHeader({
super.key,
Expand Down
1 change: 1 addition & 0 deletions lib/src/month_picker_widgets/header/header_arrows.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';

///The arrows that are used on the header to change between the pages of the grid.
class HeaderArrows extends StatelessWidget {
const HeaderArrows({
super.key,
Expand Down
1 change: 1 addition & 0 deletions lib/src/month_picker_widgets/header/header_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import '/month_picker_dialog.dart';

///The main part of the header. Where arrows and current interval are presented.
class HeaderRow extends StatelessWidget {
const HeaderRow({
super.key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '/month_picker_dialog.dart';

///The widget that presents the current selected date on the header.
class HeaderSelectedDate extends StatelessWidget {
const HeaderSelectedDate({
super.key,
Expand Down
1 change: 1 addition & 0 deletions lib/src/month_picker_widgets/pager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class PickerPager extends StatelessWidget {
final Widget selector;
final ThemeData theme;
final MonthpickerController controller;

@override
Widget build(BuildContext context) {
return SizedBox(
Expand Down
1 change: 1 addition & 0 deletions lib/src/month_selector/month_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '/month_picker_dialog.dart';

///The button to be used on the grid of months.
class MonthButton extends StatelessWidget {
const MonthButton({
super.key,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/month_selector/month_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:provider/provider.dart';

import '/month_picker_dialog.dart';

///The widget that will hold the month grid selector.
class MonthSelector extends StatefulWidget {
const MonthSelector({
super.key,
Expand Down Expand Up @@ -36,6 +37,7 @@ class MonthSelectorState extends State<MonthSelector> {
);
}

///Function to check if the page has reached the limit of the month list.
void _onPageChange(final int page) {
_blocked =
!(page - 1 > 0 && page + 1 < widget.controller.monthPageCount - 1);
Expand All @@ -56,6 +58,7 @@ class MonthSelectorState extends State<MonthSelector> {
initialize();
}

///Function to go to the next page of the grid.
void goDown() {
widget.controller.monthPageController?.animateToPage(
widget.controller.monthPageController!.page!.toInt() + 1,
Expand All @@ -64,6 +67,7 @@ class MonthSelectorState extends State<MonthSelector> {
);
}

///Function to go to the previous page of the grid.
void goUp() {
widget.controller.monthPageController?.animateToPage(
widget.controller.monthPageController!.page!.toInt() - 1,
Expand All @@ -72,6 +76,7 @@ class MonthSelectorState extends State<MonthSelector> {
);
}

///Function to initialize the grid.
void initialize() {
widget.controller.monthPageController = PageController(
initialPage: widget.controller.localFirstDate == null
Expand Down
1 change: 1 addition & 0 deletions lib/src/month_selector/month_year_grid.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import '/month_picker_dialog.dart';

///The month grid. It has all of the avaliable options to be selected.
class MonthYearGridBuilder extends StatelessWidget {
const MonthYearGridBuilder({
super.key,
Expand Down
1 change: 1 addition & 0 deletions lib/src/year_selector/year_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '/month_picker_dialog.dart';

///The button to be used on the grid of years.
class YearButton extends StatelessWidget {
const YearButton({
super.key,
Expand Down
1 change: 1 addition & 0 deletions lib/src/year_selector/year_grid.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import '/month_picker_dialog.dart';

///The year grid. It has all of the avaliable options to be selected.
class YearGrid extends StatelessWidget {
const YearGrid({
super.key,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/year_selector/year_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:provider/provider.dart';

import '/month_picker_dialog.dart';

///The widget that will hold the year grid selector.
class YearSelector extends StatefulWidget {
const YearSelector({
super.key,
Expand Down Expand Up @@ -36,6 +37,7 @@ class YearSelectorState extends State<YearSelector> {
);
}

///Function to check if the page has reached the limit of the year list.
void _onPageChange(final int page) {
_blocked =
!(page - 1 > 0 && page + 1 < widget.controller.yearPageCount - 1);
Expand All @@ -57,6 +59,7 @@ class YearSelectorState extends State<YearSelector> {
initialize();
}

///Function to go to the next page of the grid.
void goDown() {
widget.controller.yearPageController?.animateToPage(
widget.controller.yearPageController!.page!.toInt() + 1,
Expand All @@ -65,6 +68,7 @@ class YearSelectorState extends State<YearSelector> {
);
}

///Function to go to the previous page of the grid.
void goUp() {
widget.controller.yearPageController?.animateToPage(
widget.controller.yearPageController!.page!.toInt() - 1,
Expand All @@ -73,6 +77,7 @@ class YearSelectorState extends State<YearSelector> {
);
}

///Function to initialize the grid.
void initialize() {
widget.controller.yearPageController = PageController(
initialPage: widget.controller.localFirstDate == null
Expand Down

0 comments on commit 81e3721

Please sign in to comment.