feat: show network type (#1781)

This commit is contained in:
My-Responsitories
2025-12-17 21:58:42 +08:00
committed by GitHub
parent 53cf9d54c4
commit 11cdb67050

View File

@@ -19,8 +19,10 @@ import 'package:PiliPlus/services/download/download_service.dart';
import 'package:PiliPlus/utils/date_utils.dart'; import 'package:PiliPlus/utils/date_utils.dart';
import 'package:PiliPlus/utils/duration_utils.dart'; import 'package:PiliPlus/utils/duration_utils.dart';
import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/id_utils.dart';
import 'package:PiliPlus/utils/platform_utils.dart';
import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:PiliPlus/utils/utils.dart'; import 'package:PiliPlus/utils/utils.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/foundation.dart' show kDebugMode, kReleaseMode; import 'package:flutter/foundation.dart' show kDebugMode, kReleaseMode;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@@ -97,6 +99,7 @@ class _DownloadPanelState extends State<DownloadPanel> {
} }
Widget _buildHeader(ThemeData theme) { Widget _buildHeader(ThemeData theme) {
final textStyle = TextStyle(color: theme.colorScheme.onSurfaceVariant);
return Padding( return Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 0, 12), padding: const EdgeInsets.fromLTRB(16, 12, 0, 12),
child: Row( child: Row(
@@ -104,7 +107,7 @@ class _DownloadPanelState extends State<DownloadPanel> {
children: [ children: [
Text( Text(
'最高画质', '最高画质',
style: TextStyle(color: theme.colorScheme.onSurfaceVariant), style: textStyle,
), ),
Builder( Builder(
builder: (context) => PopupMenuButton<VideoQuality>( builder: (context) => PopupMenuButton<VideoQuality>(
@@ -141,6 +144,22 @@ class _DownloadPanelState extends State<DownloadPanel> {
), ),
), ),
), ),
if (kDebugMode || PlatformUtils.isMobile) ...[
const Spacer(),
StreamBuilder(
stream: Connectivity().onConnectivityChanged,
builder: (context, snapshot) {
if (snapshot.data case final data?) {
final network = data.contains(ConnectivityResult.wifi)
? 'WIFI'
: '数据';
return Text('当前网络:$network', style: textStyle);
}
return const SizedBox.shrink();
},
),
const SizedBox(width: 4),
],
], ],
), ),
); );
@@ -240,15 +259,17 @@ class _DownloadPanelState extends State<DownloadPanel> {
} }
} }
if (episode is ugc.EpisodeItem && episode.pages!.length > 1) { if (episode is ugc.EpisodeItem) {
final pages = episode.pages!;
if (pages.length > 1) {
if (isFromList && kDebugMode) { if (isFromList && kDebugMode) {
SmartDialog.showToast('hasParts'); SmartDialog.showToast('hasParts');
} }
if (isDownloadAll) { if (isDownloadAll) {
for (int i = 0; i < episode.pages!.length; i++) { for (int i = 0; i < pages.length; i++) {
_onDownload( _onDownload(
index: i, index: i,
episode: episode.pages![i], episode: pages[i],
parent: episode, parent: episode,
); );
} }
@@ -256,6 +277,7 @@ class _DownloadPanelState extends State<DownloadPanel> {
} }
return false; return false;
} }
}
try { try {
switch (episode) { switch (episode) {
@@ -516,7 +538,7 @@ class _DownloadPanelState extends State<DownloadPanel> {
isDownloadAll: true, isDownloadAll: true,
); );
} }
setState(() {}); if (mounted) setState(() {});
}, },
); );
}, },