mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-30 06:10:10 +08:00
opt: simple dialog
This commit is contained in:
@@ -123,137 +123,117 @@ class PgcIntroController extends CommonIntroController {
|
||||
'${HttpString.baseUrl}/bangumi/play/ep$epId${videoDetailCtr.playedTimePos}';
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
builder: (_) => SimpleDialog(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'复制链接',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Utils.copyText(videoUrl);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'其它app打开',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
PageUtils.launchURL(videoUrl);
|
||||
},
|
||||
),
|
||||
if (PlatformUtils.isMobile)
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'分享视频',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
onTap: () {
|
||||
final item = pgcItem.episodes?.firstWhereOrNull(
|
||||
(item) => item.epId == epId,
|
||||
);
|
||||
Get.back();
|
||||
ShareUtils.shareText(
|
||||
'${pgcItem.title}${item != null ? ' ${item.showTitle}' : ''}'
|
||||
' - $videoUrl',
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'分享至动态',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
children: [
|
||||
SimpleDialogOption(
|
||||
child: const Text('复制链接', style: TextStyle(fontSize: 14)),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Utils.copyText(videoUrl);
|
||||
},
|
||||
),
|
||||
SimpleDialogOption(
|
||||
child: const Text('其它app打开', style: TextStyle(fontSize: 14)),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
PageUtils.launchURL(videoUrl);
|
||||
},
|
||||
),
|
||||
if (PlatformUtils.isMobile)
|
||||
SimpleDialogOption(
|
||||
child: const Text('分享视频', style: TextStyle(fontSize: 14)),
|
||||
onPressed: () {
|
||||
final item = pgcItem.episodes?.firstWhereOrNull(
|
||||
(item) => item.epId == epId,
|
||||
);
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (context) => RepostPanel(
|
||||
rid: epId,
|
||||
/**
|
||||
* 1:番剧 // 4097
|
||||
2:电影 // 4098
|
||||
3:纪录片 // 4101
|
||||
4:国创 // 4100
|
||||
5:电视剧 // 4099
|
||||
6:漫画
|
||||
7:综艺 // 4099
|
||||
*/
|
||||
dynType: switch (pgcItem.type) {
|
||||
1 => 4097,
|
||||
2 => 4098,
|
||||
3 => 4101,
|
||||
4 => 4100,
|
||||
5 || 7 => 4099,
|
||||
_ => -1,
|
||||
},
|
||||
pic: pgcItem.cover,
|
||||
title:
|
||||
'${pgcItem.title}${item != null ? '\n${item.showTitle}' : ''}',
|
||||
uname: '',
|
||||
),
|
||||
Get.back();
|
||||
ShareUtils.shareText(
|
||||
'${pgcItem.title}${item != null ? ' ${item.showTitle}' : ''}'
|
||||
' - $videoUrl',
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'分享至消息',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
try {
|
||||
EpisodeItem item = pgcItem.episodes!.firstWhere(
|
||||
(item) => item.epId == epId,
|
||||
);
|
||||
final title =
|
||||
item.shareCopy ??
|
||||
'${pgcItem.title} ${item.showTitle ?? item.longTitle}';
|
||||
PageUtils.pmShare(
|
||||
context,
|
||||
content: {
|
||||
"id": epId!.toString(),
|
||||
"title": title,
|
||||
"url": item.shareUrl,
|
||||
"headline": title,
|
||||
"source": 16,
|
||||
"thumb": item.cover,
|
||||
"source_desc": switch (pgcItem.type) {
|
||||
1 => '番剧',
|
||||
2 => '电影',
|
||||
3 => '纪录片',
|
||||
4 => '国创',
|
||||
5 => '电视剧',
|
||||
6 => '漫画',
|
||||
7 => '综艺',
|
||||
_ => null,
|
||||
},
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
},
|
||||
SimpleDialogOption(
|
||||
child: const Text('分享至动态', style: TextStyle(fontSize: 14)),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
final item = pgcItem.episodes?.firstWhereOrNull(
|
||||
(item) => item.epId == epId,
|
||||
);
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (context) => RepostPanel(
|
||||
rid: epId,
|
||||
/*
|
||||
1:番剧 // 4097
|
||||
2:电影 // 4098
|
||||
3:纪录片 // 4101
|
||||
4:国创 // 4100
|
||||
5:电视剧 // 4099
|
||||
6:漫画
|
||||
7:综艺 // 4099
|
||||
*/
|
||||
dynType: switch (pgcItem.type) {
|
||||
1 => 4097,
|
||||
2 => 4098,
|
||||
3 => 4101,
|
||||
4 => 4100,
|
||||
5 || 7 => 4099,
|
||||
_ => -1,
|
||||
},
|
||||
pic: pgcItem.cover,
|
||||
title:
|
||||
'${pgcItem.title}${item != null ? '\n${item.showTitle}' : ''}',
|
||||
uname: '',
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
SimpleDialogOption(
|
||||
child: const Text(
|
||||
'分享至消息',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
try {
|
||||
final item = pgcItem.episodes!.firstWhere(
|
||||
(item) => item.epId == epId,
|
||||
);
|
||||
final title =
|
||||
item.shareCopy ??
|
||||
'${pgcItem.title} ${item.showTitle ?? item.longTitle}';
|
||||
PageUtils.pmShare(
|
||||
context,
|
||||
content: {
|
||||
"id": epId!.toString(),
|
||||
"title": title,
|
||||
"url": item.shareUrl,
|
||||
"headline": title,
|
||||
"source": 16,
|
||||
"thumb": item.cover,
|
||||
"source_desc": switch (pgcItem.type) {
|
||||
1 => '番剧',
|
||||
2 => '电影',
|
||||
3 => '纪录片',
|
||||
4 => '国创',
|
||||
5 => '电视剧',
|
||||
6 => '漫画',
|
||||
7 => '综艺',
|
||||
_ => null,
|
||||
},
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -292,110 +292,107 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
String videoUrl = '${HttpString.baseUrl}/video/$bvid';
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
builder: (_) => SimpleDialog(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'复制链接',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Utils.copyText(videoUrl);
|
||||
},
|
||||
trailing: playedTimePos.isNotEmpty
|
||||
? iconButton(
|
||||
tooltip: '精确分享',
|
||||
icon: const Icon(Icons.timer_outlined),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Utils.copyText('$videoUrl$playedTimePos');
|
||||
},
|
||||
)
|
||||
: null,
|
||||
children: [
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'复制链接',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'其它app打开',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
PageUtils.launchURL(videoUrl);
|
||||
},
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Utils.copyText(videoUrl);
|
||||
},
|
||||
trailing: playedTimePos.isNotEmpty
|
||||
? iconButton(
|
||||
tooltip: '精确分享',
|
||||
icon: const Icon(Icons.timer_outlined),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Utils.copyText('$videoUrl$playedTimePos');
|
||||
},
|
||||
)
|
||||
: null,
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'其它app打开',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
if (PlatformUtils.isMobile)
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'分享视频',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
ShareUtils.shareText(
|
||||
'${videoDetail.title} '
|
||||
'UP主: ${videoDetail.owner!.name!}'
|
||||
' - $videoUrl',
|
||||
);
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
PageUtils.launchURL(videoUrl);
|
||||
},
|
||||
),
|
||||
if (PlatformUtils.isMobile)
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'分享至动态',
|
||||
'分享视频',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (context) => RepostPanel(
|
||||
rid: videoDetail.aid,
|
||||
dynType: 8,
|
||||
pic: videoDetail.pic,
|
||||
title: videoDetail.title,
|
||||
uname: videoDetail.owner?.name,
|
||||
),
|
||||
ShareUtils.shareText(
|
||||
'${videoDetail.title} '
|
||||
'UP主: ${videoDetail.owner!.name!}'
|
||||
' - $videoUrl',
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'分享至消息',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
try {
|
||||
PageUtils.pmShare(
|
||||
context,
|
||||
content: {
|
||||
"id": videoDetail.aid!.toString(),
|
||||
"title": videoDetail.title!,
|
||||
"headline": videoDetail.title!,
|
||||
"source": 5,
|
||||
"thumb": videoDetail.pic!,
|
||||
"author": videoDetail.owner!.name!,
|
||||
"author_id": videoDetail.owner!.mid!.toString(),
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
},
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'分享至动态',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
useSafeArea: true,
|
||||
builder: (context) => RepostPanel(
|
||||
rid: videoDetail.aid,
|
||||
dynType: 8,
|
||||
pic: videoDetail.pic,
|
||||
title: videoDetail.title,
|
||||
uname: videoDetail.owner?.name,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
dense: true,
|
||||
title: const Text(
|
||||
'分享至消息',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
onTap: () {
|
||||
Get.back();
|
||||
try {
|
||||
PageUtils.pmShare(
|
||||
context,
|
||||
content: {
|
||||
"id": videoDetail.aid!.toString(),
|
||||
"title": videoDetail.title!,
|
||||
"headline": videoDetail.title!,
|
||||
"source": 5,
|
||||
"thumb": videoDetail.pic!,
|
||||
"author": videoDetail.owner!.name!,
|
||||
"author_id": videoDetail.owner!.mid!.toString(),
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -789,9 +789,7 @@ class HeaderControlState extends State<HeaderControl>
|
||||
content: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: ListTileTheme(
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 24,
|
||||
),
|
||||
contentPadding: const .symmetric(horizontal: 24),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -1152,65 +1150,57 @@ class HeaderControlState extends State<HeaderControl>
|
||||
void onExportSubtitle() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
builder: (context) => SimpleDialog(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12),
|
||||
title: const Text('保存字幕'),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: videoDetailCtr.subtitles
|
||||
.map(
|
||||
(item) => ListTile(
|
||||
dense: true,
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
final url = item.subtitleUrl;
|
||||
if (url == null || url.isEmpty) return;
|
||||
try {
|
||||
final res = await Request.dio.get<Uint8List>(
|
||||
url.http2https,
|
||||
options: Options(
|
||||
responseType: ResponseType.bytes,
|
||||
headers: Constants.baseHeaders,
|
||||
extra: {'account': const NoAccount()},
|
||||
),
|
||||
children: videoDetailCtr.subtitles
|
||||
.map(
|
||||
(item) => SimpleDialogOption(
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
final url = item.subtitleUrl;
|
||||
if (url == null || url.isEmpty) return;
|
||||
try {
|
||||
final res = await Request.dio.get<Uint8List>(
|
||||
url.http2https,
|
||||
options: Options(
|
||||
responseType: ResponseType.bytes,
|
||||
headers: Constants.baseHeaders,
|
||||
extra: {'account': const NoAccount()},
|
||||
),
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
final bytes = Uint8List.fromList(
|
||||
Request.responseBytesDecoder(
|
||||
res.data!,
|
||||
res.headers.map,
|
||||
),
|
||||
);
|
||||
String name =
|
||||
'${introController.videoDetail.value.title}-${videoDetailCtr.bvid}-${videoDetailCtr.cid.value}-${item.lanDoc}.json';
|
||||
if (Platform.isWindows) {
|
||||
// Reserved characters may not be used in file names. See: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
|
||||
name = name.replaceAll(
|
||||
RegExp(r'[<>:/\\|?*"]'),
|
||||
'',
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
final bytes = Uint8List.fromList(
|
||||
Request.responseBytesDecoder(
|
||||
res.data!,
|
||||
res.headers.map,
|
||||
),
|
||||
);
|
||||
String name =
|
||||
'${introController.videoDetail.value.title}-${videoDetailCtr.bvid}-${videoDetailCtr.cid.value}-${item.lanDoc}.json';
|
||||
if (Platform.isWindows) {
|
||||
// Reserved characters may not be used in file names. See: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
|
||||
name = name.replaceAll(
|
||||
RegExp(r'[<>:/\\|?*"]'),
|
||||
'',
|
||||
);
|
||||
}
|
||||
StorageUtils.saveBytes2File(
|
||||
name: name,
|
||||
bytes: bytes,
|
||||
allowedExtensions: const ['json'],
|
||||
);
|
||||
}
|
||||
} catch (e, s) {
|
||||
Utils.reportError(e, s);
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
},
|
||||
title: Text(
|
||||
item.lanDoc!,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
StorageUtils.saveBytes2File(
|
||||
name: name,
|
||||
bytes: bytes,
|
||||
allowedExtensions: const ['json'],
|
||||
);
|
||||
}
|
||||
} catch (e, s) {
|
||||
Utils.reportError(e, s);
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
},
|
||||
child: Text(item.lanDoc!, style: const TextStyle(fontSize: 14)),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user