mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -1,13 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
Future<void> showConfirmDialog({
|
||||
void showConfirmDialog({
|
||||
required BuildContext context,
|
||||
required String title,
|
||||
dynamic content,
|
||||
required VoidCallback onConfirm,
|
||||
}) {
|
||||
return showDialog(
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/models/common/image_type.dart';
|
||||
import 'package:PiliPlus/utils/context_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/image_util.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
@@ -43,26 +42,25 @@ class NetworkImgLayer extends StatelessWidget {
|
||||
final BoxFit? boxFit;
|
||||
|
||||
static Color? reduceLuxColor = Pref.reduceLuxColor;
|
||||
static bool reduce = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final reduce =
|
||||
quality != 100 && reduceLuxColor != null && context.isDarkMode;
|
||||
return src?.isNotEmpty == true
|
||||
? type == ImageType.avatar
|
||||
? ClipOval(child: _buildImage(context, reduce))
|
||||
? ClipOval(child: _buildImage(context))
|
||||
: radius == 0 || type == ImageType.emote
|
||||
? _buildImage(context, reduce)
|
||||
? _buildImage(context)
|
||||
: ClipRRect(
|
||||
borderRadius: radius != null
|
||||
? BorderRadius.circular(radius!)
|
||||
: StyleString.mdRadius,
|
||||
child: _buildImage(context, reduce),
|
||||
child: _buildImage(context),
|
||||
)
|
||||
: getPlaceHolder?.call() ?? _placeholder(context, reduce);
|
||||
: getPlaceHolder?.call() ?? _placeholder(context);
|
||||
}
|
||||
|
||||
Widget _buildImage(BuildContext context, bool reduce) {
|
||||
Widget _buildImage(BuildContext context) {
|
||||
int? memCacheWidth, memCacheHeight;
|
||||
if (height == null || forceUseCacheWidth || width <= height!) {
|
||||
memCacheWidth = width.cacheSize(context);
|
||||
@@ -81,15 +79,15 @@ class NetworkImgLayer extends StatelessWidget {
|
||||
fadeInDuration: fadeInDuration ?? const Duration(milliseconds: 120),
|
||||
filterQuality: FilterQuality.low,
|
||||
placeholder: (BuildContext context, String url) =>
|
||||
getPlaceHolder?.call() ?? _placeholder(context, reduce),
|
||||
getPlaceHolder?.call() ?? _placeholder(context),
|
||||
imageBuilder: imageBuilder,
|
||||
errorWidget: (context, url, error) => _placeholder(context, reduce),
|
||||
errorWidget: (context, url, error) => _placeholder(context),
|
||||
colorBlendMode: reduce ? BlendMode.modulate : null,
|
||||
color: reduce ? reduceLuxColor : null,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _placeholder(BuildContext context, bool reduce) {
|
||||
Widget _placeholder(BuildContext context) {
|
||||
return Container(
|
||||
width: width,
|
||||
height: height,
|
||||
|
||||
@@ -41,6 +41,8 @@ class _MainAppState extends State<MainApp>
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
NetworkImgLayer.reduce =
|
||||
NetworkImgLayer.reduceLuxColor != null && context.isDarkMode;
|
||||
MainApp.routeObserver.subscribe(this, ModalRoute.of(context) as PageRoute);
|
||||
}
|
||||
|
||||
|
||||
@@ -449,6 +449,7 @@ List<SettingsModel> get styleSettings => [
|
||||
SettingsModel(
|
||||
settingsType: SettingsType.normal,
|
||||
onTap: (setState) {
|
||||
final reduceLuxColor = Pref.reduceLuxColor;
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) => AlertDialog(
|
||||
@@ -457,9 +458,9 @@ List<SettingsModel> get styleSettings => [
|
||||
title: const Text('Color Picker'),
|
||||
content: SlideColorPicker(
|
||||
showResetBtn: false,
|
||||
color: Pref.reduceLuxColor ?? Colors.white,
|
||||
callback: (Color? color) async {
|
||||
if (color != null && color != Pref.reduceLuxColor) {
|
||||
color: reduceLuxColor ?? Colors.white,
|
||||
callback: (Color? color) {
|
||||
if (color != null && color != reduceLuxColor) {
|
||||
if (color == Colors.white) {
|
||||
NetworkImgLayer.reduceLuxColor = null;
|
||||
GStorage.setting.delete(SettingBoxKey.reduceLuxColor);
|
||||
@@ -477,7 +478,7 @@ List<SettingsModel> get styleSettings => [
|
||||
}
|
||||
|
||||
if (color.computeLuminance() < 0.2) {
|
||||
await showConfirmDialog(
|
||||
showConfirmDialog(
|
||||
context: context,
|
||||
title:
|
||||
'确认使用#${(color.toARGB32() & 0xFFFFFF).toRadixString(16).toUpperCase().padLeft(6)}?',
|
||||
|
||||
Reference in New Issue
Block a user