ente/lib/ui/viewer/search/result/file_result_widget.dart

79 lines
2.4 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2022-08-05 16:56:06 +00:00
import 'package:photos/ente_theme_data.dart';
2022-07-28 05:54:40 +00:00
import 'package:photos/models/file.dart';
2022-08-04 16:16:16 +00:00
import 'package:photos/models/search/file_search_result.dart';
import 'package:photos/ui/viewer/file/detail_page.dart';
2022-09-14 08:33:12 +00:00
import 'package:photos/ui/viewer/search/result/search_thumbnail_widget.dart';
import 'package:photos/utils/navigation_util.dart';
2022-07-28 05:54:40 +00:00
2022-08-10 06:28:16 +00:00
class FileSearchResultWidget extends StatelessWidget {
2022-08-04 16:16:16 +00:00
final FileSearchResult matchedFile;
2022-09-14 08:33:12 +00:00
const FileSearchResultWidget(this.matchedFile, {Key? key}) : super(key: key);
2022-07-28 05:54:40 +00:00
@override
Widget build(BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
2022-08-05 16:56:06 +00:00
child: Container(
color: Theme.of(context).colorScheme.searchResultsColor,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
2022-08-05 16:56:06 +00:00
crossAxisAlignment: CrossAxisAlignment.center,
children: [
2022-09-14 08:33:12 +00:00
SearchThumbnailWidget(
matchedFile.file,
"file_details",
),
2022-08-11 14:50:56 +00:00
const SizedBox(width: 16),
2022-08-11 14:45:42 +00:00
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'File',
style: TextStyle(
fontSize: 12,
color: Theme.of(context).colorScheme.subTextColor,
2022-08-05 16:56:06 +00:00
),
2022-08-11 14:45:42 +00:00
),
const SizedBox(height: 6),
SizedBox(
width: 220,
child: Text(
matchedFile.file.title!,
2022-08-05 16:56:06 +00:00
style: const TextStyle(fontSize: 18),
overflow: TextOverflow.ellipsis,
),
2022-08-11 14:45:42 +00:00
),
],
),
const Spacer(),
Icon(
Icons.chevron_right,
color: Theme.of(context).colorScheme.subTextColor,
2022-07-28 05:54:40 +00:00
),
2022-08-05 16:56:06 +00:00
],
),
2022-07-28 05:54:40 +00:00
),
),
onTap: () {
2022-08-04 16:16:16 +00:00
_routeToDetailPage(matchedFile.file, context);
},
2022-07-28 05:54:40 +00:00
);
}
void _routeToDetailPage(File file, BuildContext context) {
final page = DetailPage(
DetailPageConfiguration(
List.unmodifiable([file]),
null,
0,
2022-08-06 17:56:36 +00:00
"file_details",
),
);
2022-08-13 14:50:34 +00:00
routeToPage(context, page);
}
2022-07-28 05:54:40 +00:00
}