mod: format code

This commit is contained in:
guozhigq
2024-01-07 12:58:24 +08:00
parent 7a71798055
commit fa8fd42e9a
104 changed files with 1077 additions and 1032 deletions

View File

@ -1,17 +1,28 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/badge.dart';
import 'package:pilipala/common/widgets/stat/danmu.dart';
import 'package:pilipala/common/widgets/stat/view.dart';
import 'package:pilipala/http/search.dart';
import 'package:pilipala/http/user.dart';
import 'package:pilipala/utils/utils.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import '../../http/search.dart';
import '../../http/user.dart';
import '../../utils/utils.dart';
import '../constants.dart';
import 'badge.dart';
import 'network_img_layer.dart';
import 'stat/danmu.dart';
import 'stat/view.dart';
// 视频卡片 - 水平布局
class VideoCardH extends StatelessWidget {
const VideoCardH({
super.key,
required this.videoItem,
this.longPress,
this.longPressEnd,
this.source = 'normal',
this.showOwner = true,
this.showView = true,
this.showDanmaku = true,
this.showPubdate = false,
});
// ignore: prefer_typing_uninitialized_variables
final videoItem;
final Function()? longPress;
@ -22,23 +33,11 @@ class VideoCardH extends StatelessWidget {
final bool showDanmaku;
final bool showPubdate;
const VideoCardH({
Key? key,
required this.videoItem,
this.longPress,
this.longPressEnd,
this.source = 'normal',
this.showOwner = true,
this.showView = true,
this.showDanmaku = true,
this.showPubdate = false,
}) : super(key: key);
@override
Widget build(BuildContext context) {
int aid = videoItem.aid;
String bvid = videoItem.bvid;
String heroTag = Utils.makeHeroTag(aid);
final int aid = videoItem.aid;
final String bvid = videoItem.bvid;
final String heroTag = Utils.makeHeroTag(aid);
return GestureDetector(
onLongPress: () {
if (longPress != null) {
@ -53,7 +52,7 @@ class VideoCardH extends StatelessWidget {
child: InkWell(
onTap: () async {
try {
int cid =
final int cid =
videoItem.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid);
Get.toNamed('/video?bvid=$bvid&cid=$cid',
arguments: {'videoItem': videoItem, 'heroTag': heroTag});
@ -65,8 +64,8 @@ class VideoCardH extends StatelessWidget {
padding: const EdgeInsets.fromLTRB(
StyleString.safeSpace, 5, StyleString.safeSpace, 5),
child: LayoutBuilder(
builder: (context, boxConstraints) {
double width = (boxConstraints.maxWidth -
builder: (BuildContext context, BoxConstraints boxConstraints) {
final double width = (boxConstraints.maxWidth -
StyleString.cardSpace *
6 /
MediaQuery.of(context).textScaleFactor) /
@ -77,29 +76,28 @@ class VideoCardH extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
children: <Widget>[
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight;
builder: (BuildContext context,
BoxConstraints boxConstraints) {
final double maxWidth = boxConstraints.maxWidth;
final double maxHeight = boxConstraints.maxHeight;
return Stack(
children: [
Hero(
tag: heroTag,
child: NetworkImgLayer(
src: videoItem.pic,
src: videoItem.pic as String,
width: maxWidth,
height: maxHeight,
),
),
PBadge(
text: Utils.timeFormat(videoItem.duration!),
top: null,
right: 6.0,
bottom: 6.0,
left: null,
type: 'gray',
),
// if (videoItem.rcmdReason != null &&
@ -159,7 +157,7 @@ class VideoContent extends StatelessWidget {
children: [
if (videoItem.title is String) ...[
Text(
videoItem.title,
videoItem.title as String,
textAlign: TextAlign.start,
style: const TextStyle(
fontWeight: FontWeight.w500,
@ -172,9 +170,9 @@ class VideoContent extends StatelessWidget {
maxLines: 2,
text: TextSpan(
children: [
for (var i in videoItem.title) ...[
for (final i in videoItem.title) ...[
TextSpan(
text: i['text'],
text: i['text'] as String,
style: TextStyle(
fontWeight: FontWeight.w500,
letterSpacing: 0.3,
@ -216,7 +214,7 @@ class VideoContent extends StatelessWidget {
Row(
children: [
Text(
videoItem.owner.name,
videoItem.owner.name as String,
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize,
@ -230,14 +228,14 @@ class VideoContent extends StatelessWidget {
if (showView) ...[
StatView(
theme: 'gray',
view: videoItem.stat.view,
view: videoItem.stat.view as int,
),
const SizedBox(width: 8),
],
if (showDanmaku)
StatDanMu(
theme: 'gray',
danmu: videoItem.stat.danmaku,
danmu: videoItem.stat.danmaku as int,
),
const Spacer(),
@ -281,8 +279,8 @@ class VideoContent extends StatelessWidget {
PopupMenuItem<String>(
onTap: () async {
var res = await UserHttp.toViewLater(
bvid: videoItem.bvid);
SmartDialog.showToast(res['msg']);
bvid: videoItem.bvid as String);
SmartDialog.showToast(res['msg'] as String);
},
value: 'pause',
height: 35,