import 'package:yokutango_mobile_reader/components/flashcard.dart'; import 'package:flutter/material.dart'; import 'package:yokutango_mobile_reader/models/data_entry.dart'; import 'package:yokutango_mobile_reader/components/navigation_buttons.dart'; class FlashcardPage extends StatefulWidget { final YokutangoEntry card; final void Function() onNextCard; final void Function() onPreviousCard; final bool languageFlipped; final int? index; const FlashcardPage({ required this.card, required this.onNextCard, required this.onPreviousCard, this.languageFlipped = false, this.index, super.key, }); @override _FlashcardPageState createState() => _FlashcardPageState(); } class _FlashcardPageState extends State { bool isPressed = false; @override Widget build(BuildContext context) { return GestureDetector( onTap: () { if (isPressed) { widget.onNextCard(); } setState(() { isPressed = !isPressed; }); }, child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.center, children: [ 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, ), ], ), Row( children: [ const Expanded(child: SizedBox()), NavigationButtons( middleText: widget.index == null ? 'N' : (widget.index! + 1).toString(), onNextCard: () => setState(() { isPressed = false; widget.onNextCard(); }), onPreviousCard: () => setState(() { isPressed = false; widget.onPreviousCard(); }), ), const Expanded(child: SizedBox()), ], ) ], ), ); } }