2020-07-09 22:17:10 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:unofficial_jisho_api/api.dart';
|
|
|
|
|
|
|
|
class _Header extends StatelessWidget {
|
|
|
|
final String _kanji;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(10.0), color: Colors.blue),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(10.0),
|
|
|
|
child: Text(
|
|
|
|
_kanji,
|
2020-07-10 13:28:31 +02:00
|
|
|
style: TextStyle(fontSize: 80.0, color: Colors.white),
|
2020-07-09 22:17:10 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_Header(this._kanji);
|
|
|
|
}
|
|
|
|
|
2020-07-10 15:53:51 +02:00
|
|
|
class _Rank extends StatelessWidget {
|
|
|
|
final int _rank;
|
2020-07-09 22:58:30 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.all(10.0),
|
|
|
|
child: Text(
|
2020-07-10 15:53:51 +02:00
|
|
|
'${_rank.toString()} / 2500',
|
2020-07-09 22:58:30 +02:00
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontSize: 20.0,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
2020-07-10 15:53:51 +02:00
|
|
|
borderRadius: BorderRadius.circular(10.0),
|
2020-07-09 22:58:30 +02:00
|
|
|
color: Colors.blue,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-07-10 15:53:51 +02:00
|
|
|
_Rank(this._rank);
|
2020-07-09 22:58:30 +02:00
|
|
|
}
|
|
|
|
|
2020-07-10 15:53:51 +02:00
|
|
|
class _JlptLevel extends StatelessWidget {
|
|
|
|
final String _jlptLevel;
|
2020-07-10 13:28:31 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.all(10.0),
|
|
|
|
child: Text(
|
2020-07-10 15:53:51 +02:00
|
|
|
_jlptLevel,
|
2020-07-10 13:28:31 +02:00
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontSize: 20.0,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
2020-07-10 15:53:51 +02:00
|
|
|
shape: BoxShape.circle,
|
2020-07-10 13:28:31 +02:00
|
|
|
color: Colors.blue,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-07-10 15:53:51 +02:00
|
|
|
_JlptLevel(this._jlptLevel);
|
2020-07-10 13:28:31 +02:00
|
|
|
}
|
|
|
|
|
2020-07-09 22:58:30 +02:00
|
|
|
class _Grade extends StatelessWidget {
|
|
|
|
final String _grade;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.all(10.0),
|
|
|
|
child: Text(
|
|
|
|
_grade,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontSize: 20.0,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.blue,
|
2020-07-10 15:53:51 +02:00
|
|
|
shape: BoxShape.circle,
|
2020-07-09 22:58:30 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_Grade(this._grade);
|
|
|
|
}
|
|
|
|
|
2020-07-10 13:28:31 +02:00
|
|
|
class _Radical extends StatelessWidget {
|
|
|
|
final Radical _radical;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.all(10.0),
|
|
|
|
child: Text(
|
|
|
|
_radical.symbol,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white,
|
2020-07-10 15:53:51 +02:00
|
|
|
fontSize: 40.0,
|
2020-07-10 13:28:31 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
color: Colors.blue,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_Radical(this._radical);
|
|
|
|
}
|
|
|
|
|
2020-07-09 23:45:31 +02:00
|
|
|
class _StrokeOrderGif extends StatelessWidget {
|
|
|
|
final String _uri;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 20.0),
|
|
|
|
padding: EdgeInsets.all(5.0),
|
2020-07-10 13:28:31 +02:00
|
|
|
child: ClipRRect(
|
|
|
|
child: Image.network(_uri),
|
|
|
|
borderRadius: BorderRadius.circular(10.0),
|
|
|
|
),
|
2020-07-09 23:45:31 +02:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.blue,
|
|
|
|
borderRadius: BorderRadius.circular(15.0),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_StrokeOrderGif(this._uri);
|
|
|
|
}
|
|
|
|
|
2020-07-09 22:17:10 +02:00
|
|
|
class KanjiResultCard extends StatelessWidget {
|
|
|
|
final KanjiResult _result;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
children: [
|
2020-07-10 13:28:31 +02:00
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.fromLTRB(20.0, 20.0, 20.0, 30.0),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
flex: 1,
|
|
|
|
fit: FlexFit.tight,
|
|
|
|
child: Center(child: SizedBox()),
|
|
|
|
),
|
|
|
|
Flexible(
|
|
|
|
flex: 1,
|
|
|
|
fit: FlexFit.tight,
|
|
|
|
child: Center(child: _Header(_result.query)),
|
|
|
|
),
|
|
|
|
Flexible(
|
|
|
|
flex: 1,
|
|
|
|
fit: FlexFit.tight,
|
|
|
|
child: Center(
|
|
|
|
child: _Radical(_result.radical),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2020-07-09 22:17:10 +02:00
|
|
|
),
|
2020-07-10 13:28:31 +02:00
|
|
|
IntrinsicHeight(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
_StrokeOrderGif(_result.strokeOrderGifUri),
|
|
|
|
Container(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text("JLPT: ", style: TextStyle(fontSize: 20.0)),
|
2020-07-10 15:53:51 +02:00
|
|
|
_JlptLevel(_result.jlptLevel ?? "⨉"),
|
2020-07-10 13:28:31 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text("Grade: ", style: TextStyle(fontSize: 20.0)),
|
2020-07-10 15:53:51 +02:00
|
|
|
_Grade(_result.taughtIn ?? "⨉"),
|
2020-07-10 13:28:31 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text("Rank: ", style: TextStyle(fontSize: 20.0)),
|
2020-07-10 15:53:51 +02:00
|
|
|
_Rank(_result.newspaperFrequencyRank ?? -1),
|
2020-07-10 13:28:31 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2020-07-09 23:09:31 +02:00
|
|
|
),
|
2020-07-09 22:17:10 +02:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
KanjiResultCard(this._result);
|
|
|
|
}
|