mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-29 22:00:16 +08:00
opt: mapIndexed
This commit is contained in:
@@ -17,6 +17,7 @@ class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
||||
late final String key;
|
||||
late final String title;
|
||||
late final List<Pair<EnumWithLabel, bool>> list;
|
||||
late EdgeInsets padding;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -29,7 +30,7 @@ class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
||||
.map((e) => Pair(first: e, second: cache?.contains(e.index) ?? true))
|
||||
.toList();
|
||||
if (cache != null && cache.isNotEmpty) {
|
||||
final cacheIndex = {for (final (k, v) in cache.indexed) v: k};
|
||||
final cacheIndex = {for (int i = 0; i < cache.length; i++) cache[i]: i};
|
||||
list.sort((a, b) {
|
||||
final indexA = cacheIndex[a.first.index] ?? cacheIndex.length;
|
||||
final indexB = cacheIndex[b.first.index] ?? cacheIndex.length;
|
||||
@@ -38,6 +39,13 @@ class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
final viewPad = MediaQuery.viewPaddingOf(context);
|
||||
padding = .only(top: 10, right: viewPad.right + 34, bottom: viewPad.bottom);
|
||||
}
|
||||
|
||||
void saveEdit() {
|
||||
GStorage.setting.put(
|
||||
key,
|
||||
@@ -73,9 +81,7 @@ class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
||||
onReorderItem: onReorderItem,
|
||||
proxyDecorator: proxyDecorator,
|
||||
footer: Padding(
|
||||
padding:
|
||||
MediaQuery.viewPaddingOf(context).copyWith(top: 0, left: 0) +
|
||||
const EdgeInsets.only(right: 34, top: 10),
|
||||
padding: padding,
|
||||
child: const Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text('*长按拖动排序'),
|
||||
|
||||
@@ -15,6 +15,7 @@ import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/theme_utils.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flex_seed_scheme/flex_seed_scheme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@@ -148,10 +149,8 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 22,
|
||||
runSpacing: 18,
|
||||
children: colorThemeTypes.indexed.map(
|
||||
(e) {
|
||||
final index = e.$1;
|
||||
final item = e.$2;
|
||||
children: colorThemeTypes.mapIndexed(
|
||||
(index, item) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
|
||||
Reference in New Issue
Block a user