mirror of
https://github.com/Iconica-Development/flutter_grid_to_list.git
synced 2025-05-19 04:23:45 +02:00
add custom inbetween animated widget
This commit is contained in:
parent
5ca9f7ffa6
commit
3af6933d18
8 changed files with 41 additions and 27 deletions
|
@ -1,3 +1,9 @@
|
|||
## [0.0.1] 15 March 2023
|
||||
|
||||
- Initial Release
|
||||
- Initial Release
|
||||
|
||||
## [0.0.2] 17 March 2023
|
||||
|
||||
- Add custom wrap alignment
|
||||
- Add custom widget during animation
|
||||
- Can now set duration to 0 for instant transition
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# This file should be version controlled.
|
||||
|
||||
version:
|
||||
revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
||||
channel: stable
|
||||
|
||||
project_type: app
|
||||
|
@ -13,26 +13,11 @@ project_type: app
|
|||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
||||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
||||
- platform: android
|
||||
create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
- platform: ios
|
||||
create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
- platform: linux
|
||||
create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
- platform: macos
|
||||
create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
- platform: web
|
||||
create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
- platform: windows
|
||||
create_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
base_revision: 12cb4eb7a009f52b347b62ade7cb4854b926af72
|
||||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
||||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
||||
|
||||
# User provided section
|
||||
|
||||
|
|
|
@ -53,12 +53,20 @@ class _GridToListState extends State<GridToList> {
|
|||
controller: controller,
|
||||
onTap: (i) {
|
||||
if (!controller.isExpanded) {
|
||||
controller.expand(i, const Duration(seconds: 2));
|
||||
controller.expand(i, const Duration(seconds: 1));
|
||||
} else {
|
||||
controller.shrink(const Duration(seconds: 2));
|
||||
controller.shrink(const Duration(seconds: 0));
|
||||
}
|
||||
},
|
||||
itemBuilder: AnimatedGridToListItemBuilder(
|
||||
wrapAlignment: WrapAlignment.start,
|
||||
animatedItemBuilder: (context, index) => Container(
|
||||
height: MediaQuery.of(context).size.height * 0.6,
|
||||
width: MediaQuery.of(context).size.width * 0.8,
|
||||
color: containers[index].color,
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Text('Item $index IS ANIMATING'),
|
||||
),
|
||||
gridItemBuilder: (context, index) {
|
||||
return containers[index];
|
||||
},
|
||||
|
|
|
@ -68,7 +68,7 @@ packages:
|
|||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.0+1"
|
||||
version: "0.0.2+1"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
|
|
|
@ -297,6 +297,11 @@ class AnimatedGridToListController extends ChangeNotifier {
|
|||
_controller.addListener(_listenerFunction);
|
||||
|
||||
_controller.forward();
|
||||
if (duration?.inMilliseconds == 0) {
|
||||
_controller.value = _controller.value > _controller.upperBound / 2
|
||||
? _controller.upperBound
|
||||
: _controller.lowerBound;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ class AnimatedGridToListItemBuilder {
|
|||
required this.itemCount,
|
||||
required this.gridItemSize,
|
||||
required this.listItemSize,
|
||||
this.animatedItemBuilder,
|
||||
this.wrapAlignment = WrapAlignment.center,
|
||||
});
|
||||
|
||||
/// [IndexedWidgetBuilder] which build the items in grid state.
|
||||
|
@ -29,12 +31,18 @@ class AnimatedGridToListItemBuilder {
|
|||
/// [IndexedWidgetBuilder] which build the items in list state.
|
||||
final IndexedWidgetBuilder listItemBuilder;
|
||||
|
||||
/// [IndexedWidgetBuilder] which build the items in animated state.
|
||||
final IndexedWidgetBuilder? animatedItemBuilder;
|
||||
|
||||
/// A [Size] to build the items in the correct manner and handle scrolling in grid state.
|
||||
final Size gridItemSize;
|
||||
|
||||
/// A [Size] to build the items in the correct manner and handle scrolling in list state.
|
||||
final Size listItemSize;
|
||||
|
||||
/// A [WrapAlignment] to align the items in the correct manner.
|
||||
final WrapAlignment wrapAlignment;
|
||||
|
||||
/// A [int] of the amount of items to build.
|
||||
int itemCount;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ extension Render on GridToListType {
|
|||
}) {
|
||||
return !isAnimating
|
||||
? Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
alignment: itemBuilder.wrapAlignment,
|
||||
spacing: spacing,
|
||||
children: [
|
||||
for (int i = 0; i < itemBuilder.itemCount; i++) ...[
|
||||
|
@ -73,7 +73,9 @@ extension Render on GridToListType {
|
|||
width: boxWidth ?? itemBuilder.listItemSize.width,
|
||||
height: boxHeight ?? itemBuilder.listItemSize.height,
|
||||
child: GestureDetector(
|
||||
child: itemBuilder.listItemBuilder(context, tappedItem!),
|
||||
child: itemBuilder.animatedItemBuilder != null
|
||||
? itemBuilder.animatedItemBuilder!(context, tappedItem!)
|
||||
: itemBuilder.listItemBuilder(context, tappedItem!),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -2,7 +2,7 @@ name: flutter_grid_to_list
|
|||
description: A new Flutter project.
|
||||
|
||||
publish_to: "none"
|
||||
version: 1.0.0+1
|
||||
version: 0.0.2+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.19.3 <3.0.0"
|
||||
|
|
Loading…
Reference in a new issue