FilePhotoViewScreen.dart 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import 'package:flutter/material.dart';
  2. import '../basic/Common.dart';
  3. import 'components/Images.dart';
  4. import 'components/RightClickPop.dart';
  5. import 'package:photo_view/photo_view.dart';
  6. // 预览图片
  7. class FilePhotoViewScreen extends StatelessWidget {
  8. final String filePath;
  9. const FilePhotoViewScreen(this.filePath, {Key? key}) : super(key: key);
  10. @override
  11. Widget build(BuildContext context){
  12. return rightClickPop(
  13. child: buildScreen(context),
  14. context: context,
  15. canPop: true,
  16. );
  17. }
  18. Widget buildScreen(BuildContext context) => Scaffold(
  19. body: Stack(
  20. children: [
  21. GestureDetector(
  22. onLongPress: () async {
  23. String? choose =
  24. await chooseListDialog(context, '请选择', ['保存图片']);
  25. switch (choose) {
  26. case '保存图片':
  27. // TODO: saveImage
  28. // saveImage(filePath, context);
  29. break;
  30. }
  31. },
  32. child: PhotoView(
  33. imageProvider: ResourceFileImageProvider(filePath),
  34. ),
  35. ),
  36. InkWell(
  37. onTap: () => Navigator.of(context).pop(),
  38. child: Container(
  39. margin: const EdgeInsets.only(top: 30),
  40. padding: const EdgeInsets.only(left: 4, right: 4),
  41. decoration: BoxDecoration(
  42. color: Colors.black.withOpacity(.75),
  43. borderRadius: const BorderRadius.only(
  44. topRight: Radius.circular(8),
  45. bottomRight: Radius.circular(8),
  46. ),
  47. ),
  48. child: const Icon(Icons.keyboard_backspace, color: Colors.white),
  49. ),
  50. ),
  51. ],
  52. ),
  53. );
  54. }