mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-10 03:00:13 +08:00
opt: mapIndexed
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||||
import 'package:PiliPlus/models/model_owner.dart';
|
import 'package:PiliPlus/models/model_owner.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
Widget avatars({
|
Widget avatars({
|
||||||
@@ -28,19 +29,19 @@ Widget avatars({
|
|||||||
width: offset * users.length + gap,
|
width: offset * users.length + gap,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
clipBehavior: .none,
|
clipBehavior: .none,
|
||||||
children: users.indexed
|
children: users
|
||||||
.map(
|
.mapIndexed(
|
||||||
(e) => Positioned(
|
(i, e) => Positioned(
|
||||||
top: 0,
|
top: 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
width: size,
|
width: size,
|
||||||
left: e.$1 * offset,
|
left: i * offset,
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: decoration,
|
decoration: decoration,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const .all(padding),
|
padding: const .all(padding),
|
||||||
child: NetworkImgLayer(
|
child: NetworkImgLayer(
|
||||||
src: e.$2.face,
|
src: e.face,
|
||||||
width: imgSize,
|
width: imgSize,
|
||||||
height: imgSize,
|
height: imgSize,
|
||||||
type: .avatar,
|
type: .avatar,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import 'package:PiliPlus/utils/extension/theme_ext.dart';
|
|||||||
import 'package:PiliPlus/utils/image_utils.dart';
|
import 'package:PiliPlus/utils/image_utils.dart';
|
||||||
import 'package:PiliPlus/utils/page_utils.dart';
|
import 'package:PiliPlus/utils/page_utils.dart';
|
||||||
import 'package:cached_network_image_ce/cached_network_image.dart';
|
import 'package:cached_network_image_ce/cached_network_image.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get_core/src/get_main.dart';
|
import 'package:get/get_core/src/get_main.dart';
|
||||||
@@ -273,14 +274,14 @@ class OpusContent extends StatelessWidget {
|
|||||||
case 5 when (element.list != null):
|
case 5 when (element.list != null):
|
||||||
return SelectableText.rich(
|
return SelectableText.rich(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
children: element.list!.items?.indexed.map((entry) {
|
children: element.list!.items?.mapIndexed((i, entry) {
|
||||||
return TextSpan(
|
return TextSpan(
|
||||||
children: [
|
children: [
|
||||||
const WidgetSpan(
|
const WidgetSpan(
|
||||||
child: Icon(MdiIcons.circleMedium),
|
child: Icon(MdiIcons.circleMedium),
|
||||||
alignment: .middle,
|
alignment: .middle,
|
||||||
),
|
),
|
||||||
...entry.$2.nodes!.map((item) {
|
...entry.nodes!.map((item) {
|
||||||
if (item.word != null) {
|
if (item.word != null) {
|
||||||
return _getSpan(
|
return _getSpan(
|
||||||
item.word,
|
item.word,
|
||||||
@@ -307,7 +308,7 @@ class OpusContent extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
return const TextSpan();
|
return const TextSpan();
|
||||||
}),
|
}),
|
||||||
if (entry.$1 < element.list!.items!.length - 1)
|
if (i < element.list!.items!.length - 1)
|
||||||
const TextSpan(text: '\n'),
|
const TextSpan(text: '\n'),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'package:PiliPlus/pages/live_dm_block/controller.dart';
|
|||||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||||
import 'package:PiliPlus/utils/extension/size_ext.dart';
|
import 'package:PiliPlus/utils/extension/size_ext.dart';
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart' show FilteringTextInputFormatter;
|
import 'package:flutter/services.dart' show FilteringTextInputFormatter;
|
||||||
@@ -168,15 +169,14 @@ class _LiveDmBlockPageState extends State<LiveDmBlockPage> {
|
|||||||
child: Wrap(
|
child: Wrap(
|
||||||
spacing: 12,
|
spacing: 12,
|
||||||
runSpacing: 12,
|
runSpacing: 12,
|
||||||
children: list.indexed.map(
|
children: list.mapIndexed(
|
||||||
(e) {
|
(i, e) {
|
||||||
final item = e.$2;
|
|
||||||
return SearchText(
|
return SearchText(
|
||||||
text: item is ShieldUserList ? item.uname! : item as String,
|
text: e is ShieldUserList ? e.uname! : e as String,
|
||||||
onTap: (value) => showConfirmDialog(
|
onTap: (value) => showConfirmDialog(
|
||||||
context: context,
|
context: context,
|
||||||
title: const Text('确定删除该规则?'),
|
title: const Text('确定删除该规则?'),
|
||||||
onConfirm: () => _controller.onRemove(e.$1, item),
|
onConfirm: () => _controller.onRemove(i, e),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import 'package:PiliPlus/utils/extension/string_ext.dart';
|
|||||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
import 'package:PiliPlus/utils/storage_key.dart';
|
import 'package:PiliPlus/utils/storage_key.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -357,9 +358,8 @@ class _LiveHeaderControlState extends State<LiveHeaderControl>
|
|||||||
padding: .only(
|
padding: .only(
|
||||||
bottom: MediaQuery.viewPaddingOf(context).bottom + 100,
|
bottom: MediaQuery.viewPaddingOf(context).bottom + 100,
|
||||||
),
|
),
|
||||||
children: controller.stream.indexed.map((stream) {
|
children: controller.stream.mapIndexed((si, stream) {
|
||||||
final isCurrStream =
|
final isCurrStream = si == controller.streamIndex;
|
||||||
stream.$1 == controller.streamIndex;
|
|
||||||
final streamColor = isCurrStream
|
final streamColor = isCurrStream
|
||||||
? secondary
|
? secondary
|
||||||
: onSurfaceVariant;
|
: onSurfaceVariant;
|
||||||
@@ -368,15 +368,14 @@ class _LiveHeaderControlState extends State<LiveHeaderControl>
|
|||||||
iconColor: streamColor,
|
iconColor: streamColor,
|
||||||
collapsedIconColor: streamColor,
|
collapsedIconColor: streamColor,
|
||||||
title: Text(
|
title: Text(
|
||||||
stream.$2.protocolName ?? stream.$1.toString(),
|
stream.protocolName ?? si.toString(),
|
||||||
style: isCurrStream
|
style: isCurrStream
|
||||||
? currStyle
|
? currStyle
|
||||||
: const TextStyle(fontSize: 14),
|
: const TextStyle(fontSize: 14),
|
||||||
),
|
),
|
||||||
children: stream.$2.format.indexed.map((format) {
|
children: stream.format.mapIndexed((fi, format) {
|
||||||
final isCurrFormat =
|
final isCurrFormat =
|
||||||
isCurrStream &&
|
isCurrStream && fi == controller.formatIndex;
|
||||||
format.$1 == controller.formatIndex;
|
|
||||||
final formatColor = isCurrFormat
|
final formatColor = isCurrFormat
|
||||||
? secondary
|
? secondary
|
||||||
: onSurfaceVariant;
|
: onSurfaceVariant;
|
||||||
@@ -385,16 +384,14 @@ class _LiveHeaderControlState extends State<LiveHeaderControl>
|
|||||||
iconColor: formatColor,
|
iconColor: formatColor,
|
||||||
collapsedIconColor: formatColor,
|
collapsedIconColor: formatColor,
|
||||||
title: Text(
|
title: Text(
|
||||||
format.$2.formatName ?? format.$1.toString(),
|
format.formatName ?? fi.toString(),
|
||||||
style: isCurrFormat
|
style: isCurrFormat
|
||||||
? currStyle
|
? currStyle
|
||||||
: const TextStyle(fontSize: 14),
|
: const TextStyle(fontSize: 14),
|
||||||
),
|
),
|
||||||
children: format.$2.codec.indexed.map((codec) {
|
children: format.codec.mapIndexed((ci, codec) {
|
||||||
final e = codec.$2;
|
|
||||||
final isCurrCodec =
|
final isCurrCodec =
|
||||||
isCurrFormat &&
|
isCurrFormat && ci == controller.codecIndex;
|
||||||
codec.$1 == controller.codecIndex;
|
|
||||||
final codecColor = isCurrCodec
|
final codecColor = isCurrCodec
|
||||||
? secondary
|
? secondary
|
||||||
: onSurfaceVariant;
|
: onSurfaceVariant;
|
||||||
@@ -403,19 +400,19 @@ class _LiveHeaderControlState extends State<LiveHeaderControl>
|
|||||||
iconColor: codecColor,
|
iconColor: codecColor,
|
||||||
collapsedIconColor: codecColor,
|
collapsedIconColor: codecColor,
|
||||||
title: Text(
|
title: Text(
|
||||||
'${e.codecName ?? codec.$1.toString()} (${LiveQuality.fromCode(e.currentQn)?.desc ?? e.currentQn})',
|
'${codec.codecName ?? ci.toString()} (${LiveQuality.fromCode(codec.currentQn)?.desc ?? codec.currentQn})',
|
||||||
style: isCurrCodec
|
style: isCurrCodec
|
||||||
? currStyle
|
? currStyle
|
||||||
: const TextStyle(fontSize: 14),
|
: const TextStyle(fontSize: 14),
|
||||||
),
|
),
|
||||||
children: e.urlInfo.indexed.map((url) {
|
children: codec.urlInfo.mapIndexed((ui, url) {
|
||||||
final isCurrUrl =
|
final isCurrUrl =
|
||||||
(isCurrCodec &&
|
isCurrCodec &&
|
||||||
url.$1 == controller.liveUrlIndex);
|
ui == controller.liveUrlIndex;
|
||||||
return ListTile(
|
return ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
title: Text(
|
title: Text(
|
||||||
'${url.$2.host}${e.baseUrl}...',
|
'${url.host}...',
|
||||||
style: isCurrUrl
|
style: isCurrUrl
|
||||||
? const TextStyle(fontSize: 14)
|
? const TextStyle(fontSize: 14)
|
||||||
: TextStyle(
|
: TextStyle(
|
||||||
@@ -429,17 +426,17 @@ class _LiveHeaderControlState extends State<LiveHeaderControl>
|
|||||||
: () {
|
: () {
|
||||||
Get.back();
|
Get.back();
|
||||||
controller.initLiveUrl(
|
controller.initLiveUrl(
|
||||||
streamIndex: stream.$1,
|
streamIndex: si,
|
||||||
formatIndex: format.$1,
|
formatIndex: fi,
|
||||||
codecIndex: codec.$1,
|
codecIndex: ci,
|
||||||
liveUrlIndex: url.$1,
|
liveUrlIndex: ui,
|
||||||
);
|
);
|
||||||
GStorage.setting.put(
|
GStorage.setting.put(
|
||||||
SettingBoxKey.liveStream,
|
SettingBoxKey.liveStream,
|
||||||
[
|
[
|
||||||
stream.$2.protocolName,
|
stream.protocolName!,
|
||||||
format.$2.formatName,
|
format.formatName!,
|
||||||
codec.$2.codecName,
|
codec.codecName!,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ 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;
|
||||||
|
late EdgeInsets padding;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -29,7 +30,7 @@ class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
|||||||
.map((e) => Pair(first: e, second: cache?.contains(e.index) ?? true))
|
.map((e) => Pair(first: e, second: cache?.contains(e.index) ?? true))
|
||||||
.toList();
|
.toList();
|
||||||
if (cache != null && cache.isNotEmpty) {
|
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) {
|
list.sort((a, b) {
|
||||||
final indexA = cacheIndex[a.first.index] ?? cacheIndex.length;
|
final indexA = cacheIndex[a.first.index] ?? cacheIndex.length;
|
||||||
final indexB = cacheIndex[b.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() {
|
void saveEdit() {
|
||||||
GStorage.setting.put(
|
GStorage.setting.put(
|
||||||
key,
|
key,
|
||||||
@@ -73,9 +81,7 @@ class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
|||||||
onReorderItem: onReorderItem,
|
onReorderItem: onReorderItem,
|
||||||
proxyDecorator: proxyDecorator,
|
proxyDecorator: proxyDecorator,
|
||||||
footer: Padding(
|
footer: Padding(
|
||||||
padding:
|
padding: padding,
|
||||||
MediaQuery.viewPaddingOf(context).copyWith(top: 0, left: 0) +
|
|
||||||
const EdgeInsets.only(right: 34, top: 10),
|
|
||||||
child: const Align(
|
child: const Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: Text('*长按拖动排序'),
|
child: Text('*长按拖动排序'),
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import 'package:PiliPlus/utils/storage.dart';
|
|||||||
import 'package:PiliPlus/utils/storage_key.dart';
|
import 'package:PiliPlus/utils/storage_key.dart';
|
||||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||||
import 'package:PiliPlus/utils/theme_utils.dart';
|
import 'package:PiliPlus/utils/theme_utils.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flex_seed_scheme/flex_seed_scheme.dart';
|
import 'package:flex_seed_scheme/flex_seed_scheme.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
@@ -148,10 +149,8 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
|||||||
alignment: WrapAlignment.center,
|
alignment: WrapAlignment.center,
|
||||||
spacing: 22,
|
spacing: 22,
|
||||||
runSpacing: 18,
|
runSpacing: 18,
|
||||||
children: colorThemeTypes.indexed.map(
|
children: colorThemeTypes.mapIndexed(
|
||||||
(e) {
|
(index, item) {
|
||||||
final index = e.$1;
|
|
||||||
final item = e.$2;
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|||||||
@@ -724,19 +724,16 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
...videoDetailController.subtitles.indexed.map((e) {
|
...videoDetailController.subtitles.mapIndexed((i, e) {
|
||||||
return PopupMenuItem<int>(
|
return PopupMenuItem<int>(
|
||||||
value: e.$1 + 1,
|
value: i + 1,
|
||||||
height: 35,
|
height: 35,
|
||||||
onTap: () => videoDetailController.setSubtitle(e.$1 + 1),
|
onTap: () => videoDetailController.setSubtitle(i + 1),
|
||||||
child: Text(
|
child: Text(
|
||||||
"${e.$2.lanDoc}",
|
e.lanDoc ?? e.lan,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: const TextStyle(
|
style: const .new(color: Colors.white, fontSize: 13),
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 13,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user