mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-14 02:41:50 +01:00
h7x4abk3g
2f63c202fc
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
127 lines
3.5 KiB
Dart
127 lines
3.5 KiB
Dart
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,
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|