Update flutter
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import 'package:tangocard_reader/components/flashcard.dart';
|
||||
import 'package:yokutango_mobile_reader/components/flashcard.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tangocard_reader/models/data_entry.dart';
|
||||
import 'package:tangocard_reader/components/navigation_buttons.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;
|
||||
@@ -16,8 +16,8 @@ class FlashcardPage extends StatefulWidget {
|
||||
required this.onPreviousCard,
|
||||
this.languageFlipped = false,
|
||||
this.index,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
_FlashcardPageState createState() => _FlashcardPageState();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:signature/signature.dart';
|
||||
|
||||
import '../../models/data_entry.dart';
|
||||
@@ -19,105 +20,131 @@ class KanjiPage extends StatefulWidget {
|
||||
this.showDrawingPanel = false,
|
||||
this.showStrokeOrder = false,
|
||||
this.index,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
_KanjiPageState createState() => _KanjiPageState();
|
||||
}
|
||||
|
||||
class _KanjiPageState extends State<KanjiPage> {
|
||||
final focusNode = FocusNode();
|
||||
bool isPressed = false;
|
||||
late final controller = SignatureController(
|
||||
penColor: Theme.of(context).textTheme.bodyText1?.color ?? Colors.black,
|
||||
penColor: Theme.of(context).textTheme.bodyMedium?.color ?? Colors.black,
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
focusNode.requestFocus();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
focusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
if (widget.showDrawingPanel) return;
|
||||
if (isPressed) {
|
||||
controller.clear();
|
||||
widget.onNextCard();
|
||||
return RawKeyboardListener(
|
||||
focusNode: focusNode,
|
||||
onKey: (event) {
|
||||
if (event.isKeyPressed(LogicalKeyboardKey.enter) || event.isKeyPressed(LogicalKeyboardKey.space)) {
|
||||
if (widget.showDrawingPanel) return;
|
||||
if (isPressed) {
|
||||
controller.clear();
|
||||
widget.onNextCard();
|
||||
}
|
||||
setState(() => isPressed = !isPressed);
|
||||
}
|
||||
setState(() => isPressed = !isPressed);
|
||||
},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
if (widget.showDrawingPanel) ...[
|
||||
const SizedBox(width: 20),
|
||||
Signature(
|
||||
controller: controller,
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
if (widget.showDrawingPanel) return;
|
||||
if (isPressed) {
|
||||
controller.clear();
|
||||
widget.onNextCard();
|
||||
}
|
||||
setState(() => isPressed = !isPressed);
|
||||
},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
if (widget.showDrawingPanel) ...[
|
||||
const SizedBox(width: 20),
|
||||
Signature(
|
||||
controller: controller,
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
)
|
||||
],
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
widget.entry.kana.join('\n'),
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
const Divider(thickness: 5),
|
||||
const SizedBox(width: 20),
|
||||
Text(
|
||||
widget.entry.kanji,
|
||||
style: isPressed
|
||||
? Theme.of(context).textTheme.headlineLarge
|
||||
: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineLarge
|
||||
?.merge(const TextStyle(color: Colors.transparent)),
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
const Divider(thickness: 5),
|
||||
if (widget.showDrawingPanel) ...[
|
||||
const SizedBox(width: 20),
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(child: SizedBox()),
|
||||
IconButton(
|
||||
iconSize: 40,
|
||||
onPressed: controller.clear,
|
||||
icon: const Icon(Icons.delete),
|
||||
)
|
||||
],
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
bottom: 40,
|
||||
child: NavigationButtons(
|
||||
middleText:
|
||||
widget.index == null ? 'N' : (widget.index! + 1).toString(),
|
||||
onMiddlePressed: () {
|
||||
if (isPressed) {
|
||||
controller.clear();
|
||||
widget.onNextCard();
|
||||
}
|
||||
setState(() => isPressed = !isPressed);
|
||||
},
|
||||
onNextCard: () => setState(() {
|
||||
if (isPressed) {
|
||||
controller.clear();
|
||||
widget.onNextCard();
|
||||
}
|
||||
setState(() => isPressed = !isPressed);
|
||||
}),
|
||||
onPreviousCard: () => setState(() {
|
||||
controller.clear();
|
||||
isPressed = false;
|
||||
widget.onPreviousCard();
|
||||
}),
|
||||
),
|
||||
)
|
||||
],
|
||||
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),
|
||||
const SizedBox(width: 20),
|
||||
Text(
|
||||
widget.entry.kanji,
|
||||
style: isPressed
|
||||
? Theme.of(context).textTheme.headline1
|
||||
: Theme.of(context)
|
||||
.textTheme
|
||||
.headline1
|
||||
?.merge(const TextStyle(color: Colors.transparent)),
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
const Divider(thickness: 5),
|
||||
if (widget.showDrawingPanel) ...[
|
||||
const SizedBox(width: 20),
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(child: SizedBox()),
|
||||
IconButton(
|
||||
iconSize: 40,
|
||||
onPressed: controller.clear,
|
||||
icon: const Icon(Icons.delete),
|
||||
)
|
||||
],
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
bottom: 40,
|
||||
child: NavigationButtons(
|
||||
middleText:
|
||||
widget.index == null ? 'N' : (widget.index! + 1).toString(),
|
||||
onMiddlePressed: () {
|
||||
if (isPressed) {
|
||||
controller.clear();
|
||||
widget.onNextCard();
|
||||
}
|
||||
setState(() => isPressed = !isPressed);
|
||||
},
|
||||
onNextCard: () => setState(() {
|
||||
if (isPressed) {
|
||||
controller.clear();
|
||||
widget.onNextCard();
|
||||
}
|
||||
setState(() => isPressed = !isPressed);
|
||||
}),
|
||||
onPreviousCard: () => setState(() {
|
||||
controller.clear();
|
||||
isPressed = false;
|
||||
widget.onPreviousCard();
|
||||
}),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tangocard_reader/models/data_entry.dart';
|
||||
import 'package:tangocard_reader/screens/practise/kanji.dart';
|
||||
import 'package:yokutango_mobile_reader/models/data_entry.dart';
|
||||
import 'package:yokutango_mobile_reader/screens/practise/kanji.dart';
|
||||
|
||||
import 'flashcard.dart';
|
||||
|
||||
@@ -15,11 +15,11 @@ class PractiseView extends StatefulWidget {
|
||||
final int index;
|
||||
|
||||
const PractiseView({
|
||||
Key? key,
|
||||
super.key,
|
||||
required this.entries,
|
||||
required this.isKanji,
|
||||
this.index = 0,
|
||||
}) : super(key: key);
|
||||
});
|
||||
|
||||
@override
|
||||
State<PractiseView> createState() => _PractiseViewState();
|
||||
@@ -55,7 +55,7 @@ class _PractiseViewState extends State<PractiseView> {
|
||||
String get randomEncouragingWord =>
|
||||
encouragingWords[Random().nextInt(encouragingWords.length)];
|
||||
bool get isPhone =>
|
||||
MediaQueryData.fromWindow(WidgetsBinding.instance!.window)
|
||||
MediaQueryData.fromWindow(WidgetsBinding.instance.window)
|
||||
.size
|
||||
.shortestSide <
|
||||
600;
|
||||
@@ -103,21 +103,22 @@ class _PractiseViewState extends State<PractiseView> {
|
||||
icon: const Icon(Icons.repeat),
|
||||
),
|
||||
ToggleButtons(
|
||||
selectedColor: Colors.white,
|
||||
children: const [
|
||||
Icon(Icons.shuffle),
|
||||
Icon(Icons.translate),
|
||||
],
|
||||
isSelected: _flashcardToggles,
|
||||
onPressed: (int index) => setState(
|
||||
() {
|
||||
if (index == 0) {
|
||||
isShuffleMode = !_flashcardToggles[index];
|
||||
} else if (index == 1) {
|
||||
isLanguageSwitchedMode = !_flashcardToggles[index];
|
||||
}
|
||||
},
|
||||
)),
|
||||
selectedColor: Colors.white,
|
||||
isSelected: _flashcardToggles,
|
||||
onPressed: (int index) => setState(
|
||||
() {
|
||||
if (index == 0) {
|
||||
isShuffleMode = !_flashcardToggles[index];
|
||||
} else if (index == 1) {
|
||||
isLanguageSwitchedMode = !_flashcardToggles[index];
|
||||
}
|
||||
},
|
||||
),
|
||||
children: const [
|
||||
Icon(Icons.shuffle),
|
||||
Icon(Icons.translate),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
centerTitle: true,
|
||||
@@ -135,20 +136,20 @@ class _PractiseViewState extends State<PractiseView> {
|
||||
),
|
||||
ToggleButtons(
|
||||
selectedColor: Colors.white,
|
||||
children: const [
|
||||
Icon(Icons.edit),
|
||||
Icon(Icons.animation),
|
||||
],
|
||||
isSelected: _kanjiToggles,
|
||||
onPressed: (int index) => setState(
|
||||
() {
|
||||
if (index == 0) {
|
||||
isKanjiDrawingMode = !_flashcardToggles[index];
|
||||
isKanjiDrawingMode = !_kanjiToggles[index];
|
||||
} else if (index == 1) {
|
||||
isKanjiAnimationMode = !_flashcardToggles[index];
|
||||
isKanjiAnimationMode = !_kanjiToggles[index];
|
||||
}
|
||||
},
|
||||
),
|
||||
children: const [
|
||||
Icon(Icons.edit),
|
||||
Icon(Icons.animation),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user