diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..33826d0 --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "pub" + directory: "/" + schedule: + interval: "daily" \ No newline at end of file diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml index 4150827..50bb90a 100644 --- a/.github/workflows/flutter.yml +++ b/.github/workflows/flutter.yml @@ -30,18 +30,3 @@ jobs: run: flutter format -o none --set-exit-if-changed . - name: Flutter analyze run: flutter analyze - test: - 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: Run tests - run: flutter test --coverage diff --git a/README.md b/README.md index 9142298..0b06c8d 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ +[![pub package](https://img.shields.io/pub/v/flutter_carousel.svg)](https://github.com/Iconica-Development) [![Build status](https://img.shields.io/github/workflow/status/Iconica-Development/flutter_carousel/CI)](https://github.com/Iconica-Development/flutter_carousel/actions/new) [![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart) + # Carousel Carousel widget. Makes it easier to create card carousels using a list of transforms. Each card can change its rotation, position and scale when swiping the cards. -Supports all platforms. - -![Demo video](demo.gif) +![Carousel GIF](carousel.gif) ## Usage -To use this package, add `carousel` as a [dependency in your pubspec.yaml file](https://flutter.dev/docs/development/platform-integration/platform-channels). +To use this package, add `carousel` as a dependency in your pubspec.yaml file. -### Example +## How to use -See [Example Code](example/lib/main.dart) for more info. +See the [Example Code](example/lib/main.dart) for an example on how to use this package. ## Issues @@ -24,4 +24,4 @@ If you would like to contribute to the plugin (e.g. by improving the documentati ## Author -This carousel for Flutter is developed by [Iconica](https://iconica.nl). You can contact us at \ No newline at end of file +This `carousel` for Flutter is developed by [Iconica](https://iconica.nl). You can contact us at \ No newline at end of file diff --git a/carousel.gif b/carousel.gif new file mode 100644 index 0000000..5dd080e Binary files /dev/null and b/carousel.gif differ diff --git a/demo.gif b/demo.gif deleted file mode 100644 index 5205c4b..0000000 Binary files a/demo.gif and /dev/null differ diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f..9625e10 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index eab7ec8..bd5da7c 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -272,7 +272,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -350,7 +350,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -399,7 +399,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/lib/extensions/string.dart b/example/lib/extensions/string.dart new file mode 100644 index 0000000..dd0dad3 --- /dev/null +++ b/example/lib/extensions/string.dart @@ -0,0 +1,4 @@ +extension CapitalizeExtension on String { + String capitalize() => + isNotEmpty ? "${this[0].toUpperCase()}${substring(1)}" : this; +} diff --git a/example/lib/main.dart b/example/lib/main.dart index 347c645..218c255 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -6,6 +6,7 @@ import 'package:carousel/carousel.dart'; import 'package:carousel_example/pokemon.dart'; import 'package:carousel_example/pokemon_card.dart'; +import 'package:carousel_example/pokemon_types.dart'; import 'package:flutter/material.dart'; import 'dart:math' as math; @@ -25,14 +26,65 @@ class _CarouselExampleAppState extends State { Pokemon? selected; final List pokemons = [ - Pokemon(name: 'Bulbasaur', nr: 1, types: ['grass', 'poison']), - Pokemon(name: 'Charmander', nr: 4, types: ['fire']), - Pokemon(name: 'Squirtle', nr: 7, types: ['water']), - Pokemon(name: 'Caterpie', nr: 10, types: ['bug']), - Pokemon(name: 'Pidgey', nr: 16, types: ['normal', 'flying']), - Pokemon(name: 'Pikachu', nr: 25, types: ['electric']), - Pokemon(name: 'Machop', nr: 66, types: ['fighting']), - Pokemon(name: 'Geodude', nr: 74, types: ['rock', 'ground']), + Pokemon( + name: 'Bulbasaur', + nr: 1, + types: [ + PokemonType.grass, + PokemonType.poison, + ], + ), + Pokemon( + name: 'Charmander', + nr: 4, + types: [ + PokemonType.fire, + ], + ), + Pokemon( + name: 'Squirtle', + nr: 7, + types: [ + PokemonType.water, + ], + ), + Pokemon( + name: 'Caterpie', + nr: 10, + types: [ + PokemonType.bug, + ], + ), + Pokemon( + name: 'Pidgey', + nr: 16, + types: [ + PokemonType.normal, + PokemonType.flying, + ], + ), + Pokemon( + name: 'Pikachu', + nr: 25, + types: [ + PokemonType.electric, + ], + ), + Pokemon( + name: 'Machop', + nr: 66, + types: [ + PokemonType.fighting, + ], + ), + Pokemon( + name: 'Geodude', + nr: 74, + types: [ + PokemonType.rock, + PokemonType.ground, + ], + ), ]; Widget _buildCard(BuildContext context, int index) { @@ -54,7 +106,8 @@ class _CarouselExampleAppState extends State { body: Stack( alignment: Alignment.bottomCenter, children: [ - SafeArea( + Padding( + padding: const EdgeInsets.all(16.0), child: ListView( children: [ const SizedBox(height: 50), @@ -125,7 +178,7 @@ class _CarouselExampleAppState extends State { ), if (selected != null) Padding( - padding: const EdgeInsets.only(bottom: 10), + padding: const EdgeInsets.only(bottom: 20), child: Text('Clicked: ${selected!.name}'), ), ], diff --git a/example/lib/pokemon.dart b/example/lib/pokemon.dart index af885e9..00fecd7 100644 --- a/example/lib/pokemon.dart +++ b/example/lib/pokemon.dart @@ -2,6 +2,8 @@ // // SPDX-License-Identifier: BSD-3-Clause +import 'package:carousel_example/pokemon_types.dart'; + class Pokemon { Pokemon({ required this.name, @@ -10,5 +12,5 @@ class Pokemon { }); String name; int nr; - List types = const []; + List types = const []; } diff --git a/example/lib/pokemon_card.dart b/example/lib/pokemon_card.dart index dd3911d..96c64f8 100644 --- a/example/lib/pokemon_card.dart +++ b/example/lib/pokemon_card.dart @@ -2,7 +2,9 @@ // // SPDX-License-Identifier: BSD-3-Clause +import 'package:carousel_example/extensions/string.dart'; import 'package:carousel_example/pokemon.dart'; +import 'package:carousel_example/pokemon_types.dart'; import 'package:flutter/material.dart'; class PokemonCard extends StatelessWidget { @@ -20,9 +22,11 @@ class PokemonCard extends StatelessWidget { width: MediaQuery.of(context).size.width / 2.2, height: 220, decoration: BoxDecoration( - color: Colors.blue.shade700, + color: Colors.white, boxShadow: const [ - BoxShadow(blurRadius: 4), + BoxShadow( + blurRadius: 8, + ), ], borderRadius: BorderRadius.circular(15), ), @@ -40,29 +44,12 @@ class PokemonCard extends StatelessWidget { ), Padding( padding: const EdgeInsets.only(top: 20, bottom: 8), - child: Text('Types', style: textStyle), + child: Text('Type', style: textStyle), ), Row( children: [ for (var type in pokemon.types) ...[ - Container( - height: 25, - width: 60, - margin: const EdgeInsets.only(right: 10), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - color: Color(type.hashCode).withAlpha(255), - ), - child: Center( - child: Text( - type, - style: const TextStyle( - color: Colors.white, - ), - textAlign: TextAlign.center, - ), - ), - ) + TypeBadge(type: type), ], ], ), @@ -72,3 +59,77 @@ class PokemonCard extends StatelessWidget { ); } } + +class TypeBadge extends StatelessWidget { + const TypeBadge({ + super.key, + required this.type, + }); + + final PokemonType type; + + @override + Widget build(BuildContext context) { + return Container( + height: 25, + width: 60, + margin: const EdgeInsets.only(right: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: getTypeColor(type), + ), + child: Center( + child: Text( + type.name.capitalize(), + style: const TextStyle( + color: Colors.white, + ), + textAlign: TextAlign.center, + ), + ), + ); + } + + Color getTypeColor(PokemonType type) { + switch (type) { + case PokemonType.fire: + return const Color(0xFFF08030); + case PokemonType.water: + return const Color(0xFF6890F0); + case PokemonType.grass: + return const Color(0xFF78C850); + case PokemonType.normal: + return const Color(0xFFA8A878); + case PokemonType.electric: + return const Color(0xFFF8D030); + case PokemonType.ice: + return const Color(0xFF98D8D8); + case PokemonType.fighting: + return const Color(0xFFC03028); + case PokemonType.poison: + return const Color(0xFFA040A0); + case PokemonType.ground: + return const Color(0xFFE0C068); + case PokemonType.flying: + return const Color(0xFFA890F0); + case PokemonType.psychic: + return const Color(0xFFF85888); + case PokemonType.bug: + return const Color(0xFFA8B820); + case PokemonType.rock: + return const Color(0xFFB8A038); + case PokemonType.ghost: + return const Color(0xFF705898); + case PokemonType.dark: + return const Color(0xFF705848); + case PokemonType.dragon: + return const Color(0xFF7038F8); + case PokemonType.steel: + return const Color(0xFFB8B8D0); + case PokemonType.fairy: + return const Color(0xFFEE99AC); + default: + return const Color(0xFF68A090); + } + } +} diff --git a/example/lib/pokemon_types.dart b/example/lib/pokemon_types.dart new file mode 100644 index 0000000..1504291 --- /dev/null +++ b/example/lib/pokemon_types.dart @@ -0,0 +1,20 @@ +enum PokemonType { + fire, + water, + grass, + normal, + electric, + ice, + fighting, + poison, + ground, + flying, + psychic, + bug, + rock, + ghost, + dark, + dragon, + steel, + fairy, +} \ No newline at end of file