chore: code clean up

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-11-10 09:49:06 +08:00
parent 03d405e197
commit 59910e275e
133 changed files with 597 additions and 816 deletions

View File

@@ -1,5 +1,3 @@
import 'dart:convert';
import 'package:flutter/material.dart';
class StyleString {

View File

@@ -13,8 +13,8 @@ class Skeleton extends StatelessWidget {
var shimmerGradient = LinearGradient(
colors: [
Colors.transparent,
Theme.of(context).colorScheme.background.withAlpha(10),
Theme.of(context).colorScheme.background.withAlpha(10),
Theme.of(context).colorScheme.surface.withAlpha(10),
Theme.of(context).colorScheme.surface.withAlpha(10),
Colors.transparent,
],
stops: const [

View File

@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'skeleton.dart';
class VideoCardVSkeleton extends StatelessWidget {
const VideoCardVSkeleton({Key? key}) : super(key: key);
const VideoCardVSkeleton({super.key});
@override
Widget build(BuildContext context) {

View File

@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'skeleton.dart';
class VideoReplySkeleton extends StatelessWidget {
const VideoReplySkeleton({Key? key}) : super(key: key);
const VideoReplySkeleton({super.key});
@override
Widget build(BuildContext context) {

View File

@@ -4,10 +4,10 @@ import 'package:flutter/material.dart';
class AnimatedDialog extends StatefulWidget {
const AnimatedDialog({
Key? key,
super.key,
required this.videoItem,
required this.closeFn,
}) : super(key: key);
});
final dynamic videoItem;
final Function closeFn;

View File

@@ -5,8 +5,8 @@ class AppBarWidget extends StatelessWidget implements PreferredSizeWidget {
required this.child,
required this.controller,
required this.visible,
Key? key,
}) : super(key: key);
super.key,
});
final PreferredSizeWidget child;
final AnimationController controller;

View File

@@ -74,7 +74,7 @@ class ProgressBar extends LeafRenderObjectWidget {
/// When a user drags the thumb to a new location you can be notified
/// by the [onSeek] callback so that you can update your audio/video player.
const ProgressBar({
Key? key,
super.key,
required this.progress,
required this.total,
this.buffered,
@@ -96,7 +96,7 @@ class ProgressBar extends LeafRenderObjectWidget {
this.timeLabelType,
this.timeLabelTextStyle,
this.timeLabelPadding = 0.0,
}) : super(key: key);
});
/// The elapsed playing time of the media.
///
@@ -257,7 +257,7 @@ class ProgressBar extends LeafRenderObjectWidget {
final theme = Theme.of(context);
final primaryColor = theme.colorScheme.primary;
final textStyle = timeLabelTextStyle ?? theme.textTheme.bodyLarge;
final textScaleFactor = MediaQuery.textScaleFactorOf(context);
final textScaleFactor = MediaQuery.textScalerOf(context).scale(1);
return _RenderProgressBar(
progress: progress,
total: total,
@@ -274,7 +274,7 @@ class ProgressBar extends LeafRenderObjectWidget {
thumbRadius: thumbRadius,
thumbColor: thumbColor ?? primaryColor,
thumbGlowColor:
thumbGlowColor ?? (thumbColor ?? primaryColor).withAlpha(80),
thumbGlowColor ?? (thumbColor ?? primaryColor).withAlpha(80),
thumbGlowRadius: thumbGlowRadius,
thumbCanPaintOutsideBar: thumbCanPaintOutsideBar,
timeLabelLocation: timeLabelLocation ?? TimeLabelLocation.below,
@@ -290,7 +290,7 @@ class ProgressBar extends LeafRenderObjectWidget {
final theme = Theme.of(context);
final primaryColor = theme.colorScheme.primary;
final textStyle = timeLabelTextStyle ?? theme.textTheme.bodyLarge;
final textScaleFactor = MediaQuery.textScaleFactorOf(context);
final textScaleFactor = MediaQuery.textScalerOf(context).scale(1);
(renderObject as _RenderProgressBar)
..progress = progress
..total = total
@@ -958,7 +958,7 @@ class _RenderProgressBar extends RenderBox {
// progress bar
final barDy =
(isLabelBelow) ? 0.0 : _leftLabelSize.height + _timeLabelPadding;
(isLabelBelow) ? 0.0 : _leftLabelSize.height + _timeLabelPadding;
_drawProgressBar(canvas, Offset(0, barDy), Size(barWidth, barHeight));
}
@@ -1042,9 +1042,9 @@ class _RenderProgressBar extends RenderBox {
void _drawBar(
{required Canvas canvas,
required Size availableSize,
required double widthProportion,
required Color color}) {
required Size availableSize,
required double widthProportion,
required Color color}) {
final strokeCap = (_barCapShape == BarCapShape.round)
? StrokeCap.round
: StrokeCap.square;
@@ -1085,7 +1085,7 @@ class _RenderProgressBar extends RenderBox {
String _getTimeString(Duration time) {
final minutes =
time.inMinutes.remainder(Duration.minutesPerHour).toString();
time.inMinutes.remainder(Duration.minutesPerHour).toString();
final seconds = time.inSeconds
.remainder(Duration.secondsPerMinute)
.toString()
@@ -1101,7 +1101,7 @@ class _RenderProgressBar extends RenderBox {
// description
config.textDirection = TextDirection.ltr;
config.label = '进度条';//'Progress bar';
config.label = '进度条'; //'Progress bar';
config.value = '${(_thumbValue * 100).round()}%';
// increase action

View File

@@ -6,13 +6,13 @@ class ContentContainer extends StatelessWidget {
final bool isScrollable;
final Clip? childClipBehavior;
const ContentContainer(
{Key? key,
this.contentWidget,
this.bottomWidget,
this.isScrollable = true,
this.childClipBehavior})
: super(key: key);
const ContentContainer({
super.key,
this.contentWidget,
this.bottomWidget,
this.isScrollable = true,
this.childClipBehavior,
});
@override
Widget build(BuildContext context) {

View File

@@ -1,7 +1,6 @@
import 'package:PiliPalaX/pages/preview/view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import '../../utils/storage.dart';
import 'network_img_layer.dart';
// ignore: must_be_immutable
@@ -21,8 +20,8 @@ class HtmlRender extends StatelessWidget {
@override
Widget build(BuildContext context) {
double textScale =
setting.get(SettingBoxKey.defaultTextScale, defaultValue: 1.0);
// double textScale =
// setting.get(SettingBoxKey.defaultTextScale, defaultValue: 1.0);
return SelectionArea(
child: Html(
data: htmlContent,

View File

@@ -166,7 +166,7 @@ class _ListSheetContentState extends State<ListSheetContent>
title = episode.pagePart!;
} else if (episode.runtimeType.toString() == "Part") {
title = episode.pagePart!;
// print("未知类型:${episode.runtimeType}");
// debugPrint("未知类型:${episode.runtimeType}");
}
return ListTile(
onTap: () {

View File

@@ -4,13 +4,12 @@ import '../constants.dart';
import 'network_img_layer.dart';
class LiveCard extends StatelessWidget {
// ignore: prefer_typing_uninitialized_variables
final dynamic liveItem;
const LiveCard({
Key? key,
super.key,
required this.liveItem,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {
@@ -75,9 +74,8 @@ class LiveCard extends StatelessWidget {
}
class LiveContent extends StatelessWidget {
// ignore: prefer_typing_uninitialized_variables
final liveItem;
const LiveContent({Key? key, required this.liveItem}) : super(key: key);
final dynamic liveItem;
const LiveContent({super.key, required this.liveItem});
@override
Widget build(BuildContext context) {
return Padding(

View File

@@ -1,6 +1,5 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:hive/hive.dart';
import 'package:PiliPalaX/utils/extension.dart';
import 'package:PiliPalaX/utils/global_data.dart';

View File

@@ -70,7 +70,7 @@ class PullToRefreshHeader extends StatelessWidget {
child: Container(
alignment: Alignment.centerRight,
margin: const EdgeInsets.only(right: 12.0),
child: RefreshImage(top, null),
child: RefreshImage(top: top),
),
),
Column(
@@ -93,7 +93,10 @@ class PullToRefreshHeader extends StatelessWidget {
}
class RefreshImage extends StatelessWidget {
const RefreshImage(this.top, Key? key) : super(key: key);
const RefreshImage({
super.key,
required this.top,
});
final double top;

View File

@@ -6,15 +6,14 @@ class StatDanMu extends StatelessWidget {
final dynamic danmu;
final String? size;
const StatDanMu({Key? key, this.theme, this.danmu, this.size})
: super(key: key);
const StatDanMu({super.key, this.theme, this.danmu, this.size});
@override
Widget build(BuildContext context) {
Map<String, Color> colorObject = {
'white': Colors.white,
'gray': Theme.of(context).colorScheme.outline.withOpacity(0.8),
'black': Theme.of(context).colorScheme.onBackground.withOpacity(0.7),
'black': Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
};
Color color = colorObject[theme]!;
return Row(

View File

@@ -7,15 +7,14 @@ class StatView extends StatelessWidget {
final String? size;
final String? goto;
const StatView({Key? key, this.theme, this.view, this.size, this.goto})
: super(key: key);
const StatView({super.key, this.theme, this.view, this.size, this.goto});
@override
Widget build(BuildContext context) {
Map<String, Color> colorObject = {
'white': Colors.white,
'gray': Theme.of(context).colorScheme.outline.withOpacity(0.8),
'black': Theme.of(context).colorScheme.onBackground.withOpacity(0.7),
'black': Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
};
Color color = colorObject[theme]!;
return Row(

View File

@@ -24,8 +24,7 @@ class VideoCardH extends StatelessWidget {
this.showDanmaku = true,
this.showPubdate = false,
});
// ignore: prefer_typing_uninitialized_variables
final videoItem;
final dynamic videoItem;
final Function()? longPress;
final Function()? longPressEnd;
final String source;
@@ -149,8 +148,7 @@ class VideoCardH extends StatelessWidget {
}
class VideoContent extends StatelessWidget {
// ignore: prefer_typing_uninitialized_variables
final videoItem;
final dynamic videoItem;
final String source;
final bool showOwner;
final bool showView;

View File

@@ -1,18 +1,11 @@
import 'package:PiliPalaX/grpc/app/card/v1/card.pb.dart' as card;
import 'package:PiliPalaX/utils/app_scheme.dart';
import 'package:PiliPalaX/utils/id_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import '../../http/search.dart';
import '../../utils/utils.dart';
import '../constants.dart';
import 'badge.dart';
import 'network_img_layer.dart';
import 'stat/danmu.dart';
import 'stat/view.dart';
import 'video_popup_menu.dart';
// 视频卡片 - 水平布局
class VideoCardHGrpc extends StatelessWidget {
@@ -27,7 +20,6 @@ class VideoCardHGrpc extends StatelessWidget {
this.showDanmaku = true,
this.showPubdate = false,
});
// ignore: prefer_typing_uninitialized_variables
final card.Card videoItem;
final Function()? longPress;
final Function()? longPressEnd;
@@ -40,7 +32,7 @@ class VideoCardHGrpc extends StatelessWidget {
@override
Widget build(BuildContext context) {
final int aid = videoItem.smallCoverV5.base.args.aid.toInt();
final String bvid = IdUtils.av2bv(aid);
// final String bvid = IdUtils.av2bv(aid);
String type = 'video';
// try {
// type = videoItem.type;
@@ -158,7 +150,6 @@ class VideoCardHGrpc extends StatelessWidget {
}
class VideoContent extends StatelessWidget {
// ignore: prefer_typing_uninitialized_variables
final card.Card videoItem;
final String source;
final bool showOwner;

View File

@@ -1,4 +1,3 @@
import 'package:PiliPalaX/models/bangumi/info.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@@ -8,8 +7,6 @@ import '../../models/model_rec_video_item.dart';
import 'stat/danmu.dart';
import 'stat/view.dart';
import '../../http/dynamics.dart';
import '../../http/search.dart';
import '../../models/common/search_type.dart';
import '../../utils/id_utils.dart';
import '../../utils/utils.dart';
import '../constants.dart';
@@ -24,11 +21,11 @@ class VideoCardV extends StatelessWidget {
final Function()? longPressEnd;
const VideoCardV({
Key? key,
super.key,
required this.videoItem,
this.longPress,
this.longPressEnd,
}) : super(key: key);
});
bool isStringNumeric(String str) {
RegExp numericRegex = RegExp(r'^\d+$');
@@ -218,7 +215,7 @@ class VideoCardV extends StatelessWidget {
class VideoContent extends StatelessWidget {
final dynamic videoItem;
const VideoContent({Key? key, required this.videoItem}) : super(key: key);
const VideoContent({super.key, required this.videoItem});
@override
Widget build(BuildContext context) {
return Expanded(
@@ -312,9 +309,9 @@ class VideoStat extends StatelessWidget {
final dynamic videoItem;
const VideoStat({
Key? key,
super.key,
required this.videoItem,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {

View File

@@ -1,22 +1,11 @@
import 'package:PiliPalaX/models/bangumi/info.dart';
import 'package:PiliPalaX/models/space/item.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import '../../models/home/rcmd/result.dart';
import '../../models/model_rec_video_item.dart';
import 'stat/danmu.dart';
import 'stat/view.dart';
import '../../http/dynamics.dart';
import '../../http/search.dart';
import '../../models/common/search_type.dart';
import '../../utils/id_utils.dart';
import '../../utils/utils.dart';
import '../constants.dart';
import 'badge.dart';
import 'network_img_layer.dart';
import 'video_popup_menu.dart';
// 视频卡片 - 垂直布局
class VideoCardVMemberHome extends StatelessWidget {