2022-01-23 18:27:00 +01:00
|
|
|
import 'package:collection/collection.dart';
|
2020-08-24 23:45:47 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-01-23 18:27:00 +01:00
|
|
|
import 'package:unofficial_jisho_api/api.dart';
|
|
|
|
|
|
|
|
import 'sense/sense.dart';
|
2020-08-24 23:45:47 +02:00
|
|
|
|
|
|
|
class Senses extends StatelessWidget {
|
2021-03-03 00:24:25 +01:00
|
|
|
final List<JishoWordSense> senses;
|
2022-01-23 18:27:00 +01:00
|
|
|
final List<PhraseScrapeMeaning>? extraData;
|
2021-12-01 23:09:53 +01:00
|
|
|
|
|
|
|
const Senses({
|
|
|
|
required this.senses,
|
2022-01-23 18:27:00 +01:00
|
|
|
this.extraData,
|
2021-12-01 23:09:53 +01:00
|
|
|
Key? key,
|
|
|
|
}) : super(key: key);
|
2020-08-24 23:45:47 +02:00
|
|
|
|
2022-01-23 18:27:00 +01:00
|
|
|
List<Widget> get _senseWidgets => [
|
|
|
|
for (int i = 0; i < senses.length; i++)
|
|
|
|
Sense(
|
|
|
|
index: i,
|
|
|
|
sense: senses[i],
|
|
|
|
meaning: extraData?.firstWhereOrNull(
|
|
|
|
(m) => m.definition == senses[i].englishDefinitions.join('; '),
|
2021-12-01 23:09:53 +01:00
|
|
|
),
|
2021-07-17 12:19:03 +02:00
|
|
|
),
|
2022-01-23 18:27:00 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) => Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: _senseWidgets,
|
|
|
|
);
|
2020-08-24 23:45:47 +02:00
|
|
|
}
|