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;
|
|
|
|
const Senses(this.senses);
|
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
|
|
|
|
|
|
|
return Container(
|
|
|
|
child: Column(
|
2021-03-03 00:24:25 +01:00
|
|
|
children: senseWidgets,
|
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) {
|
|
|
|
return Container(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
2021-07-17 12:19:03 +02:00
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
(index + 1).toString() + '. ',
|
|
|
|
style: TextStyle(color: Colors.grey),
|
|
|
|
),
|
|
|
|
Text(
|
2021-07-26 21:39:17 +02:00
|
|
|
sense.partsOfSpeech.join(', '),
|
2021-07-17 12:19:03 +02:00
|
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
child: Row(
|
|
|
|
children:[
|
|
|
|
Column(
|
|
|
|
children:
|
2021-07-26 21:39:17 +02:00
|
|
|
sense.englishDefinitions.map((def) => Text(def)).toList(),
|
2021-07-17 12:19:03 +02:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
),
|
|
|
|
]
|
|
|
|
),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
margin: EdgeInsets.fromLTRB(0, 5, 0, 15),
|
2020-08-24 23:45:47 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|