fix: added ci and linter

This commit is contained in:
mike doornenbal 2024-02-06 16:58:14 +01:00
parent 8421f50cf6
commit 450e94f453
12 changed files with 216 additions and 156 deletions

14
.github/workflows/component-ci.yml vendored Normal file
View 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

View file

@ -7,3 +7,8 @@
- Add custom wrap alignment
- Add custom widget during animation
- Can now set duration to 0 for instant transition
## [0.0.3] 7 February 2024
- Add Figma link
- Add CI and Linter

View file

@ -1,29 +1,9 @@
# 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`.
include: package:flutter_iconica_analysis/analysis_options.yaml
# 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
# Possible to overwrite the rules from the package
analyzer:
exclude:
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
rules:

View file

@ -1,11 +1,11 @@
# 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.
# This file should be version controlled and should not be manually edited.
version:
revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
channel: stable
revision: "41456452f29d64e8deb623a3c927524bcf9f111b"
channel: "stable"
project_type: app
@ -13,11 +13,11 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
- platform: android
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
- platform: ios
create_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
base_revision: 41456452f29d64e8deb623a3c927524bcf9f111b
# User provided section

View file

@ -37,10 +37,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.17.1"
version: "1.18.0"
cupertino_icons:
dependency: "direct main"
description:
@ -82,14 +82,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
lints:
dependency: transitive
description:
@ -102,26 +94,26 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.15"
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
path:
dependency: transitive
description:
@ -139,26 +131,26 @@ packages:
dependency: transitive
description:
name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
string_scanner:
dependency: transitive
description:
@ -179,10 +171,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.5.1"
version: "0.6.1"
vector_math:
dependency: transitive
description:
@ -191,5 +183,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "0.3.0"
sdks:
dart: ">=3.0.0-0 <4.0.0"
dart: ">=3.2.0-194.0.dev <4.0.0"

View 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);
});
}

View file

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2022 Iconica
//
// SPDX-License-Identifier: BSD-3-Clause
///
library flutter_grid_to_list;
export 'src/animated_grid_to_list.dart';

View file

@ -10,12 +10,12 @@ export 'animated_grid_to_list_item_builder.dart';
class AnimatedGridToList extends StatefulWidget {
const AnimatedGridToList({
Key? key,
required this.itemBuilder,
required this.controller,
super.key,
this.startWithGrid = true,
this.onTap,
}) : super(key: key);
});
final AnimatedGridToListItemBuilder itemBuilder;
final AnimatedGridToListController controller;
@ -91,14 +91,14 @@ class AnimatedGridToListController extends ChangeNotifier {
double? _initalHeight;
double? _initialWidth;
double? _previousScrollOffset;
double? _previousScrollOffsetCopy;
late double? _previousScrollOffsetCopy;
double _spacing = 0;
bool _isAnimating = false;
bool _isExpanded = false;
int? _tappedItem;
int? _prevIndex;
late int? _prevIndex;
WrapAlignment _wrapAlignment = WrapAlignment.center;
@ -147,7 +147,7 @@ class AnimatedGridToListController extends ChangeNotifier {
void _handleScroll(int index) {
switch (_type) {
case GridToListType.grid:
_scrollController.jumpTo((index * (_boxHeight ?? 0)));
_scrollController.jumpTo(index * (_boxHeight ?? 0));
if ([WrapAlignment.start, WrapAlignment.end].contains(_wrapAlignment) &&
_controller.value > 0.5) {
_wrapAlignment = WrapAlignment.center;
@ -209,8 +209,11 @@ class AnimatedGridToListController extends ChangeNotifier {
_finalize(_previousScrollOffsetCopy!);
}
WrapAlignment _determineAlignment(int index, BuildContext context,
AnimatedGridToListItemBuilder itemBuilder) {
WrapAlignment _determineAlignment(
int index,
BuildContext context,
AnimatedGridToListItemBuilder itemBuilder,
) {
var amountOfItems =
((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;
/// 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]) {
_isExpanded = false;
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.
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.
void resize(int index, Duration? duration) {

View file

@ -5,13 +5,17 @@
import 'package:flutter/material.dart';
/// 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].
class AnimatedGridToListItemBuilder {
@ -34,10 +38,12 @@ class AnimatedGridToListItemBuilder {
/// [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.
/// 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.
/// 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.

View file

@ -5,18 +5,22 @@
import 'package:flutter/material.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 {
/// [grid] type of [GridToListType] which build a grid for [AnimatedGridToList]
/// [grid] type of [GridToListType] which build a grid for
/// [AnimatedGridToList]
grid,
/// [list] type of [GridToListType] which build a grid for [AnimatedGridToList]
/// [list] type of [GridToListType] which build a grid for
/// [AnimatedGridToList]
list,
}
extension NextType on GridToListType {
/// Extenstion method on [GridToListType] which can be called to return the next value.
get next =>
/// Extenstion method on [GridToListType] which can be called to return
/// the next value.
GridToListType get next =>
this == GridToListType.grid ? GridToListType.list : GridToListType.grid;
}
@ -31,53 +35,53 @@ extension Render on GridToListType {
required Function(int)? onTap,
required BuildContext context,
required bool isAnimating,
}) {
return !isAnimating
? Wrap(
alignment: itemBuilder.wrapAlignment,
spacing: spacing,
children: [
for (int i = 0; i < itemBuilder.itemCount; i++) ...[
Opacity(
opacity: isAnimating && tappedItem == i
? 1
: isAnimating && tappedItem != i
? 0
: 1,
child: this == GridToListType.grid
? SizedBox(
width: boxWidth ?? itemBuilder.gridItemSize.width,
height: boxHeight ?? itemBuilder.gridItemSize.height,
child: GestureDetector(
onTap: () => onTap?.call(i),
child: itemBuilder.gridItemBuilder(context, i),
}) =>
!isAnimating
? Wrap(
alignment: itemBuilder.wrapAlignment,
spacing: spacing,
children: [
for (int i = 0; i < itemBuilder.itemCount; i++) ...[
Opacity(
opacity: isAnimating && tappedItem == i
? 1
: isAnimating && tappedItem != i
? 0
: 1,
child: this == GridToListType.grid
? SizedBox(
width: boxWidth ?? itemBuilder.gridItemSize.width,
height:
boxHeight ?? itemBuilder.gridItemSize.height,
child: GestureDetector(
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(
alignment: tappedItem != itemBuilder.itemCount - 1
? Alignment.topCenter
: Alignment.bottomCenter,
child: SizedBox(
width: boxWidth ?? itemBuilder.listItemSize.width,
height: boxHeight ?? itemBuilder.listItemSize.height,
child: GestureDetector(
child: itemBuilder.animatedItemBuilder != null
? itemBuilder.animatedItemBuilder!(context, tappedItem!)
: itemBuilder.listItemBuilder(context, tappedItem!),
)
: Align(
alignment: tappedItem != itemBuilder.itemCount - 1
? Alignment.topCenter
: Alignment.bottomCenter,
child: SizedBox(
width: boxWidth ?? itemBuilder.listItemSize.width,
height: boxHeight ?? itemBuilder.listItemSize.height,
child: GestureDetector(
child: itemBuilder.animatedItemBuilder != null
? itemBuilder.animatedItemBuilder!(context, tappedItem!)
: itemBuilder.listItemBuilder(context, tappedItem!),
),
),
),
);
}
);
}

View file

@ -37,10 +37,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.17.1"
version: "1.18.0"
cupertino_icons:
dependency: "direct main"
description:
@ -62,8 +62,17 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_lints:
flutter_iconica_analysis:
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:
name: flutter_lints
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
@ -75,14 +84,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
lints:
dependency: transitive
description:
@ -95,26 +96,26 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.15"
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
path:
dependency: transitive
description:
@ -132,26 +133,26 @@ packages:
dependency: transitive
description:
name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
string_scanner:
dependency: transitive
description:
@ -172,10 +173,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.5.1"
version: "0.6.1"
vector_math:
dependency: transitive
description:
@ -184,5 +185,13 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "0.3.0"
sdks:
dart: ">=3.0.0-0 <4.0.0"
dart: ">=3.2.0-194.0.dev <4.0.0"

View file

@ -2,7 +2,7 @@ name: flutter_grid_to_list
description: A new Flutter project.
publish_to: "none"
version: 0.0.2+1
version: 0.0.3
environment:
sdk: ">=2.19.3 <3.0.0"
@ -15,7 +15,10 @@ dependencies:
dev_dependencies:
flutter_test:
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:
uses-material-design: true