Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gskinner committed Apr 17, 2024
1 parent f40286c commit 03c7a8d
Show file tree
Hide file tree
Showing 238 changed files with 7,340 additions and 2 deletions.
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# 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/
build/

# Additional working files
/__extras
10 changes: 10 additions & 0 deletions .metadata
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: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a"
channel: "stable"

project_type: package
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.exclude": {
"_assets": true
}
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## [0.1.0] - 2024-04-17
### Added
- Initial release
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BSD 3-Clause License

Copyright (c) 2024, gskinner team
Copyright (c) 2024, gskinner.com, inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
119 changes: 118 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,118 @@
# flutter_custom_carousel

Flutter Custom Carousel
================================================================================
A widget for creating fully custom, animated scrollable lists. It manages all of
the tricky logic surrounding scroll interactions and physics, and leaves the
visual presentation of items up to you.

<img src='https://github.com/gskinnerTeam/flutter_custom_carousel/blob/assets/readme_example.gif?raw=true' style='width: 100%'>

Includes an example app (shown above) with a variety of commented demos to learn
from or customize.


Platforms / devices
================================================================================
Currently, this widget is designed for touch input. On desktop, scroll wheel
input can fight with the settling scroll physics. Specifying different `physics`
can resolve this at the cost of settling (aka snapping).

You can also enable scrolling via mouse dragging on desktop by setting a
`scrollBehavior`. Check `main.dart` in the example to see it in use.

Similarly, the included examples target mobile handsets in portrait view to keep
them concise. They include only basic responsiveness.


Basics
================================================================================
Simply pass in a list of children, and define an `effectsBuilder` function.

`effectsBuilder` accepts a child and its current relative scroll position (see
**scrollRatio** below), and returns the child wrapped with widgets that apply
the desired effects.

``` dart
// very basic example that scrolls children vertically from -250px to +250px
CustomCarousel(
children: [card1, card2, etc],
effectsBuilder: (index, scrollRatio, child) =>
Transform.translate(
offset: Offset(0, scrollRatio * 250) ,
child: child
),
)
```

You can further refine visuals by specifying how many children to display before
and after the selection, whether to loop the list, a default alignment, and how
to depth sort children.

Adjust interactions by changing the scroll direction, physics, & speed, enabling
tap to select, or specifying handlers for when the selected item changes, or
when it settles into position.


scrollRatio
----------------------------------------
The `scrollRatio` value ranges from -1 to +1, where 0 is the settled position of
the selected item.

The following animation displays the `scrollRatio` for each item as it scrolls.
It also highlights the "selected" item (white background), and the "settled"
item (thick outline).

<img src='https://github.com/gskinnerTeam/flutter_custom_carousel/blob/assets/readme_scrollratio.gif?raw=true' style='width: 100%'>

Try watching a single item at a time to see how the ratio relates to selection,
settling, and items entering / exiting the visible list. Note that the specific
values are dependent on factors like `itemsBefore` / `itemsAfter`.


ScrollControllers and ScrollPhysics
----------------------------------------
To facilitate item-oriented navigation and looping content CustomCarousel
requires that you use `CustomCarouselScrollController`. This controller also
provides useful features such as `jumpToItem`, `animateToItem`, `nextItem`, and
`previousItem`, as well as smart defaults for animation durations and curves.

Similarly, CustomCarousel defaults to `CustomCarouselScrollPhysics`, which
enables "settling" onto selected items (aka snapping). Adjust the behavior of
the physics by setting the `sticky` and `stiffness` properties. You can use
other scroll physics (such as `BouncingScrollPhysics`) if you don't want this
functionality.


Using with Flutter Animate
================================================================================
You can also use [Flutter Animate](https://pub.dev/packages/flutter_animate) to
define the `effectsBuilder`, leveraging it's broad collection of effects, such
as fading, moving, blurs, shadows, shimmers, color effects, 2.5d flips, and
more.

For example, the simple vertical scroller from above would look like this:

``` dart
// very basic example that scrolls children vertically from -250px to +250px
CustomCarousel(
children: [card1, card2, etc],
effectsBuilder: CustomCarousel.effectsBuilderFromAnimate(
effects: EffectList().moveY(begin: -250, end: 250),
),
)
```

A number of the included examples demonstrate this approach in more depth. See
the docs for `CustomCarousel.effectsBuilderFromAnimate()` for more info.


API reference
================================================================================
For full documentation, see the
[API reference](https://pub.dev/documentation/flutter_custom_carousel/latest/).


Installation
================================================================================
Grab it from
[pub.dev](https://pub.dev/packages/flutter_custom_carousel/install).
7 changes: 7 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include: package:flutter_lints/flutter.yaml

analyzer:
exclude: [__extras/**]

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
43 changes: 43 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# 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
.pub-cache/
.pub/
/build/

# 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
45 changes: 45 additions & 0 deletions example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: android
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: ios
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: linux
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: macos
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: web
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
- platform: windows
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
7 changes: 7 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# example

An example app showing various uses of the `CustomCarousel` widget. Check out
the code in `/lib/views/`.

In particular, `card_deck_view.dart`, `circular_menu_view.dart`, and
`cover_slider_view.dart` have fully commented code to learn from.
28 changes: 28 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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.dev/lints.
#
# 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
13 changes: 13 additions & 0 deletions example/android/.gitignore
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
Loading

0 comments on commit 03c7a8d

Please sign in to comment.