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