-
Notifications
You must be signed in to change notification settings - Fork 2
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
0 parents
commit 4a87a49
Showing
113 changed files
with
3,804 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
/pubspec.lock | ||
**/doc/api/ | ||
.dart_tool/ | ||
.packages | ||
build/ |
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,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b | ||
channel: stable | ||
|
||
project_type: package |
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,4 @@ | ||
example/ | ||
raw/ | ||
*.iml | ||
analysis_options.yaml |
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,7 @@ | ||
## 1.0.0 | ||
|
||
* `GroupedListView` | ||
* `GroupedListView.list()` | ||
* `GroupedListView.grid()` | ||
|
||
See [documentation](https://github.com/quentin7b/flutter_grouped_listview) |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Quentin Klein | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,190 @@ | ||
# Flutter Simple Grouped ListView | ||
|
||
`simple_grouped_listview` is a package that helps you display grouped item in a listview | ||
|
||
## Usecase | ||
|
||
Sometimes, you have a `List<T>` and you want to display it but with a particularity. | ||
`T` must be grouped somehow. | ||
|
||
For example, `T` has a `DateTime` field and you want to group them under the `day` or the `month` or the `year` or even some mix. | ||
|
||
Using this package, you'll be able to display your `List<T>` easily without doing much. | ||
|
||
## Features | ||
|
||
There are 4 main features exposed in this library. | ||
|
||
- Custom Grouped ListView with a builder for the header and for the List of items | ||
- List Grouped ListView with a builder for the header and for each item of the Lists | ||
- Grid Grouped ListView with a builder for the header and for each item of the Grids | ||
- Custom Grouped ListView with a builder for each group of items (header and List of items) | ||
|
||
Using this 4 Widgets, you'll be able to do whatever you need to get some results like this: | ||
|
||
<img width="200" alt="Simple List" src="./raw/simple_list.gif"> | ||
<img width="200" alt="Simple Grid" src="./raw/grid_list.gif"> | ||
<img width="200" alt="Sticky List" src="./raw/sticky_list.gif"> | ||
|
||
|
||
## Installation | ||
|
||
### Dependency | ||
|
||
Add the package as a dependency in your `pubspec.yaml` file. | ||
|
||
```yaml | ||
dependencies: | ||
simple_grouped_listview: "^1.0.0" | ||
``` | ||
### Import | ||
Import the package in your code file. | ||
```dart | ||
import 'package:simple_grouped_listview/simple_grouped_listview.dart'; | ||
``` | ||
|
||
## Usage | ||
|
||
You can use the widget `GroupedListView` to create your listviews. | ||
|
||
There are 3 available constructors for this widhet. | ||
|
||
Mandatory params are | ||
|
||
- `items` which is the `List<T>` that you want to display | ||
- `itemGrouper` which is a `H Function(T item)`, `H` being the header that is used to group your items. | ||
For example, if you want to group your `T` items with a `DateTime` field on the year, then item groupe can be `itemGrouper: (T i) => T.dateTime.year`. | ||
|
||
Now you have 2 possibilities. | ||
|
||
- Providing a `headerBuilder` and a `listItemBuilder`/`gridItemBuilder`/`itemsBuilder` that are builders that help creating the list | ||
- Providing a `customBuilder` that will be in charge of building all the items (header and list included) | ||
|
||
Moreover, you have 3 helpers to guide you | ||
|
||
- `GroupedListView.list()` that displays your `List<T>` is a `ListView` | ||
- `GroupedListView.grid()` that displays your `List<T>` is a `GridView` | ||
- `GroupedListView()` that displays your `List<T>` is a ... your call ! | ||
|
||
Here are examples of each usage | ||
|
||
### Simple | ||
|
||
```dart | ||
GroupedListView.list( | ||
items: List<int>.generate(100, (index) => index + 1), | ||
itemGrouper: (int i) => i.isEven, | ||
headerBuilder: (context, bool isEven) => Container( | ||
color: Colors.amber, | ||
child: Text( | ||
isEven ? 'Even' : 'Odd', | ||
style: const TextStyle(fontWeight: FontWeight.bold), | ||
), | ||
padding: const EdgeInsets.all(16), | ||
), | ||
listItemBuilder: | ||
(context, int countInGroup, int itemIndexInGroup, int item) => | ||
Container( | ||
child: Text(item.toRadixString(10), textAlign: TextAlign.center), | ||
padding: const EdgeInsets.all(8), | ||
), | ||
); | ||
``` | ||
|
||
> Using the `GroupedListView.list()` constructor, you have to provide a `listItemBuilder` to build the items, the `ListView` itself is handled by the **package** | ||
### Grid | ||
|
||
```dart | ||
GroupedListView.grid( | ||
items: List<int>.generate(100, (index) => index + 1), | ||
itemGrouper: (int i) => i.isEven, | ||
headerBuilder: (context, bool isEven) => Container( | ||
color: Colors.amber, | ||
child: Text( | ||
isEven ? 'Even' : 'Odd', | ||
style: const TextStyle(fontWeight: FontWeight.bold), | ||
), | ||
padding: const EdgeInsets.all(16), | ||
), | ||
gridItemBuilder: | ||
(context, int countInGroup, int itemIndexInGroup, int item) => | ||
Container( | ||
child: Text(item.toRadixString(10), textAlign: TextAlign.center), | ||
padding: const EdgeInsets.all(8), | ||
), | ||
crossAxisCount: 5, | ||
); | ||
``` | ||
|
||
> Using the `GroupedListView.grid()` constructor, you have to provide a `gridItemBuilder` to build the items, the `GridView` itself is handled by the **package** | ||
> Note that for the `grid` constructor, a `crossAxisCount` parameter is **required** | ||
### Custom | ||
|
||
```dart | ||
GroupedListView( | ||
items: List<int>.generate(100, (index) => index + 1), | ||
headerBuilder: (context, bool isEven) => Container( | ||
child: Text( | ||
isEven ? 'Even' : 'Odd', | ||
style: const TextStyle(fontWeight: FontWeight.bold), | ||
), | ||
padding: const EdgeInsets.all(16), | ||
), | ||
itemsBuilder: (context, List<int> items) => ListView.builder( | ||
itemCount: items.length, | ||
shrinkWrap: true, | ||
physics: const NeverScrollableScrollPhysics(), | ||
itemBuilder: (context, int index) => Container( | ||
child: Text(items[index].toRadixString(10), | ||
textAlign: TextAlign.center), | ||
padding: const EdgeInsets.all(8), | ||
), | ||
), | ||
itemGrouper: (int i) => i.isEven, | ||
); | ||
``` | ||
|
||
> Using the `GroupedListView.grid()` constructor, you have to provide a `itemsBuilder` to build the items, nothing is provided by the **paclage** so, here is an example with a `ListView` | ||
### sticky_header | ||
|
||
What if you want to use some other **package** like [StickyHeaders](https://pub.dev/packages/sticky_headers), giving a `headerBuilder` and an `itemBuilder` won't work for this kind of *package*. | ||
No worries, you can use a specific **constructor** to do so. | ||
|
||
```dart | ||
GroupedListView( | ||
items: List<int>.generate(100, (index) => index + 1), | ||
customBuilder: (context, bool isEvenHeader, List<int> items) => StickyHeader( | ||
header: Container( | ||
color: Colors.amber, | ||
child: Text( | ||
isEvenHeader ? 'Even' : 'Odd', | ||
style: const TextStyle(fontWeight: FontWeight.bold), | ||
), | ||
padding: const EdgeInsets.all(16)), | ||
content: ListView.builder( | ||
itemCount: items.length, | ||
shrinkWrap: true, | ||
physics: const NeverScrollableScrollPhysics(), | ||
itemBuilder: (context, int index) => Container( | ||
child: Text(items[index].toRadixString(10), | ||
textAlign: TextAlign.center), | ||
padding: const EdgeInsets.all(8), | ||
), | ||
), | ||
), | ||
itemGrouper: (int i) => i.isEven, | ||
) | ||
``` | ||
|
||
> Using the `GroupedListView()` with a `customBuilder` helps you manage your UI with what you want the customBuilder being a Function that gives you a `BuildContext`, a `H` (your header type) and a `List<T>` | ||
|
||
## Additional information | ||
|
||
Feel free to open an issue or contribute to this package ! Hope it helps you build awesome UI with flutter. | ||
See the [example](./example) folder for examples of usage. |
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,4 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
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 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
|
||
# Web related | ||
lib/generated_plugin_registrant.dart | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Android Studio will place build artifacts here | ||
/android/app/debug | ||
/android/app/profile | ||
/android/app/release |
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,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b | ||
channel: stable | ||
|
||
project_type: app |
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,16 @@ | ||
# example | ||
|
||
A new Flutter project. | ||
|
||
## Getting Started | ||
|
||
This project is a starting point for a Flutter application. | ||
|
||
A few resources to get you started if this is your first Flutter project: | ||
|
||
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) | ||
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) | ||
|
||
For help getting started with Flutter, view our | ||
[online documentation](https://flutter.dev/docs), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. |
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,29 @@ | ||
# This file configures the analyzer, which statically analyzes Dart code to | ||
# check for errors, warnings, and lints. | ||
# | ||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled | ||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be | ||
# invoked from the command line by running `flutter analyze`. | ||
|
||
# The following line activates a set of recommended lints for Flutter apps, | ||
# packages, and plugins designed to encourage good coding practices. | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
linter: | ||
# The lint rules applied to this project can be customized in the | ||
# section below to disable rules from the `package:flutter_lints/flutter.yaml` | ||
# included above or to enable additional rules. A list of all available lints | ||
# and their documentation is published at | ||
# https://dart-lang.github.io/linter/lints/index.html. | ||
# | ||
# Instead of disabling a lint rule for the entire project in the | ||
# section below, it can also be suppressed for a single line of code | ||
# or a specific dart file by using the `// ignore: name_of_lint` and | ||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file | ||
# producing the lint. | ||
rules: | ||
# avoid_print: false # Uncomment to disable the `avoid_print` rule | ||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
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,13 @@ | ||
gradle-wrapper.jar | ||
/.gradle | ||
/captures/ | ||
/gradlew | ||
/gradlew.bat | ||
/local.properties | ||
GeneratedPluginRegistrant.java | ||
|
||
# Remember to never publicly share your keystore. | ||
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app | ||
key.properties | ||
**/*.keystore | ||
**/*.jks |
Oops, something went wrong.