Created
March 3, 2023 09:18
-
-
Save mhassanist/35f5da894eb56e9e39ad8db41f258010 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:cached_network_image/cached_network_image.dart'; | |
import 'package:extended_image/extended_image.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:photo_view/photo_view.dart'; | |
import 'package:skycap/ui/screens/submit_footage/image_editor_screen.dart'; | |
import 'package:skycap/utils/scaffold_app_bar.dart'; | |
class FullScreenView extends StatefulWidget { | |
final imageUrl; | |
final showEdit; | |
FullScreenView(this.imageUrl, {required this.showEdit}); | |
@override | |
State<FullScreenView> createState() => _FullScreenViewState(); | |
} | |
class _FullScreenViewState extends State<FullScreenView> { | |
var editedImageFilePath; | |
@override | |
Widget build(BuildContext context) { | |
return SafeArea( | |
child: ScaffoldAppBar( | |
actions: [buildEditButton(), buildUploadButton()], | |
body: buildBody(), | |
), | |
); | |
} | |
Widget buildEditButton() { | |
return widget.showEdit | |
? ElevatedButton( | |
onPressed: () async { | |
var imageEditorPage = ImageEditScreen(widget.imageUrl); | |
editedImageFilePath = await Navigator.push(context, | |
MaterialPageRoute(builder: (context) => imageEditorPage)); | |
setState(() {}); | |
}, | |
child: Text('Edit')) | |
: SizedBox(); | |
} | |
Widget buildUploadButton() { | |
return editedImageFilePath != null | |
? ElevatedButton( | |
onPressed: () async { | |
Navigator.pop(context, editedImageFilePath); | |
}, | |
child: Text('Upload')) | |
: SizedBox(); | |
} | |
buildBody() { | |
return Container( | |
color: Colors.white, | |
child: editedImageFilePath == null | |
? PhotoView( | |
imageProvider: CachedNetworkImageProvider(widget.imageUrl), | |
) | |
: PhotoView( | |
imageProvider: FileImage(File(editedImageFilePath)), | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment