mod: 代码整理

This commit is contained in:
guozhigq
2023-07-25 23:44:09 +08:00
parent 6d9f66c420
commit 7745ea076b
74 changed files with 387 additions and 424 deletions

View File

@ -27,9 +27,6 @@ class VideoCardHSkeleton extends StatelessWidget {
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight;
double PR = MediaQuery.of(context).devicePixelRatio;
return Container(
decoration: BoxDecoration(
color: Theme.of(context)

View File

@ -13,7 +13,6 @@ class AppBarWidget extends StatelessWidget implements PreferredSizeWidget {
final bool visible;
@override
// TODO: implement preferredSize
Size get preferredSize => child.preferredSize;
@override

View File

@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
class HttpError extends StatelessWidget {
HttpError({required this.errMsg, required this.fn, super.key});
const HttpError({required this.errMsg, required this.fn, super.key});
String errMsg = '';
final String? errMsg;
final Function()? fn;
@override
@ -16,7 +16,7 @@ class HttpError extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
errMsg,
errMsg ?? '请求异常',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
),

View File

@ -6,9 +6,10 @@ import 'package:pilipala/pages/rcmd/controller.dart';
import 'package:pilipala/utils/utils.dart';
class LiveCard extends StatelessWidget {
var liveItem;
// ignore: prefer_typing_uninitialized_variables
final liveItem;
LiveCard({
const LiveCard({
Key? key,
required this.liveItem,
}) : super(key: key);
@ -37,14 +38,11 @@ class LiveCard extends StatelessWidget {
child: LayoutBuilder(builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight;
double PR = MediaQuery.of(context).devicePixelRatio;
return Stack(
children: [
Hero(
tag: heroTag,
child: NetworkImgLayer(
// 指定图片尺寸
// src: videoItem.pic + '@${(maxWidth * 2).toInt()}w',
src: liveItem.cover + '@.webp',
type: 'emote',
width: maxWidth,
@ -79,6 +77,7 @@ 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);
@override
@ -140,19 +139,19 @@ class LiveStat extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
// StatView(
// theme: 'white',
// view: view,
// ),
// const SizedBox(width: 8),
// StatDanMu(
// theme: 'white',
// danmu: danmaku,
// ),
],
),
// Row(
// children: [
// StatView(
// theme: 'white',
// view: view,
// ),
// const SizedBox(width: 8),
// StatDanMu(
// theme: 'white',
// danmu: danmaku,
// ),
// ],
// ),
Text(
online.toString(),
style: const TextStyle(fontSize: 11, color: Colors.white),

View File

@ -3,8 +3,8 @@ import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
class OverlayPop extends StatelessWidget {
var videoItem;
OverlayPop({super.key, this.videoItem});
final dynamic videoItem;
const OverlayPop({super.key, this.videoItem});
@override
Widget build(BuildContext context) {

View File

@ -1,3 +1,5 @@
// ignore_for_file: depend_on_referenced_packages
import 'dart:math';
import 'dart:ui' as ui show Image;
@ -15,7 +17,8 @@ class PullToRefreshHeader extends StatelessWidget {
this.info,
this.lastRefreshTime, {
this.color,
});
Key? key,
}) : super(key: key);
final PullToRefreshScrollNotificationInfo? info;
final DateTime? lastRefreshTime;
@ -23,21 +26,21 @@ class PullToRefreshHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
final PullToRefreshScrollNotificationInfo? _info = info;
if (_info == null) {
final PullToRefreshScrollNotificationInfo? infos = info;
if (infos == null) {
return Container();
}
String text = '';
if (_info.mode == PullToRefreshIndicatorMode.armed) {
if (infos.mode == PullToRefreshIndicatorMode.armed) {
text = 'Release to refresh';
} else if (_info.mode == PullToRefreshIndicatorMode.refresh ||
_info.mode == PullToRefreshIndicatorMode.snap) {
} else if (infos.mode == PullToRefreshIndicatorMode.refresh ||
infos.mode == PullToRefreshIndicatorMode.snap) {
text = 'Loading...';
} else if (_info.mode == PullToRefreshIndicatorMode.done) {
} else if (infos.mode == PullToRefreshIndicatorMode.done) {
text = 'Refresh completed.';
} else if (_info.mode == PullToRefreshIndicatorMode.drag) {
} else if (infos.mode == PullToRefreshIndicatorMode.drag) {
text = 'Pull to refresh';
} else if (_info.mode == PullToRefreshIndicatorMode.canceled) {
} else if (infos.mode == PullToRefreshIndicatorMode.canceled) {
text = 'Cancel refresh';
}
@ -67,16 +70,15 @@ class PullToRefreshHeader extends StatelessWidget {
Expanded(
child: Container(
alignment: Alignment.centerRight,
child: RefreshImage(top),
margin: const EdgeInsets.only(right: 12.0),
child: RefreshImage(top, null),
),
),
Column(
children: <Widget>[
Text(text, style: ts),
Text(
'Last updated:' +
DateFormat('yyyy-MM-dd hh:mm').format(time),
'Last updated:${DateFormat('yyyy-MM-dd hh:mm').format(time)}',
style: ts.copyWith(fontSize: 14),
)
],
@ -92,7 +94,7 @@ class PullToRefreshHeader extends StatelessWidget {
}
class RefreshImage extends StatelessWidget {
const RefreshImage(this.top);
const RefreshImage(this.top, Key? key) : super(key: key);
final double top;

View File

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pilipala/utils/utils.dart';

View File

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pilipala/utils/utils.dart';

View File

@ -12,11 +12,11 @@ import 'package:pilipala/common/widgets/network_img_layer.dart';
// 视频卡片 - 水平布局
class VideoCardH extends StatelessWidget {
// ignore: prefer_typing_uninitialized_variables
var videoItem;
Function()? longPress;
Function()? longPressEnd;
final videoItem;
final Function()? longPress;
final Function()? longPressEnd;
VideoCardH({
const VideoCardH({
Key? key,
required this.videoItem,
this.longPress,
@ -71,21 +71,16 @@ class VideoCardH extends StatelessWidget {
builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight;
double PR =
MediaQuery.of(context).devicePixelRatio;
return Stack(
children: [
Hero(
tag: heroTag,
child: NetworkImgLayer(
// src: videoItem['pic'] +
// '@${(maxWidth * 2).toInt()}w',
src: videoItem.pic + '@.webp',
width: maxWidth,
height: maxHeight,
),
),
// Image.network( videoItem['pic'], width: double.infinity, height: double.infinity,),
pBadge(Utils.timeFormat(videoItem.duration!),
context, null, 6.0, 6.0, null,
type: 'gray'),
@ -119,6 +114,7 @@ class VideoCardH extends StatelessWidget {
}
class VideoContent extends StatelessWidget {
// ignore: prefer_typing_uninitialized_variables
final videoItem;
const VideoContent({super.key, required this.videoItem});
@ -186,7 +182,7 @@ class VideoContent extends StatelessWidget {
Text(
videoItem.owner.name,
style: TextStyle(
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
color: Theme.of(context).colorScheme.outline,
),
),

View File

@ -6,16 +6,16 @@ import 'package:pilipala/common/widgets/stat/view.dart';
import 'package:pilipala/pages/rcmd/index.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'package:pilipala/utils/utils.dart';
import 'package:pilipala/pages/home/controller.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
// 视频卡片 - 垂直布局
class VideoCardV extends StatelessWidget {
var videoItem;
Function()? longPress;
Function()? longPressEnd;
// ignore: prefer_typing_uninitialized_variables
final videoItem;
final Function()? longPress;
final Function()? longPressEnd;
VideoCardV({
const VideoCardV({
Key? key,
required this.videoItem,
this.longPress,
@ -67,14 +67,11 @@ class VideoCardV extends StatelessWidget {
child: LayoutBuilder(builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight;
double PR = MediaQuery.of(context).devicePixelRatio;
return Stack(
children: [
Hero(
tag: heroTag,
child: NetworkImgLayer(
// 指定图片尺寸
// src: videoItem.pic + '@${(maxWidth * 2).toInt()}w',
src: videoItem.pic + '@.webp',
width: maxWidth,
height: maxHeight,
@ -111,6 +108,7 @@ class VideoCardV extends StatelessWidget {
}
class VideoContent extends StatelessWidget {
// ignore: prefer_typing_uninitialized_variables
final videoItem;
const VideoContent({Key? key, required this.videoItem}) : super(key: key);
@override