opt: image view

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-12-15 11:44:44 +08:00
parent fee1ad56f7
commit 52f888167f
11 changed files with 120 additions and 57 deletions

View File

@@ -11,6 +11,8 @@ class SetSwitchItem extends StatefulWidget {
final bool? needReboot;
final Widget? leading;
final GestureTapCallback? onTap;
final EdgeInsetsGeometry? contentPadding;
final TextStyle? titleStyle;
const SetSwitchItem({
this.title,
@@ -21,6 +23,8 @@ class SetSwitchItem extends StatefulWidget {
this.needReboot,
this.leading,
this.onTap,
this.contentPadding,
this.titleStyle,
super.key,
});
@@ -45,7 +49,7 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
// Utils.checkUpdate();
// }
widget.onChanged?.call(val);
if (widget.needReboot != null && widget.needReboot!) {
if (widget.needReboot == true) {
SmartDialog.showToast('重启生效');
}
setState(() {});
@@ -53,15 +57,18 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
@override
Widget build(BuildContext context) {
TextStyle titleStyle = Theme.of(context).textTheme.titleMedium!.copyWith(
color: widget.onTap != null && !val
? Theme.of(context).colorScheme.outline
: null);
TextStyle titleStyle = widget.titleStyle ??
Theme.of(context).textTheme.titleMedium!.copyWith(
color: widget.onTap != null && !val
? Theme.of(context).colorScheme.outline
: null,
);
TextStyle subTitleStyle = Theme.of(context)
.textTheme
.labelMedium!
.copyWith(color: Theme.of(context).colorScheme.outline);
return ListTile(
contentPadding: widget.contentPadding,
enabled: widget.onTap != null ? val : true,
enableFeedback: true,
onTap: () =>

View File

@@ -48,6 +48,7 @@ class _SubPageState extends State<SubPage> {
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
// TODO: refactor
Map? data = snapshot.data;
if (data != null && data['status']) {
return Obx(() => CustomScrollView(

View File

@@ -202,6 +202,15 @@ class _SubDetailPageState extends State<SubDetailPage> {
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
// TODO: refactor
if (snapshot.data is! Map) {
return HttpError(
callback: () => setState(() {
_futureBuilderFuture =
_subDetailController.queryUserSubFolderDetail();
}),
);
}
Map data = snapshot.data;
if (data['status']) {
if (_subDetailController.item.mediaCount == 0) {

View File

@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:io';
import 'dart:math';
import 'package:PiliPalaX/pages/setting/widgets/switch_item.dart';
import 'package:PiliPalaX/utils/id_utils.dart';
import 'package:canvas_danmaku/canvas_danmaku.dart';
import 'package:floating/floating.dart';
@@ -916,6 +917,7 @@ class _HeaderControlState extends State<HeaderControl> {
double strokeWidth = widget.controller!.strokeWidth;
// 字体粗细
int fontWeight = widget.controller!.fontWeight;
bool massiveMode = widget.controller!.massiveMode;
final DanmakuController danmakuController =
widget.controller!.danmakuController!;
@@ -1041,7 +1043,7 @@ class _HeaderControlState extends State<HeaderControl> {
),
const Text('显示区域'),
Padding(
padding: const EdgeInsets.only(top: 12, bottom: 18),
padding: const EdgeInsets.only(top: 12),
child: Row(
children: [
for (final Map<String, dynamic> i in showAreas) ...[
@@ -1066,6 +1068,23 @@ class _HeaderControlState extends State<HeaderControl> {
],
),
),
SetSwitchItem(
title: '海量弹幕',
contentPadding: EdgeInsets.all(0),
titleStyle: TextStyle(fontSize: 14),
defaultVal: massiveMode,
setKey: SettingBoxKey.danmakuMassiveMode,
onChanged: (value) {
massiveMode = value;
widget.controller!.massiveMode = value;
setState(() {});
try {
danmakuController.updateOption(
danmakuController.option.copyWith(massiveMode: value),
);
} catch (_) {}
},
),
Text('不透明度 ${opacityVal * 100}%'),
Padding(
padding: const EdgeInsets.only(
@@ -1261,6 +1280,47 @@ class _HeaderControlState extends State<HeaderControl> {
),
),
),
Text('弹幕时长 $danmakuDurationVal'),
Padding(
padding: const EdgeInsets.only(
top: 0,
bottom: 6,
left: 10,
right: 10,
),
child: SliderTheme(
data: SliderThemeData(
trackShape: MSliderTrackShape(),
thumbColor: Theme.of(context).colorScheme.primary,
activeTrackColor: Theme.of(context).colorScheme.primary,
trackHeight: 10,
thumbShape: const RoundSliderThumbShape(
enabledThumbRadius: 6.0),
),
child: Slider(
min: 1,
max: 4,
value: pow(danmakuDurationVal, 1 / 4) as double,
divisions: 60,
label: danmakuDurationVal.toString(),
onChanged: (double val) {
danmakuDurationVal =
(pow(val, 4) as double).toPrecision(2);
widget.controller!.danmakuDurationVal =
danmakuDurationVal;
widget.controller?.putDanmakuSettings();
setState(() {});
try {
danmakuController.updateOption(
danmakuController.option.copyWith(
duration: danmakuDurationVal ~/
widget.controller!.playbackSpeed),
);
} catch (_) {}
},
),
),
),
Text(
'字幕字体大小 ${(subtitleFontScale * 100).toStringAsFixed(1)}%'),
Padding(
@@ -1331,47 +1391,6 @@ class _HeaderControlState extends State<HeaderControl> {
),
),
),
Text('弹幕时长 $danmakuDurationVal'),
Padding(
padding: const EdgeInsets.only(
top: 0,
bottom: 6,
left: 10,
right: 10,
),
child: SliderTheme(
data: SliderThemeData(
trackShape: MSliderTrackShape(),
thumbColor: Theme.of(context).colorScheme.primary,
activeTrackColor: Theme.of(context).colorScheme.primary,
trackHeight: 10,
thumbShape: const RoundSliderThumbShape(
enabledThumbRadius: 6.0),
),
child: Slider(
min: 1,
max: 4,
value: pow(danmakuDurationVal, 1 / 4) as double,
divisions: 60,
label: danmakuDurationVal.toString(),
onChanged: (double val) {
danmakuDurationVal =
(pow(val, 4) as double).toPrecision(2);
widget.controller!.danmakuDurationVal =
danmakuDurationVal;
widget.controller?.putDanmakuSettings();
setState(() {});
try {
danmakuController.updateOption(
danmakuController.option.copyWith(
duration: danmakuDurationVal ~/
widget.controller!.playbackSpeed),
);
} catch (_) {}
},
),
),
),
],
),
),