mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-05 16:15:43 +00:00
refactor: common message dialog method
This commit is contained in:
1 parent
7fdba12376
commit
f42838810a
15 files changed
+47
-22
No files matched your search
@@ -125,7 +125,7 @@ Future<void> putConfig(DownloaderConfig config) async {
|
||||
return _parse(() => _client.dio.put("/api/v1/config", data: config), null);
|
||||
}
|
||||
|
||||
Future<Response<T>> proxyRequest<T>(String uri,
|
||||
Future<Response<String>> proxyRequest<T>(String uri,
|
||||
{data, Options? options}) async {
|
||||
options ??= Options();
|
||||
options.headers ??= {};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:gopeed/api/model/options.dart';
|
||||
import 'package:gopeed/api/model/request.dart';
|
||||
import 'package:gopeed/api/model/resource.dart';
|
||||
import 'options.dart';
|
||||
import 'request.dart';
|
||||
import 'resource.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'meta.g.dart';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:gopeed/api/model/resource.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import 'resource.dart';
|
||||
|
||||
part 'resolve_result.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import 'package:desktop_drop/desktop_drop.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:gopeed/api/model/resolve_result.dart';
|
||||
import '../../../../api/model/resolve_result.dart';
|
||||
import '../../../../api/model/result.dart';
|
||||
import 'package:rounded_loading_button/rounded_loading_button.dart';
|
||||
|
||||
import '../../../../api/api.dart';
|
||||
import '../../../../api/model/create_task.dart';
|
||||
import '../../../../api/model/options.dart';
|
||||
import '../../../../api/model/request.dart';
|
||||
import '../../../../util/message.dart';
|
||||
import '../../../../util/util.dart';
|
||||
import '../../../routes/app_pages.dart';
|
||||
import '../../../views/views/directory_selector.dart';
|
||||
@@ -79,7 +81,7 @@ class CreateView extends GetView<CreateController> {
|
||||
await _showResolveDialog(rr);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.snackbar('error'.tr, e.toString());
|
||||
showErrorMessage(e);
|
||||
} finally {
|
||||
_confirmController.reset();
|
||||
}
|
||||
@@ -167,7 +169,7 @@ class CreateView extends GetView<CreateController> {
|
||||
try {
|
||||
downloadController.start();
|
||||
if (controller.selectedIndexes.isEmpty) {
|
||||
Get.snackbar('tip'.tr, 'noFileSelected'.tr);
|
||||
showMessage('tip'.tr, 'noFileSelected'.tr);
|
||||
return;
|
||||
}
|
||||
if (createFormKey.currentState!.validate()) {
|
||||
@@ -189,8 +191,7 @@ class CreateView extends GetView<CreateController> {
|
||||
Get.rootDelegate.offNamed(Routes.DOWNLOADING);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.snackbar('error'.tr, e.toString());
|
||||
rethrow;
|
||||
showErrorMessage(e);
|
||||
} finally {
|
||||
downloadController.reset();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:gopeed/app/views/views/buid_task_list_view.dart';
|
||||
|
||||
import '../../../views/views/buid_task_list_view.dart';
|
||||
import '../controllers/downloaded_controller.dart';
|
||||
|
||||
class DownloadedView extends GetView<DownloadedController> {
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../../util/message.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
@@ -39,7 +40,7 @@ class SettingView extends GetView<SettingController> {
|
||||
.then(completer.complete)
|
||||
.onError(completer.completeError);
|
||||
if (needRestart) {
|
||||
Get.snackbar('tip'.tr, 'effectAfterRestart'.tr);
|
||||
showMessage('tip'.tr, 'effectAfterRestart'.tr);
|
||||
}
|
||||
});
|
||||
return completer.future;
|
||||
@@ -126,7 +127,7 @@ class SettingView extends GetView<SettingController> {
|
||||
try {
|
||||
await appController.trackerUpdate();
|
||||
} catch (e) {
|
||||
Get.snackbar('error'.tr, 'subscribeFail'.tr);
|
||||
showErrorMessage('subscribeFail'.tr);
|
||||
} finally {
|
||||
trackerUpdateController.stop();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import '../../../api/api.dart';
|
||||
import '../../../api/model/task.dart';
|
||||
import '../../../util/file_icon.dart';
|
||||
import '../../../util/icons.dart';
|
||||
import '../../../util/message.dart';
|
||||
import '../../../util/util.dart';
|
||||
import '../../routes/app_pages.dart';
|
||||
|
||||
@@ -103,7 +104,7 @@ class BuildTaskListView extends GetView {
|
||||
await deleteTask(id, !keep.value);
|
||||
Get.back();
|
||||
} catch (e) {
|
||||
Get.snackbar('error'.tr, e.toString());
|
||||
showErrorMessage(e);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'dart:ui' as ui;
|
||||
import 'package:fluent_ui/fluent_ui.dart' as fluent;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:gopeed/api/model/resource.dart';
|
||||
import '../../../api/model/resource.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../../../util/file_icon.dart';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'libgopeed_interface.dart';
|
||||
import 'start_config.dart';
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import 'dart:convert';
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:ffi/ffi.dart';
|
||||
import '../ffi/libgopeed_bind.dart';
|
||||
|
||||
import '../ffi/libgopeed_bind.dart';
|
||||
import 'libgopeed_interface.dart';
|
||||
import 'start_config.dart';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:gopeed/core/common/start_config.dart';
|
||||
import '../common/start_config.dart';
|
||||
|
||||
import '../libgopeed_boot.dart';
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:gopeed/api/api.dart' as api;
|
||||
|
||||
import 'api/api.dart' as api;
|
||||
import 'app/modules/app/controllers/app_controller.dart';
|
||||
import 'app/modules/app/views/app_view.dart';
|
||||
import 'core/libgopeed_boot.dart';
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../api/model/result.dart';
|
||||
|
||||
void showErrorMessage(msg) {
|
||||
final title = 'error'.tr;
|
||||
if (msg is Result) {
|
||||
Get.snackbar(title, msg.msg!);
|
||||
return;
|
||||
}
|
||||
if (msg is Exception && (msg as dynamic).message is Result) {
|
||||
Get.snackbar(title, ((msg as dynamic).message as Result).msg!);
|
||||
return;
|
||||
}
|
||||
Get.snackbar(title, msg);
|
||||
}
|
||||
|
||||
void showMessage(title, msg) {
|
||||
Get.snackbar(title, msg);
|
||||
}
|
||||
@@ -277,10 +277,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fluent_ui
|
||||
sha256: f9d443f9181900cfab9f38793195c7c4221cf05eb86918ac3517e67c024da867
|
||||
sha256: "55294f8f8b1aab6ac7a2be529b1dcb4affcff3e3176e5e50e5f1918a40050df7"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.2.0"
|
||||
version: "4.4.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@@ -1005,4 +1005,4 @@ packages:
|
||||
version: "3.1.1"
|
||||
sdks:
|
||||
dart: ">=2.18.0 <3.0.0"
|
||||
flutter: ">=3.3.0"
|
||||
flutter: ">=3.7.0"
|
||||
@@ -51,7 +51,7 @@ dependencies:
|
||||
desktop_drop: ^0.3.3
|
||||
intl: ^0.17.0
|
||||
package_info_plus: ^3.0.2
|
||||
fluent_ui: ^4.2.0
|
||||
fluent_ui: ^4.4.0
|
||||
path: any
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in new issue
Block a user