Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-07-23 16:47:11 +08:00
parent 148e0872b4
commit 418a1e8d39
821 changed files with 29467 additions and 25520 deletions

View File

@@ -48,9 +48,11 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
slivers: [
SliverPadding(
padding: EdgeInsets.only(
bottom: MediaQuery.paddingOf(context).bottom + 80),
bottom: MediaQuery.paddingOf(context).bottom + 80,
),
sliver: Obx(
() => _buildBody(_favPgcController.loadingState.value)),
() => _buildBody(_favPgcController.loadingState.value),
),
),
],
),
@@ -93,14 +95,16 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
value: _favPgcController.allSelected.value,
onChanged: (value) {
_favPgcController.handleSelect(
!_favPgcController.allSelected.value);
!_favPgcController.allSelected.value,
);
},
),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => _favPgcController
.handleSelect(!_favPgcController.allSelected.value),
onTap: () => _favPgcController.handleSelect(
!_favPgcController.allSelected.value,
),
child: const Padding(
padding: EdgeInsets.only(
top: 14,
@@ -112,12 +116,13 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
),
const Spacer(),
...const [
(followStatus: 1, title: '想看'),
(followStatus: 2, title: '在看'),
(followStatus: 3, title: '看过'),
]
.where((item) =>
item.followStatus != widget.followStatus)
(followStatus: 1, title: '想看'),
(followStatus: 2, title: '在看'),
(followStatus: 3, title: '看过'),
]
.where(
(item) => item.followStatus != widget.followStatus,
)
.map(
(item) => Padding(
padding: const EdgeInsets.only(left: 25),
@@ -126,13 +131,16 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
onTap: () {
if (_favPgcController.checkedCount.value !=
0) {
_favPgcController
.onUpdateList(item.followStatus);
_favPgcController.onUpdateList(
item.followStatus,
);
}
},
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 14, horizontal: 5),
vertical: 14,
horizontal: 5,
),
child: Text(
'标记为${item.title}',
style: TextStyle(
@@ -158,56 +166,57 @@ class _FavPgcChildPageState extends State<FavPgcChildPage>
Widget _buildBody(LoadingState<List<FavPgcItemModel>?> loadingState) {
return switch (loadingState) {
Loading() => SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(context, index) {
return const FavPgcItemSkeleton();
},
childCount: 10,
),
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(context, index) {
return const FavPgcItemSkeleton();
},
childCount: 10,
),
Success(:var response) => response?.isNotEmpty == true
? SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == response.length - 1) {
_favPgcController.onLoadMore();
}
final item = response[index];
return FavPgcItem(
item: item,
ctr: _favPgcController,
onSelect: () => _favPgcController.onSelect(item),
onUpdateStatus: () => showPgcFollowDialog(
context: context,
type: widget.type == 0 ? '追番' : '追剧',
followStatus: widget.followStatus,
onUpdateStatus: (followStatus) {
if (followStatus == -1) {
_favPgcController.pgcDel(
index,
item.seasonId,
);
} else {
_favPgcController.onUpdate(
index,
followStatus,
item.seasonId,
);
}
},
),
);
},
childCount: response!.length,
),
)
: HttpError(onReload: _favPgcController.onReload),
),
Success(:var response) =>
response?.isNotEmpty == true
? SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == response.length - 1) {
_favPgcController.onLoadMore();
}
final item = response[index];
return FavPgcItem(
item: item,
ctr: _favPgcController,
onSelect: () => _favPgcController.onSelect(item),
onUpdateStatus: () => showPgcFollowDialog(
context: context,
type: widget.type == 0 ? '追番' : '追剧',
followStatus: widget.followStatus,
onUpdateStatus: (followStatus) {
if (followStatus == -1) {
_favPgcController.pgcDel(
index,
item.seasonId,
);
} else {
_favPgcController.onUpdate(
index,
followStatus,
item.seasonId,
);
}
},
),
);
},
childCount: response!.length,
),
)
: HttpError(onReload: _favPgcController.onReload),
Error(:var errMsg) => HttpError(
errMsg: errMsg,
onReload: _favPgcController.onReload,
),
errMsg: errMsg,
onReload: _favPgcController.onReload,
),
};
}

View File

@@ -41,11 +41,11 @@ class FavPgcController
@override
Future<LoadingState<FavPgcData>> customGetData() => FavHttp.favPgc(
mid: Accounts.main.mid,
type: type,
followStatus: followStatus,
pn: page,
);
mid: Accounts.main.mid,
type: type,
followStatus: followStatus,
pn: page,
);
void onDisable() {
if (checkedCount.value != 0) {
@@ -67,24 +67,28 @@ class FavPgcController
Future<void> onUpdateList(int followStatus) async {
List<FavPgcItemModel> dataList = loadingState.value.data!;
Set<FavPgcItemModel> updateList =
dataList.where((item) => item.checked == true).toSet();
Set<FavPgcItemModel> updateList = dataList
.where((item) => item.checked == true)
.toSet();
final res = await VideoHttp.pgcUpdate(
seasonId: updateList.map((item) => item.seasonId).toList(),
status: followStatus,
);
if (res['status']) {
List<FavPgcItemModel> remainList =
dataList.toSet().difference(updateList).toList();
List<FavPgcItemModel> remainList = dataList
.toSet()
.difference(updateList)
.toList();
loadingState.value = Success(remainList);
enableMultiSelect.value = false;
try {
final ctr = Get.find<FavPgcController>(tag: '$type$followStatus');
if (ctr.loadingState.value.isSuccess) {
ctr.loadingState
..value
.data!
.insertAll(0, updateList.map((item) => item..checked = null))
..value.data!.insertAll(
0,
updateList.map((item) => item..checked = null),
)
..refresh();
ctr.allSelected.value = false;
}

View File

@@ -15,8 +15,11 @@ class FavPgcPage extends StatefulWidget {
class _FavPgcPageState extends State<FavPgcPage>
with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin {
late final TabController _tabController =
TabController(length: 3, vsync: this, initialIndex: 1);
late final TabController _tabController = TabController(
length: 3,
vsync: this,
initialIndex: 1,
);
@override
bool get wantKeepAlive => true;
@@ -46,16 +49,19 @@ class _FavPgcPageState extends State<FavPgcPage>
padding: const EdgeInsets.symmetric(horizontal: 8),
dividerHeight: 0,
indicatorWeight: 0,
indicatorPadding:
const EdgeInsets.symmetric(horizontal: 3, vertical: 8),
indicatorPadding: const EdgeInsets.symmetric(
horizontal: 3,
vertical: 8,
),
indicator: BoxDecoration(
color: theme.colorScheme.secondaryContainer,
borderRadius: const BorderRadius.all(Radius.circular(20)),
),
indicatorSize: TabBarIndicatorSize.tab,
labelStyle: TabBarTheme.of(context)
.labelStyle
?.copyWith(fontSize: 14) ??
labelStyle:
TabBarTheme.of(
context,
).labelStyle?.copyWith(fontSize: 14) ??
const TextStyle(fontSize: 14),
labelColor: theme.colorScheme.onSecondaryContainer,
unselectedLabelColor: theme.colorScheme.outline,

View File

@@ -55,8 +55,7 @@ class FavPgcItem extends StatelessWidget {
AspectRatio(
aspectRatio: 3 / 4,
child: LayoutBuilder(
builder: (BuildContext context,
BoxConstraints boxConstraints) {
builder: (BuildContext context, BoxConstraints boxConstraints) {
return Stack(
clipBehavior: Clip.none,
children: [
@@ -82,52 +81,66 @@ class FavPgcItem extends StatelessWidget {
child: LayoutBuilder(
builder: (context, constraints) =>
AnimatedOpacity(
opacity: item.checked == true ? 1 : 0,
duration: const Duration(milliseconds: 200),
child: Container(
alignment: Alignment.center,
height: constraints.maxHeight,
width: constraints.maxHeight *
StyleString.aspectRatio,
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(
Radius.circular(4)),
color:
Colors.black.withValues(alpha: 0.6),
),
child: SizedBox(
width: 34,
height: 34,
child: AnimatedScale(
scale: item.checked == true ? 1 : 0,
duration:
const Duration(milliseconds: 250),
curve: Curves.easeInOut,
child: IconButton(
tooltip: '取消选择',
style: ButtonStyle(
padding: WidgetStateProperty.all(
EdgeInsets.zero),
backgroundColor:
WidgetStateProperty
.resolveWith(
(states) {
return theme
.colorScheme.surface
.withValues(alpha: 0.8);
},
),
opacity: item.checked == true ? 1 : 0,
duration: const Duration(
milliseconds: 200,
),
child: Container(
alignment: Alignment.center,
height: constraints.maxHeight,
width:
constraints.maxHeight *
StyleString.aspectRatio,
decoration: BoxDecoration(
borderRadius:
const BorderRadius.all(
Radius.circular(4),
),
color: Colors.black.withValues(
alpha: 0.6,
),
onPressed: null,
icon: Icon(
Icons.done_all_outlined,
color: theme.colorScheme.primary,
),
child: SizedBox(
width: 34,
height: 34,
child: AnimatedScale(
scale: item.checked == true
? 1
: 0,
duration: const Duration(
milliseconds: 250,
),
curve: Curves.easeInOut,
child: IconButton(
tooltip: '取消选择',
style: ButtonStyle(
padding:
WidgetStateProperty.all(
EdgeInsets.zero,
),
backgroundColor:
WidgetStateProperty.resolveWith(
(states) {
return theme
.colorScheme
.surface
.withValues(
alpha: 0.8,
);
},
),
),
onPressed: null,
icon: Icon(
Icons.done_all_outlined,
color:
theme.colorScheme.primary,
),
),
),
),
),
),
),
),
),
),
),
@@ -155,7 +168,8 @@ class FavPgcItem extends StatelessWidget {
],
if (item.progress != null) ...[
SizedBox(
height: item.newEp?.indexShow != null ? 2 : 6),
height: item.newEp?.indexShow != null ? 2 : 6,
),
Text(
item.progress!,
style: TextStyle(