Skip to content

Commit

Permalink
Merge pull request #6 from xpwmaosldk/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
xpwmaosldk authored May 3, 2024
2 parents a0606cf + 25dd805 commit dda8a59
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 126 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ build/
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3

**/coverage/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.6
- Update minimum supported SDK version (>=3.0.0)
- Improve code (partial update applied)

## 1.0.5
- Add new property: buttonSpacing, groupSpacing.

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
![preview](https://github.com/xpwmaosldk/number_pagination/assets/13146337/aed48430-96de-43ec-8864-dc75cae9a197)

# number_pagination ![flutter test](https://github.com/xpwmaosldk/number_pagination/actions/workflows/flutter_test.yml/badge.svg)
Implementing Flutter Number Pagination using a Popular Web Approach
Implementing Flutter Number Pagination using a Popular Web Approach.

This package is very simple. Without depending on other packages, the code is less than 200 lines. Its usage is also simple and easy.
This package is very simple. Without depending on other packages.

Its usage is also simple and easy.

[See document](https://pub.dev/documentation/number_pagination/latest/number_pagination/NumberPagination-class.html)

Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class _MyHomePageState extends State<MyHomePage> {
),
NumberPagination(
onPageChanged: (int pageNumber) {
//do somthing for selected page
//To optimize further, use a package that supports partial updates instead of setState (e.g. riverpod)
setState(() {
selectedPageNumber = pageNumber;
});
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.3"
version: "1.0.5"
path:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=3.0.0 <4.0.0"

dependencies:
flutter:
Expand Down
42 changes: 42 additions & 0 deletions lib/control_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';

class ControlButton extends StatelessWidget {
const ControlButton(
this.buttonElevation,
this.buttonRadius,
this.colorPrimary,
this.colorSub,
this.icon,
this.enabled,
this.onTap,
);

final double buttonElevation;
final double buttonRadius;
final Color colorPrimary;
final Color colorSub;
final Widget icon;
final bool enabled;
final Function(BuildContext) onTap;

@override
Widget build(BuildContext context) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: buttonElevation,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(buttonRadius),
),
surfaceTintColor: Colors.transparent,
padding: EdgeInsets.zero,
minimumSize: Size(48, 48),
foregroundColor: enabled ? colorPrimary : Colors.grey,
backgroundColor: colorSub,
disabledForegroundColor: colorPrimary,
disabledBackgroundColor: colorSub,
),
onPressed: enabled ? () => onTap(context) : null,
child: icon,
);
}
}
68 changes: 68 additions & 0 deletions lib/number_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import 'package:flutter/material.dart';
import 'number_pagination.dart';

class NumberButton extends StatelessWidget {
const NumberButton(
this.number,
this.buttonElevation,
this.buttonRadius,
this.colorPrimary,
this.colorSub,
this.fontSize,
this.fontFamily,
this.onSelect,
);

final int number;
final double buttonElevation;
final double buttonRadius;
final Color colorPrimary;
final Color colorSub;
final double fontSize;
final String fontFamily;
final Function(BuildContext, int) onSelect;

@override
Widget build(BuildContext context) {
return Flexible(
child: Padding(
padding: const EdgeInsets.all(1.5),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shadowColor: number == NumberPageContainer.of(context).currentPage
? colorPrimary
: null,
elevation: buttonElevation,
surfaceTintColor: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(buttonRadius),
),
padding: EdgeInsets.zero,
minimumSize: Size(48, 48),
foregroundColor:
number == NumberPageContainer.of(context).currentPage
? colorSub
: colorPrimary,
backgroundColor:
number == NumberPageContainer.of(context).currentPage
? colorPrimary
: colorSub,
),
onPressed: () {
onSelect(context, number);
},
child: Text(
'${number}',
style: TextStyle(
fontSize: fontSize,
fontFamily: fontFamily,
color: number == NumberPageContainer.of(context).currentPage
? colorSub
: colorPrimary,
),
),
),
),
);
}
}
Loading

0 comments on commit dda8a59

Please sign in to comment.