Jisho-Study-Tool/lib/view/components/search/search_result_page/search_card.dart

61 lines
2.0 KiB
Dart
Raw Normal View History

2020-07-09 22:17:10 +02:00
import 'package:flutter/material.dart';
2021-04-11 01:48:43 +02:00
import 'package:jisho_study_tool/view/components/search/search_result_page/parts/common_badge.dart';
import 'package:jisho_study_tool/view/components/search/search_result_page/parts/jlpt_badge.dart';
import 'package:jisho_study_tool/view/components/search/search_result_page/parts/wanikani_badge.dart';
2020-07-09 22:17:10 +02:00
import 'package:unofficial_jisho_api/api.dart';
2021-03-02 23:09:56 +01:00
import './parts/header.dart';
import './parts/senses.dart';
import './parts/other_forms.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] : ''),
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
);
}
}