From 023f3a45db49dd14cf8cdbf5d3c6081612aa4ac7 Mon Sep 17 00:00:00 2001 From: Jeho Date: Wed, 11 Sep 2024 14:57:31 +0900 Subject: [PATCH] Improve document. --- CHANGELOG.md | 3 +++ README.md | 1 + lib/number_pagination.dart | 31 +++++++++++++++++-------------- lib/src/control_button.dart | 11 ++++++++--- lib/src/number_button.dart | 7 ++++--- 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8be910e..b9df287 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.1.2 +- Improve document. + ## 1.1.1 - Improve document. - Add more customize options. diff --git a/README.md b/README.md index e77e624..77cbf21 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/number_pagination.dart b/lib/number_pagination.dart index 3ae33ae..a375f3c 100644 --- a/lib/number_pagination.dart +++ b/lib/number_pagination.dart @@ -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. @@ -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), + ], ), ); } @@ -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( @@ -150,6 +152,7 @@ class NumberPagination extends StatelessWidget { (c) => _changePage( c, isForward ? totalPages : pageService.currentPage - 1), controlButtonSize, + controlButtonColor, ), ], ), diff --git a/lib/src/control_button.dart b/lib/src/control_button.dart index 56bb049..42f84ba 100644 --- a/lib/src/control_button.dart +++ b/lib/src/control_button.dart @@ -7,7 +7,8 @@ class ControlButton extends StatelessWidget { this.icon, this.enabled, this.onTap, - this.minimumSize, { + this.fixedSize, + this.backgroundColor, { super.key, }); @@ -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) { @@ -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, diff --git a/lib/src/number_button.dart b/lib/src/number_button.dart index b43d177..6c628e3 100644 --- a/lib/src/number_button.dart +++ b/lib/src/number_button.dart @@ -9,7 +9,7 @@ class NumberButton extends StatelessWidget { this.fontSize, this.fontFamily, this.onSelect, - this.minimumSize, + this.fixedSize, this.selectedTextColor, this.unSelectedTextColor, this.selectedButtonColor, @@ -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; @@ -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, ),