Fixed some coloring issues, respect color theme on file-viewer background, make file-viewer images rotatable
This commit is contained in:
@ -11,7 +11,8 @@ import 'placeholderView.dart';
|
||||
class FileViewer extends StatelessWidget {
|
||||
final String path;
|
||||
final bool openExternal;
|
||||
const FileViewer({super.key, required this.path, this.openExternal = false});
|
||||
final bool allowExternal;
|
||||
const FileViewer({super.key, required this.path, this.openExternal = false, this.allowExternal = true});
|
||||
|
||||
|
||||
@override
|
||||
@ -19,15 +20,18 @@ class FileViewer extends StatelessWidget {
|
||||
AppBar appbar = AppBar(
|
||||
title: Text(path.split("/").last),
|
||||
actions: [
|
||||
IconButton(onPressed: () => ConfirmDialog(
|
||||
title: "Extern öffnen",
|
||||
content: "Möchtest du die Datei mit dem Systemdialog öffnen?",
|
||||
onConfirm: () => Navigator.of(context).push(MaterialPageRoute(builder: (context) => FileViewer(path: path, openExternal: true))),
|
||||
confirmButton: "Öffnen",
|
||||
).asDialog(context), icon: const Icon(Icons.open_in_new))
|
||||
Visibility(
|
||||
visible: allowExternal,
|
||||
child: IconButton(onPressed: () => ConfirmDialog(
|
||||
title: "Extern öffnen",
|
||||
content: "Möchtest du die Datei mit dem Systemdialog öffnen?",
|
||||
onConfirm: () => Navigator.of(context).push(MaterialPageRoute(builder: (context) => FileViewer(path: path, openExternal: true))),
|
||||
confirmButton: "Öffnen",
|
||||
).asDialog(context), icon: const Icon(Icons.open_in_new)),
|
||||
)
|
||||
],
|
||||
);
|
||||
switch(openExternal ? "x" : path.split(".").last) {
|
||||
switch(openExternal ? "" : path.split(".").last) {
|
||||
case "png":
|
||||
case "jpg":
|
||||
case "jpeg":
|
||||
@ -36,7 +40,8 @@ class FileViewer extends StatelessWidget {
|
||||
backgroundColor: Colors.white,
|
||||
body: PhotoView(
|
||||
imageProvider: Image.file(File(path)).image,
|
||||
backgroundDecoration: const BoxDecoration(color: Colors.white60),
|
||||
backgroundDecoration: BoxDecoration(color: Theme.of(context).colorScheme.surface),
|
||||
enableRotation: true,
|
||||
)
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user