-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d527515
commit e81e395
Showing
7 changed files
with
103 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError | ||
android.useAndroidX=true | ||
android.enableJetifier=true | ||
org.gradle.java.home=C:/Program Files/Java/jdk-17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:number_paginator/number_paginator.dart'; | ||
|
||
class ScrollableNumbers extends StatefulWidget { | ||
const ScrollableNumbers({Key? key}) : super(key: key); | ||
|
||
@override | ||
_ScrollableNumbersState createState() => _ScrollableNumbersState(); | ||
} | ||
|
||
class _ScrollableNumbersState extends State<ScrollableNumbers> { | ||
final int _numPages = 100; | ||
int _currentPage = 0; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
var pages = List.generate( | ||
_numPages, | ||
(index) => Center( | ||
child: Text( | ||
"Page ${index + 1}", | ||
style: Theme.of(context).textTheme.displayLarge, | ||
), | ||
), | ||
); | ||
|
||
return Scaffold( | ||
backgroundColor: Theme.of(context).colorScheme.primaryContainer, | ||
body: pages[_currentPage], | ||
// card for elevation | ||
bottomNavigationBar: Card( | ||
margin: EdgeInsets.zero, | ||
elevation: 4, | ||
child: NumberPaginator( | ||
config: const NumberPaginatorUIConfig(mode: ContentDisplayMode.scrollableNumbers), | ||
numberPages: _numPages, | ||
onPageChange: (int index) { | ||
setState(() { | ||
_currentPage = index; | ||
}); | ||
}, | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ enum ContentDisplayMode { | |
hidden, | ||
numbers, | ||
dropdown, | ||
scrollableNumbers, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
lib/src/ui/widgets/paginator_content/scrollable_numbers_content.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:auto_size_text/auto_size_text.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:number_paginator/src/ui/widgets/buttons/paginator_button.dart'; | ||
import 'package:number_paginator/src/ui/widgets/inherited_number_paginator.dart'; | ||
|
||
class ScrollableNumberContent extends StatelessWidget { | ||
final int currentPage; | ||
|
||
const ScrollableNumberContent({ | ||
super.key, | ||
required this.currentPage, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
var numberPages = InheritedNumberPaginator.of(context).numberPages; | ||
|
||
return SizedBox( | ||
//height: 50, // Set a fixed height | ||
child: ListView.builder( | ||
scrollDirection: Axis.horizontal, // Enable scrolling | ||
itemCount: numberPages, | ||
itemBuilder: (context, index) { | ||
return _buildPageButton(context, index); | ||
}, | ||
), | ||
); | ||
} | ||
|
||
/// Builds a **clickable page button**. | ||
Widget _buildPageButton(BuildContext context, int index) => PaginatorButton( | ||
onPressed: () => | ||
InheritedNumberPaginator.of(context).onPageChange?.call(index), | ||
selected: index == currentPage, | ||
child: AutoSizeText( | ||
(index + 1).toString(), | ||
maxLines: 1, | ||
minFontSize: 5, | ||
), | ||
); | ||
} |