Skip to content

Commit

Permalink
feat: support default direct download config (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie authored Sep 7, 2024
1 parent a198132 commit c5af916
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ui/flutter/lib/api/model/downloader_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ class ExtraConfig {
String themeMode;
String locale;
bool lastDeleteTaskKeep;
bool defaultDirectDownload;

ExtraConfigBt bt = ExtraConfigBt();

ExtraConfig({
this.themeMode = '',
this.locale = '',
this.lastDeleteTaskKeep = false,
this.defaultDirectDownload = false,
});

factory ExtraConfig.fromJson(Map<String, dynamic>? json) =>
Expand Down
2 changes: 2 additions & 0 deletions ui/flutter/lib/api/model/downloader_config.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:gopeed/api/model/request.dart';

import '../../app/controllers/app_controller.dart';

class CreateController extends GetxController
with GetSingleTickerProviderStateMixin {
// final files = [].obs;
Expand All @@ -23,6 +25,11 @@ class CreateController extends GetxController
void onInit() {
super.onInit();
advancedTabController = TabController(length: 2, vsync: this);
directDownload.value = Get.find<AppController>()
.downloaderConfig
.value
.extra
.defaultDirectDownload;
}

@override
Expand Down
24 changes: 23 additions & 1 deletion ui/flutter/lib/app/modules/setting/views/setting_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:io';

import 'package:badges/badges.dart' as badges;
import 'package:flutter/material.dart';
import 'package:path/path.dart' as path;
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:gopeed/app/views/copy_button.dart';
Expand Down Expand Up @@ -110,6 +109,28 @@ class SettingView extends GetView<SettingController> {
],
);
});

final buildDefaultDirectDownload =
_buildConfigItem('defaultDirectDownload'.tr, () {
return appController.downloaderConfig.value.extra.defaultDirectDownload
? 'on'.tr
: 'off'.tr;
}, (Key key) {
return Container(
alignment: Alignment.centerLeft,
child: Switch(
value:
appController.downloaderConfig.value.extra.defaultDirectDownload,
onChanged: (bool value) async {
appController.downloaderConfig.update((val) {
val!.extra.defaultDirectDownload = value;
});
await debounceSave();
},
),
);
});

buildBrowserExtension() {
return ListTile(
title: Text('browserExtension'.tr),
Expand Down Expand Up @@ -904,6 +925,7 @@ class SettingView extends GetView<SettingController> {
children: _addDivider([
buildDownloadDir(),
buildMaxRunning(),
buildDefaultDirectDownload(),
buildBrowserExtension(),
buildAutoStartup(),
]),
Expand Down
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/en_us.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const enUS = {
'connections': 'Connections',
'useServerCtime': 'Use server time for file creation',
'maxRunning': 'Max Running Tasks',
'defaultDirectDownload': 'Check direct download by default',
'items': '@count items',
'subscribeTracker': 'Subscribe Tracker',
'subscribeFail':
Expand Down
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/zh_cn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const zhCN = {
'connections': '连接数',
'useServerCtime': '创建文件使用服务器时间',
'maxRunning': '最大下载数',
'defaultDirectDownload': '默认勾选直接下载',
'items': '@count 项',
'subscribeTracker': '订阅 Tracker',
'subscribeFail': '订阅失败,请检查网络或稍后重试',
Expand Down
1 change: 1 addition & 0 deletions ui/flutter/lib/i18n/langs/zh_tw.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const zhTW = {
'connections': '連接數',
'useServerCtime': '使用伺服器時間作為檔案建立時間',
'maxRunning': '最大執行任務數',
'defaultDirectDownload': '預設勾選直接下載',
'items': '@count 個項目',
'subscribeTracker': '訂閱 Tracker',
'subscribeFail': '訂閱失敗,請檢查網路或稍後再試',
Expand Down

0 comments on commit c5af916

Please sign in to comment.