ente/lib/ui/face_search_results_page.dart

51 lines
1.4 KiB
Dart
Raw Normal View History

2020-04-05 14:00:44 +00:00
import 'package:flutter/material.dart';
2020-05-01 18:20:12 +00:00
import 'package:photos/core/configuration.dart';
import 'package:photos/face_search_manager.dart';
import 'package:photos/models/face.dart';
import 'package:photos/models/photo.dart';
import 'package:photos/ui/circular_network_image_widget.dart';
2020-06-02 14:24:37 +00:00
import 'package:photos/ui/gallery.dart';
2020-06-02 11:32:35 +00:00
import 'package:photos/ui/loading_widget.dart';
2020-04-05 14:00:44 +00:00
class FaceSearchResultsPage extends StatelessWidget {
final FaceSearchManager _faceSearchManager = FaceSearchManager.instance;
2020-06-03 13:53:53 +00:00
final Face face;
2020-04-05 14:00:44 +00:00
2020-06-03 13:53:53 +00:00
FaceSearchResultsPage(this.face, {Key key}) : super(key: key);
2020-04-05 14:00:44 +00:00
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Search results"),
actions: <Widget>[
2020-06-02 14:24:37 +00:00
CircularNetworkImageWidget(
Configuration.instance.getHttpEndpoint() +
"/" +
2020-06-03 13:53:53 +00:00
face.thumbnailPath,
2020-06-02 14:24:37 +00:00
20),
2020-04-05 14:00:44 +00:00
],
),
body: Container(
child: _getBody(),
),
);
}
2020-04-17 08:17:37 +00:00
FutureBuilder<List<Photo>> _getBody() {
return FutureBuilder<List<Photo>>(
2020-06-03 13:53:53 +00:00
future: _faceSearchManager.getFaceSearchResults(face),
2020-04-05 14:00:44 +00:00
builder: (context, snapshot) {
if (snapshot.hasData) {
2020-06-02 14:24:37 +00:00
return Gallery(
snapshot.data,
Set<Photo>(),
);
2020-04-05 14:00:44 +00:00
} else {
2020-06-02 11:32:35 +00:00
return Center(child: loadWidget);
2020-04-05 14:00:44 +00:00
}
},
);
}
}