ente/lib/ui/detail_page.dart

51 lines
1.2 KiB
Dart
Raw Normal View History

2020-03-24 19:59:36 +00:00
import 'dart:io';
import 'package:flutter/material.dart';
2020-04-14 15:36:18 +00:00
import 'package:logger/logger.dart';
2020-03-28 18:18:27 +00:00
import 'package:myapp/core/lru_map.dart';
2020-03-30 14:28:46 +00:00
import 'package:myapp/models/photo.dart';
import 'package:share_extend/share_extend.dart';
2020-03-24 19:59:36 +00:00
2020-04-05 14:45:04 +00:00
class DetailPage extends StatelessWidget {
2020-03-30 14:28:46 +00:00
final Photo photo;
2020-03-24 19:59:36 +00:00
2020-04-05 14:45:04 +00:00
const DetailPage(this.photo, {Key key}) : super(key: key);
2020-03-24 19:59:36 +00:00
@override
Widget build(BuildContext context) {
2020-04-14 15:36:18 +00:00
Logger().i(photo.localPath);
2020-03-24 19:59:36 +00:00
return Scaffold(
2020-03-30 14:28:46 +00:00
appBar: AppBar(
actions: <Widget>[
// action button
IconButton(
icon: Icon(Icons.share),
onPressed: () {
2020-04-05 14:45:04 +00:00
ShareExtend.share(photo.localPath, "image");
2020-03-30 14:28:46 +00:00
},
)
],
),
2020-03-24 19:59:36 +00:00
body: Center(
child: Container(
2020-03-27 19:54:24 +00:00
child: _buildContent(context),
2020-03-24 19:59:36 +00:00
),
),
);
}
2020-03-27 19:54:24 +00:00
Widget _buildContent(BuildContext context) {
return GestureDetector(
onVerticalDragUpdate: (details) {
Navigator.pop(context);
},
2020-04-05 14:45:04 +00:00
child: ImageLruCache.getData(photo.localPath) == null
2020-03-30 14:28:46 +00:00
? Image.file(
2020-04-05 14:45:04 +00:00
File(photo.localPath),
2020-03-30 14:28:46 +00:00
filterQuality: FilterQuality.low,
)
2020-04-05 14:45:04 +00:00
: ImageLruCache.getData(photo.localPath),
2020-03-24 19:59:36 +00:00
);
}
}