39 lines
1.1 KiB
Dart
39 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:swipable_stack/swipable_stack.dart';
|
|
|
|
class CardOverlay extends StatelessWidget {
|
|
final double swipeProgress;
|
|
final SwipeDirection direction;
|
|
|
|
const CardOverlay({
|
|
super.key,
|
|
required this.swipeProgress,
|
|
required this.direction,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Positioned.fill(
|
|
bottom: 300,
|
|
child: Opacity(
|
|
opacity: swipeProgress.abs().clamp(0.0, 1.0),
|
|
child: Align(
|
|
alignment: direction == SwipeDirection.right
|
|
? Alignment.centerLeft
|
|
: (direction == SwipeDirection.left
|
|
? Alignment.centerRight
|
|
: Alignment.center),
|
|
child: Icon(
|
|
direction == SwipeDirection.right
|
|
? Icons.thumb_up
|
|
: (direction == SwipeDirection.left ? Icons.thumb_down : null),
|
|
size: 100,
|
|
color: direction == SwipeDirection.right
|
|
? Colors.green
|
|
: (direction == SwipeDirection.left ? Colors.red : Colors.blue),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |