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-03-03 00:24:25 +01:00
|
|
|
SearchResultCard(this.result) {
|
|
|
|
this.mainWord = result.japanese[0];
|
|
|
|
this.otherForms = result.japanese.sublist(1);
|
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-04-11 01:48:43 +02:00
|
|
|
title:
|
|
|
|
IntrinsicWidth(
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
JapaneseHeader(mainWord),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
WKBadge(result.tags.firstWhere((tag) => tag.contains("wanikani"), orElse: () => '')),
|
|
|
|
JLPTBadge(result.jlpt.isNotEmpty ? result.jlpt[0] : ''),
|
2021-08-03 22:13:50 +02:00
|
|
|
CommonBadge(result.isCommon ?? false)
|
2021-04-11 01:48:43 +02:00
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
),
|
|
|
|
),
|
2020-08-24 23:45:47 +02:00
|
|
|
children: [
|
2021-04-11 01:48:43 +02:00
|
|
|
Container(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Senses(result.senses),
|
|
|
|
OtherForms(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
|
|
|
],
|
|
|
|
),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 30),
|
|
|
|
)
|
2020-08-24 23:45:47 +02:00
|
|
|
],
|
2020-08-23 00:06:09 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|