Jisho-Study-Tool/lib/view/components/history/kanji_search_item.dart

80 lines
2.0 KiB
Dart
Raw Normal View History

2021-07-19 01:49:18 +02:00
import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
2021-08-08 23:16:54 +02:00
import 'package:jisho_study_tool/bloc/theme/theme_bloc.dart';
2021-08-03 22:02:42 +02:00
import 'package:jisho_study_tool/models/history/kanji_query.dart';
2021-08-08 23:16:54 +02:00
import 'package:jisho_study_tool/models/themes/theme.dart';
2021-07-19 01:49:18 +02:00
2021-08-03 22:02:42 +02:00
import './search_item.dart';
2021-07-19 01:49:18 +02:00
2021-08-03 22:02:42 +02:00
class _KanjiBox extends StatelessWidget {
final String kanji;
const _KanjiBox(this.kanji);
2021-07-19 01:49:18 +02:00
@override
Widget build(BuildContext context) {
2021-08-08 23:16:54 +02:00
final ColorSet _menuColors = BlocProvider.of<ThemeBloc>(context).state.theme.menuGreyLight;
2021-08-03 22:02:42 +02:00
return IntrinsicHeight(
child: AspectRatio(
aspectRatio: 1,
child: Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
2021-08-08 23:16:54 +02:00
color: _menuColors.background,
2021-08-03 22:02:42 +02:00
borderRadius: BorderRadius.circular(10.0),
),
child: Center(
child: FittedBox(
child: Text(
kanji,
style: TextStyle(
2021-08-08 23:16:54 +02:00
color: _menuColors.foreground,
2021-08-03 22:02:42 +02:00
fontSize: 25,
),
),
),
),
),
),
);
2021-07-19 01:49:18 +02:00
}
}
class KanjiSearchItem extends StatelessWidget {
2021-08-03 22:02:42 +02:00
final KanjiQuery result;
final DateTime timestamp;
2021-07-19 01:49:18 +02:00
2021-08-03 22:02:42 +02:00
const KanjiSearchItem({
required this.result,
required this.timestamp,
Key? key,
}) : super(key: key);
2021-07-19 01:49:18 +02:00
@override
Widget build(BuildContext context) {
return Slidable(
2021-08-03 22:02:42 +02:00
child: SearchItem(
onTap: () {
Navigator.pushNamed(context, '/kanjiSearch', arguments: this.result.kanji);
2021-08-03 22:02:42 +02:00
},
time: timestamp,
search: _KanjiBox(result.kanji),
),
2021-07-19 01:49:18 +02:00
actionPane: SlidableScrollActionPane(),
secondaryActions: [
IconSlideAction(
caption: "Favourite",
color: Colors.yellow,
2021-08-03 22:02:42 +02:00
icon: Icons.star,
2021-07-19 01:49:18 +02:00
),
IconSlideAction(
caption: "Delete",
color: Colors.red,
2021-08-03 22:02:42 +02:00
icon: Icons.delete,
),
2021-07-19 01:49:18 +02:00
],
);
}
}