From eb769c1e41c5dbe4c4e89d846946a886913ecc17 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Wed, 6 Dec 2023 16:45:37 +0100 Subject: [PATCH 1/2] Allow specifying button text style via config. --- lib/src/model/config.dart | 8 ++++++++ lib/src/ui/widgets/buttons/paginator_button.dart | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/src/model/config.dart b/lib/src/model/config.dart index 2606952..f178fa6 100644 --- a/lib/src/model/config.dart +++ b/lib/src/model/config.dart @@ -44,6 +44,13 @@ class NumberPaginatorUIConfig { /// content. final EdgeInsets? contentPadding; + /// The [TextStyle] that should be used for the [PaginatorButton]'s text. + /// This property only takes effect if [mode] is set to + /// [ContentDisplayMode.numbers]. + /// The color of the text is determined by [buttonSelectedForegroundColor] and + /// [buttonUnselectedForegroundColor]. + final TextStyle? buttonTextStyle; + const NumberPaginatorUIConfig({ this.height = 48.0, this.buttonShape, @@ -54,5 +61,6 @@ class NumberPaginatorUIConfig { this.mode = ContentDisplayMode.numbers, this.mainAxisAlignment = MainAxisAlignment.start, this.contentPadding, + this.buttonTextStyle, }); } diff --git a/lib/src/ui/widgets/buttons/paginator_button.dart b/lib/src/ui/widgets/buttons/paginator_button.dart index f6f6cbd..81de81c 100644 --- a/lib/src/ui/widgets/buttons/paginator_button.dart +++ b/lib/src/ui/widgets/buttons/paginator_button.dart @@ -21,6 +21,7 @@ class PaginatorButton extends StatelessWidget { @override Widget build(BuildContext context) { + final config = InheritedNumberPaginator.of(context).config; return AspectRatio( aspectRatio: 1, child: Padding( @@ -28,10 +29,10 @@ class PaginatorButton extends StatelessWidget { child: TextButton( onPressed: onPressed, style: TextButton.styleFrom( - shape: InheritedNumberPaginator.of(context).config.buttonShape ?? - const CircleBorder(), + shape: config.buttonShape ?? const CircleBorder(), backgroundColor: _backgroundColor(context, selected), foregroundColor: _foregroundColor(context, selected), + textStyle: config.buttonTextStyle, ), child: child, ), From f1e83c3e754727c71b5b1a131b324d1c9008f7d4 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Thu, 7 Dec 2023 09:16:11 +0100 Subject: [PATCH 2/2] Allow specifying button padding --- lib/src/model/config.dart | 4 ++++ lib/src/ui/widgets/buttons/paginator_button.dart | 1 + 2 files changed, 5 insertions(+) diff --git a/lib/src/model/config.dart b/lib/src/model/config.dart index f178fa6..084906c 100644 --- a/lib/src/model/config.dart +++ b/lib/src/model/config.dart @@ -51,6 +51,9 @@ class NumberPaginatorUIConfig { /// [buttonUnselectedForegroundColor]. final TextStyle? buttonTextStyle; + /// The [Padding] that should be used for the [PaginatorButton]'s content. + final EdgeInsetsGeometry? buttonPadding; + const NumberPaginatorUIConfig({ this.height = 48.0, this.buttonShape, @@ -62,5 +65,6 @@ class NumberPaginatorUIConfig { this.mainAxisAlignment = MainAxisAlignment.start, this.contentPadding, this.buttonTextStyle, + this.buttonPadding, }); } diff --git a/lib/src/ui/widgets/buttons/paginator_button.dart b/lib/src/ui/widgets/buttons/paginator_button.dart index 81de81c..b045402 100644 --- a/lib/src/ui/widgets/buttons/paginator_button.dart +++ b/lib/src/ui/widgets/buttons/paginator_button.dart @@ -33,6 +33,7 @@ class PaginatorButton extends StatelessWidget { backgroundColor: _backgroundColor(context, selected), foregroundColor: _foregroundColor(context, selected), textStyle: config.buttonTextStyle, + padding: config.buttonPadding, ), child: child, ),