Skip to content

Commit

Permalink
support open and select single success compress file
Browse files Browse the repository at this point in the history
  • Loading branch information
JerryFans committed Jan 20, 2022
1 parent cb61111 commit 0e7f1d6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
Binary file added images/folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/Controller/tiny_image_info_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class TinyImageInfoController extends GetxController {
},
);
if (isSuc) {
vm.saveFile = compressFile;
vm.updateStatus(TinyImageInfoStatus.success);
taskList.refresh();
saveKb.value += vm.saveKB;
Expand Down
1 change: 1 addition & 0 deletions lib/Model/tiny_image_info_item_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class TinyImageInfoItemViewModel {
TinyImageInfoStatus status = TinyImageInfoStatus.uploading;
TinyImageInfo? imageInfo;
double saveKB = 0;
File? saveFile;

void updateProgress(int count ,int total) {
if (status == TinyImageInfoStatus.downloading) {
Expand Down
32 changes: 29 additions & 3 deletions lib/View/image_task_cell.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:oktoast/oktoast.dart';
import 'dart:io';
import 'package:tiny_png4_flutter/ImagesAnim.dart';
import 'package:tiny_png4_flutter/Model/tiny_image_info_item_view_model.dart';
import 'package:flutter/cupertino.dart';
Expand All @@ -8,7 +8,8 @@ class ImageTaskCell extends StatelessWidget {
final TinyImageInfoItemViewModel vm;
final Function(TinyImageInfoItemViewModel vm) retryCallBack;

ImageTaskCell({Key? key, required this.vm, required this.retryCallBack}) : super(key: key);
ImageTaskCell({Key? key, required this.vm, required this.retryCallBack})
: super(key: key);

@override
Widget build(BuildContext context) {
Expand All @@ -21,7 +22,7 @@ class ImageTaskCell extends StatelessWidget {
children: [
Image.file(
vm.file,
height: 100,
height: 80,
fit: BoxFit.fitHeight,
),
SizedBox(
Expand Down Expand Up @@ -50,6 +51,31 @@ class ImageTaskCell extends StatelessWidget {
),
Row(
children: [
Visibility(
visible: vm.status == TinyImageInfoStatus.success,
child: GestureDetector(
onTap: () {
if (vm.saveFile != null) {
if (Platform.isMacOS) {
Process.run("open", ['-R', vm.saveFile!.path]);
} else if (Platform.isWindows) {
Process.run("explorer", [vm.saveFile!.path]);
}
}
},
child: Row(
children: [
Image.asset(
"images/folder.png",
width: 30,
height: 30,
),
SizedBox(
width: 15,
),
],
),
)),
Visibility(
visible: vm.status == TinyImageInfoStatus.downloadFail ||
vm.status == TinyImageInfoStatus.uploadFail,
Expand Down

0 comments on commit 0e7f1d6

Please sign in to comment.