Compare commits

..

2 Commits

Author SHA1 Message Date
cb3fd24cf7 merge main 2023-11-12 12:09:16 +08:00
3e8216923f just_audio 2023-09-05 12:40:42 +08:00
132 changed files with 3122 additions and 5185 deletions

View File

@ -36,7 +36,7 @@ jobs:
if: steps.cache-flutter.outputs.cache-hit != 'true'
uses: subosito/flutter-action@v2
with:
flutter-version: 3.16.4
flutter-version: 3.10.6
channel: any
- name: 下载项目依赖

View File

@ -3,23 +3,16 @@
</div>
<div align="center">
<h1>PiliPala</h1>
<div align="center">
![GitHub repo size](https://img.shields.io/github/repo-size/guozhigq/pilipala)
![GitHub Repo stars](https://img.shields.io/github/stars/guozhigq/pilipala)
![GitHub all releases](https://img.shields.io/github/downloads/guozhigq/pilipala/total)
</div>
<p>使用Flutter开发的BiliBili第三方客户端</p>
<img src="https://github.com/guozhigq/pilipala/blob/main/assets/sreenshot/510shots_so.png" width="32%" alt="home" />
<img src="https://github.com/guozhigq/pilipala/blob/main/assets/sreenshot/174shots_so.png" width="32%" alt="home" />
<img src="https://github.com/guozhigq/pilipala/blob/main/assets/sreenshot/850shots_so.png" width="32%" alt="home" />
<br/>
<img src="https://github.com/guozhigq/pilipala/blob/main/assets/sreenshot/main_screen.png" width="96%" alt="home" />
<br/>
<br/>
<img src="https://github.com/guozhigq/pilipala/blob/main/assets/sreenshot/510shots_so.png" width="32%" alt="home" />
<img src="https://github.com/guozhigq/pilipala/blob/main/assets/sreenshot/174shots_so.png" width="32%" alt="home" />
<img src="https://github.com/guozhigq/pilipala/blob/main/assets/sreenshot/850shots_so.png" width="32%" alt="home" />
<br/>
<img src="https://github.com/guozhigq/pilipala/blob/main/assets/sreenshot/main_screen.png" width="96%" alt="home" />
<br/>
</div>
## 开发环境

View File

@ -63,7 +63,6 @@ android {
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
minSdkVersion 19
multiDexEnabled true
}
signingConfigs {

View File

@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.guozhigq.pilipala">
<queries>
<intent>
@ -63,6 +64,27 @@
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- ADD THIS "SERVICE" element -->
<service
android:name="com.ryanheise.audioservice.AudioService"
android:exported="true"
android:foregroundServiceType="mediaPlayback"
tools:ignore="Instantiatable">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>
<!-- ADD THIS "RECEIVER" element -->
<receiver
android:name="com.ryanheise.audioservice.MediaButtonReceiver"
android:exported="true"
tools:ignore="Instantiatable">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
@ -265,4 +287,8 @@
-->
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
</manifest>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

View File

@ -1,11 +0,0 @@
## 1.0.12
### 修复
+ iOS端视频播放时没有声音
+ 超过6分钟弹幕不显示
+ 视频详情页网络异常
更多更新日志可在Github上查看
问题反馈、功能建议请查看「关于」页面。

View File

@ -1,22 +0,0 @@
## 1.0.13
### 新功能
+ 视频详情页稍后再看
+ 发送弹幕 感谢@orz12
+ 消息展示
+ up主页显示获赞数
+ up主页显示合集
+ 视频详情页「ai总结」增加开关
### 修复
+ 首页推荐问题(需要重新登录)
+ 长按倍速逻辑
+ 视频详情页网络异常
### 优化
+ 设置面板样式 感谢@GuMengYu @KoolShow
更多更新日志可在Github上查看
问题反馈、功能建议请查看「关于」页面。

View File

@ -1,28 +0,0 @@
## 1.0.14
圣诞节快乐~ 🎉
大部分内容由@orz12提供,感谢👏
### 修复
+ 全屏弹幕消失
+ iOS全屏/退出全屏视频暂停
+ 个人主页关注状态
+ 视频合集向下滑动UI问题
+ 媒体库滑动底栏不隐藏
+ 个人主页动态加载问题 * 2
+ 未登录状态访问个人主页异常
+ 视频搜索标题特殊字符转义
+ iOS闪退
+ 消息页面夜间模式异常
+ 消息页面含有撤回消息时异常
+ 弹幕速度
### 优化
+ 全屏播放方案优化
+ 弹幕加载逻辑优化
+ 点赞、投币逻辑优化
+ 进度条及播放时间渲染优化
更多更新日志可在Github上查看
问题反馈、功能建议请查看「关于」页面。

View File

@ -38,10 +38,10 @@ post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
deployment_target = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
if !deployment_target.nil? && !deployment_target.empty? && deployment_target.to_f < 12.0
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
'AUDIO_SESSION_MICROPHONE=0'
]
end
end
end

View File

@ -5,8 +5,6 @@ PODS:
- Flutter
- audio_session (0.0.1):
- Flutter
- auto_orientation (0.0.1):
- Flutter
- connectivity_plus (0.0.1):
- Flutter
- ReachabilitySwift
@ -20,8 +18,13 @@ PODS:
- FMDB/standard (2.7.5)
- gt3_flutter_plugin (0.0.8):
- Flutter
<<<<<<< HEAD
- just_audio (0.0.1):
- Flutter
=======
- GT3Captcha-iOS
- GT3Captcha-iOS (0.15.8.3)
>>>>>>> main
- media_kit_libs_ios_video (1.0.4):
- Flutter
- media_kit_native_event_loop (1.0.0):
@ -64,12 +67,16 @@ DEPENDENCIES:
- appscheme (from `.symlinks/plugins/appscheme/ios`)
- audio_service (from `.symlinks/plugins/audio_service/ios`)
- audio_session (from `.symlinks/plugins/audio_session/ios`)
- auto_orientation (from `.symlinks/plugins/auto_orientation/ios`)
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- Flutter (from `Flutter`)
- flutter_volume_controller (from `.symlinks/plugins/flutter_volume_controller/ios`)
<<<<<<< HEAD
- image_gallery_saver (from `.symlinks/plugins/image_gallery_saver/ios`)
- just_audio (from `.symlinks/plugins/just_audio/ios`)
=======
- gt3_flutter_plugin (from `.symlinks/plugins/gt3_flutter_plugin/ios`)
>>>>>>> main
- media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`)
- media_kit_native_event_loop (from `.symlinks/plugins/media_kit_native_event_loop/ios`)
- media_kit_video (from `.symlinks/plugins/media_kit_video/ios`)
@ -101,8 +108,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/audio_service/ios"
audio_session:
:path: ".symlinks/plugins/audio_session/ios"
auto_orientation:
:path: ".symlinks/plugins/auto_orientation/ios"
connectivity_plus:
:path: ".symlinks/plugins/connectivity_plus/ios"
device_info_plus:
@ -111,8 +116,15 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_volume_controller:
:path: ".symlinks/plugins/flutter_volume_controller/ios"
<<<<<<< HEAD
image_gallery_saver:
:path: ".symlinks/plugins/image_gallery_saver/ios"
just_audio:
:path: ".symlinks/plugins/just_audio/ios"
=======
gt3_flutter_plugin:
:path: ".symlinks/plugins/gt3_flutter_plugin/ios"
>>>>>>> main
media_kit_libs_ios_video:
:path: ".symlinks/plugins/media_kit_libs_ios_video/ios"
media_kit_native_event_loop:
@ -152,33 +164,37 @@ SPEC CHECKSUMS:
appscheme: b1c3f8862331cb20430cf9e0e4af85dbc1572ad8
audio_service: f509d65da41b9521a61f1c404dd58651f265a567
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
auto_orientation: 102ed811a5938d52c86520ddd7ecd3a126b5d39d
connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a
device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6
device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_volume_controller: e4d5832f08008180f76e30faf671ffd5a425e529
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
<<<<<<< HEAD
image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
=======
gt3_flutter_plugin: bfa1f26e9a09dc00401514be5ed437f964cabf23
GT3Captcha-iOS: 5e3b1077834d8a9d6f4d64a447a30af3e14affe6
>>>>>>> main
media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1
media_kit_native_event_loop: e6b2ab20cf0746eb1c33be961fcf79667304fa2a
media_kit_video: 5da63f157170e5bf303bf85453b7ef6971218a2e
package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
saver_gallery: 2b4e584106fde2407ab51560f3851564963e6b78
screen_brightness_ios: 715ca807df953bf676d339f11464e438143ee625
share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5
share_plus: 599aa54e4ea31d4b4c0e9c911bcc26c55e791028
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
status_bar_control: 7c84146799e6a076315cc1550f78ef53aae3e446
system_proxy: bec1a5c5af67dd3e3ebf43979400a8756c04cc44
url_launcher_ios: bf5ce03e0e2088bad9cc378ea97fa0ed5b49673b
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
volume_controller: 531ddf792994285c9b17f9d8a7e4dcdd29b3eae9
wakelock_plus: 8b09852c8876491e4b6d179e17dfe2a0b5f60d47
webview_cookie_manager: eaf920722b493bd0f7611b5484771ca53fed03f7
webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a
PODFILE CHECKSUM: 637cd290bed23275b5f5ffcc7eb1e73d0a5fb2be
PODFILE CHECKSUM: fc8a34c4ba2e14d31df90bf03cf419a764f2778c
COCOAPODS: 1.14.3
COCOAPODS: 1.12.1

View File

@ -121,6 +121,7 @@
3DA6FBBC55FDD1E3261D6D67 /* Pods-Runner.release.xcconfig */,
32E2926120A1A8DC0E629BC6 /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
@ -156,7 +157,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
@ -360,7 +361,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
@ -376,7 +377,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = RN352BA826;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
@ -438,7 +439,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@ -487,7 +488,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
@ -505,7 +506,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = RN352BA826;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
@ -528,7 +529,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = RN352BA826;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
@ -16,14 +14,13 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-11" y="-41"/>
</scene>
</scenes>
</document>

View File

@ -103,6 +103,10 @@
</array>
</dict>
</array>
<<<<<<< HEAD
<!-- audio service配置 -->
=======
>>>>>>> main
<key>UIBackgroundModes</key>
<array>
<string>audio</string>

View File

@ -9,11 +9,7 @@ class StyleString {
}
class Constants {
// 27eb53fc9058f8c3 移动端 Android
// 4409e2ce8ffd12b8 TV端
static const String appKey = '4409e2ce8ffd12b8';
// 59b43e04ad6965f34319062b478f83dd TV端
static const String appSec = '59b43e04ad6965f34319062b478f83dd';
static const String appKey = '27eb53fc9058f8c3';
static const String thirdSign = '04224646d1fea004e79606d3b038c84a';
static const String thirdApi =
'https://www.mcbbs.net/template/mcbbs/image/special_photo_bg.png';

View File

@ -1,5 +1,37 @@
import 'package:flutter/material.dart';
// Widget pBadge(
// text,
// context,
// double? top,
// double? right,
// double? bottom,
// double? left, {
// type = 'primary',
// }) {
// Color bgColor = Theme.of(context).colorScheme.primary;
// Color color = Theme.of(context).colorScheme.onPrimary;
// if (type == 'gray') {
// bgColor = Colors.black54.withOpacity(0.4);
// color = Colors.white;
// }
// return Positioned(
// top: top,
// left: left,
// right: right,
// bottom: bottom,
// child: Container(
// padding: const EdgeInsets.symmetric(vertical: 1, horizontal: 6),
// decoration:
// BoxDecoration(borderRadius: BorderRadius.circular(4), color: bgColor),
// child: Text(
// text,
// style: TextStyle(fontSize: 11, color: color),
// ),
// ),
// );
// }
class PBadge extends StatelessWidget {
final String? text;
final double? top;

View File

@ -1,47 +0,0 @@
import 'package:flutter/material.dart';
class ContentContainer extends StatelessWidget {
final Widget? contentWidget;
final Widget? bottomWidget;
final bool isScrollable;
final Clip? childClipBehavior;
const ContentContainer(
{Key? key,
this.contentWidget,
this.bottomWidget,
this.isScrollable = true,
this.childClipBehavior})
: super(key: key);
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return SingleChildScrollView(
clipBehavior: childClipBehavior ?? Clip.hardEdge,
physics: isScrollable ? null : NeverScrollableScrollPhysics(),
child: ConstrainedBox(
constraints: constraints.copyWith(
minHeight: constraints.maxHeight,
maxHeight: double.infinity,
),
child: IntrinsicHeight(
child: Column(
children: <Widget>[
if (contentWidget != null)
Expanded(
child: contentWidget!,
)
else
Spacer(),
if (bottomWidget != null) bottomWidget!,
],
),
),
),
);
},
);
}
}

View File

@ -17,10 +17,6 @@ class VideoCardH extends StatelessWidget {
final Function()? longPress;
final Function()? longPressEnd;
final String source;
final bool showOwner;
final bool showView;
final bool showDanmaku;
final bool showPubdate;
const VideoCardH({
Key? key,
@ -28,10 +24,6 @@ class VideoCardH extends StatelessWidget {
this.longPress,
this.longPressEnd,
this.source = 'normal',
this.showOwner = true,
this.showView = true,
this.showDanmaku = true,
this.showPubdate = false,
}) : super(key: key);
@override
@ -111,14 +103,7 @@ class VideoCardH extends StatelessWidget {
},
),
),
VideoContent(
videoItem: videoItem,
source: source,
showOwner: showOwner,
showView: showView,
showDanmaku: showDanmaku,
showPubdate: showPubdate,
)
VideoContent(videoItem: videoItem, source: source)
],
),
);
@ -134,20 +119,8 @@ class VideoContent extends StatelessWidget {
// ignore: prefer_typing_uninitialized_variables
final videoItem;
final String source;
final bool showOwner;
final bool showView;
final bool showDanmaku;
final bool showPubdate;
const VideoContent({
super.key,
required this.videoItem,
this.source = 'normal',
this.showOwner = true,
this.showView = true,
this.showDanmaku = true,
this.showPubdate = false,
});
const VideoContent(
{super.key, required this.videoItem, this.source = 'normal'});
@override
Widget build(BuildContext context) {
@ -206,40 +179,34 @@ class VideoContent extends StatelessWidget {
// ),
// ),
// const SizedBox(height: 4),
if (showPubdate)
Text(
Utils.dateFormat(videoItem.pubdate!),
style: TextStyle(
fontSize: 11, color: Theme.of(context).colorScheme.outline),
),
if (showOwner)
Row(
children: [
Text(
videoItem.owner.name,
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize,
color: Theme.of(context).colorScheme.outline,
),
),
],
),
Row(
children: [
if (showView) ...[
StatView(
theme: 'gray',
view: videoItem.stat.view,
Text(
videoItem.owner.name,
style: TextStyle(
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
color: Theme.of(context).colorScheme.outline,
),
const SizedBox(width: 8),
],
if (showDanmaku)
StatDanMu(
theme: 'gray',
danmu: videoItem.stat.danmaku,
),
),
],
),
Row(
children: [
StatView(
theme: 'gray',
view: videoItem.stat.view,
),
const SizedBox(width: 8),
StatDanMu(
theme: 'gray',
danmu: videoItem.stat.danmaku,
),
// Text(
// Utils.dateFormat(videoItem.pubdate!),
// style: TextStyle(
// fontSize: 11,
// color: Theme.of(context).colorScheme.outline),
// )
const Spacer(),
// SizedBox(
// width: 20,

View File

@ -333,10 +333,8 @@ class VideoStat extends StatelessWidget {
color: Theme.of(context).colorScheme.outline,
),
children: [
if (videoItem.stat.view != '-')
TextSpan(text: '${videoItem.stat.view}观看'),
if (videoItem.stat.danmu != '-')
TextSpan(text: '${videoItem.stat.danmu}弹幕'),
TextSpan(text: '${videoItem.stat.view}观看'),
TextSpan(text: '${videoItem.stat.danmu}弹幕'),
],
),
);

View File

@ -97,8 +97,8 @@ class Api {
// 操作用户关系
static const String relationMod = '/x/relation/modify';
// 相互关系查询 // 失效
// static const String relationSearch = '/x/space/wbi/acc/relation';
// 相互关系查询
static const String relationSearch = '/x/space/wbi/acc/relation';
// 评论列表
// https://api.bilibili.com/x/v2/reply/main?csrf=6e22efc1a47225ea25f901f922b5cfdd&mode=3&oid=254175381&pagination_str=%7B%22offset%22:%22%22%7D&plat=1&seek_rpid=0&type=11
@ -215,7 +215,7 @@ class Api {
// 粉丝
// vmid 用户id pn 页码 ps 每页个数最大50 order: desc
// order_type 排序规则 最近访问传空,最常访问传 attention
static const String fans = '/x/relation/fans';
static const String fans = 'https://api.bilibili.com/x/relation/fans';
// 直播
// ?page=1&page_size=30&platform=web
@ -312,10 +312,6 @@ class Api {
static const String webDanmaku = '/x/v2/dm/web/seg.so';
//发送视频弹幕
//https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/danmaku/action.md
static const String shootDanmaku = '/x/v2/dm/post';
// up主分组
static const String followUpTag = '/x/relation/tags';
@ -326,51 +322,6 @@ class Api {
// 获取指定分组下的up
static const String followUpGroup = '/x/relation/tag';
/// 私聊
/// 'https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions?
/// session_type=1&
/// group_fold=1&
/// unfollow_fold=0&
/// sort_rule=2&
/// build=0&
/// mobi_app=web&
/// w_rid=8641d157fb9a9255eb2159f316ee39e2&
/// wts=1697305010
static const String sessionList =
'https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions';
/// 私聊用户信息
/// uids
/// build=0&mobi_app=web
static const String sessionAccountList =
'https://api.vc.bilibili.com/account/v1/user/cards';
/// https://api.vc.bilibili.com/svr_sync/v1/svr_sync/fetch_session_msgs?
/// talker_id=400787461&
/// session_type=1&
/// size=20&
/// sender_device_id=1&
/// build=0&
/// mobi_app=web&
/// web_location=333.1296&
/// w_rid=cfe3bf58c9fe181bbf4dd6c75175e6b0&
/// wts=1697350697
static const String sessionMsg =
'https://api.vc.bilibili.com/svr_sync/v1/svr_sync/fetch_session_msgs';
/// 标记已读 POST
/// talker_id:
/// session_type: 1
/// ack_seqno: 920224140918926
/// build: 0
/// mobi_app: web
/// csrf_token:
/// csrf:
static const String updateAck =
'https://api.vc.bilibili.com/session_svr/v1/session_svr/update_ack';
// 获取某个动态详情
// timezone_offset=-480
// id=849312409672744983
@ -421,49 +372,4 @@ class Api {
/// local_id
static const getWebKey =
'https://passport.bilibili.com/x/passport-login/web/key';
/// cookie转access_key
static const cookieToKey =
'https://passport.bilibili.com/x/passport-tv-login/h5/qrcode/confirm';
/// 申请二维码(TV端)
static const getTVCode =
'https://passport.snm0516.aisee.tv/x/passport-tv-login/qrcode/auth_code';
///扫码登录TV端
static const qrcodePoll =
'https://passport.bilibili.com/x/passport-tv-login/qrcode/poll';
/// 置顶视频
static const getTopVideoApi = '/x/space/top/arc';
/// 主页 - 最近投币的视频
/// vmid
/// gaia_source = main_web
/// web_location
/// w_rid
/// wts
static const getRecentCoinVideoApi = '/x/space/coin/video';
/// 最近点赞的视频
static const getRecentLikeVideoApi = '/x/space/like/video';
/// 最近追番
static const getRecentBangumiApi = '/x/space/bangumi/follow/list';
/// 用户专栏
static const getMemberSeasonsApi = '/x/polymer/web-space/home/seasons_series';
/// 获赞数 播放数
/// mid
static const getMemberViewApi = '/x/space/upstat';
/// 查询某个专栏
/// mid
/// season_id
/// sort_reverse
/// page_num
/// page_size
static const getSeasonDetailApi =
'/x/polymer/web-space/seasons_archives_list';
}

View File

@ -24,72 +24,4 @@ class DanmakaHttp {
);
return DmSegMobileReply.fromBuffer(response.data);
}
static Future shootDanmaku({
int type = 1,//弹幕类选择(1视频弹幕 2漫画弹幕)
required int oid,// 视频cid
required String msg,//弹幕文本(长度小于 100 字符)
int mode = 1,// 弹幕类型(1滚动弹幕 4底端弹幕 5顶端弹幕 6逆向弹幕(不能使用) 7高级弹幕 8代码弹幕不能使用 9BAS弹幕pool必须为2)
// String? aid,// 稿件avid
// String? bvid,// bvid与aid必须有一个
required String bvid,
int? progress,// 弹幕出现在视频内的时间单位为毫秒默认为0
int? color,// 弹幕颜色(默认白色16777215
int? fontsize,// 弹幕字号默认25
int? pool,// 弹幕池选择0普通池 1字幕池 2特殊池代码/BAS弹幕默认普通池0
//int? rnd,// 当前时间戳*1000000若无此项则发送弹幕冷却时间限制为90s若有此项则发送弹幕冷却时间限制为5s
int? colorful,//60001专属渐变彩色需要会员
int? checkbox_type,//是否带 UP 身份标识0普通4带有标识
// String? csrf,//CSRF Token位于 Cookie Cookie 方式必要
// String? access_key,// APP 登录 Token APP 方式必要
}) async {
// 构建参数对象
// assert(aid != null || bvid != null);
// assert(csrf != null || access_key != null);
assert(msg.length < 100);
// 构建参数对象
var params = <String, dynamic>{
'type': type,
'oid': oid,
'msg': msg,
'mode': mode,
//'aid': aid,
'bvid': bvid,
'progress': progress,
'color': color,
'fontsize': fontsize,
'pool': pool,
'rnd': DateTime.now().microsecondsSinceEpoch,
'colorful': colorful,
'checkbox_type': checkbox_type,
'csrf': await Request.getCsrf(),
// 'access_key': access_key,
}..removeWhere((key, value) => value == null);
var response = await Request().post(
Api.shootDanmaku,
data: params,
options: Options(
contentType: Headers.formUrlEncodedContentType,
),
);
if (response.statusCode != 200) {
return {
'status': false,
'data': [],
'msg': '弹幕发送失败,状态码:${response.statusCode}',
};
}
if (response.data['code'] == 0) {
return {
'status': true,
'data': response.data['data'],
};
} else {
return {
'status': false,
'data': [],
'msg': "${response.data['code']}: ${response.data['message']}",
};
}
}
}

View File

@ -115,24 +115,30 @@ class Request {
idleTimeout: const Duration(milliseconds: 10000),
onClientCreate: (_, config) => config.onBadCertificate = (_) => true,
),
);
)
/// 设置代理
if (enableSystemProxy) {
dio.httpClientAdapter = IOHttpClientAdapter(
/// 设置代理
..httpClientAdapter = IOHttpClientAdapter(
createHttpClient: () {
final client = HttpClient();
// Config the client.
client.findProxy = (uri) {
// return 'PROXY host:port';
return 'PROXY $systemProxyHost:$systemProxyPort';
if (enableSystemProxy) {
print('🌹:$systemProxyHost');
print('🌹:$systemProxyPort');
// return 'PROXY host:port';
return 'PROXY $systemProxyHost:$systemProxyPort';
} else {
// 不设置代理
return 'DIRECT';
}
};
client.badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
return client;
},
);
}
//添加拦截器
dio.interceptors.add(ApiInterceptor());

View File

@ -1,16 +1,9 @@
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/http/index.dart';
import 'package:pilipala/models/dynamics/result.dart';
import 'package:pilipala/models/follow/result.dart';
import 'package:pilipala/models/member/archive.dart';
import 'package:pilipala/models/member/coin.dart';
import 'package:pilipala/models/member/info.dart';
import 'package:pilipala/models/member/seasons.dart';
import 'package:pilipala/models/member/tags.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/utils.dart';
import 'package:pilipala/utils/wbi_sign.dart';
class MemberHttp {
@ -222,243 +215,4 @@ class MemberHttp {
};
}
}
// 获取up置顶
static Future getTopVideo(String? vmid) async {
var res = await Request().get(Api.getTopVideoApi);
if (res.data['code'] == 0) {
return {
'status': true,
'data': res.data['data']
.map<MemberTagItemModel>((e) => MemberTagItemModel.fromJson(e))
.toList()
};
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
// 获取uo专栏
static Future getMemberSeasons(int? mid, int? pn, int? ps) async {
var res = await Request().get(Api.getMemberSeasonsApi, data: {
'mid': mid,
'page_num': pn,
'page_size': ps,
});
if (res.data['code'] == 0) {
return {
'status': true,
'data': MemberSeasonsDataModel.fromJson(res.data['data']['items_lists'])
};
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
// 最近投币
static Future getRecentCoinVideo({required int mid}) async {
Map params = await WbiSign().makSign({
'mid': mid,
'gaia_source': 'main_web',
'web_location': 333.999,
});
var res = await Request().get(
Api.getRecentCoinVideoApi,
data: {
'vmid': mid,
'gaia_source': 'main_web',
'web_location': 333.999,
'w_rid': params['w_rid'],
'wts': params['wts'],
},
);
if (res.data['code'] == 0) {
return {
'status': true,
'data': res.data['data']
.map<MemberCoinsDataModel>((e) => MemberCoinsDataModel.fromJson(e))
.toList(),
};
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
// 最近点赞
static Future getRecentLikeVideo({required int mid}) async {
Map params = await WbiSign().makSign({
'mid': mid,
'gaia_source': 'main_web',
'web_location': 333.999,
});
var res = await Request().get(
Api.getRecentLikeVideoApi,
data: {
'vmid': mid,
'gaia_source': 'main_web',
'web_location': 333.999,
'w_rid': params['w_rid'],
'wts': params['wts'],
},
);
if (res.data['code'] == 0) {
return {
'status': true,
'data': MemberSeasonsDataModel.fromJson(res.data['data']['items_lists'])
};
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
// 查看某个专栏
static Future getSeasonDetail({
required int mid,
required int seasonId,
bool sortReverse = false,
required int pn,
required int ps,
}) async {
var res = await Request().get(
Api.getSeasonDetailApi,
data: {
'mid': mid,
'season_id': seasonId,
'sort_reverse': sortReverse,
'page_num': pn,
'page_size': ps,
},
);
if (res.data['code'] == 0) {
try {
return {
'status': true,
'data': MemberSeasonsList.fromJson(res.data['data'])
};
} catch (err) {
print(err);
}
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
// 获取TV authCode
static Future getTVCode() async {
SmartDialog.showLoading();
var params = {
'appkey': Constants.appKey,
'local_id': '0',
'ts': (DateTime.now().millisecondsSinceEpoch ~/ 1000).toString(),
};
String sign = Utils.appSign(
params,
Constants.appKey,
Constants.appSec,
);
var res = await Request()
.post(Api.getTVCode, queryParameters: {...params, 'sign': sign});
if (res.data['code'] == 0) {
return {
'status': true,
'data': res.data['data']['auth_code'],
'msg': '操作成功'
};
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
// 获取access_key
static Future cookieToKey() async {
var authCodeRes = await getTVCode();
if (authCodeRes['status']) {
var res = await Request().post(Api.cookieToKey, queryParameters: {
'auth_code': authCodeRes['data'],
'build': 708200,
'csrf': await Request.getCsrf(),
});
await Future.delayed(const Duration(milliseconds: 300));
await qrcodePoll(authCodeRes['data']);
if (res.data['code'] == 0) {
return {'status': true, 'data': [], 'msg': '操作成功'};
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
}
static Future qrcodePoll(authCode) async {
var params = {
'appkey': Constants.appKey,
'auth_code': authCode.toString(),
'local_id': '0',
'ts': (DateTime.now().millisecondsSinceEpoch ~/ 1000).toString(),
};
String sign = Utils.appSign(
params,
Constants.appKey,
Constants.appSec,
);
var res = await Request()
.post(Api.qrcodePoll, queryParameters: {...params, 'sign': sign});
SmartDialog.dismiss();
if (res.data['code'] == 0) {
String accessKey = res.data['data']['access_token'];
Box localCache = GStrorage.localCache;
Box userInfoCache = GStrorage.userInfo;
var userInfo = userInfoCache.get('userInfoCache');
localCache.put(
LocalCacheKey.accessKey, {'mid': userInfo.mid, 'value': accessKey});
return {'status': true, 'data': [], 'msg': '操作成功'};
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
// 获取up播放数、点赞数
static Future memberView({required int mid}) async {
var res = await Request().get(Api.getMemberViewApi, data: {'mid': mid});
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
}

View File

@ -1,89 +0,0 @@
import 'package:pilipala/http/api.dart';
import 'package:pilipala/http/init.dart';
import 'package:pilipala/models/msg/account.dart';
import 'package:pilipala/models/msg/session.dart';
import 'package:pilipala/utils/wbi_sign.dart';
class MsgHttp {
// 会话列表
static Future sessionList({int? endTs}) async {
Map<String, dynamic> params = {
'session_type': 1,
'group_fold': 1,
'unfollow_fold': 0,
'sort_rule': 2,
'build': 0,
'mobi_app': 'web',
};
if (endTs != null) {
params['end_ts'] = endTs;
}
Map signParams = await WbiSign().makSign(params);
var res = await Request().get(Api.sessionList, data: signParams);
if (res.data['code'] == 0) {
return {
'status': true,
'data': SessionDataModel.fromJson(res.data['data']),
};
} else {
return {
'status': false,
'date': [],
'msg': res.data['message'],
};
}
}
static Future accountList(uids) async {
var res = await Request().get(Api.sessionAccountList, data: {
'uids': uids,
'build': 0,
'mobi_app': 'web',
});
if (res.data['code'] == 0) {
return {
'status': true,
'data': res.data['data']
.map<AccountListModel>((e) => AccountListModel.fromJson(e))
.toList(),
};
} else {
return {
'status': false,
'date': [],
'msg': res.data['message'],
};
}
}
static Future sessionMsg({
int? talkerId,
}) async {
Map params = await WbiSign().makSign({
'talker_id': talkerId,
'session_type': 1,
'size': 20,
'sender_device_id': 1,
'build': 0,
'mobi_app': 'web',
});
var res = await Request().get(Api.sessionMsg, data: params);
if (res.data['code'] == 0) {
try {
return {
'status': true,
'data': SessionMsgDataModel.fromJson(res.data['data']),
};
} catch (err) {
print(err);
}
} else {
return {
'status': false,
'date': [],
'msg': res.data['message'],
};
}
}
}

View File

@ -199,7 +199,7 @@ class UserHttp {
}
}
// 获取用户凭证 失效
// 获取用户凭证
static Future thirdLogin() async {
var res = await Request().get(
'https://passport.bilibili.com/login/app/third',
@ -251,43 +251,30 @@ class UserHttp {
}
}
static Future hasFollow(int mid) async {
// 相互关系查询
static Future relationSearch(int mid) async {
Map params = await WbiSign().makSign({
'mid': mid,
'token': '',
'platform': 'web',
'web_location': 1550101,
});
var res = await Request().get(
Api.hasFollow,
Api.relationSearch,
data: {
'fid': mid,
'mid': mid,
'w_rid': params['w_rid'],
'wts': params['wts'],
},
);
if (res.data['code'] == 0) {
// relation 主动状态
// 被动状态
return {'status': true, 'data': res.data['data']};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
// // 相互关系查询
// static Future relationSearch(int mid) async {
// Map params = await WbiSign().makSign({
// 'mid': mid,
// 'token': '',
// 'platform': 'web',
// 'web_location': 1550101,
// });
// var res = await Request().get(
// Api.relationSearch,
// data: {
// 'mid': mid,
// 'w_rid': params['w_rid'],
// 'wts': params['wts'],
// },
// );
// if (res.data['code'] == 0) {
// // relation 主动状态
// // 被动状态
// return {'status': true, 'data': res.data['data']};
// } else {
// return {'status': false, 'msg': res.data['message']};
// }
// }
// 搜索历史记录
static Future searchHistory(

View File

@ -1,5 +1,9 @@
<<<<<<< HEAD
import 'package:audio_service/audio_service.dart';
=======
import 'dart:io';
>>>>>>> main
import 'package:flutter/services.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
@ -29,7 +33,22 @@ void main() async {
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown])
.then((_) async {
await GStrorage.init();
<<<<<<< HEAD
await AudioService.init<AudioHandler>(
builder: () => MyAudioHandler(),
config: const AudioServiceConfig(
androidNotificationChannelId: 'com.guozhigq.pilipala.channel.audio',
androidNotificationChannelName: 'Music playback',
androidNotificationOngoing: true,
androidStopForegroundOnPause: true,
androidNotificationIcon: 'drawable/audio_service_icon',
),
);
=======
await setupServiceLocator();
>>>>>>> main
runApp(const MyApp());
// 小白条、导航栏沉浸
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
@ -157,3 +176,34 @@ class MyApp extends StatelessWidget {
);
}
}
class MyAudioHandler extends BaseAudioHandler
with
QueueHandler, // mix in default queue callback implementations
SeekHandler {
// mix in default seek callback implementations
// The most common callbacks:
@override
Future<void> play() async {
print('play');
// All 'play' requests from all origins route to here. Implement this
// callback to start playing audio appropriate to your app. e.g. music.
}
///
@override
Future<void> pause() async {}
///
@override
Future<void> stop() async {}
///
@override
Future<void> seek(Duration position) async {}
///
@override
Future<void> skipToQueueItem(int i) async {}
}

View File

@ -118,7 +118,7 @@ class RcmdStat {
RcmdStat.fromJson(Map<String, dynamic> json) {
view = json["cover_left_text_1"];
danmu = json['cover_left_text_2'] ?? '-';
danmu = json['cover_left_text_2'];
}
}

View File

@ -1,89 +0,0 @@
class MemberCoinsDataModel {
MemberCoinsDataModel({
this.aid,
this.bvid,
this.cid,
this.coins,
this.copyright,
this.ctime,
this.desc,
this.duration,
this.owner,
this.pic,
this.pubLocation,
this.pubdate,
this.resourceType,
this.state,
this.subtitle,
this.time,
this.title,
this.tname,
this.videos,
this.view,
this.danmaku,
});
int? aid;
String? bvid;
int? cid;
int? coins;
int? copyright;
int? ctime;
String? desc;
int? duration;
Owner? owner;
String? pic;
String? pubLocation;
int? pubdate;
String? resourceType;
int? state;
String? subtitle;
int? time;
String? title;
String? tname;
int? videos;
int? view;
int? danmaku;
MemberCoinsDataModel.fromJson(Map<String, dynamic> json) {
aid = json['aid'];
bvid = json['bvid'];
cid = json['cid'];
coins = json['coins'];
copyright = json['copyright'];
ctime = json['ctime'];
desc = json['desc'];
duration = json['duration'];
owner = Owner.fromJson(json['owner']);
pic = json['pic'];
pubLocation = json['pub_location'];
pubdate = json['pubdate'];
resourceType = json['resource_type'];
state = json['state'];
subtitle = json['subtitle'];
time = json['time'];
title = json['title'];
tname = json['tname'];
videos = json['videos'];
view = json['stat']['view'];
danmaku = json['stat']['danmaku'];
}
}
class Owner {
Owner({
this.mid,
this.name,
this.face,
});
int? mid;
String? name;
String? face;
Owner.fromJson(Map<String, dynamic> json) {
mid = json['mid'];
name = json['name'];
face = json['face'];
}
}

View File

@ -1,108 +0,0 @@
class MemberSeasonsDataModel {
MemberSeasonsDataModel({
this.page,
this.seasonsList,
});
Map? page;
List<MemberSeasonsList>? seasonsList;
MemberSeasonsDataModel.fromJson(Map<String, dynamic> json) {
page = json['page'];
seasonsList = json['seasons_list'] != null
? json['seasons_list']
.map<MemberSeasonsList>((e) => MemberSeasonsList.fromJson(e))
.toList()
: [];
}
}
class MemberSeasonsList {
MemberSeasonsList({
this.archives,
this.meta,
this.recentAids,
this.page,
});
List<MemberArchiveItem>? archives;
MamberMeta? meta;
List? recentAids;
Map? page;
MemberSeasonsList.fromJson(Map<String, dynamic> json) {
archives = json['archives'] != null
? json['archives']
.map<MemberArchiveItem>((e) => MemberArchiveItem.fromJson(e))
.toList()
: [];
meta = MamberMeta.fromJson(json['meta']);
page = json['page'];
}
}
class MemberArchiveItem {
MemberArchiveItem({
this.aid,
this.bvid,
this.ctime,
this.duration,
this.pic,
this.cover,
this.pubdate,
this.view,
this.title,
});
int? aid;
String? bvid;
int? ctime;
int? duration;
String? pic;
String? cover;
int? pubdate;
int? view;
String? title;
MemberArchiveItem.fromJson(Map<String, dynamic> json) {
aid = json['aid'];
bvid = json['bvid'];
ctime = json['ctime'];
duration = json['duration'];
pic = json['pic'];
cover = json['pic'];
pubdate = json['pubdate'];
view = json['stat']['view'];
title = json['title'];
}
}
class MamberMeta {
MamberMeta({
this.cover,
this.description,
this.mid,
this.name,
this.ptime,
this.seasonId,
this.total,
});
String? cover;
String? description;
int? mid;
String? name;
int? ptime;
int? seasonId;
int? total;
MamberMeta.fromJson(Map<String, dynamic> json) {
cover = json['cover'];
description = json['description'];
mid = json['mid'];
name = json['name'];
ptime = json['ptime'];
seasonId = json['season_id'];
total = json['total'];
}
}

View File

@ -36,7 +36,7 @@ class RecVideoItemModel {
@HiveField(6)
String? title = '';
@HiveField(7)
String? duration = '';
int? duration = -1;
@HiveField(8)
int? pubdate = -1;
@HiveField(9)
@ -56,7 +56,7 @@ class RecVideoItemModel {
uri = json["uri"];
pic = json["pic"];
title = json["title"];
duration = json["duration"].toString();
duration = json["duration"];
pubdate = json["pubdate"];
owner = Owner.fromJson(json["owner"]);
stat = Stat.fromJson(json["stat"]);
@ -72,19 +72,19 @@ class Stat {
Stat({
this.view,
this.like,
this.danmu,
this.danmaku,
});
@HiveField(0)
int? view;
@HiveField(1)
int? like;
@HiveField(2)
int? danmu;
int? danmaku;
Stat.fromJson(Map<String, dynamic> json) {
view = json["view"];
like = json["like"];
danmu = json['danmaku'];
danmaku = json['danmaku'];
}
}

View File

@ -24,7 +24,7 @@ class RecVideoItemModelAdapter extends TypeAdapter<RecVideoItemModel> {
uri: fields[4] as String?,
pic: fields[5] as String?,
title: fields[6] as String?,
duration: fields[7] as String?,
duration: fields[7] as int?,
pubdate: fields[8] as int?,
owner: fields[9] as Owner?,
stat: fields[10] as Stat?,
@ -89,7 +89,7 @@ class StatAdapter extends TypeAdapter<Stat> {
return Stat(
view: fields[0] as int?,
like: fields[1] as int?,
danmu: fields[2] as int?,
danmaku: fields[2] as int?,
);
}
@ -102,7 +102,7 @@ class StatAdapter extends TypeAdapter<Stat> {
..writeByte(1)
..write(obj.like)
..writeByte(2)
..write(obj.danmu);
..write(obj.danmaku);
}
@override

View File

@ -1,80 +0,0 @@
class AccountListModel {
AccountListModel({
this.mid,
this.name,
this.sex,
this.face,
this.sign,
this.rank,
this.level,
this.silence,
this.vip,
this.pendant,
this.nameplate,
this.official,
this.birthday,
this.isFakeAccount,
this.isDeleted,
this.inRegAudit,
this.faceNft,
this.faceNftNew,
this.isSeniorMember,
this.digitalId,
this.digitalType,
this.attestation,
this.expertInfo,
this.honours,
});
int? mid;
String? name;
String? sex;
String? face;
String? sign;
int? rank;
int? level;
int? silence;
Map? vip;
Map? pendant;
Map? nameplate;
Map? official;
int? birthday;
int? isFakeAccount;
int? isDeleted;
int? inRegAudit;
int? faceNft;
int? faceNftNew;
int? isSeniorMember;
String? digitalId;
int? digitalType;
Map? attestation;
Map? expertInfo;
Map? honours;
AccountListModel.fromJson(Map<String, dynamic> json) {
mid = json['mid'];
name = json['name'] ?? '';
sex = json['sex'];
face = json['face'];
sign = json['sign'];
rank = json['rank'];
level = json['level'];
silence = json['silence'];
vip = json['vip'];
pendant = json['pendant'];
nameplate = json['nameplate'];
official = json['official'];
birthday = json['birthday'];
isFakeAccount = json['is_fake_account'];
isDeleted = json['is_deleted'];
inRegAudit = json['in_reg_audit'];
faceNft = json['face_nft'];
faceNftNew = json['face_nft_new'];
isSeniorMember = json['is_senior_member'];
digitalId = json['digital_id'];
digitalType = json['digital_type'];
attestation = json['attestation'];
expertInfo = json['expert_info'];
honours = json['honours'];
}
}

View File

@ -1,226 +0,0 @@
import 'dart:convert';
import 'package:pilipala/models/msg/account.dart';
class SessionDataModel {
SessionDataModel({
this.sessionList,
this.hasMore,
});
List? sessionList;
int? hasMore;
SessionDataModel.fromJson(Map<String, dynamic> json) {
sessionList = json['session_list']
?.map<SessionList>((e) => SessionList.fromJson(e))
.toList();
hasMore = json['has_more'];
}
}
class SessionList {
SessionList({
this.talkerId,
this.sessionType,
this.atSeqno,
this.topTs,
this.groupName,
this.groupCover,
this.isFollow,
this.isDnd,
this.ackSeqno,
this.ackTs,
this.sessionTs,
this.unreadCount,
this.lastMsg,
this.groupType,
this.canFold,
this.status,
this.maxSeqno,
this.newPushMsg,
this.setting,
this.isGuardian,
this.isIntercept,
this.isTrust,
this.systemMsgType,
this.liveStatus,
this.bizMsgUnreadCount,
// this.userLabel,
});
int? talkerId;
int? sessionType;
int? atSeqno;
int? topTs;
String? groupName;
String? groupCover;
int? isFollow;
int? isDnd;
int? ackSeqno;
int? ackTs;
int? sessionTs;
int? unreadCount;
LastMsg? lastMsg;
int? groupType;
int? canFold;
int? status;
int? maxSeqno;
int? newPushMsg;
int? setting;
int? isGuardian;
int? isIntercept;
int? isTrust;
int? systemMsgType;
int? liveStatus;
int? bizMsgUnreadCount;
// int? userLabel;
AccountListModel? accountInfo;
SessionList.fromJson(Map<String, dynamic> json) {
talkerId = json["talker_id"];
sessionType = json["session_type"];
atSeqno = json["at_seqno"];
topTs = json["top_ts"];
groupName = json["group_name"];
groupCover = json["group_cover"];
isFollow = json["is_follow"];
isDnd = json["is_dnd"];
ackSeqno = json["ack_seqno"];
ackTs = json["ack_ts"];
sessionTs = json["session_ts"];
unreadCount = json["unread_count"];
lastMsg =
json["last_msg"] != null ? LastMsg.fromJson(json["last_msg"]) : null;
groupType = json["group_type"];
canFold = json["can_fold"];
status = json["status"];
maxSeqno = json["max_seqno"];
newPushMsg = json["new_push_msg"];
setting = json["setting"];
isGuardian = json["is_guardian"];
isIntercept = json["is_intercept"];
isTrust = json["is_trust"];
systemMsgType = json["system_msg_type"];
liveStatus = json["live_status"];
bizMsgUnreadCount = json["biz_msg_unread_count"];
// userLabel = json["user_label"];
}
}
class LastMsg {
LastMsg({
this.senderIid,
this.receiverType,
this.receiverId,
this.msgType,
this.content,
this.msgSeqno,
this.timestamp,
this.atUids,
this.msgKey,
this.msgStatus,
this.notifyCode,
this.newFaceVersion,
});
int? senderIid;
int? receiverType;
int? receiverId;
int? msgType;
Map? content;
int? msgSeqno;
int? timestamp;
String? atUids;
int? msgKey;
int? msgStatus;
String? notifyCode;
int? newFaceVersion;
LastMsg.fromJson(Map<String, dynamic> json) {
senderIid = json['sender_uid'];
receiverType = json['receiver_type'];
receiverId = json['receiver_id'];
msgType = json['msg_type'];
content = jsonDecode(json['content']);
msgSeqno = json['msg_seqno'];
timestamp = json['timestamp'];
atUids = json['at_uids'];
msgKey = json['msg_key'];
msgStatus = json['msg_status'];
notifyCode = json['notify_code'];
newFaceVersion = json['new_face_version'];
}
}
class SessionMsgDataModel {
SessionMsgDataModel({
this.messages,
this.hasMore,
this.minSeqno,
this.maxSeqno,
this.eInfos,
});
List<MessageItem>? messages;
int? hasMore;
int? minSeqno;
int? maxSeqno;
List? eInfos;
SessionMsgDataModel.fromJson(Map<String, dynamic> json) {
messages = json['messages']
.map<MessageItem>((e) => MessageItem.fromJson(e))
.toList();
hasMore = json['has_more'];
minSeqno = json['min_seqno'];
maxSeqno = json['max_seqno'];
eInfos = json['e_infos'];
}
}
class MessageItem {
MessageItem({
this.senderUid,
this.receiverType,
this.receiverId,
this.msgType,
this.content,
this.msgSeqno,
this.timestamp,
this.atUids,
this.msgKey,
this.msgStatus,
this.notifyCode,
this.newFaceVersion,
});
int? senderUid;
int? receiverType;
int? receiverId;
int? msgType;
dynamic content;
int? msgSeqno;
int? timestamp;
List? atUids;
int? msgKey;
int? msgStatus;
String? notifyCode;
int? newFaceVersion;
MessageItem.fromJson(Map<String, dynamic> json) {
senderUid = json['sender_uid'];
receiverType = json['receiver_type'];
receiverId = json['receiver_id'];
// 1 文本 2 图片 18 系统提示 10 系统通知 5 撤回的消息
msgType = json['msg_type'];
content = jsonDecode(json['content']);
msgSeqno = json['msg_seqno'];
timestamp = json['timestamp'];
atUids = json['at_uids'];
msgKey = json['msg_key'];
msgStatus = json['msg_status'];
notifyCode = json['notify_code'];
newFaceVersion = json['new_face_version'];
}
}

View File

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:pilipala/models/video/play/quality.dart';
class PlayUrlModel {

View File

@ -1,3 +1,6 @@
import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@ -31,6 +34,11 @@ class _AboutPageState extends State<AboutPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Divider(
thickness: 8,
height: 10,
color: Theme.of(context).colorScheme.onInverseSurface,
),
Image.asset(
'assets/images/logo/logo_android_2.png',
width: 150,
@ -75,9 +83,9 @@ class _AboutPageState extends State<AboutPage> {
// ),
// ),
Divider(
thickness: 1,
thickness: 8,
height: 30,
color: Theme.of(context).colorScheme.outlineVariant,
color: Theme.of(context).colorScheme.onInverseSurface,
),
ListTile(
onTap: () => _aboutController.githubUrl(),
@ -126,6 +134,11 @@ class _AboutPageState extends State<AboutPage> {
title: const Text('赞助'),
trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline),
),
Divider(
thickness: 8,
height: 30,
color: Theme.of(context).colorScheme.onInverseSurface,
),
],
),
),

View File

View File

@ -1,4 +1,4 @@
library member_archive;
library pl_audio_player;
export './controller.dart';
export './view.dart';
export './controller.dart';

539
lib/pages/audio/view.dart Normal file
View File

@ -0,0 +1,539 @@
import 'dart:math';
import 'package:audio_service/audio_service.dart';
import 'package:audio_session/audio_session.dart';
import 'package:flutter/material.dart';
import 'package:just_audio/just_audio.dart';
// import 'package:just_audio_background/just_audio_background.dart';
class AudioPlayerPage extends StatefulWidget {
const AudioPlayerPage({super.key});
@override
State<AudioPlayerPage> createState() => _AudioPlayerPageState();
}
class _AudioPlayerPageState extends State<AudioPlayerPage> {
static int _nextMediaId = 0;
late AudioPlayer _player;
final _playlist = ConcatenatingAudioSource(children: [
ClippingAudioSource(
start: const Duration(seconds: 0),
end: const Duration(seconds: 90),
child: AudioSource.uri(Uri.parse(
"https://s3.amazonaws.com/scifri-episodes/scifri20181123-episode.mp3")),
tag: MediaItem(
id: '${_nextMediaId++}',
album: "Science Friday",
title: "A Salute To Head-Scratching Science (30 seconds)",
artUri: Uri.parse(
"https://media.wnyc.org/i/1400/1400/l/80/1/ScienceFriday_WNYCStudios_1400.jpg"),
),
),
// AudioSource.uri(
// Uri.parse(
// "https://upos-sz-mirror08c.bilivideo.com/upgcxcode/05/52/1205825205/1205825205-1-16.mp4?e=ig8euxZM2rNcNbRVhwdVhwdlhWdVhwdVhoNvNC8BqJIzNbfq9rVEuxTEnE8L5F6VnEsSTx0vkX8fqJeYTj_lta53NCM=&uipk=5&nbs=1&deadline=1693821903&gen=playurlv2&os=08cbv&oi=1865700872&trid=bfc9c19f85c545dd8f4794ff97f4f57fh&mid=17340771&platform=html5&upsig=9bf98515091bb8a80e1950a03a2a0d68&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&bvc=vod&nettype=0&f=h_0_0&bw=49663&logo=80000000"),
// headers: {
// 'user-agent':
// 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_3_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15',
// 'referer': 'https://www.bilibili.com'
// },
// tag: MediaItem(
// id: '${_nextMediaId++}',
// album: "Science Friday",
// title: "A Salute To Head-Scratching Science",
// artUri: Uri.parse(
// "https://media.wnyc.org/i/1400/1400/l/80/1/ScienceFriday_WNYCStudios_1400.jpg"),
// ),
// ),
AudioSource.uri(
Uri.parse("https://s3.amazonaws.com/scifri-segments/scifri201711241.mp3"),
tag: MediaItem(
id: '${_nextMediaId++}',
album: "Science Friday",
title: "From Cat Rheology To Operatic Incompetence",
artUri: Uri.parse(
"https://media.wnyc.org/i/1400/1400/l/80/1/ScienceFriday_WNYCStudios_1400.jpg"),
),
),
AudioSource.uri(
Uri.parse("asset:///audio/nature.mp3"),
tag: MediaItem(
id: '${_nextMediaId++}',
album: "Public Domain",
title: "Nature Sounds",
artUri: Uri.parse(
"https://media.wnyc.org/i/1400/1400/l/80/1/ScienceFriday_WNYCStudios_1400.jpg"),
),
),
]);
@override
void initState() {
super.initState();
_player = AudioPlayer();
_init();
}
@override
void dispose() {
_player.dispose();
super.dispose();
}
Future<void> _init() async {
final session = await AudioSession.instance;
await session.configure(const AudioSessionConfiguration.speech());
// Listen to errors during playback.
_player.playbackEventStream.listen((event) {},
onError: (Object e, StackTrace stackTrace) {
print('A stream error occurred: $e');
});
try {
await _player.setAudioSource(_playlist);
} catch (e, stackTrace) {
// Catch load errors: 404, invalid url ...
print("Error loading playlist: $e");
print(stackTrace);
}
}
// Stream<PositionData> get _positionDataStream =>
// Rx.combineLatest3<Duration, Duration, Duration?, PositionData>(
// _player.positionStream,
// _player.bufferedPositionStream,
// _player.durationStream,
// (position, bufferedPosition, duration) => PositionData(
// position, bufferedPosition, duration ?? Duration.zero));
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: StreamBuilder<SequenceState?>(
stream: _player.sequenceStateStream,
builder: (context, snapshot) {
final state = snapshot.data;
if (state?.sequence.isEmpty ?? true) {
return const SizedBox();
}
final metadata = state!.currentSource!.tag as MediaItem;
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Image.network(metadata.artUri.toString())),
),
),
Text(metadata.album!,
style: Theme.of(context).textTheme.titleLarge),
Text(metadata.title),
],
);
},
),
),
ControlButtons(_player),
// StreamBuilder<PositionData>(
// stream: _positionDataStream,
// builder: (context, snapshot) {
// final positionData = snapshot.data;
// return SeekBar(
// duration: positionData?.duration ?? Duration.zero,
// position: positionData?.position ?? Duration.zero,
// bufferedPosition:
// positionData?.bufferedPosition ?? Duration.zero,
// onChangeEnd: (newPosition) {
// _player.seek(newPosition);
// },
// );
// },
// ),
const SizedBox(height: 8.0),
Row(
children: [
StreamBuilder<LoopMode>(
stream: _player.loopModeStream,
builder: (context, snapshot) {
final loopMode = snapshot.data ?? LoopMode.off;
const icons = [
Icon(Icons.repeat, color: Colors.grey),
Icon(Icons.repeat, color: Colors.orange),
Icon(Icons.repeat_one, color: Colors.orange),
];
const cycleModes = [
LoopMode.off,
LoopMode.all,
LoopMode.one,
];
final index = cycleModes.indexOf(loopMode);
return IconButton(
icon: icons[index],
onPressed: () {
_player.setLoopMode(cycleModes[
(cycleModes.indexOf(loopMode) + 1) %
cycleModes.length]);
},
);
},
),
Expanded(
child: Text(
"Playlist",
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.center,
),
),
StreamBuilder<bool>(
stream: _player.shuffleModeEnabledStream,
builder: (context, snapshot) {
final shuffleModeEnabled = snapshot.data ?? false;
return IconButton(
icon: shuffleModeEnabled
? const Icon(Icons.shuffle, color: Colors.orange)
: const Icon(Icons.shuffle, color: Colors.grey),
onPressed: () async {
final enable = !shuffleModeEnabled;
if (enable) {
await _player.shuffle();
}
await _player.setShuffleModeEnabled(enable);
},
);
},
),
],
),
SizedBox(
height: 240.0,
child: StreamBuilder<SequenceState?>(
stream: _player.sequenceStateStream,
builder: (context, snapshot) {
final state = snapshot.data;
final sequence = state?.sequence ?? [];
return ReorderableListView(
onReorder: (int oldIndex, int newIndex) {
if (oldIndex < newIndex) newIndex--;
_playlist.move(oldIndex, newIndex);
},
children: [
for (var i = 0; i < sequence.length; i++)
Dismissible(
key: ValueKey(sequence[i]),
background: Container(
color: Colors.redAccent,
alignment: Alignment.centerRight,
child: const Padding(
padding: EdgeInsets.only(right: 8.0),
child: Icon(Icons.delete, color: Colors.white),
),
),
onDismissed: (dismissDirection) {
_playlist.removeAt(i);
},
child: Material(
color: i == state!.currentIndex
? Colors.grey.shade300
: null,
child: ListTile(
title: Text(sequence[i].tag.title as String),
onTap: () {
_player.seek(Duration.zero, index: i);
},
),
),
),
],
);
},
),
),
],
),
),
);
}
}
class ControlButtons extends StatelessWidget {
final AudioPlayer player;
const ControlButtons(this.player, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: const Icon(Icons.volume_up),
onPressed: () {
showSliderDialog(
context: context,
title: "Adjust volume",
divisions: 10,
min: 0.0,
max: 1.0,
stream: player.volumeStream,
onChanged: player.setVolume,
);
},
),
StreamBuilder<SequenceState?>(
stream: player.sequenceStateStream,
builder: (context, snapshot) => IconButton(
icon: const Icon(Icons.skip_previous),
onPressed: player.hasPrevious ? player.seekToPrevious : null,
),
),
StreamBuilder<PlayerState>(
stream: player.playerStateStream,
builder: (context, snapshot) {
final playerState = snapshot.data;
final processingState = playerState?.processingState;
final playing = playerState?.playing;
if (processingState == ProcessingState.loading ||
processingState == ProcessingState.buffering) {
return Container(
margin: const EdgeInsets.all(8.0),
width: 64.0,
height: 64.0,
child: const CircularProgressIndicator(),
);
} else if (playing != true) {
return IconButton(
icon: const Icon(Icons.play_arrow),
iconSize: 64.0,
onPressed: player.play,
);
} else if (processingState != ProcessingState.completed) {
return IconButton(
icon: const Icon(Icons.pause),
iconSize: 64.0,
onPressed: player.pause,
);
} else {
return IconButton(
icon: const Icon(Icons.replay),
iconSize: 64.0,
onPressed: () => player.seek(Duration.zero,
index: player.effectiveIndices!.first),
);
}
},
),
StreamBuilder<SequenceState?>(
stream: player.sequenceStateStream,
builder: (context, snapshot) => IconButton(
icon: const Icon(Icons.skip_next),
onPressed: player.hasNext ? player.seekToNext : null,
),
),
StreamBuilder<double>(
stream: player.speedStream,
builder: (context, snapshot) => IconButton(
icon: Text("${snapshot.data?.toStringAsFixed(1)}x",
style: const TextStyle(fontWeight: FontWeight.bold)),
onPressed: () {
showSliderDialog(
context: context,
title: "Adjust speed",
divisions: 10,
min: 0.5,
max: 1.5,
stream: player.speedStream,
onChanged: player.setSpeed,
);
},
),
),
],
);
}
}
void showSliderDialog({
required BuildContext context,
required String title,
required int divisions,
required double min,
required double max,
String valueSuffix = '',
required Stream<double> stream,
required ValueChanged<double> onChanged,
}) {
showDialog<void>(
context: context,
builder: (context) => AlertDialog(
title: Text(title, textAlign: TextAlign.center),
content: StreamBuilder<double>(
stream: stream,
builder: (context, snapshot) => SizedBox(
height: 100.0,
child: Column(
children: [
Text('${snapshot.data?.toStringAsFixed(1)}$valueSuffix',
style: const TextStyle(
fontFamily: 'Fixed',
fontWeight: FontWeight.bold,
fontSize: 24.0)),
Slider(
divisions: divisions,
min: min,
max: max,
value: snapshot.data ?? 1.0,
onChanged: onChanged,
),
],
),
),
),
),
);
}
class PositionData {
final Duration position;
final Duration bufferedPosition;
final Duration duration;
PositionData(this.position, this.bufferedPosition, this.duration);
}
class SeekBar extends StatefulWidget {
final Duration duration;
final Duration position;
final Duration bufferedPosition;
final ValueChanged<Duration>? onChanged;
final ValueChanged<Duration>? onChangeEnd;
const SeekBar({
Key? key,
required this.duration,
required this.position,
required this.bufferedPosition,
this.onChanged,
this.onChangeEnd,
}) : super(key: key);
@override
SeekBarState createState() => SeekBarState();
}
class SeekBarState extends State<SeekBar> {
double? _dragValue;
late SliderThemeData _sliderThemeData;
@override
void didChangeDependencies() {
super.didChangeDependencies();
_sliderThemeData = SliderTheme.of(context).copyWith(
trackHeight: 2.0,
);
}
@override
Widget build(BuildContext context) {
return Stack(
children: [
SliderTheme(
data: _sliderThemeData.copyWith(
thumbShape: HiddenThumbComponentShape(),
activeTrackColor: Colors.blue.shade100,
inactiveTrackColor: Colors.grey.shade300,
),
child: ExcludeSemantics(
child: Slider(
min: 0.0,
max: widget.duration.inMilliseconds.toDouble(),
value: min(widget.bufferedPosition.inMilliseconds.toDouble(),
widget.duration.inMilliseconds.toDouble()),
onChanged: (value) {
setState(() {
_dragValue = value;
});
if (widget.onChanged != null) {
widget.onChanged!(Duration(milliseconds: value.round()));
}
},
onChangeEnd: (value) {
if (widget.onChangeEnd != null) {
widget.onChangeEnd!(Duration(milliseconds: value.round()));
}
_dragValue = null;
},
),
),
),
SliderTheme(
data: _sliderThemeData.copyWith(
inactiveTrackColor: Colors.transparent,
),
child: Slider(
min: 0.0,
max: widget.duration.inMilliseconds.toDouble(),
value: min(_dragValue ?? widget.position.inMilliseconds.toDouble(),
widget.duration.inMilliseconds.toDouble()),
onChanged: (value) {
setState(() {
_dragValue = value;
});
if (widget.onChanged != null) {
widget.onChanged!(Duration(milliseconds: value.round()));
}
},
onChangeEnd: (value) {
if (widget.onChangeEnd != null) {
widget.onChangeEnd!(Duration(milliseconds: value.round()));
}
_dragValue = null;
},
),
),
Positioned(
right: 16.0,
bottom: 0.0,
child: Text(
RegExp(r'((^0*[1-9]\d*:)?\d{2}:\d{2})\.\d+$')
.firstMatch("$_remaining")
?.group(1) ??
'$_remaining',
style: Theme.of(context).textTheme.bodySmall),
),
],
);
}
Duration get _remaining => widget.duration - widget.position;
}
class HiddenThumbComponentShape extends SliderComponentShape {
@override
Size getPreferredSize(bool isEnabled, bool isDiscrete) => Size.zero;
@override
void paint(
PaintingContext context,
Offset center, {
required Animation<double> activationAnimation,
required Animation<double> enableAnimation,
required bool isDiscrete,
required TextPainter labelPainter,
required RenderBox parentBox,
required SliderThemeData sliderTheme,
required TextDirection textDirection,
required double value,
required double textScaleFactor,
required Size sizeWithOverflow,
}) {}
}

View File

@ -5,6 +5,7 @@ import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/badge.dart';
import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/common/widgets/stat/danmu.dart';
import 'package:pilipala/common/widgets/stat/view.dart';
@ -121,14 +122,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
late final BangumiInfoModel? bangumiItem;
late double sheetHeight;
int? cid;
bool isProcessing = false;
void Function()? handleState(Future Function() action) {
return isProcessing ? null : () async {
setState(() => isProcessing = true);
await action();
setState(() => isProcessing = false);
};
}
@override
void initState() {
super.initState();
@ -402,7 +396,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
() => ActionItem(
icon: const Icon(FontAwesomeIcons.thumbsUp),
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
onTap: handleState(bangumiIntroController.actionLikeVideo),
onTap: () => bangumiIntroController.actionLikeVideo(),
selectStatus: bangumiIntroController.hasLike.value,
loadingStatus: false,
text: !widget.loadingStatus
@ -413,7 +407,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
() => ActionItem(
icon: const Icon(FontAwesomeIcons.b),
selectIcon: const Icon(FontAwesomeIcons.b),
onTap: handleState(bangumiIntroController.actionCoinVideo),
onTap: () => bangumiIntroController.actionCoinVideo(),
selectStatus: bangumiIntroController.hasCoin.value,
loadingStatus: false,
text: !widget.loadingStatus
@ -462,7 +456,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
Obx(
() => ActionRowItem(
icon: const Icon(FontAwesomeIcons.thumbsUp),
onTap: handleState(videoIntroController.actionLikeVideo),
onTap: () => videoIntroController.actionLikeVideo(),
selectStatus: videoIntroController.hasLike.value,
loadingStatus: widget.loadingStatus,
text: !widget.loadingStatus
@ -474,7 +468,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
Obx(
() => ActionRowItem(
icon: const Icon(FontAwesomeIcons.b),
onTap: handleState(videoIntroController.actionCoinVideo),
onTap: () => videoIntroController.actionCoinVideo(),
selectStatus: videoIntroController.hasCoin.value,
loadingStatus: widget.loadingStatus,
text: !widget.loadingStatus

View File

@ -6,7 +6,6 @@ import 'package:flutter/rendering.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/pages/home/index.dart';
import 'package:pilipala/pages/main/index.dart';
import 'package:pilipala/pages/rcmd/view.dart';
@ -36,8 +35,6 @@ class _BangumiPageState extends State<BangumiPage>
scrollController = _bangumidController.scrollController;
StreamController<bool> mainStream =
Get.find<MainController>().bottomBarStream;
StreamController<bool> searchBarStream =
Get.find<HomeController>().searchBarStream;
_futureBuilderFuture = _bangumidController.queryBangumiListFeed();
_futureBuilderFutureFollow = _bangumidController.queryBangumiFollow();
scrollController.addListener(
@ -54,10 +51,8 @@ class _BangumiPageState extends State<BangumiPage>
scrollController.position.userScrollDirection;
if (direction == ScrollDirection.forward) {
mainStream.add(true);
searchBarStream.add(true);
} else if (direction == ScrollDirection.reverse) {
mainStream.add(false);
searchBarStream.add(false);
}
},
);

View File

@ -5,7 +5,6 @@ import 'package:hive/hive.dart';
import 'package:pilipala/models/bangumi/info.dart';
import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
class BangumiPanel extends StatefulWidget {
final List<EpisodeItem> pages;
@ -36,7 +35,6 @@ class _BangumiPanelState extends State<BangumiPanel> {
late int cid;
String heroTag = Get.arguments['heroTag'];
late final VideoDetailController videoDetailCtr;
final ItemScrollController itemScrollController = ItemScrollController();
@override
void initState() {
@ -72,11 +70,10 @@ class _BangumiPanelState extends State<BangumiPanel> {
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);
await Future.delayed(const Duration(milliseconds: 200));
listViewScrollCtr_2.animateTo(currentIndex * 56,
duration: const Duration(milliseconds: 500),
curve: Curves.easeInOut);
});
// 在这里使用 setState 更新状态
return Container(
@ -104,39 +101,42 @@ class _BangumiPanelState extends State<BangumiPanel> {
),
Expanded(
child: Material(
child: ScrollablePositionedList.builder(
child: ListView.builder(
controller: listViewScrollCtr_2,
itemCount: widget.pages.length,
itemBuilder: (context, index) => ListTile(
onTap: () {
setState(() {
changeFucCall(widget.pages[index], index);
});
},
dense: false,
leading: index == currentIndex
? Image.asset(
'assets/images/live.gif',
color: Theme.of(context).colorScheme.primary,
height: 12,
)
: null,
title: Text(
'${index + 1}${widget.pages[index].longTitle!}',
style: TextStyle(
fontSize: 14,
color: index == currentIndex
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.onSurface,
itemBuilder: (context, index) {
return ListTile(
onTap: () {
setState(() {
changeFucCall(widget.pages[index], index);
});
},
dense: false,
leading: index == currentIndex
? Image.asset(
'assets/images/live.gif',
color:
Theme.of(context).colorScheme.primary,
height: 12,
)
: null,
title: Text(
'${index + 1}${widget.pages[index].longTitle!}',
style: TextStyle(
fontSize: 14,
color: index == currentIndex
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.onSurface,
),
),
),
trailing: widget.pages[index].badge != null
? Image.asset(
'assets/images/big-vip.png',
height: 20,
)
: const SizedBox(),
),
itemScrollController: itemScrollController,
trailing: widget.pages[index].badge != null
? Image.asset(
'assets/images/big-vip.png',
height: 20,
)
: const SizedBox(),
);
},
),
),
),
@ -236,7 +236,7 @@ class _BangumiPanelState extends State<BangumiPanel> {
children: [
if (i == currentIndex) ...[
Image.asset(
'assets/images/live.png',
'assets/images/live.gif',
color:
Theme.of(context).colorScheme.primary,
height: 12,

View File

@ -3,56 +3,74 @@ import 'package:pilipala/models/danmaku/dm.pb.dart';
import 'package:pilipala/plugin/pl_player/index.dart';
class PlDanmakuController {
PlDanmakuController(this.cid);
PlDanmakuController(this.cid, this.playerController);
final int cid;
Map<int,List<DanmakuElem>> dmSegMap = {};
final PlPlayerController playerController;
late Duration videoDuration;
// 按 6min 分段
int segCount = 0;
List<DmSegMobileReply> dmSegList = [];
// 已请求的段落标记
List<bool> requestedSeg = [];
List<int> hasrequestSeg = [];
int currentSegIndex = 1;
int currentDmIndex = 0;
bool get initiated => requestedSeg.isNotEmpty;
static int SEGMENT_LENGTH = 60 * 6 * 1000;
void initiate(int videoDuration, int progress) {
if (requestedSeg.isEmpty) {
int segCount = (videoDuration / SEGMENT_LENGTH).ceil();
requestedSeg = List<bool>.generate(segCount, (index) => false);
}
queryDanmaku(
calcSegment(progress)
);
void calcSegment() {
dmSegList.clear();
// 视频分段数
segCount = (videoDuration.inSeconds / (60 * 6)).ceil();
dmSegList = List<DmSegMobileReply>.generate(
segCount < 1 ? 1 : segCount, (index) => DmSegMobileReply());
// 当前分段
try {
currentSegIndex =
(playerController.position.value.inSeconds / (60 * 6)).ceil();
currentSegIndex = currentSegIndex < 1 ? 1 : currentSegIndex;
} catch (_) {}
}
void dispose() {
dmSegMap.clear();
requestedSeg.clear();
}
int calcSegment(int progress) {
return progress ~/ SEGMENT_LENGTH;
}
void queryDanmaku(int segmentIndex) async {
assert(requestedSeg[segmentIndex] == false);
requestedSeg[segmentIndex] = true;
Future<List<DmSegMobileReply>> queryDanmaku() async {
// dmSegList.clear();
DmSegMobileReply result =
await DanmakaHttp.queryDanmaku(cid: cid, segmentIndex: segmentIndex + 1);
await DanmakaHttp.queryDanmaku(cid: cid, segmentIndex: currentSegIndex);
if (result.elems.isNotEmpty) {
for (var element in result.elems) {
int pos = element.progress ~/ 100;//每0.1秒存储一次
if (dmSegMap[pos] == null) {
dmSegMap[pos] = [];
}
dmSegMap[pos]!.add(element);
}
result.elems.sort((a, b) => (a.progress).compareTo(b.progress));
// dmSegList.add(result);
currentSegIndex = currentSegIndex < 1 ? 1 : currentSegIndex;
dmSegList[currentSegIndex - 1] = result;
}
if (dmSegList.isNotEmpty) {
findClosestPositionIndex(playerController.position.value.inMilliseconds);
}
return dmSegList;
}
List<DanmakuElem>? getCurrentDanmaku(int progress) {
int segmentIndex = calcSegment(progress);
if (!requestedSeg[segmentIndex]) {
queryDanmaku(segmentIndex);
/// 查询当前最接近的弹幕
void findClosestPositionIndex(int position) {
int segIndex = (position / (6 * 60 * 1000)).ceil() - 1;
if (segIndex < 0) segIndex = 0;
List elems = dmSegList[segIndex].elems;
if (segIndex < dmSegList.length) {
int left = 0;
int right = elems.length;
while (left < right) {
int mid = (right + left) ~/ 2;
var midPosition = elems[mid].progress;
if (midPosition >= position) {
right = mid;
} else {
left = mid + 1;
}
}
currentSegIndex = segIndex;
currentDmIndex = right;
} else {
currentSegIndex = segIndex;
currentDmIndex = 0;
}
return dmSegMap[progress ~/ 100];
}
}

View File

@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:ns_danmaku/ns_danmaku.dart';
import 'package:pilipala/models/danmaku/dm.pb.dart';
import 'package:pilipala/pages/danmaku/index.dart';
import 'package:pilipala/plugin/pl_player/index.dart';
import 'package:pilipala/utils/danmaku.dart';
@ -28,15 +27,14 @@ class _PlDanmakuState extends State<PlDanmaku> {
late PlPlayerController playerController;
late PlDanmakuController _plDanmakuController;
DanmakuController? _controller;
// bool danmuPlayStatus = true;
bool danmuPlayStatus = true;
Box setting = GStrorage.setting;
late bool enableShowDanmaku;
late List blockTypes;
late double showArea;
late double opacityVal;
late double fontSizeVal;
late double danmakuDurationVal;
int latestAddedPosition = -1;
late double danmakuSpeedVal;
@override
void initState() {
@ -44,32 +42,33 @@ class _PlDanmakuState extends State<PlDanmaku> {
enableShowDanmaku =
setting.get(SettingBoxKey.enableShowDanmaku, defaultValue: false);
_plDanmakuController =
PlDanmakuController(widget.cid);
PlDanmakuController(widget.cid, widget.playerController);
if (mounted) {
playerController = widget.playerController;
_plDanmakuController.videoDuration = playerController.duration.value;
if (enableShowDanmaku || playerController.isOpenDanmu.value) {
_plDanmakuController.initiate(
playerController.duration.value.inMilliseconds,
playerController.position.value.inMilliseconds
);
_plDanmakuController
..calcSegment()
..queryDanmaku();
}
playerController
..addStatusLister(playerListener)
..addPositionListener(videoPositionListen);
}
playerController.isOpenDanmu.listen((p0) {
if (p0 && !_plDanmakuController.initiated) {
_plDanmakuController.initiate(
playerController.duration.value.inMilliseconds,
playerController.position.value.inMilliseconds
);
if (p0) {
if (_plDanmakuController.dmSegList.isEmpty) {
_plDanmakuController
..calcSegment()
..queryDanmaku();
}
}
});
blockTypes = playerController.blockTypes;
showArea = playerController.showArea;
opacityVal = playerController.opacityVal;
fontSizeVal = playerController.fontSizeVal;
danmakuDurationVal = playerController.danmakuDurationVal;
danmakuSpeedVal = playerController.danmakuSpeedVal;
}
// 播放器状态监听
@ -83,32 +82,64 @@ class _PlDanmakuState extends State<PlDanmaku> {
}
void videoPositionListen(Duration position) {
if (!danmuPlayStatus) {
_controller!.onResume();
danmuPlayStatus = true;
}
if (!playerController.isOpenDanmu.value) {
return;
}
PlDanmakuController ctr = _plDanmakuController;
int currentPosition = position.inMilliseconds;
currentPosition -= currentPosition % 100;//取整百的毫秒数
if (currentPosition == latestAddedPosition) {
blockTypes = playerController.blockTypes;
// 根据position判断是否有已缓存弹幕。没有则请求对应段
int segIndex = (currentPosition / (6 * 60 * 1000)).ceil();
segIndex = segIndex < 1 ? 1 : segIndex;
if (ctr.dmSegList[segIndex - 1].elems.isEmpty &&
!ctr.hasrequestSeg.contains(segIndex - 1)) {
ctr.hasrequestSeg.add(segIndex - 1);
ctr.currentSegIndex = segIndex;
EasyThrottle.throttle('follow', const Duration(seconds: 1), () {
ctr.queryDanmaku();
});
}
// 超出分段数返回
if (ctr.currentSegIndex >= ctr.dmSegList.length) {
return;
}
latestAddedPosition = currentPosition;
if (ctr.dmSegList.isEmpty ||
ctr.dmSegList[ctr.currentSegIndex].elems.isEmpty) {
return;
}
// 超出当前分段的弹幕总数返回
if (ctr.currentDmIndex >= ctr.dmSegList[ctr.currentSegIndex].elems.length) {
ctr.currentDmIndex = 0;
ctr.currentSegIndex++;
return;
}
var element = ctr.dmSegList[ctr.currentSegIndex].elems[ctr.currentDmIndex];
var delta = currentPosition - element.progress;
List<DanmakuElem>? currentDanmakuList =
_plDanmakuController.getCurrentDanmaku(currentPosition);
if (currentDanmakuList != null) {
Color? defaultColor = playerController.blockTypes.contains(6) ?
DmUtils.decimalToColor(16777215) : null;
_controller!.addItems(
currentDanmakuList.map((e) => DanmakuItem(
e.content,
color: defaultColor ?? DmUtils.decimalToColor(e.color),
time: e.progress,
type: DmUtils.getPosition(e.mode),
)).toList()
);
if (delta >= 0 && delta < 200) {
// 屏蔽彩色弹幕
if (blockTypes.contains(6) ? element.color == 16777215 : true) {
_controller!.addItems([
DanmakuItem(
element.content,
color: DmUtils.decimalToColor(element.color),
time: element.progress,
type: DmUtils.getPosition(element.mode),
)
]);
}
ctr.currentDmIndex++;
} else {
if (!playerController.isOpenDanmu.value) {
_controller!.pause();
danmuPlayStatus = false;
return;
}
ctr.findClosestPositionIndex(position.inMilliseconds);
}
}
@ -121,7 +152,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, box) {
// double initDuration = box.maxWidth / 12;
double initDuration = box.maxWidth / 12;
return Obx(
() => AnimatedOpacity(
opacity: playerController.isOpenDanmu.value ? 1 : 0,
@ -137,9 +168,8 @@ class _PlDanmakuState extends State<PlDanmaku> {
hideTop: blockTypes.contains(5),
hideScroll: blockTypes.contains(2),
hideBottom: blockTypes.contains(4),
duration: danmakuDurationVal / widget.playerController.playbackSpeed,
// initDuration /
// (danmakuSpeedVal * widget.playerController.playbackSpeed),
duration: initDuration /
(danmakuSpeedVal * widget.playerController.playbackSpeed),
),
statusChanged: (isPlaying) {},
),

View File

@ -231,15 +231,6 @@ class _DynamicsPageState extends State<DynamicsPage>
}
},
),
SliverToBoxAdapter(
child: Container(
height: 6,
color: Theme.of(context)
.colorScheme
.onInverseSurface
.withOpacity(0.5),
),
),
FutureBuilder(
future: _futureBuilderFuture,
builder: (context, snapshot) {

View File

@ -23,14 +23,7 @@ class ActionPanel extends StatefulWidget {
class _ActionPanelState extends State<ActionPanel> {
final DynamicsController _dynamicsController = Get.put(DynamicsController());
late ModuleStatModel stat;
bool isProcessing = false;
void Function()? handleState(Future Function() action) {
return isProcessing ? null : () async {
setState(() => isProcessing = true);
await action();
setState(() => isProcessing = false);
};
}
@override
void initState() {
super.initState();
@ -38,7 +31,7 @@ class _ActionPanelState extends State<ActionPanel> {
}
// 动态点赞
Future onLikeDynamic() async {
onLikeDynamic() async {
feedBack();
var item = widget.item!;
String dynamicId = item.idStr!;
@ -108,7 +101,7 @@ class _ActionPanelState extends State<ActionPanel> {
Expanded(
flex: 1,
child: TextButton.icon(
onPressed: handleState(onLikeDynamic),
onPressed: () => onLikeDynamic(),
icon: Icon(
stat.like!.status!
? FontAwesomeIcons.solidThumbsUp

View File

@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/models/dynamics/result.dart';
import 'package:pilipala/pages/preview/index.dart';
// 富文本
InlineSpan richNode(item, context) {
@ -9,11 +11,13 @@ InlineSpan richNode(item, context) {
TextStyle authorStyle =
TextStyle(color: Theme.of(context).colorScheme.primary);
List<InlineSpan> spanChilds = [];
String contentType = 'desc';
dynamic richTextNodes;
if (item.modules.moduleDynamic.desc != null) {
richTextNodes = item.modules.moduleDynamic.desc.richTextNodes;
} else if (item.modules.moduleDynamic.major != null) {
contentType = 'major';
// 动态页面 richTextNodes 层级可能与主页动态层级不同
richTextNodes =
item.modules.moduleDynamic.major.opus.summary.richTextNodes;

View File

@ -56,73 +56,67 @@ class _UpPanelState extends State<UpPanel> {
floating: true,
pinned: false,
delegate: _SliverHeaderDelegate(
height: 124,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
color: Theme.of(context).colorScheme.background,
padding: const EdgeInsets.only(left: 16, right: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text('最新关注'),
GestureDetector(
onTap: () {
feedBack();
Get.toNamed('/follow?mid=${userInfo.mid}');
},
child: Container(
padding: const EdgeInsets.only(top: 5, bottom: 5),
height: 90,
child: Container(
height: 90,
color: Theme.of(context).colorScheme.background,
child: Row(
children: [
Expanded(
child: ListView(
scrollDirection: Axis.horizontal,
controller: scrollController,
children: [
const SizedBox(width: 10),
if (liveList.isNotEmpty) ...[
for (int i = 0; i < liveList.length; i++) ...[
upItemBuild(liveList[i], i)
],
VerticalDivider(
indent: 20,
endIndent: 40,
width: 26,
color: Theme.of(context)
.colorScheme
.primary
.withOpacity(0.5),
),
],
for (int i = 0; i < upList.length; i++) ...[
upItemBuild(upList[i], i)
],
const SizedBox(width: 10),
],
),
),
Material(
child: InkWell(
onTap: () => {
feedBack(),
Get.toNamed('/follow?mid=${userInfo.mid}')
},
child: Container(
height: 100,
padding: const EdgeInsets.only(left: 10, right: 10),
color: Theme.of(context)
.colorScheme
.secondaryContainer
.withOpacity(0.3),
child: Center(
child: Text(
'查看全部',
'全部',
style: TextStyle(
color: Theme.of(context).colorScheme.outline),
color: Theme.of(context)
.colorScheme
.onSecondaryContainer),
),
),
),
],
),
),
),
Container(
height: 90,
color: Theme.of(context).colorScheme.background,
child: Row(
children: [
Expanded(
child: ListView(
scrollDirection: Axis.horizontal,
controller: scrollController,
children: [
const SizedBox(width: 10),
if (liveList.isNotEmpty) ...[
for (int i = 0; i < liveList.length; i++) ...[
upItemBuild(liveList[i], i)
],
VerticalDivider(
indent: 20,
endIndent: 40,
width: 26,
color: Theme.of(context)
.colorScheme
.primary
.withOpacity(0.5),
),
],
for (int i = 0; i < upList.length; i++) ...[
upItemBuild(upList[i], i)
],
const SizedBox(width: 10),
],
),
),
],
),
),
],
)),
],
)),
),
);
}

View File

@ -15,7 +15,6 @@ class FansController extends GetxController {
late String name;
var userInfo;
RxString loadingText = '加载中...'.obs;
RxBool isOwner = false.obs;
@override
void onInit() {
@ -24,7 +23,6 @@ class FansController extends GetxController {
mid = Get.parameters['mid'] != null
? int.parse(Get.parameters['mid']!)
: userInfo.mid;
isOwner.value = mid == userInfo.mid;
name = Get.parameters['name'] ?? userInfo.uname;
}

View File

@ -54,7 +54,7 @@ class _FansPageState extends State<FansPage> {
centerTitle: false,
titleSpacing: 0,
title: Text(
_fansController.isOwner.value ? '我的粉丝' : '${_fansController.name}的粉丝',
'${_fansController.name}的粉丝',
style: Theme.of(context).textTheme.titleMedium,
),
),

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/models/follow/result.dart';

View File

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

View File

@ -11,6 +11,7 @@ import 'package:pilipala/models/bangumi/info.dart';
import 'package:pilipala/models/common/business_type.dart';
import 'package:pilipala/models/common/search_type.dart';
import 'package:pilipala/models/live/item.dart';
import 'package:pilipala/pages/history/index.dart';
import 'package:pilipala/pages/history_search/index.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/id_utils.dart';

View File

@ -131,6 +131,7 @@ class _HistorySearchPageState extends State<HistorySearchPage> {
onChoose: null,
onUpdateMultiple: () => null,
);
;
}
},
)

View File

@ -1,5 +1,3 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
@ -17,10 +15,6 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
RxBool userLogin = false.obs;
RxString userFace = ''.obs;
var userInfo;
Box setting = GStrorage.setting;
late final StreamController<bool> searchBarStream =
StreamController<bool>.broadcast();
late bool hideSearchBar;
@override
void onInit() {
@ -39,8 +33,6 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
length: tabs.length,
vsync: this,
);
hideSearchBar =
setting.get(SettingBoxKey.hideSearchBar, defaultValue: true);
}
void onRefresh() {

View File

@ -1,8 +1,7 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/pages/main/index.dart';
import 'package:pilipala/pages/mine/index.dart';
import 'package:pilipala/pages/search/index.dart';
import 'package:pilipala/utils/feed_back.dart';
@ -19,17 +18,11 @@ class _HomePageState extends State<HomePage>
with AutomaticKeepAliveClientMixin, TickerProviderStateMixin {
final HomeController _homeController = Get.put(HomeController());
List videoList = [];
late Stream<bool> stream;
Stream<bool> stream = Get.find<MainController>().bottomBarStream.stream;
@override
bool get wantKeepAlive => true;
@override
void initState() {
super.initState();
stream = _homeController.searchBarStream.stream;
}
showUserBottonSheet() {
feedBack();
showModalBottomSheet(
@ -53,9 +46,7 @@ class _HomePageState extends State<HomePage>
body: Column(
children: [
CustomAppBar(
stream: _homeController.hideSearchBar
? stream
: StreamController<bool>.broadcast().stream,
stream: stream,
ctr: _homeController,
callback: showUserBottonSheet,
),
@ -74,7 +65,6 @@ class _HomePageState extends State<HomePage>
dividerColor: Colors.transparent,
enableFeedback: true,
splashBorderRadius: BorderRadius.circular(10),
tabAlignment: TabAlignment.center,
onTap: (value) {
feedBack();
if (_homeController.initialIndex == value) {
@ -128,7 +118,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
duration: const Duration(milliseconds: 500),
height: snapshot.data
? MediaQuery.of(context).padding.top + 52
: MediaQuery.of(context).padding.top - 10,
: MediaQuery.of(context).padding.top,
child: Container(
padding: EdgeInsets.only(
left: 20,
@ -139,13 +129,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
child: Row(
children: [
const Expanded(child: SearchPage()),
if (ctr!.userLogin.value) ...[
const SizedBox(width: 6),
IconButton(
onPressed: () => Get.toNamed('/whisper'),
icon: const Icon(Icons.notifications_none))
],
const SizedBox(width: 6),
const SizedBox(width: 10),
Obx(
() => ctr!.userLogin.value
? Stack(

View File

@ -9,7 +9,6 @@ import 'package:pilipala/common/widgets/overlay_pop.dart';
import 'package:pilipala/common/skeleton/video_card_h.dart';
import 'package:pilipala/common/widgets/http_error.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/main/index.dart';
@ -36,8 +35,6 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
scrollController = _hotController.scrollController;
StreamController<bool> mainStream =
Get.find<MainController>().bottomBarStream;
StreamController<bool> searchBarStream =
Get.find<HomeController>().searchBarStream;
scrollController.addListener(
() {
if (scrollController.position.pixels >=
@ -52,10 +49,8 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
scrollController.position.userScrollDirection;
if (direction == ScrollDirection.forward) {
mainStream.add(true);
searchBarStream.add(true);
} else if (direction == ScrollDirection.reverse) {
mainStream.add(false);
searchBarStream.add(false);
}
},
);

View File

@ -9,6 +9,7 @@ import 'package:pilipala/common/widgets/html_render.dart';
import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/models/common/reply_type.dart';
import 'package:pilipala/pages/mine/index.dart';
import 'package:pilipala/pages/video/detail/reply/widgets/reply_item.dart';
import 'package:pilipala/pages/video/detail/replyNew/index.dart';
import 'package:pilipala/pages/video/detail/replyReply/index.dart';

View File

@ -32,7 +32,7 @@ class _LaterPageState extends State<LaterPage> {
title: Obx(
() => _laterController.laterList.isNotEmpty
? Text(
'稍后再看 (${_laterController.laterList.length})',
'稍后再看 (${_laterController.laterList.length}/100)',
style: Theme.of(context).textTheme.titleMedium,
)
: Text(

View File

@ -9,7 +9,6 @@ import 'package:pilipala/common/skeleton/video_card_v.dart';
import 'package:pilipala/common/widgets/animated_dialog.dart';
import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/common/widgets/overlay_pop.dart';
import 'package:pilipala/pages/home/index.dart';
import 'package:pilipala/pages/main/index.dart';
import 'package:pilipala/pages/rcmd/index.dart';
@ -39,8 +38,6 @@ class _LivePageState extends State<LivePage>
scrollController = _liveController.scrollController;
StreamController<bool> mainStream =
Get.find<MainController>().bottomBarStream;
StreamController<bool> searchBarStream =
Get.find<HomeController>().searchBarStream;
scrollController.addListener(
() {
if (scrollController.position.pixels >=
@ -55,10 +52,8 @@ class _LivePageState extends State<LivePage>
scrollController.position.userScrollDirection;
if (direction == ScrollDirection.forward) {
mainStream.add(true);
searchBarStream.add(true);
} else if (direction == ScrollDirection.reverse) {
mainStream.add(false);
searchBarStream.add(false);
}
},
);
@ -72,7 +67,6 @@ class _LivePageState extends State<LivePage>
@override
Widget build(BuildContext context) {
super.build(context);
return Container(
clipBehavior: Clip.hardEdge,
margin: const EdgeInsets.only(

View File

@ -52,6 +52,7 @@ class _LiveRoomPageState extends State<LiveRoomPage> {
@override
Widget build(BuildContext context) {
final videoHeight = MediaQuery.of(context).size.width * 9 / 16;
Widget childWhenDisabled = Scaffold(
primary: true,
appBar: AppBar(

View File

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:floating/floating.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/models/video/play/url.dart';
import 'package:pilipala/pages/liveRoom/index.dart';
@ -42,6 +43,10 @@ class _BottomControlState extends State<BottomControl> {
@override
Widget build(BuildContext context) {
const textStyle = TextStyle(
color: Colors.white,
fontSize: 12,
);
return AppBar(
backgroundColor: Colors.transparent,
foregroundColor: Colors.white,

View File

@ -55,7 +55,6 @@ class MainController extends GetxController {
StreamController<bool>.broadcast();
Box setting = GStrorage.setting;
DateTime? _lastPressedAt;
late bool hideTabBar;
@override
void onInit() {
@ -63,7 +62,6 @@ class MainController extends GetxController {
if (setting.get(SettingBoxKey.autoUpdate, defaultValue: false)) {
Utils.checkUpdata();
}
hideTabBar = setting.get(SettingBoxKey.hideTabBar, defaultValue: true);
}
Future<bool> onBackPressed(BuildContext context) {

View File

@ -1,5 +1,3 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
@ -115,8 +113,8 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
MediaQuery.of(context).size.width * 9 / 16;
localCache.put('sheetHeight', sheetHeight);
localCache.put('statusBarHeight', statusBarHeight);
return PopScope(
onPopInvoked: (bool status) => _mainController.onBackPressed(context),
return WillPopScope(
onWillPop: () => _mainController.onBackPressed(context),
child: Scaffold(
extendBody: true,
body: FadeTransition(
@ -144,9 +142,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
),
),
bottomNavigationBar: StreamBuilder(
stream: _mainController.hideTabBar
? _mainController.bottomBarStream.stream
: StreamController<bool>.broadcast().stream,
stream: _mainController.bottomBarStream.stream,
initialData: true,
builder: (context, AsyncSnapshot snapshot) {
return AnimatedSlide(

View File

@ -36,7 +36,6 @@ class MediaController extends GetxController {
];
var userInfo;
int? mid;
final ScrollController scrollController = ScrollController();
@override
void onInit() {

View File

@ -1,11 +1,7 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/network_img_layer.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/utils/utils.dart';
@ -29,32 +25,12 @@ class _MediaPageState extends State<MediaPage>
super.initState();
mediaController = Get.put(MediaController());
_futureBuilderFuture = mediaController.queryFavFolder();
ScrollController scrollController = mediaController.scrollController;
StreamController<bool> mainStream =
Get.find<MainController>().bottomBarStream;
mediaController.userLogin.listen((status) {
setState(() {
_futureBuilderFuture = mediaController.queryFavFolder();
});
});
scrollController.addListener(
() {
final ScrollDirection direction =
scrollController.position.userScrollDirection;
if (direction == ScrollDirection.forward) {
mainStream.add(true);
} else if (direction == ScrollDirection.reverse) {
mainStream.add(false);
}
},
);
}
@override
void dispose() {
mediaController.scrollController.removeListener(() {});
super.dispose();
}
@override
@ -64,7 +40,6 @@ class _MediaPageState extends State<MediaPage>
return Scaffold(
appBar: AppBar(toolbarHeight: 30),
body: SingleChildScrollView(
controller: mediaController.scrollController,
child: Column(
children: [
ListTile(

View File

@ -1,11 +1,9 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/http/member.dart';
import 'package:pilipala/models/member/archive.dart';
class MemberArchiveController extends GetxController {
final ScrollController scrollController = ScrollController();
late int mid;
class ArchiveController extends GetxController {
ArchiveController(this.mid);
int? mid;
int pn = 1;
int count = 0;
RxMap<String, String> currentOrder = <String, String>{}.obs;
@ -14,27 +12,20 @@ class MemberArchiveController extends GetxController {
{'type': 'click', 'label': '最多播放'},
{'type': 'stow', 'label': '最多收藏'},
];
RxList<VListItemModel> archivesList = <VListItemModel>[].obs;
@override
void onInit() {
super.onInit();
mid = int.parse(Get.parameters['mid']!);
mid ??= int.parse(Get.parameters['mid']!);
print('🐶🐶: $mid');
currentOrder.value = orderList.first;
}
// 稿
Future getMemberArchive(type) async {
if (type == 'onRefresh') {
pn = 1;
}
Future getMemberArchive() async {
var res = await MemberHttp.memberArchive(
mid: mid,
pn: pn,
order: currentOrder['type']!,
);
mid: mid, pn: pn, order: currentOrder['type']!);
if (res['status']) {
archivesList.addAll(res['data'].list.vlist);
count = res['data'].page['count'];
pn += 1;
}
@ -43,16 +34,11 @@ class MemberArchiveController extends GetxController {
toggleSort() async {
pn = 1;
int index = orderList.indexOf(currentOrder);
int index = orderList.indexOf(currentOrder.value);
if (index == orderList.length - 1) {
currentOrder.value = orderList.first;
} else {
currentOrder.value = orderList[index + 1];
}
}
//
Future onLoad() async {
getMemberArchive('onLoad');
}
}

View File

@ -0,0 +1,4 @@
library archive_panel;
export './controller.dart';
export 'index.dart';

View File

@ -0,0 +1,240 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:loading_more_list/loading_more_list.dart';
import 'package:pilipala/common/widgets/video_card_h.dart';
import 'package:pilipala/models/member/archive.dart';
import 'package:pilipala/pages/member/archive/index.dart';
import 'package:pilipala/utils/utils.dart';
import 'package:pull_to_refresh_notification/pull_to_refresh_notification.dart';
class ArchivePanel extends StatefulWidget {
final int? mid;
const ArchivePanel({super.key, this.mid});
@override
State<ArchivePanel> createState() => _ArchivePanelState();
}
class _ArchivePanelState extends State<ArchivePanel>
with AutomaticKeepAliveClientMixin {
DateTime lastRefreshTime = DateTime.now();
late final LoadMoreListSource source;
late final ArchiveController _archiveController;
@override
bool get wantKeepAlive => true;
@override
void initState() {
super.initState();
print('🐶🐶: ${widget.mid}');
_archiveController = Get.put(ArchiveController(widget.mid),
tag: Utils.makeHeroTag(widget.mid));
source = LoadMoreListSource(_archiveController);
}
@override
Widget build(BuildContext context) {
super.build(context);
return PullToRefreshNotification(
onRefresh: () async {
await Future.delayed(const Duration(seconds: 1));
return true;
},
maxDragOffset: 50,
child: GlowNotificationWidget(
Column(
children: <Widget>[
// 下拉刷新指示器
// PullToRefreshContainer(
// (PullToRefreshScrollNotificationInfo? info) {
// return PullToRefreshHeader(info, lastRefreshTime);
// },
// ),
Padding(
padding:
const EdgeInsets.only(left: 14, top: 8, bottom: 8, right: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('排序方式'),
SizedBox(
height: 35,
width: 85,
child: TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () {
// _archiveController.order = 'click';
// _archiveController.pn = 1;
_archiveController.toggleSort();
source.refresh(true);
// LoadMoreListSource().loadData();
},
child: Obx(
() => AnimatedSwitcher(
duration: const Duration(milliseconds: 400),
transitionBuilder:
(Widget child, Animation<double> animation) {
return ScaleTransition(
scale: animation, child: child);
},
child: Text(
_archiveController.currentOrder['label']!,
key: ValueKey<String>(
_archiveController.currentOrder['label']!),
),
),
),
),
),
],
),
),
Expanded(
child: LoadingMoreList<VListItemModel>(
ListConfig<VListItemModel>(
sourceList: source,
itemBuilder:
(BuildContext c, VListItemModel item, int index) {
if (index == 0) {
return Column(
children: [
const SizedBox(height: 6),
VideoCardH(videoItem: item)
],
);
} else {
return VideoCardH(videoItem: item);
}
},
indicatorBuilder: _buildIndicator,
),
),
)
],
),
showGlowLeading: false,
),
);
}
Widget _buildIndicator(BuildContext context, IndicatorStatus status) {
TextStyle style =
TextStyle(fontSize: 13, color: Theme.of(context).colorScheme.outline);
Widget? widget;
switch (status) {
case IndicatorStatus.none:
widget = Container(height: 0.0);
break;
case IndicatorStatus.loadingMoreBusying:
widget = Text('加载中...', style: style);
widget = _setbackground(false, widget, height: 60.0);
break;
case IndicatorStatus.fullScreenBusying:
widget = Text('加载中...', style: style);
widget = _setbackground(true, widget);
break;
case IndicatorStatus.error:
/// TODO 异常逻辑
widget = Text('没有更多了', style: style);
widget = _setbackground(false, widget);
widget = GestureDetector(
onTap: () {},
child: widget,
);
break;
case IndicatorStatus.fullScreenError:
/// TODO 异常逻辑
widget = Text('没有更多了', style: style);
widget = _setbackground(true, widget);
widget = GestureDetector(
onTap: () {},
child: widget,
);
break;
case IndicatorStatus.noMoreLoad:
widget = Text('没有更多了', style: style);
widget = _setbackground(false, widget, height: 60.0);
break;
case IndicatorStatus.empty:
widget = Text('用户没有投稿', style: style);
widget = _setbackground(true, widget);
break;
}
return widget;
}
Widget _setbackground(bool full, Widget widget, {double height = 100}) {
widget = Padding(
padding: height == double.infinity
? EdgeInsets.zero
: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: Container(
width: double.infinity,
height: height,
color: Theme.of(context).colorScheme.background,
alignment: Alignment.center,
child: widget,
),
);
return widget;
}
Widget getIndicator(BuildContext context) {
final TargetPlatform platform = Theme.of(context).platform;
return platform == TargetPlatform.iOS
? const CupertinoActivityIndicator(
animating: true,
radius: 16.0,
)
: CircularProgressIndicator(
strokeWidth: 2.0,
valueColor:
AlwaysStoppedAnimation<Color>(Theme.of(context).primaryColor),
);
}
}
class LoadMoreListSource extends LoadingMoreBase<VListItemModel> {
late ArchiveController ctr;
LoadMoreListSource(this.ctr);
bool forceRefresh = false;
@override
Future<bool> loadData([bool isloadMoreAction = false]) async {
bool isSuccess = false;
var res = await ctr.getMemberArchive();
if (res['status']) {
if (ctr.pn == 2) {
clear();
}
addAll(res['data'].list.vlist);
}
if (length < res['data'].page['count']) {
isSuccess = true;
} else {
isSuccess = false;
}
return isSuccess;
}
@override
Future<bool> refresh([bool clearBeforeRequest = false]) async {
// _hasMore = true;
// pageindex = 1;
// //force to refresh list when you don't want clear list before request
// //for the case, if your list already has 20 items.
forceRefresh = !clearBeforeRequest;
var result = await super.refresh(clearBeforeRequest);
forceRefresh = false;
return result;
}
}

View File

@ -6,7 +6,6 @@ import 'package:pilipala/http/member.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/coin.dart';
import 'package:pilipala/models/member/info.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:share_plus/share_plus.dart';
@ -14,17 +13,16 @@ import 'package:share_plus/share_plus.dart';
class MemberController extends GetxController {
late int mid;
Rx<MemberInfoModel> memberInfo = MemberInfoModel().obs;
late Map userStat;
Map? userStat;
RxString face = ''.obs;
String? heroTag;
Box userInfoCache = GStrorage.userInfo;
late int ownerMid;
// 投稿列表
RxList<VListItemModel>? archiveList = [VListItemModel()].obs;
dynamic userInfo;
var userInfo;
RxInt attribute = (-1).obs;
RxString attributeText = '关注'.obs;
RxList<MemberCoinsDataModel> recentCoinsList = <MemberCoinsDataModel>[].obs;
@override
void onInit() {
@ -40,7 +38,6 @@ class MemberController extends GetxController {
// 获取用户信息
Future<Map<String, dynamic>> getInfo() async {
await getMemberStat();
await getMemberView();
var res = await MemberHttp.memberInfo(mid: mid);
if (res['status']) {
memberInfo.value = res['data'];
@ -58,14 +55,13 @@ class MemberController extends GetxController {
return res;
}
// 获取用户播放数 获赞数
Future<Map<String, dynamic>> getMemberView() async {
var res = await MemberHttp.memberView(mid: mid);
if (res['status']) {
userStat.addAll(res['data']);
}
return res;
}
// Future getMemberCardInfo() async {
// var res = await MemberHttp.memberCardInfo(mid: mid);
// if (res['status']) {
// print(userStat);
// }
// return res;
// }
// 关注/取关up
Future actionRelationMod() async {
@ -116,28 +112,16 @@ class MemberController extends GetxController {
Future relationSearch() async {
if (userInfo == null) return;
if (mid == ownerMid) return;
var res = await UserHttp.hasFollow(mid);
var res = await UserHttp.relationSearch(mid);
if (res['status']) {
attribute.value = res['data']['attribute'];
switch (attribute.value) {
case 1:
attributeText.value = '悄悄关注';
break;
case 2:
attributeText.value = '关注';
break;
case 6:
attributeText.value = '已互关';
break;
case 128:
attributeText.value = '已拉黑';
break;
default:
attributeText.value = '关注';
}
if (res['data']['special'] == 1) {
attributeText.value += 'SP';
}
attribute.value = res['data']['relation']['attribute'];
attributeText.value = attribute.value == 0
? '关注'
: attribute.value == 2
? '已关注'
: attribute.value == 6
? '互粉'
: '已拉黑';
}
}
@ -189,35 +173,4 @@ class MemberController extends GetxController {
void shareUser() {
Share.share('${memberInfo.value.name} - https://space.bilibili.com/$mid');
}
// 请求专栏
Future getMemberSeasons() async {
if (userInfo == null) return;
var res = await MemberHttp.getMemberSeasons(mid, 1, 10);
if (!res['status']) {
SmartDialog.showToast("用户专栏请求异常:${res['msg']}");
}
return res;
}
// 请求投币视频
Future getRecentCoinVideo() async {
if (userInfo == null) return;
var res = await MemberHttp.getRecentCoinVideo(mid: mid);
recentCoinsList.value = res['data'];
return res;
}
// 跳转查看动态
void pushDynamicsPage() => Get.toNamed('/memberDynamics?mid=$mid');
// 跳转查看投稿
void pushArchivesPage() => Get.toNamed('/memberArchive?mid=$mid');
// 跳转查看专栏
void pushSeasonsPage() {}
// 跳转查看最近投币
void pushRecentCoinsPage() async {
if (recentCoinsList.isNotEmpty) {}
}
}

View File

@ -0,0 +1,31 @@
import 'package:get/get.dart';
import 'package:pilipala/http/member.dart';
class MemberDynamicPanelController extends GetxController {
MemberDynamicPanelController(this.mid);
int? mid;
String offset = '';
int count = 0;
bool hasMore = true;
@override
void onInit() {
super.onInit();
mid ??= int.parse(Get.parameters['mid']!);
}
Future getMemberDynamic() async {
if (!hasMore) {
return {'status': false};
}
var res = await MemberHttp.memberDynamic(
offset: offset,
mid: mid,
);
if (res['status']) {
offset = res['data'].offset;
hasMore = res['data'].hasMore;
}
return res;
}
}

View File

@ -1,4 +1,4 @@
library member_like;
library dynamic_panel;
export './controller.dart';
export './view.dart';

View File

@ -0,0 +1,152 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:loading_more_list/loading_more_list.dart';
import 'package:pilipala/models/dynamics/result.dart';
import 'package:pilipala/pages/dynamics/widgets/dynamic_panel.dart';
import 'package:pilipala/utils/utils.dart';
import 'controller.dart';
class MemberDynamicPanel extends StatefulWidget {
final int? mid;
const MemberDynamicPanel({super.key, this.mid});
@override
State<MemberDynamicPanel> createState() => _MemberDynamicPanelState();
}
class _MemberDynamicPanelState extends State<MemberDynamicPanel>
with AutomaticKeepAliveClientMixin {
DateTime lastRefreshTime = DateTime.now();
late final LoadMoreListSource source;
late final MemberDynamicPanelController _dynamicController;
@override
bool get wantKeepAlive => true;
@override
void initState() {
super.initState();
_dynamicController = Get.put(MemberDynamicPanelController(widget.mid),
tag: Utils.makeHeroTag(widget.mid));
source = LoadMoreListSource(_dynamicController);
}
@override
Widget build(BuildContext context) {
super.build(context);
return LoadingMoreList<DynamicItemModel>(
ListConfig<DynamicItemModel>(
sourceList: source,
itemBuilder: (BuildContext c, DynamicItemModel item, int index) {
return DynamicPanel(item: item);
},
indicatorBuilder: _buildIndicator,
),
);
}
Widget _buildIndicator(BuildContext context, IndicatorStatus status) {
TextStyle style =
TextStyle(fontSize: 13, color: Theme.of(context).colorScheme.outline);
Widget? widget;
switch (status) {
case IndicatorStatus.none:
widget = Container(height: 0.0);
break;
case IndicatorStatus.loadingMoreBusying:
widget = Text('加载中...', style: style);
widget = _setbackground(false, widget, height: 60.0);
break;
case IndicatorStatus.fullScreenBusying:
widget = Text('加载中...', style: style);
widget = _setbackground(true, widget);
break;
case IndicatorStatus.error:
/// TODO 异常逻辑
widget = Text('没有更多了', style: style);
widget = _setbackground(false, widget);
widget = GestureDetector(
onTap: () {},
child: widget,
);
break;
case IndicatorStatus.fullScreenError:
/// TODO 异常逻辑
widget = Text('没有更多了', style: style);
widget = _setbackground(true, widget);
widget = GestureDetector(
onTap: () {},
child: widget,
);
break;
case IndicatorStatus.noMoreLoad:
widget = Text('没有更多了', style: style);
widget = _setbackground(false, widget, height: 60.0);
break;
case IndicatorStatus.empty:
widget = Text('用户没有投稿', style: style);
widget = _setbackground(true, widget);
break;
}
return widget;
}
Widget _setbackground(bool full, Widget widget, {double height = 100}) {
widget = Padding(
padding: height == double.infinity
? EdgeInsets.zero
: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
child: Container(
width: double.infinity,
height: height,
color: Theme.of(context).colorScheme.background,
alignment: Alignment.center,
child: widget,
),
);
return widget;
}
Widget getIndicator(BuildContext context) {
final TargetPlatform platform = Theme.of(context).platform;
return platform == TargetPlatform.iOS
? const CupertinoActivityIndicator(
animating: true,
radius: 16.0,
)
: CircularProgressIndicator(
strokeWidth: 2.0,
valueColor:
AlwaysStoppedAnimation<Color>(Theme.of(context).primaryColor),
);
}
}
class LoadMoreListSource extends LoadingMoreBase<DynamicItemModel> {
late MemberDynamicPanelController ctr;
LoadMoreListSource(this.ctr);
@override
Future<bool> loadData([bool isloadMoreAction = false]) async {
bool isSuccess = false;
var res = await ctr.getMemberDynamic();
if (res['status']) {
addAll(res['data'].items);
}
try {
if (res['data'].hasMore) {
isSuccess = true;
} else {
isSuccess = false;
}
} catch (_) {}
return isSuccess;
}
}

View File

@ -1,16 +1,16 @@
import 'dart:async';
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/pages/member/archive/view.dart';
import 'package:pilipala/pages/member/dynamic/index.dart';
import 'package:pilipala/pages/member/index.dart';
import 'package:pilipala/utils/utils.dart';
import 'widgets/conis.dart';
import 'widgets/profile.dart';
import 'widgets/seasons.dart';
class MemberPage extends StatefulWidget {
const MemberPage({super.key});
@ -23,10 +23,9 @@ class _MemberPageState extends State<MemberPage>
with SingleTickerProviderStateMixin {
late String heroTag;
late MemberController _memberController;
late Future _futureBuilderFuture;
late Future _memberSeasonsFuture;
late Future _memberCoinsFuture;
Future? _futureBuilderFuture;
final ScrollController _extendNestCtr = ScrollController();
late TabController _tabController;
final StreamController<bool> appbarStream = StreamController<bool>();
late int mid;
@ -36,13 +35,12 @@ class _MemberPageState extends State<MemberPage>
mid = int.parse(Get.parameters['mid']!);
heroTag = Get.arguments['heroTag'] ?? Utils.makeHeroTag(mid);
_memberController = Get.put(MemberController(), tag: heroTag);
_tabController = TabController(length: 3, vsync: this, initialIndex: 2);
_futureBuilderFuture = _memberController.getInfo();
_memberSeasonsFuture = _memberController.getMemberSeasons();
_memberCoinsFuture = _memberController.getRecentCoinVideo();
_extendNestCtr.addListener(
() {
double offset = _extendNestCtr.position.pixels;
if (offset > 100) {
if (offset > 230) {
appbarStream.add(true);
} else {
appbarStream.add(false);
@ -61,222 +59,183 @@ class _MemberPageState extends State<MemberPage>
Widget build(BuildContext context) {
return Scaffold(
primary: true,
body: Column(
children: [
AppBar(
title: StreamBuilder(
stream: appbarStream.stream,
initialData: false,
builder: (context, AsyncSnapshot snapshot) {
return AnimatedOpacity(
opacity: snapshot.data ? 1 : 0,
curve: Curves.easeOut,
duration: const Duration(milliseconds: 500),
child: Row(
children: [
Row(
children: [
Obx(
() => NetworkImgLayer(
width: 35,
height: 35,
type: 'avatar',
src: _memberController.face.value,
body: ExtendedNestedScrollView(
controller: _extendNestCtr,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
pinned: false,
primary: true,
elevation: 0,
scrolledUnderElevation: 1,
forceElevated: innerBoxIsScrolled,
expandedHeight: 290,
titleSpacing: 0,
title: StreamBuilder(
stream: appbarStream.stream,
initialData: false,
builder: (context, AsyncSnapshot snapshot) {
return AnimatedOpacity(
opacity: snapshot.data ? 1 : 0,
curve: Curves.easeOut,
duration: const Duration(milliseconds: 500),
child: Row(
children: [
Row(
children: [
Obx(
() => NetworkImgLayer(
width: 35,
height: 35,
type: 'avatar',
src: _memberController.face.value,
),
),
),
const SizedBox(width: 10),
Obx(
() => Text(
_memberController.memberInfo.value.name ?? '',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onBackground,
fontSize: 14),
const SizedBox(width: 10),
Obx(
() => Text(
_memberController.memberInfo.value.name ?? '',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onBackground,
fontSize: 14),
),
),
),
],
],
)
],
),
);
},
),
actions: [
IconButton(
onPressed: () => Get.toNamed(
'/memberSearch?mid=${Get.parameters['mid']}&uname=${_memberController.memberInfo.value.name!}'),
icon: const Icon(Icons.search_outlined),
),
PopupMenuButton(
icon: const Icon(Icons.more_vert),
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
if (_memberController.ownerMid !=
_memberController.mid) ...[
PopupMenuItem(
onTap: () => _memberController.blockUser(),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.block, size: 19),
const SizedBox(width: 10),
Text(_memberController.attribute.value != 128
? '加入黑名单'
: '移除黑名单'),
],
),
)
],
),
);
},
),
actions: [
IconButton(
onPressed: () => Get.toNamed(
'/memberSearch?mid=${Get.parameters['mid']}&uname=${_memberController.memberInfo.value.name!}'),
icon: const Icon(Icons.search_outlined),
),
PopupMenuButton(
icon: const Icon(Icons.more_vert),
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
if (_memberController.ownerMid != _memberController.mid) ...[
PopupMenuItem(
onTap: () => _memberController.blockUser(),
onTap: () => _memberController.shareUser(),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.block, size: 19),
const Icon(Icons.share_outlined, size: 19),
const SizedBox(width: 10),
Text(_memberController.attribute.value != 128
? '加入黑名单'
: '移除黑名单'),
Text(_memberController.ownerMid !=
_memberController.mid
? '分享UP主'
: '分享我的主页'),
],
),
)
),
],
PopupMenuItem(
onTap: () => _memberController.shareUser(),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.share_outlined, size: 19),
const SizedBox(width: 10),
Text(_memberController.ownerMid != _memberController.mid
? '分享UP主'
: '分享我的主页'),
],
),
),
],
),
const SizedBox(width: 4),
],
),
Expanded(
child: SingleChildScrollView(
controller: _extendNestCtr,
child: Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom + 20,
),
child: Column(
const SizedBox(width: 4),
],
flexibleSpace: FlexibleSpaceBar(
background: Stack(
children: [
profileWidget(),
/// 动态链接
ListTile(
onTap: _memberController.pushDynamicsPage,
title: const Text('Ta的动态'),
trailing:
const Icon(Icons.arrow_forward_outlined, size: 19),
),
/// 视频
ListTile(
onTap: _memberController.pushArchivesPage,
title: const Text('Ta的投稿'),
trailing:
const Icon(Icons.arrow_forward_outlined, size: 19),
),
/// 专栏
ListTile(
onTap: () {},
title: const Text('Ta的专栏'),
),
MediaQuery.removePadding(
removeTop: true,
removeBottom: true,
context: context,
child: Padding(
padding: const EdgeInsets.only(
left: StyleString.safeSpace,
right: StyleString.safeSpace,
),
child: FutureBuilder(
future: _memberSeasonsFuture,
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.done) {
if (snapshot.data == null) {
return const SizedBox();
}
if (snapshot.data['status']) {
Map data = snapshot.data as Map;
if (data['data'].seasonsList.isEmpty) {
return commenWidget('用户没有设置专栏');
} else {
return MemberSeasonsPanel(data: data['data']);
}
} else {
// 请求错误
return const SizedBox();
}
} else {
return const SizedBox();
}
},
),
),
),
/// 收藏
/// 追番
/// 最近投币
Obx(
() => _memberController.recentCoinsList.isNotEmpty
? ListTile(
onTap: () {},
title: const Text('最近投币的视频'),
// trailing: const Icon(Icons.arrow_forward_outlined,
// size: 19),
() => _memberController.face.value != ''
? Positioned.fill(
bottom: 10,
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fitWidth,
image: NetworkImage(
_memberController.face.value),
alignment: Alignment.topCenter,
isAntiAlias: true,
),
),
foregroundDecoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Theme.of(context)
.colorScheme
.background
.withOpacity(0.44),
Theme.of(context).colorScheme.background,
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
stops: const [0.0, 0.46],
),
),
),
)
: const SizedBox(),
),
MediaQuery.removePadding(
removeTop: true,
removeBottom: true,
context: context,
child: Padding(
padding: const EdgeInsets.only(
left: StyleString.safeSpace,
right: StyleString.safeSpace,
),
child: FutureBuilder(
future: _memberCoinsFuture,
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.done) {
if (snapshot.data == null) {
return const SizedBox();
}
if (snapshot.data['status']) {
Map data = snapshot.data as Map;
return MemberCoinsPanel(data: data['data']);
} else {
// 请求错误
return const SizedBox();
}
} else {
return const SizedBox();
}
},
),
Positioned(
left: 0,
right: 0,
bottom: 0,
height: 20,
child: Container(
color: Theme.of(context).colorScheme.background,
),
),
// 最近点赞
// ListTile(
// onTap: () {},
// title: const Text('最近点赞的视频'),
// trailing:
// const Icon(Icons.arrow_forward_outlined, size: 19),
// ),
profileWidget(),
],
),
),
),
),
],
];
},
pinnedHeaderSliverHeightBuilder: () {
return MediaQuery.of(context).padding.top + kToolbarHeight;
},
onlyOneScrollInBody: true,
body: Column(
children: [
SizedBox(
width: double.infinity,
height: 50,
child: TabBar(controller: _tabController, tabs: const [
Tab(text: '主页'),
Tab(text: '动态'),
Tab(text: '投稿'),
]),
),
Expanded(
child: TabBarView(
controller: _tabController,
children: [
const Text('主页'),
MemberDynamicPanel(mid: mid),
ArchivePanel(mid: mid),
],
))
],
),
),
);
}
Widget profileWidget() {
return Padding(
padding: const EdgeInsets.only(left: 18, right: 18, bottom: 20),
padding: const EdgeInsets.only(left: 18, right: 18),
child: FutureBuilder(
future: _futureBuilderFuture,
builder: (context, snapshot) {
@ -290,8 +249,8 @@ class _MemberPageState extends State<MemberPage>
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ProfilePanel(ctr: _memberController),
const SizedBox(height: 20),
profile(_memberController),
const SizedBox(height: 14),
Row(
children: [
Flexible(
@ -301,7 +260,7 @@ class _MemberPageState extends State<MemberPage>
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.titleMedium!
.bodyLarge!
.copyWith(fontWeight: FontWeight.bold),
)),
const SizedBox(width: 2),
@ -373,11 +332,29 @@ class _MemberPageState extends State<MemberPage>
softWrap: true,
),
],
const SizedBox(height: 6),
const SizedBox(height: 4),
if (_memberController.memberInfo.value.sign != '')
SelectableText(
_memberController.memberInfo.value.sign!,
),
maxLines: _memberController
.memberInfo.value.official!['title'] !=
''
? 1
: 2,
style: const TextStyle(
overflow: TextOverflow.ellipsis),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: SelectableText(_memberController
.memberInfo.value.sign!),
);
},
);
},
)
],
),
],
@ -388,28 +365,10 @@ class _MemberPageState extends State<MemberPage>
}
} else {
// 骨架屏
return ProfilePanel(ctr: _memberController, loadingStatus: true);
return profile(_memberController, loadingStatus: true);
}
},
),
);
}
Widget commenWidget(msg) {
return Padding(
padding: const EdgeInsets.only(
top: 20,
bottom: 30,
),
child: Center(
child: Text(
msg,
style: Theme.of(context)
.textTheme
.labelMedium!
.copyWith(color: Theme.of(context).colorScheme.outline),
),
),
);
}
}

View File

@ -1,31 +0,0 @@
import 'package:flutter/material.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/models/member/coin.dart';
import 'package:pilipala/pages/member_coin/widgets/item.dart';
class MemberCoinsPanel extends StatelessWidget {
final List<MemberCoinsDataModel>? data;
const MemberCoinsPanel({super.key, this.data});
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, boxConstraints) {
return GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, // Use a fixed count for GridView
crossAxisSpacing: StyleString.safeSpace,
mainAxisSpacing: StyleString.safeSpace,
childAspectRatio: 0.94,
),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: data!.length,
itemBuilder: (context, i) {
return MemberCoinsItem(coinItem: data![i]);
},
);
},
);
}
}

View File

@ -6,162 +6,99 @@ import 'package:pilipala/models/live/item.dart';
import 'package:pilipala/models/member/info.dart';
import 'package:pilipala/utils/utils.dart';
class ProfilePanel extends StatelessWidget {
final dynamic ctr;
final bool loadingStatus;
const ProfilePanel({
super.key,
required this.ctr,
this.loadingStatus = false,
});
@override
Widget build(BuildContext context) {
MemberInfoModel memberInfo = ctr.memberInfo.value;
return Builder(
builder: ((context) {
return Padding(
padding:
EdgeInsets.only(top: MediaQuery.of(context).padding.top - 20),
child: Row(
children: [
Hero(
tag: ctr.heroTag!,
child: Stack(
children: [
NetworkImgLayer(
width: 90,
height: 90,
type: 'avatar',
src: !loadingStatus ? memberInfo.face : ctr.face.value,
),
if (!loadingStatus &&
memberInfo.liveRoom != null &&
memberInfo.liveRoom!.liveStatus == 1)
Positioned(
bottom: 0,
left: 14,
child: GestureDetector(
onTap: () {
LiveItemModel liveItem = LiveItemModel.fromJson({
'title': memberInfo.liveRoom!.title,
'uname': memberInfo.name,
'face': memberInfo.face,
'roomid': memberInfo.liveRoom!.roomId,
'watched_show': memberInfo.liveRoom!.watchedShow,
});
Get.toNamed(
'/liveRoom?roomid=${memberInfo.liveRoom!.roomId}',
arguments: {'liveItem': liveItem},
);
},
child: Container(
padding: const EdgeInsets.fromLTRB(6, 2, 6, 2),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
borderRadius:
const BorderRadius.all(Radius.circular(10)),
),
child: Row(children: [
Image.asset(
'assets/images/live.gif',
height: 10,
),
Text(
' 直播中',
style: TextStyle(
color: Colors.white,
fontSize: Theme.of(context)
.textTheme
.labelSmall!
.fontSize),
)
]),
Widget profile(ctr, {loadingStatus = false}) {
MemberInfoModel memberInfo = ctr.memberInfo.value;
return Builder(
builder: ((context) {
return Padding(
padding: EdgeInsets.only(top: 3 * MediaQuery.of(context).padding.top),
child: Row(
children: [
Hero(
tag: ctr.heroTag!,
child: Stack(
children: [
NetworkImgLayer(
width: 90,
height: 90,
type: 'avatar',
src: !loadingStatus ? memberInfo.face : ctr.face.value,
),
if (!loadingStatus &&
memberInfo.liveRoom != null &&
memberInfo.liveRoom!.liveStatus == 1)
Positioned(
bottom: 0,
left: 14,
child: GestureDetector(
onTap: () {
LiveItemModel liveItem = LiveItemModel.fromJson({
'title': memberInfo.liveRoom!.title,
'uname': memberInfo.name,
'face': memberInfo.face,
'roomid': memberInfo.liveRoom!.roomId,
'watched_show': memberInfo.liveRoom!.watchedShow,
});
Get.toNamed(
'/liveRoom?roomid=${memberInfo.liveRoom!.roomId}',
arguments: {'liveItem': liveItem},
);
},
child: Container(
padding: const EdgeInsets.fromLTRB(6, 2, 6, 2),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
borderRadius:
const BorderRadius.all(Radius.circular(10)),
),
child: Row(children: [
Image.asset(
'assets/images/live.gif',
height: 10,
),
Text(
' 直播中',
style: TextStyle(
color: Colors.white,
fontSize: Theme.of(context)
.textTheme
.labelSmall!
.fontSize),
)
]),
),
)
],
),
),
)
],
),
const SizedBox(width: 12),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding:
const EdgeInsets.only(top: 10, left: 10, right: 10),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
InkWell(
onTap: () {
Get.toNamed(
'/follow?mid=${memberInfo.mid}&name=${memberInfo.name}');
},
child: Column(
children: [
Text(
!loadingStatus
? ctr.userStat!['following'].toString()
: '-',
style: const TextStyle(
fontWeight: FontWeight.bold),
),
Text(
'关注',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize),
)
],
),
),
InkWell(
onTap: () {
Get.toNamed(
'/fan?mid=${memberInfo.mid}&name=${memberInfo.name}');
},
child: Column(
children: [
Text(
!loadingStatus
? ctr.userStat!['follower'] != null
? Utils.numFormat(
ctr.userStat!['follower'],
)
: '-'
: '-',
style: const TextStyle(
fontWeight: FontWeight.bold)),
Text(
'粉丝',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize),
)
],
),
),
Column(
),
const SizedBox(width: 12),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(left: 10, right: 10),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
InkWell(
onTap: () {
Get.toNamed(
'/follow?mid=${memberInfo.mid}&name=${memberInfo.name}');
},
child: Column(
children: [
Text(
!loadingStatus
? ctr.userStat!['likes'] != null
? Utils.numFormat(
ctr.userStat!['likes'],
)
: '-'
: '-',
style: const TextStyle(
fontWeight: FontWeight.bold)),
!loadingStatus
? ctr.userStat!['following'].toString()
: '-',
style: const TextStyle(
fontWeight: FontWeight.bold),
),
Text(
'获赞',
'关注',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
@ -170,89 +107,112 @@ class ProfilePanel extends StatelessWidget {
)
],
),
],
),
),
InkWell(
onTap: () {
Get.toNamed(
'/fan?mid=${memberInfo.mid}&name=${memberInfo.name}');
},
child: Column(
children: [
Text(
!loadingStatus
? Utils.numFormat(
ctr.userStat!['follower'],
)
: '-',
style: const TextStyle(
fontWeight: FontWeight.bold)),
Text(
'粉丝',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize),
)
],
),
),
Column(
children: [
const Text('-',
style: TextStyle(fontWeight: FontWeight.bold)),
Text(
'获赞',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize),
)
],
),
],
),
const SizedBox(height: 10),
if (ctr.ownerMid != ctr.mid && ctr.ownerMid != -1) ...[
Row(
children: [
Obx(
() => Expanded(
child: TextButton(
onPressed: () => ctr.actionRelationMod(),
style: TextButton.styleFrom(
foregroundColor: ctr.attribute.value == -1
? Colors.transparent
: ctr.attribute.value != 0
? Theme.of(context)
.colorScheme
.outline
: Theme.of(context)
.colorScheme
.onPrimary,
backgroundColor: ctr.attribute.value != 0
? Theme.of(context)
.colorScheme
.onInverseSurface
: Theme.of(context)
.colorScheme
.primary, // 设置按钮背景色
),
child: Obx(() => Text(ctr.attributeText.value)),
),
const SizedBox(height: 10),
if (ctr.ownerMid != ctr.mid) ...[
Row(
children: [
Obx(
() => Expanded(
child: TextButton(
onPressed: () => ctr.actionRelationMod(),
style: TextButton.styleFrom(
foregroundColor: ctr.attribute.value == -1
? Colors.transparent
: ctr.attribute.value != 0
? Theme.of(context).colorScheme.outline
: Theme.of(context)
.colorScheme
.onPrimary,
backgroundColor: ctr.attribute.value != 0
? Theme.of(context)
.colorScheme
.onInverseSurface
: Theme.of(context)
.colorScheme
.primary, // 设置按钮背景色
),
child: Obx(() => Text(ctr.attributeText.value)),
),
),
const SizedBox(width: 8),
Expanded(
child: TextButton(
onPressed: () {},
style: TextButton.styleFrom(
backgroundColor: Theme.of(context)
.colorScheme
.onInverseSurface,
),
child: const Text('发消息'),
),
const SizedBox(width: 8),
Expanded(
child: TextButton(
onPressed: () {},
style: TextButton.styleFrom(
backgroundColor: Theme.of(context)
.colorScheme
.onInverseSurface,
),
)
],
)
],
if (ctr.ownerMid == ctr.mid && ctr.ownerMid != -1) ...[
TextButton(
onPressed: () {
SmartDialog.showToast('功能开发中 💪');
},
style: TextButton.styleFrom(
padding: const EdgeInsets.only(left: 80, right: 80),
foregroundColor:
Theme.of(context).colorScheme.onPrimary,
backgroundColor:
Theme.of(context).colorScheme.primary,
),
child: const Text('编辑资料'),
)
],
if (ctr.ownerMid == -1) ...[
TextButton(
onPressed: () {},
style: TextButton.styleFrom(
padding: const EdgeInsets.only(left: 80, right: 80),
foregroundColor:
Theme.of(context).colorScheme.outline,
backgroundColor:
Theme.of(context).colorScheme.onInverseSurface,
),
child: const Text('未登录'),
)
]
],
),
child: const Text('发消息'),
),
)
],
)
] else ...[
TextButton(
onPressed: () {
SmartDialog.showToast('功能开发中 💪');
},
style: TextButton.styleFrom(
padding: const EdgeInsets.only(left: 80, right: 80),
foregroundColor:
Theme.of(context).colorScheme.onPrimary,
backgroundColor: Theme.of(context).colorScheme.primary,
),
child: const Text('编辑资料'),
)
]
],
),
],
),
);
}),
);
}
),
],
),
);
}),
);
}

View File

@ -1,85 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/badge.dart';
import 'package:pilipala/models/member/seasons.dart';
import 'package:pilipala/pages/member_seasons/widgets/item.dart';
class MemberSeasonsPanel extends StatelessWidget {
final MemberSeasonsDataModel? data;
const MemberSeasonsPanel({super.key, this.data});
@override
Widget build(BuildContext context) {
return ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: data!.seasonsList!.length,
itemBuilder: (context, index) {
MemberSeasonsList item = data!.seasonsList![index];
return Padding(
padding: const EdgeInsets.only(bottom: 12, right: 4),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 12, left: 4),
child: Row(
children: [
Text(
item.meta!.name!,
maxLines: 1,
style: Theme.of(context).textTheme.titleSmall!,
),
const SizedBox(width: 10),
PBadge(
stack: 'relative',
size: 'small',
text: item.meta!.total.toString(),
),
const Spacer(),
SizedBox(
width: 35,
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,
),
),
)
],
),
),
LayoutBuilder(
builder: (context, boxConstraints) {
return GridView.builder(
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, // Use a fixed count for GridView
crossAxisSpacing: StyleString.safeSpace,
mainAxisSpacing: StyleString.safeSpace,
childAspectRatio: 0.94,
),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: item.archives!.length,
itemBuilder: (context, i) {
return MemberSeasonsItem(seasonItem: item.archives![i]);
},
);
},
),
],
),
);
},
);
}
}

View File

@ -1,125 +0,0 @@
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/widgets/video_card_h.dart';
import 'package:pilipala/utils/utils.dart';
import 'controller.dart';
class MemberArchivePage extends StatefulWidget {
const MemberArchivePage({super.key});
@override
State<MemberArchivePage> createState() => _MemberArchivePageState();
}
class _MemberArchivePageState extends State<MemberArchivePage> {
late MemberArchiveController _memberArchivesController;
late Future _futureBuilderFuture;
late ScrollController scrollController;
late int mid;
@override
void initState() {
super.initState();
mid = int.parse(Get.parameters['mid']!);
final String heroTag = Utils.makeHeroTag(mid);
_memberArchivesController =
Get.put(MemberArchiveController(), tag: heroTag);
_futureBuilderFuture =
_memberArchivesController.getMemberArchive('onRefresh');
scrollController = _memberArchivesController.scrollController;
scrollController.addListener(
() {
if (scrollController.position.pixels >=
scrollController.position.maxScrollExtent - 200) {
EasyThrottle.throttle(
'member_archives', const Duration(milliseconds: 500), () {
_memberArchivesController.onLoad();
});
}
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('他的投稿'),
// actions: [
// Obx(
// () => PopupMenuButton<String>(
// padding: EdgeInsets.zero,
// tooltip: '投稿排序',
// icon: Icon(
// Icons.more_vert_outlined,
// color: Theme.of(context).colorScheme.outline,
// ),
// position: PopupMenuPosition.under,
// onSelected: (String type) {},
// itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
// for (var i in _memberArchivesController.orderList) ...[
// PopupMenuItem<String>(
// onTap: () {},
// value: _memberArchivesController.currentOrder['label'],
// child: Row(
// mainAxisSize: MainAxisSize.min,
// children: [
// Text(i['label']!),
// if (_memberArchivesController.currentOrder['label'] ==
// i['label']) ...[
// const SizedBox(width: 10),
// const Icon(Icons.done, size: 20),
// ],
// ],
// ),
// ),
// ]
// ],
// ),
// ),
// ],
),
body: CustomScrollView(
controller: _memberArchivesController.scrollController,
slivers: [
FutureBuilder(
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data != null) {
Map data = snapshot.data as Map;
List list = _memberArchivesController.archivesList;
if (data['status']) {
return Obx(
() => list.isNotEmpty
? SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return VideoCardH(
videoItem: list[index],
showOwner: false,
showPubdate: true,
);
},
childCount: list.length,
),
)
: const SliverToBoxAdapter(),
);
} else {
return const SliverToBoxAdapter();
}
} else {
return const SliverToBoxAdapter();
}
} else {
return const SliverToBoxAdapter();
}
},
),
],
),
);
}
}

View File

@ -1,3 +0,0 @@
import 'package:get/get.dart';
class MemberCoinController extends GetxController {}

View File

@ -1,4 +0,0 @@
library member_coin;
export './controller.dart';
export './view.dart';

View File

@ -1,15 +0,0 @@
import 'package:flutter/material.dart';
class MemberCoinPage extends StatefulWidget {
const MemberCoinPage({super.key});
@override
State<MemberCoinPage> createState() => _MemberCoinPageState();
}
class _MemberCoinPageState extends State<MemberCoinPage> {
@override
Widget build(BuildContext context) {
return Scaffold();
}
}

View File

@ -1,95 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/badge.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/common/widgets/stat/view.dart';
import 'package:pilipala/http/search.dart';
import 'package:pilipala/models/member/coin.dart';
import 'package:pilipala/utils/utils.dart';
class MemberCoinsItem extends StatelessWidget {
final MemberCoinsDataModel coinItem;
const MemberCoinsItem({
Key? key,
required this.coinItem,
}) : super(key: key);
@override
Widget build(BuildContext context) {
String heroTag = Utils.makeHeroTag(coinItem.aid);
return Card(
elevation: 0,
clipBehavior: Clip.hardEdge,
margin: EdgeInsets.zero,
child: InkWell(
onTap: () async {
int cid =
await SearchHttp.ab2c(aid: coinItem.aid, bvid: coinItem.bvid);
Get.toNamed('/video?bvid=${coinItem.bvid}&cid=$cid',
arguments: {'videoItem': coinItem, 'heroTag': heroTag});
},
child: Column(
children: [
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight;
return Stack(
children: [
NetworkImgLayer(
src: coinItem.pic,
width: maxWidth,
height: maxHeight,
),
if (coinItem.duration != null)
PBadge(
bottom: 6,
right: 6,
type: 'gray',
text: Utils.timeFormat(coinItem.duration),
)
],
);
}),
),
Padding(
padding: const EdgeInsets.fromLTRB(5, 6, 0, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
coinItem.title!,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
Row(
children: [
StatView(
view: coinItem.view,
theme: 'gray',
),
const Spacer(),
Text(
Utils.CustomStamp_str(
timestamp: coinItem.pubdate, date: 'MM-DD'),
style: TextStyle(
fontSize: 11,
color: Theme.of(context).colorScheme.outline,
),
),
const SizedBox(width: 6)
],
),
],
),
),
],
),
),
);
}
}

View File

@ -1,44 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/http/member.dart';
import 'package:pilipala/models/dynamics/result.dart';
class MemberDynamicsController extends GetxController {
final ScrollController scrollController = ScrollController();
late int mid;
String offset = '';
int count = 0;
bool hasMore = true;
RxList<DynamicItemModel> dynamicsList = <DynamicItemModel>[].obs;
@override
void onInit() {
super.onInit();
mid = int.parse(Get.parameters['mid']!);
}
Future getMemberDynamic(type) async {
if (type == 'onRefresh') {
offset = '';
dynamicsList.clear();
}
if (offset == '-1') {
return;
}
var res = await MemberHttp.memberDynamic(
offset: offset,
mid: mid,
);
if (res['status']) {
dynamicsList.addAll(res['data'].items);
offset = res['data'].offset != '' ? res['data'].offset : '-1';
hasMore = res['data'].hasMore;
}
return res;
}
// 上拉加载
Future onLoad() async {
getMemberDynamic('onLoad');
}
}

View File

@ -1,4 +0,0 @@
library member_dynamics;
export './controller.dart';
export './view.dart';

View File

@ -1,95 +0,0 @@
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/pages/member_dynamics/index.dart';
import 'package:pilipala/utils/utils.dart';
import '../dynamics/widgets/dynamic_panel.dart';
class MemberDynamicsPage extends StatefulWidget {
const MemberDynamicsPage({super.key});
@override
State<MemberDynamicsPage> createState() => _MemberDynamicsPageState();
}
class _MemberDynamicsPageState extends State<MemberDynamicsPage> {
late MemberDynamicsController _memberDynamicController;
late Future _futureBuilderFuture;
late ScrollController scrollController;
late int mid;
@override
void initState() {
super.initState();
mid = int.parse(Get.parameters['mid']!);
final String heroTag = Utils.makeHeroTag(mid);
_memberDynamicController =
Get.put(MemberDynamicsController(), tag: heroTag);
_futureBuilderFuture =
_memberDynamicController.getMemberDynamic('onRefresh');
scrollController = _memberDynamicController.scrollController;
scrollController.addListener(
() {
if (scrollController.position.pixels >=
scrollController.position.maxScrollExtent - 200) {
EasyThrottle.throttle(
'member_dynamics', const Duration(milliseconds: 1000), () {
_memberDynamicController.onLoad();
});
}
},
);
}
@override
void dispose() {
_memberDynamicController.scrollController.removeListener(() {});
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('他的动态'),
),
body: CustomScrollView(
controller: _memberDynamicController.scrollController,
slivers: [
FutureBuilder(
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data != null) {
Map data = snapshot.data as Map;
List list = _memberDynamicController.dynamicsList;
if (data['status']) {
return Obx(
() => list.isNotEmpty
? SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return DynamicPanel(item: list[index]);
},
childCount: list.length,
),
)
: const SliverToBoxAdapter(),
);
} else {
return const SliverToBoxAdapter();
}
} else {
return const SliverToBoxAdapter();
}
} else {
return const SliverToBoxAdapter();
}
},
),
],
),
);
}
}

View File

@ -1,3 +0,0 @@
import 'package:get/get.dart';
class MemberLikeController extends GetxController {}

View File

@ -1,15 +0,0 @@
import 'package:flutter/material.dart';
class MemberLikePage extends StatefulWidget {
const MemberLikePage({super.key});
@override
State<MemberLikePage> createState() => _MemberLikePageState();
}
class _MemberLikePageState extends State<MemberLikePage> {
@override
Widget build(BuildContext context) {
return Scaffold();
}
}

View File

@ -1,47 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/http/member.dart';
import 'package:pilipala/models/member/seasons.dart';
class MemberSeasonsController extends GetxController {
final ScrollController scrollController = ScrollController();
late int mid;
late int seasonId;
int pn = 1;
int ps = 30;
int count = 0;
RxList<MemberArchiveItem> seasonsList = <MemberArchiveItem>[].obs;
late Map page;
@override
void onInit() {
super.onInit();
mid = int.parse(Get.parameters['mid']!);
seasonId = int.parse(Get.parameters['seasonId']!);
}
// 获取专栏详情
Future getSeasonDetail(type) async {
if (type == 'onRefresh') {
pn = 1;
}
var res = await MemberHttp.getSeasonDetail(
mid: mid,
seasonId: seasonId,
pn: pn,
ps: ps,
sortReverse: false,
);
if (res['status']) {
seasonsList.addAll(res['data'].archives);
page = res['data'].page;
pn += 1;
}
return res;
}
// 上拉加载
Future onLoad() async {
getSeasonDetail('onLoad');
}
}

View File

@ -1,4 +0,0 @@
library member_seasons;
export 'controller.dart';
export 'view.dart';

View File

@ -1,103 +0,0 @@
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/constants.dart';
import 'controller.dart';
import 'widgets/item.dart';
class MemberSeasonsPage extends StatefulWidget {
const MemberSeasonsPage({super.key});
@override
State<MemberSeasonsPage> createState() => _MemberSeasonsPageState();
}
class _MemberSeasonsPageState extends State<MemberSeasonsPage> {
final MemberSeasonsController _memberSeasonsController =
Get.put(MemberSeasonsController());
late Future _futureBuilderFuture;
late ScrollController scrollController;
@override
void initState() {
super.initState();
_futureBuilderFuture =
_memberSeasonsController.getSeasonDetail('onRefresh');
scrollController = _memberSeasonsController.scrollController;
scrollController.addListener(
() {
if (scrollController.position.pixels >=
scrollController.position.maxScrollExtent - 200) {
EasyThrottle.throttle(
'member_archives', const Duration(milliseconds: 500), () {
_memberSeasonsController.onLoad();
});
}
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('他的专栏'),
),
body: Padding(
padding: const EdgeInsets.only(
left: StyleString.safeSpace,
right: StyleString.safeSpace,
),
child: SingleChildScrollView(
controller: _memberSeasonsController.scrollController,
child: FutureBuilder(
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data != null) {
Map data = snapshot.data as Map;
List list = _memberSeasonsController.seasonsList;
if (data['status']) {
return Obx(
() => list.isNotEmpty
? LayoutBuilder(
builder: (context, boxConstraints) {
return GridView.builder(
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
crossAxisSpacing: StyleString.safeSpace,
mainAxisSpacing: StyleString.safeSpace,
childAspectRatio: 0.94,
),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: _memberSeasonsController
.seasonsList.length,
itemBuilder: (context, i) {
return MemberSeasonsItem(
seasonItem: _memberSeasonsController
.seasonsList[i],
);
},
);
},
)
: const SizedBox(),
);
} else {
return const SizedBox();
}
} else {
return const SizedBox();
}
} else {
return const SizedBox();
}
},
),
),
),
);
}
}

View File

@ -1,98 +0,0 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/constants.dart';
import 'package:pilipala/common/widgets/badge.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
import 'package:pilipala/common/widgets/stat/view.dart';
import 'package:pilipala/http/search.dart';
import 'package:pilipala/utils/utils.dart';
class MemberSeasonsItem extends StatelessWidget {
final dynamic seasonItem;
const MemberSeasonsItem({
Key? key,
required this.seasonItem,
}) : super(key: key);
@override
Widget build(BuildContext context) {
String heroTag = Utils.makeHeroTag(seasonItem.aid);
return Card(
elevation: 0,
clipBehavior: Clip.hardEdge,
margin: EdgeInsets.zero,
child: InkWell(
onTap: () async {
int cid =
await SearchHttp.ab2c(aid: seasonItem.aid, bvid: seasonItem.bvid);
Get.toNamed('/video?bvid=${seasonItem.bvid}&cid=$cid',
arguments: {'videoItem': seasonItem, 'heroTag': heroTag});
},
child: Column(
children: [
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight;
return Stack(
children: [
Hero(
tag: heroTag,
child: NetworkImgLayer(
src: seasonItem.pic,
width: maxWidth,
height: maxHeight,
),
),
if (seasonItem.duration != null)
PBadge(
bottom: 6,
right: 6,
type: 'gray',
text: Utils.timeFormat(seasonItem.duration),
)
],
);
}),
),
Padding(
padding: const EdgeInsets.fromLTRB(5, 6, 0, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
seasonItem.title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
Row(
children: [
StatView(
view: seasonItem.view,
theme: 'gray',
),
const Spacer(),
Text(
Utils.CustomStamp_str(
timestamp: seasonItem.pubdate, date: 'MM-DD'),
style: TextStyle(
fontSize: 11,
color: Theme.of(context).colorScheme.outline,
),
),
const SizedBox(width: 6)
],
),
],
),
),
],
),
),
);
}
}

View File

@ -129,12 +129,4 @@ class MineController extends GetxController {
}
Get.toNamed('/fan?mid=${userInfo.value.mid}');
}
pushDynamic() {
if (!userLogin.value) {
SmartDialog.showToast('账号未登录');
return;
}
Get.toNamed('/memberDynamics?mid=${userInfo.value.mid}');
}
}

View File

@ -234,7 +234,7 @@ class _MinePageState extends State<MinePage> {
childAspectRatio: 1.67,
children: <Widget>[
InkWell(
onTap: () => _mineController.pushDynamic(),
onTap: () {},
borderRadius: StyleString.mdRadius,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,

View File

@ -159,6 +159,7 @@ class _ImagePreviewState extends State<ImagePreview>
_previewController.onChange(index),
canScrollPage: (GestureDetails? gestureDetails) =>
gestureDetails!.totalScale! <= 1.0,
preloadPagesCount: 2,
itemCount: widget.imgList!.length,
itemBuilder: (BuildContext context, int index) {
return ExtendedImage.network(

View File

@ -3,14 +3,12 @@ import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/http/video.dart';
import 'package:pilipala/models/home/rcmd/result.dart';
// import 'package:pilipala/models/model_rec_video_item.dart';
import 'package:pilipala/utils/storage.dart';
class RcmdController extends GetxController {
final ScrollController scrollController = ScrollController();
int _currentPage = 0;
RxList<RecVideoItemAppModel> videoList = <RecVideoItemAppModel>[].obs;
// RxList<RecVideoItemModel> videoList = <RecVideoItemModel>[].obs;
bool isLoadingMore = true;
OverlayEntry? popupDialog;
Box recVideo = GStrorage.recVideo;
@ -23,7 +21,6 @@ class RcmdController extends GetxController {
super.onInit();
crossAxisCount.value =
setting.get(SettingBoxKey.customRows, defaultValue: 2);
// 读取app端缓存内容
if (recVideo.get('cacheList') != null &&
recVideo.get('cacheList').isNotEmpty) {
List<RecVideoItemAppModel> list = [];
@ -38,11 +35,6 @@ class RcmdController extends GetxController {
// 获取推荐
Future queryRcmdFeed(type) async {
return await queryRcmdFeedApp(type);
}
// 获取app端推荐
Future queryRcmdFeedApp(type) async {
if (isLoadingMore == false) {
return;
}
@ -75,40 +67,6 @@ class RcmdController extends GetxController {
return res;
}
// 获取web端推荐
Future queryRcmdFeedWeb(type) async {
if (isLoadingMore == false) {
return;
}
if (type == 'onRefresh') {
_currentPage = 0;
}
var res = await VideoHttp.rcmdVideoList(
ps: 20,
freshIdx: _currentPage,
);
if (res['status']) {
if (type == 'init') {
if (videoList.isNotEmpty) {
videoList.addAll(res['data']);
} else {
videoList.value = res['data'];
}
} else if (type == 'onRefresh') {
if (enableSaveLastData) {
videoList.insertAll(0, res['data']);
} else {
videoList.value = res['data'];
}
} else if (type == 'onLoad') {
videoList.addAll(res['data']);
}
_currentPage += 1;
}
isLoadingMore = false;
return res;
}
// 下拉刷新
Future onRefresh() async {
isLoadingMore = true;

View File

@ -11,7 +11,6 @@ import 'package:pilipala/common/widgets/animated_dialog.dart';
import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/common/widgets/overlay_pop.dart';
import 'package:pilipala/common/widgets/video_card_v.dart';
import 'package:pilipala/pages/home/index.dart';
import 'package:pilipala/pages/main/index.dart';
import 'controller.dart';
@ -38,8 +37,6 @@ class _RcmdPageState extends State<RcmdPage>
ScrollController scrollController = _rcmdController.scrollController;
StreamController<bool> mainStream =
Get.find<MainController>().bottomBarStream;
StreamController<bool> searchBarStream =
Get.find<HomeController>().searchBarStream;
scrollController.addListener(
() {
if (scrollController.position.pixels >=
@ -50,14 +47,13 @@ class _RcmdPageState extends State<RcmdPage>
_rcmdController.onLoad();
});
}
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);
}
},
);
@ -86,7 +82,6 @@ class _RcmdPageState extends State<RcmdPage>
},
child: CustomScrollView(
controller: _rcmdController.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding:
@ -157,10 +152,11 @@ class _RcmdPageState extends State<RcmdPage>
// crossAxisCount = 1;
// }
int crossAxisCount = ctr.crossAxisCount.value;
double mainAxisExtent = (Get.size.width /
crossAxisCount /
StyleString.aspectRatio) +
(crossAxisCount == 1 ? 68 : MediaQuery.textScalerOf(context).scale(86));
double mainAxisExtent =
(Get.size.width / crossAxisCount / StyleString.aspectRatio) +
(crossAxisCount == 1
? 68
: 86 * MediaQuery.of(context).textScaleFactor);
return SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// 行间距
@ -195,8 +191,8 @@ class _RcmdPageState extends State<RcmdPage>
}
class LoadingMore extends StatelessWidget {
final dynamic ctr;
const LoadingMore({super.key, this.ctr});
dynamic ctr;
LoadingMore({super.key, this.ctr});
@override
Widget build(BuildContext context) {
@ -207,13 +203,12 @@ class LoadingMore extends StatelessWidget {
child: GestureDetector(
onTap: () {
if (ctr != null) {
ctr!.isLoadingMore = true;
ctr!.onLoad();
}
},
child: Center(
child: Text(
'点击加载更多 👇',
'加载更多 👇',
style: TextStyle(
color: Theme.of(context).colorScheme.outline, fontSize: 13),
),

View File

@ -160,25 +160,25 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
}
Widget _searchSuggest() {
SSearchController ssCtr = _searchController;
SSearchController _ssCtr = _searchController;
return Obx(
() => ssCtr.searchSuggestList.isNotEmpty &&
ssCtr.searchSuggestList.first.term != null &&
ssCtr.controller.value.text != ''
() => _ssCtr.searchSuggestList.isNotEmpty &&
_ssCtr.searchSuggestList.first.term != null &&
_ssCtr.controller.value.text != ''
? ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: ssCtr.searchSuggestList.length,
itemCount: _ssCtr.searchSuggestList.length,
itemBuilder: (context, index) {
return InkWell(
customBorder: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4),
),
onTap: () => ssCtr
.onClickKeyword(ssCtr.searchSuggestList[index].term!),
onTap: () => _ssCtr
.onClickKeyword(_ssCtr.searchSuggestList[index].term!),
child: Padding(
padding: const EdgeInsets.only(left: 20, top: 9, bottom: 9),
child: ssCtr.searchSuggestList[index].textRich,
child: _ssCtr.searchSuggestList[index].textRich,
),
);
},
@ -235,7 +235,6 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
return Obx(
() => HotKeyword(
width: width,
// ignore: invalid_use_of_protected_member
hotSearchList: _searchController.hotSearchList.value,
onClick: (keyword) async {
_searchController.searchFocusNode.unfocus();

View File

@ -83,7 +83,6 @@ class _SearchPanelState extends State<SearchPanel>
case SearchType.video:
return SearchVideoPanel(
ctr: _searchPanelController,
// ignore: invalid_use_of_protected_member
list: list.value,
);
case SearchType.media_bangumi:

View File

@ -82,7 +82,6 @@ class _SearchResultPageState extends State<SearchResultPage>
labelStyle: const TextStyle(fontSize: 13),
dividerColor: Colors.transparent,
unselectedLabelColor: Theme.of(context).colorScheme.outline,
tabAlignment: TabAlignment.start,
onTap: (index) {
if (index == _searchResultController!.tabIndex) {
Get.find<SearchPanelController>(

View File

@ -3,7 +3,6 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/models/common/dynamics_type.dart';
import 'package:pilipala/models/common/reply_sort_type.dart';
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
import 'package:pilipala/utils/storage.dart';
import 'widgets/switch_item.dart';
@ -170,12 +169,6 @@ class _ExtraSettingState extends State<ExtraSetting> {
setKey: SettingBoxKey.enableSaveLastData,
defaultVal: false,
),
const SetSwitchItem(
title: '启用ai总结',
subTitle: '视频详情页开启ai总结',
setKey: SettingBoxKey.enableAi,
defaultVal: true,
),
ListTile(
dense: false,
title: Text('评论展示', style: titleStyle),
@ -183,21 +176,23 @@ class _ExtraSettingState extends State<ExtraSetting> {
'当前优先展示「${ReplySortType.values[defaultReplySort].titles}',
style: subTitleStyle,
),
onTap: () async {
int? result = await showDialog(
context: context,
builder: (context) {
return SelectDialog<int>(title: '评论展示', value: defaultReplySort, values: ReplySortType.values.map((e) {
return {'title': e.titles, 'value': e.index};
}).toList());
},
);
if (result != null) {
defaultReplySort = result;
setting.put(SettingBoxKey.replySortType, result);
trailing: PopupMenuButton(
initialValue: defaultReplySort,
icon: const Icon(Icons.more_vert_outlined, size: 22),
onSelected: (item) {
defaultReplySort = item;
setting.put(SettingBoxKey.replySortType, item);
setState(() {});
}
},
},
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
for (var i in ReplySortType.values) ...[
PopupMenuItem(
value: i.index,
child: Text(i.titles),
),
]
],
),
),
ListTile(
dense: false,
@ -206,21 +201,23 @@ class _ExtraSettingState extends State<ExtraSetting> {
'当前优先展示「${DynamicsType.values[defaultDynamicType].labels}',
style: subTitleStyle,
),
onTap: () async {
int? result = await showDialog(
context: context,
builder: (context) {
return SelectDialog<int>(title: '动态展示', value: defaultDynamicType, values: DynamicsType.values.map((e) {
return {'title': e.labels, 'value': e.index};
}).toList());
},
);
if (result != null) {
defaultDynamicType = result;
setting.put(SettingBoxKey.defaultDynamicType, result);
trailing: PopupMenuButton(
initialValue: defaultDynamicType,
icon: const Icon(Icons.more_vert_outlined, size: 22),
onSelected: (item) {
defaultDynamicType = item;
setting.put(SettingBoxKey.defaultDynamicType, item);
setState(() {});
}
},
},
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
for (var i in DynamicsType.values) ...[
PopupMenuItem(
value: i.index,
child: Text(i.labels),
),
]
],
),
),
ListTile(
enableFeedback: true,
@ -228,7 +225,6 @@ class _ExtraSettingState extends State<ExtraSetting> {
title: Text('设置代理', style: titleStyle),
subtitle: Text('设置代理 host:port', style: subTitleStyle),
trailing: Transform.scale(
alignment: Alignment.centerRight,
scale: 0.8,
child: Switch(
thumbIcon: MaterialStateProperty.resolveWith<Icon?>(

View File

@ -44,10 +44,12 @@ class _FontSizeSelectPageState extends State<FontSizeSelectPage> {
body: Column(
children: [
Expanded(
child: Center(
child: Text(
'当前字体大小:${currentSize == 1.0 ? '默认' : currentSize}',
style: TextStyle(fontSize: 14 * currentSize),
child: SingleChildScrollView(
child: Center(
child: Text(
'当前字体大小:${currentSize == 1.0 ? '默认' : currentSize}',
style: TextStyle(fontSize: 14 * currentSize),
),
),
),
),

Some files were not shown because too many files have changed in this diff Show More