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

55 lines
1.6 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;
JishoJapaneseWord mainWord;
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) {
return ExpansionTile(
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.is_common)
],
)
],
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),
],
),
padding: EdgeInsets.symmetric(horizontal: 30),
)
2020-08-24 23:45:47 +02:00
],
2020-08-23 00:06:09 +02:00
);
}
}