opt: 图片加载&设置
This commit is contained in:
@ -2,6 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/utils/extension.dart';
|
import 'package:pilipala/utils/extension.dart';
|
||||||
|
import 'package:pilipala/utils/global_data.dart';
|
||||||
import '../../utils/storage.dart';
|
import '../../utils/storage.dart';
|
||||||
import '../constants.dart';
|
import '../constants.dart';
|
||||||
|
|
||||||
@ -32,8 +33,10 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final int defaultImgQuality = GlobalData().imgQuality;
|
||||||
final String imageUrl =
|
final String imageUrl =
|
||||||
'${src!.startsWith('//') ? 'https:${src!}' : src!}@${quality ?? 100}q.webp';
|
'${src!.startsWith('//') ? 'https:${src!}' : src!}@${quality ?? defaultImgQuality}q.webp';
|
||||||
|
print(imageUrl);
|
||||||
int? memCacheWidth, memCacheHeight;
|
int? memCacheWidth, memCacheHeight;
|
||||||
double aspectRatio = (width / height).toDouble();
|
double aspectRatio = (width / height).toDouble();
|
||||||
|
|
||||||
@ -81,7 +84,7 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
fadeOutDuration ?? const Duration(milliseconds: 120),
|
fadeOutDuration ?? const Duration(milliseconds: 120),
|
||||||
fadeInDuration:
|
fadeInDuration:
|
||||||
fadeInDuration ?? const Duration(milliseconds: 120),
|
fadeInDuration ?? const Duration(milliseconds: 120),
|
||||||
filterQuality: FilterQuality.high,
|
filterQuality: FilterQuality.low,
|
||||||
errorWidget: (BuildContext context, String url, Object error) =>
|
errorWidget: (BuildContext context, String url, Object error) =>
|
||||||
placeholder(context),
|
placeholder(context),
|
||||||
placeholder: (BuildContext context, String url) =>
|
placeholder: (BuildContext context, String url) =>
|
||||||
|
@ -201,11 +201,11 @@ class _AboutPageState extends State<AboutPage> {
|
|||||||
var cleanStatus = await CacheManage().clearCacheAll();
|
var cleanStatus = await CacheManage().clearCacheAll();
|
||||||
if (cleanStatus) {
|
if (cleanStatus) {
|
||||||
getCacheSize();
|
getCacheSize();
|
||||||
|
SmartDialog.showToast('清除成功');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
title: const Text('清除缓存'),
|
title: const Text('清除缓存'),
|
||||||
subtitle: Text('图片及网络缓存 $cacheSize', style: subTitleStyle),
|
subtitle: Text('图片及网络缓存 $cacheSize', style: subTitleStyle),
|
||||||
trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline),
|
|
||||||
),
|
),
|
||||||
SizedBox(height: MediaQuery.of(context).padding.bottom + 20)
|
SizedBox(height: MediaQuery.of(context).padding.bottom + 20)
|
||||||
],
|
],
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/models/common/dynamics_type.dart';
|
import 'package:pilipala/models/common/dynamics_type.dart';
|
||||||
import 'package:pilipala/models/common/reply_sort_type.dart';
|
import 'package:pilipala/models/common/reply_sort_type.dart';
|
||||||
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
|
import '../home/index.dart';
|
||||||
import 'widgets/switch_item.dart';
|
import 'widgets/switch_item.dart';
|
||||||
|
|
||||||
class ExtraSetting extends StatefulWidget {
|
class ExtraSetting extends StatefulWidget {
|
||||||
@ -138,18 +140,20 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
),
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
children: [
|
children: [
|
||||||
SetSwitchItem(
|
const SetSwitchItem(
|
||||||
title: '大家都在搜',
|
title: '大家都在搜',
|
||||||
subTitle: '是否展示「大家都在搜」',
|
subTitle: '是否展示「大家都在搜」',
|
||||||
setKey: SettingBoxKey.enableHotKey,
|
setKey: SettingBoxKey.enableHotKey,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
callFn: (val) => {SmartDialog.showToast('下次启动时生效')},
|
|
||||||
),
|
),
|
||||||
const SetSwitchItem(
|
SetSwitchItem(
|
||||||
title: '搜索默认词',
|
title: '搜索默认词',
|
||||||
subTitle: '是否展示搜索框默认词',
|
subTitle: '是否展示搜索框默认词',
|
||||||
setKey: SettingBoxKey.enableSearchWord,
|
setKey: SettingBoxKey.enableSearchWord,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
|
callFn: (val) {
|
||||||
|
Get.find<HomeController>().defaultSearch.value = '';
|
||||||
|
},
|
||||||
),
|
),
|
||||||
const SetSwitchItem(
|
const SetSwitchItem(
|
||||||
title: '快速收藏',
|
title: '快速收藏',
|
||||||
|
@ -8,6 +8,7 @@ import 'package:pilipala/models/common/theme_type.dart';
|
|||||||
import 'package:pilipala/pages/setting/pages/color_select.dart';
|
import 'package:pilipala/pages/setting/pages/color_select.dart';
|
||||||
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
||||||
import 'package:pilipala/pages/setting/widgets/slide_dialog.dart';
|
import 'package:pilipala/pages/setting/widgets/slide_dialog.dart';
|
||||||
|
import 'package:pilipala/utils/global_data.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
import '../../models/common/dynamic_badge_mode.dart';
|
import '../../models/common/dynamic_badge_mode.dart';
|
||||||
@ -176,6 +177,8 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
SettingBoxKey.defaultPicQa, picQuality);
|
SettingBoxKey.defaultPicQa, picQuality);
|
||||||
Get.back();
|
Get.back();
|
||||||
settingController.picQuality.value = picQuality;
|
settingController.picQuality.value = picQuality;
|
||||||
|
GlobalData().imgQuality = picQuality;
|
||||||
|
SmartDialog.showToast('设置成功');
|
||||||
},
|
},
|
||||||
child: const Text('确定'),
|
child: const Text('确定'),
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,6 @@ import 'package:easy_debounce/easy_throttle.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/pages/fav/widgets/item.dart';
|
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
import 'widgets/item.dart';
|
import 'widgets/item.dart';
|
||||||
|
|
||||||
|
12
lib/utils/global_data.dart
Normal file
12
lib/utils/global_data.dart
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
class GlobalData {
|
||||||
|
int imgQuality = 10;
|
||||||
|
|
||||||
|
// 私有构造函数
|
||||||
|
GlobalData._();
|
||||||
|
|
||||||
|
// 单例实例
|
||||||
|
static final GlobalData _instance = GlobalData._();
|
||||||
|
|
||||||
|
// 获取全局实例
|
||||||
|
factory GlobalData() => _instance;
|
||||||
|
}
|
@ -1,11 +1,10 @@
|
|||||||
// import 'package:hive/hive.dart';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:hive_flutter/hive_flutter.dart';
|
import 'package:hive_flutter/hive_flutter.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:pilipala/models/model_owner.dart';
|
import 'package:pilipala/models/model_owner.dart';
|
||||||
import 'package:pilipala/models/search/hot.dart';
|
import 'package:pilipala/models/search/hot.dart';
|
||||||
import 'package:pilipala/models/user/info.dart';
|
import 'package:pilipala/models/user/info.dart';
|
||||||
|
import 'global_data.dart';
|
||||||
|
|
||||||
class GStrorage {
|
class GStrorage {
|
||||||
static late final Box<dynamic> userInfo;
|
static late final Box<dynamic> userInfo;
|
||||||
@ -44,6 +43,8 @@ class GStrorage {
|
|||||||
);
|
);
|
||||||
// 视频设置
|
// 视频设置
|
||||||
video = await Hive.openBox('video');
|
video = await Hive.openBox('video');
|
||||||
|
GlobalData().imgQuality =
|
||||||
|
setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10); // 设置全局变量
|
||||||
}
|
}
|
||||||
|
|
||||||
static void regAdapter() {
|
static void regAdapter() {
|
||||||
|
Reference in New Issue
Block a user