Compare commits

...

17 commits

Author SHA1 Message Date
Gorter-dev
eef26a375b
Merge pull request #12 from Iconica-Development/chore/deploy
chore: ready the package for deployment to the pub server
2024-07-22 14:59:39 +02:00
Bart Ribbers
cb432b548f chore: ready the package for deployment to the pub server 2024-07-11 19:38:45 +02:00
Bart Ribbers
6f9e7c863d chore: add fvm configuration to gitignore 2024-07-11 19:36:42 +02:00
Freek van de Ven
4d1edb208e
Merge pull request #11 from Iconica-Development/update-component-documentation-workflow-correct
Add component-documentation.yml correct
2024-02-14 08:06:23 +01:00
Vick Top
537870d922 feat(documentation): Create component-documentation.yml workflow file 2024-02-13 13:36:23 +01:00
Vick Top
f382ec7e59 chore: Remove old component-documentation.yml 2024-02-13 13:36:23 +01:00
Freek van de Ven
3a6b8e0232
Merge pull request #10 from Iconica-Development/update-component-documentation-workflow
Add component-documentation.yml
2024-02-12 20:18:17 +01:00
Vick Top
6a130302cf feat(documentation): Create component-documentation.yml workflow file 2024-02-12 19:08:14 +01:00
mike doornenbal
9f1fff083c Merge branch 'feature/add_ci_flutter_iconica_analysis' 2024-02-02 16:08:09 +01:00
mike doornenbal
7459954bed feat: add iconica linter and CI 2024-02-02 16:07:29 +01:00
Freek van de Ven
34f9b4143b chore: add figma link 2023-12-17 11:50:44 +01:00
Niels Gorter
7644eafa30 fix version 2023-09-26 11:56:03 +02:00
Gorter-dev
c4d82a1667
Merge pull request #8 from Iconica-Development/hotfix/inital_and_scroll
Hotfix/inital and scroll
2023-09-26 10:12:33 +02:00
Niels Gorter
19d008c411 fix linter 2023-09-26 10:12:08 +02:00
Niels Gorter
6a2161ca03 fix linter 2023-09-26 10:10:14 +02:00
Niels Gorter
782361b846 fix linter 2023-09-26 09:57:59 +02:00
Niels Gorter
7992d71076 fix: https://github.com/Iconica-Development/flutter_carousel/issues/5 2023-09-26 09:53:56 +02:00
14 changed files with 146 additions and 139 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

@ -0,0 +1,14 @@
name: Iconica Standard Component Documentation Workflow
# Workflow Caller version: 1.0.0
on:
release:
types: [published]
workflow_dispatch:
jobs:
call-iconica-component-documentation-workflow:
uses: Iconica-Development/.github/.github/workflows/component-documentation.yml@master
secrets: inherit
permissions: write-all

View file

@ -1,32 +0,0 @@
name: CI
on:
push:
branches: [ master ]
pull_request:
branches:
- master
- feature/*
- bugfix/*
- hotfix/*
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.gradle/wrapper
/opt/hostedtoolcache/flutter
key: ${{ runner.OS }}-flutter-install-cache
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Flutter pub get
run: flutter pub get
- name: Flutter format
run: flutter format -o none --set-exit-if-changed .
- name: Flutter analyze
run: flutter analyze

4
.gitignore vendored
View file

@ -21,3 +21,7 @@ doc/api/
*.js.map *.js.map
.idea .idea
# FVM Version Cache
.fvm/
.fvmrc

View file

@ -1,3 +1,10 @@
## 0.3.1
* Added Iconica CI and Iconica Linter
## 0.3.0
* Added option for backwards infinite scrolling and intial page
## 0.1.0 ## 0.1.0
* add opacity as an option to the card transform * add opacity as an option to the card transform

7
FEATURES.md Normal file
View file

@ -0,0 +1,7 @@
* Every sort of widget can be animated as a card.
* For the animation the following properties can be set between animation frames:
this.x = 0,
this.y = 0,
this.angle = 0,
this.scale = 1,
this.opacity = 1.0,

View file

@ -6,6 +6,9 @@ Each card can change its rotation, position and scale when swiping the cards.
![Carousel GIF](carousel.gif) ![Carousel GIF](carousel.gif)
Figma Design that defines this component (only accessible for Iconica developers): https://www.figma.com/file/4WkjwynOz5wFeFBRqTHPeP/Iconica-Design-System?type=design&node-id=357%3A3335&mode=design&t=XulkAJNPQ32ARxWh-1
## Usage ## Usage
To use this package, add `carousel` as a dependency in your pubspec.yaml file. To use this package, add `carousel` as a dependency in your pubspec.yaml file.

View file

@ -1 +1,9 @@
include: package:flutter_lints/flutter.yaml include: package:flutter_iconica_analysis/analysis_options.yaml
# Possible to overwrite the rules from the package
analyzer:
exclude:
linter:
rules:

View file

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2022 Iconica // SPDX-FileCopyrightText: 2022 Iconica
// //
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
/// A Flutter package for creating a carousel widget.
library carousel; library carousel;
export 'package:carousel/src/carousel.dart'; export 'package:carousel/src/carousel.dart';

View file

@ -11,7 +11,8 @@ typedef CarouselCardBuilder = Widget Function(BuildContext context, int index);
class Carousel extends StatefulWidget { class Carousel extends StatefulWidget {
/// Animated cards by swiping. /// Animated cards by swiping.
/// Each card can change its rotation, position and scale when swiping the cards. /// Each card can change its rotation, position
/// and scale when swiping the cards.
/// Transform path can be privided using [transforms] /// Transform path can be privided using [transforms]
const Carousel({ const Carousel({
required this.transforms, required this.transforms,
@ -21,8 +22,10 @@ class Carousel extends StatefulWidget {
this.onPageChanged, this.onPageChanged,
this.alignment = AlignmentDirectional.topStart, this.alignment = AlignmentDirectional.topStart,
this.onCardClick, this.onCardClick,
Key? key, this.initialPage = 0,
}) : super(key: key); this.allowInfiniteScrollingBackwards = false,
super.key,
});
/// A list of transforms to calculate the position of the card when swiping. /// A list of transforms to calculate the position of the card when swiping.
/// Every item in the list is one of the possible card positions. /// Every item in the list is one of the possible card positions.
@ -31,7 +34,8 @@ class Carousel extends StatefulWidget {
/// The index of the transform card which acts as the selected card. /// The index of the transform card which acts as the selected card.
final int selectableCardId; final int selectableCardId;
/// Builder for the card given a [context] and a [index] to identify the right card. /// Builder for the card given a [context] and a [index] to
/// identify the right card.
final CarouselCardBuilder builder; final CarouselCardBuilder builder;
/// Called when selected card is changed to the next one. /// Called when selected card is changed to the next one.
@ -46,16 +50,31 @@ class Carousel extends StatefulWidget {
/// Size of the pageview used to capture swipe gestures. /// Size of the pageview used to capture swipe gestures.
final double pageViewHeight; final double pageViewHeight;
/// The page to show when first creating the [Carousel].
final int initialPage;
/// Whether to allow infinite scrolling backwards. Defaults to false. If true,
/// this works by using a very large number of pages (10000).
/// Works in conjunction with [initialPage].
final bool allowInfiniteScrollingBackwards;
@override @override
State<Carousel> createState() => _CarouselState(); State<Carousel> createState() => _CarouselState();
} }
class _CarouselState extends State<Carousel> { class _CarouselState extends State<Carousel> {
final PageController _pageController = PageController(initialPage: 0); late PageController _pageController;
double _currentPage = 0; double _currentPage = 0;
@override @override
void initState() { void initState() {
_pageController = PageController(
initialPage: widget.allowInfiniteScrollingBackwards
? 10000 + widget.initialPage
: widget.initialPage,
);
_currentPage = _pageController.initialPage.toDouble();
_pageController.addListener(() { _pageController.addListener(() {
_currentPage = _pageController.page!; _currentPage = _pageController.page!;
}); });
@ -69,16 +88,15 @@ class _CarouselState extends State<Carousel> {
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) => Stack(
return Stack(
alignment: widget.alignment, alignment: widget.alignment,
children: [ children: [
AnimatedBuilder( AnimatedBuilder(
animation: _pageController, animation: _pageController,
builder: (context, _) { builder: (context, _) {
final transitionPos = _currentPage % 1; var transitionPos = _currentPage % 1;
final index = _currentPage.floor(); var index = _currentPage.floor();
final length = widget.transforms.length - 1; var length = widget.transforms.length - 1;
return Stack( return Stack(
children: [ children: [
@ -99,8 +117,7 @@ class _CarouselState extends State<Carousel> {
scrollBehavior: _MouseSwipeOnWeb(), scrollBehavior: _MouseSwipeOnWeb(),
onPageChanged: widget.onPageChanged, onPageChanged: widget.onPageChanged,
controller: _pageController, controller: _pageController,
itemBuilder: (context, index) { itemBuilder: (context, index) => Visibility(
return Visibility(
visible: false, visible: false,
maintainState: true, maintainState: true,
maintainAnimation: true, maintainAnimation: true,
@ -120,13 +137,11 @@ class _CarouselState extends State<Carousel> {
), ),
], ],
), ),
); ),
},
), ),
), ),
], ],
); );
}
} }
class _MouseSwipeOnWeb extends MaterialScrollBehavior { class _MouseSwipeOnWeb extends MaterialScrollBehavior {

View file

@ -28,15 +28,14 @@ class CardTransform {
/// [transitionPos] is a position value of a swipe for example. /// [transitionPos] is a position value of a swipe for example.
/// [other] is the position, scale, rotation /// [other] is the position, scale, rotation
/// which the current [CardTransform] need to be transformed to. /// which the current [CardTransform] need to be transformed to.
CardTransform transform(CardTransform other, double transitionPos) { CardTransform transform(CardTransform other, double transitionPos) =>
return CardTransform( CardTransform(
x: _transformValue(x, other.x, transitionPos), x: _transformValue(x, other.x, transitionPos),
y: _transformValue(y, other.y, transitionPos), y: _transformValue(y, other.y, transitionPos),
angle: _transformValue(angle, other.angle, transitionPos), angle: _transformValue(angle, other.angle, transitionPos),
scale: _transformValue(scale, other.scale, transitionPos), scale: _transformValue(scale, other.scale, transitionPos),
opacity: _transformValue(opacity, other.opacity, transitionPos), opacity: _transformValue(opacity, other.opacity, transitionPos),
); );
}
double _transformValue(double valueA, double valueB, double transformPos) => double _transformValue(double valueA, double valueB, double transformPos) =>
valueA - ((valueA - valueB) * transformPos); valueA - ((valueA - valueB) * transformPos);

View file

@ -10,15 +10,14 @@ class CarouselCard extends StatelessWidget {
const CarouselCard({ const CarouselCard({
required this.cardTransform, required this.cardTransform,
required this.child, required this.child,
Key? key, super.key,
}) : super(key: key); });
final CardTransform cardTransform; final CardTransform cardTransform;
final Widget child; final Widget child;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) => Transform.translate(
return Transform.translate(
offset: Offset(cardTransform.x, cardTransform.y), offset: Offset(cardTransform.x, cardTransform.y),
child: Transform.rotate( child: Transform.rotate(
angle: cardTransform.angle, angle: cardTransform.angle,
@ -31,5 +30,4 @@ class CarouselCard extends StatelessWidget {
), ),
), ),
); );
}
} }

View file

@ -1,9 +1,11 @@
name: carousel name: carousel
description: card carousel description: card carousel
version: 0.2.0 version: 0.3.1
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub
environment: environment:
sdk: ">=2.17.6 <3.0.0" sdk: ">=3.0.0 <4.0.0"
flutter: ">=1.17.0" flutter: ">=1.17.0"
dependencies: dependencies:
@ -13,41 +15,9 @@ 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
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter: flutter:
# To add assets to your package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# To add custom fonts to your package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/custom-fonts/#from-packages