From ce027e9f01eca830526cc2853ee840e79d21eb1f Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 11 Aug 2023 19:01:32 +0200 Subject: [PATCH 01/15] Implement prev/next button with custom content --- lib/src/ui/number_paginator.dart | 34 ++++++++++++++++--- .../buttons/paginator_icon_button.dart | 26 -------------- 2 files changed, 29 insertions(+), 31 deletions(-) delete mode 100644 lib/src/ui/widgets/buttons/paginator_icon_button.dart diff --git a/lib/src/ui/number_paginator.dart b/lib/src/ui/number_paginator.dart index 2a6140e..a3b5918 100644 --- a/lib/src/ui/number_paginator.dart +++ b/lib/src/ui/number_paginator.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:number_paginator/src/model/config.dart'; import 'package:number_paginator/src/model/display_mode.dart'; import 'package:number_paginator/src/ui/number_paginator_controller.dart'; -import 'package:number_paginator/src/ui/widgets/buttons/paginator_icon_button.dart'; +import 'package:number_paginator/src/ui/widgets/buttons/paginator_button.dart'; import 'package:number_paginator/src/ui/widgets/inherited_number_paginator.dart'; import 'package:number_paginator/src/ui/widgets/paginator_content.dart'; @@ -29,6 +29,28 @@ class NumberPaginator extends StatefulWidget { final NumberPaginatorController? controller; + /// Content of the "previous" button which is automatically displayed and goes + /// one page back. + /// + /// Defaults to: + /// ```dart + /// const FittedBox( + /// child: Icon(Icons.chevron_left), + /// ) + /// ``` + final Widget prevButtonContent; + + /// Content of the "next" button which is automatically displayed and goes + /// one page forward. + /// + /// Defaults to: + /// ```dart + /// const FittedBox( + /// child: Icon(Icons.chevron_right), + /// ) + /// ``` + final Widget nextButtonContent; + /// Creates an instance of [NumberPaginator]. const NumberPaginator({ Key? key, @@ -38,6 +60,8 @@ class NumberPaginator extends StatefulWidget { this.config = const NumberPaginatorUIConfig(), this.contentBuilder, this.controller, + this.prevButtonContent = const FittedBox(child: Icon(Icons.chevron_left)), + this.nextButtonContent = const FittedBox(child: Icon(Icons.chevron_right)), }) : assert(initialPage >= 0), assert(initialPage <= numberPages - 1), super(key: key); @@ -72,16 +96,16 @@ class NumberPaginatorState extends State { child: Row( mainAxisAlignment: widget.config.mainAxisAlignment, children: [ - PaginatorIconButton( + PaginatorButton( onPressed: _controller.currentPage > 0 ? _controller.prev : null, - icon: Icons.chevron_left, + child: widget.prevButtonContent, ), ..._buildCenterContent(), - PaginatorIconButton( + PaginatorButton( onPressed: _controller.currentPage < widget.numberPages - 1 ? _controller.next : null, - icon: Icons.chevron_right, + child: widget.nextButtonContent, ), ], ), diff --git a/lib/src/ui/widgets/buttons/paginator_icon_button.dart b/lib/src/ui/widgets/buttons/paginator_icon_button.dart deleted file mode 100644 index 8dbc9a8..0000000 --- a/lib/src/ui/widgets/buttons/paginator_icon_button.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:number_paginator/src/ui/widgets/buttons/paginator_button.dart'; - -/// A paginator button that has an [Icon] as a child, instead of text. The icon -/// scales with the available space, depending on the size of the button. -class PaginatorIconButton extends StatelessWidget { - final IconData icon; - final VoidCallback? onPressed; - - const PaginatorIconButton({ - Key? key, - required this.icon, - this.onPressed, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return PaginatorButton( - onPressed: onPressed, - // size icon depending on available height - child: FittedBox( - child: Icon(icon), - ), - ); - } -} From f169fce8df77205a03830c7587828ba03ed18cfa Mon Sep 17 00:00:00 2001 From: Felix Date: Sun, 24 Sep 2023 17:30:20 +0200 Subject: [PATCH 02/15] Add options for show + builders for prev/next button --- lib/src/ui/number_paginator.dart | 53 ++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/lib/src/ui/number_paginator.dart b/lib/src/ui/number_paginator.dart index a3b5918..707207c 100644 --- a/lib/src/ui/number_paginator.dart +++ b/lib/src/ui/number_paginator.dart @@ -29,6 +29,16 @@ class NumberPaginator extends StatefulWidget { final NumberPaginatorController? controller; + /// Whether the "prev" button should be shown. + /// + /// Defaults to `true`. + final bool showPrevButton; + + /// Whether the "next" button should be shown. + /// + /// Defaults to `true`. + final showNextButton; + /// Content of the "previous" button which is automatically displayed and goes /// one page back. /// @@ -51,6 +61,18 @@ class NumberPaginator extends StatefulWidget { /// ``` final Widget nextButtonContent; + /// Builder option for providing a custom "previous" button. + /// + /// If this is provided, [prevButtonContent] is ignored. + /// If [showPrevButton] is `false`, this is ignored. + final WidgetBuilder? prevButtonBuilder; + + /// Builder option for providing a custom "next" button. + /// + /// If this is provided, [nextButtonContent] is ignored. + /// If [showNextButton] is `false`, this is ignored. + final WidgetBuilder? nextButtonBuilder; + /// Creates an instance of [NumberPaginator]. const NumberPaginator({ Key? key, @@ -60,8 +82,12 @@ class NumberPaginator extends StatefulWidget { this.config = const NumberPaginatorUIConfig(), this.contentBuilder, this.controller, - this.prevButtonContent = const FittedBox(child: Icon(Icons.chevron_left)), - this.nextButtonContent = const FittedBox(child: Icon(Icons.chevron_right)), + this.showPrevButton = true, + this.showNextButton = true, + this.prevButtonContent = const Icon(Icons.chevron_left), + this.nextButtonContent = const Icon(Icons.chevron_right), + this.prevButtonBuilder, + this.nextButtonBuilder, }) : assert(initialPage >= 0), assert(initialPage <= numberPages - 1), super(key: key); @@ -96,17 +122,20 @@ class NumberPaginatorState extends State { child: Row( mainAxisAlignment: widget.config.mainAxisAlignment, children: [ - PaginatorButton( - onPressed: _controller.currentPage > 0 ? _controller.prev : null, - child: widget.prevButtonContent, - ), + if (widget.showPrevButton) + widget.prevButtonBuilder?.call(context) ?? + PaginatorButton( + onPressed: _controller.currentPage > 0 ? _controller.prev : null, + child: widget.prevButtonContent, + ), ..._buildCenterContent(), - PaginatorButton( - onPressed: _controller.currentPage < widget.numberPages - 1 - ? _controller.next - : null, - child: widget.nextButtonContent, - ), + if (widget.showNextButton) + widget.nextButtonBuilder?.call(context) ?? + PaginatorButton( + onPressed: + _controller.currentPage < widget.numberPages - 1 ? _controller.next : null, + child: widget.nextButtonContent, + ), ], ), ), From 2731373efe15960e73d5a5396a4d88dc5c8b4019 Mon Sep 17 00:00:00 2001 From: Felix Date: Sun, 24 Sep 2023 17:34:19 +0200 Subject: [PATCH 03/15] Add constructor for no prev/next buttons --- lib/src/ui/number_paginator.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/src/ui/number_paginator.dart b/lib/src/ui/number_paginator.dart index 707207c..df2d0fc 100644 --- a/lib/src/ui/number_paginator.dart +++ b/lib/src/ui/number_paginator.dart @@ -92,6 +92,24 @@ class NumberPaginator extends StatefulWidget { assert(initialPage <= numberPages - 1), super(key: key); + const NumberPaginator.noPrevNextButtons({ + Key? key, + required this.numberPages, + this.initialPage = 0, + this.onPageChange, + this.config = const NumberPaginatorUIConfig(), + this.contentBuilder, + this.controller, + }) : showPrevButton = false, + showNextButton = false, + prevButtonContent = const SizedBox(), + nextButtonContent = const SizedBox(), + prevButtonBuilder = null, + nextButtonBuilder = null, + assert(initialPage >= 0), + assert(initialPage <= numberPages - 1), + super(key: key); + @override NumberPaginatorState createState() => NumberPaginatorState(); } From 8f802eab1902036aa9fe2bebbeeeac525fbe3e38 Mon Sep 17 00:00:00 2001 From: Felix Date: Sun, 24 Sep 2023 22:48:38 +0200 Subject: [PATCH 04/15] Upgrade pubspec.locks --- example/pubspec.lock | 38 +++++++++++++++++++------------------- pubspec.lock | 42 +++++++++++++++++++++--------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 4db71f9..3ec68fe 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.17.2" fake_async: dependency: transitive description: @@ -75,14 +75,6 @@ packages: description: flutter source: sdk version: "0.0.0" - js: - dependency: transitive - description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" - source: hosted - version: "0.6.7" lints: dependency: transitive description: @@ -95,18 +87,18 @@ packages: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.5.0" meta: dependency: transitive description: @@ -139,10 +131,10 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: @@ -179,10 +171,10 @@ packages: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.6.0" vector_math: dependency: transitive description: @@ -191,6 +183,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" sdks: - dart: ">=3.0.0-0 <4.0.0" + dart: ">=3.1.0-185.0.dev <4.0.0" flutter: ">=1.17.0" diff --git a/pubspec.lock b/pubspec.lock index 373dd73..9f9c74a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.17.2" fake_async: dependency: transitive description: @@ -66,23 +66,15 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.0.3" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" - js: - dependency: transitive - description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" - source: hosted - version: "0.6.7" lints: dependency: transitive description: @@ -95,18 +87,18 @@ packages: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.5.0" meta: dependency: transitive description: @@ -132,10 +124,10 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: @@ -172,10 +164,10 @@ packages: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.6.0" vector_math: dependency: transitive description: @@ -184,6 +176,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" sdks: - dart: ">=3.0.0 <4.0.0" + dart: ">=3.1.0-185.0.dev <4.0.0" flutter: ">=1.17.0" From 5e5589f5c4f828f8eae0a9ca0107985ebd92a5be Mon Sep 17 00:00:00 2001 From: Felix Date: Tue, 26 Sep 2023 18:49:27 +0200 Subject: [PATCH 05/15] Docs + type fix --- lib/src/ui/number_paginator.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/ui/number_paginator.dart b/lib/src/ui/number_paginator.dart index df2d0fc..e1f4cb6 100644 --- a/lib/src/ui/number_paginator.dart +++ b/lib/src/ui/number_paginator.dart @@ -27,6 +27,8 @@ class NumberPaginator extends StatefulWidget { /// [config] is ignored. final NumberPaginatorContentBuilder? contentBuilder; + /// The controller for the paginator. Can be used to control the paginator from the outside. + /// If not provided, a new controller is created. final NumberPaginatorController? controller; /// Whether the "prev" button should be shown. @@ -37,7 +39,7 @@ class NumberPaginator extends StatefulWidget { /// Whether the "next" button should be shown. /// /// Defaults to `true`. - final showNextButton; + final bool showNextButton; /// Content of the "previous" button which is automatically displayed and goes /// one page back. From 8d6703e8fec4a55d6763cad5cf2019ee620619ca Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 29 Sep 2023 22:04:32 +0200 Subject: [PATCH 06/15] Small fix in NumberContent --- .../paginator_content/number_content.dart | 38 +++++++------------ 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/lib/src/ui/widgets/paginator_content/number_content.dart b/lib/src/ui/widgets/paginator_content/number_content.dart index 5cceec0..387a8b9 100644 --- a/lib/src/ui/widgets/paginator_content/number_content.dart +++ b/lib/src/ui/widgets/paginator_content/number_content.dart @@ -26,15 +26,12 @@ class NumberContent extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ _buildPageButton(context, 0), - if (_frontDotsShouldShow(context, availableSpots)) - _buildDots(context), + if (_frontDotsShouldShow(context, availableSpots)) _buildDots(context), if (InheritedNumberPaginator.of(context).numberPages > 1) ..._generateButtonList(context, availableSpots), - if (_backDotsShouldShow(context, availableSpots)) - _buildDots(context), + if (_backDotsShouldShow(context, availableSpots)) _buildDots(context), if (InheritedNumberPaginator.of(context).numberPages > 1) - _buildPageButton(context, - InheritedNumberPaginator.of(context).numberPages - 1), + _buildPageButton(context, InheritedNumberPaginator.of(context).numberPages - 1), ], ); }, @@ -59,38 +56,31 @@ class NumberContent extends StatelessWidget { minValue = (maxValue - shownPages).clamp(1, numberPages - 1); } - return List.generate(maxValue - minValue, - (index) => _buildPageButton(context, minValue + index)); + return List.generate( + maxValue - minValue, (index) => _buildPageButton(context, minValue + index)); } /// Builds a button for the given index. Widget _buildPageButton(BuildContext context, int index) => PaginatorButton( - onPressed: () => - InheritedNumberPaginator.of(context).onPageChange?.call(index), + onPressed: () => InheritedNumberPaginator.of(context).onPageChange?.call(index), selected: _selected(index), - child: - AutoSizeText((index + 1).toString(), maxLines: 1, minFontSize: 5), + child: AutoSizeText((index + 1).toString(), maxLines: 1, minFontSize: 5), ); Widget _buildDots(BuildContext context) => AspectRatio( aspectRatio: 1, child: Container( - // padding: const EdgeInsets.all(4.0), - margin: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(4.0), + margin: const EdgeInsets.all(4.0), alignment: Alignment.bottomCenter, decoration: ShapeDecoration( - shape: InheritedNumberPaginator.of(context).config.buttonShape ?? - const CircleBorder(), - color: InheritedNumberPaginator.of(context) - .config - .buttonUnselectedBackgroundColor, + shape: InheritedNumberPaginator.of(context).config.buttonShape ?? const CircleBorder(), + color: InheritedNumberPaginator.of(context).config.buttonUnselectedBackgroundColor, ), child: AutoSizeText( "...", style: TextStyle( - color: InheritedNumberPaginator.of(context) - .config - .buttonUnselectedForegroundColor ?? + color: InheritedNumberPaginator.of(context).config.buttonUnselectedForegroundColor ?? Theme.of(context).colorScheme.secondary, fontSize: 16, fontWeight: FontWeight.bold, @@ -102,9 +92,7 @@ class NumberContent extends StatelessWidget { /// Checks if pages don't fit in available spots and dots have to be shown. bool _backDotsShouldShow(BuildContext context, int availableSpots) => availableSpots < InheritedNumberPaginator.of(context).numberPages && - currentPage < - InheritedNumberPaginator.of(context).numberPages - - availableSpots ~/ 2; + currentPage < InheritedNumberPaginator.of(context).numberPages - availableSpots ~/ 2; bool _frontDotsShouldShow(BuildContext context, int availableSpots) => availableSpots < InheritedNumberPaginator.of(context).numberPages && From 62470a01fbbb2abacc69942e22f106aad923e7da Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 29 Sep 2023 22:04:48 +0200 Subject: [PATCH 07/15] iOS upgrades --- example/ios/Runner.xcodeproj/project.pbxproj | 2 +- .../ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 59260ed..6b8f839 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -127,7 +127,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 3db53b6..b52b2e6 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ Date: Fri, 29 Sep 2023 22:17:29 +0200 Subject: [PATCH 08/15] Add new features to readme customization examples --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index d98541f..2825c5a 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,19 @@ NumberPaginator( buttonUnselectedBackgroundColor: Colors.grey, buttonSelectedBackgroundColor: Colors.blueGrey, ), + // show/hide the prev/next buttons + showPrevButton: false, // defaults to true + showNextButton: false, // defaults to true + // custom prev/next buttons using builder + prevButtonBuilder: (context) => TextButton( + onPressed: _controller.currentPage > 0 ? () => _controller.prev() : null, // _controller must be passed to NumberPaginator + child: const Row( + children: [ + Icon(Icons.chevron_left), + Text("Previous"), + ], + ), + ), ) ```

From 73519f72b43b10c979794d35f6354e6a6b435320 Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 29 Sep 2023 22:24:27 +0200 Subject: [PATCH 09/15] Separate readme section for new features --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index 2825c5a..e582e81 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ floatingActionButton: FloatingActionButton( ### Customize `NumberPaginator` allows for several customizations. + +#### Button look and feel ```dart NumberPaginator( // by default, the paginator shows numbers as center content @@ -98,6 +100,35 @@ NumberPaginator( custom buttons

+#### Visibility/customisation of prev/next buttons +```dart +NumberPaginator( + // by default, the paginator shows numbers as center content + numberPages: 10, + onPageChange: (int index) { + setState(() { + _currentPage = index; // _currentPage is a variable within State of StatefulWidget + }); + }, + // show/hide the prev/next buttons + showPrevButton: true, + showNextButton: false, // defaults to true + // custom prev/next buttons using builder (ignored if showPrevButton/showNextButton is false) + prevButtonBuilder: (context) => TextButton( + onPressed: _controller.currentPage > 0 ? () => _controller.prev() : null, // _controller must be passed to NumberPaginator + child: const Row( + children: [ + Icon(Icons.chevron_left), + Text("Previous"), + ], + ), + ), +) +``` +

+ custom buttons +

+ ### Content variations The new version of `NumberPaginator` allows for further customization of how a user can navigate between pages. It provides three different modes and an additional possibility of complete customization o the content using a `builder`. From 93d899a6ec6271ef4f025db18402cebe2d0cae9b Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 29 Sep 2023 22:26:33 +0200 Subject: [PATCH 10/15] Add new screenshot to readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e582e81..1ef89f6 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ NumberPaginator( ) ```

- custom buttons + prev/next button customisation

### Content variations From 35939978672eb870d487edab42e91b9b64e77cfd Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 29 Sep 2023 22:28:48 +0200 Subject: [PATCH 11/15] Version bump to 0.4.0 --- CHANGELOG.md | 5 +++++ pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d96eba..632d43f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [0.4.0] - 29.09.2023 + +- New properties `showNextButton` and `showPrevButton` for showing/hiding the next/prev buttons +- New way to customize prev/next buttons using `prevButtonBuilder` or `nextButtonBuilder` + ## [0.3.2] - 30.07.2023 - Correct images in README.md diff --git a/pubspec.yaml b/pubspec.yaml index 31aac87..3f0f193 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: number_paginator description: A Flutter paginator widget for switching between page numbers. -version: 0.3.2 +version: 0.4.0 homepage: https://github.com/WieFel/number_paginator environment: From d411634f4fd6dc97eb6b038a902a96258f76cda8 Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 29 Sep 2023 22:30:27 +0200 Subject: [PATCH 12/15] Remove obsolete code part from readme --- README.md | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/README.md b/README.md index 1ef89f6..5f10b11 100644 --- a/README.md +++ b/README.md @@ -81,19 +81,6 @@ NumberPaginator( buttonUnselectedBackgroundColor: Colors.grey, buttonSelectedBackgroundColor: Colors.blueGrey, ), - // show/hide the prev/next buttons - showPrevButton: false, // defaults to true - showNextButton: false, // defaults to true - // custom prev/next buttons using builder - prevButtonBuilder: (context) => TextButton( - onPressed: _controller.currentPage > 0 ? () => _controller.prev() : null, // _controller must be passed to NumberPaginator - child: const Row( - children: [ - Icon(Icons.chevron_left), - Text("Previous"), - ], - ), - ), ) ```

From 65244fcdcc8d2fb05421add2f009bb7a9b2e4039 Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 29 Sep 2023 22:33:00 +0200 Subject: [PATCH 13/15] Docs correction --- lib/src/ui/number_paginator.dart | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/src/ui/number_paginator.dart b/lib/src/ui/number_paginator.dart index e1f4cb6..b4de1bb 100644 --- a/lib/src/ui/number_paginator.dart +++ b/lib/src/ui/number_paginator.dart @@ -41,25 +41,19 @@ class NumberPaginator extends StatefulWidget { /// Defaults to `true`. final bool showNextButton; - /// Content of the "previous" button which is automatically displayed and goes - /// one page back. + /// Content of the "previous" button which when pressed goes one page back. /// /// Defaults to: /// ```dart - /// const FittedBox( - /// child: Icon(Icons.chevron_left), - /// ) + /// Icon(Icons.chevron_left), /// ``` final Widget prevButtonContent; - /// Content of the "next" button which is automatically displayed and goes - /// one page forward. + /// Content of the "next" button which when pressed goes one page forward. /// /// Defaults to: /// ```dart - /// const FittedBox( - /// child: Icon(Icons.chevron_right), - /// ) + /// Icon(Icons.chevron_right), /// ``` final Widget nextButtonContent; From c582cbc2e7b0f8cdf78119a0a65adbbcb8ee31eb Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 29 Sep 2023 22:35:44 +0200 Subject: [PATCH 14/15] Add additional example to new customisations in readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5f10b11..1ab9ca4 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,8 @@ NumberPaginator( // show/hide the prev/next buttons showPrevButton: true, showNextButton: false, // defaults to true + // custom content of the prev/next buttons, maintains their behavior + nextButtonContent: Icon(Icons.arrow_right_alt), // custom prev/next buttons using builder (ignored if showPrevButton/showNextButton is false) prevButtonBuilder: (context) => TextButton( onPressed: _controller.currentPage > 0 ? () => _controller.prev() : null, // _controller must be passed to NumberPaginator From ee310363bdf3c69d33e85f5be7f3a09221ef40c3 Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 29 Sep 2023 22:37:26 +0200 Subject: [PATCH 15/15] Changelog update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 632d43f..5d6406d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - New properties `showNextButton` and `showPrevButton` for showing/hiding the next/prev buttons - New way to customize prev/next buttons using `prevButtonBuilder` or `nextButtonBuilder` +- Slight adaptation of margin/padding of "three dots" (only noticeable if it's background is colored) ## [0.3.2] - 30.07.2023