diff --git a/example/README.md b/example/README.md deleted file mode 100644 index 2b3fce4..0000000 --- a/example/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# example - -A new Flutter project. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) - -For help getting started with Flutter development, view the -[online documentation](https://docs.flutter.dev/), which offers tutorials, -samples, guidance on mobile development, and a full API reference. diff --git a/example/lib/example_buttons.dart b/example/lib/example_buttons.dart deleted file mode 100644 index c8f5dd0..0000000 --- a/example/lib/example_buttons.dart +++ /dev/null @@ -1,80 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_card_swiper/flutter_card_swiper.dart'; - -class ExampleButton extends StatelessWidget { - final Function onTap; - final Widget child; - - const ExampleButton({ - required this.onTap, - required this.child, - Key? key, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return GestureDetector( - onTap: () => onTap(), - child: child, - ); - } -} - -//swipe card to the right side -Widget swipeRightButton(CardSwiperController controller) { - return ExampleButton( - onTap: () => controller.swipeRight(), - child: Container( - height: 60, - width: 60, - decoration: BoxDecoration( - color: CupertinoColors.activeGreen, - borderRadius: BorderRadius.circular(50), - boxShadow: [ - BoxShadow( - color: CupertinoColors.activeGreen.withOpacity(0.9), - spreadRadius: -10, - blurRadius: 20, - offset: const Offset(0, 20), // changes position of shadow - ), - ], - ), - alignment: Alignment.center, - child: const Icon( - Icons.check, - color: CupertinoColors.white, - size: 40, - ), - ), - ); -} - -//swipe card to the left side -Widget swipeLeftButton(CardSwiperController controller) { - return ExampleButton( - onTap: () => controller.swipeLeft(), - child: Container( - height: 60, - width: 60, - decoration: BoxDecoration( - color: const Color(0xFFFF3868), - borderRadius: BorderRadius.circular(50), - boxShadow: [ - BoxShadow( - color: const Color(0xFFFF3868).withOpacity(0.9), - spreadRadius: -10, - blurRadius: 20, - offset: const Offset(0, 20), // changes position of shadow - ), - ], - ), - alignment: Alignment.center, - child: const Icon( - Icons.close, - color: CupertinoColors.white, - size: 40, - ), - ), - ); -} diff --git a/example/lib/example_candidate_model.dart b/example/lib/example_candidate_model.dart index d90820b..006f8db 100644 --- a/example/lib/example_candidate_model.dart +++ b/example/lib/example_candidate_model.dart @@ -1,75 +1,42 @@ import 'package:flutter/cupertino.dart'; class ExampleCandidateModel { - String? name; - String? job; - String? city; - LinearGradient? color; + String name; + String job; + String city; + List color; ExampleCandidateModel({ - this.name, - this.job, - this.city, - this.color, + required this.name, + required this.job, + required this.city, + required this.color, }); } List candidates = [ ExampleCandidateModel( - name: 'Two, 2', - job: 'Manager', - city: 'Town', - color: gradientPurple, + name: 'One, 1', + job: 'Developer', + city: 'Areado', + color: [Color(0xFFFF3868), Color(0xFFFFB49A)], ), ExampleCandidateModel( - name: 'One, 1', + name: 'Two, 2', job: 'Manager', - city: 'Town', - color: gradientRed, + city: 'New York', + color: [Color(0xFF736EFE), Color(0xFF62E4EC)], + ), + ExampleCandidateModel( + name: 'Three, 3', + job: 'Engineer', + city: 'London', + color: [Color(0xFF2F80ED), Color(0xFF56CCF2)], + ), + ExampleCandidateModel( + name: 'Four, 4', + job: 'Designer', + city: 'Tokyo', + color: [Color(0xFF0BA4E0), Color(0xFFA9E4BD)], ), ]; - -const LinearGradient gradientRed = LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Color(0xFFFF3868), - Color(0xFFFFB49A), - ], -); - -const LinearGradient gradientPurple = LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Color(0xFF736EFE), - Color(0xFF62E4EC), - ], -); - -const LinearGradient gradientBlue = LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Color(0xFF0BA4E0), - Color(0xFFA9E4BD), - ], -); - -const LinearGradient gradientPink = LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Color(0xFFFF6864), - Color(0xFFFFB92F), - ], -); - -const LinearGradient kNewFeedCardColorsIdentityGradient = LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Color(0xFF7960F1), - Color(0xFFE1A5C9), - ], -); diff --git a/example/lib/example_card.dart b/example/lib/example_card.dart index 1d340a9..3faf1ca 100644 --- a/example/lib/example_card.dart +++ b/example/lib/example_card.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'example_candidate_model.dart'; @@ -6,20 +5,21 @@ import 'example_candidate_model.dart'; class ExampleCard extends StatelessWidget { final ExampleCandidateModel candidate; - const ExampleCard({ + const ExampleCard( + this.candidate, { Key? key, - required this.candidate, }) : super(key: key); @override Widget build(BuildContext context) { return Container( + clipBehavior: Clip.hardEdge, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - color: CupertinoColors.white, + color: Colors.white, boxShadow: [ BoxShadow( - color: CupertinoColors.systemGrey.withOpacity(0.2), + color: Colors.grey.withOpacity(0.2), spreadRadius: 3, blurRadius: 7, offset: const Offset(0, 3), @@ -28,64 +28,45 @@ class ExampleCard extends StatelessWidget { ), alignment: Alignment.center, child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Flexible( child: Container( decoration: BoxDecoration( - gradient: candidate.color, - borderRadius: const BorderRadius.only( - topLeft: Radius.circular(10), - topRight: Radius.circular(10), + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: candidate.color, ), ), ), ), - Container( - padding: const EdgeInsets.all(15), - decoration: const BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(10), - bottomRight: Radius.circular(10), - ), - ), - child: Row( + Padding( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - candidate.name!, - style: const TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: 20, - ), - ), - const SizedBox( - height: 5, - ), - Text( - candidate.job!, - style: const TextStyle( - color: Colors.grey, - fontSize: 15, - ), - ), - const SizedBox( - height: 5, - ), - Text( - candidate.city!, - style: const TextStyle( - color: Colors.grey, - fontSize: 15, - ), - ) - ], + Text( + candidate.name, + style: const TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 20, + ), ), + const SizedBox(height: 5), + Text( + candidate.job, + style: const TextStyle( + color: Colors.grey, + fontSize: 15, + ), + ), + const SizedBox(height: 5), + Text( + candidate.city, + style: const TextStyle(color: Colors.grey), + ) ], ), ), diff --git a/example/lib/main.dart b/example/lib/main.dart index b366a5c..2c97e95 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -2,27 +2,14 @@ import 'dart:developer'; import 'package:example/example_candidate_model.dart'; import 'package:example/example_card.dart'; -import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_card_swiper/flutter_card_swiper.dart'; -import 'example_buttons.dart'; - void main() { - runApp(const MyApp()); -} - -class MyApp extends StatelessWidget { - const MyApp({ - Key? key, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return const CupertinoApp( - debugShowCheckedModeBanner: false, - home: Example(), - ); - } + runApp(const MaterialApp( + debugShowCheckedModeBanner: false, + home: Example(), + )); } class Example extends StatefulWidget { @@ -37,57 +24,44 @@ class Example extends StatefulWidget { class _ExamplePageState extends State { final CardSwiperController controller = CardSwiperController(); - List cards = []; - - @override - void initState() { - _loadCards(); - super.initState(); - } - - void _loadCards() { - for (ExampleCandidateModel candidate in candidates) { - cards.add( - ExampleCard( - candidate: candidate, - ), - ); - } - } + final cards = candidates.map((candidate) => ExampleCard(candidate)).toList(); @override Widget build(BuildContext context) { - return CupertinoPageScaffold( - child: Column( - children: [ - const SizedBox( - height: 50, - ), - SizedBox( - height: MediaQuery.of(context).size.height * 0.75, - child: CardSwiper( - controller: controller, - cards: cards, - onSwipe: _swipe, - padding: const EdgeInsets.only( - left: 25, - right: 25, - top: 50, - bottom: 40, + return Scaffold( + body: SafeArea( + child: Column( + children: [ + Flexible( + child: CardSwiper( + controller: controller, + cards: cards, + onSwipe: _swipe, + padding: const EdgeInsets.all(24.0), ), ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - swipeLeftButton(controller), - const SizedBox( - width: 20, + Padding( + padding: EdgeInsets.symmetric(vertical: 16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + FloatingActionButton( + onPressed: controller.swipe, + child: Icon(Icons.rotate_right), + ), + FloatingActionButton( + onPressed: controller.swipeLeft, + child: Icon(Icons.keyboard_arrow_left), + ), + FloatingActionButton( + onPressed: controller.swipeRight, + child: Icon(Icons.keyboard_arrow_right), + ), + ], ), - swipeRightButton(controller), - ], - ) - ], + ) + ], + ), ), ); } diff --git a/example/pubspec.lock b/example/pubspec.lock index f4c40de..2a9e3e7 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -26,7 +26,7 @@ packages: path: ".." relative: true source: path - version: "1.0.0" + version: "1.0.2" material_color_utilities: dependency: transitive description: