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

38 lines
808 B
Dart
Raw Normal View History

2021-07-19 01:49:18 +02:00
import 'package:flutter/material.dart';
2021-08-03 22:02:42 +02:00
class SearchItem extends StatelessWidget {
final DateTime time;
final Widget search;
final void Function()? onTap;
2021-07-19 01:49:18 +02:00
2021-08-03 22:02:42 +02:00
const SearchItem({
required this.time,
required this.search,
this.onTap,
Key? key,
}) : super(key: key);
2021-07-19 01:49:18 +02:00
2021-08-03 22:02:42 +02:00
String getTime() {
2021-12-01 23:09:53 +01:00
final hours = time.hour.toString().padLeft(2, '0');
final mins = time.minute.toString().padLeft(2, '0');
return '$hours:$mins';
2021-07-19 01:49:18 +02:00
}
@override
Widget build(BuildContext context) {
2021-12-01 23:09:53 +01:00
return ListTile(
onTap: onTap,
contentPadding: EdgeInsets.zero,
title: Row(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Text(getTime()),
),
search,
],
2021-08-03 22:02:42 +02:00
),
2021-07-19 01:49:18 +02:00
);
}
}