Merge branch 'main' into feature-updateVideoDetailStructure
This commit is contained in:
3
.github/workflows/beta_ci.yml
vendored
3
.github/workflows/beta_ci.yml
vendored
@ -4,7 +4,7 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "main"
|
- "never"
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- "**.md"
|
- "**.md"
|
||||||
- "**.txt"
|
- "**.txt"
|
||||||
@ -12,6 +12,7 @@ on:
|
|||||||
- ".idea/**"
|
- ".idea/**"
|
||||||
- "!.github/workflows/**"
|
- "!.github/workflows/**"
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update_version:
|
update_version:
|
||||||
name: Read and update version
|
name: Read and update version
|
||||||
|
|||||||
@ -26,13 +26,13 @@
|
|||||||
Xcode 13.4 不支持**auto_orientation**,请注释相关代码
|
Xcode 13.4 不支持**auto_orientation**,请注释相关代码
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
[✓] Flutter (Channel stable, 3.16.4, on macOS 14.1.2 23B92 darwin-arm64, locale
|
[✓] Flutter (Channel stable, 3.16.5, on macOS 14.1.2 23B92 darwin-arm64, locale
|
||||||
zh-Hans-CN)
|
zh-Hans-CN)
|
||||||
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
|
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
|
||||||
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
|
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
|
||||||
[✓] Chrome - develop for the web
|
[✓] Chrome - develop for the web
|
||||||
[✓] Android Studio (version 2022.3)
|
[✓] Android Studio (version 2022.3)
|
||||||
[✓] VS Code (version 1.85.1)
|
[✓] VS Code (version 1.87.2)
|
||||||
[✓] Connected device (3 available)
|
[✓] Connected device (3 available)
|
||||||
[✓] Network resources
|
[✓] Network resources
|
||||||
|
|
||||||
@ -44,6 +44,9 @@ Xcode 13.4 不支持**auto_orientation**,请注释相关代码
|
|||||||
## 技术交流
|
## 技术交流
|
||||||
|
|
||||||
Telegram: https://t.me/+lm_oOVmF0RJiODk1
|
Telegram: https://t.me/+lm_oOVmF0RJiODk1
|
||||||
|
|
||||||
|
Tg Beta版本:@PiliPala_Beta
|
||||||
|
|
||||||
QQ频道: https://pd.qq.com/s/365esodk3
|
QQ频道: https://pd.qq.com/s/365esodk3
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
146
lib/common/pages_bottom_sheet.dart
Normal file
146
lib/common/pages_bottom_sheet.dart
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||||
|
import '../models/common/video_episode_type.dart';
|
||||||
|
|
||||||
|
class EpisodeBottomSheet {
|
||||||
|
final List<dynamic> episodes;
|
||||||
|
final int currentCid;
|
||||||
|
final dynamic dataType;
|
||||||
|
final BuildContext context;
|
||||||
|
final Function changeFucCall;
|
||||||
|
final int? cid;
|
||||||
|
final double? sheetHeight;
|
||||||
|
bool isFullScreen = false;
|
||||||
|
|
||||||
|
EpisodeBottomSheet({
|
||||||
|
required this.episodes,
|
||||||
|
required this.currentCid,
|
||||||
|
required this.dataType,
|
||||||
|
required this.context,
|
||||||
|
required this.changeFucCall,
|
||||||
|
this.cid,
|
||||||
|
this.sheetHeight,
|
||||||
|
this.isFullScreen = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
Widget buildEpisodeListItem(
|
||||||
|
dynamic episode,
|
||||||
|
int index,
|
||||||
|
bool isCurrentIndex,
|
||||||
|
) {
|
||||||
|
Color primary = Theme.of(context).colorScheme.primary;
|
||||||
|
Color onSurface = Theme.of(context).colorScheme.onSurface;
|
||||||
|
|
||||||
|
String title = '';
|
||||||
|
switch (dataType) {
|
||||||
|
case VideoEpidoesType.videoEpisode:
|
||||||
|
title = episode.title;
|
||||||
|
break;
|
||||||
|
case VideoEpidoesType.videoPart:
|
||||||
|
title = episode.pagePart;
|
||||||
|
break;
|
||||||
|
case VideoEpidoesType.bangumiEpisode:
|
||||||
|
title = '第${episode.title}话 ${episode.longTitle!}';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ListTile(
|
||||||
|
onTap: () {
|
||||||
|
SmartDialog.showToast('切换至「$title」');
|
||||||
|
changeFucCall.call(episode, index);
|
||||||
|
},
|
||||||
|
dense: false,
|
||||||
|
leading: isCurrentIndex
|
||||||
|
? Image.asset(
|
||||||
|
'assets/images/live.gif',
|
||||||
|
color: primary,
|
||||||
|
height: 12,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
title: Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: isCurrentIndex ? primary : onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildTitle() {
|
||||||
|
return AppBar(
|
||||||
|
toolbarHeight: 45,
|
||||||
|
automaticallyImplyLeading: false,
|
||||||
|
centerTitle: false,
|
||||||
|
title: Text(
|
||||||
|
'合集(${episodes.length})',
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
actions: !isFullScreen
|
||||||
|
? [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.close, size: 20),
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 14),
|
||||||
|
]
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildShowContent(BuildContext context) {
|
||||||
|
final ItemScrollController itemScrollController = ItemScrollController();
|
||||||
|
int currentIndex = episodes.indexWhere((dynamic e) => e.cid == currentCid);
|
||||||
|
return StatefulBuilder(
|
||||||
|
builder: (BuildContext context, StateSetter setState) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
itemScrollController.jumpTo(index: currentIndex);
|
||||||
|
});
|
||||||
|
return Container(
|
||||||
|
height: sheetHeight,
|
||||||
|
color: Theme.of(context).colorScheme.background,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
buildTitle(),
|
||||||
|
Expanded(
|
||||||
|
child: Material(
|
||||||
|
child: PageStorage(
|
||||||
|
bucket: PageStorageBucket(),
|
||||||
|
child: ScrollablePositionedList.builder(
|
||||||
|
itemScrollController: itemScrollController,
|
||||||
|
itemCount: episodes.length + 1,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
bool isLastItem = index == episodes.length;
|
||||||
|
bool isCurrentIndex = currentIndex == index;
|
||||||
|
return isLastItem
|
||||||
|
? SizedBox(
|
||||||
|
height:
|
||||||
|
MediaQuery.of(context).padding.bottom + 20,
|
||||||
|
)
|
||||||
|
: buildEpisodeListItem(
|
||||||
|
episodes[index],
|
||||||
|
index,
|
||||||
|
isCurrentIndex,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The [BuildContext] of the widget that calls the bottom sheet.
|
||||||
|
PersistentBottomSheetController show(BuildContext context) {
|
||||||
|
final PersistentBottomSheetController btmSheetCtr = showBottomSheet(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return buildShowContent(context);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return btmSheetCtr;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -484,11 +484,17 @@ class Api {
|
|||||||
/// 激活buvid3
|
/// 激活buvid3
|
||||||
static const activateBuvidApi = '/x/internal/gaia-gateway/ExClimbWuzhi';
|
static const activateBuvidApi = '/x/internal/gaia-gateway/ExClimbWuzhi';
|
||||||
|
|
||||||
|
/// 获取字幕配置
|
||||||
|
static const getSubtitleConfig = '/x/player/v2';
|
||||||
|
|
||||||
/// 我的订阅
|
/// 我的订阅
|
||||||
static const userSubFolder = '/x/v3/fav/folder/collected/list';
|
static const userSubFolder = '/x/v3/fav/folder/collected/list';
|
||||||
|
|
||||||
/// 我的订阅详情
|
/// 我的订阅详情 type 21
|
||||||
static const userSubFolderDetail = '/x/space/fav/season/list';
|
static const userSeasonList = '/x/space/fav/season/list';
|
||||||
|
|
||||||
|
/// 我的订阅详情 type 11
|
||||||
|
static const userResourceList = '/x/v3/fav/resource/list';
|
||||||
|
|
||||||
/// 表情
|
/// 表情
|
||||||
static const emojiList = '/x/emote/user/panel/web';
|
static const emojiList = '/x/emote/user/panel/web';
|
||||||
@ -503,4 +509,6 @@ class Api {
|
|||||||
/// 排行榜
|
/// 排行榜
|
||||||
static const String getRankApi = "/x/web-interface/ranking/v2";
|
static const String getRankApi = "/x/web-interface/ranking/v2";
|
||||||
|
|
||||||
|
/// 取消订阅
|
||||||
|
static const String cancelSub = '/x/v3/fav/season/unfav';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -330,12 +330,12 @@ class UserHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future userSubFolderDetail({
|
static Future userSeasonList({
|
||||||
required int seasonId,
|
required int seasonId,
|
||||||
required int pn,
|
required int pn,
|
||||||
required int ps,
|
required int ps,
|
||||||
}) async {
|
}) async {
|
||||||
var res = await Request().get(Api.userSubFolderDetail, data: {
|
var res = await Request().get(Api.userSeasonList, data: {
|
||||||
'season_id': seasonId,
|
'season_id': seasonId,
|
||||||
'ps': ps,
|
'ps': ps,
|
||||||
'pn': pn,
|
'pn': pn,
|
||||||
@ -349,4 +349,50 @@ class UserHttp {
|
|||||||
return {'status': false, 'msg': res.data['message']};
|
return {'status': false, 'msg': res.data['message']};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future userResourceList({
|
||||||
|
required int seasonId,
|
||||||
|
required int pn,
|
||||||
|
required int ps,
|
||||||
|
}) async {
|
||||||
|
var res = await Request().get(Api.userResourceList, data: {
|
||||||
|
'media_id': seasonId,
|
||||||
|
'ps': ps,
|
||||||
|
'pn': pn,
|
||||||
|
'keyword': '',
|
||||||
|
'order': 'mtime',
|
||||||
|
'type': 0,
|
||||||
|
'tid': 0,
|
||||||
|
'platform': 'web',
|
||||||
|
});
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
try {
|
||||||
|
return {
|
||||||
|
'status': true,
|
||||||
|
'data': SubDetailModelData.fromJson(res.data['data'])
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
return {'status': false, 'msg': err};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {'status': false, 'msg': res.data['message']};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消订阅
|
||||||
|
static Future cancelSub({required int seasonId}) async {
|
||||||
|
var res = await Request().post(
|
||||||
|
Api.cancelSub,
|
||||||
|
queryParameters: {
|
||||||
|
'platform': 'web',
|
||||||
|
'season_id': seasonId,
|
||||||
|
'csrf': await Request.getCsrf(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {'status': true};
|
||||||
|
} else {
|
||||||
|
return {'status': false, 'msg': res.data['message']};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,9 +8,11 @@ import '../models/model_rec_video_item.dart';
|
|||||||
import '../models/user/fav_folder.dart';
|
import '../models/user/fav_folder.dart';
|
||||||
import '../models/video/ai.dart';
|
import '../models/video/ai.dart';
|
||||||
import '../models/video/play/url.dart';
|
import '../models/video/play/url.dart';
|
||||||
|
import '../models/video/subTitile/result.dart';
|
||||||
import '../models/video_detail_res.dart';
|
import '../models/video_detail_res.dart';
|
||||||
import '../utils/recommend_filter.dart';
|
import '../utils/recommend_filter.dart';
|
||||||
import '../utils/storage.dart';
|
import '../utils/storage.dart';
|
||||||
|
import '../utils/subtitle.dart';
|
||||||
import '../utils/wbi_sign.dart';
|
import '../utils/wbi_sign.dart';
|
||||||
import 'api.dart';
|
import 'api.dart';
|
||||||
import 'init.dart';
|
import 'init.dart';
|
||||||
@ -476,6 +478,25 @@ class VideoHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future getSubtitle({int? cid, String? bvid}) async {
|
||||||
|
var res = await Request().get(Api.getSubtitleConfig, data: {
|
||||||
|
'cid': cid,
|
||||||
|
'bvid': bvid,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {
|
||||||
|
'status': true,
|
||||||
|
'data': SubTitlteModel.fromJson(res.data['data']),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {'status': false, 'data': [], 'msg': res.data['msg']};
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
print(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 视频排行
|
// 视频排行
|
||||||
static Future getRankVideoList(int rid) async {
|
static Future getRankVideoList(int rid) async {
|
||||||
try {
|
try {
|
||||||
@ -498,4 +519,12 @@ class VideoHttp {
|
|||||||
return {'status': false, 'data': [], 'msg': err};
|
return {'status': false, 'data': [], 'msg': err};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取字幕内容
|
||||||
|
static Future<Map<String, dynamic>> getSubtitleContent(url) async {
|
||||||
|
var res = await Request().get('https:$url');
|
||||||
|
final String content = SubTitleUtils.convertToWebVTT(res.data['body']);
|
||||||
|
final List body = res.data['body'];
|
||||||
|
return {'content': content, 'body': body};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import 'package:pilipala/services/disable_battery_opt.dart';
|
|||||||
import 'package:pilipala/services/service_locator.dart';
|
import 'package:pilipala/services/service_locator.dart';
|
||||||
import 'package:pilipala/utils/app_scheme.dart';
|
import 'package:pilipala/utils/app_scheme.dart';
|
||||||
import 'package:pilipala/utils/data.dart';
|
import 'package:pilipala/utils/data.dart';
|
||||||
|
import 'package:pilipala/utils/global_data.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:media_kit/media_kit.dart'; // Provides [Player], [Media], [Playlist] etc.
|
import 'package:media_kit/media_kit.dart'; // Provides [Player], [Media], [Playlist] etc.
|
||||||
import 'package:pilipala/utils/recommend_filter.dart';
|
import 'package:pilipala/utils/recommend_filter.dart';
|
||||||
@ -34,6 +35,7 @@ void main() async {
|
|||||||
.then((_) async {
|
.then((_) async {
|
||||||
await GStrorage.init();
|
await GStrorage.init();
|
||||||
await setupServiceLocator();
|
await setupServiceLocator();
|
||||||
|
clearLogs();
|
||||||
Request();
|
Request();
|
||||||
await Request.setCookie();
|
await Request.setCookie();
|
||||||
RecommendFilter();
|
RecommendFilter();
|
||||||
@ -63,14 +65,8 @@ void main() async {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// 小白条、导航栏沉浸
|
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
|
||||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
|
||||||
systemNavigationBarColor: Colors.transparent,
|
|
||||||
systemNavigationBarDividerColor: Colors.transparent,
|
|
||||||
statusBarColor: Colors.transparent,
|
|
||||||
));
|
|
||||||
Data.init();
|
Data.init();
|
||||||
|
GlobalData();
|
||||||
PiliSchame.init();
|
PiliSchame.init();
|
||||||
DisableBatteryOpt();
|
DisableBatteryOpt();
|
||||||
});
|
});
|
||||||
@ -133,45 +129,51 @@ class MyApp extends StatelessWidget {
|
|||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final SnackBarThemeData snackBarThemeData = SnackBarThemeData(
|
||||||
|
actionTextColor: darkColorScheme.primary,
|
||||||
|
backgroundColor: darkColorScheme.secondaryContainer,
|
||||||
|
closeIconColor: darkColorScheme.secondary,
|
||||||
|
contentTextStyle: TextStyle(color: darkColorScheme.secondary),
|
||||||
|
elevation: 20,
|
||||||
|
);
|
||||||
|
|
||||||
|
ThemeData themeData = ThemeData(
|
||||||
|
// fontFamily: 'HarmonyOS',
|
||||||
|
colorScheme: currentThemeValue == ThemeType.dark
|
||||||
|
? darkColorScheme
|
||||||
|
: lightColorScheme,
|
||||||
|
snackBarTheme: snackBarThemeData,
|
||||||
|
pageTransitionsTheme: const PageTransitionsTheme(
|
||||||
|
builders: <TargetPlatform, PageTransitionsBuilder>{
|
||||||
|
TargetPlatform.android: ZoomPageTransitionsBuilder(
|
||||||
|
allowEnterRouteSnapshotting: false,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// 小白条、导航栏沉浸
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
|
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
||||||
|
systemNavigationBarColor: GlobalData().enableMYBar
|
||||||
|
? const Color(0x00010000)
|
||||||
|
: themeData.canvasColor,
|
||||||
|
systemNavigationBarDividerColor: GlobalData().enableMYBar
|
||||||
|
? const Color(0x00010000)
|
||||||
|
: themeData.canvasColor,
|
||||||
|
systemNavigationBarIconBrightness: currentThemeValue == ThemeType.dark
|
||||||
|
? Brightness.light
|
||||||
|
: Brightness.dark,
|
||||||
|
statusBarColor: Colors.transparent,
|
||||||
|
));
|
||||||
|
|
||||||
// 图片缓存
|
// 图片缓存
|
||||||
// PaintingBinding.instance.imageCache.maximumSizeBytes = 1000 << 20;
|
// PaintingBinding.instance.imageCache.maximumSizeBytes = 1000 << 20;
|
||||||
return GetMaterialApp(
|
return GetMaterialApp(
|
||||||
title: 'PiLiPaLa',
|
title: 'PiLiPaLa',
|
||||||
theme: ThemeData(
|
theme: themeData,
|
||||||
// fontFamily: 'HarmonyOS',
|
darkTheme: themeData,
|
||||||
colorScheme: currentThemeValue == ThemeType.dark
|
|
||||||
? darkColorScheme
|
|
||||||
: lightColorScheme,
|
|
||||||
useMaterial3: true,
|
|
||||||
snackBarTheme: SnackBarThemeData(
|
|
||||||
actionTextColor: lightColorScheme.primary,
|
|
||||||
backgroundColor: lightColorScheme.secondaryContainer,
|
|
||||||
closeIconColor: lightColorScheme.secondary,
|
|
||||||
contentTextStyle: TextStyle(color: lightColorScheme.secondary),
|
|
||||||
elevation: 20,
|
|
||||||
),
|
|
||||||
pageTransitionsTheme: const PageTransitionsTheme(
|
|
||||||
builders: <TargetPlatform, PageTransitionsBuilder>{
|
|
||||||
TargetPlatform.android: ZoomPageTransitionsBuilder(
|
|
||||||
allowEnterRouteSnapshotting: false,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
darkTheme: ThemeData(
|
|
||||||
// fontFamily: 'HarmonyOS',
|
|
||||||
colorScheme: currentThemeValue == ThemeType.light
|
|
||||||
? lightColorScheme
|
|
||||||
: darkColorScheme,
|
|
||||||
useMaterial3: true,
|
|
||||||
snackBarTheme: SnackBarThemeData(
|
|
||||||
actionTextColor: darkColorScheme.primary,
|
|
||||||
backgroundColor: darkColorScheme.secondaryContainer,
|
|
||||||
closeIconColor: darkColorScheme.secondary,
|
|
||||||
contentTextStyle: TextStyle(color: darkColorScheme.secondary),
|
|
||||||
elevation: 20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: const [
|
||||||
GlobalCupertinoLocalizations.delegate,
|
GlobalCupertinoLocalizations.delegate,
|
||||||
GlobalMaterialLocalizations.delegate,
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../pages/dynamics/index.dart';
|
||||||
|
import '../../pages/home/index.dart';
|
||||||
|
import '../../pages/media/index.dart';
|
||||||
|
import '../../pages/rank/index.dart';
|
||||||
|
|
||||||
List defaultNavigationBars = [
|
List defaultNavigationBars = [
|
||||||
{
|
{
|
||||||
'id': 0,
|
'id': 0,
|
||||||
@ -13,6 +18,7 @@ List defaultNavigationBars = [
|
|||||||
),
|
),
|
||||||
'label': "首页",
|
'label': "首页",
|
||||||
'count': 0,
|
'count': 0,
|
||||||
|
'page': const HomePage(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 1,
|
'id': 1,
|
||||||
@ -26,6 +32,7 @@ List defaultNavigationBars = [
|
|||||||
),
|
),
|
||||||
'label': "排行榜",
|
'label': "排行榜",
|
||||||
'count': 0,
|
'count': 0,
|
||||||
|
'page': const RankPage(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 2,
|
'id': 2,
|
||||||
@ -39,6 +46,7 @@ List defaultNavigationBars = [
|
|||||||
),
|
),
|
||||||
'label': "动态",
|
'label': "动态",
|
||||||
'count': 0,
|
'count': 0,
|
||||||
|
'page': const DynamicsPage(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'id': 3,
|
'id': 3,
|
||||||
@ -52,5 +60,6 @@ List defaultNavigationBars = [
|
|||||||
),
|
),
|
||||||
'label': "媒体库",
|
'label': "媒体库",
|
||||||
'count': 0,
|
'count': 0,
|
||||||
|
'page': const MediaPage(),
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
47
lib/models/common/subtitle_type.dart
Normal file
47
lib/models/common/subtitle_type.dart
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
enum SubtitleType {
|
||||||
|
// 中文(中国)
|
||||||
|
zhCN,
|
||||||
|
// 中文(自动翻译)
|
||||||
|
aizh,
|
||||||
|
// 英语(自动生成)
|
||||||
|
aien,
|
||||||
|
}
|
||||||
|
|
||||||
|
extension SubtitleTypeExtension on SubtitleType {
|
||||||
|
String get description {
|
||||||
|
switch (this) {
|
||||||
|
case SubtitleType.zhCN:
|
||||||
|
return '中文(中国)';
|
||||||
|
case SubtitleType.aizh:
|
||||||
|
return '中文(自动翻译)';
|
||||||
|
case SubtitleType.aien:
|
||||||
|
return '英语(自动生成)';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension SubtitleIdExtension on SubtitleType {
|
||||||
|
String get id {
|
||||||
|
switch (this) {
|
||||||
|
case SubtitleType.zhCN:
|
||||||
|
return 'zh-CN';
|
||||||
|
case SubtitleType.aizh:
|
||||||
|
return 'ai-zh';
|
||||||
|
case SubtitleType.aien:
|
||||||
|
return 'ai-en';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension SubtitleCodeExtension on SubtitleType {
|
||||||
|
int get code {
|
||||||
|
switch (this) {
|
||||||
|
case SubtitleType.zhCN:
|
||||||
|
return 1;
|
||||||
|
case SubtitleType.aizh:
|
||||||
|
return 2;
|
||||||
|
case SubtitleType.aien:
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
5
lib/models/common/video_episode_type.dart
Normal file
5
lib/models/common/video_episode_type.dart
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
enum VideoEpidoesType {
|
||||||
|
videoEpisode,
|
||||||
|
videoPart,
|
||||||
|
bangumiEpisode,
|
||||||
|
}
|
||||||
@ -47,18 +47,23 @@ class Vip {
|
|||||||
this.status,
|
this.status,
|
||||||
this.dueDate,
|
this.dueDate,
|
||||||
this.label,
|
this.label,
|
||||||
|
this.nicknameColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
int? type;
|
int? type;
|
||||||
int? status;
|
int? status;
|
||||||
int? dueDate;
|
int? dueDate;
|
||||||
Map? label;
|
Map? label;
|
||||||
|
int? nicknameColor;
|
||||||
|
|
||||||
Vip.fromJson(Map<String, dynamic> json) {
|
Vip.fromJson(Map<String, dynamic> json) {
|
||||||
type = json['type'];
|
type = json['type'];
|
||||||
status = json['status'];
|
status = json['status'];
|
||||||
dueDate = json['due_date'];
|
dueDate = json['due_date'];
|
||||||
label = json['label'];
|
label = json['label'];
|
||||||
|
nicknameColor = json['nickname_color'] == ''
|
||||||
|
? null
|
||||||
|
: int.parse("0xFF${json['nickname_color'].replaceAll('#', '')}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -437,7 +437,8 @@ class SearchArticleItemModel {
|
|||||||
pubTime = json['pub_time'];
|
pubTime = json['pub_time'];
|
||||||
like = json['like'];
|
like = json['like'];
|
||||||
title = Em.regTitle(json['title']);
|
title = Em.regTitle(json['title']);
|
||||||
subTitle = json['title'].replaceAll(RegExp(r'<[^>]*>'), '');
|
subTitle =
|
||||||
|
Em.decodeHtmlEntities(json['title'].replaceAll(RegExp(r'<[^>]*>'), ''));
|
||||||
rankOffset = json['rank_offset'];
|
rankOffset = json['rank_offset'];
|
||||||
mid = json['mid'];
|
mid = json['mid'];
|
||||||
imageUrls = json['image_urls'];
|
imageUrls = json['image_urls'];
|
||||||
|
|||||||
20
lib/models/video/subTitile/content.dart
Normal file
20
lib/models/video/subTitile/content.dart
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
class SubTitileContentModel {
|
||||||
|
double? from;
|
||||||
|
double? to;
|
||||||
|
int? location;
|
||||||
|
String? content;
|
||||||
|
|
||||||
|
SubTitileContentModel({
|
||||||
|
this.from,
|
||||||
|
this.to,
|
||||||
|
this.location,
|
||||||
|
this.content,
|
||||||
|
});
|
||||||
|
|
||||||
|
SubTitileContentModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
from = json['from'];
|
||||||
|
to = json['to'];
|
||||||
|
location = json['location'];
|
||||||
|
content = json['content'];
|
||||||
|
}
|
||||||
|
}
|
||||||
89
lib/models/video/subTitile/result.dart
Normal file
89
lib/models/video/subTitile/result.dart
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
import 'package:get/get.dart';
|
||||||
|
import '../../common/subtitle_type.dart';
|
||||||
|
|
||||||
|
class SubTitlteModel {
|
||||||
|
SubTitlteModel({
|
||||||
|
this.aid,
|
||||||
|
this.bvid,
|
||||||
|
this.cid,
|
||||||
|
this.loginMid,
|
||||||
|
this.loginMidHash,
|
||||||
|
this.isOwner,
|
||||||
|
this.name,
|
||||||
|
this.subtitles,
|
||||||
|
});
|
||||||
|
|
||||||
|
int? aid;
|
||||||
|
String? bvid;
|
||||||
|
int? cid;
|
||||||
|
int? loginMid;
|
||||||
|
String? loginMidHash;
|
||||||
|
bool? isOwner;
|
||||||
|
String? name;
|
||||||
|
List<SubTitlteItemModel>? subtitles;
|
||||||
|
|
||||||
|
factory SubTitlteModel.fromJson(Map<String, dynamic> json) => SubTitlteModel(
|
||||||
|
aid: json["aid"],
|
||||||
|
bvid: json["bvid"],
|
||||||
|
cid: json["cid"],
|
||||||
|
loginMid: json["login_mid"],
|
||||||
|
loginMidHash: json["login_mid_hash"],
|
||||||
|
isOwner: json["is_owner"],
|
||||||
|
name: json["name"],
|
||||||
|
subtitles: json["subtitle"] != null
|
||||||
|
? json["subtitle"]["subtitles"]
|
||||||
|
.map<SubTitlteItemModel>((x) => SubTitlteItemModel.fromJson(x))
|
||||||
|
.toList()
|
||||||
|
: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class SubTitlteItemModel {
|
||||||
|
SubTitlteItemModel({
|
||||||
|
this.id,
|
||||||
|
this.lan,
|
||||||
|
this.lanDoc,
|
||||||
|
this.isLock,
|
||||||
|
this.subtitleUrl,
|
||||||
|
this.type,
|
||||||
|
this.aiType,
|
||||||
|
this.aiStatus,
|
||||||
|
this.title,
|
||||||
|
this.code,
|
||||||
|
this.content,
|
||||||
|
this.body,
|
||||||
|
});
|
||||||
|
|
||||||
|
int? id;
|
||||||
|
String? lan;
|
||||||
|
String? lanDoc;
|
||||||
|
bool? isLock;
|
||||||
|
String? subtitleUrl;
|
||||||
|
int? type;
|
||||||
|
int? aiType;
|
||||||
|
int? aiStatus;
|
||||||
|
String? title;
|
||||||
|
int? code;
|
||||||
|
String? content;
|
||||||
|
List? body;
|
||||||
|
|
||||||
|
factory SubTitlteItemModel.fromJson(Map<String, dynamic> json) =>
|
||||||
|
SubTitlteItemModel(
|
||||||
|
id: json["id"],
|
||||||
|
lan: json["lan"].replaceAll('-', ''),
|
||||||
|
lanDoc: json["lan_doc"],
|
||||||
|
isLock: json["is_lock"],
|
||||||
|
subtitleUrl: json["subtitle_url"],
|
||||||
|
type: json["type"],
|
||||||
|
aiType: json["ai_type"],
|
||||||
|
aiStatus: json["ai_status"],
|
||||||
|
title: json["lan_doc"],
|
||||||
|
code: SubtitleType.values
|
||||||
|
.firstWhereOrNull(
|
||||||
|
(element) => element.id.toString() == json["lan"])
|
||||||
|
?.index ??
|
||||||
|
-1,
|
||||||
|
content: '',
|
||||||
|
body: [],
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -15,6 +15,10 @@ import 'package:pilipala/utils/id_utils.dart';
|
|||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
|
import '../../../common/pages_bottom_sheet.dart';
|
||||||
|
import '../../../models/common/video_episode_type.dart';
|
||||||
|
import '../../../utils/drawer.dart';
|
||||||
|
|
||||||
class BangumiIntroController extends GetxController {
|
class BangumiIntroController extends GetxController {
|
||||||
// 视频bvid
|
// 视频bvid
|
||||||
String bvid = Get.parameters['bvid']!;
|
String bvid = Get.parameters['bvid']!;
|
||||||
@ -291,4 +295,29 @@ class BangumiIntroController extends GetxController {
|
|||||||
int aid = episodes[nextIndex].aid!;
|
int aid = episodes[nextIndex].aid!;
|
||||||
changeSeasonOrbangu(bvid, cid, aid);
|
changeSeasonOrbangu(bvid, cid, aid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 播放器底栏 选集 回调
|
||||||
|
void showEposideHandler() {
|
||||||
|
late List episodes = bangumiDetail.value.episodes!;
|
||||||
|
VideoEpidoesType dataType = VideoEpidoesType.bangumiEpisode;
|
||||||
|
if (episodes.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
VideoDetailController videoDetailCtr =
|
||||||
|
Get.find<VideoDetailController>(tag: Get.arguments['heroTag']);
|
||||||
|
DrawerUtils.showRightDialog(
|
||||||
|
child: EpisodeBottomSheet(
|
||||||
|
episodes: episodes,
|
||||||
|
currentCid: videoDetailCtr.cid.value,
|
||||||
|
dataType: dataType,
|
||||||
|
context: Get.context!,
|
||||||
|
sheetHeight: Get.size.height,
|
||||||
|
isFullScreen: true,
|
||||||
|
changeFucCall: (item, index) {
|
||||||
|
changeSeasonOrbangu(item.bvid, item.cid, item.aid);
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
},
|
||||||
|
).buildShowContent(Get.context!),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,6 +138,9 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
cid = widget.cid!;
|
cid = widget.cid!;
|
||||||
videoDetailCtr.cid.listen((p0) {
|
videoDetailCtr.cid.listen((p0) {
|
||||||
cid = p0;
|
cid = p0;
|
||||||
|
if (!mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -317,7 +320,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
if (widget.bangumiDetail!.episodes!.isNotEmpty) ...[
|
if (widget.bangumiDetail!.episodes!.isNotEmpty) ...[
|
||||||
BangumiPanel(
|
BangumiPanel(
|
||||||
pages: widget.bangumiDetail!.episodes!,
|
pages: widget.bangumiDetail!.episodes!,
|
||||||
cid: cid ?? widget.bangumiDetail!.episodes!.first.cid,
|
cid: cid! ?? widget.bangumiDetail!.episodes!.first.cid!,
|
||||||
sheetHeight: sheetHeight,
|
sheetHeight: sheetHeight,
|
||||||
changeFuc: (bvid, cid, aid) =>
|
changeFuc: (bvid, cid, aid) =>
|
||||||
bangumiIntroController.changeSeasonOrbangu(bvid, cid, aid),
|
bangumiIntroController.changeSeasonOrbangu(bvid, cid, aid),
|
||||||
|
|||||||
@ -2,13 +2,11 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:nil/nil.dart';
|
import 'package:nil/nil.dart';
|
||||||
import 'package:pilipala/common/constants.dart';
|
import 'package:pilipala/common/constants.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/pages/home/index.dart';
|
import 'package:pilipala/utils/main_stream.dart';
|
||||||
import 'package:pilipala/pages/main/index.dart';
|
|
||||||
|
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
import 'widgets/bangumu_card_v.dart';
|
import 'widgets/bangumu_card_v.dart';
|
||||||
@ -34,10 +32,6 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
scrollController = _bangumidController.scrollController;
|
scrollController = _bangumidController.scrollController;
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
StreamController<bool> searchBarStream =
|
|
||||||
Get.find<HomeController>().searchBarStream;
|
|
||||||
_futureBuilderFuture = _bangumidController.queryBangumiListFeed();
|
_futureBuilderFuture = _bangumidController.queryBangumiListFeed();
|
||||||
_futureBuilderFutureFollow = _bangumidController.queryBangumiFollow();
|
_futureBuilderFutureFollow = _bangumidController.queryBangumiFollow();
|
||||||
scrollController.addListener(
|
scrollController.addListener(
|
||||||
@ -49,16 +43,7 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
_bangumidController.onLoad();
|
_bangumidController.onLoad();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
handleScrollEvent(scrollController);
|
||||||
final ScrollDirection direction =
|
|
||||||
scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
searchBarStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
searchBarStream.add(false);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
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';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -6,19 +8,21 @@ import 'package:pilipala/models/bangumi/info.dart';
|
|||||||
import 'package:pilipala/pages/video/detail/index.dart';
|
import 'package:pilipala/pages/video/detail/index.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||||
|
import '../../../common/pages_bottom_sheet.dart';
|
||||||
|
import '../../../models/common/video_episode_type.dart';
|
||||||
|
|
||||||
class BangumiPanel extends StatefulWidget {
|
class BangumiPanel extends StatefulWidget {
|
||||||
const BangumiPanel({
|
const BangumiPanel({
|
||||||
super.key,
|
super.key,
|
||||||
required this.pages,
|
required this.pages,
|
||||||
this.cid,
|
required this.cid,
|
||||||
this.sheetHeight,
|
this.sheetHeight,
|
||||||
this.changeFuc,
|
this.changeFuc,
|
||||||
this.bangumiDetail,
|
this.bangumiDetail,
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<EpisodeItem> pages;
|
final List<EpisodeItem> pages;
|
||||||
final int? cid;
|
final int cid;
|
||||||
final double? sheetHeight;
|
final double? sheetHeight;
|
||||||
final Function? changeFuc;
|
final Function? changeFuc;
|
||||||
final BangumiInfoModel? bangumiDetail;
|
final BangumiInfoModel? bangumiDetail;
|
||||||
@ -28,9 +32,8 @@ class BangumiPanel extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _BangumiPanelState extends State<BangumiPanel> {
|
class _BangumiPanelState extends State<BangumiPanel> {
|
||||||
late int currentIndex;
|
late RxInt currentIndex = (-1).obs;
|
||||||
final ScrollController listViewScrollCtr = ScrollController();
|
final ScrollController listViewScrollCtr = ScrollController();
|
||||||
final ScrollController listViewScrollCtr_2 = ScrollController();
|
|
||||||
Box userInfoCache = GStrorage.userInfo;
|
Box userInfoCache = GStrorage.userInfo;
|
||||||
dynamic userInfo;
|
dynamic userInfo;
|
||||||
// 默认未开通
|
// 默认未开通
|
||||||
@ -39,169 +42,68 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
String heroTag = Get.arguments['heroTag'];
|
String heroTag = Get.arguments['heroTag'];
|
||||||
late final VideoDetailController videoDetailCtr;
|
late final VideoDetailController videoDetailCtr;
|
||||||
final ItemScrollController itemScrollController = ItemScrollController();
|
final ItemScrollController itemScrollController = ItemScrollController();
|
||||||
|
late PersistentBottomSheetController? _bottomSheetController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
cid = widget.cid!;
|
cid = widget.cid;
|
||||||
currentIndex = widget.pages.indexWhere((e) => e.cid == cid);
|
videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
|
||||||
|
currentIndex.value =
|
||||||
|
widget.pages.indexWhere((EpisodeItem e) => e.cid == cid);
|
||||||
scrollToIndex();
|
scrollToIndex();
|
||||||
|
videoDetailCtr.cid.listen((int p0) {
|
||||||
|
cid = p0;
|
||||||
|
currentIndex.value =
|
||||||
|
widget.pages.indexWhere((EpisodeItem e) => e.cid == cid);
|
||||||
|
scrollToIndex();
|
||||||
|
});
|
||||||
|
|
||||||
|
/// 获取大会员状态
|
||||||
userInfo = userInfoCache.get('userInfoCache');
|
userInfo = userInfoCache.get('userInfoCache');
|
||||||
if (userInfo != null) {
|
if (userInfo != null) {
|
||||||
vipStatus = userInfo.vipStatus;
|
vipStatus = userInfo.vipStatus;
|
||||||
}
|
}
|
||||||
videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
|
|
||||||
|
|
||||||
videoDetailCtr.cid.listen((int p0) {
|
|
||||||
cid = p0;
|
|
||||||
setState(() {});
|
|
||||||
currentIndex = widget.pages.indexWhere((EpisodeItem e) => e.cid == cid);
|
|
||||||
scrollToIndex();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
listViewScrollCtr.dispose();
|
listViewScrollCtr.dispose();
|
||||||
listViewScrollCtr_2.dispose();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildPageListItem(
|
|
||||||
EpisodeItem page,
|
|
||||||
int index,
|
|
||||||
bool isCurrentIndex,
|
|
||||||
) {
|
|
||||||
Color primary = Theme.of(context).colorScheme.primary;
|
|
||||||
return ListTile(
|
|
||||||
onTap: () {
|
|
||||||
Get.back();
|
|
||||||
setState(() {
|
|
||||||
changeFucCall(page, index);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
dense: false,
|
|
||||||
leading: isCurrentIndex
|
|
||||||
? Image.asset(
|
|
||||||
'assets/images/live.gif',
|
|
||||||
color: primary,
|
|
||||||
height: 12,
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
title: Text(
|
|
||||||
'第${page.title}话 ${page.longTitle!}',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: isCurrentIndex
|
|
||||||
? primary
|
|
||||||
: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
trailing: page.badge != null
|
|
||||||
? Text(
|
|
||||||
page.badge!,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: const SizedBox(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void showBangumiPanel() {
|
|
||||||
showBottomSheet(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return StatefulBuilder(
|
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
||||||
// await Future.delayed(const Duration(milliseconds: 200));
|
|
||||||
// listViewScrollCtr_2.animateTo(currentIndex * 56,
|
|
||||||
// duration: const Duration(milliseconds: 500),
|
|
||||||
// curve: Curves.easeInOut);
|
|
||||||
itemScrollController.jumpTo(index: currentIndex);
|
|
||||||
});
|
|
||||||
// 在这里使用 setState 更新状态
|
|
||||||
return Container(
|
|
||||||
height: widget.sheetHeight,
|
|
||||||
color: Theme.of(context).colorScheme.background,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
AppBar(
|
|
||||||
toolbarHeight: 45,
|
|
||||||
automaticallyImplyLeading: false,
|
|
||||||
title: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'合集(${widget.pages.length})',
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.close),
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
titleSpacing: 10,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Material(
|
|
||||||
child: ScrollablePositionedList.builder(
|
|
||||||
itemCount: widget.pages.length + 1,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
bool isLastItem = index == widget.pages.length;
|
|
||||||
bool isCurrentIndex = currentIndex == index;
|
|
||||||
return isLastItem
|
|
||||||
? SizedBox(
|
|
||||||
height:
|
|
||||||
MediaQuery.of(context).padding.bottom +
|
|
||||||
20,
|
|
||||||
)
|
|
||||||
: buildPageListItem(
|
|
||||||
widget.pages[index],
|
|
||||||
index,
|
|
||||||
isCurrentIndex,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemScrollController: itemScrollController,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void changeFucCall(item, i) async {
|
void changeFucCall(item, i) async {
|
||||||
if (item.badge != null && item.badge == '会员' && vipStatus != 1) {
|
if (item.badge != null && item.badge == '会员' && vipStatus != 1) {
|
||||||
SmartDialog.showToast('需要大会员');
|
SmartDialog.showToast('需要大会员');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await widget.changeFuc!(
|
widget.changeFuc?.call(
|
||||||
item.bvid,
|
item.bvid,
|
||||||
item.cid,
|
item.cid,
|
||||||
item.aid,
|
item.aid,
|
||||||
);
|
);
|
||||||
|
_bottomSheetController?.close();
|
||||||
currentIndex = i;
|
currentIndex = i;
|
||||||
setState(() {});
|
|
||||||
scrollToIndex();
|
scrollToIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollToIndex() {
|
void scrollToIndex() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
// 在回调函数中获取更新后的状态
|
// 在回调函数中获取更新后的状态
|
||||||
listViewScrollCtr.animateTo(currentIndex * 150,
|
final double offset = min((currentIndex * 150) - 75,
|
||||||
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
|
listViewScrollCtr.position.maxScrollExtent);
|
||||||
|
listViewScrollCtr.animateTo(
|
||||||
|
offset,
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Color primary = Theme.of(context).colorScheme.primary;
|
||||||
|
Color onSurface = Theme.of(context).colorScheme.onSurface;
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
@ -211,12 +113,14 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
children: [
|
children: [
|
||||||
const Text('选集 '),
|
const Text('选集 '),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Obx(
|
||||||
' 正在播放:${widget.pages[currentIndex].longTitle}',
|
() => Text(
|
||||||
overflow: TextOverflow.ellipsis,
|
' 正在播放:${widget.pages[currentIndex.value].longTitle}',
|
||||||
style: TextStyle(
|
overflow: TextOverflow.ellipsis,
|
||||||
fontSize: 12,
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.outline,
|
fontSize: 12,
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -227,7 +131,16 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
),
|
),
|
||||||
onPressed: () => showBangumiPanel(),
|
onPressed: () {
|
||||||
|
_bottomSheetController = EpisodeBottomSheet(
|
||||||
|
currentCid: cid,
|
||||||
|
episodes: widget.pages,
|
||||||
|
changeFucCall: changeFucCall,
|
||||||
|
sheetHeight: widget.sheetHeight,
|
||||||
|
dataType: VideoEpidoesType.bangumiEpisode,
|
||||||
|
context: context,
|
||||||
|
).show(context);
|
||||||
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'${widget.bangumiDetail!.newEp!['desc']}',
|
'${widget.bangumiDetail!.newEp!['desc']}',
|
||||||
style: const TextStyle(fontSize: 13),
|
style: const TextStyle(fontSize: 13),
|
||||||
@ -245,6 +158,8 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
itemCount: widget.pages.length,
|
itemCount: widget.pages.length,
|
||||||
itemExtent: 150,
|
itemExtent: 150,
|
||||||
itemBuilder: (BuildContext context, int i) {
|
itemBuilder: (BuildContext context, int i) {
|
||||||
|
var page = widget.pages[i];
|
||||||
|
bool isSelected = i == currentIndex.value;
|
||||||
return Container(
|
return Container(
|
||||||
width: 150,
|
width: 150,
|
||||||
margin: const EdgeInsets.only(right: 10),
|
margin: const EdgeInsets.only(right: 10),
|
||||||
@ -253,42 +168,37 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => changeFucCall(widget.pages[i], i),
|
onTap: () => changeFucCall(page, i),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 8, horizontal: 10),
|
vertical: 8,
|
||||||
|
horizontal: 10,
|
||||||
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
if (i == currentIndex) ...<Widget>[
|
if (isSelected) ...<Widget>[
|
||||||
Image.asset(
|
Image.asset('assets/images/live.png',
|
||||||
'assets/images/live.png',
|
color: primary, height: 12),
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
height: 12,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 6)
|
const SizedBox(width: 6)
|
||||||
],
|
],
|
||||||
Text(
|
Text(
|
||||||
'第${i + 1}话',
|
'第${i + 1}话',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: i == currentIndex
|
color: isSelected ? primary : onSurface,
|
||||||
? Theme.of(context).colorScheme.primary
|
),
|
||||||
: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onSurface),
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 2),
|
const SizedBox(width: 2),
|
||||||
if (widget.pages[i].badge != null) ...[
|
if (page.badge != null) ...[
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Text(
|
Text(
|
||||||
widget.pages[i].badge!,
|
page.badge!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color:
|
color: primary,
|
||||||
Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@ -296,13 +206,12 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 3),
|
const SizedBox(height: 3),
|
||||||
Text(
|
Text(
|
||||||
widget.pages[i].longTitle!,
|
page.longTitle!,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: i == currentIndex
|
color: isSelected ? primary : onSurface,
|
||||||
? Theme.of(context).colorScheme.primary
|
),
|
||||||
: Theme.of(context).colorScheme.onSurface),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|||||||
111
lib/pages/dlna/index.dart
Normal file
111
lib/pages/dlna/index.dart
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:dlna_dart/dlna.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class LiveDlnaPage extends StatefulWidget {
|
||||||
|
final String datasource;
|
||||||
|
|
||||||
|
const LiveDlnaPage({Key? key, required this.datasource}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<LiveDlnaPage> createState() => _LiveDlnaPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LiveDlnaPageState extends State<LiveDlnaPage> {
|
||||||
|
final Map<String, DLNADevice> _deviceList = {};
|
||||||
|
final DLNAManager searcher = DLNAManager();
|
||||||
|
late final Timer stopSearchTimer;
|
||||||
|
String selectDeviceKey = '';
|
||||||
|
bool isSearching = true;
|
||||||
|
|
||||||
|
DLNADevice? get device => _deviceList[selectDeviceKey];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
stopSearchTimer = Timer(const Duration(seconds: 20), () {
|
||||||
|
setState(() => isSearching = false);
|
||||||
|
searcher.stop();
|
||||||
|
});
|
||||||
|
searcher.stop();
|
||||||
|
startSearch();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
searcher.stop();
|
||||||
|
stopSearchTimer.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void startSearch() async {
|
||||||
|
// clear old devices
|
||||||
|
isSearching = true;
|
||||||
|
selectDeviceKey = '';
|
||||||
|
_deviceList.clear();
|
||||||
|
setState(() {});
|
||||||
|
// start search server
|
||||||
|
final m = await searcher.start();
|
||||||
|
m.devices.stream.listen((deviceList) {
|
||||||
|
deviceList.forEach((key, value) {
|
||||||
|
_deviceList[key] = value;
|
||||||
|
});
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
// close the server, the closed server can be start by call searcher.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
void selectDevice(String key) {
|
||||||
|
if (selectDeviceKey.isNotEmpty) device?.pause();
|
||||||
|
|
||||||
|
selectDeviceKey = key;
|
||||||
|
device?.setUrl(widget.datasource);
|
||||||
|
device?.play();
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Widget cur;
|
||||||
|
if (isSearching && _deviceList.isEmpty) {
|
||||||
|
cur = const Center(child: CircularProgressIndicator());
|
||||||
|
} else if (_deviceList.isEmpty) {
|
||||||
|
cur = Center(
|
||||||
|
child: Text(
|
||||||
|
'没有找到设备',
|
||||||
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
cur = ListView(
|
||||||
|
children: _deviceList.keys
|
||||||
|
.map<Widget>((key) => ListTile(
|
||||||
|
contentPadding: const EdgeInsets.all(2),
|
||||||
|
title: Text(_deviceList[key]!.info.friendlyName),
|
||||||
|
subtitle: Text(key),
|
||||||
|
onTap: () => selectDevice(key),
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return AlertDialog(
|
||||||
|
title: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text('查找设备'),
|
||||||
|
IconButton(
|
||||||
|
onPressed: startSearch,
|
||||||
|
icon: const Icon(Icons.refresh_rounded),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
content: SizedBox(
|
||||||
|
height: 200,
|
||||||
|
width: 200,
|
||||||
|
child: cur,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -194,7 +194,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
title: StreamBuilder(
|
title: StreamBuilder(
|
||||||
stream: titleStreamC.stream,
|
stream: titleStreamC.stream.distinct(),
|
||||||
initialData: false,
|
initialData: false,
|
||||||
builder: (context, AsyncSnapshot snapshot) {
|
builder: (context, AsyncSnapshot snapshot) {
|
||||||
return AnimatedOpacity(
|
return AnimatedOpacity(
|
||||||
|
|||||||
@ -3,15 +3,14 @@ import 'dart:async';
|
|||||||
import 'package:custom_sliding_segmented_control/custom_sliding_segmented_control.dart';
|
import 'package:custom_sliding_segmented_control/custom_sliding_segmented_control.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/common/skeleton/dynamic_card.dart';
|
import 'package:pilipala/common/skeleton/dynamic_card.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/common/widgets/no_data.dart';
|
import 'package:pilipala/common/widgets/no_data.dart';
|
||||||
import 'package:pilipala/models/dynamics/result.dart';
|
import 'package:pilipala/models/dynamics/result.dart';
|
||||||
import 'package:pilipala/pages/main/index.dart';
|
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
|
import 'package:pilipala/utils/main_stream.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
import '../mine/controller.dart';
|
import '../mine/controller.dart';
|
||||||
@ -44,8 +43,6 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
_futureBuilderFuture = _dynamicsController.queryFollowDynamic();
|
_futureBuilderFuture = _dynamicsController.queryFollowDynamic();
|
||||||
_futureBuilderFutureUp = _dynamicsController.queryFollowUp();
|
_futureBuilderFutureUp = _dynamicsController.queryFollowUp();
|
||||||
scrollController = _dynamicsController.scrollController;
|
scrollController = _dynamicsController.scrollController;
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
scrollController.addListener(
|
scrollController.addListener(
|
||||||
() async {
|
() async {
|
||||||
if (scrollController.position.pixels >=
|
if (scrollController.position.pixels >=
|
||||||
@ -55,14 +52,7 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
_dynamicsController.queryFollowDynamic(type: 'onLoad');
|
_dynamicsController.queryFollowDynamic(type: 'onLoad');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
handleScrollEvent(scrollController);
|
||||||
final ScrollDirection direction =
|
|
||||||
scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -67,7 +67,7 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
|||||||
pinned: true,
|
pinned: true,
|
||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
title: StreamBuilder(
|
title: StreamBuilder(
|
||||||
stream: titleStreamC.stream,
|
stream: titleStreamC.stream.distinct(),
|
||||||
initialData: false,
|
initialData: false,
|
||||||
builder: (context, AsyncSnapshot snapshot) {
|
builder: (context, AsyncSnapshot snapshot) {
|
||||||
return AnimatedOpacity(
|
return AnimatedOpacity(
|
||||||
|
|||||||
@ -185,7 +185,7 @@ class HistoryItem extends StatelessWidget {
|
|||||||
? '已看完'
|
? '已看完'
|
||||||
: '${Utils.timeFormat(videoItem.progress!)}/${Utils.timeFormat(videoItem.duration!)}',
|
: '${Utils.timeFormat(videoItem.progress!)}/${Utils.timeFormat(videoItem.duration!)}',
|
||||||
right: 6.0,
|
right: 6.0,
|
||||||
bottom: 6.0,
|
bottom: 8.0,
|
||||||
type: 'gray',
|
type: 'gray',
|
||||||
),
|
),
|
||||||
// 右上角
|
// 右上角
|
||||||
@ -258,6 +258,27 @@ class HistoryItem extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
videoItem.progress != 0
|
||||||
|
? Positioned(
|
||||||
|
left: 3,
|
||||||
|
right: 3,
|
||||||
|
bottom: 0,
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
bottomLeft: Radius.circular(
|
||||||
|
StyleString.imgRadius.x),
|
||||||
|
bottomRight: Radius.circular(
|
||||||
|
StyleString.imgRadius.x),
|
||||||
|
),
|
||||||
|
child: LinearProgressIndicator(
|
||||||
|
value: videoItem.progress == -1
|
||||||
|
? 100
|
||||||
|
: videoItem.progress /
|
||||||
|
videoItem.duration,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const SizedBox()
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
VideoContent(videoItem: videoItem, ctr: ctr)
|
VideoContent(videoItem: videoItem, ctr: ctr)
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
|||||||
userLogin.value = userInfo != null;
|
userLogin.value = userInfo != null;
|
||||||
userFace.value = userInfo != null ? userInfo.face : '';
|
userFace.value = userInfo != null ? userInfo.face : '';
|
||||||
hideSearchBar =
|
hideSearchBar =
|
||||||
setting.get(SettingBoxKey.hideSearchBar, defaultValue: true);
|
setting.get(SettingBoxKey.hideSearchBar, defaultValue: false);
|
||||||
if (setting.get(SettingBoxKey.enableSearchWord, defaultValue: true)) {
|
if (setting.get(SettingBoxKey.enableSearchWord, defaultValue: true)) {
|
||||||
searchDefault();
|
searchDefault();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -171,7 +171,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StreamBuilder(
|
return StreamBuilder(
|
||||||
stream: stream,
|
stream: stream!.distinct(),
|
||||||
initialData: true,
|
initialData: true,
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||||
final RxBool isUserLoggedIn = ctr!.userLogin;
|
final RxBool isUserLoggedIn = ctr!.userLogin;
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/constants.dart';
|
import 'package:pilipala/common/constants.dart';
|
||||||
import 'package:pilipala/common/widgets/animated_dialog.dart';
|
import 'package:pilipala/common/widgets/animated_dialog.dart';
|
||||||
@ -9,9 +8,8 @@ import 'package:pilipala/common/widgets/overlay_pop.dart';
|
|||||||
import 'package:pilipala/common/skeleton/video_card_h.dart';
|
import 'package:pilipala/common/skeleton/video_card_h.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/common/widgets/video_card_h.dart';
|
import 'package:pilipala/common/widgets/video_card_h.dart';
|
||||||
import 'package:pilipala/pages/home/index.dart';
|
|
||||||
import 'package:pilipala/pages/hot/controller.dart';
|
import 'package:pilipala/pages/hot/controller.dart';
|
||||||
import 'package:pilipala/pages/main/index.dart';
|
import 'package:pilipala/utils/main_stream.dart';
|
||||||
|
|
||||||
class HotPage extends StatefulWidget {
|
class HotPage extends StatefulWidget {
|
||||||
const HotPage({Key? key}) : super(key: key);
|
const HotPage({Key? key}) : super(key: key);
|
||||||
@ -34,10 +32,6 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
|
|||||||
super.initState();
|
super.initState();
|
||||||
_futureBuilderFuture = _hotController.queryHotFeed('init');
|
_futureBuilderFuture = _hotController.queryHotFeed('init');
|
||||||
scrollController = _hotController.scrollController;
|
scrollController = _hotController.scrollController;
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
StreamController<bool> searchBarStream =
|
|
||||||
Get.find<HomeController>().searchBarStream;
|
|
||||||
scrollController.addListener(
|
scrollController.addListener(
|
||||||
() {
|
() {
|
||||||
if (scrollController.position.pixels >=
|
if (scrollController.position.pixels >=
|
||||||
@ -47,16 +41,7 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
|
|||||||
_hotController.onLoad();
|
_hotController.onLoad();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
handleScrollEvent(scrollController);
|
||||||
final ScrollDirection direction =
|
|
||||||
scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
searchBarStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
searchBarStream.add(false);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,15 +2,13 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/constants.dart';
|
import 'package:pilipala/common/constants.dart';
|
||||||
import 'package:pilipala/common/skeleton/video_card_v.dart';
|
import 'package:pilipala/common/skeleton/video_card_v.dart';
|
||||||
import 'package:pilipala/common/widgets/animated_dialog.dart';
|
import 'package:pilipala/common/widgets/animated_dialog.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/common/widgets/overlay_pop.dart';
|
import 'package:pilipala/common/widgets/overlay_pop.dart';
|
||||||
import 'package:pilipala/pages/home/index.dart';
|
import 'package:pilipala/utils/main_stream.dart';
|
||||||
import 'package:pilipala/pages/main/index.dart';
|
|
||||||
|
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
import 'widgets/live_item.dart';
|
import 'widgets/live_item.dart';
|
||||||
@ -36,10 +34,6 @@ class _LivePageState extends State<LivePage>
|
|||||||
super.initState();
|
super.initState();
|
||||||
_futureBuilderFuture = _liveController.queryLiveList('init');
|
_futureBuilderFuture = _liveController.queryLiveList('init');
|
||||||
scrollController = _liveController.scrollController;
|
scrollController = _liveController.scrollController;
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
StreamController<bool> searchBarStream =
|
|
||||||
Get.find<HomeController>().searchBarStream;
|
|
||||||
scrollController.addListener(
|
scrollController.addListener(
|
||||||
() {
|
() {
|
||||||
if (scrollController.position.pixels >=
|
if (scrollController.position.pixels >=
|
||||||
@ -49,16 +43,7 @@ class _LivePageState extends State<LivePage>
|
|||||||
_liveController.onLoad();
|
_liveController.onLoad();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
handleScrollEvent(scrollController);
|
||||||
final ScrollDirection direction =
|
|
||||||
scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
searchBarStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
searchBarStream.add(false);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,6 +62,11 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
|
|||||||
controller: plPlayerController,
|
controller: plPlayerController,
|
||||||
liveRoomCtr: _liveRoomController,
|
liveRoomCtr: _liveRoomController,
|
||||||
floating: floating,
|
floating: floating,
|
||||||
|
onRefresh: () {
|
||||||
|
setState(() {
|
||||||
|
_futureBuilderFuture = _liveRoomController.queryLiveInfo();
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -14,10 +14,12 @@ class BottomControl extends StatefulWidget implements PreferredSizeWidget {
|
|||||||
final PlPlayerController? controller;
|
final PlPlayerController? controller;
|
||||||
final LiveRoomController? liveRoomCtr;
|
final LiveRoomController? liveRoomCtr;
|
||||||
final Floating? floating;
|
final Floating? floating;
|
||||||
|
final Function? onRefresh;
|
||||||
const BottomControl({
|
const BottomControl({
|
||||||
this.controller,
|
this.controller,
|
||||||
this.liveRoomCtr,
|
this.liveRoomCtr,
|
||||||
this.floating,
|
this.floating,
|
||||||
|
this.onRefresh,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@ -61,6 +63,14 @@ class _BottomControlState extends State<BottomControl> {
|
|||||||
// ),
|
// ),
|
||||||
// fuc: () => Get.back(),
|
// fuc: () => Get.back(),
|
||||||
// ),
|
// ),
|
||||||
|
ComBtn(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.refresh_outlined,
|
||||||
|
size: 18,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
fuc: widget.onRefresh,
|
||||||
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
// ComBtn(
|
// ComBtn(
|
||||||
// icon: const Icon(
|
// icon: const Icon(
|
||||||
@ -150,21 +160,3 @@ class _BottomControlState extends State<BottomControl> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MSliderTrackShape extends RoundedRectSliderTrackShape {
|
|
||||||
@override
|
|
||||||
Rect getPreferredRect({
|
|
||||||
required RenderBox parentBox,
|
|
||||||
Offset offset = Offset.zero,
|
|
||||||
SliderThemeData? sliderTheme,
|
|
||||||
bool isEnabled = false,
|
|
||||||
bool isDiscrete = false,
|
|
||||||
}) {
|
|
||||||
const double trackHeight = 3;
|
|
||||||
final double trackLeft = offset.dx;
|
|
||||||
final double trackTop =
|
|
||||||
offset.dy + (parentBox.size.height - trackHeight) / 2 + 4;
|
|
||||||
final double trackWidth = parentBox.size.width;
|
|
||||||
return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -6,23 +6,16 @@ import 'package:get/get.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/http/common.dart';
|
import 'package:pilipala/http/common.dart';
|
||||||
import 'package:pilipala/pages/dynamics/index.dart';
|
|
||||||
import 'package:pilipala/pages/home/view.dart';
|
|
||||||
import 'package:pilipala/pages/media/index.dart';
|
|
||||||
import 'package:pilipala/pages/rank/index.dart';
|
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
import '../../models/common/dynamic_badge_mode.dart';
|
import '../../models/common/dynamic_badge_mode.dart';
|
||||||
import '../../models/common/nav_bar_config.dart';
|
import '../../models/common/nav_bar_config.dart';
|
||||||
|
|
||||||
class MainController extends GetxController {
|
class MainController extends GetxController {
|
||||||
List<Widget> pages = <Widget>[
|
List<Widget> pages = <Widget>[];
|
||||||
const HomePage(),
|
RxList navigationBars = [].obs;
|
||||||
const RankPage(),
|
late List defaultNavTabs;
|
||||||
const DynamicsPage(),
|
late List<int> navBarSort;
|
||||||
const MediaPage(),
|
|
||||||
];
|
|
||||||
RxList navigationBars = defaultNavigationBars.obs;
|
|
||||||
final StreamController<bool> bottomBarStream =
|
final StreamController<bool> bottomBarStream =
|
||||||
StreamController<bool>.broadcast();
|
StreamController<bool>.broadcast();
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
@ -40,11 +33,8 @@ class MainController extends GetxController {
|
|||||||
if (setting.get(SettingBoxKey.autoUpdate, defaultValue: false)) {
|
if (setting.get(SettingBoxKey.autoUpdate, defaultValue: false)) {
|
||||||
Utils.checkUpdata();
|
Utils.checkUpdata();
|
||||||
}
|
}
|
||||||
hideTabBar = setting.get(SettingBoxKey.hideTabBar, defaultValue: true);
|
hideTabBar = setting.get(SettingBoxKey.hideTabBar, defaultValue: false);
|
||||||
int defaultHomePage =
|
|
||||||
setting.get(SettingBoxKey.defaultHomePage, defaultValue: 0) as int;
|
|
||||||
selectedIndex = defaultNavigationBars
|
|
||||||
.indexWhere((item) => item['id'] == defaultHomePage);
|
|
||||||
var userInfo = userInfoCache.get('userInfoCache');
|
var userInfo = userInfoCache.get('userInfoCache');
|
||||||
userLogin.value = userInfo != null;
|
userLogin.value = userInfo != null;
|
||||||
dynamicBadgeType.value = DynamicBadgeMode.values[setting.get(
|
dynamicBadgeType.value = DynamicBadgeMode.values[setting.get(
|
||||||
@ -53,6 +43,7 @@ class MainController extends GetxController {
|
|||||||
if (dynamicBadgeType.value != DynamicBadgeMode.hidden) {
|
if (dynamicBadgeType.value != DynamicBadgeMode.hidden) {
|
||||||
getUnreadDynamic();
|
getUnreadDynamic();
|
||||||
}
|
}
|
||||||
|
setNavBarConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onBackPressed(BuildContext context) {
|
void onBackPressed(BuildContext context) {
|
||||||
@ -93,4 +84,21 @@ class MainController extends GetxController {
|
|||||||
}
|
}
|
||||||
navigationBars.refresh();
|
navigationBars.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setNavBarConfig() async {
|
||||||
|
defaultNavTabs = [...defaultNavigationBars];
|
||||||
|
navBarSort =
|
||||||
|
setting.get(SettingBoxKey.navBarSort, defaultValue: [0, 1, 2, 3]);
|
||||||
|
defaultNavTabs.retainWhere((item) => navBarSort.contains(item['id']));
|
||||||
|
defaultNavTabs.sort((a, b) =>
|
||||||
|
navBarSort.indexOf(a['id']).compareTo(navBarSort.indexOf(b['id'])));
|
||||||
|
navigationBars.value = defaultNavTabs;
|
||||||
|
int defaultHomePage =
|
||||||
|
setting.get(SettingBoxKey.defaultHomePage, defaultValue: 0) as int;
|
||||||
|
int defaultIndex =
|
||||||
|
navigationBars.indexWhere((item) => item['id'] == defaultHomePage);
|
||||||
|
// 如果找不到匹配项,默认索引设置为0或其他合适的值
|
||||||
|
selectedIndex = defaultIndex != -1 ? defaultIndex : 0;
|
||||||
|
pages = navigationBars.map<Widget>((e) => e['page']).toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import 'package:pilipala/pages/media/index.dart';
|
|||||||
import 'package:pilipala/pages/rank/index.dart';
|
import 'package:pilipala/pages/rank/index.dart';
|
||||||
import 'package:pilipala/utils/event_bus.dart';
|
import 'package:pilipala/utils/event_bus.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
|
import 'package:pilipala/utils/global_data.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import './controller.dart';
|
import './controller.dart';
|
||||||
|
|
||||||
@ -29,7 +30,6 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
|
|
||||||
int? _lastSelectTime; //上次点击时间
|
int? _lastSelectTime; //上次点击时间
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
late bool enableMYBar;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -37,7 +37,6 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
_lastSelectTime = DateTime.now().millisecondsSinceEpoch;
|
_lastSelectTime = DateTime.now().millisecondsSinceEpoch;
|
||||||
_mainController.pageController =
|
_mainController.pageController =
|
||||||
PageController(initialPage: _mainController.selectedIndex);
|
PageController(initialPage: _mainController.selectedIndex);
|
||||||
enableMYBar = setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIndex(int value) async {
|
void setIndex(int value) async {
|
||||||
@ -127,81 +126,82 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
},
|
},
|
||||||
children: _mainController.pages,
|
children: _mainController.pages,
|
||||||
),
|
),
|
||||||
bottomNavigationBar: StreamBuilder(
|
bottomNavigationBar: _mainController.navigationBars.length > 1
|
||||||
stream: _mainController.hideTabBar
|
? StreamBuilder(
|
||||||
? _mainController.bottomBarStream.stream
|
stream: _mainController.hideTabBar
|
||||||
: StreamController<bool>.broadcast().stream,
|
? _mainController.bottomBarStream.stream.distinct()
|
||||||
initialData: true,
|
: StreamController<bool>.broadcast().stream,
|
||||||
builder: (context, AsyncSnapshot snapshot) {
|
initialData: true,
|
||||||
return AnimatedSlide(
|
builder: (context, AsyncSnapshot snapshot) {
|
||||||
curve: Curves.easeInOutCubicEmphasized,
|
return AnimatedSlide(
|
||||||
duration: const Duration(milliseconds: 500),
|
curve: Curves.easeInOutCubicEmphasized,
|
||||||
offset: Offset(0, snapshot.data ? 0 : 1),
|
duration: const Duration(milliseconds: 500),
|
||||||
child: Obx(
|
offset: Offset(0, snapshot.data ? 0 : 1),
|
||||||
() => enableMYBar
|
child: GlobalData().enableMYBar
|
||||||
? NavigationBar(
|
? NavigationBar(
|
||||||
onDestinationSelected: (value) => setIndex(value),
|
onDestinationSelected: (value) => setIndex(value),
|
||||||
selectedIndex: _mainController.selectedIndex,
|
selectedIndex: _mainController.selectedIndex,
|
||||||
destinations: <Widget>[
|
destinations: <Widget>[
|
||||||
..._mainController.navigationBars.map((e) {
|
..._mainController.navigationBars.map((e) {
|
||||||
return NavigationDestination(
|
return NavigationDestination(
|
||||||
icon: Obx(
|
icon: Obx(
|
||||||
() => Badge(
|
() => Badge(
|
||||||
label:
|
label: _mainController
|
||||||
_mainController.dynamicBadgeType.value ==
|
.dynamicBadgeType.value ==
|
||||||
DynamicBadgeMode.number
|
DynamicBadgeMode.number
|
||||||
? Text(e['count'].toString())
|
? Text(e['count'].toString())
|
||||||
: null,
|
: null,
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||||
isLabelVisible:
|
isLabelVisible: _mainController
|
||||||
_mainController.dynamicBadgeType.value !=
|
.dynamicBadgeType.value !=
|
||||||
DynamicBadgeMode.hidden &&
|
DynamicBadgeMode.hidden &&
|
||||||
e['count'] > 0,
|
e['count'] > 0,
|
||||||
child: e['icon'],
|
child: e['icon'],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
selectedIcon: e['selectIcon'],
|
selectedIcon: e['selectIcon'],
|
||||||
label: e['label'],
|
label: e['label'],
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: BottomNavigationBar(
|
: BottomNavigationBar(
|
||||||
currentIndex: _mainController.selectedIndex,
|
currentIndex: _mainController.selectedIndex,
|
||||||
onTap: (value) => setIndex(value),
|
type: BottomNavigationBarType.fixed,
|
||||||
iconSize: 16,
|
onTap: (value) => setIndex(value),
|
||||||
selectedFontSize: 12,
|
iconSize: 16,
|
||||||
unselectedFontSize: 12,
|
selectedFontSize: 12,
|
||||||
items: [
|
unselectedFontSize: 12,
|
||||||
..._mainController.navigationBars.map((e) {
|
items: [
|
||||||
return BottomNavigationBarItem(
|
..._mainController.navigationBars.map((e) {
|
||||||
icon: Obx(
|
return BottomNavigationBarItem(
|
||||||
() => Badge(
|
icon: Obx(
|
||||||
label:
|
() => Badge(
|
||||||
_mainController.dynamicBadgeType.value ==
|
label: _mainController
|
||||||
|
.dynamicBadgeType.value ==
|
||||||
DynamicBadgeMode.number
|
DynamicBadgeMode.number
|
||||||
? Text(e['count'].toString())
|
? Text(e['count'].toString())
|
||||||
: null,
|
: null,
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||||
isLabelVisible:
|
isLabelVisible: _mainController
|
||||||
_mainController.dynamicBadgeType.value !=
|
.dynamicBadgeType.value !=
|
||||||
DynamicBadgeMode.hidden &&
|
DynamicBadgeMode.hidden &&
|
||||||
e['count'] > 0,
|
e['count'] > 0,
|
||||||
child: e['icon'],
|
child: e['icon'],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
activeIcon: e['selectIcon'],
|
activeIcon: e['selectIcon'],
|
||||||
label: e['label'],
|
label: e['label'],
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
)
|
||||||
),
|
: null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:media_kit/media_kit.dart';
|
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/models/user/fav_folder.dart';
|
import 'package:pilipala/models/user/fav_folder.dart';
|
||||||
import 'package:pilipala/pages/main/index.dart';
|
|
||||||
import 'package:pilipala/pages/media/index.dart';
|
import 'package:pilipala/pages/media/index.dart';
|
||||||
|
import 'package:pilipala/utils/main_stream.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
class MediaPage extends StatefulWidget {
|
class MediaPage extends StatefulWidget {
|
||||||
@ -31,25 +29,12 @@ class _MediaPageState extends State<MediaPage>
|
|||||||
mediaController = Get.put(MediaController());
|
mediaController = Get.put(MediaController());
|
||||||
_futureBuilderFuture = mediaController.queryFavFolder();
|
_futureBuilderFuture = mediaController.queryFavFolder();
|
||||||
ScrollController scrollController = mediaController.scrollController;
|
ScrollController scrollController = mediaController.scrollController;
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
|
|
||||||
mediaController.userLogin.listen((status) {
|
mediaController.userLogin.listen((status) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_futureBuilderFuture = mediaController.queryFavFolder();
|
_futureBuilderFuture = mediaController.queryFavFolder();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
scrollController.addListener(
|
handleScrollEvent(scrollController);
|
||||||
() {
|
|
||||||
final ScrollDirection direction =
|
|
||||||
scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class _MemberPageState extends State<MemberPage>
|
|||||||
children: [
|
children: [
|
||||||
AppBar(
|
AppBar(
|
||||||
title: StreamBuilder(
|
title: StreamBuilder(
|
||||||
stream: appbarStream.stream,
|
stream: appbarStream.stream.distinct(),
|
||||||
initialData: false,
|
initialData: false,
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||||
return AnimatedOpacity(
|
return AnimatedOpacity(
|
||||||
@ -281,8 +281,8 @@ class _MemberPageState extends State<MemberPage>
|
|||||||
future: _futureBuilderFuture,
|
future: _futureBuilderFuture,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
Map data = snapshot.data!;
|
Map? data = snapshot.data;
|
||||||
if (data['status']) {
|
if (data != null && data['status']) {
|
||||||
return Obx(
|
return Obx(
|
||||||
() => Stack(
|
() => Stack(
|
||||||
alignment: AlignmentDirectional.center,
|
alignment: AlignmentDirectional.center,
|
||||||
@ -302,7 +302,14 @@ class _MemberPageState extends State<MemberPage>
|
|||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.titleMedium!
|
.titleMedium!
|
||||||
.copyWith(fontWeight: FontWeight.bold),
|
.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: _memberController.memberInfo.value
|
||||||
|
.vip!.nicknameColor !=
|
||||||
|
null
|
||||||
|
? Color(_memberController.memberInfo
|
||||||
|
.value.vip!.nicknameColor!)
|
||||||
|
: null),
|
||||||
)),
|
)),
|
||||||
const SizedBox(width: 2),
|
const SizedBox(width: 2),
|
||||||
if (_memberController.memberInfo.value.sex == '女')
|
if (_memberController.memberInfo.value.sex == '女')
|
||||||
|
|||||||
@ -180,7 +180,9 @@ class ProfilePanel extends StatelessWidget {
|
|||||||
Obx(
|
Obx(
|
||||||
() => Expanded(
|
() => Expanded(
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: () => ctr.actionRelationMod(),
|
onPressed: () => loadingStatus
|
||||||
|
? null
|
||||||
|
: ctr.actionRelationMod(),
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
foregroundColor: ctr.attribute.value == -1
|
foregroundColor: ctr.attribute.value == -1
|
||||||
? Colors.transparent
|
? Colors.transparent
|
||||||
|
|||||||
@ -18,45 +18,32 @@ class MemberSeasonsPanel extends StatelessWidget {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
MemberSeasonsList item = data!.seasonsList![index];
|
MemberSeasonsList item = data!.seasonsList![index];
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 12, right: 4),
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
ListTile(
|
||||||
padding: const EdgeInsets.only(bottom: 12, left: 4),
|
onTap: () => Get.toNamed(
|
||||||
child: Row(
|
'/memberSeasons?mid=${item.meta!.mid}&seasonId=${item.meta!.seasonId}'),
|
||||||
children: [
|
title: Text(
|
||||||
Text(
|
item.meta!.name!,
|
||||||
item.meta!.name!,
|
maxLines: 1,
|
||||||
maxLines: 1,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: Theme.of(context).textTheme.titleSmall!,
|
style: Theme.of(context).textTheme.titleSmall!,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
dense: true,
|
||||||
PBadge(
|
leading: PBadge(
|
||||||
stack: 'relative',
|
stack: 'relative',
|
||||||
size: 'small',
|
size: 'small',
|
||||||
text: item.meta!.total.toString(),
|
text: item.meta!.total.toString(),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
trailing: const Icon(
|
||||||
SizedBox(
|
Icons.arrow_forward,
|
||||||
width: 35,
|
size: 20,
|
||||||
height: 35,
|
|
||||||
child: IconButton(
|
|
||||||
onPressed: () => Get.toNamed(
|
|
||||||
'/memberSeasons?mid=${item.meta!.mid}&seasonId=${item.meta!.seasonId}'),
|
|
||||||
style: ButtonStyle(
|
|
||||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
|
||||||
),
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.arrow_forward,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
LayoutBuilder(
|
LayoutBuilder(
|
||||||
builder: (context, boxConstraints) {
|
builder: (context, boxConstraints) {
|
||||||
return GridView.builder(
|
return GridView.builder(
|
||||||
|
|||||||
@ -59,6 +59,7 @@ class MemberCoinsItem extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.fromLTRB(5, 6, 0, 0),
|
padding: const EdgeInsets.fromLTRB(5, 6, 0, 0),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
coinItem.title!,
|
coinItem.title!,
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class MemberSeasonsItem extends StatelessWidget {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
int cid =
|
int cid =
|
||||||
await SearchHttp.ab2c(aid: seasonItem.aid, bvid: seasonItem.bvid);
|
await SearchHttp.ab2c(aid: seasonItem.aid, bvid: seasonItem.bvid);
|
||||||
Get.toNamed('/video?bvid=${seasonItem.bvid}&cid=$cid',
|
Get.toNamed('/video?bvid=${seasonItem.bvid}&cid=$cid',
|
||||||
arguments: {'videoItem': seasonItem, 'heroTag': heroTag});
|
arguments: {'videoItem': seasonItem, 'heroTag': heroTag});
|
||||||
},
|
},
|
||||||
@ -51,8 +51,7 @@ class MemberSeasonsItem extends StatelessWidget {
|
|||||||
bottom: 6,
|
bottom: 6,
|
||||||
right: 6,
|
right: 6,
|
||||||
type: 'gray',
|
type: 'gray',
|
||||||
text: Utils.CustomStamp_str(
|
text: Utils.timeFormat(seasonItem.duration),
|
||||||
timestamp: seasonItem.pubdate, date: 'YY-MM-DD'),
|
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import 'package:pilipala/utils/storage.dart';
|
|||||||
class RankController extends GetxController with GetTickerProviderStateMixin {
|
class RankController extends GetxController with GetTickerProviderStateMixin {
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
late RxList tabs = [].obs;
|
late RxList tabs = [].obs;
|
||||||
RxInt initialIndex = 1.obs;
|
RxInt initialIndex = 0.obs;
|
||||||
late TabController tabController;
|
late TabController tabController;
|
||||||
late List tabsCtrList;
|
late List tabsCtrList;
|
||||||
late List<Widget> tabsPageList;
|
late List<Widget> tabsPageList;
|
||||||
@ -50,21 +50,5 @@ class RankController extends GetxController with GetTickerProviderStateMixin {
|
|||||||
length: tabs.length,
|
length: tabs.length,
|
||||||
vsync: this,
|
vsync: this,
|
||||||
);
|
);
|
||||||
// 监听 tabController 切换
|
|
||||||
if (enableGradientBg) {
|
|
||||||
tabController.animation!.addListener(() {
|
|
||||||
if (tabController.indexIsChanging) {
|
|
||||||
if (initialIndex.value != tabController.index) {
|
|
||||||
initialIndex.value = tabController.index;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
final int temp = tabController.animation!.value.round();
|
|
||||||
if (initialIndex.value != temp) {
|
|
||||||
initialIndex.value = temp;
|
|
||||||
tabController.index = initialIndex.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/constants.dart';
|
import 'package:pilipala/common/constants.dart';
|
||||||
import 'package:pilipala/common/widgets/animated_dialog.dart';
|
import 'package:pilipala/common/widgets/animated_dialog.dart';
|
||||||
@ -9,9 +8,8 @@ import 'package:pilipala/common/widgets/overlay_pop.dart';
|
|||||||
import 'package:pilipala/common/skeleton/video_card_h.dart';
|
import 'package:pilipala/common/skeleton/video_card_h.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/common/widgets/video_card_h.dart';
|
import 'package:pilipala/common/widgets/video_card_h.dart';
|
||||||
import 'package:pilipala/pages/home/index.dart';
|
|
||||||
import 'package:pilipala/pages/main/index.dart';
|
|
||||||
import 'package:pilipala/pages/rank/zone/index.dart';
|
import 'package:pilipala/pages/rank/zone/index.dart';
|
||||||
|
import 'package:pilipala/utils/main_stream.dart';
|
||||||
|
|
||||||
class ZonePage extends StatefulWidget {
|
class ZonePage extends StatefulWidget {
|
||||||
const ZonePage({Key? key, required this.rid}) : super(key: key);
|
const ZonePage({Key? key, required this.rid}) : super(key: key);
|
||||||
@ -22,21 +20,22 @@ class ZonePage extends StatefulWidget {
|
|||||||
State<ZonePage> createState() => _ZonePageState();
|
State<ZonePage> createState() => _ZonePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ZonePageState extends State<ZonePage> {
|
class _ZonePageState extends State<ZonePage>
|
||||||
final ZoneController _zoneController = Get.put(ZoneController());
|
with AutomaticKeepAliveClientMixin {
|
||||||
|
late ZoneController _zoneController;
|
||||||
List videoList = [];
|
List videoList = [];
|
||||||
Future? _futureBuilderFuture;
|
Future? _futureBuilderFuture;
|
||||||
late ScrollController scrollController;
|
late ScrollController scrollController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get wantKeepAlive => true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_zoneController = Get.put(ZoneController(), tag: widget.rid.toString());
|
||||||
_futureBuilderFuture = _zoneController.queryRankFeed('init', widget.rid);
|
_futureBuilderFuture = _zoneController.queryRankFeed('init', widget.rid);
|
||||||
scrollController = _zoneController.scrollController;
|
scrollController = _zoneController.scrollController;
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
StreamController<bool> searchBarStream =
|
|
||||||
Get.find<HomeController>().searchBarStream;
|
|
||||||
scrollController.addListener(
|
scrollController.addListener(
|
||||||
() {
|
() {
|
||||||
if (scrollController.position.pixels >=
|
if (scrollController.position.pixels >=
|
||||||
@ -46,16 +45,7 @@ class _ZonePageState extends State<ZonePage> {
|
|||||||
_zoneController.onLoad();
|
_zoneController.onLoad();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
handleScrollEvent(scrollController);
|
||||||
final ScrollDirection direction =
|
|
||||||
scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
searchBarStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
searchBarStream.add(false);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -68,6 +58,7 @@ class _ZonePageState extends State<ZonePage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
super.build(context);
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
return await _zoneController.onRefresh();
|
return await _zoneController.onRefresh();
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/constants.dart';
|
import 'package:pilipala/common/constants.dart';
|
||||||
import 'package:pilipala/common/skeleton/video_card_v.dart';
|
import 'package:pilipala/common/skeleton/video_card_v.dart';
|
||||||
@ -10,8 +9,7 @@ import 'package:pilipala/common/widgets/animated_dialog.dart';
|
|||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/common/widgets/overlay_pop.dart';
|
import 'package:pilipala/common/widgets/overlay_pop.dart';
|
||||||
import 'package:pilipala/common/widgets/video_card_v.dart';
|
import 'package:pilipala/common/widgets/video_card_v.dart';
|
||||||
import 'package:pilipala/pages/home/index.dart';
|
import 'package:pilipala/utils/main_stream.dart';
|
||||||
import 'package:pilipala/pages/main/index.dart';
|
|
||||||
|
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
|
|
||||||
@ -35,10 +33,6 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
super.initState();
|
super.initState();
|
||||||
_futureBuilderFuture = _rcmdController.queryRcmdFeed('init');
|
_futureBuilderFuture = _rcmdController.queryRcmdFeed('init');
|
||||||
ScrollController scrollController = _rcmdController.scrollController;
|
ScrollController scrollController = _rcmdController.scrollController;
|
||||||
StreamController<bool> mainStream =
|
|
||||||
Get.find<MainController>().bottomBarStream;
|
|
||||||
StreamController<bool> searchBarStream =
|
|
||||||
Get.find<HomeController>().searchBarStream;
|
|
||||||
scrollController.addListener(
|
scrollController.addListener(
|
||||||
() {
|
() {
|
||||||
if (scrollController.position.pixels >=
|
if (scrollController.position.pixels >=
|
||||||
@ -49,15 +43,7 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
_rcmdController.onLoad();
|
_rcmdController.onLoad();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
final ScrollDirection direction =
|
handleScrollEvent(scrollController);
|
||||||
scrollController.position.userScrollDirection;
|
|
||||||
if (direction == ScrollDirection.forward) {
|
|
||||||
mainStream.add(true);
|
|
||||||
searchBarStream.add(true);
|
|
||||||
} else if (direction == ScrollDirection.reverse) {
|
|
||||||
mainStream.add(false);
|
|
||||||
searchBarStream.add(false);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
100
lib/pages/setting/pages/navigation_bar_set.dart
Normal file
100
lib/pages/setting/pages/navigation_bar_set.dart
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/models/common/tab_type.dart';
|
||||||
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
|
import '../../../models/common/nav_bar_config.dart';
|
||||||
|
|
||||||
|
class NavigationBarSetPage extends StatefulWidget {
|
||||||
|
const NavigationBarSetPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<NavigationBarSetPage> createState() => _NavigationbarSetPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _NavigationbarSetPageState extends State<NavigationBarSetPage> {
|
||||||
|
Box settingStorage = GStrorage.setting;
|
||||||
|
late List defaultNavTabs;
|
||||||
|
late List<int> navBarSort;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
defaultNavTabs = defaultNavigationBars;
|
||||||
|
navBarSort = settingStorage
|
||||||
|
.get(SettingBoxKey.navBarSort, defaultValue: [0, 1, 2, 3]);
|
||||||
|
// 对 tabData 进行排序
|
||||||
|
defaultNavTabs.sort((a, b) {
|
||||||
|
int indexA = navBarSort.indexOf(a['id']);
|
||||||
|
int indexB = navBarSort.indexOf(b['id']);
|
||||||
|
|
||||||
|
// 如果类型在 sortOrder 中不存在,则放在末尾
|
||||||
|
if (indexA == -1) indexA = navBarSort.length;
|
||||||
|
if (indexB == -1) indexB = navBarSort.length;
|
||||||
|
|
||||||
|
return indexA.compareTo(indexB);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveEdit() {
|
||||||
|
List<int> sortedTabbar = defaultNavTabs
|
||||||
|
.where((i) => navBarSort.contains(i['id']))
|
||||||
|
.map<int>((i) => i['id'])
|
||||||
|
.toList();
|
||||||
|
settingStorage.put(SettingBoxKey.navBarSort, sortedTabbar);
|
||||||
|
SmartDialog.showToast('保存成功,下次启动时生效');
|
||||||
|
}
|
||||||
|
|
||||||
|
void onReorder(int oldIndex, int newIndex) {
|
||||||
|
setState(() {
|
||||||
|
if (newIndex > oldIndex) {
|
||||||
|
newIndex -= 1;
|
||||||
|
}
|
||||||
|
final tabsItem = defaultNavTabs.removeAt(oldIndex);
|
||||||
|
defaultNavTabs.insert(newIndex, tabsItem);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final listTiles = [
|
||||||
|
for (int i = 0; i < defaultNavTabs.length; i++) ...[
|
||||||
|
CheckboxListTile(
|
||||||
|
key: Key(defaultNavTabs[i]['label']),
|
||||||
|
value: navBarSort.contains(defaultNavTabs[i]['id']),
|
||||||
|
onChanged: (bool? newValue) {
|
||||||
|
int tabTypeId = defaultNavTabs[i]['id'];
|
||||||
|
if (!newValue!) {
|
||||||
|
navBarSort.remove(tabTypeId);
|
||||||
|
} else {
|
||||||
|
navBarSort.add(tabTypeId);
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
title: Text(defaultNavTabs[i]['label']),
|
||||||
|
secondary: const Icon(Icons.drag_indicator_rounded),
|
||||||
|
enabled: defaultNavTabs[i]['id'] != 0,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Navbar编辑'),
|
||||||
|
actions: [
|
||||||
|
TextButton(onPressed: () => saveEdit(), child: const Text('保存')),
|
||||||
|
const SizedBox(width: 12)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: ReorderableListView(
|
||||||
|
onReorder: onReorder,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
footer: SizedBox(
|
||||||
|
height: MediaQuery.of(context).padding.bottom + 30,
|
||||||
|
),
|
||||||
|
children: listTiles,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -284,12 +284,17 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
onTap: () => Get.toNamed('/tabbarSetting'),
|
onTap: () => Get.toNamed('/tabbarSetting'),
|
||||||
title: Text('首页tabbar', style: titleStyle),
|
title: Text('首页tabbar', style: titleStyle),
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
onTap: () => Get.toNamed('/navbarSetting'),
|
||||||
|
title: Text('底部导航栏设置', style: titleStyle),
|
||||||
|
),
|
||||||
if (Platform.isAndroid)
|
if (Platform.isAndroid)
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: false,
|
dense: false,
|
||||||
onTap: () => Get.toNamed('/displayModeSetting'),
|
onTap: () => Get.toNamed('/displayModeSetting'),
|
||||||
title: Text('屏幕帧率', style: titleStyle),
|
title: Text('屏幕帧率', style: titleStyle),
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -44,6 +44,7 @@ class _SelectDialogState<T> extends State<SelectDialog<T>> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_tempValue = value as T;
|
_tempValue = value as T;
|
||||||
});
|
});
|
||||||
|
Navigator.pop(context, _tempValue);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@ -51,19 +52,6 @@ class _SelectDialogState<T> extends State<SelectDialog<T>> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
child: Text(
|
|
||||||
'取消',
|
|
||||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(context, _tempValue),
|
|
||||||
child: const Text('确定'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,4 +46,40 @@ class SubController extends GetxController {
|
|||||||
Future onLoad() async {
|
Future onLoad() async {
|
||||||
querySubFolder(type: 'onload');
|
querySubFolder(type: 'onload');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 取消订阅
|
||||||
|
Future<void> cancelSub(SubFolderItemData subFolderItem) async {
|
||||||
|
showDialog(
|
||||||
|
context: Get.context!,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: const Text('提示'),
|
||||||
|
content: const Text('确定取消订阅吗?'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'取消',
|
||||||
|
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
var res = await UserHttp.cancelSub(seasonId: subFolderItem.id!);
|
||||||
|
if (res['status']) {
|
||||||
|
subFolderData.value.list!.remove(subFolderItem);
|
||||||
|
subFolderData.update((val) {});
|
||||||
|
SmartDialog.showToast('取消订阅成功');
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
child: const Text('确定'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,7 +58,8 @@ class _SubPageState extends State<SubPage> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return SubItem(
|
return SubItem(
|
||||||
subFolderItem:
|
subFolderItem:
|
||||||
_subController.subFolderData.value.list![index]);
|
_subController.subFolderData.value.list![index],
|
||||||
|
cancelSub: _subController.cancelSub);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -8,7 +8,12 @@ import '../../../models/user/sub_folder.dart';
|
|||||||
|
|
||||||
class SubItem extends StatelessWidget {
|
class SubItem extends StatelessWidget {
|
||||||
final SubFolderItemData subFolderItem;
|
final SubFolderItemData subFolderItem;
|
||||||
const SubItem({super.key, required this.subFolderItem});
|
final Function(SubFolderItemData) cancelSub;
|
||||||
|
const SubItem({
|
||||||
|
super.key,
|
||||||
|
required this.subFolderItem,
|
||||||
|
required this.cancelSub,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -51,7 +56,10 @@ class SubItem extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
VideoContent(subFolderItem: subFolderItem)
|
VideoContent(
|
||||||
|
subFolderItem: subFolderItem,
|
||||||
|
cancelSub: cancelSub,
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -64,7 +72,8 @@ class SubItem extends StatelessWidget {
|
|||||||
|
|
||||||
class VideoContent extends StatelessWidget {
|
class VideoContent extends StatelessWidget {
|
||||||
final SubFolderItemData subFolderItem;
|
final SubFolderItemData subFolderItem;
|
||||||
const VideoContent({super.key, required this.subFolderItem});
|
final Function(SubFolderItemData)? cancelSub;
|
||||||
|
const VideoContent({super.key, required this.subFolderItem, this.cancelSub});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -100,6 +109,24 @@ class VideoContent extends StatelessWidget {
|
|||||||
color: Theme.of(context).colorScheme.outline,
|
color: Theme.of(context).colorScheme.outline,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 35,
|
||||||
|
width: 35,
|
||||||
|
child: IconButton(
|
||||||
|
onPressed: () => cancelSub?.call(subFolderItem),
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: Theme.of(context).colorScheme.outline,
|
||||||
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
|
||||||
|
),
|
||||||
|
icon: const Icon(Icons.delete_outline, size: 18),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import '../../models/user/sub_folder.dart';
|
|||||||
|
|
||||||
class SubDetailController extends GetxController {
|
class SubDetailController extends GetxController {
|
||||||
late SubFolderItemData item;
|
late SubFolderItemData item;
|
||||||
|
|
||||||
late int seasonId;
|
late int seasonId;
|
||||||
late String heroTag;
|
late String heroTag;
|
||||||
int currentPage = 1;
|
int currentPage = 1;
|
||||||
@ -26,17 +25,23 @@ class SubDetailController extends GetxController {
|
|||||||
super.onInit();
|
super.onInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> queryUserSubFolderDetail({type = 'init'}) async {
|
Future<dynamic> queryUserSeasonList({type = 'init'}) async {
|
||||||
if (type == 'onLoad' && subList.length >= mediaCount) {
|
if (type == 'onLoad' && subList.length >= mediaCount) {
|
||||||
loadingText.value = '没有更多了';
|
loadingText.value = '没有更多了';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isLoadingMore = true;
|
isLoadingMore = true;
|
||||||
var res = await UserHttp.userSubFolderDetail(
|
var res = type == 21
|
||||||
seasonId: seasonId,
|
? await UserHttp.userSeasonList(
|
||||||
ps: 20,
|
seasonId: seasonId,
|
||||||
pn: currentPage,
|
ps: 20,
|
||||||
);
|
pn: currentPage,
|
||||||
|
)
|
||||||
|
: await UserHttp.userResourceList(
|
||||||
|
seasonId: seasonId,
|
||||||
|
ps: 20,
|
||||||
|
pn: currentPage,
|
||||||
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
subInfo.value = res['data'].info;
|
subInfo.value = res['data'].info;
|
||||||
if (currentPage == 1 && type == 'init') {
|
if (currentPage == 1 && type == 'init') {
|
||||||
@ -55,6 +60,6 @@ class SubDetailController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
queryUserSubFolderDetail(type: 'onLoad');
|
queryUserSeasonList(type: 'onLoad');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,13 +26,11 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
|||||||
Get.put(SubDetailController());
|
Get.put(SubDetailController());
|
||||||
late StreamController<bool> titleStreamC; // a
|
late StreamController<bool> titleStreamC; // a
|
||||||
late Future _futureBuilderFuture;
|
late Future _futureBuilderFuture;
|
||||||
late String seasonId;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
seasonId = Get.parameters['seasonId']!;
|
_futureBuilderFuture = _subDetailController.queryUserSeasonList();
|
||||||
_futureBuilderFuture = _subDetailController.queryUserSubFolderDetail();
|
|
||||||
titleStreamC = StreamController<bool>();
|
titleStreamC = StreamController<bool>();
|
||||||
_controller.addListener(
|
_controller.addListener(
|
||||||
() {
|
() {
|
||||||
@ -69,7 +67,7 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
|||||||
pinned: true,
|
pinned: true,
|
||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
title: StreamBuilder(
|
title: StreamBuilder(
|
||||||
stream: titleStreamC.stream,
|
stream: titleStreamC.stream.distinct(),
|
||||||
initialData: false,
|
initialData: false,
|
||||||
builder: (context, AsyncSnapshot snapshot) {
|
builder: (context, AsyncSnapshot snapshot) {
|
||||||
return AnimatedOpacity(
|
return AnimatedOpacity(
|
||||||
@ -161,15 +159,18 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Obx(
|
||||||
'${Utils.numFormat(_subDetailController.item.viewCount)}次播放',
|
() => Text(
|
||||||
style: TextStyle(
|
'${Utils.numFormat(_subDetailController.subInfo.value.cntInfo?['play'])}次播放',
|
||||||
fontSize: Theme.of(context)
|
style: TextStyle(
|
||||||
.textTheme
|
fontSize: Theme.of(context)
|
||||||
.labelSmall!
|
.textTheme
|
||||||
.fontSize,
|
.labelSmall!
|
||||||
color: Theme.of(context).colorScheme.outline),
|
.fontSize,
|
||||||
),
|
color:
|
||||||
|
Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -182,14 +183,12 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
|||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(top: 15, bottom: 8, left: 14),
|
padding: const EdgeInsets.only(top: 15, bottom: 8, left: 14),
|
||||||
child: Obx(
|
child: Text(
|
||||||
() => Text(
|
'共${_subDetailController.item.mediaCount}条视频',
|
||||||
'共${_subDetailController.subList.length}条视频',
|
style: TextStyle(
|
||||||
style: TextStyle(
|
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||||
fontSize:
|
color: Theme.of(context).colorScheme.outline,
|
||||||
Theme.of(context).textTheme.labelMedium!.fontSize,
|
letterSpacing: 1,
|
||||||
color: Theme.of(context).colorScheme.outline,
|
|
||||||
letterSpacing: 1),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -20,7 +20,9 @@ import 'package:pilipala/utils/utils.dart';
|
|||||||
import 'package:pilipala/utils/video_utils.dart';
|
import 'package:pilipala/utils/video_utils.dart';
|
||||||
import 'package:screen_brightness/screen_brightness.dart';
|
import 'package:screen_brightness/screen_brightness.dart';
|
||||||
|
|
||||||
|
import '../../../models/video/subTitile/content.dart';
|
||||||
import '../../../http/danmaku.dart';
|
import '../../../http/danmaku.dart';
|
||||||
|
import '../../../plugin/pl_player/models/bottom_control_type.dart';
|
||||||
import '../../../utils/id_utils.dart';
|
import '../../../utils/id_utils.dart';
|
||||||
import 'widgets/header_control.dart';
|
import 'widgets/header_control.dart';
|
||||||
|
|
||||||
@ -90,10 +92,20 @@ class VideoDetailController extends GetxController
|
|||||||
late bool enableCDN;
|
late bool enableCDN;
|
||||||
late int? cacheVideoQa;
|
late int? cacheVideoQa;
|
||||||
late String cacheDecode;
|
late String cacheDecode;
|
||||||
late int cacheAudioQa;
|
late int defaultAudioQa;
|
||||||
|
|
||||||
PersistentBottomSheetController? replyReplyBottomSheetCtr;
|
PersistentBottomSheetController? replyReplyBottomSheetCtr;
|
||||||
|
RxList<SubTitileContentModel> subtitleContents =
|
||||||
|
<SubTitileContentModel>[].obs;
|
||||||
late bool enableRelatedVideo;
|
late bool enableRelatedVideo;
|
||||||
|
List subtitles = [];
|
||||||
|
RxList<BottomControlType> bottomList = [
|
||||||
|
BottomControlType.playOrPause,
|
||||||
|
BottomControlType.time,
|
||||||
|
BottomControlType.space,
|
||||||
|
BottomControlType.fit,
|
||||||
|
BottomControlType.fullscreen,
|
||||||
|
].obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -142,9 +154,10 @@ class VideoDetailController extends GetxController
|
|||||||
// 预设的解码格式
|
// 预设的解码格式
|
||||||
cacheDecode = setting.get(SettingBoxKey.defaultDecode,
|
cacheDecode = setting.get(SettingBoxKey.defaultDecode,
|
||||||
defaultValue: VideoDecodeFormats.values.last.code);
|
defaultValue: VideoDecodeFormats.values.last.code);
|
||||||
cacheAudioQa = setting.get(SettingBoxKey.defaultAudioQa,
|
defaultAudioQa = setting.get(SettingBoxKey.defaultAudioQa,
|
||||||
defaultValue: AudioQuality.hiRes.code);
|
defaultValue: AudioQuality.hiRes.code);
|
||||||
oid.value = IdUtils.bv2av(Get.parameters['bvid']!);
|
oid.value = IdUtils.bv2av(Get.parameters['bvid']!);
|
||||||
|
getSubtitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
showReplyReplyPanel() {
|
showReplyReplyPanel() {
|
||||||
@ -251,6 +264,8 @@ class VideoDetailController extends GetxController
|
|||||||
|
|
||||||
/// 开启自动全屏时,在player初始化完成后立即传入headerControl
|
/// 开启自动全屏时,在player初始化完成后立即传入headerControl
|
||||||
plPlayerController.headerControl = headerControl;
|
plPlayerController.headerControl = headerControl;
|
||||||
|
|
||||||
|
plPlayerController.subtitles.value = subtitles;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 视频链接
|
// 视频链接
|
||||||
@ -346,9 +361,9 @@ class VideoDetailController extends GetxController
|
|||||||
|
|
||||||
if (audiosList.isNotEmpty) {
|
if (audiosList.isNotEmpty) {
|
||||||
final List<int> numbers = audiosList.map((map) => map.id!).toList();
|
final List<int> numbers = audiosList.map((map) => map.id!).toList();
|
||||||
int closestNumber = Utils.findClosestNumber(cacheAudioQa, numbers);
|
int closestNumber = Utils.findClosestNumber(defaultAudioQa, numbers);
|
||||||
if (!numbers.contains(cacheAudioQa) &&
|
if (!numbers.contains(defaultAudioQa) &&
|
||||||
numbers.any((e) => e > cacheAudioQa)) {
|
numbers.any((e) => e > defaultAudioQa)) {
|
||||||
closestNumber = 30280;
|
closestNumber = 30280;
|
||||||
}
|
}
|
||||||
firstAudio = audiosList.firstWhere((e) => e.id == closestNumber);
|
firstAudio = audiosList.firstWhere((e) => e.id == closestNumber);
|
||||||
@ -388,6 +403,45 @@ class VideoDetailController extends GetxController
|
|||||||
: print('replyReplyBottomSheetCtr is null');
|
: print('replyReplyBottomSheetCtr is null');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取字幕配置
|
||||||
|
Future getSubtitle() async {
|
||||||
|
var result = await VideoHttp.getSubtitle(bvid: bvid, cid: cid.value);
|
||||||
|
if (result['status']) {
|
||||||
|
if (result['data'].subtitles.isNotEmpty) {
|
||||||
|
subtitles = result['data'].subtitles;
|
||||||
|
if (subtitles.isNotEmpty) {
|
||||||
|
for (var i in subtitles) {
|
||||||
|
final Map<String, dynamic> res = await VideoHttp.getSubtitleContent(
|
||||||
|
i.subtitleUrl,
|
||||||
|
);
|
||||||
|
i.content = res['content'];
|
||||||
|
i.body = res['body'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result['data'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取字幕内容
|
||||||
|
// Future getSubtitleContent(String url) async {
|
||||||
|
// var res = await Request().get('https:$url');
|
||||||
|
// subtitleContents.value = res.data['body'].map<SubTitileContentModel>((e) {
|
||||||
|
// return SubTitileContentModel.fromJson(e);
|
||||||
|
// }).toList();
|
||||||
|
// setSubtitleContent();
|
||||||
|
// }
|
||||||
|
|
||||||
|
setSubtitleContent() {
|
||||||
|
plPlayerController.subtitleContent.value = '';
|
||||||
|
plPlayerController.subtitles.value = subtitles;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearSubtitleContent() {
|
||||||
|
plPlayerController.subtitleContent.value = '';
|
||||||
|
plPlayerController.subtitles.value = [];
|
||||||
|
}
|
||||||
|
|
||||||
/// 发送弹幕
|
/// 发送弹幕
|
||||||
void showShootDanmakuSheet() {
|
void showShootDanmakuSheet() {
|
||||||
final TextEditingController textController = TextEditingController();
|
final TextEditingController textController = TextEditingController();
|
||||||
|
|||||||
@ -18,6 +18,9 @@ import 'package:pilipala/utils/id_utils.dart';
|
|||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
|
import '../../../../common/pages_bottom_sheet.dart';
|
||||||
|
import '../../../../models/common/video_episode_type.dart';
|
||||||
|
import '../../../../utils/drawer.dart';
|
||||||
import '../related/index.dart';
|
import '../related/index.dart';
|
||||||
import 'widgets/group_panel.dart';
|
import 'widgets/group_panel.dart';
|
||||||
|
|
||||||
@ -25,15 +28,10 @@ class VideoIntroController extends GetxController {
|
|||||||
VideoIntroController({required this.bvid});
|
VideoIntroController({required this.bvid});
|
||||||
// 视频bvid
|
// 视频bvid
|
||||||
String bvid;
|
String bvid;
|
||||||
// 请求状态
|
|
||||||
RxBool isLoading = false.obs;
|
|
||||||
|
|
||||||
// 视频详情 请求返回
|
// 视频详情 请求返回
|
||||||
Rx<VideoDetailData> videoDetail = VideoDetailData().obs;
|
Rx<VideoDetailData> videoDetail = VideoDetailData().obs;
|
||||||
|
|
||||||
// up主粉丝数
|
// up主粉丝数
|
||||||
Map userStat = {'follower': '-'};
|
Map userStat = {'follower': '-'};
|
||||||
|
|
||||||
// 是否点赞
|
// 是否点赞
|
||||||
RxBool hasLike = false.obs;
|
RxBool hasLike = false.obs;
|
||||||
// 是否投币
|
// 是否投币
|
||||||
@ -59,6 +57,7 @@ class VideoIntroController extends GetxController {
|
|||||||
bool isPaused = false;
|
bool isPaused = false;
|
||||||
String heroTag = '';
|
String heroTag = '';
|
||||||
late ModelResult modelResult;
|
late ModelResult modelResult;
|
||||||
|
PersistentBottomSheetController? bottomSheetController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -562,4 +561,52 @@ class VideoIntroController extends GetxController {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hiddenEpisodeBottomSheet() {
|
||||||
|
bottomSheetController?.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 播放器底栏 选集 回调
|
||||||
|
void showEposideHandler() {
|
||||||
|
late List episodes;
|
||||||
|
VideoEpidoesType dataType = VideoEpidoesType.videoEpisode;
|
||||||
|
if (videoDetail.value.ugcSeason != null) {
|
||||||
|
dataType = VideoEpidoesType.videoEpisode;
|
||||||
|
final List<SectionItem> sections = videoDetail.value.ugcSeason!.sections!;
|
||||||
|
for (int i = 0; i < sections.length; i++) {
|
||||||
|
final List<EpisodeItem> episodesList = sections[i].episodes!;
|
||||||
|
for (int j = 0; j < episodesList.length; j++) {
|
||||||
|
if (episodesList[j].cid == lastPlayCid.value) {
|
||||||
|
episodes = episodesList;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (videoDetail.value.pages != null &&
|
||||||
|
videoDetail.value.pages!.length > 1) {
|
||||||
|
dataType = VideoEpidoesType.videoPart;
|
||||||
|
episodes = videoDetail.value.pages!;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawerUtils.showRightDialog(
|
||||||
|
child: EpisodeBottomSheet(
|
||||||
|
episodes: episodes,
|
||||||
|
currentCid: lastPlayCid.value,
|
||||||
|
dataType: dataType,
|
||||||
|
context: Get.context!,
|
||||||
|
sheetHeight: Get.size.height,
|
||||||
|
isFullScreen: true,
|
||||||
|
changeFucCall: (item, index) {
|
||||||
|
if (dataType == VideoEpidoesType.videoEpisode) {
|
||||||
|
changeSeasonOrbangu(IdUtils.av2bv(item.aid), item.cid, item.aid);
|
||||||
|
}
|
||||||
|
if (dataType == VideoEpidoesType.videoPart) {
|
||||||
|
changeSeasonOrbangu(bvid, item.cid, null);
|
||||||
|
}
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
},
|
||||||
|
).buildShowContent(Get.context!),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,8 +20,8 @@ import '../../../../http/user.dart';
|
|||||||
import 'widgets/action_item.dart';
|
import 'widgets/action_item.dart';
|
||||||
import 'widgets/fav_panel.dart';
|
import 'widgets/fav_panel.dart';
|
||||||
import 'widgets/intro_detail.dart';
|
import 'widgets/intro_detail.dart';
|
||||||
import 'widgets/page.dart';
|
import 'widgets/page_panel.dart';
|
||||||
import 'widgets/season.dart';
|
import 'widgets/season_panel.dart';
|
||||||
|
|
||||||
class VideoIntroPanel extends StatefulWidget {
|
class VideoIntroPanel extends StatefulWidget {
|
||||||
final String bvid;
|
final String bvid;
|
||||||
@ -373,7 +373,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
|
|
||||||
/// 点赞收藏转发
|
/// 点赞收藏转发
|
||||||
actionGrid(context, videoIntroController),
|
actionGrid(context, videoIntroController),
|
||||||
// 合集
|
// 合集 videoPart 简洁
|
||||||
if (widget.videoDetail!.ugcSeason != null) ...[
|
if (widget.videoDetail!.ugcSeason != null) ...[
|
||||||
Obx(
|
Obx(
|
||||||
() => SeasonPanel(
|
() => SeasonPanel(
|
||||||
@ -383,19 +383,31 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
: widget.videoDetail!.pages!.first.cid,
|
: widget.videoDetail!.pages!.first.cid,
|
||||||
sheetHeight: sheetHeight,
|
sheetHeight: sheetHeight,
|
||||||
changeFuc: (bvid, cid, aid) =>
|
changeFuc: (bvid, cid, aid) =>
|
||||||
videoIntroController.changeSeasonOrbangu(bvid, cid, aid),
|
videoIntroController.changeSeasonOrbangu(
|
||||||
|
bvid,
|
||||||
|
cid,
|
||||||
|
aid,
|
||||||
|
),
|
||||||
|
videoIntroCtr: videoIntroController,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
// 合集 videoEpisode
|
||||||
if (widget.videoDetail!.pages != null &&
|
if (widget.videoDetail!.pages != null &&
|
||||||
widget.videoDetail!.pages!.length > 1) ...[
|
widget.videoDetail!.pages!.length > 1) ...[
|
||||||
Obx(() => PagesPanel(
|
Obx(
|
||||||
pages: widget.videoDetail!.pages!,
|
() => PagesPanel(
|
||||||
cid: videoIntroController.lastPlayCid.value,
|
pages: widget.videoDetail!.pages!,
|
||||||
sheetHeight: sheetHeight,
|
cid: videoIntroController.lastPlayCid.value,
|
||||||
changeFuc: (cid) => videoIntroController.changeSeasonOrbangu(
|
sheetHeight: sheetHeight,
|
||||||
videoIntroController.bvid, cid, null),
|
changeFuc: (cid) => videoIntroController.changeSeasonOrbangu(
|
||||||
))
|
videoIntroController.bvid,
|
||||||
|
cid,
|
||||||
|
null,
|
||||||
|
),
|
||||||
|
videoIntroCtr: videoIntroController,
|
||||||
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: onPushMember,
|
onTap: onPushMember,
|
||||||
|
|||||||
@ -1,258 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:pilipala/models/video_detail_res.dart';
|
|
||||||
import 'package:pilipala/pages/video/detail/index.dart';
|
|
||||||
|
|
||||||
class PagesPanel extends StatefulWidget {
|
|
||||||
const PagesPanel({
|
|
||||||
super.key,
|
|
||||||
required this.pages,
|
|
||||||
this.cid,
|
|
||||||
this.sheetHeight,
|
|
||||||
this.changeFuc,
|
|
||||||
});
|
|
||||||
final List<Part> pages;
|
|
||||||
final int? cid;
|
|
||||||
final double? sheetHeight;
|
|
||||||
final Function? changeFuc;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<PagesPanel> createState() => _PagesPanelState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _PagesPanelState extends State<PagesPanel> {
|
|
||||||
late List<Part> episodes;
|
|
||||||
late int cid;
|
|
||||||
late int currentIndex;
|
|
||||||
final String heroTag = Get.arguments['heroTag'];
|
|
||||||
late VideoDetailController _videoDetailController;
|
|
||||||
final ScrollController _scrollController = ScrollController();
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
cid = widget.cid!;
|
|
||||||
episodes = widget.pages;
|
|
||||||
_videoDetailController = Get.find<VideoDetailController>(tag: heroTag);
|
|
||||||
currentIndex = episodes.indexWhere((Part e) => e.cid == cid);
|
|
||||||
_videoDetailController.cid.listen((int p0) {
|
|
||||||
cid = p0;
|
|
||||||
setState(() {});
|
|
||||||
currentIndex = episodes.indexWhere((Part e) => e.cid == cid);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void changeFucCall(item, i) async {
|
|
||||||
await widget.changeFuc!(
|
|
||||||
item.cid,
|
|
||||||
);
|
|
||||||
currentIndex = i;
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_scrollController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget buildEpisodeListItem(
|
|
||||||
Part episode,
|
|
||||||
int index,
|
|
||||||
bool isCurrentIndex,
|
|
||||||
) {
|
|
||||||
Color primary = Theme.of(context).colorScheme.primary;
|
|
||||||
return ListTile(
|
|
||||||
onTap: () {
|
|
||||||
changeFucCall(episode, index);
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
dense: false,
|
|
||||||
leading: isCurrentIndex
|
|
||||||
? Image.asset(
|
|
||||||
'assets/images/live.gif',
|
|
||||||
color: primary,
|
|
||||||
height: 12,
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
title: Text(
|
|
||||||
episode.pagePart!,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: isCurrentIndex
|
|
||||||
? primary
|
|
||||||
: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Column(
|
|
||||||
children: <Widget>[
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 10, bottom: 2),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
const Text('视频选集 '),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
' 正在播放:${widget.pages[currentIndex].pagePart}',
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: Theme.of(context).colorScheme.outline,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
SizedBox(
|
|
||||||
height: 34,
|
|
||||||
child: TextButton(
|
|
||||||
style: ButtonStyle(
|
|
||||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
showBottomSheet(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return StatefulBuilder(builder:
|
|
||||||
(BuildContext context, StateSetter setState) {
|
|
||||||
WidgetsBinding.instance
|
|
||||||
.addPostFrameCallback((_) async {
|
|
||||||
await Future.delayed(
|
|
||||||
const Duration(milliseconds: 200));
|
|
||||||
_scrollController.jumpTo(currentIndex * 56);
|
|
||||||
});
|
|
||||||
return Container(
|
|
||||||
height: widget.sheetHeight,
|
|
||||||
color: Theme.of(context).colorScheme.background,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
height: 45,
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
left: 14, right: 14),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'合集(${episodes.length})',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.titleMedium,
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.close),
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Divider(
|
|
||||||
height: 1,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.dividerColor
|
|
||||||
.withOpacity(0.1),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Material(
|
|
||||||
child: ListView.builder(
|
|
||||||
controller: _scrollController,
|
|
||||||
itemCount: episodes.length + 1,
|
|
||||||
itemBuilder:
|
|
||||||
(BuildContext context, int index) {
|
|
||||||
bool isLastItem =
|
|
||||||
index == episodes.length;
|
|
||||||
bool isCurrentIndex =
|
|
||||||
currentIndex == index;
|
|
||||||
return isLastItem
|
|
||||||
? SizedBox(
|
|
||||||
height: MediaQuery.of(context)
|
|
||||||
.padding
|
|
||||||
.bottom +
|
|
||||||
20,
|
|
||||||
)
|
|
||||||
: buildEpisodeListItem(
|
|
||||||
episodes[index],
|
|
||||||
index,
|
|
||||||
isCurrentIndex,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'共${widget.pages.length}集',
|
|
||||||
style: const TextStyle(fontSize: 13),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
height: 35,
|
|
||||||
margin: const EdgeInsets.only(bottom: 8),
|
|
||||||
child: ListView.builder(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
itemCount: widget.pages.length,
|
|
||||||
itemExtent: 150,
|
|
||||||
itemBuilder: (BuildContext context, int i) {
|
|
||||||
bool isCurrentIndex = currentIndex == i;
|
|
||||||
return Container(
|
|
||||||
width: 150,
|
|
||||||
margin: const EdgeInsets.only(right: 10),
|
|
||||||
child: Material(
|
|
||||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
|
||||||
borderRadius: BorderRadius.circular(6),
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () => changeFucCall(widget.pages[i], i),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 8, horizontal: 8),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
if (isCurrentIndex) ...<Widget>[
|
|
||||||
Image.asset(
|
|
||||||
'assets/images/live.gif',
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
height: 12,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 6)
|
|
||||||
],
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
widget.pages[i].pagePart!,
|
|
||||||
maxLines: 1,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: isCurrentIndex
|
|
||||||
? Theme.of(context).colorScheme.primary
|
|
||||||
: Theme.of(context).colorScheme.onSurface),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
185
lib/pages/video/detail/introduction/widgets/page_panel.dart
Normal file
185
lib/pages/video/detail/introduction/widgets/page_panel.dart
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pilipala/models/video_detail_res.dart';
|
||||||
|
import 'package:pilipala/pages/video/detail/index.dart';
|
||||||
|
import 'package:pilipala/pages/video/detail/introduction/index.dart';
|
||||||
|
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||||
|
import '../../../../../common/pages_bottom_sheet.dart';
|
||||||
|
import '../../../../../models/common/video_episode_type.dart';
|
||||||
|
|
||||||
|
class PagesPanel extends StatefulWidget {
|
||||||
|
const PagesPanel({
|
||||||
|
super.key,
|
||||||
|
required this.pages,
|
||||||
|
required this.cid,
|
||||||
|
this.sheetHeight,
|
||||||
|
this.changeFuc,
|
||||||
|
required this.videoIntroCtr,
|
||||||
|
});
|
||||||
|
final List<Part> pages;
|
||||||
|
final int cid;
|
||||||
|
final double? sheetHeight;
|
||||||
|
final Function? changeFuc;
|
||||||
|
final VideoIntroController videoIntroCtr;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<PagesPanel> createState() => _PagesPanelState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PagesPanelState extends State<PagesPanel> {
|
||||||
|
late List<Part> episodes;
|
||||||
|
late int cid;
|
||||||
|
late RxInt currentIndex = (-1).obs;
|
||||||
|
final String heroTag = Get.arguments['heroTag'];
|
||||||
|
late VideoDetailController _videoDetailController;
|
||||||
|
final ScrollController listViewScrollCtr = ScrollController();
|
||||||
|
final ItemScrollController itemScrollController = ItemScrollController();
|
||||||
|
late PersistentBottomSheetController? _bottomSheetController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
cid = widget.cid;
|
||||||
|
episodes = widget.pages;
|
||||||
|
_videoDetailController = Get.find<VideoDetailController>(tag: heroTag);
|
||||||
|
currentIndex.value = episodes.indexWhere((Part e) => e.cid == cid);
|
||||||
|
scrollToIndex();
|
||||||
|
_videoDetailController.cid.listen((int p0) {
|
||||||
|
cid = p0;
|
||||||
|
currentIndex.value = episodes.indexWhere((Part e) => e.cid == cid);
|
||||||
|
scrollToIndex();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
listViewScrollCtr.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void changeFucCall(item, i) async {
|
||||||
|
print('pages changeFucCall');
|
||||||
|
widget.changeFuc?.call(item.cid);
|
||||||
|
currentIndex.value = i;
|
||||||
|
_bottomSheetController?.close();
|
||||||
|
scrollToIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
void scrollToIndex() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
// 在回调函数中获取更新后的状态
|
||||||
|
final double offset = min((currentIndex * 150) - 75,
|
||||||
|
listViewScrollCtr.position.maxScrollExtent);
|
||||||
|
listViewScrollCtr.animateTo(
|
||||||
|
offset,
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 10, bottom: 2),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Text('视频选集 '),
|
||||||
|
Expanded(
|
||||||
|
child: Obx(() => Text(
|
||||||
|
' 正在播放:${widget.pages[currentIndex.value].pagePart}',
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
SizedBox(
|
||||||
|
height: 34,
|
||||||
|
child: TextButton(
|
||||||
|
style: ButtonStyle(
|
||||||
|
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
widget.videoIntroCtr.bottomSheetController =
|
||||||
|
_bottomSheetController = EpisodeBottomSheet(
|
||||||
|
currentCid: cid,
|
||||||
|
episodes: episodes,
|
||||||
|
changeFucCall: changeFucCall,
|
||||||
|
sheetHeight: widget.sheetHeight,
|
||||||
|
dataType: VideoEpidoesType.videoPart,
|
||||||
|
context: context,
|
||||||
|
).show(context);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'共${widget.pages.length}集',
|
||||||
|
style: const TextStyle(fontSize: 13),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: 35,
|
||||||
|
margin: const EdgeInsets.only(bottom: 8),
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
controller: listViewScrollCtr,
|
||||||
|
itemCount: widget.pages.length,
|
||||||
|
itemExtent: 150,
|
||||||
|
itemBuilder: (BuildContext context, int i) {
|
||||||
|
bool isCurrentIndex = currentIndex.value == i;
|
||||||
|
return Container(
|
||||||
|
width: 150,
|
||||||
|
margin: const EdgeInsets.only(right: 10),
|
||||||
|
child: Material(
|
||||||
|
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () => changeFucCall(widget.pages[i], i),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 8, horizontal: 8),
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
if (isCurrentIndex) ...<Widget>[
|
||||||
|
Image.asset(
|
||||||
|
'assets/images/live.gif',
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6)
|
||||||
|
],
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
widget.pages[i].pagePart!,
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: isCurrentIndex
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Theme.of(context).colorScheme.onSurface),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,9 +1,12 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pilipala/common/pages_bottom_sheet.dart';
|
||||||
import 'package:pilipala/models/video_detail_res.dart';
|
import 'package:pilipala/models/video_detail_res.dart';
|
||||||
import 'package:pilipala/pages/video/detail/index.dart';
|
import 'package:pilipala/pages/video/detail/index.dart';
|
||||||
import 'package:pilipala/utils/id_utils.dart';
|
import 'package:pilipala/utils/id_utils.dart';
|
||||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
||||||
|
import '../../../../../models/common/video_episode_type.dart';
|
||||||
|
import '../controller.dart';
|
||||||
|
|
||||||
class SeasonPanel extends StatefulWidget {
|
class SeasonPanel extends StatefulWidget {
|
||||||
const SeasonPanel({
|
const SeasonPanel({
|
||||||
@ -12,11 +15,13 @@ class SeasonPanel extends StatefulWidget {
|
|||||||
this.cid,
|
this.cid,
|
||||||
this.sheetHeight,
|
this.sheetHeight,
|
||||||
this.changeFuc,
|
this.changeFuc,
|
||||||
|
required this.videoIntroCtr,
|
||||||
});
|
});
|
||||||
final UgcSeason ugcSeason;
|
final UgcSeason ugcSeason;
|
||||||
final int? cid;
|
final int? cid;
|
||||||
final double? sheetHeight;
|
final double? sheetHeight;
|
||||||
final Function? changeFuc;
|
final Function? changeFuc;
|
||||||
|
final VideoIntroController videoIntroCtr;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SeasonPanel> createState() => _SeasonPanelState();
|
State<SeasonPanel> createState() => _SeasonPanelState();
|
||||||
@ -25,11 +30,11 @@ class SeasonPanel extends StatefulWidget {
|
|||||||
class _SeasonPanelState extends State<SeasonPanel> {
|
class _SeasonPanelState extends State<SeasonPanel> {
|
||||||
late List<EpisodeItem> episodes;
|
late List<EpisodeItem> episodes;
|
||||||
late int cid;
|
late int cid;
|
||||||
late int currentIndex;
|
late RxInt currentIndex = (-1).obs;
|
||||||
final String heroTag = Get.arguments['heroTag'];
|
final String heroTag = Get.arguments['heroTag'];
|
||||||
late VideoDetailController _videoDetailController;
|
late VideoDetailController _videoDetailController;
|
||||||
final ScrollController _scrollController = ScrollController();
|
|
||||||
final ItemScrollController itemScrollController = ItemScrollController();
|
final ItemScrollController itemScrollController = ItemScrollController();
|
||||||
|
late PersistentBottomSheetController? _bottomSheetController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -52,32 +57,21 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 取对应 season_id 的 episodes
|
/// 取对应 season_id 的 episodes
|
||||||
// episodes = widget.ugcSeason.sections!
|
currentIndex.value = episodes.indexWhere((EpisodeItem e) => e.cid == cid);
|
||||||
// .firstWhere((e) => e.seasonId == widget.ugcSeason.id)
|
|
||||||
// .episodes!;
|
|
||||||
currentIndex = episodes.indexWhere((EpisodeItem e) => e.cid == cid);
|
|
||||||
_videoDetailController.cid.listen((int p0) {
|
_videoDetailController.cid.listen((int p0) {
|
||||||
cid = p0;
|
cid = p0;
|
||||||
setState(() {});
|
currentIndex.value = episodes.indexWhere((EpisodeItem e) => e.cid == cid);
|
||||||
currentIndex = episodes.indexWhere((EpisodeItem e) => e.cid == cid);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeFucCall(item, int i) async {
|
void changeFucCall(item, int i) async {
|
||||||
await widget.changeFuc!(
|
widget.changeFuc?.call(
|
||||||
IdUtils.av2bv(item.aid),
|
IdUtils.av2bv(item.aid),
|
||||||
item.cid,
|
item.cid,
|
||||||
item.aid,
|
item.aid,
|
||||||
);
|
);
|
||||||
currentIndex = i;
|
currentIndex.value = i;
|
||||||
Get.back();
|
_bottomSheetController?.close();
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_scrollController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildEpisodeListItem(
|
Widget buildEpisodeListItem(
|
||||||
@ -123,71 +117,17 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
|||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => showBottomSheet(
|
onTap: () {
|
||||||
context: context,
|
widget.videoIntroCtr.bottomSheetController =
|
||||||
builder: (BuildContext context) {
|
_bottomSheetController = EpisodeBottomSheet(
|
||||||
return StatefulBuilder(
|
currentCid: cid,
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
episodes: episodes,
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
changeFucCall: changeFucCall,
|
||||||
itemScrollController.jumpTo(index: currentIndex);
|
sheetHeight: widget.sheetHeight,
|
||||||
});
|
dataType: VideoEpidoesType.videoEpisode,
|
||||||
return Container(
|
context: context,
|
||||||
height: widget.sheetHeight,
|
).show(context);
|
||||||
color: Theme.of(context).colorScheme.background,
|
},
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
height: 45,
|
|
||||||
padding: const EdgeInsets.only(left: 14, right: 14),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'合集(${episodes.length})',
|
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.close),
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Divider(
|
|
||||||
height: 1,
|
|
||||||
color:
|
|
||||||
Theme.of(context).dividerColor.withOpacity(0.1),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Material(
|
|
||||||
child: ScrollablePositionedList.builder(
|
|
||||||
itemCount: episodes.length + 1,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
bool isLastItem = index == episodes.length;
|
|
||||||
bool isCurrentIndex = currentIndex == index;
|
|
||||||
return isLastItem
|
|
||||||
? SizedBox(
|
|
||||||
height: MediaQuery.of(context)
|
|
||||||
.padding
|
|
||||||
.bottom +
|
|
||||||
20,
|
|
||||||
)
|
|
||||||
: buildEpisodeListItem(
|
|
||||||
episodes[index],
|
|
||||||
index,
|
|
||||||
isCurrentIndex,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemScrollController: itemScrollController,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),
|
padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -206,10 +146,10 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
|||||||
height: 12,
|
height: 12,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Text(
|
Obx(() => Text(
|
||||||
'${currentIndex + 1}/${episodes.length}',
|
'${currentIndex.value + 1}/${episodes.length}',
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
style: Theme.of(context).textTheme.labelMedium,
|
||||||
),
|
)),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
const Icon(
|
const Icon(
|
||||||
Icons.arrow_forward_ios_outlined,
|
Icons.arrow_forward_ios_outlined,
|
||||||
@ -148,34 +148,16 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
floating: true,
|
floating: true,
|
||||||
delegate: _MySliverPersistentHeaderDelegate(
|
delegate: _MySliverPersistentHeaderDelegate(
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 45,
|
height: 40,
|
||||||
padding: const EdgeInsets.fromLTRB(12, 0, 6, 0),
|
padding: const EdgeInsets.fromLTRB(12, 0, 6, 0),
|
||||||
decoration: BoxDecoration(
|
color: Theme.of(context).colorScheme.surface,
|
||||||
color: Theme.of(context).colorScheme.background,
|
|
||||||
border: Border(
|
|
||||||
bottom: BorderSide(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.outline
|
|
||||||
.withOpacity(0.1)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Obx(
|
Obx(
|
||||||
() => AnimatedSwitcher(
|
() => Text(
|
||||||
duration: const Duration(milliseconds: 400),
|
'${_videoReplyController.sortTypeLabel.value}评论',
|
||||||
transitionBuilder:
|
style: const TextStyle(fontSize: 13),
|
||||||
(Widget child, Animation<double> animation) {
|
|
||||||
return ScaleTransition(
|
|
||||||
scale: animation, child: child);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'共${_videoReplyController.count.value}条回复',
|
|
||||||
key: ValueKey<int>(
|
|
||||||
_videoReplyController.count.value),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@ -184,10 +166,12 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
_videoReplyController.queryBySort(),
|
_videoReplyController.queryBySort(),
|
||||||
icon: const Icon(Icons.sort, size: 16),
|
icon: const Icon(Icons.sort, size: 16),
|
||||||
label: Obx(() => Text(
|
label: Obx(
|
||||||
_videoReplyController.sortTypeLabel.value,
|
() => Text(
|
||||||
style: const TextStyle(fontSize: 13),
|
_videoReplyController.sortTypeLabel.value,
|
||||||
)),
|
style: const TextStyle(fontSize: 13),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -329,8 +313,8 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
|
|
||||||
class _MySliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
|
class _MySliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
|
||||||
_MySliverPersistentHeaderDelegate({required this.child});
|
_MySliverPersistentHeaderDelegate({required this.child});
|
||||||
final double _minExtent = 45;
|
final double _minExtent = 40;
|
||||||
final double _maxExtent = 45;
|
final double _maxExtent = 40;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -498,7 +498,7 @@ InlineSpan buildContent(
|
|||||||
return str;
|
return str;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// content.message = content.message.replaceAll(RegExp(r"\{vote:.*?\}"), ' ');
|
content.message = content.message.replaceAll(RegExp(r"\{vote:.*?\}"), ' ');
|
||||||
content.message = content.message
|
content.message = content.message
|
||||||
.replaceAll('&', '&')
|
.replaceAll('&', '&')
|
||||||
.replaceAll('<', '<')
|
.replaceAll('<', '<')
|
||||||
@ -525,14 +525,18 @@ InlineSpan buildContent(
|
|||||||
if (jumpUrlKeysList.isNotEmpty) {
|
if (jumpUrlKeysList.isNotEmpty) {
|
||||||
patternStr += '|${jumpUrlKeysList.join('|')}';
|
patternStr += '|${jumpUrlKeysList.join('|')}';
|
||||||
}
|
}
|
||||||
|
RegExp bv23Regex = RegExp(r'https://b23\.tv/[a-zA-Z0-9]{7}');
|
||||||
final RegExp pattern = RegExp(patternStr);
|
final RegExp pattern = RegExp(patternStr);
|
||||||
List<String> matchedStrs = [];
|
List<String> matchedStrs = [];
|
||||||
void addPlainTextSpan(str) {
|
void addPlainTextSpan(str) {
|
||||||
spanChilds.add(TextSpan(
|
spanChilds.add(
|
||||||
|
TextSpan(
|
||||||
text: str,
|
text: str,
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () =>
|
..onTap = () =>
|
||||||
replyReply?.call(replyItem.root == 0 ? replyItem : fReplyItem)));
|
replyReply?.call(replyItem.root == 0 ? replyItem : fReplyItem),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分割文本并处理每个部分
|
// 分割文本并处理每个部分
|
||||||
@ -734,8 +738,36 @@ InlineSpan buildContent(
|
|||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
onNonMatch: (String nonMatchStr) {
|
onNonMatch: (String nonMatchStr) {
|
||||||
addPlainTextSpan(nonMatchStr);
|
return nonMatchStr.splitMapJoin(
|
||||||
return nonMatchStr;
|
bv23Regex,
|
||||||
|
onMatch: (Match match) {
|
||||||
|
String matchStr = match[0]!;
|
||||||
|
spanChilds.add(
|
||||||
|
TextSpan(
|
||||||
|
text: ' $matchStr ',
|
||||||
|
style: isVideoPage
|
||||||
|
? TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () => Get.toNamed(
|
||||||
|
'/webview',
|
||||||
|
parameters: {
|
||||||
|
'url': matchStr,
|
||||||
|
'type': 'url',
|
||||||
|
'pageTitle': matchStr
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
onNonMatch: (String nonMatchOtherStr) {
|
||||||
|
addPlainTextSpan(nonMatchOtherStr);
|
||||||
|
return nonMatchOtherStr;
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -142,9 +142,10 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
double keyboardHeight = EdgeInsets.fromViewPadding(
|
double _keyboardHeight = EdgeInsets.fromViewPadding(
|
||||||
View.of(context).viewInsets, View.of(context).devicePixelRatio)
|
View.of(context).viewInsets, View.of(context).devicePixelRatio)
|
||||||
.bottom;
|
.bottom;
|
||||||
|
print('_keyboardHeight: $_keyboardHeight');
|
||||||
return Container(
|
return Container(
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -235,7 +236,11 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
|
|||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: toolbarType == 'input' ? keyboardHeight : emoteHeight,
|
height: toolbarType == 'input'
|
||||||
|
? (_keyboardHeight > keyboardHeight
|
||||||
|
? _keyboardHeight
|
||||||
|
: keyboardHeight)
|
||||||
|
: emoteHeight,
|
||||||
child: EmotePanel(
|
child: EmotePanel(
|
||||||
onChoose: (package, emote) => onChooseEmote(package, emote),
|
onChoose: (package, emote) => onChooseEmote(package, emote),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -140,8 +140,8 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
future: _futureBuilderFuture,
|
future: _futureBuilderFuture,
|
||||||
builder: (BuildContext context, snapshot) {
|
builder: (BuildContext context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
final Map data = snapshot.data as Map;
|
Map? data = snapshot.data;
|
||||||
if (data['status']) {
|
if (data != null && data['status']) {
|
||||||
// 请求成功
|
// 请求成功
|
||||||
return Obx(
|
return Obx(
|
||||||
() => SliverList(
|
() => SliverList(
|
||||||
@ -199,7 +199,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
|||||||
} else {
|
} else {
|
||||||
// 请求错误
|
// 请求错误
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data?['msg'] ?? '请求错误',
|
||||||
fn: () => setState(() {}),
|
fn: () => setState(() {}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
|
|||||||
import 'package:pilipala/services/service_locator.dart';
|
import 'package:pilipala/services/service_locator.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
|
import '../../../plugin/pl_player/models/bottom_control_type.dart';
|
||||||
import '../../../services/shutdown_timer_service.dart';
|
import '../../../services/shutdown_timer_service.dart';
|
||||||
import 'widgets/app_bar.dart';
|
import 'widgets/app_bar.dart';
|
||||||
|
|
||||||
@ -176,6 +177,16 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
plPlayerController?.isFullScreen.listen((bool isFullScreen) {
|
plPlayerController?.isFullScreen.listen((bool isFullScreen) {
|
||||||
if (isFullScreen) {
|
if (isFullScreen) {
|
||||||
vdCtr.hiddenReplyReplyPanel();
|
vdCtr.hiddenReplyReplyPanel();
|
||||||
|
videoIntroController.hiddenEpisodeBottomSheet();
|
||||||
|
if (videoIntroController.videoDetail.value.ugcSeason != null ||
|
||||||
|
(videoIntroController.videoDetail.value.pages != null &&
|
||||||
|
videoIntroController.videoDetail.value.pages!.length > 1)) {
|
||||||
|
vdCtr.bottomList.insert(3, BottomControlType.episode);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (vdCtr.bottomList.contains(BottomControlType.episode)) {
|
||||||
|
vdCtr.bottomList.removeAt(3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -212,6 +223,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
videoIntroController.isPaused = true;
|
videoIntroController.isPaused = true;
|
||||||
plPlayerController!.removeStatusLister(playerListener);
|
plPlayerController!.removeStatusLister(playerListener);
|
||||||
plPlayerController!.pause();
|
plPlayerController!.pause();
|
||||||
|
vdCtr.clearSubtitleContent();
|
||||||
}
|
}
|
||||||
setState(() => isShowing = false);
|
setState(() => isShowing = false);
|
||||||
super.didPushNext();
|
super.didPushNext();
|
||||||
@ -222,7 +234,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
void didPopNext() async {
|
void didPopNext() async {
|
||||||
if (plPlayerController != null &&
|
if (plPlayerController != null &&
|
||||||
plPlayerController!.videoPlayerController != null) {
|
plPlayerController!.videoPlayerController != null) {
|
||||||
setState(() => isShowing = true);
|
setState(() {
|
||||||
|
vdCtr.setSubtitleContent();
|
||||||
|
isShowing = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
vdCtr.isFirstTime = false;
|
vdCtr.isFirstTime = false;
|
||||||
final bool autoplay = autoPlayEnable;
|
final bool autoplay = autoPlayEnable;
|
||||||
@ -288,15 +303,19 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
() {
|
() {
|
||||||
return !vdCtr.autoPlay.value
|
return !vdCtr.autoPlay.value
|
||||||
? const SizedBox()
|
? const SizedBox()
|
||||||
: PLVideoPlayer(
|
: Obx(
|
||||||
controller: plPlayerController!,
|
() => PLVideoPlayer(
|
||||||
headerControl: vdCtr.headerControl,
|
controller: plPlayerController!,
|
||||||
danmuWidget: Obx(
|
headerControl: vdCtr.headerControl,
|
||||||
() => PlDanmaku(
|
danmuWidget: PlDanmaku(
|
||||||
key: Key(vdCtr.danmakuCid.value.toString()),
|
key: Key(vdCtr.danmakuCid.value.toString()),
|
||||||
cid: vdCtr.danmakuCid.value,
|
cid: vdCtr.danmakuCid.value,
|
||||||
playerController: plPlayerController!,
|
playerController: plPlayerController!,
|
||||||
),
|
),
|
||||||
|
bottomList: vdCtr.bottomList,
|
||||||
|
showEposideCb: () => vdCtr.videoType == SearchType.video
|
||||||
|
? videoIntroController.showEposideHandler()
|
||||||
|
: bangumiIntroController.showEposideHandler(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -599,7 +618,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
/// 重新进入会刷新
|
/// 重新进入会刷新
|
||||||
// 播放完成/暂停播放
|
// 播放完成/暂停播放
|
||||||
StreamBuilder(
|
StreamBuilder(
|
||||||
stream: appbarStream.stream,
|
stream: appbarStream.stream.distinct(),
|
||||||
initialData: 0,
|
initialData: 0,
|
||||||
builder: ((context, snapshot) {
|
builder: ((context, snapshot) {
|
||||||
return ScrollAppBar(
|
return ScrollAppBar(
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import 'package:ns_danmaku/ns_danmaku.dart';
|
|||||||
import 'package:pilipala/http/user.dart';
|
import 'package:pilipala/http/user.dart';
|
||||||
import 'package:pilipala/models/video/play/quality.dart';
|
import 'package:pilipala/models/video/play/quality.dart';
|
||||||
import 'package:pilipala/models/video/play/url.dart';
|
import 'package:pilipala/models/video/play/url.dart';
|
||||||
|
import 'package:pilipala/pages/dlna/index.dart';
|
||||||
import 'package:pilipala/pages/video/detail/index.dart';
|
import 'package:pilipala/pages/video/detail/index.dart';
|
||||||
import 'package:pilipala/pages/video/detail/introduction/widgets/menu_row.dart';
|
import 'package:pilipala/pages/video/detail/introduction/widgets/menu_row.dart';
|
||||||
import 'package:pilipala/plugin/pl_player/index.dart';
|
import 'package:pilipala/plugin/pl_player/index.dart';
|
||||||
@ -158,7 +159,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
dense: true,
|
dense: true,
|
||||||
leading:
|
leading:
|
||||||
const Icon(Icons.hourglass_top_outlined, size: 20),
|
const Icon(Icons.hourglass_top_outlined, size: 20),
|
||||||
title: const Text('定时关闭(测试)', style: titleStyle),
|
title: const Text('定时关闭', style: titleStyle),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
onTap: () => {Get.back(), showSetVideoQa()},
|
onTap: () => {Get.back(), showSetVideoQa()},
|
||||||
@ -421,6 +422,56 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 选择字幕
|
||||||
|
void showSubtitleDialog() async {
|
||||||
|
int tempThemeValue = widget.controller!.subTitleCode.value;
|
||||||
|
int len = widget.videoDetailCtr!.subtitles.length;
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('选择字幕'),
|
||||||
|
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 18),
|
||||||
|
content: StatefulBuilder(builder: (context, StateSetter setState) {
|
||||||
|
return len == 0
|
||||||
|
? const SizedBox(
|
||||||
|
height: 60,
|
||||||
|
child: Center(
|
||||||
|
child: Text('没有字幕'),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
RadioListTile(
|
||||||
|
value: -1,
|
||||||
|
title: const Text('关闭弹幕'),
|
||||||
|
groupValue: tempThemeValue,
|
||||||
|
onChanged: (value) {
|
||||||
|
tempThemeValue = value!;
|
||||||
|
widget.controller?.toggleSubtitle(value);
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
...widget.videoDetailCtr!.subtitles
|
||||||
|
.map((e) => RadioListTile(
|
||||||
|
value: e.code,
|
||||||
|
title: Text(e.title),
|
||||||
|
groupValue: tempThemeValue,
|
||||||
|
onChanged: (value) {
|
||||||
|
tempThemeValue = value!;
|
||||||
|
widget.controller?.toggleSubtitle(value);
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// 选择倍速
|
/// 选择倍速
|
||||||
void showSetSpeedSheet() {
|
void showSetSpeedSheet() {
|
||||||
final double currentSpeed = widget.controller!.playbackSpeed;
|
final double currentSpeed = widget.controller!.playbackSpeed;
|
||||||
@ -680,9 +731,12 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
margin: const EdgeInsets.all(12),
|
margin: const EdgeInsets.all(12),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
height: 45,
|
height: 45,
|
||||||
child: Center(child: Text('选择解码格式', style: titleStyle))),
|
child: Center(
|
||||||
|
child: Text('选择解码格式', style: titleStyle),
|
||||||
|
),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Material(
|
child: Material(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
@ -1027,9 +1081,12 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
margin: const EdgeInsets.all(12),
|
margin: const EdgeInsets.all(12),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
height: 45,
|
height: 45,
|
||||||
child: Center(child: Text('选择播放顺序', style: titleStyle))),
|
child: Center(
|
||||||
|
child: Text('选择播放顺序', style: titleStyle),
|
||||||
|
),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Material(
|
child: Material(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
@ -1114,11 +1171,13 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
children: [
|
children: [
|
||||||
ConstrainedBox(
|
ConstrainedBox(
|
||||||
constraints: const BoxConstraints(maxWidth: 200),
|
constraints: const BoxConstraints(maxWidth: 200),
|
||||||
child: Text(
|
child: Obx(
|
||||||
videoIntroController.videoDetail.value.title ?? '',
|
() => Text(
|
||||||
style: const TextStyle(
|
videoIntroController.videoDetail.value.title ?? '',
|
||||||
color: Colors.white,
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
color: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -1158,6 +1217,22 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
// ),
|
// ),
|
||||||
// fuc: () => _.screenshot(),
|
// fuc: () => _.screenshot(),
|
||||||
// ),
|
// ),
|
||||||
|
ComBtn(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.cast,
|
||||||
|
size: 19,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
fuc: () async {
|
||||||
|
showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return LiveDlnaPage(
|
||||||
|
datasource: widget.videoDetailCtr!.videoUrl);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
if (isFullScreen.value) ...[
|
if (isFullScreen.value) ...[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 56,
|
width: 56,
|
||||||
@ -1229,6 +1304,31 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
),
|
),
|
||||||
SizedBox(width: buttonSpace),
|
SizedBox(width: buttonSpace),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
/// 字幕
|
||||||
|
// SizedBox(
|
||||||
|
// width: 34,
|
||||||
|
// height: 34,
|
||||||
|
// child: IconButton(
|
||||||
|
// style: ButtonStyle(
|
||||||
|
// padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
|
// ),
|
||||||
|
// onPressed: () => showSubtitleDialog(),
|
||||||
|
// icon: const Icon(
|
||||||
|
// Icons.closed_caption_off,
|
||||||
|
// size: 22,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
ComBtn(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.closed_caption_off,
|
||||||
|
size: 22,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
fuc: () => showSubtitleDialog(),
|
||||||
|
),
|
||||||
|
SizedBox(width: buttonSpace),
|
||||||
Obx(
|
Obx(
|
||||||
() => SizedBox(
|
() => SizedBox(
|
||||||
width: 45,
|
width: 45,
|
||||||
|
|||||||
19
lib/pages/video/detail/widgets/right_drawer.dart
Normal file
19
lib/pages/video/detail/widgets/right_drawer.dart
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class RightDrawer extends StatefulWidget {
|
||||||
|
const RightDrawer({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RightDrawer> createState() => _RightDrawerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RightDrawerState extends State<RightDrawer> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Drawer(
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
elevation: 0,
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).colorScheme.surface.withOpacity(0.8));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,6 +21,8 @@ import 'package:pilipala/utils/storage.dart';
|
|||||||
import 'package:screen_brightness/screen_brightness.dart';
|
import 'package:screen_brightness/screen_brightness.dart';
|
||||||
import 'package:status_bar_control/status_bar_control.dart';
|
import 'package:status_bar_control/status_bar_control.dart';
|
||||||
import 'package:universal_platform/universal_platform.dart';
|
import 'package:universal_platform/universal_platform.dart';
|
||||||
|
import '../../models/video/subTitile/content.dart';
|
||||||
|
import '../../models/video/subTitile/result.dart';
|
||||||
// import 'package:wakelock_plus/wakelock_plus.dart';
|
// import 'package:wakelock_plus/wakelock_plus.dart';
|
||||||
|
|
||||||
Box videoStorage = GStrorage.video;
|
Box videoStorage = GStrorage.video;
|
||||||
@ -73,6 +75,8 @@ class PlPlayerController {
|
|||||||
final Rx<bool> _doubleSpeedStatus = false.obs;
|
final Rx<bool> _doubleSpeedStatus = false.obs;
|
||||||
final Rx<bool> _controlsLock = false.obs;
|
final Rx<bool> _controlsLock = false.obs;
|
||||||
final Rx<bool> _isFullScreen = false.obs;
|
final Rx<bool> _isFullScreen = false.obs;
|
||||||
|
final Rx<bool> _subTitleOpen = false.obs;
|
||||||
|
final Rx<int> _subTitleCode = (-1).obs;
|
||||||
// 默认投稿视频格式
|
// 默认投稿视频格式
|
||||||
static Rx<String> _videoType = 'archive'.obs;
|
static Rx<String> _videoType = 'archive'.obs;
|
||||||
|
|
||||||
@ -97,7 +101,7 @@ class PlPlayerController {
|
|||||||
bool _isFirstTime = true;
|
bool _isFirstTime = true;
|
||||||
|
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
Timer? _timerForSeek;
|
late Timer? _timerForSeek;
|
||||||
Timer? _timerForVolume;
|
Timer? _timerForVolume;
|
||||||
Timer? _timerForShowingVolume;
|
Timer? _timerForShowingVolume;
|
||||||
Timer? _timerForGettingVolume;
|
Timer? _timerForGettingVolume;
|
||||||
@ -118,6 +122,7 @@ class PlPlayerController {
|
|||||||
PreferredSizeWidget? headerControl;
|
PreferredSizeWidget? headerControl;
|
||||||
PreferredSizeWidget? bottomControl;
|
PreferredSizeWidget? bottomControl;
|
||||||
Widget? danmuWidget;
|
Widget? danmuWidget;
|
||||||
|
late RxList subtitles;
|
||||||
|
|
||||||
/// 数据加载监听
|
/// 数据加载监听
|
||||||
Stream<DataStatus> get onDataStatusChanged => dataStatus.status.stream;
|
Stream<DataStatus> get onDataStatusChanged => dataStatus.status.stream;
|
||||||
@ -147,6 +152,11 @@ class PlPlayerController {
|
|||||||
Rx<bool> get mute => _mute;
|
Rx<bool> get mute => _mute;
|
||||||
Stream<bool> get onMuteChanged => _mute.stream;
|
Stream<bool> get onMuteChanged => _mute.stream;
|
||||||
|
|
||||||
|
/// 字幕开启状态
|
||||||
|
Rx<bool> get subTitleOpen => _subTitleOpen;
|
||||||
|
Rx<int> get subTitleCode => _subTitleCode;
|
||||||
|
// Stream<bool> get onSubTitleOpenChanged => _subTitleOpen.stream;
|
||||||
|
|
||||||
/// [videoPlayerController] instace of Player
|
/// [videoPlayerController] instace of Player
|
||||||
Player? get videoPlayerController => _videoPlayerController;
|
Player? get videoPlayerController => _videoPlayerController;
|
||||||
|
|
||||||
@ -231,6 +241,10 @@ class PlPlayerController {
|
|||||||
// 播放顺序相关
|
// 播放顺序相关
|
||||||
PlayRepeat playRepeat = PlayRepeat.pause;
|
PlayRepeat playRepeat = PlayRepeat.pause;
|
||||||
|
|
||||||
|
RxList<SubTitileContentModel> subtitleContents =
|
||||||
|
<SubTitileContentModel>[].obs;
|
||||||
|
RxString subtitleContent = ''.obs;
|
||||||
|
|
||||||
void updateSliderPositionSecond() {
|
void updateSliderPositionSecond() {
|
||||||
int newSecond = _sliderPosition.value.inSeconds;
|
int newSecond = _sliderPosition.value.inSeconds;
|
||||||
if (sliderPositionSeconds.value != newSecond) {
|
if (sliderPositionSeconds.value != newSecond) {
|
||||||
@ -350,6 +364,8 @@ class PlPlayerController {
|
|||||||
bool enableHeart = true,
|
bool enableHeart = true,
|
||||||
// 是否首次加载
|
// 是否首次加载
|
||||||
bool isFirstTime = true,
|
bool isFirstTime = true,
|
||||||
|
// 是否开启字幕
|
||||||
|
bool enableSubTitle = false,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
_autoPlay = autoplay;
|
_autoPlay = autoplay;
|
||||||
@ -364,7 +380,9 @@ class PlPlayerController {
|
|||||||
_cid = cid;
|
_cid = cid;
|
||||||
_enableHeart = enableHeart;
|
_enableHeart = enableHeart;
|
||||||
_isFirstTime = isFirstTime;
|
_isFirstTime = isFirstTime;
|
||||||
|
_subTitleOpen.value = enableSubTitle;
|
||||||
|
subtitles = [].obs;
|
||||||
|
subtitleContent.value = '';
|
||||||
if (_videoPlayerController != null &&
|
if (_videoPlayerController != null &&
|
||||||
_videoPlayerController!.state.playing) {
|
_videoPlayerController!.state.playing) {
|
||||||
await pause(notify: false);
|
await pause(notify: false);
|
||||||
@ -575,6 +593,8 @@ class PlPlayerController {
|
|||||||
_sliderPosition.value = event;
|
_sliderPosition.value = event;
|
||||||
updateSliderPositionSecond();
|
updateSliderPositionSecond();
|
||||||
}
|
}
|
||||||
|
querySubtitleContent(
|
||||||
|
videoPlayerController!.state.position.inSeconds.toDouble());
|
||||||
|
|
||||||
/// 触发回调事件
|
/// 触发回调事件
|
||||||
for (var element in _positionListeners) {
|
for (var element in _positionListeners) {
|
||||||
@ -609,6 +629,10 @@ class PlPlayerController {
|
|||||||
const Duration(seconds: 1),
|
const Duration(seconds: 1),
|
||||||
() => videoPlayerServiceHandler.onPositionChange(event));
|
() => videoPlayerServiceHandler.onPositionChange(event));
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// onSubTitleOpenChanged.listen((bool event) {
|
||||||
|
// toggleSubtitle(event ? subTitleCode.value : -1);
|
||||||
|
// })
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -622,9 +646,6 @@ class PlPlayerController {
|
|||||||
|
|
||||||
/// 跳转至指定位置
|
/// 跳转至指定位置
|
||||||
Future<void> seekTo(Duration position, {type = 'seek'}) async {
|
Future<void> seekTo(Duration position, {type = 'seek'}) async {
|
||||||
// if (position >= duration.value) {
|
|
||||||
// position = duration.value - const Duration(milliseconds: 100);
|
|
||||||
// }
|
|
||||||
if (position < Duration.zero) {
|
if (position < Duration.zero) {
|
||||||
position = Duration.zero;
|
position = Duration.zero;
|
||||||
}
|
}
|
||||||
@ -637,21 +658,13 @@ class PlPlayerController {
|
|||||||
await _videoPlayerController?.stream.buffer.first;
|
await _videoPlayerController?.stream.buffer.first;
|
||||||
}
|
}
|
||||||
await _videoPlayerController?.seek(position);
|
await _videoPlayerController?.seek(position);
|
||||||
// if (playerStatus.stopped) {
|
|
||||||
// play();
|
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
print('seek duration else');
|
|
||||||
_timerForSeek?.cancel();
|
_timerForSeek?.cancel();
|
||||||
_timerForSeek =
|
_timerForSeek ??=
|
||||||
Timer.periodic(const Duration(milliseconds: 200), (Timer t) async {
|
Timer.periodic(const Duration(milliseconds: 200), (Timer t) async {
|
||||||
//_timerForSeek = null;
|
|
||||||
if (duration.value.inSeconds != 0) {
|
if (duration.value.inSeconds != 0) {
|
||||||
await _videoPlayerController!.stream.buffer.first;
|
await _videoPlayerController!.stream.buffer.first;
|
||||||
await _videoPlayerController?.seek(position);
|
await _videoPlayerController?.seek(position);
|
||||||
// if (playerStatus.status.value == PlayerStatus.paused) {
|
|
||||||
// play();
|
|
||||||
// }
|
|
||||||
t.cancel();
|
t.cancel();
|
||||||
_timerForSeek = null;
|
_timerForSeek = null;
|
||||||
}
|
}
|
||||||
@ -1047,12 +1060,61 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 字幕
|
||||||
|
void toggleSubtitle(int code) {
|
||||||
|
_subTitleOpen.value = code != -1;
|
||||||
|
_subTitleCode.value = code;
|
||||||
|
// if (code == -1) {
|
||||||
|
// // 关闭字幕
|
||||||
|
// _subTitleOpen.value = false;
|
||||||
|
// _subTitleCode.value = code;
|
||||||
|
// _videoPlayerController?.setSubtitleTrack(SubtitleTrack.no());
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// final SubTitlteItemModel? subtitle = subtitles?.firstWhereOrNull(
|
||||||
|
// (element) => element.code == code,
|
||||||
|
// );
|
||||||
|
// _subTitleOpen.value = true;
|
||||||
|
// _subTitleCode.value = code;
|
||||||
|
// _videoPlayerController?.setSubtitleTrack(
|
||||||
|
// SubtitleTrack.data(
|
||||||
|
// subtitle!.content!,
|
||||||
|
// title: subtitle.title,
|
||||||
|
// language: subtitle.lan,
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
|
||||||
|
void querySubtitleContent(double progress) {
|
||||||
|
if (subTitleCode.value == -1) {
|
||||||
|
subtitleContent.value = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (subtitles.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final SubTitlteItemModel? subtitle = subtitles.firstWhereOrNull(
|
||||||
|
(element) => element.code == subTitleCode.value,
|
||||||
|
);
|
||||||
|
if (subtitle != null && subtitle.body!.isNotEmpty) {
|
||||||
|
for (var content in subtitle.body!) {
|
||||||
|
if (progress >= content['from']! && progress <= content['to']!) {
|
||||||
|
subtitleContent.value = content['content']!;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setPlayRepeat(PlayRepeat type) {
|
setPlayRepeat(PlayRepeat type) {
|
||||||
playRepeat = type;
|
playRepeat = type;
|
||||||
videoStorage.put(VideoBoxKey.playRepeat, type.value);
|
videoStorage.put(VideoBoxKey.playRepeat, type.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> dispose({String type = 'single'}) async {
|
Future<void> dispose({String type = 'single'}) async {
|
||||||
|
print('dispose');
|
||||||
|
print('dispose: ${playerCount.value}');
|
||||||
|
|
||||||
// 每次减1,最后销毁
|
// 每次减1,最后销毁
|
||||||
if (type == 'single' && playerCount.value > 1) {
|
if (type == 'single' && playerCount.value > 1) {
|
||||||
_playerCount.value -= 1;
|
_playerCount.value -= 1;
|
||||||
@ -1062,6 +1124,7 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
_playerCount.value = 0;
|
_playerCount.value = 0;
|
||||||
try {
|
try {
|
||||||
|
print('dispose dispose ---------');
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
_timerForVolume?.cancel();
|
_timerForVolume?.cancel();
|
||||||
_timerForGettingVolume?.cancel();
|
_timerForGettingVolume?.cancel();
|
||||||
|
|||||||
@ -4,6 +4,7 @@ enum BottomControlType {
|
|||||||
next,
|
next,
|
||||||
time,
|
time,
|
||||||
space,
|
space,
|
||||||
|
episode,
|
||||||
fit,
|
fit,
|
||||||
speed,
|
speed,
|
||||||
fullscreen,
|
fullscreen,
|
||||||
|
|||||||
@ -37,6 +37,7 @@ class PLVideoPlayer extends StatefulWidget {
|
|||||||
this.bottomList,
|
this.bottomList,
|
||||||
this.customWidget,
|
this.customWidget,
|
||||||
this.customWidgets,
|
this.customWidgets,
|
||||||
|
this.showEposideCb,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -49,6 +50,7 @@ class PLVideoPlayer extends StatefulWidget {
|
|||||||
|
|
||||||
final Widget? customWidget;
|
final Widget? customWidget;
|
||||||
final List<Widget>? customWidgets;
|
final List<Widget>? customWidgets;
|
||||||
|
final Function? showEposideCb;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PLVideoPlayer> createState() => _PLVideoPlayerState();
|
State<PLVideoPlayer> createState() => _PLVideoPlayerState();
|
||||||
@ -214,8 +216,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
/// 上一集
|
/// 上一集
|
||||||
BottomControlType.pre: ComBtn(
|
BottomControlType.pre: ComBtn(
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.skip_previous_outlined,
|
Icons.skip_previous_rounded,
|
||||||
size: 15,
|
size: 21,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
fuc: () {},
|
fuc: () {},
|
||||||
@ -229,8 +231,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
/// 下一集
|
/// 下一集
|
||||||
BottomControlType.next: ComBtn(
|
BottomControlType.next: ComBtn(
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.last_page_outlined,
|
Icons.skip_next_rounded,
|
||||||
size: 15,
|
size: 21,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
fuc: () {},
|
fuc: () {},
|
||||||
@ -239,6 +241,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
/// 时间进度
|
/// 时间进度
|
||||||
BottomControlType.time: Row(
|
BottomControlType.time: Row(
|
||||||
children: [
|
children: [
|
||||||
|
const SizedBox(width: 8),
|
||||||
Obx(() {
|
Obx(() {
|
||||||
return Text(
|
return Text(
|
||||||
_.durationSeconds.value >= 3600
|
_.durationSeconds.value >= 3600
|
||||||
@ -266,6 +269,24 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
/// 空白占位
|
/// 空白占位
|
||||||
BottomControlType.space: const Spacer(),
|
BottomControlType.space: const Spacer(),
|
||||||
|
|
||||||
|
/// 选集
|
||||||
|
BottomControlType.episode: SizedBox(
|
||||||
|
height: 30,
|
||||||
|
width: 30,
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
widget.showEposideCb?.call();
|
||||||
|
},
|
||||||
|
style: ButtonStyle(
|
||||||
|
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
|
),
|
||||||
|
child: const Text(
|
||||||
|
'选集',
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 13),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
/// 画面比例
|
/// 画面比例
|
||||||
BottomControlType.fit: SizedBox(
|
BottomControlType.fit: SizedBox(
|
||||||
height: 30,
|
height: 30,
|
||||||
@ -580,6 +601,45 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
if (widget.danmuWidget != null)
|
if (widget.danmuWidget != null)
|
||||||
Positioned.fill(top: 4, child: widget.danmuWidget!),
|
Positioned.fill(top: 4, child: widget.danmuWidget!),
|
||||||
|
|
||||||
|
/// 开启且有字幕时展示
|
||||||
|
Stack(
|
||||||
|
children: [
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 30,
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Obx(
|
||||||
|
() => Visibility(
|
||||||
|
visible: widget.controller.subTitleCode.value != -1,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
color: widget.controller.subtitleContent.value != ''
|
||||||
|
? Colors.black.withOpacity(0.6)
|
||||||
|
: Colors.transparent,
|
||||||
|
),
|
||||||
|
padding: widget.controller.subTitleCode.value != -1
|
||||||
|
? const EdgeInsets.symmetric(
|
||||||
|
horizontal: 10,
|
||||||
|
vertical: 4,
|
||||||
|
)
|
||||||
|
: EdgeInsets.zero,
|
||||||
|
child: Text(
|
||||||
|
widget.controller.subtitleContent.value,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
/// 手势
|
/// 手势
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
left: 16,
|
left: 16,
|
||||||
|
|||||||
@ -68,91 +68,8 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Row(
|
Row(children: [...buildBottomControl!]),
|
||||||
children: [...buildBottomControl!],
|
const SizedBox(height: 10),
|
||||||
),
|
|
||||||
// Row(
|
|
||||||
// children: [
|
|
||||||
// PlayOrPauseButton(
|
|
||||||
// controller: _,
|
|
||||||
// ),
|
|
||||||
// const SizedBox(width: 4),
|
|
||||||
// // 播放时间
|
|
||||||
// Obx(() {
|
|
||||||
// return Text(
|
|
||||||
// _.durationSeconds.value >= 3600
|
|
||||||
// ? printDurationWithHours(
|
|
||||||
// Duration(seconds: _.positionSeconds.value))
|
|
||||||
// : printDuration(
|
|
||||||
// Duration(seconds: _.positionSeconds.value)),
|
|
||||||
// style: textStyle,
|
|
||||||
// );
|
|
||||||
// }),
|
|
||||||
// const SizedBox(width: 2),
|
|
||||||
// const Text('/', style: textStyle),
|
|
||||||
// const SizedBox(width: 2),
|
|
||||||
// Obx(
|
|
||||||
// () => Text(
|
|
||||||
// _.durationSeconds.value >= 3600
|
|
||||||
// ? printDurationWithHours(
|
|
||||||
// Duration(seconds: _.durationSeconds.value))
|
|
||||||
// : printDuration(
|
|
||||||
// Duration(seconds: _.durationSeconds.value)),
|
|
||||||
// style: textStyle,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// const Spacer(),
|
|
||||||
// // 倍速
|
|
||||||
// // Obx(
|
|
||||||
// // () => SizedBox(
|
|
||||||
// // width: 45,
|
|
||||||
// // height: 34,
|
|
||||||
// // child: TextButton(
|
|
||||||
// // style: ButtonStyle(
|
|
||||||
// // padding: MaterialStateProperty.all(EdgeInsets.zero),
|
|
||||||
// // ),
|
|
||||||
// // onPressed: () {
|
|
||||||
// // _.togglePlaybackSpeed();
|
|
||||||
// // },
|
|
||||||
// // child: Text(
|
|
||||||
// // '${_.playbackSpeed.toString()}X',
|
|
||||||
// // style: textStyle,
|
|
||||||
// // ),
|
|
||||||
// // ),
|
|
||||||
// // ),
|
|
||||||
// // ),
|
|
||||||
// SizedBox(
|
|
||||||
// height: 30,
|
|
||||||
// child: TextButton(
|
|
||||||
// onPressed: () => _.toggleVideoFit(),
|
|
||||||
// style: ButtonStyle(
|
|
||||||
// padding: MaterialStateProperty.all(EdgeInsets.zero),
|
|
||||||
// ),
|
|
||||||
// child: Obx(
|
|
||||||
// () => Text(
|
|
||||||
// _.videoFitDEsc.value,
|
|
||||||
// style: const TextStyle(color: Colors.white, fontSize: 13),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// const SizedBox(width: 10),
|
|
||||||
// // 全屏
|
|
||||||
// Obx(
|
|
||||||
// () => ComBtn(
|
|
||||||
// icon: Icon(
|
|
||||||
// _.isFullScreen.value
|
|
||||||
// ? FontAwesomeIcons.compress
|
|
||||||
// : FontAwesomeIcons.expand,
|
|
||||||
// size: 15,
|
|
||||||
// color: Colors.white,
|
|
||||||
// ),
|
|
||||||
// fuc: () => triggerFullScreen!(),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -39,6 +39,7 @@ import '../pages/setting/pages/color_select.dart';
|
|||||||
import '../pages/setting/pages/display_mode.dart';
|
import '../pages/setting/pages/display_mode.dart';
|
||||||
import '../pages/setting/pages/font_size_select.dart';
|
import '../pages/setting/pages/font_size_select.dart';
|
||||||
import '../pages/setting/pages/home_tabbar_set.dart';
|
import '../pages/setting/pages/home_tabbar_set.dart';
|
||||||
|
import '../pages/setting/pages/navigation_bar_set.dart';
|
||||||
import '../pages/setting/pages/play_gesture_set.dart';
|
import '../pages/setting/pages/play_gesture_set.dart';
|
||||||
import '../pages/setting/pages/play_speed_set.dart';
|
import '../pages/setting/pages/play_speed_set.dart';
|
||||||
import '../pages/setting/recommend_setting.dart';
|
import '../pages/setting/recommend_setting.dart';
|
||||||
@ -170,6 +171,9 @@ class Routes {
|
|||||||
// 播放器手势
|
// 播放器手势
|
||||||
CustomGetPage(
|
CustomGetPage(
|
||||||
name: '/playerGestureSet', page: () => const PlayGesturePage()),
|
name: '/playerGestureSet', page: () => const PlayGesturePage()),
|
||||||
|
// navigation bar
|
||||||
|
CustomGetPage(
|
||||||
|
name: '/navbarSetting', page: () => const NavigationBarSetPage()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
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';
|
||||||
@ -70,9 +72,20 @@ class DownloadUtils {
|
|||||||
static Future<bool> downloadImg(String imgUrl,
|
static Future<bool> downloadImg(String imgUrl,
|
||||||
{String imgType = 'cover'}) async {
|
{String imgType = 'cover'}) async {
|
||||||
try {
|
try {
|
||||||
if (!await requestPhotoPer()) {
|
if (!Platform.isAndroid || !await requestPhotoPer()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
final androidInfo = await DeviceInfoPlugin().androidInfo;
|
||||||
|
if (androidInfo.version.sdkInt <= 32) {
|
||||||
|
if (!await requestStoragePer()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!await requestPhotoPer()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SmartDialog.showLoading(msg: '保存中');
|
SmartDialog.showLoading(msg: '保存中');
|
||||||
var response = await Dio()
|
var response = await Dio()
|
||||||
.get(imgUrl, options: Options(responseType: ResponseType.bytes));
|
.get(imgUrl, options: Options(responseType: ResponseType.bytes));
|
||||||
|
|||||||
39
lib/utils/drawer.dart
Normal file
39
lib/utils/drawer.dart
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
|
||||||
|
class DrawerUtils {
|
||||||
|
static void showRightDialog({
|
||||||
|
required Widget child,
|
||||||
|
double width = 400,
|
||||||
|
bool useSystem = false,
|
||||||
|
}) {
|
||||||
|
SmartDialog.show(
|
||||||
|
alignment: Alignment.topRight,
|
||||||
|
animationBuilder: (controller, child, animationParam) {
|
||||||
|
return SlideTransition(
|
||||||
|
position: Tween<Offset>(
|
||||||
|
begin: const Offset(1, 0),
|
||||||
|
end: Offset.zero,
|
||||||
|
).animate(controller.view),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
useSystem: useSystem,
|
||||||
|
maskColor: Colors.black.withOpacity(0.5),
|
||||||
|
animationTime: const Duration(milliseconds: 200),
|
||||||
|
builder: (context) => Container(
|
||||||
|
width: width,
|
||||||
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
child: SafeArea(
|
||||||
|
left: false,
|
||||||
|
right: false,
|
||||||
|
bottom: false,
|
||||||
|
child: MediaQuery(
|
||||||
|
data: const MediaQueryData(padding: EdgeInsets.zero),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,15 +19,7 @@ class Em {
|
|||||||
return regCate(matchStr);
|
return regCate(matchStr);
|
||||||
}, onNonMatch: (String str) {
|
}, onNonMatch: (String str) {
|
||||||
if (str != '') {
|
if (str != '') {
|
||||||
str = str
|
str = decodeHtmlEntities(str);
|
||||||
.replaceAll('<', '<')
|
|
||||||
.replaceAll('>', '>')
|
|
||||||
.replaceAll('"', '"')
|
|
||||||
.replaceAll(''', "'")
|
|
||||||
.replaceAll('"', '"')
|
|
||||||
.replaceAll(''', "'")
|
|
||||||
.replaceAll(' ', " ")
|
|
||||||
.replaceAll('&', "&");
|
|
||||||
Map map = {'type': 'text', 'text': str};
|
Map map = {'type': 'text', 'text': str};
|
||||||
res.add(map);
|
res.add(map);
|
||||||
}
|
}
|
||||||
@ -35,4 +27,17 @@ class Em {
|
|||||||
});
|
});
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String decodeHtmlEntities(String title) {
|
||||||
|
return title
|
||||||
|
.replaceAll('<', '<')
|
||||||
|
.replaceAll('>', '>')
|
||||||
|
.replaceAll('"', '"')
|
||||||
|
.replaceAll(''', "'")
|
||||||
|
.replaceAll('"', '"')
|
||||||
|
.replaceAll(''', "'")
|
||||||
|
.replaceAll(' ', " ")
|
||||||
|
.replaceAll('&', "&")
|
||||||
|
.replaceAll(''', "'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,16 @@
|
|||||||
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import '../models/common/index.dart';
|
import '../models/common/index.dart';
|
||||||
|
|
||||||
|
Box setting = GStrorage.setting;
|
||||||
|
|
||||||
class GlobalData {
|
class GlobalData {
|
||||||
int imgQuality = 10;
|
int imgQuality = 10;
|
||||||
FullScreenGestureMode fullScreenGestureMode =
|
FullScreenGestureMode fullScreenGestureMode =
|
||||||
FullScreenGestureMode.values.last;
|
FullScreenGestureMode.values.last;
|
||||||
bool enablePlayerControlAnimation = true;
|
bool enablePlayerControlAnimation = true;
|
||||||
|
final bool enableMYBar =
|
||||||
|
setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
||||||
|
|
||||||
// 私有构造函数
|
// 私有构造函数
|
||||||
GlobalData._();
|
GlobalData._();
|
||||||
|
|||||||
34
lib/utils/main_stream.dart
Normal file
34
lib/utils/main_stream.dart
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
import '../pages/home/index.dart';
|
||||||
|
import '../pages/main/index.dart';
|
||||||
|
|
||||||
|
void handleScrollEvent(
|
||||||
|
ScrollController scrollController,
|
||||||
|
// StreamController<bool> mainStream,
|
||||||
|
// StreamController<bool>? searchBarStream,
|
||||||
|
) {
|
||||||
|
StreamController<bool> mainStream =
|
||||||
|
Get.find<MainController>().bottomBarStream;
|
||||||
|
StreamController<bool> searchBarStream =
|
||||||
|
Get.find<HomeController>().searchBarStream;
|
||||||
|
EasyThrottle.throttle(
|
||||||
|
'stream-throttler',
|
||||||
|
const Duration(milliseconds: 300),
|
||||||
|
() {
|
||||||
|
final ScrollDirection direction =
|
||||||
|
scrollController.position.userScrollDirection;
|
||||||
|
if (direction == ScrollDirection.forward) {
|
||||||
|
mainStream.add(true);
|
||||||
|
searchBarStream.add(true);
|
||||||
|
} else if (direction == ScrollDirection.reverse) {
|
||||||
|
mainStream.add(false);
|
||||||
|
searchBarStream.add(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -148,7 +148,8 @@ class SettingBoxKey {
|
|||||||
hideTabBar = 'hideTabBar', // 收起底栏
|
hideTabBar = 'hideTabBar', // 收起底栏
|
||||||
tabbarSort = 'tabbarSort', // 首页tabbar
|
tabbarSort = 'tabbarSort', // 首页tabbar
|
||||||
dynamicBadgeMode = 'dynamicBadgeMode',
|
dynamicBadgeMode = 'dynamicBadgeMode',
|
||||||
enableGradientBg = 'enableGradientBg';
|
enableGradientBg = 'enableGradientBg',
|
||||||
|
navBarSort = 'navBarSort';
|
||||||
}
|
}
|
||||||
|
|
||||||
class LocalCacheKey {
|
class LocalCacheKey {
|
||||||
|
|||||||
32
lib/utils/subtitle.dart
Normal file
32
lib/utils/subtitle.dart
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
class SubTitleUtils {
|
||||||
|
// 格式整理
|
||||||
|
static String convertToWebVTT(List jsonData) {
|
||||||
|
String webVTTContent = 'WEBVTT FILE\n\n';
|
||||||
|
|
||||||
|
for (int i = 0; i < jsonData.length; i++) {
|
||||||
|
final item = jsonData[i];
|
||||||
|
double from = item['from'] as double;
|
||||||
|
double to = item['to'] as double;
|
||||||
|
int sid = (item['sid'] ?? 0) as int;
|
||||||
|
String content = item['content'] as String;
|
||||||
|
|
||||||
|
webVTTContent += '$sid\n';
|
||||||
|
webVTTContent += '${formatTime(from)} --> ${formatTime(to)}\n';
|
||||||
|
webVTTContent += '$content\n\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
return webVTTContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
static String formatTime(num seconds) {
|
||||||
|
final String h = (seconds / 3600).floor().toString().padLeft(2, '0');
|
||||||
|
final String m = (seconds % 3600 / 60).floor().toString().padLeft(2, '0');
|
||||||
|
final String s = (seconds % 60).floor().toString().padLeft(2, '0');
|
||||||
|
final String ms =
|
||||||
|
(seconds * 1000 % 1000).floor().toString().padLeft(3, '0');
|
||||||
|
if (h == '00') {
|
||||||
|
return "$m:$s.$ms";
|
||||||
|
}
|
||||||
|
return "$h:$m:$s.$ms";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -51,7 +51,7 @@ class Utils {
|
|||||||
}
|
}
|
||||||
if (time < 3600) {
|
if (time < 3600) {
|
||||||
if (time == 0) {
|
if (time == 0) {
|
||||||
return time;
|
return '00:00';
|
||||||
}
|
}
|
||||||
final int minute = time ~/ 60;
|
final int minute = time ~/ 60;
|
||||||
final double res = time / 60;
|
final double res = time / 60;
|
||||||
@ -208,17 +208,35 @@ class Utils {
|
|||||||
|
|
||||||
static int findClosestNumber(int target, List<int> numbers) {
|
static int findClosestNumber(int target, List<int> numbers) {
|
||||||
int minDiff = 127;
|
int minDiff = 127;
|
||||||
late int closestNumber;
|
int closestNumber = 0; // 初始化为0,表示没有找到比目标值小的整数
|
||||||
|
|
||||||
|
// 向下查找
|
||||||
try {
|
try {
|
||||||
for (int number in numbers) {
|
for (int number in numbers) {
|
||||||
int diff = (number - target).abs();
|
if (number < target) {
|
||||||
|
int diff = target - number; // 计算目标值与当前整数的差值
|
||||||
|
|
||||||
if (diff < minDiff) {
|
if (diff < minDiff) {
|
||||||
minDiff = diff;
|
minDiff = diff;
|
||||||
closestNumber = number;
|
closestNumber = number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
|
||||||
|
// 向上查找
|
||||||
|
if (closestNumber == 0) {
|
||||||
|
try {
|
||||||
|
for (int number in numbers) {
|
||||||
|
int diff = (number - target).abs();
|
||||||
|
|
||||||
|
if (diff < minDiff) {
|
||||||
|
minDiff = diff;
|
||||||
|
closestNumber = number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
return closestNumber;
|
return closestNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -409,6 +409,14 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.2"
|
version: "1.0.2"
|
||||||
|
dlna_dart:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: dlna_dart
|
||||||
|
sha256: ae07c1c53077bbf58756fa589f936968719b0085441981d33e74f82f89d1d281
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.8"
|
||||||
dynamic_color:
|
dynamic_color:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -144,6 +144,8 @@ dependencies:
|
|||||||
disable_battery_optimization: ^1.1.1
|
disable_battery_optimization: ^1.1.1
|
||||||
# 展开/收起
|
# 展开/收起
|
||||||
expandable: ^5.0.1
|
expandable: ^5.0.1
|
||||||
|
# 投屏
|
||||||
|
dlna_dart: ^0.0.8
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user