mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
refa: whisper page
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PBadge extends StatelessWidget {
|
||||
final String? text;
|
||||
|
||||
final bool isStack;
|
||||
final double? top;
|
||||
final double? right;
|
||||
final double? bottom;
|
||||
final double? left;
|
||||
final String? type;
|
||||
final String? size;
|
||||
final String? stack;
|
||||
final double? fs;
|
||||
final String? semanticsLabel;
|
||||
final bool bold;
|
||||
final double? textScaleFactor;
|
||||
final EdgeInsets? padding;
|
||||
|
||||
final PBadgeType type;
|
||||
final PBadgeSize size;
|
||||
|
||||
final double fontSize;
|
||||
final bool isBold;
|
||||
final double? textScaleFactor;
|
||||
|
||||
const PBadge({
|
||||
super.key,
|
||||
required this.text,
|
||||
@@ -23,12 +26,11 @@ class PBadge extends StatelessWidget {
|
||||
this.right,
|
||||
this.bottom,
|
||||
this.left,
|
||||
this.type = 'primary',
|
||||
this.size = 'medium',
|
||||
this.stack = 'position',
|
||||
this.fs = 11,
|
||||
this.semanticsLabel,
|
||||
this.bold = true,
|
||||
this.type = PBadgeType.primary,
|
||||
this.size = PBadgeSize.medium,
|
||||
this.isStack = true,
|
||||
this.fontSize = 11,
|
||||
this.isBold = true,
|
||||
this.textScaleFactor,
|
||||
this.padding,
|
||||
});
|
||||
@@ -40,37 +42,39 @@ class PBadge extends StatelessWidget {
|
||||
}
|
||||
|
||||
ColorScheme theme = Theme.of(context).colorScheme;
|
||||
// 背景色
|
||||
Color bgColor = theme.primary;
|
||||
// 前景色
|
||||
Color color = theme.onPrimary;
|
||||
// 边框色
|
||||
|
||||
Color bgColor;
|
||||
Color color;
|
||||
Color borderColor = Colors.transparent;
|
||||
if (type == 'gray') {
|
||||
bgColor = Colors.black45;
|
||||
color = Colors.white;
|
||||
} else if (type == 'color') {
|
||||
bgColor = theme.secondaryContainer.withOpacity(0.5);
|
||||
color = theme.onSecondaryContainer;
|
||||
} else if (type == 'line') {
|
||||
bgColor = Colors.transparent;
|
||||
color = theme.primary;
|
||||
borderColor = theme.primary;
|
||||
} else if (type == 'error') {
|
||||
bgColor = theme.error;
|
||||
color = theme.onError;
|
||||
|
||||
switch (type) {
|
||||
case PBadgeType.primary:
|
||||
bgColor = theme.primary;
|
||||
color = theme.onPrimary;
|
||||
case PBadgeType.secondary:
|
||||
bgColor = theme.secondaryContainer.withOpacity(0.5);
|
||||
color = theme.onSecondaryContainer;
|
||||
case PBadgeType.gray:
|
||||
bgColor = Colors.black45;
|
||||
color = Colors.white;
|
||||
case PBadgeType.error:
|
||||
bgColor = theme.error;
|
||||
color = theme.onError;
|
||||
case PBadgeType.line_primary:
|
||||
color = theme.primary;
|
||||
bgColor = Colors.transparent;
|
||||
borderColor = theme.primary;
|
||||
case PBadgeType.line_secondary:
|
||||
color = theme.secondary;
|
||||
bgColor = Colors.transparent;
|
||||
borderColor = theme.secondary;
|
||||
}
|
||||
|
||||
late EdgeInsets paddingStyle =
|
||||
const EdgeInsets.symmetric(vertical: 2, horizontal: 3);
|
||||
double fontSize = 11;
|
||||
BorderRadius br = const BorderRadius.all(Radius.circular(4));
|
||||
|
||||
if (size == 'small') {
|
||||
paddingStyle = const EdgeInsets.symmetric(vertical: 2, horizontal: 3);
|
||||
fontSize = 11;
|
||||
br = const BorderRadius.all(Radius.circular(3));
|
||||
}
|
||||
BorderRadius br = size == PBadgeSize.small
|
||||
? const BorderRadius.all(Radius.circular(3))
|
||||
: const BorderRadius.all(Radius.circular(4));
|
||||
|
||||
Widget content = Container(
|
||||
padding: padding ?? paddingStyle,
|
||||
@@ -86,20 +90,19 @@ class PBadge extends StatelessWidget {
|
||||
: null,
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
fontSize: fs ?? fontSize,
|
||||
fontSize: fontSize,
|
||||
color: color,
|
||||
fontWeight: bold ? FontWeight.bold : null,
|
||||
fontWeight: isBold ? FontWeight.bold : null,
|
||||
),
|
||||
strutStyle: StrutStyle(
|
||||
leading: 0,
|
||||
height: 1,
|
||||
fontSize: fs ?? fontSize,
|
||||
fontWeight: bold ? FontWeight.bold : null,
|
||||
fontSize: fontSize,
|
||||
fontWeight: isBold ? FontWeight.bold : null,
|
||||
),
|
||||
semanticsLabel: semanticsLabel,
|
||||
),
|
||||
);
|
||||
if (stack == 'position') {
|
||||
if (isStack) {
|
||||
return Positioned(
|
||||
top: top,
|
||||
left: left,
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/nine_grid_view.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models/common/image_preview_type.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
@@ -168,7 +169,7 @@ Widget imageView(
|
||||
text: 'Live',
|
||||
right: 8,
|
||||
bottom: 8,
|
||||
type: 'gray',
|
||||
type: PBadgeType.gray,
|
||||
)
|
||||
else if (picArr[index].isLongPic)
|
||||
const PBadge(
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:PiliPlus/common/widgets/progress_bar/video_progress_indicator.da
|
||||
import 'package:PiliPlus/common/widgets/stat/stat.dart';
|
||||
import 'package:PiliPlus/common/widgets/video_popup_menu.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models/model_hot_video_item.dart';
|
||||
import 'package:PiliPlus/models/model_video.dart';
|
||||
import 'package:PiliPlus/models/search/result.dart';
|
||||
@@ -158,7 +159,7 @@ class VideoCardH extends StatelessWidget {
|
||||
: '${Utils.timeFormat(progress)}/${Utils.timeFormat(videoItem.duration)}',
|
||||
right: 6,
|
||||
bottom: 8,
|
||||
type: 'gray',
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
@@ -175,14 +176,14 @@ class VideoCardH extends StatelessWidget {
|
||||
text: Utils.timeFormat(videoItem.duration),
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
type: 'gray',
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
if (type != 'video')
|
||||
PBadge(
|
||||
text: type,
|
||||
left: 6.0,
|
||||
bottom: 6.0,
|
||||
type: 'primary',
|
||||
type: PBadgeType.primary,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/progress_bar/video_progress_indicator.dart';
|
||||
import 'package:PiliPlus/common/widgets/stat/stat.dart';
|
||||
import 'package:PiliPlus/common/widgets/video_popup_menu.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models/space_archive/item.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
@@ -112,8 +113,8 @@ class VideoCardHMemberVideo extends StatelessWidget {
|
||||
right: 6.0,
|
||||
top: 6.0,
|
||||
type: videoItem.badges!.first.text == '充电专属'
|
||||
? 'error'
|
||||
: 'primary',
|
||||
? PBadgeType.error
|
||||
: PBadgeType.primary,
|
||||
),
|
||||
if (videoItem.history != null) ...[
|
||||
Builder(builder: (context) {
|
||||
@@ -140,7 +141,7 @@ class VideoCardHMemberVideo extends StatelessWidget {
|
||||
: '${Utils.timeFormat(videoItem.history!['progress'])}/${Utils.timeFormat(videoItem.history!['duration'])}',
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
type: 'gray',
|
||||
type: PBadgeType.gray,
|
||||
);
|
||||
} catch (_) {
|
||||
return PBadge(
|
||||
@@ -148,7 +149,7 @@ class VideoCardHMemberVideo extends StatelessWidget {
|
||||
Utils.timeFormat(videoItem.duration),
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
type: 'gray',
|
||||
type: PBadgeType.gray,
|
||||
);
|
||||
}
|
||||
}),
|
||||
@@ -157,7 +158,7 @@ class VideoCardHMemberVideo extends StatelessWidget {
|
||||
text: Utils.timeFormat(videoItem.duration),
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
type: 'gray',
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/stat/stat.dart';
|
||||
import 'package:PiliPlus/common/widgets/video_popup_menu.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models/home/rcmd/result.dart';
|
||||
import 'package:PiliPlus/models/model_rec_video_item.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
@@ -127,8 +128,8 @@ class VideoCardV extends StatelessWidget {
|
||||
PBadge(
|
||||
bottom: 6,
|
||||
right: 7,
|
||||
size: 'small',
|
||||
type: 'gray',
|
||||
size: PBadgeSize.small,
|
||||
type: PBadgeType.gray,
|
||||
text: Utils.timeFormat(videoItem.duration),
|
||||
)
|
||||
],
|
||||
@@ -180,38 +181,38 @@ class VideoCardV extends StatelessWidget {
|
||||
if (videoItem.goto == 'bangumi') ...[
|
||||
PBadge(
|
||||
text: videoItem.bangumiBadge,
|
||||
stack: 'normal',
|
||||
size: 'small',
|
||||
type: 'line',
|
||||
fs: 9,
|
||||
isStack: false,
|
||||
size: PBadgeSize.small,
|
||||
type: PBadgeType.line_primary,
|
||||
fontSize: 9,
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
],
|
||||
if (videoItem.rcmdReason != null) ...[
|
||||
PBadge(
|
||||
text: videoItem.rcmdReason,
|
||||
stack: 'normal',
|
||||
size: 'small',
|
||||
type: 'color',
|
||||
isStack: false,
|
||||
size: PBadgeSize.small,
|
||||
type: PBadgeType.secondary,
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
],
|
||||
if (videoItem.goto == 'picture') ...[
|
||||
const PBadge(
|
||||
text: '动态',
|
||||
stack: 'normal',
|
||||
size: 'small',
|
||||
type: 'line',
|
||||
fs: 9,
|
||||
isStack: false,
|
||||
size: PBadgeSize.small,
|
||||
type: PBadgeType.line_primary,
|
||||
fontSize: 9,
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
],
|
||||
if (videoItem.isFollowed) ...[
|
||||
const PBadge(
|
||||
text: '已关注',
|
||||
stack: 'normal',
|
||||
size: 'small',
|
||||
type: 'color',
|
||||
isStack: false,
|
||||
size: PBadgeSize.small,
|
||||
type: PBadgeType.secondary,
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
],
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:PiliPlus/common/widgets/badge.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/image_save.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
import 'package:PiliPlus/models/space/item.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
@@ -85,8 +86,8 @@ class VideoCardVMemberHome extends StatelessWidget {
|
||||
PBadge(
|
||||
bottom: 6,
|
||||
right: 7,
|
||||
size: 'small',
|
||||
type: 'gray',
|
||||
size: PBadgeSize.small,
|
||||
type: PBadgeType.gray,
|
||||
text: Utils.timeFormat(videoItem.duration),
|
||||
)
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user