2020-08-24 23:45:47 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:unofficial_jisho_api/parser.dart';
|
|
|
|
|
|
|
|
class Senses extends StatelessWidget {
|
2021-03-03 00:24:25 +01:00
|
|
|
final List<JishoWordSense> senses;
|
2021-12-01 23:09:53 +01:00
|
|
|
|
|
|
|
const Senses({
|
|
|
|
required this.senses,
|
|
|
|
Key? key,
|
|
|
|
}) : super(key: key);
|
2020-08-24 23:45:47 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-03-03 00:24:25 +01:00
|
|
|
final List<Widget> senseWidgets =
|
2021-07-17 12:19:03 +02:00
|
|
|
senses.asMap().entries.map((e) => _Sense(e.key, e.value)).toList();
|
2020-08-24 23:45:47 +02:00
|
|
|
|
2021-12-01 23:09:53 +01:00
|
|
|
return Column(
|
2021-03-03 00:24:25 +01:00
|
|
|
children: senseWidgets,
|
2021-12-01 23:09:53 +01:00
|
|
|
);
|
2020-08-24 23:45:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _Sense extends StatelessWidget {
|
2021-07-17 12:19:03 +02:00
|
|
|
final int index;
|
2021-03-03 00:24:25 +01:00
|
|
|
final JishoWordSense sense;
|
2021-07-17 12:19:03 +02:00
|
|
|
|
|
|
|
const _Sense(this.index, this.sense);
|
2020-08-24 23:45:47 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-12-01 23:09:53 +01:00
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'${index + 1}. ',
|
|
|
|
style: const TextStyle(color: Colors.grey),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
sense.partsOfSpeech.join(', '),
|
|
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
margin: const EdgeInsets.fromLTRB(0, 5, 0, 15),
|
|
|
|
child: Row(
|
2021-07-17 12:19:03 +02:00
|
|
|
children: [
|
2021-12-01 23:09:53 +01:00
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children:
|
|
|
|
sense.englishDefinitions.map((def) => Text(def)).toList(),
|
2021-07-17 12:19:03 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2021-12-01 23:09:53 +01:00
|
|
|
),
|
|
|
|
],
|
2020-08-24 23:45:47 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|