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

40 lines
867 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() {
final hours = this.time.hour.toString().padLeft(2, '0');
final mins = this.time.minute.toString().padLeft(2, '0');
return "$hours:$mins";
2021-07-19 01:49:18 +02:00
}
@override
Widget build(BuildContext context) {
2021-08-03 22:02:42 +02:00
return Container(
child: ListTile(
onTap: onTap,
contentPadding: EdgeInsets.zero,
title: Row(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: Text(getTime()),
),
search,
],
),
),
2021-07-19 01:49:18 +02:00
);
}
}