1
0
mirror of https://github.com/h7x4/Jisho-Study-Tool.git synced 2024-12-21 13:37:29 +01:00

Update search card layout

This commit is contained in:
Oystein Kristoffer Tveit 2020-08-24 23:45:47 +02:00
parent 7c4d03e87b
commit c7f6f8c4b2
4 changed files with 62 additions and 6 deletions

View File

@ -10,6 +10,8 @@ class JapaneseHeader extends StatelessWidget {
final hasFurigana = (_word.word != null);
return Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 10.0),
child: Column(
children: [
(hasFurigana) ? Text(_word.reading) : Text(''),

View File

@ -8,9 +8,18 @@ class OtherForms extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: Row(
children: _otherForms.map((form) => _KanaBox(form)).toList(),
));
child: Column(
children: [
Text(
'Other Forms',
style: TextStyle(fontWeight: FontWeight.bold),
),
Row(
children: _otherForms.map((form) => _KanaBox(form)).toList(),
),
],
),
);
}
}
@ -47,4 +56,4 @@ class _KanaBox extends StatelessWidget {
),
);
}
}
}

View File

@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import 'package:unofficial_jisho_api/parser.dart';
class Senses extends StatelessWidget {
final List<JishoWordSense> _senses;
const Senses(this._senses);
@override
Widget build(BuildContext context) {
final List<Widget> _senseWidgets =
_senses.map((sense) => _Sense(sense)).toList();
return Container(
child: Column(
children: _senseWidgets,
));
}
}
class _Sense extends StatelessWidget {
final JishoWordSense _sense;
const _Sense(this._sense);
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: [
Text(
_sense.parts_of_speech.join(', '),
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.left,
),
Column(
children:
_sense.english_definitions.map((def) => Text(def)).toList(),
)
],
),
);
}
}

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:unofficial_jisho_api/api.dart';
import 'parts/header.dart';
import 'parts/senses.dart';
import 'parts/other_forms.dart';
class SearchResultCard extends StatelessWidget {
@ -19,8 +20,10 @@ class SearchResultCard extends StatelessWidget {
Widget build(BuildContext context) {
return ExpansionTile(
title: JapaneseHeader(_mainWord),
children: [OtherForms(_otherForms)],
children: [
Senses(_result.senses),
OtherForms(_otherForms),
],
);
}
}