mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-21 13:37:29 +01:00
Modularize search_card parts
This commit is contained in:
parent
5681b9708c
commit
c4e5fdd9ff
21
lib/components/search/parts/header.dart
Normal file
21
lib/components/search/parts/header.dart
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:unofficial_jisho_api/api.dart';
|
||||||
|
|
||||||
|
class JapaneseHeader extends StatelessWidget {
|
||||||
|
final JishoJapaneseWord _word;
|
||||||
|
const JapaneseHeader(this._word);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final hasFurigana = (_word.word != null);
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
(hasFurigana) ? Text(_word.reading) : Text(''),
|
||||||
|
(hasFurigana) ? Text(_word.word) : Text(_word.reading),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
50
lib/components/search/parts/other_forms.dart
Normal file
50
lib/components/search/parts/other_forms.dart
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:unofficial_jisho_api/api.dart';
|
||||||
|
|
||||||
|
class OtherForms extends StatelessWidget {
|
||||||
|
final List<JishoJapaneseWord> _otherForms;
|
||||||
|
OtherForms(this._otherForms);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
child: Row(
|
||||||
|
children: _otherForms.map((form) => _KanaBox(form)).toList(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _KanaBox extends StatelessWidget {
|
||||||
|
final JishoJapaneseWord _word;
|
||||||
|
const _KanaBox(this._word);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final hasFurigana = (_word.word != null);
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
(hasFurigana) ? Text(_word.reading) : Text(''),
|
||||||
|
(hasFurigana) ? Text(_word.word) : Text(_word.reading),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
margin: EdgeInsets.symmetric(
|
||||||
|
horizontal: 5.0,
|
||||||
|
vertical: 5.0,
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.all(5.0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.grey.withOpacity(0.5),
|
||||||
|
spreadRadius: 1,
|
||||||
|
blurRadius: 0.5,
|
||||||
|
offset: Offset(1, 1),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,9 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import 'package:unofficial_jisho_api/api.dart';
|
import 'package:unofficial_jisho_api/api.dart';
|
||||||
|
|
||||||
|
import 'parts/header.dart';
|
||||||
|
import 'parts/other_forms.dart';
|
||||||
|
|
||||||
class SearchResultCard extends StatelessWidget {
|
class SearchResultCard extends StatelessWidget {
|
||||||
final JishoResult _result;
|
final JishoResult _result;
|
||||||
JishoJapaneseWord _mainWord;
|
JishoJapaneseWord _mainWord;
|
||||||
@ -15,68 +18,9 @@ class SearchResultCard extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ExpansionTile(
|
return ExpansionTile(
|
||||||
title: _JapaneseHeader(_mainWord),
|
title: JapaneseHeader(_mainWord),
|
||||||
children: [_OtherForms(_otherForms)],
|
children: [OtherForms(_otherForms)],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _JapaneseHeader extends StatelessWidget {
|
|
||||||
final JishoJapaneseWord _word;
|
|
||||||
const _JapaneseHeader(this._word);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
child: _KanaBox(_word),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _OtherForms extends StatelessWidget {
|
|
||||||
final List<JishoJapaneseWord> _otherForms;
|
|
||||||
_OtherForms(this._otherForms);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
child: Row(
|
|
||||||
children: _otherForms.map((form) => _KanaBox(form)).toList(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _KanaBox extends StatelessWidget {
|
|
||||||
final JishoJapaneseWord _word;
|
|
||||||
const _KanaBox(this._word);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final hasFurigana = (_word.word != null);
|
|
||||||
|
|
||||||
return Container(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
(hasFurigana) ? Text(_word.reading) : Text(''),
|
|
||||||
(hasFurigana) ? Text(_word.word) : Text(_word.reading),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
margin: EdgeInsets.symmetric(
|
|
||||||
horizontal: 5.0,
|
|
||||||
vertical: 5.0,
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.all(5.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.grey.withOpacity(0.5),
|
|
||||||
spreadRadius: 1,
|
|
||||||
blurRadius: 0.5,
|
|
||||||
offset: Offset(1, 1),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user