yokutango-mobile-reader/lib/screens/practise/flashcard.dart

61 lines
1.4 KiB
Dart
Raw Normal View History

2022-01-26 00:25:07 +01:00
import 'package:tangocard_reader/components/flashcard.dart';
import 'package:flutter/material.dart';
2022-01-26 01:58:47 +01:00
import 'package:tangocard_reader/models/data_entry.dart';
2022-01-26 00:25:07 +01:00
2022-01-29 19:16:13 +01:00
class FlashcardPage extends StatefulWidget {
2022-01-26 00:25:07 +01:00
final YokutangoEntry card;
final Function() onNextCard;
final bool languageFlipped;
final int? index;
2022-01-29 19:16:13 +01:00
const FlashcardPage({
2022-01-26 00:25:07 +01:00
required this.card,
required this.onNextCard,
this.languageFlipped = false,
this.index,
Key? key,
}) : super(key: key);
@override
_FlashcardPageState createState() => _FlashcardPageState();
}
2022-01-29 19:16:13 +01:00
class _FlashcardPageState extends State<FlashcardPage> {
2022-01-26 00:25:07 +01:00
bool isPressed = false;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
if (isPressed) {
widget.onNextCard();
}
setState(() {
isPressed = !isPressed;
});
},
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flashcard(
card: widget.card,
cardIndex: widget.index,
isLeftSide: true,
languageFlipped: widget.languageFlipped,
),
const SizedBox(width: 40),
Flashcard(
card: isPressed ? widget.card : null,
cardIndex: widget.index,
languageFlipped: widget.languageFlipped,
),
],
),
),
);
}
}