1
0
mirror of https://github.com/h7x4/Jisho-Study-Tool.git synced 2024-12-14 10:46:53 +01:00
Jisho-Study-Tool/lib/components/kanji/kanji__search_page/kunyomi.dart

78 lines
1.7 KiB
Dart
Raw Normal View History

2020-07-12 23:58:30 +02:00
import 'package:flutter/material.dart';
class Kunyomi extends StatelessWidget {
2020-07-14 15:39:31 +02:00
final List<String> _kunyomi;
2020-07-16 22:49:07 +02:00
List<_KunyomiCard> _kunyomiCards;
bool _expandable;
Kunyomi(this._kunyomi) {
_kunyomiCards = _kunyomi.map((kunyomi) => _KunyomiCard(kunyomi)).toList();
_expandable = (_kunyomi.length > 6);
}
2020-07-14 15:39:31 +02:00
2020-07-12 23:58:30 +02:00
@override
Widget build(BuildContext context) {
return Container(
2020-07-16 14:09:03 +02:00
margin: EdgeInsets.symmetric(
horizontal: 10.0,
vertical: 5.0,
),
alignment: Alignment.centerLeft,
2020-07-16 22:49:07 +02:00
child: _KunyomiWrapper(context),
);
}
Widget _KunyomiWrapper(BuildContext context) {
if (_expandable) {
return ExpansionTile(
initiallyExpanded: false,
title: Center(child: _KunyomiCard('Kunyomi')),
children: [
SizedBox(
height: 20.0,
),
Wrap(
runSpacing: 10.0,
children: _kunyomiCards,
),
SizedBox(
height: 25.0,
),
],
);
} else {
return Wrap(
2020-07-16 14:09:03 +02:00
runSpacing: 10.0,
2020-07-16 22:49:07 +02:00
children: _kunyomiCards,
);
}
}
}
class _KunyomiCard extends StatelessWidget {
final String _kunyomi;
const _KunyomiCard(this._kunyomi);
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 10.0),
padding: EdgeInsets.symmetric(
vertical: 10.0,
horizontal: 10.0,
),
child: Text(
_kunyomi,
style: TextStyle(
fontSize: 20.0,
color: Colors.white,
),
),
decoration: BoxDecoration(
color: Colors.lightBlue,
borderRadius: BorderRadius.circular(10.0),
2020-07-14 15:39:31 +02:00
),
2020-07-12 23:58:30 +02:00
);
}
2020-07-14 15:39:31 +02:00
}