diff --git a/lib/components/kanji/kanji__search_page/grade.dart b/lib/components/kanji/kanji__search_page/grade.dart new file mode 100644 index 0000000..c7422ea --- /dev/null +++ b/lib/components/kanji/kanji__search_page/grade.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; + +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, + shape: BoxShape.circle, + ), + ); + } + + Grade(this._grade); +} \ No newline at end of file diff --git a/lib/components/kanji/kanji__search_page/header.dart b/lib/components/kanji/kanji__search_page/header.dart new file mode 100644 index 0000000..08d2211 --- /dev/null +++ b/lib/components/kanji/kanji__search_page/header.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.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, + style: TextStyle(fontSize: 80.0, color: Colors.white), + ), + ), + ); + } + + Header(this._kanji); +} \ No newline at end of file diff --git a/lib/components/kanji/kanji__search_page/jlpt_level.dart b/lib/components/kanji/kanji__search_page/jlpt_level.dart new file mode 100644 index 0000000..4f67fd3 --- /dev/null +++ b/lib/components/kanji/kanji__search_page/jlpt_level.dart @@ -0,0 +1,26 @@ + +import 'package:flutter/material.dart'; + +class JlptLevel extends StatelessWidget { + final String _jlptLevel; + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.all(10.0), + child: Text( + _jlptLevel, + style: TextStyle( + color: Colors.white, + fontSize: 20.0, + ), + ), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.blue, + ), + ); + } + + JlptLevel(this._jlptLevel); +} \ No newline at end of file diff --git a/lib/components/kanji/kanji__search_page/kanji_search_page.dart b/lib/components/kanji/kanji__search_page/kanji_search_page.dart new file mode 100644 index 0000000..7ca4080 --- /dev/null +++ b/lib/components/kanji/kanji__search_page/kanji_search_page.dart @@ -0,0 +1,83 @@ +import 'package:flutter/material.dart'; + +import 'package:unofficial_jisho_api/api.dart' as jisho; + +import './grade.dart'; +import './header.dart'; +import './jlpt_level.dart'; +import './radical.dart'; +import './rank.dart'; +import './stroke_order_gif.dart'; + +class KanjiResultCard extends StatelessWidget { + final jisho.KanjiResult _result; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + 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), + ), + ), + ], + ), + ), + 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)), + JlptLevel(_result.jlptLevel ?? "⨉"), + ], + ), + Row( + children: [ + Text("Grade: ", style: TextStyle(fontSize: 20.0)), + Grade(_result.taughtIn ?? "⨉"), + ], + ), + Row( + children: [ + Text("Rank: ", style: TextStyle(fontSize: 20.0)), + Rank(_result.newspaperFrequencyRank ?? -1), + ], + ), + ], + ), + ), + ], + ), + ), + ], + ); + } + + KanjiResultCard(this._result); +} diff --git a/lib/components/kanji/kanji__search_page/radical.dart b/lib/components/kanji/kanji__search_page/radical.dart new file mode 100644 index 0000000..fcc952e --- /dev/null +++ b/lib/components/kanji/kanji__search_page/radical.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; +import 'package:unofficial_jisho_api/api.dart' as jisho; + +class Radical extends StatelessWidget { + final jisho.Radical _radical; + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.all(10.0), + child: Text( + _radical.symbol, + style: TextStyle( + color: Colors.white, + fontSize: 40.0, + ), + ), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.blue, + ), + ); + } + + Radical(this._radical); +} \ No newline at end of file diff --git a/lib/components/kanji/kanji__search_page/rank.dart b/lib/components/kanji/kanji__search_page/rank.dart new file mode 100644 index 0000000..4202398 --- /dev/null +++ b/lib/components/kanji/kanji__search_page/rank.dart @@ -0,0 +1,26 @@ + +import 'package:flutter/material.dart'; + +class Rank extends StatelessWidget { + final int _rank; + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.all(10.0), + child: Text( + '${_rank.toString()} / 2500', + style: TextStyle( + color: Colors.white, + fontSize: 20.0, + ), + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10.0), + color: Colors.blue, + ), + ); + } + + Rank(this._rank); +} \ No newline at end of file diff --git a/lib/components/kanji/kanji__search_page/stroke_order_gif.dart b/lib/components/kanji/kanji__search_page/stroke_order_gif.dart new file mode 100644 index 0000000..e99b7da --- /dev/null +++ b/lib/components/kanji/kanji__search_page/stroke_order_gif.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; + +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), + child: ClipRRect( + child: Image.network(_uri), + borderRadius: BorderRadius.circular(10.0), + ), + decoration: BoxDecoration( + color: Colors.blue, + borderRadius: BorderRadius.circular(15.0), + ), + ); + } + + StrokeOrderGif(this._uri); +} \ No newline at end of file diff --git a/lib/components/kanji/kanji_list.dart b/lib/components/kanji/kanji_list/kanji_list.dart similarity index 100% rename from lib/components/kanji/kanji_list.dart rename to lib/components/kanji/kanji_list/kanji_list.dart diff --git a/lib/components/kanji/kanji_search_page.dart b/lib/components/kanji/kanji_search_page.dart deleted file mode 100644 index a5820ae..0000000 --- a/lib/components/kanji/kanji_search_page.dart +++ /dev/null @@ -1,215 +0,0 @@ -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, - style: TextStyle(fontSize: 80.0, color: Colors.white), - ), - ), - ); - } - - _Header(this._kanji); -} - -class _Rank extends StatelessWidget { - final int _rank; - - @override - Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.all(10.0), - child: Text( - '${_rank.toString()} / 2500', - style: TextStyle( - color: Colors.white, - fontSize: 20.0, - ), - ), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10.0), - color: Colors.blue, - ), - ); - } - - _Rank(this._rank); -} - -class _JlptLevel extends StatelessWidget { - final String _jlptLevel; - - @override - Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.all(10.0), - child: Text( - _jlptLevel, - style: TextStyle( - color: Colors.white, - fontSize: 20.0, - ), - ), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.blue, - ), - ); - } - - _JlptLevel(this._jlptLevel); -} - -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, - shape: BoxShape.circle, - ), - ); - } - - _Grade(this._grade); -} - -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, - fontSize: 40.0, - ), - ), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.blue, - ), - ); - } - - _Radical(this._radical); -} - -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), - child: ClipRRect( - child: Image.network(_uri), - borderRadius: BorderRadius.circular(10.0), - ), - decoration: BoxDecoration( - color: Colors.blue, - borderRadius: BorderRadius.circular(15.0), - ), - ); - } - - _StrokeOrderGif(this._uri); -} - -class KanjiResultCard extends StatelessWidget { - final KanjiResult _result; - - @override - Widget build(BuildContext context) { - return Column( - children: [ - 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), - ), - ), - ], - ), - ), - 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)), - _JlptLevel(_result.jlptLevel ?? "⨉"), - ], - ), - Row( - children: [ - Text("Grade: ", style: TextStyle(fontSize: 20.0)), - _Grade(_result.taughtIn ?? "⨉"), - ], - ), - Row( - children: [ - Text("Rank: ", style: TextStyle(fontSize: 20.0)), - _Rank(_result.newspaperFrequencyRank ?? -1), - ], - ), - ], - ), - ), - ], - ), - ), - ], - ); - } - - KanjiResultCard(this._result); -}