mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
* Add multi-select support to share panel - Replace single selection index with per-user selected flag - Allow sending to multiple selected users - Add sending state to prevent multiple clicks - Update default selection logic to mark first user as selected * 简化代码逻辑 * update Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> --------- Signed-off-by: lesetong <oscarlbw@qq.com> Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
89 lines
2.4 KiB
Dart
89 lines
2.4 KiB
Dart
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||
import 'package:PiliPlus/models_new/follow/list.dart';
|
||
import 'package:PiliPlus/pages/fan/controller.dart';
|
||
import 'package:PiliPlus/pages/follow_type/view.dart';
|
||
import 'package:PiliPlus/pages/follow_type/widgets/item.dart';
|
||
import 'package:PiliPlus/pages/share/view.dart' show UserModel;
|
||
import 'package:PiliPlus/utils/platform_utils.dart';
|
||
import 'package:PiliPlus/utils/utils.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:get/get.dart';
|
||
|
||
class FansPage extends StatefulWidget {
|
||
const FansPage({
|
||
super.key,
|
||
this.showName = true,
|
||
this.onSelect,
|
||
});
|
||
|
||
final bool showName;
|
||
final ValueChanged<UserModel>? onSelect;
|
||
|
||
@override
|
||
State<FansPage> createState() => _FansPageState();
|
||
|
||
static void toFansPage({dynamic mid, String? name}) {
|
||
if (mid == null) {
|
||
return;
|
||
}
|
||
Get.toNamed(
|
||
'/fan',
|
||
arguments: {
|
||
'mid': Utils.safeToInt(mid),
|
||
'name': name,
|
||
},
|
||
);
|
||
}
|
||
}
|
||
|
||
class _FansPageState extends FollowTypePageState<FansPage> {
|
||
@override
|
||
late final FansController controller = Get.put(
|
||
FansController(widget.showName),
|
||
tag: Get.arguments?['mid']?.toString() ?? Utils.generateRandomString(8),
|
||
);
|
||
late final flag = widget.onSelect == null && controller.isOwner;
|
||
|
||
@override
|
||
PreferredSizeWidget? get appBar => widget.showName
|
||
? AppBar(
|
||
title: controller.isOwner
|
||
? const Text('我的粉丝')
|
||
: Obx(() {
|
||
final name = controller.name.value;
|
||
if (name != null) return Text('$name的粉丝');
|
||
return const SizedBox.shrink();
|
||
}),
|
||
)
|
||
: null;
|
||
|
||
@override
|
||
Widget buildItem(int index, FollowItemModel item) {
|
||
void onRemove() => showConfirmDialog(
|
||
context: context,
|
||
title: '确定移除 ${item.uname} ?',
|
||
onConfirm: () => controller.onRemoveFan(index, item.mid),
|
||
);
|
||
|
||
return FollowTypeItem(
|
||
item: item,
|
||
onTap: () {
|
||
if (widget.onSelect != null) {
|
||
widget.onSelect!(
|
||
UserModel(
|
||
mid: item.mid,
|
||
name: item.uname!,
|
||
avatar: item.face!,
|
||
selected: true,
|
||
),
|
||
);
|
||
return;
|
||
}
|
||
Get.toNamed('/member?mid=${item.mid}');
|
||
},
|
||
onLongPress: flag ? onRemove : null,
|
||
onSecondaryTap: flag && !PlatformUtils.isMobile ? onRemove : null,
|
||
);
|
||
}
|
||
}
|