Skip to content

Commit

Permalink
Improve document.
Browse files Browse the repository at this point in the history
  • Loading branch information
xpwmaosldk committed Sep 11, 2024
1 parent ef584ca commit 023f3a4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.1.2
- Improve document.

## 1.1.1
- Improve document.
- Add more customize options.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ The NumberPagination widget offers a wide range of customization options to tail
| `unSelectedTextColor` | `Color` | Text color for unselected page buttons | Colors.black |
| `selectedButtonColor` | `Color` | Background color of the selected page button | Colors.black |
| `unSelectedButtonColor` | `Color` | Background color of unselected page buttons | Colors.white |
| `controlButtonColor` | `Color` | Background color of control buttons | Colors.white |

## Icons

Expand Down
31 changes: 17 additions & 14 deletions lib/number_pagination.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class NumberPagination extends StatelessWidget {
this.unSelectedTextColor = Colors.black,
this.selectedButtonColor = Colors.black,
this.unSelectedButtonColor = Colors.white,
this.controlButtonColor = Colors.white,
});

/// Callback function triggered when the page changes.
Expand Down Expand Up @@ -100,24 +101,24 @@ class NumberPagination extends StatelessWidget {
/// The background color of unselected page buttons.
final Color unSelectedButtonColor;

/// The background color of control buttons.
final Color controlButtonColor;

@override
Widget build(BuildContext context) {
final pageService = NumberPageService(currentPage);

return Padding(
padding: const EdgeInsets.all(10.0),
child: NumberPageContainer(
pageService: pageService,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildNavigationButtons(pageService),
SizedBox(width: sectionSpacing),
_buildPageNumbers(pageService),
SizedBox(width: sectionSpacing),
_buildNavigationButtons(pageService, isForward: true),
],
),
return NumberPageContainer(
pageService: pageService,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildNavigationButtons(pageService),
SizedBox(width: sectionSpacing),
_buildPageNumbers(pageService),
SizedBox(width: sectionSpacing),
_buildNavigationButtons(pageService, isForward: true),
],
),
);
}
Expand All @@ -138,6 +139,7 @@ class NumberPagination extends StatelessWidget {
: pageService.currentPage != 1,
(c) => _changePage(c, isForward ? pageService.currentPage + 1 : 1),
controlButtonSize,
controlButtonColor,
),
SizedBox(width: navigationButtonSpacing),
ControlButton(
Expand All @@ -150,6 +152,7 @@ class NumberPagination extends StatelessWidget {
(c) => _changePage(
c, isForward ? totalPages : pageService.currentPage - 1),
controlButtonSize,
controlButtonColor,
),
],
),
Expand Down
11 changes: 8 additions & 3 deletions lib/src/control_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class ControlButton extends StatelessWidget {
this.icon,
this.enabled,
this.onTap,
this.minimumSize, {
this.fixedSize,
this.backgroundColor, {
super.key,
});

Expand All @@ -16,7 +17,8 @@ class ControlButton extends StatelessWidget {
final Widget icon;
final bool enabled;
final Function(BuildContext) onTap;
final Size minimumSize;
final Size fixedSize;
final Color backgroundColor;

@override
Widget build(BuildContext context) {
Expand All @@ -28,7 +30,10 @@ class ControlButton extends StatelessWidget {
),
surfaceTintColor: Colors.transparent,
padding: EdgeInsets.zero,
minimumSize: minimumSize,
fixedSize: fixedSize,
minimumSize: fixedSize,
disabledBackgroundColor: Colors.transparent,
backgroundColor: Colors.white,
),
onPressed: enabled ? () => onTap(context) : null,
child: icon,
Expand Down
7 changes: 4 additions & 3 deletions lib/src/number_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class NumberButton extends StatelessWidget {
this.fontSize,
this.fontFamily,
this.onSelect,
this.minimumSize,
this.fixedSize,
this.selectedTextColor,
this.unSelectedTextColor,
this.selectedButtonColor,
Expand All @@ -23,7 +23,7 @@ class NumberButton extends StatelessWidget {
final double fontSize;
final String fontFamily;
final Function(BuildContext, int) onSelect;
final Size minimumSize;
final Size fixedSize;
final Color selectedTextColor;
final Color unSelectedTextColor;
final Color selectedButtonColor;
Expand All @@ -43,7 +43,8 @@ class NumberButton extends StatelessWidget {
borderRadius: BorderRadius.circular(buttonRadius),
),
padding: EdgeInsets.zero,
minimumSize: minimumSize,
fixedSize: fixedSize,
minimumSize: fixedSize,
backgroundColor:
selected ? selectedButtonColor : unSelectedButtonColor,
),
Expand Down

0 comments on commit 023f3a4

Please sign in to comment.