2020-07-09 22:17:10 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:unofficial_jisho_api/api.dart';
|
|
|
|
|
2021-09-07 00:05:33 +02:00
|
|
|
import './parts/common_badge.dart';
|
2021-03-02 23:09:56 +01:00
|
|
|
import './parts/header.dart';
|
2021-09-07 00:05:33 +02:00
|
|
|
import './parts/jlpt_badge.dart';
|
2021-03-02 23:09:56 +01:00
|
|
|
import './parts/other_forms.dart';
|
2021-09-07 00:05:33 +02:00
|
|
|
import './parts/senses.dart';
|
|
|
|
import './parts/wanikani_badge.dart';
|
2020-08-23 00:38:42 +02:00
|
|
|
|
2020-07-09 22:17:10 +02:00
|
|
|
class SearchResultCard extends StatelessWidget {
|
2021-03-03 00:24:25 +01:00
|
|
|
final JishoResult result;
|
2021-07-26 21:39:17 +02:00
|
|
|
late final JishoJapaneseWord mainWord;
|
|
|
|
late final List<JishoJapaneseWord> otherForms;
|
2020-08-23 00:06:09 +02:00
|
|
|
|
2021-12-01 23:09:53 +01:00
|
|
|
SearchResultCard({
|
|
|
|
required this.result,
|
|
|
|
Key? key,
|
|
|
|
}) : mainWord = result.japanese[0],
|
|
|
|
otherForms = result.japanese.sublist(1),
|
|
|
|
super(key: key);
|
2020-08-23 00:06:09 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-08-08 23:16:54 +02:00
|
|
|
final backgroundColor = Theme.of(context).scaffoldBackgroundColor;
|
2020-08-23 00:06:09 +02:00
|
|
|
return ExpansionTile(
|
2021-08-08 23:16:54 +02:00
|
|
|
collapsedBackgroundColor: backgroundColor,
|
|
|
|
backgroundColor: backgroundColor,
|
2021-12-01 23:09:53 +01:00
|
|
|
title: IntrinsicWidth(
|
2021-04-11 01:48:43 +02:00
|
|
|
child: Row(
|
2021-12-01 23:09:53 +01:00
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
2021-04-11 01:48:43 +02:00
|
|
|
children: [
|
2021-12-01 23:09:53 +01:00
|
|
|
JapaneseHeader(word: mainWord),
|
2021-04-11 01:48:43 +02:00
|
|
|
Row(
|
|
|
|
children: [
|
2021-12-01 23:09:53 +01:00
|
|
|
WKBadge(
|
2021-12-04 05:22:58 +01:00
|
|
|
level: result.tags.firstWhere(
|
2021-12-01 23:09:53 +01:00
|
|
|
(tag) => tag.contains('wanikani'),
|
|
|
|
orElse: () => '',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
JLPTBadge(
|
|
|
|
jlptLevel: result.jlpt.isNotEmpty ? result.jlpt[0] : '',
|
|
|
|
),
|
|
|
|
CommonBadge(isCommon: result.isCommon ?? false)
|
2021-04-11 01:48:43 +02:00
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2020-08-24 23:45:47 +02:00
|
|
|
children: [
|
2021-04-11 01:48:43 +02:00
|
|
|
Container(
|
2021-12-01 23:09:53 +01:00
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 30),
|
2021-04-11 01:48:43 +02:00
|
|
|
child: Column(
|
|
|
|
children: [
|
2021-12-01 23:09:53 +01:00
|
|
|
Senses(senses: result.senses),
|
|
|
|
OtherForms(forms: otherForms),
|
2021-07-17 12:19:03 +02:00
|
|
|
// Text(result.toJson().toString()),
|
|
|
|
// Text(result.attribution.toJson().toString()),
|
|
|
|
// Text(result.japanese.map((e) => e.toJson().toString()).toList().toString()),
|
2021-04-11 01:48:43 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
2020-08-24 23:45:47 +02:00
|
|
|
],
|
2020-08-23 00:06:09 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|