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

62 lines
1.5 KiB
Dart
Raw Normal View History

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(
sense.parts_of_speech.join(', '),
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.left,
),
],
),
Container(
child: Row(
children:[
Column(
children:
sense.english_definitions.map((def) => Text(def)).toList(),
crossAxisAlignment: CrossAxisAlignment.start,
),
]
),
padding: EdgeInsets.symmetric(horizontal: 20),
margin: EdgeInsets.fromLTRB(0, 5, 0, 15),
2020-08-24 23:45:47 +02:00
),
],
),
);
}
}