-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix trash bug and allow dock file drops
- Loading branch information
Showing
9 changed files
with
100 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:alic/filesystem.dart'; | ||
import 'package:alic/log.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
registerDockDropHandler(Function(List<File>) onDrop) async { | ||
const platform = MethodChannel('io.kbl.alic'); | ||
platform.setMethodCallHandler((call) async { | ||
log.d(call); | ||
if (call.method == 'openImage') { | ||
var path = call.arguments as String; | ||
var paths = await resolvePaths([path]); | ||
onDrop(paths); | ||
} | ||
}); | ||
} |
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,27 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:alic/imagefiles.dart'; | ||
|
||
Future<List<File>> resolvePaths(List<String> paths) async { | ||
List<File> resolvedPaths = []; | ||
for (var path in paths) { | ||
final dir = Directory(path); | ||
final file = File(path); | ||
if (await dir.exists()) { | ||
resolvedPaths.addAll(await getImagesFromDirectory(dir)); | ||
} else if (await file.exists()) { | ||
resolvedPaths.add(file); | ||
} | ||
} | ||
return resolvedPaths; | ||
} | ||
|
||
// Return a list of images from a directory, recursively | ||
Future<List<File>> getImagesFromDirectory(Directory dir) async { | ||
return await dir | ||
.list(recursive: true, followLinks: false) | ||
.where((entity) => entity is File) | ||
.map((entity) => entity as File) | ||
.where((file) => ImageFormats.isImage(file.path)) | ||
.toList(); | ||
} |
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