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

81 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import '../../models/data_entry.dart';
import 'navigation_buttons.dart';
class KanjiPage extends StatefulWidget {
final KanjiEntry entry;
final Function() onNextCard;
final Function() onPreviousCard;
final bool showDrawingPanel;
final bool showStrokeOrder;
final int? index;
const KanjiPage({
required this.entry,
required this.onNextCard,
required this.onPreviousCard,
this.showDrawingPanel = false,
this.showStrokeOrder = false,
this.index,
Key? key,
}) : super(key: key);
@override
_KanjiPageState createState() => _KanjiPageState();
}
class _KanjiPageState extends State<KanjiPage> {
bool isPressed = false;
@override
Widget build(BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (isPressed) widget.onNextCard();
setState(() => isPressed = !isPressed);
},
child: Stack(
alignment: Alignment.center,
fit: StackFit.expand,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
widget.entry.kana.join('\n'),
style: Theme.of(context).textTheme.headline3,
),
const SizedBox(width: 20),
const Divider(thickness: 5),
if (isPressed) ...[
const SizedBox(width: 20),
Text(
widget.entry.kanji,
style: Theme.of(context).textTheme.headline1,
),
],
],
),
Positioned(
bottom: 40,
child: NavigationButtons(
middleText:
widget.index == null ? 'N' : (widget.index! + 1).toString(),
onNextCard: () => setState(() {
isPressed = false;
widget.onNextCard();
}),
onPreviousCard: () => setState(() {
isPressed = false;
widget.onPreviousCard();
}),
),
)
],
),
);
}
}