From e994d73506b5fcb4c38e1aecabb9bdcbfa088665 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Sun, 23 Jan 2022 16:25:43 +0100 Subject: [PATCH] Make kanji widgets squared --- .../search_results_body/parts/kanji.dart | 53 +++++++++++++------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/lib/components/search/search_results_body/parts/kanji.dart b/lib/components/search/search_results_body/parts/kanji.dart index 5fc9ac7..f631525 100644 --- a/lib/components/search/search_results_body/parts/kanji.dart +++ b/lib/components/search/search_results_body/parts/kanji.dart @@ -5,18 +5,50 @@ import '../../../../routing/routes.dart'; class KanjiRow extends StatelessWidget { final List kanji; + final double fontSize; const KanjiRow({ Key? key, required this.kanji, + this.fontSize = 20, }) : super(key: key); + Widget _kanjiBox(String kanji) => UnconstrainedBox( + child: IntrinsicHeight( + child: AspectRatio( + aspectRatio: 1, + child: BlocBuilder( + builder: (context, state) { + final colors = state.theme.menuGreyLight; + return Container( + padding: const EdgeInsets.all(10), + alignment: Alignment.center, + decoration: BoxDecoration( + color: colors.background, + borderRadius: BorderRadius.circular(10), + ), + child: FittedBox( + child: Text( + kanji, + style: TextStyle( + color: colors.foreground, + fontSize: fontSize, + ), + ), + ), + ); + }, + ), + ), + ), + ); + @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( - 'Kanji', + 'Kanji:', style: TextStyle(fontWeight: FontWeight.bold), ), const SizedBox(height: 5), @@ -26,21 +58,12 @@ class KanjiRow extends StatelessWidget { children: kanji .map( (k) => InkWell( - onTap: () => Navigator.pushNamed(context, Routes.kanjiSearch, arguments: k), - child: BlocBuilder( - builder: (context, state) { - final colors = state.theme.menuGreyLight; - return Container( - padding: const EdgeInsets.all(10), - decoration: BoxDecoration( - color: colors.background, - borderRadius: BorderRadius.circular(10), - ), - child: - Text(k, style: TextStyle(color: colors.foreground, fontSize: 25)), - ); - }, + onTap: () => Navigator.pushNamed( + context, + Routes.kanjiSearch, + arguments: k, ), + child: _kanjiBox(k), ), ) .toList(),