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