Skip to content

Commit

Permalink
Merge pull request #20 from t-unit/main
Browse files Browse the repository at this point in the history
Allow specifying button padding and text style
  • Loading branch information
WieFel committed Jan 30, 2024
2 parents 1266d91 + f1e83c3 commit 32c6393
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions lib/src/model/config.dart
Expand Up @@ -44,6 +44,16 @@ 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;

/// The [Padding] that should be used for the [PaginatorButton]'s content.
final EdgeInsetsGeometry? buttonPadding;

const NumberPaginatorUIConfig({
this.height = 48.0,
this.buttonShape,
Expand All @@ -54,5 +64,7 @@ class NumberPaginatorUIConfig {
this.mode = ContentDisplayMode.numbers,
this.mainAxisAlignment = MainAxisAlignment.start,
this.contentPadding,
this.buttonTextStyle,
this.buttonPadding,
});
}
6 changes: 4 additions & 2 deletions lib/src/ui/widgets/buttons/paginator_button.dart
Expand Up @@ -21,17 +21,19 @@ class PaginatorButton extends StatelessWidget {

@override
Widget build(BuildContext context) {
final config = InheritedNumberPaginator.of(context).config;
return AspectRatio(
aspectRatio: 1,
child: Padding(
padding: const EdgeInsets.all(4.0),
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,
padding: config.buttonPadding,
),
child: child,
),
Expand Down

0 comments on commit 32c6393

Please sign in to comment.