Skip to content

Commit

Permalink
mod: 部分弹出层调整,封面长按能力统一
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Jan 11, 2025
1 parent 6c99d15 commit ddd48fb
Show file tree
Hide file tree
Showing 28 changed files with 1,202 additions and 1,157 deletions.
49 changes: 31 additions & 18 deletions lib/common/widgets/list_sheet.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';

import '../../utils/storage.dart';
import '../../utils/utils.dart';

class ListSheet {
ListSheet({
Expand All @@ -23,18 +25,19 @@ class ListSheet {
final Function changeFucCall;
final BuildContext context;

late PersistentBottomSheetController bottomSheetController;

void buildShowBottomSheet() {
bottomSheetController = showBottomSheet(
context: context,
builder: (context) => ListSheetContent(
SmartDialog.show(
alignment: MediaQuery.of(context).orientation == Orientation.portrait
? Alignment.bottomRight
: Alignment.topRight,
useSystem: true,
builder: (BuildContext context) => ListSheetContent(
episodes: episodes,
bvid: bvid,
aid: aid,
currentCid: currentCid,
changeFucCall: changeFucCall,
onClose: bottomSheetController.close,
onClose: SmartDialog.dismiss,
));
}
}
Expand Down Expand Up @@ -116,15 +119,16 @@ class _ListSheetContentState extends State<ListSheetContent> {
widget.changeFucCall(widget.bvid!, episode.cid, widget.aid!);
}
},
dense: false,
leading: isCurrentIndex
? Image.asset(
'assets/images/live.png',
color: primary,
height: 12,
semanticLabel: "正在播放:",
)
: null,
selected: isCurrentIndex,
// dense: false,
// leading: isCurrentIndex
// ? Image.asset(
// 'assets/images/live.png',
// color: primary,
// height: 12,
// semanticLabel: "正在播放:",
// )
// : null,
title: Text(
title,
style: TextStyle(
Expand All @@ -133,6 +137,7 @@ class _ListSheetContentState extends State<ListSheetContent> {
? primary
: Theme.of(context).colorScheme.onSurface,
),
semanticsLabel: isCurrentIndex ? "正在播放:$title" : title,
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
Expand All @@ -158,8 +163,15 @@ class _ListSheetContentState extends State<ListSheetContent> {
@override
Widget build(BuildContext context) {
return Container(
height: Utils.getSheetHeight(context),
color: Theme.of(context).colorScheme.surface,
height: 500,
width: min(Get.width, 500),
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
borderRadius: const BorderRadius.all(Radius.circular(12)),
),
margin: const EdgeInsets.all(12),
padding: const EdgeInsets.all(6),
child: Column(
children: [
Container(
Expand Down Expand Up @@ -215,6 +227,7 @@ class _ListSheetContentState extends State<ListSheetContent> {
height: 1,
color: Theme.of(context).dividerColor.withOpacity(0.1),
),
const SizedBox(height: 1),
Expanded(
child: Material(
child: ScrollablePositionedList.separated(
Expand Down
90 changes: 71 additions & 19 deletions lib/common/widgets/overlay_pop.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import '../../http/user.dart';
import '../../utils/download.dart';
import '../constants.dart';
import 'network_img_layer.dart';
Expand All @@ -15,6 +18,7 @@ class OverlayPop extends StatelessWidget {
@override
Widget build(BuildContext context) {
final double imgWidth = min(Get.height, Get.width) - 8 * 2;
print('videoItem.title: ${videoItem.title}');
return Container(
margin: const EdgeInsets.symmetric(horizontal: 8),
width: imgWidth,
Expand All @@ -31,7 +35,9 @@ class OverlayPop extends StatelessWidget {
NetworkImgLayer(
width: imgWidth,
height: imgWidth / StyleString.aspectRatio,
src: videoItem.pic! as String,
src: (videoItem.runtimeType.toString() == "DynamicArchiveModel")
? videoItem.cover ?? ''
: videoItem.pic ?? videoItem.cover ?? '',
quality: 100,
),
Positioned(
Expand Down Expand Up @@ -61,30 +67,76 @@ class OverlayPop extends StatelessWidget {
],
),
Padding(
padding: const EdgeInsets.fromLTRB(12, 10, 8, 10),
child: Row(
children: [
padding: const EdgeInsets.fromLTRB(12, 10, 8, 10),
child: Row(
children: [
if (videoItem.title is String) ...[
Expanded(
child: Text(
videoItem.title! as String,
child: SelectableText(
videoItem.title ?? '',
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize:
Theme.of(context).textTheme.bodyMedium!.fontSize,
height: 1.42,
letterSpacing: 0.3,
),
// overflow: TextOverflow.ellipsis,
),
),
const SizedBox(width: 4),
] else ...[
Expanded(
child: RichText(
overflow: TextOverflow.ellipsis,
maxLines: 2,
text: TextSpan(
children: [
for (final i in videoItem.title) ...[
TextSpan(
text: i['text'] as String,
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: Theme.of(context)
.textTheme
.bodyMedium!
.fontSize,
letterSpacing: 0.3,
color: i['type'] == 'em'
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.onSurface,
),
),
]
],
),
),
),
],
if (videoItem.runtimeType.toString() != 'LiveItemModel')
IconButton(
tooltip: '保存封面图',
tooltip: '稍后再看',
icon: Icon(MdiIcons.clockTimeEightOutline, size: 20),
onPressed: () async {
await DownloadUtils.downloadImg(
context,
videoItem.pic != null
? videoItem.pic as String
: videoItem.cover as String,
);
// closeFn!();
var res = await UserHttp.toViewLater(
bvid: videoItem.bvid as String);
SmartDialog.showToast(res['msg']);
},
icon: const Icon(Icons.download, size: 20),
)
],
)),
),
const SizedBox(width: 4),
IconButton(
tooltip: '保存封面图',
onPressed: () async {
await DownloadUtils.downloadImg(
context,
videoItem.pic ?? videoItem.cover ?? '',
);
// closeFn!();
},
icon: const Icon(Icons.download_outlined, size: 20),
)
],
),
),
],
),
);
Expand Down
Loading

0 comments on commit ddd48fb

Please sign in to comment.