mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-06 01:57:45 +08:00
18
lib/common/widgets/reorder_mixin.dart
Normal file
18
lib/common/widgets/reorder_mixin.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
mixin ReorderMixin<T extends StatefulWidget> on State<T> {
|
||||
late ColorScheme scheme;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
scheme = ColorScheme.of(context);
|
||||
}
|
||||
|
||||
Widget proxyDecorator(Widget child, _, _) {
|
||||
return ColoredBox(
|
||||
color: scheme.onInverseSurface,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/common/widgets/reorder_mixin.dart';
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_folder/list.dart';
|
||||
@@ -16,10 +17,10 @@ class FavFolderSortPage extends StatefulWidget {
|
||||
State<FavFolderSortPage> createState() => _FavFolderSortPageState();
|
||||
}
|
||||
|
||||
class _FavFolderSortPageState extends State<FavFolderSortPage> {
|
||||
class _FavFolderSortPageState extends State<FavFolderSortPage>
|
||||
with ReorderMixin {
|
||||
FavController get _favController => widget.favController;
|
||||
|
||||
final GlobalKey _key = GlobalKey();
|
||||
late List<FavFolderInfo> sortList = List<FavFolderInfo>.from(
|
||||
_favController.loadingState.value.data!,
|
||||
);
|
||||
@@ -73,8 +74,8 @@ class _FavFolderSortPageState extends State<FavFolderSortPage> {
|
||||
|
||||
Widget get _buildBody {
|
||||
return ReorderableListView.builder(
|
||||
key: _key,
|
||||
onReorder: onReorder,
|
||||
proxyDecorator: proxyDecorator,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemCount: sortList.length,
|
||||
padding:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/common/widgets/reorder_mixin.dart';
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_detail/media.dart';
|
||||
@@ -17,10 +18,9 @@ class FavSortPage extends StatefulWidget {
|
||||
State<FavSortPage> createState() => _FavSortPageState();
|
||||
}
|
||||
|
||||
class _FavSortPageState extends State<FavSortPage> {
|
||||
class _FavSortPageState extends State<FavSortPage> with ReorderMixin {
|
||||
FavDetailController get _favDetailController => widget.favDetailController;
|
||||
|
||||
final GlobalKey _key = GlobalKey();
|
||||
late List<FavDetailItemModel> sortList = List<FavDetailItemModel>.from(
|
||||
_favDetailController.loadingState.value.data!,
|
||||
);
|
||||
@@ -102,8 +102,8 @@ class _FavSortPageState extends State<FavSortPage> {
|
||||
|
||||
Widget get _buildBody {
|
||||
final child = ReorderableListView.builder(
|
||||
key: _key,
|
||||
onReorder: onReorder,
|
||||
proxyDecorator: proxyDecorator,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding:
|
||||
MediaQuery.viewPaddingOf(context).copyWith(top: 0) +
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/common/widgets/reorder_mixin.dart';
|
||||
import 'package:PiliPlus/http/follow.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/member/tags.dart';
|
||||
@@ -16,9 +17,8 @@ class FollowTagSortPage extends StatefulWidget {
|
||||
State<FollowTagSortPage> createState() => _FollowTagSortPageState();
|
||||
}
|
||||
|
||||
class _FollowTagSortPageState extends State<FollowTagSortPage> {
|
||||
late ColorScheme _scheme;
|
||||
final GlobalKey _key = GlobalKey();
|
||||
class _FollowTagSortPageState extends State<FollowTagSortPage>
|
||||
with ReorderMixin {
|
||||
final List<MemberTagItemModel> _defTags = <MemberTagItemModel>[];
|
||||
final List<MemberTagItemModel> _customTags = <MemberTagItemModel>[];
|
||||
|
||||
@@ -34,12 +34,6 @@ class _FollowTagSortPageState extends State<FollowTagSortPage> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_scheme = ColorScheme.of(context);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -90,12 +84,12 @@ class _FollowTagSortPageState extends State<FollowTagSortPage> {
|
||||
|
||||
Widget get _buildBody {
|
||||
return ReorderableListView.builder(
|
||||
key: _key,
|
||||
onReorder: onReorder,
|
||||
proxyDecorator: proxyDecorator,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding:
|
||||
MediaQuery.viewPaddingOf(context).copyWith(top: 0) +
|
||||
const EdgeInsets.only(bottom: 100),
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.viewPaddingOf(context).bottom + 100,
|
||||
),
|
||||
header: Column(
|
||||
children: _defTags.map((e) => _buildItem(e, enabled: false)).toList(),
|
||||
),
|
||||
@@ -111,14 +105,14 @@ class _FollowTagSortPageState extends State<FollowTagSortPage> {
|
||||
bool enabled = true,
|
||||
}) {
|
||||
return ListTile(
|
||||
textColor: enabled ? null : _scheme.outline,
|
||||
textColor: enabled ? null : scheme.outline,
|
||||
key: ValueKey(item.tagid),
|
||||
leading: enabled
|
||||
? const Icon(Icons.group_outlined)
|
||||
: Icon(
|
||||
size: 23,
|
||||
Icons.lock_outline,
|
||||
color: _scheme.outline,
|
||||
color: scheme.outline,
|
||||
),
|
||||
minLeadingWidth: 0,
|
||||
title: Text('${item.name} (${item.count})'),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:PiliPlus/common/widgets/pair.dart';
|
||||
import 'package:PiliPlus/common/widgets/reorder_mixin.dart';
|
||||
import 'package:PiliPlus/models/common/enum_with_label.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -12,7 +13,7 @@ class BarSetPage extends StatefulWidget {
|
||||
State<BarSetPage> createState() => _BarSetPageState();
|
||||
}
|
||||
|
||||
class _BarSetPageState extends State<BarSetPage> {
|
||||
class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
||||
late final String key;
|
||||
late final String title;
|
||||
late final List<Pair<EnumWithLabel, bool>> list;
|
||||
@@ -71,6 +72,7 @@ class _BarSetPageState extends State<BarSetPage> {
|
||||
),
|
||||
body: ReorderableListView(
|
||||
onReorder: onReorder,
|
||||
proxyDecorator: proxyDecorator,
|
||||
footer: Padding(
|
||||
padding:
|
||||
MediaQuery.viewPaddingOf(context).copyWith(top: 0, left: 0) +
|
||||
|
||||
Reference in New Issue
Block a user