-
-
Notifications
You must be signed in to change notification settings - Fork 826
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mobile] add panorama viewer (#2362)
## Description ## Tests
- Loading branch information
Showing
14 changed files
with
212 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import "dart:io"; | ||
|
||
import "package:flutter/material.dart"; | ||
import "package:panorama_viewer/panorama_viewer.dart"; | ||
|
||
class PanoramaViewerScreen extends StatelessWidget { | ||
const PanoramaViewerScreen({ | ||
super.key, | ||
required this.file, | ||
}); | ||
|
||
final File file; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
elevation: 0, // Remove shadow | ||
leading: IconButton( | ||
icon: const Icon( | ||
Icons.arrow_back, | ||
size: 18, | ||
), | ||
onPressed: () { | ||
Navigator.of(context).pop(); | ||
}, | ||
), | ||
), | ||
body: PanoramaViewer( | ||
child: Image.file( | ||
file, | ||
fit: BoxFit.cover, | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import "package:flutter/painting.dart"; | ||
import "package:photos/models/file/extensions/file_props.dart"; | ||
import "package:photos/models/file/file.dart"; | ||
import "package:photos/models/file/file_type.dart"; | ||
import "package:photos/utils/file_util.dart"; | ||
|
||
/// Check if the file is a panorama image. | ||
Future<bool> checkIfPanorama(EnteFile enteFile) async { | ||
if (enteFile.fileType != FileType.image) { | ||
return false; | ||
} | ||
if (enteFile.isPanorama() != null) { | ||
return enteFile.isPanorama()!; | ||
} | ||
final file = await getFile(enteFile); | ||
if (file == null) { | ||
return false; | ||
} | ||
|
||
final image = await decodeImageFromList(await file.readAsBytes()); | ||
final width = image.width.toDouble(); | ||
final height = image.height.toDouble(); | ||
|
||
if (height > width) { | ||
return height / width >= 2.0; | ||
} | ||
return width / height >= 2.0; | ||
} |
Oops, something went wrong.