Merge branch 'main' into opt-videoPlayerControl
This commit is contained in:
47
README.md
47
README.md
@ -26,15 +26,50 @@
|
|||||||
Xcode 13.4 不支持**auto_orientation**,请注释相关代码
|
Xcode 13.4 不支持**auto_orientation**,请注释相关代码
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
[✓] Flutter (Channel stable, 3.16.5, on macOS 14.1.2 23B92 darwin-arm64, locale
|
[!] Flutter (Channel [user-branch], 3.19.6, on macOS 14.6.1 23G93 darwin-arm64,
|
||||||
zh-Hans-CN)
|
locale zh-Hans-CN)
|
||||||
|
! Flutter version 3.19.6 on channel [user-branch] at
|
||||||
|
/Users/rr/Documents/sdk/flutter
|
||||||
|
Currently on an unknown channel. Run `flutter channel` to switch to an
|
||||||
|
official channel.
|
||||||
|
If that doesn't fix the issue, reinstall Flutter by following instructions
|
||||||
|
at https://flutter.dev/docs/get-started/install.
|
||||||
|
! Upstream repository unknown source is not a standard remote.
|
||||||
|
Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss
|
||||||
|
this error.
|
||||||
|
• Framework revision 54e66469a9 (8 months ago), 2024-04-17 13:08:03 -0700
|
||||||
|
• Engine revision c4cd48e186
|
||||||
|
• Dart version 3.3.4
|
||||||
|
• DevTools version 2.31.1
|
||||||
|
• Pub download mirror https://pub.flutter-io.cn
|
||||||
|
• Flutter download mirror https://storage.flutter-io.cn
|
||||||
|
• If those were intentional, you can disregard the above warnings; however
|
||||||
|
it is recommended to use "git" directly to perform update checks and
|
||||||
|
upgrades.
|
||||||
|
|
||||||
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
|
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
|
||||||
|
• Android SDK at /Users/rr/Library/Android/sdk
|
||||||
|
• Platform android-34, build-tools 34.0.0
|
||||||
|
• Java binary at: /Applications/Android
|
||||||
|
Studio.app/Contents/jbr/Contents/Home/bin/java
|
||||||
|
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
|
||||||
|
• All Android licenses accepted.
|
||||||
|
|
||||||
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
|
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
|
||||||
|
• Xcode at /Applications/Xcode.app/Contents/Developer
|
||||||
|
• Build 15C65
|
||||||
|
• CocoaPods version 1.14.3
|
||||||
|
|
||||||
[✓] Chrome - develop for the web
|
[✓] Chrome - develop for the web
|
||||||
[✓] Android Studio (version 2022.3)
|
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
|
||||||
[✓] VS Code (version 1.87.2)
|
|
||||||
[✓] Connected device (3 available)
|
[✓] Android Studio (version 2024.2)
|
||||||
[✓] Network resources
|
• Android Studio at /Applications/Android Studio.app/Contents
|
||||||
|
• Flutter plugin can be installed from:
|
||||||
|
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
|
||||||
|
• Dart plugin can be installed from:
|
||||||
|
🔨 https://plugins.jetbrains.com/plugin/6351-dart
|
||||||
|
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -778,11 +778,16 @@ class UgcSeasonBuild extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (ugcSeason.intro != null && ugcSeason.intro != '') ...[
|
if (ugcSeason.intro != null && ugcSeason.intro != '') ...[
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 6),
|
||||||
Text(
|
Container(
|
||||||
|
constraints: const BoxConstraints(maxHeight: 100),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Text(
|
||||||
ugcSeason.intro!,
|
ugcSeason.intro!,
|
||||||
style: TextStyle(color: outline, fontSize: 12),
|
style: TextStyle(color: outline, fontSize: 12),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text.rich(
|
Text.rich(
|
||||||
|
|||||||
@ -1,12 +1,10 @@
|
|||||||
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';
|
||||||
import 'package:hive/hive.dart';
|
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/http/member.dart';
|
import 'package:pilipala/http/member.dart';
|
||||||
import 'package:pilipala/models/member/tags.dart';
|
import 'package:pilipala/models/member/tags.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
|
||||||
|
|
||||||
class GroupPanel extends StatefulWidget {
|
class GroupPanel extends StatefulWidget {
|
||||||
final int? mid;
|
final int? mid;
|
||||||
@ -18,7 +16,6 @@ class GroupPanel extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _GroupPanelState extends State<GroupPanel> {
|
class _GroupPanelState extends State<GroupPanel> {
|
||||||
final Box<dynamic> localCache = GStorage.localCache;
|
|
||||||
late Future _futureBuilderFuture;
|
late Future _futureBuilderFuture;
|
||||||
late List<MemberTagItemModel> tagsList;
|
late List<MemberTagItemModel> tagsList;
|
||||||
bool showDefault = true;
|
bool showDefault = true;
|
||||||
@ -137,7 +134,7 @@ class _GroupPanelState extends State<GroupPanel> {
|
|||||||
left: 20,
|
left: 20,
|
||||||
right: 20,
|
right: 20,
|
||||||
top: 12,
|
top: 12,
|
||||||
bottom: MediaQuery.of(context).padding.bottom + 12,
|
bottom: MediaQuery.paddingOf(context).bottom + 12,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
@ -1,13 +1,11 @@
|
|||||||
// ignore_for_file: avoid_print
|
// ignore_for_file: avoid_print
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:developer';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:cookie_jar/cookie_jar.dart';
|
import 'package:cookie_jar/cookie_jar.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:dio/io.dart';
|
import 'package:dio/io.dart';
|
||||||
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
|
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/models/user/info.dart';
|
|
||||||
import 'package:pilipala/utils/id_utils.dart';
|
import 'package:pilipala/utils/id_utils.dart';
|
||||||
import '../utils/storage.dart';
|
import '../utils/storage.dart';
|
||||||
import '../utils/utils.dart';
|
import '../utils/utils.dart';
|
||||||
@ -39,18 +37,7 @@ class Request {
|
|||||||
dio.interceptors.add(cookieManager);
|
dio.interceptors.add(cookieManager);
|
||||||
final List<Cookie> cookie = await cookieManager.cookieJar
|
final List<Cookie> cookie = await cookieManager.cookieJar
|
||||||
.loadForRequest(Uri.parse(HttpString.baseUrl));
|
.loadForRequest(Uri.parse(HttpString.baseUrl));
|
||||||
final UserInfoData? userInfo = userInfoCache.get('userInfoCache');
|
final userInfo = userInfoCache.get('userInfoCache');
|
||||||
if (userInfo != null && userInfo.mid != null) {
|
|
||||||
final List<Cookie> cookie2 = await cookieManager.cookieJar
|
|
||||||
.loadForRequest(Uri.parse(HttpString.tUrl));
|
|
||||||
if (cookie2.isEmpty) {
|
|
||||||
try {
|
|
||||||
await Request().get(HttpString.tUrl);
|
|
||||||
} catch (e) {
|
|
||||||
log("setCookie, ${e.toString()}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setOptionsHeaders(userInfo, userInfo != null && userInfo.mid != null);
|
setOptionsHeaders(userInfo, userInfo != null && userInfo.mid != null);
|
||||||
String baseUrlType = 'default';
|
String baseUrlType = 'default';
|
||||||
if (setting.get(SettingBoxKey.enableGATMode, defaultValue: false)) {
|
if (setting.get(SettingBoxKey.enableGATMode, defaultValue: false)) {
|
||||||
@ -69,10 +56,10 @@ class Request {
|
|||||||
static Future<String> getCsrf() async {
|
static Future<String> getCsrf() async {
|
||||||
List<Cookie> cookies = await cookieManager.cookieJar
|
List<Cookie> cookies = await cookieManager.cookieJar
|
||||||
.loadForRequest(Uri.parse(HttpString.baseUrl));
|
.loadForRequest(Uri.parse(HttpString.baseUrl));
|
||||||
String token = '';
|
String token = cookies
|
||||||
if (cookies.where((e) => e.name == 'bili_jct').isNotEmpty) {
|
.firstWhere((e) => e.name == 'bili_jct',
|
||||||
token = cookies.firstWhere((e) => e.name == 'bili_jct').value;
|
orElse: () => Cookie('bili_jct', ''))
|
||||||
}
|
.value;
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:pilipala/utils/login.dart';
|
// import 'package:pilipala/utils/login.dart';
|
||||||
|
|
||||||
class ApiInterceptor extends Interceptor {
|
class ApiInterceptor extends Interceptor {
|
||||||
@override
|
@override
|
||||||
@ -19,9 +19,9 @@ class ApiInterceptor extends Interceptor {
|
|||||||
void onResponse(Response response, ResponseInterceptorHandler handler) {
|
void onResponse(Response response, ResponseInterceptorHandler handler) {
|
||||||
try {
|
try {
|
||||||
// 在响应之后处理数据
|
// 在响应之后处理数据
|
||||||
if (response.data is Map && response.data['code'] == -101) {
|
// if (response.data is Map && response.data['code'] == -101) {
|
||||||
LoginUtils.loginOut();
|
// LoginUtils.loginOut();
|
||||||
}
|
// }
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
print('ApiInterceptor: $err');
|
print('ApiInterceptor: $err');
|
||||||
}
|
}
|
||||||
@ -39,6 +39,8 @@ class ApiInterceptor extends Interceptor {
|
|||||||
SmartDialog.showToast(
|
SmartDialog.showToast(
|
||||||
await dioError(err),
|
await dioError(err),
|
||||||
displayType: SmartToastType.onlyRefresh,
|
displayType: SmartToastType.onlyRefresh,
|
||||||
|
displayTime: const Duration(seconds: 1),
|
||||||
|
debounce: true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
super.onError(err, handler);
|
super.onError(err, handler);
|
||||||
@ -62,7 +64,7 @@ class ApiInterceptor extends Interceptor {
|
|||||||
return '发送请求超时,请检查网络设置';
|
return '发送请求超时,请检查网络设置';
|
||||||
case DioExceptionType.unknown:
|
case DioExceptionType.unknown:
|
||||||
final String res = await checkConnect();
|
final String res = await checkConnect();
|
||||||
return '$res,网络异常!';
|
return '$res ${error.error}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -216,6 +216,21 @@ class BuildMainApp extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Box setting = GStorage.setting;
|
||||||
|
|
||||||
|
/// 纯黑模式主题配置
|
||||||
|
ColorScheme? pureDarkColorScheme;
|
||||||
|
final bool enablePureBlack =
|
||||||
|
setting.get(SettingBoxKey.enablePureBlack, defaultValue: false);
|
||||||
|
if (enablePureBlack) {
|
||||||
|
pureDarkColorScheme = darkColorScheme.copyWith(
|
||||||
|
background: Colors.black,
|
||||||
|
surface: Colors.black,
|
||||||
|
onPrimary: Colors.black,
|
||||||
|
onSecondary: Colors.black,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final SnackBarThemeData snackBarTheme = SnackBarThemeData(
|
final SnackBarThemeData snackBarTheme = SnackBarThemeData(
|
||||||
actionTextColor: lightColorScheme.primary,
|
actionTextColor: lightColorScheme.primary,
|
||||||
backgroundColor: lightColorScheme.secondaryContainer,
|
backgroundColor: lightColorScheme.secondaryContainer,
|
||||||
@ -255,13 +270,13 @@ class BuildMainApp extends StatelessWidget {
|
|||||||
title: 'PiliPala',
|
title: 'PiliPala',
|
||||||
theme: buildThemeData(
|
theme: buildThemeData(
|
||||||
currentThemeValue == ThemeType.dark
|
currentThemeValue == ThemeType.dark
|
||||||
? darkColorScheme
|
? pureDarkColorScheme ?? darkColorScheme
|
||||||
: lightColorScheme,
|
: lightColorScheme,
|
||||||
),
|
),
|
||||||
darkTheme: buildThemeData(
|
darkTheme: buildThemeData(
|
||||||
currentThemeValue == ThemeType.light
|
currentThemeValue == ThemeType.light
|
||||||
? lightColorScheme
|
? lightColorScheme
|
||||||
: darkColorScheme,
|
: pureDarkColorScheme ?? darkColorScheme,
|
||||||
),
|
),
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: const [
|
||||||
GlobalCupertinoLocalizations.delegate,
|
GlobalCupertinoLocalizations.delegate,
|
||||||
|
|||||||
@ -84,10 +84,7 @@ Widget highlightText(String str) {
|
|||||||
String remainingText = str.substring(currentIndex);
|
String remainingText = str.substring(currentIndex);
|
||||||
|
|
||||||
// 将剩余的普通文本部分添加到 children 列表中
|
// 将剩余的普通文本部分添加到 children 列表中
|
||||||
children.add(TextSpan(
|
children.add(TextSpan(text: remainingText));
|
||||||
text: remainingText,
|
|
||||||
style: DefaultTextStyle.of(Get.context!).style,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用 Text.rich 创建包含高亮显示的富文本小部件,并返回
|
// 使用 Text.rich 创建包含高亮显示的富文本小部件,并返回
|
||||||
|
|||||||
@ -117,20 +117,23 @@ class DynamicsController extends GetxController {
|
|||||||
/// 点击评论action 直接查看评论
|
/// 点击评论action 直接查看评论
|
||||||
if (action == 'comment') {
|
if (action == 'comment') {
|
||||||
Get.toNamed('/dynamicDetail',
|
Get.toNamed('/dynamicDetail',
|
||||||
arguments: {'item': item, 'floor': floor, 'action': action});
|
arguments: {'item': item, 'floor': floor, 'action': action},
|
||||||
|
preventDuplicates: false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (item!.type) {
|
switch (item!.type) {
|
||||||
/// 转发的动态
|
/// 转发的动态
|
||||||
case 'DYNAMIC_TYPE_FORWARD':
|
case 'DYNAMIC_TYPE_FORWARD':
|
||||||
Get.toNamed('/dynamicDetail',
|
Get.toNamed('/dynamicDetail',
|
||||||
arguments: {'item': item, 'floor': floor});
|
arguments: {'item': item, 'floor': floor},
|
||||||
|
preventDuplicates: false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/// 图文动态查看
|
/// 图文动态查看
|
||||||
case 'DYNAMIC_TYPE_DRAW':
|
case 'DYNAMIC_TYPE_DRAW':
|
||||||
Get.toNamed('/dynamicDetail',
|
Get.toNamed('/dynamicDetail',
|
||||||
arguments: {'item': item, 'floor': floor});
|
arguments: {'item': item, 'floor': floor},
|
||||||
|
preventDuplicates: false);
|
||||||
break;
|
break;
|
||||||
case 'DYNAMIC_TYPE_AV':
|
case 'DYNAMIC_TYPE_AV':
|
||||||
String bvid = item.modules.moduleDynamic.major.archive.bvid;
|
String bvid = item.modules.moduleDynamic.major.archive.bvid;
|
||||||
@ -188,7 +191,8 @@ class DynamicsController extends GetxController {
|
|||||||
case 'DYNAMIC_TYPE_WORD':
|
case 'DYNAMIC_TYPE_WORD':
|
||||||
print('纯文本');
|
print('纯文本');
|
||||||
Get.toNamed('/dynamicDetail',
|
Get.toNamed('/dynamicDetail',
|
||||||
arguments: {'item': item, 'floor': floor});
|
arguments: {'item': item, 'floor': floor},
|
||||||
|
preventDuplicates: false);
|
||||||
break;
|
break;
|
||||||
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
case 'DYNAMIC_TYPE_LIVE_RCMD':
|
||||||
DynamicLiveModel liveRcmd = item.modules.moduleDynamic.major.liveRcmd;
|
DynamicLiveModel liveRcmd = item.modules.moduleDynamic.major.liveRcmd;
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -61,6 +63,7 @@ class _OverlayPanelState extends State<OverlayPanel>
|
|||||||
|
|
||||||
void onClickUp(data, i, {type = 'click'}) {
|
void onClickUp(data, i, {type = 'click'}) {
|
||||||
if (type == 'click') {
|
if (type == 'click') {
|
||||||
|
data.hasUpdate = false;
|
||||||
pageController.jumpToPage(i);
|
pageController.jumpToPage(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,11 +84,11 @@ class _OverlayPanelState extends State<OverlayPanel>
|
|||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
|
child: BackdropFilter(
|
||||||
|
filter: ImageFilter.blur(sigmaX: 8.0, sigmaY: 8.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
TabBar(
|
||||||
height: 50,
|
|
||||||
child: TabBar(
|
|
||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
dividerColor: Colors.transparent,
|
dividerColor: Colors.transparent,
|
||||||
automaticIndicatorColorAdjustment: false,
|
automaticIndicatorColorAdjustment: false,
|
||||||
@ -106,7 +109,6 @@ class _OverlayPanelState extends State<OverlayPanel>
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: PageView.builder(
|
child: PageView.builder(
|
||||||
itemCount: upList.length,
|
itemCount: upList.length,
|
||||||
@ -119,13 +121,15 @@ class _OverlayPanelState extends State<OverlayPanel>
|
|||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
child: UpDyanmicsPage(upInfo: upList[index], ctr: widget.ctr),
|
child:
|
||||||
|
UpDyanmicsPage(upInfo: upList[index], ctr: widget.ctr),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,8 +143,8 @@ class _OverlayPanelState extends State<OverlayPanel>
|
|||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
scale: currentMid == data.mid ? 1 : 0.9,
|
scale: currentMid == data.mid ? 1 : 0.9,
|
||||||
child: NetworkImgLayer(
|
child: NetworkImgLayer(
|
||||||
width: contentWidth,
|
width: 46,
|
||||||
height: contentWidth,
|
height: 46,
|
||||||
src: data.face,
|
src: data.face,
|
||||||
type: 'avatar',
|
type: 'avatar',
|
||||||
),
|
),
|
||||||
|
|||||||
@ -44,6 +44,7 @@ class _UpPanelState extends State<UpPanel> {
|
|||||||
|
|
||||||
void onClickUp(data, i) {
|
void onClickUp(data, i) {
|
||||||
currentMid.value = data.mid;
|
currentMid.value = data.mid;
|
||||||
|
data.hasUpdate = false;
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
PlPopupRoute(
|
PlPopupRoute(
|
||||||
|
|||||||
@ -3,8 +3,8 @@ import 'package:get/get.dart';
|
|||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/models/follow/result.dart';
|
import 'package:pilipala/models/follow/result.dart';
|
||||||
import 'package:pilipala/pages/follow/index.dart';
|
import 'package:pilipala/pages/follow/index.dart';
|
||||||
import 'package:pilipala/pages/video/detail/introduction/widgets/group_panel.dart';
|
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
|
import 'package:pilipala/utils/follow.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
class FollowItem extends StatelessWidget {
|
class FollowItem extends StatelessWidget {
|
||||||
@ -47,28 +47,11 @@ class FollowItem extends StatelessWidget {
|
|||||||
height: 34,
|
height: 34,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await showModalBottomSheet(
|
int followStatus = await FollowUtils(
|
||||||
context: context,
|
context: context,
|
||||||
useSafeArea: true,
|
followStatus: 2,
|
||||||
isScrollControlled: true,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return DraggableScrollableSheet(
|
|
||||||
initialChildSize: 0.6,
|
|
||||||
minChildSize: 0,
|
|
||||||
maxChildSize: 1,
|
|
||||||
snap: true,
|
|
||||||
expand: false,
|
|
||||||
snapSizes: const [0.6],
|
|
||||||
builder: (BuildContext context,
|
|
||||||
ScrollController scrollController) {
|
|
||||||
return GroupPanel(
|
|
||||||
mid: item.mid!,
|
mid: item.mid!,
|
||||||
scrollController: scrollController,
|
).showFollowSheet();
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
||||||
|
|||||||
@ -1,14 +1,19 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:cookie_jar/cookie_jar.dart';
|
||||||
|
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
|
||||||
import 'package:encrypt/encrypt.dart';
|
import 'package:encrypt/encrypt.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';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:pilipala/http/constants.dart';
|
||||||
|
import 'package:pilipala/http/index.dart';
|
||||||
import 'package:pilipala/http/login.dart';
|
import 'package:pilipala/http/login.dart';
|
||||||
import 'package:gt3_flutter_plugin/gt3_flutter_plugin.dart';
|
import 'package:gt3_flutter_plugin/gt3_flutter_plugin.dart';
|
||||||
import 'package:pilipala/models/login/index.dart';
|
import 'package:pilipala/models/login/index.dart';
|
||||||
import 'package:pilipala/utils/login.dart';
|
import 'package:pilipala/utils/login.dart';
|
||||||
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
class LoginPageController extends GetxController {
|
class LoginPageController extends GetxController {
|
||||||
final GlobalKey mobFormKey = GlobalKey<FormState>();
|
final GlobalKey mobFormKey = GlobalKey<FormState>();
|
||||||
@ -341,4 +346,32 @@ class LoginPageController extends GetxController {
|
|||||||
Get.back();
|
Get.back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cookie登录
|
||||||
|
Future loginInByCookie({
|
||||||
|
required String cookiesStr,
|
||||||
|
String domain = HttpString.baseUrl,
|
||||||
|
}) async {
|
||||||
|
final List<String> cookiesStrList = cookiesStr.split('; ');
|
||||||
|
final List<Cookie> cookiesList = cookiesStrList.map((cookie) {
|
||||||
|
final cookieArr = cookie.split('=');
|
||||||
|
return Cookie(cookieArr[0], cookieArr[1]);
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
final String cookiePath = await Utils.getCookiePath();
|
||||||
|
final cookieJar = PersistCookieJar(
|
||||||
|
ignoreExpires: true,
|
||||||
|
storage: FileStorage(cookiePath),
|
||||||
|
);
|
||||||
|
CookieManager cookieManager = CookieManager(cookieJar);
|
||||||
|
Request.cookieManager = cookieManager;
|
||||||
|
await Request.cookieManager.cookieJar
|
||||||
|
.saveFromResponse(Uri.parse(HttpString.baseUrl), cookiesList);
|
||||||
|
try {
|
||||||
|
Request.dio.options.headers['cookie'] = cookiesStr;
|
||||||
|
} catch (err) {
|
||||||
|
debugPrint(err.toString());
|
||||||
|
}
|
||||||
|
LoginUtils.confirmLogin('', null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,36 +14,8 @@ class LoginPage extends StatefulWidget {
|
|||||||
class _LoginPageState extends State<LoginPage> {
|
class _LoginPageState extends State<LoginPage> {
|
||||||
final LoginPageController _loginPageCtr = Get.put(LoginPageController());
|
final LoginPageController _loginPageCtr = Get.put(LoginPageController());
|
||||||
|
|
||||||
@override
|
// 浏览器登录
|
||||||
void dispose() {
|
void loginInByWeb() {
|
||||||
_loginPageCtr.validTimer?.cancel();
|
|
||||||
_loginPageCtr.timer?.cancel();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
leading: Obx(
|
|
||||||
() => _loginPageCtr.currentIndex.value == 0
|
|
||||||
? IconButton(
|
|
||||||
onPressed: () async {
|
|
||||||
_loginPageCtr.mobTextFieldNode.unfocus();
|
|
||||||
await Future.delayed(const Duration(milliseconds: 200));
|
|
||||||
Get.back();
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.close_outlined),
|
|
||||||
)
|
|
||||||
: IconButton(
|
|
||||||
onPressed: () => _loginPageCtr.previousPage(),
|
|
||||||
icon: const Icon(Icons.arrow_back),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
IconButton(
|
|
||||||
tooltip: '浏览器打开',
|
|
||||||
onPressed: () {
|
|
||||||
Get.offNamed(
|
Get.offNamed(
|
||||||
'/webview',
|
'/webview',
|
||||||
parameters: {
|
parameters: {
|
||||||
@ -52,17 +24,14 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
'pageTitle': '登录bilibili',
|
'pageTitle': '登录bilibili',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
icon: const Icon(Icons.language, size: 20),
|
|
||||||
),
|
// 二维码方式登录
|
||||||
IconButton(
|
void loginInByWebQrcode() {
|
||||||
tooltip: '二维码登录',
|
|
||||||
onPressed: () {
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return StatefulBuilder(
|
return StatefulBuilder(builder: (context, StateSetter setState) {
|
||||||
builder: (context, StateSetter setState) {
|
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Row(
|
title: Row(
|
||||||
children: [
|
children: [
|
||||||
@ -84,8 +53,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
child: FutureBuilder(
|
child: FutureBuilder(
|
||||||
future: _loginPageCtr.getWebQrcode(),
|
future: _loginPageCtr.getWebQrcode(),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState ==
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
ConnectionState.done) {
|
|
||||||
if (snapshot.data == null) {
|
if (snapshot.data == null) {
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
@ -122,10 +90,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
'检查登录状态',
|
'检查登录状态',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: Theme.of(context)
|
fontSize: Theme.of(context).textTheme.titleMedium!.fontSize,
|
||||||
.textTheme
|
|
||||||
.titleMedium!
|
|
||||||
.fontSize,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -136,7 +101,97 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
).then((value) {
|
).then((value) {
|
||||||
_loginPageCtr.validTimer!.cancel();
|
_loginPageCtr.validTimer!.cancel();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// cookie登录
|
||||||
|
// cookie登录
|
||||||
|
void loginInByCookie() async {
|
||||||
|
var cookies = '';
|
||||||
|
final outline = Theme.of(context).colorScheme.outline;
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('Cookie登录'),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Text('请将主站cookie粘贴到下方输入框中,点击「确认」即可完成登录。(记得清空粘贴板~)'),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
TextField(
|
||||||
|
minLines: 1,
|
||||||
|
maxLines: 3,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'cookie',
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(6.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onChanged: (e) => cookies = e,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: Navigator.of(context).pop,
|
||||||
|
child: Text('取消', style: TextStyle(color: outline))),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
if (cookies.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await _loginPageCtr.loginInByCookie(cookiesStr: cookies);
|
||||||
|
if (context.mounted) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
child: const Text('确认'))
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_loginPageCtr.validTimer?.cancel();
|
||||||
|
_loginPageCtr.timer?.cancel();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
leading: Obx(
|
||||||
|
() => _loginPageCtr.currentIndex.value == 0
|
||||||
|
? IconButton(
|
||||||
|
onPressed: () async {
|
||||||
|
_loginPageCtr.mobTextFieldNode.unfocus();
|
||||||
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.close_outlined),
|
||||||
|
)
|
||||||
|
: IconButton(
|
||||||
|
onPressed: () => _loginPageCtr.previousPage(),
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
tooltip: '浏览器打开',
|
||||||
|
onPressed: loginInByWeb,
|
||||||
|
icon: const Icon(Icons.language, size: 20),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
tooltip: 'cookie登录',
|
||||||
|
onPressed: loginInByCookie,
|
||||||
|
icon: const Icon(Icons.cookie_outlined, size: 20),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
tooltip: '二维码登录',
|
||||||
|
onPressed: loginInByWebQrcode,
|
||||||
icon: const Icon(Icons.qr_code, size: 20),
|
icon: const Icon(Icons.qr_code, size: 20),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 22),
|
const SizedBox(width: 22),
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
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';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/http/member.dart';
|
import 'package:pilipala/http/member.dart';
|
||||||
import 'package:pilipala/http/user.dart';
|
import 'package:pilipala/http/user.dart';
|
||||||
import 'package:pilipala/http/video.dart';
|
|
||||||
import 'package:pilipala/models/member/archive.dart';
|
import 'package:pilipala/models/member/archive.dart';
|
||||||
import 'package:pilipala/models/member/coin.dart';
|
import 'package:pilipala/models/member/coin.dart';
|
||||||
import 'package:pilipala/models/member/info.dart';
|
import 'package:pilipala/models/member/info.dart';
|
||||||
import 'package:pilipala/models/member/like.dart';
|
import 'package:pilipala/models/member/like.dart';
|
||||||
import 'package:pilipala/models/user/info.dart';
|
import 'package:pilipala/models/user/info.dart';
|
||||||
|
import 'package:pilipala/utils/follow.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';
|
||||||
|
|
||||||
@ -29,6 +28,12 @@ class MemberController extends GetxController {
|
|||||||
RxList<MemberCoinsDataModel> recentCoinsList = <MemberCoinsDataModel>[].obs;
|
RxList<MemberCoinsDataModel> recentCoinsList = <MemberCoinsDataModel>[].obs;
|
||||||
RxList<MemberLikeDataModel> recentLikeList = <MemberLikeDataModel>[].obs;
|
RxList<MemberLikeDataModel> recentLikeList = <MemberLikeDataModel>[].obs;
|
||||||
RxBool isOwner = false.obs;
|
RxBool isOwner = false.obs;
|
||||||
|
final Map<int, String> attributeTextMap = {
|
||||||
|
1: '悄悄关注',
|
||||||
|
2: '已关注',
|
||||||
|
6: '已互粉',
|
||||||
|
128: '已拉黑',
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -85,11 +90,12 @@ class MemberController extends GetxController {
|
|||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (attribute.value == 128) {
|
attribute.value = await FollowUtils(
|
||||||
modifyRelation('block');
|
context: Get.context!,
|
||||||
} else {
|
followStatus: attribute.value,
|
||||||
modifyRelation('follow');
|
mid: mid,
|
||||||
}
|
).showFollowSheet();
|
||||||
|
attributeText.value = attributeTextMap[attribute.value] ?? '关注';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关系查询
|
// 关系查询
|
||||||
@ -99,16 +105,10 @@ class MemberController extends GetxController {
|
|||||||
var res = await UserHttp.hasFollow(mid);
|
var res = await UserHttp.hasFollow(mid);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
attribute.value = res['data']['attribute'];
|
attribute.value = res['data']['attribute'];
|
||||||
final Map<int, String> attributeTextMap = {
|
|
||||||
1: '悄悄关注',
|
|
||||||
2: '已关注',
|
|
||||||
6: '已互关',
|
|
||||||
128: '已拉黑',
|
|
||||||
};
|
|
||||||
attributeText.value = attributeTextMap[attribute.value] ?? '关注';
|
|
||||||
if (res['data']['special'] == 1) {
|
if (res['data']['special'] == 1) {
|
||||||
attributeText.value = '特别关注';
|
attributeText.value = '特别关注';
|
||||||
}
|
}
|
||||||
|
attributeText.value = attributeTextMap[attribute.value] ?? '关注';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,66 +118,15 @@ class MemberController extends GetxController {
|
|||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
modifyRelation('block');
|
final String actionType = attribute.value == 128 ? 'remove' : 'block';
|
||||||
}
|
attribute.value = await FollowUtils(
|
||||||
|
|
||||||
// 合并关注/取关和拉黑逻辑
|
|
||||||
Future modifyRelation(String actionType) async {
|
|
||||||
String contentText;
|
|
||||||
int act;
|
|
||||||
if (actionType == 'follow') {
|
|
||||||
contentText = memberInfo.value.isFollowed! ? '确定取消关注UP主?' : '确定关注UP主?';
|
|
||||||
act = memberInfo.value.isFollowed! ? 2 : 1;
|
|
||||||
} else if (actionType == 'block') {
|
|
||||||
contentText = attribute.value != 128 ? '确定拉黑UP主?' : '确定从黑名单移除UP主?';
|
|
||||||
act = attribute.value != 128 ? 5 : 6;
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
showDialog(
|
|
||||||
context: Get.context!,
|
context: Get.context!,
|
||||||
builder: (BuildContext context) {
|
followStatus: attribute.value,
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('提示'),
|
|
||||||
content: Text(contentText),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
child: Text(
|
|
||||||
'点错了',
|
|
||||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
var res = await VideoHttp.relationMod(
|
|
||||||
mid: mid,
|
mid: mid,
|
||||||
act: act,
|
).modifyRelationFetch(actionType, isDirect: true);
|
||||||
reSrc: 11,
|
if (attribute.value != -1) {
|
||||||
);
|
attributeText.value = attributeTextMap[attribute.value] ?? '关注';
|
||||||
SmartDialog.dismiss();
|
|
||||||
if (res['status']) {
|
|
||||||
if (actionType == 'follow') {
|
|
||||||
memberInfo.value.isFollowed = !memberInfo.value.isFollowed!;
|
|
||||||
} else if (actionType == 'block') {
|
|
||||||
attribute.value = attribute.value != 128 ? 128 : 0;
|
|
||||||
attributeText.value = attribute.value == 128 ? '已拉黑' : '关注';
|
|
||||||
memberInfo.value.isFollowed = false;
|
|
||||||
}
|
}
|
||||||
relationSearch();
|
|
||||||
if (context.mounted) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
memberInfo.update((val) {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: const Text('确定'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void shareUser() {
|
void shareUser() {
|
||||||
|
|||||||
@ -37,6 +37,7 @@ class MemberSearchController extends GetxController {
|
|||||||
} else {
|
} else {
|
||||||
Get.back();
|
Get.back();
|
||||||
}
|
}
|
||||||
|
loadingStatus.value = 'init';
|
||||||
}
|
}
|
||||||
|
|
||||||
void onChange(value) {
|
void onChange(value) {
|
||||||
@ -76,7 +77,7 @@ class MemberSearchController extends GetxController {
|
|||||||
archivePn += 1;
|
archivePn += 1;
|
||||||
hasRequest = true;
|
hasRequest = true;
|
||||||
}
|
}
|
||||||
// loadingStatus.value = 'finish';
|
loadingStatus.value = 'finish';
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -249,6 +249,15 @@ class _StyleSettingState extends State<StyleSetting> {
|
|||||||
'当前模式:${settingController.themeType.value.description}',
|
'当前模式:${settingController.themeType.value.description}',
|
||||||
style: subTitleStyle)),
|
style: subTitleStyle)),
|
||||||
),
|
),
|
||||||
|
SetSwitchItem(
|
||||||
|
title: '纯黑模式',
|
||||||
|
subTitle: '深色模式时使用纯黑色背景,适用于OLED屏幕',
|
||||||
|
setKey: SettingBoxKey.enablePureBlack,
|
||||||
|
defaultVal: false,
|
||||||
|
callFn: (bool val) => {
|
||||||
|
if (val && Get.isDarkMode) {Get.appUpdate()}
|
||||||
|
},
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: false,
|
dense: false,
|
||||||
onTap: () => settingController.setDynamicBadgeMode(context),
|
onTap: () => settingController.setDynamicBadgeMode(context),
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import 'package:pilipala/pages/video/detail/controller.dart';
|
|||||||
import 'package:pilipala/pages/video/detail/reply/index.dart';
|
import 'package:pilipala/pages/video/detail/reply/index.dart';
|
||||||
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
|
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
|
import 'package:pilipala/utils/follow.dart';
|
||||||
import 'package:pilipala/utils/global_data_cache.dart';
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
import 'package:pilipala/utils/id_utils.dart';
|
import 'package:pilipala/utils/id_utils.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
@ -26,7 +27,6 @@ import '../../../../common/pages_bottom_sheet.dart';
|
|||||||
import '../../../../models/common/video_episode_type.dart';
|
import '../../../../models/common/video_episode_type.dart';
|
||||||
import '../../../../utils/drawer.dart';
|
import '../../../../utils/drawer.dart';
|
||||||
import '../related/index.dart';
|
import '../related/index.dart';
|
||||||
import 'widgets/group_panel.dart';
|
|
||||||
|
|
||||||
class VideoIntroController extends GetxController {
|
class VideoIntroController extends GetxController {
|
||||||
VideoIntroController({required this.bvid});
|
VideoIntroController({required this.bvid});
|
||||||
@ -50,7 +50,7 @@ class VideoIntroController extends GetxController {
|
|||||||
List addMediaIdsNew = [];
|
List addMediaIdsNew = [];
|
||||||
List delMediaIdsNew = [];
|
List delMediaIdsNew = [];
|
||||||
// 关注状态 默认未关注
|
// 关注状态 默认未关注
|
||||||
RxMap followStatus = {}.obs;
|
RxInt followStatus = (-1).obs;
|
||||||
RxInt lastPlayCid = 0.obs;
|
RxInt lastPlayCid = 0.obs;
|
||||||
UserInfoData? userInfo;
|
UserInfoData? userInfo;
|
||||||
RxList<VideoTagItem> videoTags = <VideoTagItem>[].obs;
|
RxList<VideoTagItem> videoTags = <VideoTagItem>[].obs;
|
||||||
@ -66,6 +66,8 @@ class VideoIntroController extends GetxController {
|
|||||||
late bool enableRelatedVideo;
|
late bool enableRelatedVideo;
|
||||||
UgcSeason? ugcSeason;
|
UgcSeason? ugcSeason;
|
||||||
RxList<Part> pages = <Part>[].obs;
|
RxList<Part> pages = <Part>[].obs;
|
||||||
|
// 默认原创视频
|
||||||
|
int copyright = 1;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -94,6 +96,7 @@ class VideoIntroController extends GetxController {
|
|||||||
videoDetail.value = result['data']!;
|
videoDetail.value = result['data']!;
|
||||||
ugcSeason = result['data']!.ugcSeason;
|
ugcSeason = result['data']!.ugcSeason;
|
||||||
pages.value = result['data']!.pages!;
|
pages.value = result['data']!.pages!;
|
||||||
|
copyright = result['data']!.copyright!;
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
lastPlayCid.value = cid ?? videoDetail.value.cid!;
|
lastPlayCid.value = cid ?? videoDetail.value.cid!;
|
||||||
}
|
}
|
||||||
@ -215,7 +218,7 @@ class VideoIntroController extends GetxController {
|
|||||||
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 24),
|
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 24),
|
||||||
content: Column(
|
content: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [1, 2]
|
children: (copyright == 2 ? [1] : [1, 2])
|
||||||
.map(
|
.map(
|
||||||
(e) => ListTile(
|
(e) => ListTile(
|
||||||
title: Padding(
|
title: Padding(
|
||||||
@ -334,113 +337,23 @@ class VideoIntroController extends GetxController {
|
|||||||
}
|
}
|
||||||
var result = await VideoHttp.hasFollow(mid: videoDetail.value.owner!.mid!);
|
var result = await VideoHttp.hasFollow(mid: videoDetail.value.owner!.mid!);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
followStatus.value = result['data'];
|
followStatus.value = result['data']['attribute'];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关注/取关up
|
// 关注/取关up
|
||||||
Future actionRelationMod() async {
|
Future actionRelationMod(BuildContext context) async {
|
||||||
feedBack();
|
feedBack();
|
||||||
if (userInfo == null) {
|
if (userInfo == null) {
|
||||||
SmartDialog.showToast('账号未登录');
|
SmartDialog.showToast('账号未登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final int currentStatus = followStatus['attribute'];
|
followStatus.value = await FollowUtils(
|
||||||
if (currentStatus == 128) {
|
context: context,
|
||||||
modifyRelation('block', currentStatus);
|
followStatus: followStatus.value,
|
||||||
} else {
|
mid: videoDetail.value.owner!.mid!,
|
||||||
modifyRelation('follow', currentStatus);
|
).showFollowSheet();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 操作用户关系
|
|
||||||
Future modifyRelation(String actionType, int currentStatus) async {
|
|
||||||
final int mid = videoDetail.value.owner!.mid!;
|
|
||||||
String contentText;
|
|
||||||
int act;
|
|
||||||
if (actionType == 'follow') {
|
|
||||||
contentText = currentStatus != 0 ? '确定取消关注UP主?' : '确定关注UP主?';
|
|
||||||
act = currentStatus != 0 ? 2 : 1;
|
|
||||||
} else if (actionType == 'block') {
|
|
||||||
contentText = '确定从黑名单移除UP主?';
|
|
||||||
act = 6;
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
showDialog(
|
|
||||||
context: Get.context!,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
final Color outline = Theme.of(Get.context!).colorScheme.outline;
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('提示'),
|
|
||||||
content: Text(contentText),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: Navigator.of(context).pop,
|
|
||||||
child: Text('点错了', style: TextStyle(color: outline)),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => modifyRelationFetch(
|
|
||||||
context,
|
|
||||||
mid,
|
|
||||||
act,
|
|
||||||
currentStatus,
|
|
||||||
actionType,
|
|
||||||
),
|
|
||||||
child: const Text('确定'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 操作用户关系Future
|
|
||||||
Future modifyRelationFetch(
|
|
||||||
BuildContext context,
|
|
||||||
mid,
|
|
||||||
act,
|
|
||||||
currentStatus,
|
|
||||||
actionType,
|
|
||||||
) async {
|
|
||||||
var res = await VideoHttp.relationMod(mid: mid, act: act, reSrc: 11);
|
|
||||||
if (context.mounted) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
if (res['status']) {
|
|
||||||
if (actionType == 'follow') {
|
|
||||||
final Map<int, int> statusMap = {
|
|
||||||
0: 2,
|
|
||||||
2: 0,
|
|
||||||
};
|
|
||||||
late int actionStatus;
|
|
||||||
actionStatus = statusMap[currentStatus] ?? 0;
|
|
||||||
followStatus['attribute'] = actionStatus;
|
|
||||||
if (currentStatus == 0 && Get.context!.mounted) {
|
|
||||||
ScaffoldMessenger.of(Get.context!).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: const Text('关注成功'),
|
|
||||||
duration: const Duration(seconds: 2),
|
|
||||||
action: SnackBarAction(
|
|
||||||
label: '设置分组',
|
|
||||||
onPressed: setFollowGroup,
|
|
||||||
),
|
|
||||||
showCloseIcon: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
SmartDialog.showToast('取消关注成功');
|
|
||||||
}
|
|
||||||
} else if (actionType == 'block') {
|
|
||||||
followStatus['attribute'] = 0;
|
|
||||||
SmartDialog.showToast('取消拉黑成功');
|
|
||||||
}
|
|
||||||
followStatus.refresh();
|
|
||||||
} else {
|
|
||||||
SmartDialog.showToast(res['msg']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改分P或番剧分集
|
// 修改分P或番剧分集
|
||||||
@ -565,33 +478,33 @@ class VideoIntroController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置关注分组
|
// 设置关注分组
|
||||||
void setFollowGroup() async {
|
// void setFollowGroup() async {
|
||||||
final mediaQueryData = MediaQuery.of(Get.context!);
|
// final mediaQueryData = MediaQuery.of(Get.context!);
|
||||||
final contentHeight = mediaQueryData.size.height - kToolbarHeight;
|
// final contentHeight = mediaQueryData.size.height - kToolbarHeight;
|
||||||
final double initialChildSize =
|
// final double initialChildSize =
|
||||||
(contentHeight - Get.width * 9 / 16) / contentHeight;
|
// (contentHeight - Get.width * 9 / 16) / contentHeight;
|
||||||
await showModalBottomSheet(
|
// await showModalBottomSheet(
|
||||||
context: Get.context!,
|
// context: Get.context!,
|
||||||
useSafeArea: true,
|
// useSafeArea: true,
|
||||||
isScrollControlled: true,
|
// isScrollControlled: true,
|
||||||
builder: (BuildContext context) {
|
// builder: (BuildContext context) {
|
||||||
return DraggableScrollableSheet(
|
// return DraggableScrollableSheet(
|
||||||
initialChildSize: initialChildSize,
|
// initialChildSize: initialChildSize,
|
||||||
minChildSize: 0,
|
// minChildSize: 0,
|
||||||
maxChildSize: 1,
|
// maxChildSize: 1,
|
||||||
snap: true,
|
// snap: true,
|
||||||
expand: false,
|
// expand: false,
|
||||||
snapSizes: [initialChildSize],
|
// snapSizes: [initialChildSize],
|
||||||
builder: (BuildContext context, ScrollController scrollController) {
|
// builder: (BuildContext context, ScrollController scrollController) {
|
||||||
return GroupPanel(
|
// return GroupPanel(
|
||||||
mid: videoDetail.value.owner!.mid!,
|
// mid: videoDetail.value.owner!.mid!,
|
||||||
scrollController: scrollController,
|
// scrollController: scrollController,
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
// ai总结
|
// ai总结
|
||||||
Future aiConclusion() async {
|
Future aiConclusion() async {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/common/constants.dart';
|
import 'package:pilipala/common/constants.dart';
|
||||||
import 'package:pilipala/common/skeleton/video_intro.dart';
|
import 'package:pilipala/common/skeleton/video_intro.dart';
|
||||||
|
import 'package:pilipala/common/widgets/badge.dart';
|
||||||
import 'package:pilipala/common/widgets/http_error.dart';
|
import 'package:pilipala/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/pages/video/detail/index.dart';
|
import 'package:pilipala/pages/video/detail/index.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
@ -17,6 +18,7 @@ import 'package:pilipala/models/video_detail_res.dart';
|
|||||||
import 'package:pilipala/pages/video/detail/introduction/controller.dart';
|
import 'package:pilipala/pages/video/detail/introduction/controller.dart';
|
||||||
import 'package:pilipala/pages/video/detail/widgets/ai_detail.dart';
|
import 'package:pilipala/pages/video/detail/widgets/ai_detail.dart';
|
||||||
import 'package:pilipala/utils/feed_back.dart';
|
import 'package:pilipala/utils/feed_back.dart';
|
||||||
|
import 'package:pilipala/utils/follow.dart';
|
||||||
import 'package:pilipala/utils/global_data_cache.dart';
|
import 'package:pilipala/utils/global_data_cache.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';
|
||||||
@ -264,6 +266,26 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final ThemeData t = Theme.of(context);
|
final ThemeData t = Theme.of(context);
|
||||||
final Color outline = t.colorScheme.outline;
|
final Color outline = t.colorScheme.outline;
|
||||||
|
const TextStyle titleStyle = TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
);
|
||||||
|
|
||||||
|
TextSpan titltWidget = TextSpan(
|
||||||
|
children: [
|
||||||
|
WidgetSpan(
|
||||||
|
child: Visibility(
|
||||||
|
visible: widget.videoDetail!.copyright == 2,
|
||||||
|
child: const PBadge(text: '转载', type: 'color'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const TextSpan(text: ' '),
|
||||||
|
TextSpan(
|
||||||
|
text: widget.videoDetail!.title!,
|
||||||
|
style: titleStyle,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
return SliverPadding(
|
return SliverPadding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: StyleString.safeSpace,
|
left: StyleString.safeSpace,
|
||||||
@ -285,25 +307,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
},
|
},
|
||||||
child: ExpandablePanel(
|
child: ExpandablePanel(
|
||||||
controller: _expandableCtr,
|
controller: _expandableCtr,
|
||||||
collapsed: Text(
|
collapsed: Text.rich(softWrap: true, maxLines: 2, titltWidget),
|
||||||
widget.videoDetail!.title!,
|
expanded: Text.rich(softWrap: true, maxLines: 10, titltWidget),
|
||||||
softWrap: true,
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
expanded: Text(
|
|
||||||
widget.videoDetail!.title!,
|
|
||||||
softWrap: true,
|
|
||||||
maxLines: 10,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
theme: const ExpandableThemeData(
|
theme: const ExpandableThemeData(
|
||||||
animationDuration: Duration(milliseconds: 300),
|
animationDuration: Duration(milliseconds: 300),
|
||||||
scrollAnimationDuration: Duration(milliseconds: 300),
|
scrollAnimationDuration: Duration(milliseconds: 300),
|
||||||
@ -454,14 +459,14 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
Obx(
|
Obx(
|
||||||
() {
|
() {
|
||||||
final int attr =
|
final int attr =
|
||||||
videoIntroController.followStatus['attribute'] ?? 0;
|
videoIntroController.followStatus.value;
|
||||||
return videoIntroController.followStatus.isEmpty
|
return attr == -1
|
||||||
? const SizedBox()
|
? const SizedBox()
|
||||||
: SizedBox(
|
: SizedBox(
|
||||||
height: 32,
|
height: 32,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed:
|
onPressed: () => videoIntroController
|
||||||
videoIntroController.actionRelationMod,
|
.actionRelationMod(context),
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 8,
|
left: 8,
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
||||||
import 'package:floating/floating.dart';
|
import 'package:floating/floating.dart';
|
||||||
@ -76,7 +77,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
getStatusHeight();
|
getStatusHeight();
|
||||||
heroTag = Get.arguments['heroTag'];
|
heroTag = Get.arguments['heroTag'];
|
||||||
vdCtr = Get.put(VideoDetailController(), tag: heroTag);
|
vdCtr = Get.put(VideoDetailController(), tag: heroTag);
|
||||||
vdCtr.sheetHeight.value = localCache.get('sheetHeight');
|
vdCtr.sheetHeight.value = GlobalDataCache.sheetHeight;
|
||||||
videoIntroController = Get.put(
|
videoIntroController = Get.put(
|
||||||
VideoIntroController(bvid: Get.parameters['bvid']!),
|
VideoIntroController(bvid: Get.parameters['bvid']!),
|
||||||
tag: heroTag);
|
tag: heroTag);
|
||||||
@ -223,8 +224,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
void _extendNestCtrListener() {
|
void _extendNestCtrListener() {
|
||||||
final double offset = _extendNestCtr.position.pixels;
|
final double offset = _extendNestCtr.position.pixels;
|
||||||
if (vdCtr.videoDirection.value == 'horizontal') {
|
if (vdCtr.videoDirection.value == 'horizontal') {
|
||||||
vdCtr.sheetHeight.value =
|
vdCtr.sheetHeight.value = max(GlobalDataCache.sheetHeight,
|
||||||
Get.size.height - videoHeight - statusBarHeight + offset;
|
Get.size.height - videoHeight - statusBarHeight + offset);
|
||||||
appbarStream.add(offset);
|
appbarStream.add(offset);
|
||||||
} else {
|
} else {
|
||||||
if (offset > (Get.size.width * 22 / 16 - videoHeight)) {
|
if (offset > (Get.size.width * 22 / 16 - videoHeight)) {
|
||||||
@ -502,7 +503,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final sizeContext = MediaQuery.sizeOf(context);
|
final sizeContext = MediaQuery.sizeOf(context);
|
||||||
final _context = MediaQuery.of(context);
|
final orientation = MediaQuery.orientationOf(context);
|
||||||
late final double verticalHeight = sizeContext.width * 22 / 16;
|
late final double verticalHeight = sizeContext.width * 22 / 16;
|
||||||
late double defaultVideoHeight = vdCtr.videoDirection.value == 'vertical'
|
late double defaultVideoHeight = vdCtr.videoDirection.value == 'vertical'
|
||||||
? verticalHeight
|
? verticalHeight
|
||||||
@ -517,12 +518,12 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 竖屏
|
// 竖屏
|
||||||
final bool isPortrait = _context.orientation == Orientation.portrait;
|
final bool isPortrait = orientation == Orientation.portrait;
|
||||||
// 横屏
|
// 横屏
|
||||||
final bool isLandscape = _context.orientation == Orientation.landscape;
|
final bool isLandscape = orientation == Orientation.landscape;
|
||||||
final Rx<bool> isFullScreen = plPlayerController?.isFullScreen ?? false.obs;
|
final Rx<bool> isFullScreen = plPlayerController?.isFullScreen ?? false.obs;
|
||||||
// 全屏时高度撑满
|
// 全屏时高度撑满
|
||||||
if (isLandscape || isFullScreen.value == true) {
|
if (isLandscape || isFullScreen.value) {
|
||||||
videoHeight.value = Get.size.height;
|
videoHeight.value = Get.size.height;
|
||||||
enterFullScreen();
|
enterFullScreen();
|
||||||
} else {
|
} else {
|
||||||
@ -634,10 +635,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget childWhenDisabled = SafeArea(
|
Widget childWhenDisabled = SafeArea(
|
||||||
top: MediaQuery.of(context).orientation == Orientation.portrait &&
|
top: isPortrait && isFullScreen.value,
|
||||||
plPlayerController?.isFullScreen.value == true,
|
bottom: isPortrait && isFullScreen.value,
|
||||||
bottom: MediaQuery.of(context).orientation == Orientation.portrait &&
|
|
||||||
plPlayerController?.isFullScreen.value == true,
|
|
||||||
left: false,
|
left: false,
|
||||||
right: false,
|
right: false,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
@ -660,22 +659,25 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
return <Widget>[
|
return <Widget>[
|
||||||
Obx(
|
Obx(
|
||||||
() {
|
() {
|
||||||
final Orientation orientation =
|
final bool isLandscape =
|
||||||
MediaQuery.of(context).orientation;
|
MediaQuery.orientationOf(context) ==
|
||||||
|
Orientation.landscape;
|
||||||
final bool isFullScreen =
|
final bool isFullScreen =
|
||||||
plPlayerController?.isFullScreen.value == true;
|
plPlayerController?.isFullScreen.value ?? false;
|
||||||
final double expandedHeight =
|
|
||||||
orientation == Orientation.landscape || isFullScreen
|
late double expandedHeight;
|
||||||
? (MediaQuery.sizeOf(context).height -
|
if (isLandscape || isFullScreen) {
|
||||||
(orientation == Orientation.landscape
|
|
||||||
? 0
|
|
||||||
: MediaQuery.of(context).padding.top))
|
|
||||||
: videoHeight.value;
|
|
||||||
if (orientation == Orientation.landscape ||
|
|
||||||
isFullScreen) {
|
|
||||||
enterFullScreen();
|
enterFullScreen();
|
||||||
|
expandedHeight = (MediaQuery.sizeOf(context).height -
|
||||||
|
(isLandscape
|
||||||
|
? 0
|
||||||
|
: MediaQuery.paddingOf(context).top));
|
||||||
} else {
|
} else {
|
||||||
exitFullScreen();
|
exitFullScreen();
|
||||||
|
if (vdCtr.videoDirection.value == 'vertical') {
|
||||||
|
videoHeight.value = verticalHeight;
|
||||||
|
}
|
||||||
|
expandedHeight = videoHeight.value;
|
||||||
}
|
}
|
||||||
return SliverAppBar(
|
return SliverAppBar(
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
@ -687,21 +689,24 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
flexibleSpace: SizedBox.expand(
|
flexibleSpace: SizedBox.expand(
|
||||||
child: PopScope(
|
child: PopScope(
|
||||||
canPop:
|
canPop: !isFullScreen,
|
||||||
plPlayerController?.isFullScreen.value != true,
|
|
||||||
onPopInvoked: (bool didPop) {
|
onPopInvoked: (bool didPop) {
|
||||||
if (plPlayerController?.controlsLock.value ==
|
if (plPlayerController != null) {
|
||||||
true) {
|
if (plPlayerController!.controlsLock.value) {
|
||||||
plPlayerController?.onLockControl(false);
|
plPlayerController!.onLockControl(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plPlayerController?.isFullScreen.value ==
|
if (isFullScreen) {
|
||||||
true) {
|
|
||||||
plPlayerController!
|
plPlayerController!
|
||||||
.triggerFullScreen(status: false);
|
.triggerFullScreen(status: false);
|
||||||
|
if (vdCtr.videoDirection.value ==
|
||||||
|
'vertical') {
|
||||||
|
videoHeight.value = verticalHeight;
|
||||||
}
|
}
|
||||||
if (MediaQuery.of(context).orientation ==
|
}
|
||||||
Orientation.landscape) {
|
}
|
||||||
|
|
||||||
|
if (isLandscape) {
|
||||||
verticalScreen();
|
verticalScreen();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -746,9 +751,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
|
|
||||||
/// 不收回
|
/// 不收回
|
||||||
pinnedHeaderSliverHeightBuilder: () {
|
pinnedHeaderSliverHeightBuilder: () {
|
||||||
return MediaQuery.of(context).orientation ==
|
return isLandscape || isFullScreen.value
|
||||||
Orientation.landscape ||
|
|
||||||
plPlayerController?.isFullScreen.value == true
|
|
||||||
? MediaQuery.sizeOf(context).height
|
? MediaQuery.sizeOf(context).height
|
||||||
: playerStatus.value != PlayerStatus.playing
|
: playerStatus.value != PlayerStatus.playing
|
||||||
? kToolbarHeight
|
? kToolbarHeight
|
||||||
|
|||||||
@ -45,6 +45,7 @@ class WhisperController extends GetxController {
|
|||||||
if (isLoading) return;
|
if (isLoading) return;
|
||||||
var res = await MsgHttp.sessionList(
|
var res = await MsgHttp.sessionList(
|
||||||
endTs: type == 'onLoad' ? sessionList.last.sessionTs : null);
|
endTs: type == 'onLoad' ? sessionList.last.sessionTs : null);
|
||||||
|
try {
|
||||||
if (res['status'] &&
|
if (res['status'] &&
|
||||||
res['data'].sessionList != null &&
|
res['data'].sessionList != null &&
|
||||||
res['data'].sessionList.isNotEmpty) {
|
res['data'].sessionList.isNotEmpty) {
|
||||||
@ -75,6 +76,13 @@ class WhisperController extends GetxController {
|
|||||||
sessionList.value = res['data'].sessionList;
|
sessionList.value = res['data'].sessionList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
res = {
|
||||||
|
'status': false,
|
||||||
|
'message': err.toString(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,24 @@ class _WhisperPageState extends State<WhisperPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('消息')),
|
appBar: AppBar(
|
||||||
|
title: const Text('消息'),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.open_in_browser_rounded,
|
||||||
|
color: Theme.of(context).colorScheme.primary),
|
||||||
|
tooltip: '用浏览器打开',
|
||||||
|
onPressed: () {
|
||||||
|
Get.toNamed('/webview', parameters: {
|
||||||
|
'url': 'https://message.bilibili.com',
|
||||||
|
'type': 'whisper',
|
||||||
|
'pageTitle': '消息中心',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12)
|
||||||
|
],
|
||||||
|
),
|
||||||
body: RefreshIndicator(
|
body: RefreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
_whisperController.unread();
|
_whisperController.unread();
|
||||||
|
|||||||
@ -521,6 +521,7 @@ class SystemNotice extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Map content = item.content ?? '';
|
Map content = item.content ?? '';
|
||||||
|
Color primary = Theme.of(context).colorScheme.primary;
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
@ -557,12 +558,35 @@ class SystemNotice extends StatelessWidget {
|
|||||||
.labelSmall!
|
.labelSmall!
|
||||||
.copyWith(color: Theme.of(context).colorScheme.outline),
|
.copyWith(color: Theme.of(context).colorScheme.outline),
|
||||||
),
|
),
|
||||||
Divider(
|
Divider(color: primary.withOpacity(0.05)),
|
||||||
color: Theme.of(context).colorScheme.primary.withOpacity(0.05),
|
SelectableText(content['text']),
|
||||||
|
if (content['jump_text'] != null &&
|
||||||
|
content['jump_uri'] != null) ...[
|
||||||
|
Divider(color: primary.withOpacity(0.05)),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Get.toNamed('/webview', parameters: {
|
||||||
|
'url': content['jump_uri'],
|
||||||
|
'type': 'url',
|
||||||
|
'pageTitle': content['jump_text'] == ''
|
||||||
|
? '查看详情'
|
||||||
|
: content['jump_text'],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
style: ButtonStyle(
|
||||||
|
backgroundColor:
|
||||||
|
MaterialStateProperty.resolveWith((states) {
|
||||||
|
return primary.withAlpha(20);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
SelectableText(
|
child: Text(content['jump_text'] == ''
|
||||||
content['text'],
|
? '查看详情'
|
||||||
)
|
: content['jump_text']),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
207
lib/utils/follow.dart
Normal file
207
lib/utils/follow.dart
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:pilipala/common/widgets/drag_handle.dart';
|
||||||
|
import 'package:pilipala/common/widgets/group_panel.dart';
|
||||||
|
import 'package:pilipala/http/video.dart';
|
||||||
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
|
|
||||||
|
class FollowUtils {
|
||||||
|
final BuildContext context;
|
||||||
|
final int followStatus;
|
||||||
|
final int mid;
|
||||||
|
|
||||||
|
FollowUtils({
|
||||||
|
required this.context,
|
||||||
|
required this.followStatus,
|
||||||
|
required this.mid,
|
||||||
|
});
|
||||||
|
|
||||||
|
// static final Map<int, Map<String, dynamic>> followMap = {
|
||||||
|
// // 未关注
|
||||||
|
// 0: {
|
||||||
|
// 'desc': '确定关注UP主?',
|
||||||
|
// // 1 关注 5 拉黑
|
||||||
|
// 'act': 1,
|
||||||
|
// },
|
||||||
|
// // 已关注
|
||||||
|
// 2: {
|
||||||
|
// 'desc': '确定取消关注UP主?',
|
||||||
|
// 'act': 2,
|
||||||
|
// },
|
||||||
|
// // 已互粉
|
||||||
|
// 6: {
|
||||||
|
// 'desc': '确定取消关注UP主?',
|
||||||
|
// 'act': 2,
|
||||||
|
// },
|
||||||
|
// // 已拉黑
|
||||||
|
// 128: {
|
||||||
|
// 'desc': '确定从黑名单移除UP主?',
|
||||||
|
// 'act': 6,
|
||||||
|
// },
|
||||||
|
// };
|
||||||
|
|
||||||
|
static final Map<String, Map<String, dynamic>> actionTypeMap = {
|
||||||
|
'remove': {
|
||||||
|
'desc': '确定从黑名单移除UP主?',
|
||||||
|
'tips': '已从黑名单移除',
|
||||||
|
'act': 6,
|
||||||
|
'followStatus': 0,
|
||||||
|
},
|
||||||
|
'unFollow': {
|
||||||
|
'desc': '确定取消关注UP主?',
|
||||||
|
'tips': '已取消关注',
|
||||||
|
'act': 2,
|
||||||
|
'followStatus': 0,
|
||||||
|
},
|
||||||
|
'follow': {
|
||||||
|
'desc': '确定关注UP主?',
|
||||||
|
'tips': '关注成功',
|
||||||
|
'act': 1,
|
||||||
|
'followStatus': 2,
|
||||||
|
},
|
||||||
|
'block': {
|
||||||
|
'desc': '确定拉黑UP主?',
|
||||||
|
'tips': '已拉黑',
|
||||||
|
'act': 5,
|
||||||
|
'followStatus': 128,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
Future<int> showFollowSheet() async {
|
||||||
|
var res = await showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder: (context) {
|
||||||
|
return Padding(
|
||||||
|
padding:
|
||||||
|
EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const DragHandle(),
|
||||||
|
if (followStatus == 128) ...[
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.remove_circle_outline_rounded),
|
||||||
|
onTap: () => modifyRelation('remove'),
|
||||||
|
title: const Text('从黑名单移除'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if ([2, 6].contains(followStatus)) ...[
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.group_add_outlined),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
setFollowGroup();
|
||||||
|
},
|
||||||
|
title: const Text('设置分组'),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.heart_broken_outlined),
|
||||||
|
onTap: () => modifyRelation('unFollow'),
|
||||||
|
title: const Text('取消关注'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
if (followStatus == 0) ...[
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.favorite_border_rounded),
|
||||||
|
onTap: () => modifyRelation('follow'),
|
||||||
|
title: const Text('关注up主'),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.block_rounded),
|
||||||
|
onTap: () => modifyRelation('block'),
|
||||||
|
title: const Text('拉黑up主'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return res ?? followStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 操作用户关系
|
||||||
|
Future modifyRelation(String actionType) async {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
final Color outline = Theme.of(context).colorScheme.outline;
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('提示'),
|
||||||
|
content: Text(actionTypeMap[actionType]!['desc']),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: Navigator.of(context).pop,
|
||||||
|
child: Text('点错了', style: TextStyle(color: outline)),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => modifyRelationFetch(actionType),
|
||||||
|
child: const Text('确定'),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 操作用户关系Future
|
||||||
|
Future<int> modifyRelationFetch(String actionType, {bool? isDirect}) async {
|
||||||
|
if (isDirect != true) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
SmartDialog.showLoading(msg: '请求中');
|
||||||
|
var res = await VideoHttp.relationMod(
|
||||||
|
mid: mid,
|
||||||
|
act: actionTypeMap[actionType]!['act'],
|
||||||
|
reSrc: 11,
|
||||||
|
);
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
if (res['status']) {
|
||||||
|
final int newFollowStatus = actionTypeMap[actionType]!['followStatus'];
|
||||||
|
SmartDialog.showToast(actionTypeMap[actionType]!['tips']);
|
||||||
|
if (context.mounted) {
|
||||||
|
if (isDirect != true) {
|
||||||
|
Navigator.of(context).pop(newFollowStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newFollowStatus;
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
if (context.mounted && isDirect != true) {
|
||||||
|
Navigator.of(context).pop(-1);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置分组
|
||||||
|
Future setFollowGroup() async {
|
||||||
|
final size = MediaQuery.sizeOf(context);
|
||||||
|
final contentHeight = size.height - kToolbarHeight;
|
||||||
|
final double initialChildSize =
|
||||||
|
(contentHeight - size.width * 9 / 16) / contentHeight;
|
||||||
|
await showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
useSafeArea: true,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return DraggableScrollableSheet(
|
||||||
|
initialChildSize: initialChildSize,
|
||||||
|
minChildSize: 0,
|
||||||
|
maxChildSize: 1,
|
||||||
|
snap: true,
|
||||||
|
expand: false,
|
||||||
|
snapSizes: [initialChildSize],
|
||||||
|
builder: (BuildContext context, ScrollController scrollController) {
|
||||||
|
return GroupPanel(
|
||||||
|
mid: GlobalDataCache.userInfo!.mid!,
|
||||||
|
scrollController: scrollController,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,7 +12,6 @@ import 'package:pilipala/http/user.dart';
|
|||||||
import 'package:pilipala/pages/dynamics/index.dart';
|
import 'package:pilipala/pages/dynamics/index.dart';
|
||||||
import 'package:pilipala/pages/home/index.dart';
|
import 'package:pilipala/pages/home/index.dart';
|
||||||
import 'package:pilipala/pages/mine/index.dart';
|
import 'package:pilipala/pages/mine/index.dart';
|
||||||
import 'package:pilipala/utils/cookie.dart';
|
|
||||||
import 'package:pilipala/utils/global_data_cache.dart';
|
import 'package:pilipala/utils/global_data_cache.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
@ -68,7 +67,6 @@ class LoginUtils {
|
|||||||
content = '${content + url}; \n';
|
content = '${content + url}; \n';
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await SetCookie.onSet();
|
|
||||||
final result = await UserHttp.userInfo();
|
final result = await UserHttp.userInfo();
|
||||||
if (result['status'] && result['data'].isLogin) {
|
if (result['status'] && result['data'].isLogin) {
|
||||||
SmartDialog.showToast('登录成功');
|
SmartDialog.showToast('登录成功');
|
||||||
|
|||||||
@ -137,7 +137,8 @@ class SettingBoxKey {
|
|||||||
enableGradientBg = 'enableGradientBg',
|
enableGradientBg = 'enableGradientBg',
|
||||||
enableDynamicSwitch = 'enableDynamicSwitch',
|
enableDynamicSwitch = 'enableDynamicSwitch',
|
||||||
navBarSort = 'navBarSort',
|
navBarSort = 'navBarSort',
|
||||||
actionTypeSort = 'actionTypeSort';
|
actionTypeSort = 'actionTypeSort',
|
||||||
|
enablePureBlack = 'enablePureBlack';
|
||||||
}
|
}
|
||||||
|
|
||||||
class LocalCacheKey {
|
class LocalCacheKey {
|
||||||
|
|||||||
Reference in New Issue
Block a user