mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-21 13:37:29 +01:00
Squashed commit of the following:
commit 17db40663d761fc989803469620e3af5ae62f674 Author: h7x4 <h7x4abk3g@protonmail.com> Date: Sun Jul 19 23:27:31 2020 +0200 Style examples commit 298add43b7d00961de7524560cd37c704c26b885 Author: h7x4abk3g <h7x4abk3g@protonmail.com> Date: Sat Jul 18 18:49:40 2020 +0200 Add examples
This commit is contained in:
parent
d0ba5b9e88
commit
2f63c202fc
126
lib/components/kanji/kanji__search_page/examples.dart
Normal file
126
lib/components/kanji/kanji__search_page/examples.dart
Normal file
@ -0,0 +1,126 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:unofficial_jisho_api/api.dart';
|
||||
|
||||
class Examples extends StatelessWidget {
|
||||
final List<YomiExample> _onyomiExamples;
|
||||
final List<YomiExample> _kunyomiExamples;
|
||||
|
||||
const Examples(
|
||||
this._onyomiExamples,
|
||||
this._kunyomiExamples,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ExpansionTile(
|
||||
title: Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 10.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue,
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
child: Text(
|
||||
'Examples',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
children: [
|
||||
_onyomiExamples
|
||||
.map((onyomiExample) => _Example(onyomiExample, _KanaType.onyomi))
|
||||
.toList(),
|
||||
_kunyomiExamples
|
||||
.map((kunyomiExample) =>
|
||||
_Example(kunyomiExample, _KanaType.kunyomi))
|
||||
.toList(),
|
||||
].expand((list) => list).toList());
|
||||
}
|
||||
}
|
||||
|
||||
enum _KanaType { kunyomi, onyomi }
|
||||
|
||||
class _Example extends StatelessWidget {
|
||||
final _KanaType _kanaType;
|
||||
final YomiExample _yomiExample;
|
||||
|
||||
const _Example(this._yomiExample, this._kanaType);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(
|
||||
vertical: 10.0,
|
||||
horizontal: 10.0,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey, borderRadius: BorderRadius.circular(10.0)),
|
||||
child: IntrinsicHeight(
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 10.0,
|
||||
horizontal: 10.0,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: (_kanaType == _KanaType.kunyomi)
|
||||
? Colors.lightBlue
|
||||
: Colors.orange,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(10.0),
|
||||
bottomLeft: Radius.circular(10.0),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
child: Text(
|
||||
_yomiExample.reading,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
_yomiExample.example,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 15.0,
|
||||
),
|
||||
Expanded(
|
||||
child: Wrap(
|
||||
children: [
|
||||
Container(
|
||||
child: Text(
|
||||
_yomiExample.meaning,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jisho_study_tool/components/kanji/kanji__search_page/examples.dart';
|
||||
|
||||
import 'package:unofficial_jisho_api/api.dart' as jisho;
|
||||
|
||||
@ -81,6 +82,7 @@ class KanjiResultCard extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
Examples(_result.onyomiExamples, _result.kunyomiExamples),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user