ente/lib/ui/face_search_results_page.dart
2020-06-03 19:23:53 +05:30

51 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
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';
import 'package:photos/ui/gallery.dart';
import 'package:photos/ui/loading_widget.dart';
class FaceSearchResultsPage extends StatelessWidget {
final FaceSearchManager _faceSearchManager = FaceSearchManager.instance;
final Face face;
FaceSearchResultsPage(this.face, {Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Search results"),
actions: <Widget>[
CircularNetworkImageWidget(
Configuration.instance.getHttpEndpoint() +
"/" +
face.thumbnailPath,
20),
],
),
body: Container(
child: _getBody(),
),
);
}
FutureBuilder<List<Photo>> _getBody() {
return FutureBuilder<List<Photo>>(
future: _faceSearchManager.getFaceSearchResults(face),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Gallery(
snapshot.data,
Set<Photo>(),
);
} else {
return Center(child: loadWidget);
}
},
);
}
}