Skip to content

Commit

Permalink
Merge branch 'guozhigq:main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
KoolShow authored Dec 24, 2023
2 parents 6d2a6e8 + e649fbb commit a7a988b
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 206 deletions.
1 change: 1 addition & 0 deletions lib/http/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class UserHttp {
return {'status': false, 'msg': res.data['message']};
}
}

static Future hasFollow(int mid) async {
var res = await Request().get(
Api.hasFollow,
Expand Down
10 changes: 5 additions & 5 deletions lib/models/model_rec_video_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RecVideoItemModel {
@HiveField(6)
String? title = '';
@HiveField(7)
int? duration = -1;
String? duration = '';
@HiveField(8)
int? pubdate = -1;
@HiveField(9)
Expand All @@ -56,7 +56,7 @@ class RecVideoItemModel {
uri = json["uri"];
pic = json["pic"];
title = json["title"];
duration = json["duration"];
duration = json["duration"].toString();
pubdate = json["pubdate"];
owner = Owner.fromJson(json["owner"]);
stat = Stat.fromJson(json["stat"]);
Expand All @@ -72,19 +72,19 @@ class Stat {
Stat({
this.view,
this.like,
this.danmaku,
this.danmu,
});
@HiveField(0)
int? view;
@HiveField(1)
int? like;
@HiveField(2)
int? danmaku;
int? danmu;

Stat.fromJson(Map<String, dynamic> json) {
view = json["view"];
like = json["like"];
danmaku = json['danmaku'];
danmu = json['danmaku'];
}
}

Expand Down
6 changes: 3 additions & 3 deletions lib/models/model_rec_video_item.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 38 additions & 38 deletions lib/pages/bangumi/widgets/bangumi_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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;
Expand Down Expand Up @@ -35,6 +36,7 @@ class _BangumiPanelState extends State<BangumiPanel> {
late int cid;
String heroTag = Get.arguments['heroTag'];
late final VideoDetailController videoDetailCtr;
final ItemScrollController itemScrollController = ItemScrollController();

@override
void initState() {
Expand Down Expand Up @@ -70,10 +72,11 @@ 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);
// await Future.delayed(const Duration(milliseconds: 200));
// listViewScrollCtr_2.animateTo(currentIndex * 56,
// duration: const Duration(milliseconds: 500),
// curve: Curves.easeInOut);
itemScrollController.jumpTo(index: currentIndex);
});
// 在这里使用 setState 更新状态
return Container(
Expand Down Expand Up @@ -101,42 +104,39 @@ class _BangumiPanelState extends State<BangumiPanel> {
),
Expanded(
child: Material(
child: ListView.builder(
controller: listViewScrollCtr_2,
child: ScrollablePositionedList.builder(
itemCount: widget.pages.length,
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,
),
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,
),
trailing: widget.pages[index].badge != null
? Image.asset(
'assets/images/big-vip.png',
height: 20,
)
: const SizedBox(),
);
},
),
trailing: widget.pages[index].badge != null
? Image.asset(
'assets/images/big-vip.png',
height: 20,
)
: const SizedBox(),
),
itemScrollController: itemScrollController,
),
),
),
Expand Down
9 changes: 7 additions & 2 deletions lib/pages/member_archive/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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 {
Expand All @@ -12,14 +13,18 @@ class MemberArchivePage extends StatefulWidget {
}

class _MemberArchivePageState extends State<MemberArchivePage> {
final MemberArchiveController _memberArchivesController =
Get.put(MemberArchiveController());
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;
Expand Down
44 changes: 27 additions & 17 deletions lib/pages/member_dynamics/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ 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 'package:protobuf/protobuf.dart';

import '../dynamics/widgets/dynamic_panel.dart';

Expand All @@ -13,14 +15,18 @@ class MemberDynamicsPage extends StatefulWidget {
}

class _MemberDynamicsPageState extends State<MemberDynamicsPage> {
final MemberDynamicsController _memberDynamicController =
Get.put(MemberDynamicsController());
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;
Expand Down Expand Up @@ -56,21 +62,25 @@ class _MemberDynamicsPageState extends State<MemberDynamicsPage> {
future: _futureBuilderFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
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(),
);
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();
}
Expand Down
42 changes: 42 additions & 0 deletions lib/pages/rcmd/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ 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;
Expand All @@ -21,6 +23,7 @@ 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 = [];
Expand All @@ -35,6 +38,11 @@ class RcmdController extends GetxController {

// 获取推荐
Future queryRcmdFeed(type) async {
return await queryRcmdFeedApp(type);
}

// 获取app端推荐
Future queryRcmdFeedApp(type) async {
if (isLoadingMore == false) {
return;
}
Expand Down Expand Up @@ -67,6 +75,40 @@ 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;
Expand Down
Loading

0 comments on commit a7a988b

Please sign in to comment.