mirror of
https://github.com/Iconica-Development/flutter_grid_to_list.git
synced 2025-05-19 04:23:45 +02:00
fix: added ci and linter
This commit is contained in:
parent
8421f50cf6
commit
450e94f453
12 changed files with 216 additions and 156 deletions
14
.github/workflows/component-ci.yml
vendored
Normal file
14
.github/workflows/component-ci.yml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
name: Iconica Standard Component CI Workflow
|
||||||
|
# Workflow Caller version: 2.0.0
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
call-global-iconica-workflow:
|
||||||
|
uses: Iconica-Development/.github/.github/workflows/component-ci.yml@master
|
||||||
|
secrets: inherit
|
||||||
|
permissions: write-all
|
||||||
|
with:
|
||||||
|
subfolder: "." # add optional subfolder to run workflow in
|
|
@ -7,3 +7,8 @@
|
||||||
- Add custom wrap alignment
|
- Add custom wrap alignment
|
||||||
- Add custom widget during animation
|
- Add custom widget during animation
|
||||||
- Can now set duration to 0 for instant transition
|
- Can now set duration to 0 for instant transition
|
||||||
|
|
||||||
|
## [0.0.3] 7 February 2024
|
||||||
|
|
||||||
|
- Add Figma link
|
||||||
|
- Add CI and Linter
|
||||||
|
|
|
@ -1,29 +1,9 @@
|
||||||
# This file configures the analyzer, which statically analyzes Dart code to
|
include: package:flutter_iconica_analysis/analysis_options.yaml
|
||||||
# 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,
|
# Possible to overwrite the rules from the package
|
||||||
# packages, and plugins designed to encourage good coding practices.
|
|
||||||
include: package:flutter_lints/flutter.yaml
|
analyzer:
|
||||||
|
exclude:
|
||||||
|
|
||||||
linter:
|
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:
|
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
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
# This file tracks properties of this Flutter project.
|
# This file tracks properties of this Flutter project.
|
||||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||||
#
|
#
|
||||||
# This file should be version controlled.
|
# This file should be version controlled and should not be manually edited.
|
||||||
|
|
||||||
version:
|
version:
|
||||||
revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
revision: "41456452f29d64e8deb623a3c927524bcf9f111b"
|
||||||
channel: stable
|
channel: "stable"
|
||||||
|
|
||||||
project_type: app
|
project_type: app
|
||||||
|
|
||||||
|
@ -13,11 +13,11 @@ project_type: app
|
||||||
migration:
|
migration:
|
||||||
platforms:
|
platforms:
|
||||||
- platform: root
|
- platform: root
|
||||||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
|
||||||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
|
||||||
- platform: android
|
- platform: ios
|
||||||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
|
||||||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
|
||||||
|
|
||||||
# User provided section
|
# User provided section
|
||||||
|
|
||||||
|
|
|
@ -37,10 +37,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
|
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.17.1"
|
version: "1.18.0"
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -82,14 +82,6 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
js:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: js
|
|
||||||
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.6.7"
|
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -102,26 +94,26 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
|
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.15"
|
version: "0.12.16"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
|
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.0"
|
version: "0.5.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
|
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.10.0"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -139,26 +131,26 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: source_span
|
name: source_span
|
||||||
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
|
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.10.0"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stack_trace
|
name: stack_trace
|
||||||
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
|
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.11.0"
|
version: "1.11.1"
|
||||||
stream_channel:
|
stream_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
|
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.2"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -179,10 +171,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
|
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.1"
|
version: "0.6.1"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -191,5 +183,13 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.4"
|
||||||
|
web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: web
|
||||||
|
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.0.0-0 <4.0.0"
|
dart: ">=3.2.0-194.0.dev <4.0.0"
|
||||||
|
|
32
example/test/widget_test.dart
Normal file
32
example/test/widget_test.dart
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// This is a basic Flutter widget test.
|
||||||
|
//
|
||||||
|
// To perform an interaction with a widget in your test, use the WidgetTester
|
||||||
|
// utility in the flutter_test package. For example, you can send tap and scroll
|
||||||
|
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||||
|
// tree, read text, and verify that the values of widget properties are correct.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import 'package:example/main.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||||
|
// Build our app and trigger a frame.
|
||||||
|
await tester.pumpWidget(const MaterialApp(
|
||||||
|
home: GridToList(),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Verify that our counter starts at 0.
|
||||||
|
expect(find.text('0'), findsOneWidget);
|
||||||
|
expect(find.text('1'), findsNothing);
|
||||||
|
|
||||||
|
// Tap the '+' icon and trigger a frame.
|
||||||
|
await tester.tap(find.byIcon(Icons.add));
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
// Verify that our counter has incremented.
|
||||||
|
expect(find.text('0'), findsNothing);
|
||||||
|
expect(find.text('1'), findsOneWidget);
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
// SPDX-FileCopyrightText: 2022 Iconica
|
// SPDX-FileCopyrightText: 2022 Iconica
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
///
|
||||||
library flutter_grid_to_list;
|
library flutter_grid_to_list;
|
||||||
|
|
||||||
export 'src/animated_grid_to_list.dart';
|
export 'src/animated_grid_to_list.dart';
|
||||||
|
|
|
@ -10,12 +10,12 @@ export 'animated_grid_to_list_item_builder.dart';
|
||||||
|
|
||||||
class AnimatedGridToList extends StatefulWidget {
|
class AnimatedGridToList extends StatefulWidget {
|
||||||
const AnimatedGridToList({
|
const AnimatedGridToList({
|
||||||
Key? key,
|
|
||||||
required this.itemBuilder,
|
required this.itemBuilder,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
|
super.key,
|
||||||
this.startWithGrid = true,
|
this.startWithGrid = true,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
final AnimatedGridToListItemBuilder itemBuilder;
|
final AnimatedGridToListItemBuilder itemBuilder;
|
||||||
final AnimatedGridToListController controller;
|
final AnimatedGridToListController controller;
|
||||||
|
@ -91,14 +91,14 @@ class AnimatedGridToListController extends ChangeNotifier {
|
||||||
double? _initalHeight;
|
double? _initalHeight;
|
||||||
double? _initialWidth;
|
double? _initialWidth;
|
||||||
double? _previousScrollOffset;
|
double? _previousScrollOffset;
|
||||||
double? _previousScrollOffsetCopy;
|
late double? _previousScrollOffsetCopy;
|
||||||
double _spacing = 0;
|
double _spacing = 0;
|
||||||
|
|
||||||
bool _isAnimating = false;
|
bool _isAnimating = false;
|
||||||
bool _isExpanded = false;
|
bool _isExpanded = false;
|
||||||
|
|
||||||
int? _tappedItem;
|
int? _tappedItem;
|
||||||
int? _prevIndex;
|
late int? _prevIndex;
|
||||||
|
|
||||||
WrapAlignment _wrapAlignment = WrapAlignment.center;
|
WrapAlignment _wrapAlignment = WrapAlignment.center;
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ class AnimatedGridToListController extends ChangeNotifier {
|
||||||
void _handleScroll(int index) {
|
void _handleScroll(int index) {
|
||||||
switch (_type) {
|
switch (_type) {
|
||||||
case GridToListType.grid:
|
case GridToListType.grid:
|
||||||
_scrollController.jumpTo((index * (_boxHeight ?? 0)));
|
_scrollController.jumpTo(index * (_boxHeight ?? 0));
|
||||||
if ([WrapAlignment.start, WrapAlignment.end].contains(_wrapAlignment) &&
|
if ([WrapAlignment.start, WrapAlignment.end].contains(_wrapAlignment) &&
|
||||||
_controller.value > 0.5) {
|
_controller.value > 0.5) {
|
||||||
_wrapAlignment = WrapAlignment.center;
|
_wrapAlignment = WrapAlignment.center;
|
||||||
|
@ -209,8 +209,11 @@ class AnimatedGridToListController extends ChangeNotifier {
|
||||||
_finalize(_previousScrollOffsetCopy!);
|
_finalize(_previousScrollOffsetCopy!);
|
||||||
}
|
}
|
||||||
|
|
||||||
WrapAlignment _determineAlignment(int index, BuildContext context,
|
WrapAlignment _determineAlignment(
|
||||||
AnimatedGridToListItemBuilder itemBuilder) {
|
int index,
|
||||||
|
BuildContext context,
|
||||||
|
AnimatedGridToListItemBuilder itemBuilder,
|
||||||
|
) {
|
||||||
var amountOfItems =
|
var amountOfItems =
|
||||||
((context.size?.width ?? 0) / itemBuilder.gridItemSize.width).floor();
|
((context.size?.width ?? 0) / itemBuilder.gridItemSize.width).floor();
|
||||||
|
|
||||||
|
@ -253,10 +256,12 @@ class AnimatedGridToListController extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Can be used to retrieve the status of the widget. This is only useful if you use [shrink] and [expand] methods
|
/// Can be used to retrieve the status of the widget. This is only useful if
|
||||||
|
/// you use [shrink] and [expand] methods
|
||||||
bool get isExpanded => _isExpanded;
|
bool get isExpanded => _isExpanded;
|
||||||
|
|
||||||
/// Can be called to shrink to widget to it's grid state. Only works when the current state is of type [GridToListType.list]
|
/// Can be called to shrink to widget to it's grid state. Only works when the
|
||||||
|
/// current state is of type [GridToListType.list]
|
||||||
void shrink([Duration? duration]) {
|
void shrink([Duration? duration]) {
|
||||||
_isExpanded = false;
|
_isExpanded = false;
|
||||||
if (_type == GridToListType.list) {
|
if (_type == GridToListType.list) {
|
||||||
|
@ -264,7 +269,8 @@ class AnimatedGridToListController extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Can be called to expand to widget to it's list state. Only works when the current state is of type [GridToListType.grid]
|
/// Can be called to expand to widget to it's list state. Only works when the
|
||||||
|
/// current state is of type [GridToListType.grid]
|
||||||
///
|
///
|
||||||
/// Gets an index to determine which item it needs to transform.
|
/// Gets an index to determine which item it needs to transform.
|
||||||
void expand(int index, [Duration? duration]) {
|
void expand(int index, [Duration? duration]) {
|
||||||
|
@ -275,7 +281,8 @@ class AnimatedGridToListController extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Can be called to dynamically change the state of the widget. Works in either [GridToListType.grid] or [GridToListType.list]
|
/// Can be called to dynamically change the state of the widget. Works in
|
||||||
|
/// either [GridToListType.grid] or [GridToListType.list]
|
||||||
///
|
///
|
||||||
/// Gets an index to determine which item it needs to transform.
|
/// Gets an index to determine which item it needs to transform.
|
||||||
void resize(int index, Duration? duration) {
|
void resize(int index, Duration? duration) {
|
||||||
|
|
|
@ -5,13 +5,17 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// Class required by [AnimatedGridToList] to build items.
|
/// Class required by [AnimatedGridToList] to build items.
|
||||||
/// Requires [gridItemBuilder] which is an [IndexedWidgetBuilder] to build items in [AnimatedGridToList] grid state.
|
/// Requires [gridItemBuilder] which is an [IndexedWidgetBuilder] to build items
|
||||||
|
/// in [AnimatedGridToList] grid state.
|
||||||
///
|
///
|
||||||
/// Requires [listItemBuilder] which is an [IndexedWidgetBuilder] to build items in [AnimatedGridToList] list state.
|
/// Requires [listItemBuilder] which is an [IndexedWidgetBuilder] to build items
|
||||||
|
/// in [AnimatedGridToList] list state.
|
||||||
///
|
///
|
||||||
/// Requires [gridItemSize] which is of type [Size] to build the items and handle the scrolling accordingly.
|
/// Requires [gridItemSize] which is of type [Size] to build the items and
|
||||||
|
/// handle the scrolling accordingly.
|
||||||
///
|
///
|
||||||
/// Requires [listItemSize] which is of type [Size] to build the items and handle the scrolling accordingly.
|
/// Requires [listItemSize] which is of type [Size] to build the items and
|
||||||
|
/// handle the scrolling accordingly.
|
||||||
///
|
///
|
||||||
/// It also requires an [itemCount], which is of type [int].
|
/// It also requires an [itemCount], which is of type [int].
|
||||||
class AnimatedGridToListItemBuilder {
|
class AnimatedGridToListItemBuilder {
|
||||||
|
@ -34,10 +38,12 @@ class AnimatedGridToListItemBuilder {
|
||||||
/// [IndexedWidgetBuilder] which build the items in animated state.
|
/// [IndexedWidgetBuilder] which build the items in animated state.
|
||||||
final IndexedWidgetBuilder? animatedItemBuilder;
|
final IndexedWidgetBuilder? animatedItemBuilder;
|
||||||
|
|
||||||
/// A [Size] to build the items in the correct manner and handle scrolling in grid state.
|
/// A [Size] to build the items in the correct manner and handle scrolling
|
||||||
|
/// in grid state.
|
||||||
final Size gridItemSize;
|
final Size gridItemSize;
|
||||||
|
|
||||||
/// A [Size] to build the items in the correct manner and handle scrolling in list state.
|
/// A [Size] to build the items in the correct manner and handle scrolling
|
||||||
|
/// in list state.
|
||||||
final Size listItemSize;
|
final Size listItemSize;
|
||||||
|
|
||||||
/// A [WrapAlignment] to align the items in the correct manner.
|
/// A [WrapAlignment] to align the items in the correct manner.
|
||||||
|
|
|
@ -5,18 +5,22 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_grid_to_list/src/animated_grid_to_list_item_builder.dart';
|
import 'package:flutter_grid_to_list/src/animated_grid_to_list_item_builder.dart';
|
||||||
|
|
||||||
/// An enum to which offers the possibilties the [AnimatedGridToList] can be rendered in.
|
/// An enum to which offers the possibilties the [AnimatedGridToList] can be
|
||||||
|
/// rendered in.
|
||||||
enum GridToListType {
|
enum GridToListType {
|
||||||
/// [grid] type of [GridToListType] which build a grid for [AnimatedGridToList]
|
/// [grid] type of [GridToListType] which build a grid for
|
||||||
|
/// [AnimatedGridToList]
|
||||||
grid,
|
grid,
|
||||||
|
|
||||||
/// [list] type of [GridToListType] which build a grid for [AnimatedGridToList]
|
/// [list] type of [GridToListType] which build a grid for
|
||||||
|
/// [AnimatedGridToList]
|
||||||
list,
|
list,
|
||||||
}
|
}
|
||||||
|
|
||||||
extension NextType on GridToListType {
|
extension NextType on GridToListType {
|
||||||
/// Extenstion method on [GridToListType] which can be called to return the next value.
|
/// Extenstion method on [GridToListType] which can be called to return
|
||||||
get next =>
|
/// the next value.
|
||||||
|
GridToListType get next =>
|
||||||
this == GridToListType.grid ? GridToListType.list : GridToListType.grid;
|
this == GridToListType.grid ? GridToListType.list : GridToListType.grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,53 +35,53 @@ extension Render on GridToListType {
|
||||||
required Function(int)? onTap,
|
required Function(int)? onTap,
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required bool isAnimating,
|
required bool isAnimating,
|
||||||
}) {
|
}) =>
|
||||||
return !isAnimating
|
!isAnimating
|
||||||
? Wrap(
|
? Wrap(
|
||||||
alignment: itemBuilder.wrapAlignment,
|
alignment: itemBuilder.wrapAlignment,
|
||||||
spacing: spacing,
|
spacing: spacing,
|
||||||
children: [
|
children: [
|
||||||
for (int i = 0; i < itemBuilder.itemCount; i++) ...[
|
for (int i = 0; i < itemBuilder.itemCount; i++) ...[
|
||||||
Opacity(
|
Opacity(
|
||||||
opacity: isAnimating && tappedItem == i
|
opacity: isAnimating && tappedItem == i
|
||||||
? 1
|
? 1
|
||||||
: isAnimating && tappedItem != i
|
: isAnimating && tappedItem != i
|
||||||
? 0
|
? 0
|
||||||
: 1,
|
: 1,
|
||||||
child: this == GridToListType.grid
|
child: this == GridToListType.grid
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
width: boxWidth ?? itemBuilder.gridItemSize.width,
|
width: boxWidth ?? itemBuilder.gridItemSize.width,
|
||||||
height: boxHeight ?? itemBuilder.gridItemSize.height,
|
height:
|
||||||
child: GestureDetector(
|
boxHeight ?? itemBuilder.gridItemSize.height,
|
||||||
onTap: () => onTap?.call(i),
|
child: GestureDetector(
|
||||||
child: itemBuilder.gridItemBuilder(context, i),
|
onTap: () => onTap?.call(i),
|
||||||
|
child: itemBuilder.gridItemBuilder(context, i),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: SizedBox(
|
||||||
|
width: boxWidth ?? itemBuilder.listItemSize.width,
|
||||||
|
height: null,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => onTap?.call(i),
|
||||||
|
child: itemBuilder.listItemBuilder(context, i),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
: SizedBox(
|
],
|
||||||
width: boxWidth ?? itemBuilder.listItemSize.width,
|
|
||||||
height: null,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () => onTap?.call(i),
|
|
||||||
child: itemBuilder.listItemBuilder(context, i),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
],
|
)
|
||||||
)
|
: Align(
|
||||||
: Align(
|
alignment: tappedItem != itemBuilder.itemCount - 1
|
||||||
alignment: tappedItem != itemBuilder.itemCount - 1
|
? Alignment.topCenter
|
||||||
? Alignment.topCenter
|
: Alignment.bottomCenter,
|
||||||
: Alignment.bottomCenter,
|
child: SizedBox(
|
||||||
child: SizedBox(
|
width: boxWidth ?? itemBuilder.listItemSize.width,
|
||||||
width: boxWidth ?? itemBuilder.listItemSize.width,
|
height: boxHeight ?? itemBuilder.listItemSize.height,
|
||||||
height: boxHeight ?? itemBuilder.listItemSize.height,
|
child: GestureDetector(
|
||||||
child: GestureDetector(
|
child: itemBuilder.animatedItemBuilder != null
|
||||||
child: itemBuilder.animatedItemBuilder != null
|
? itemBuilder.animatedItemBuilder!(context, tappedItem!)
|
||||||
? itemBuilder.animatedItemBuilder!(context, tappedItem!)
|
: itemBuilder.listItemBuilder(context, tappedItem!),
|
||||||
: itemBuilder.listItemBuilder(context, tappedItem!),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
61
pubspec.lock
61
pubspec.lock
|
@ -37,10 +37,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
|
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.17.1"
|
version: "1.18.0"
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -62,8 +62,17 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
flutter_lints:
|
flutter_iconica_analysis:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
|
description:
|
||||||
|
path: "."
|
||||||
|
ref: "6.0.0"
|
||||||
|
resolved-ref: "5f0a02791db6785add4e445d383a1ac012fa8f55"
|
||||||
|
url: "https://github.com/Iconica-Development/flutter_iconica_analysis"
|
||||||
|
source: git
|
||||||
|
version: "6.0.0"
|
||||||
|
flutter_lints:
|
||||||
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: flutter_lints
|
name: flutter_lints
|
||||||
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
|
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
|
||||||
|
@ -75,14 +84,6 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
js:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: js
|
|
||||||
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.6.7"
|
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -95,26 +96,26 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
|
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.15"
|
version: "0.12.16"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
|
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.0"
|
version: "0.5.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
|
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.10.0"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -132,26 +133,26 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: source_span
|
name: source_span
|
||||||
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
|
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.10.0"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stack_trace
|
name: stack_trace
|
||||||
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
|
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.11.0"
|
version: "1.11.1"
|
||||||
stream_channel:
|
stream_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
|
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.2"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -172,10 +173,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
|
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.1"
|
version: "0.6.1"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -184,5 +185,13 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.4"
|
||||||
|
web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: web
|
||||||
|
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.0.0-0 <4.0.0"
|
dart: ">=3.2.0-194.0.dev <4.0.0"
|
||||||
|
|
|
@ -2,7 +2,7 @@ name: flutter_grid_to_list
|
||||||
description: A new Flutter project.
|
description: A new Flutter project.
|
||||||
|
|
||||||
publish_to: "none"
|
publish_to: "none"
|
||||||
version: 0.0.2+1
|
version: 0.0.3
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.19.3 <3.0.0"
|
sdk: ">=2.19.3 <3.0.0"
|
||||||
|
@ -15,7 +15,10 @@ dependencies:
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^2.0.0
|
flutter_iconica_analysis:
|
||||||
|
git:
|
||||||
|
url: https://github.com/Iconica-Development/flutter_iconica_analysis
|
||||||
|
ref: 6.0.0
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
Loading…
Reference in a new issue