mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: singleton FollowTypeController (#1578)
This commit is contained in:
committed by
GitHub
parent
fb59c208e3
commit
77ec78e3fe
@@ -11,11 +11,11 @@ import 'package:get/get.dart';
|
||||
class FansPage extends StatefulWidget {
|
||||
const FansPage({
|
||||
super.key,
|
||||
this.showName,
|
||||
this.showName = true,
|
||||
this.onSelect,
|
||||
});
|
||||
|
||||
final bool? showName;
|
||||
final bool showName;
|
||||
final ValueChanged<UserModel>? onSelect;
|
||||
|
||||
@override
|
||||
@@ -25,15 +25,14 @@ class FansPage extends StatefulWidget {
|
||||
class _FansPageState extends FollowTypePageState<FansPage> {
|
||||
@override
|
||||
late final FansController controller = Get.put(
|
||||
FansController(widget.showName ?? true),
|
||||
tag: Utils.generateRandomString(8),
|
||||
FansController(widget.showName),
|
||||
tag: Get.parameters['mid'],
|
||||
);
|
||||
late final flag = widget.onSelect == null && controller.isOwner;
|
||||
|
||||
@override
|
||||
PreferredSizeWidget? get appBar => widget.showName == false
|
||||
? null
|
||||
: AppBar(
|
||||
PreferredSizeWidget? get appBar => widget.showName
|
||||
? AppBar(
|
||||
title: controller.isOwner
|
||||
? const Text('我的粉丝')
|
||||
: Obx(() {
|
||||
@@ -41,7 +40,8 @@ class _FansPageState extends FollowTypePageState<FansPage> {
|
||||
if (name != null) return Text('$name的粉丝');
|
||||
return const SizedBox.shrink();
|
||||
}),
|
||||
);
|
||||
)
|
||||
: null;
|
||||
|
||||
@override
|
||||
Widget buildItem(int index, FollowItemModel item) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:PiliPlus/pages/follow_type/follow_same/controller.dart';
|
||||
import 'package:PiliPlus/pages/follow_type/view.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@@ -13,9 +13,9 @@ class FollowSamePage extends StatefulWidget {
|
||||
|
||||
class _FollowSamePageState extends FollowTypePageState<FollowSamePage> {
|
||||
@override
|
||||
final controller = Get.put(
|
||||
FollowSameController(),
|
||||
tag: Utils.generateRandomString(8),
|
||||
final controller = Get.putOrFind(
|
||||
FollowSameController.new,
|
||||
tag: Get.parameters['mid'],
|
||||
);
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:PiliPlus/pages/follow_type/followed/controller.dart';
|
||||
import 'package:PiliPlus/pages/follow_type/view.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@@ -13,9 +13,9 @@ class FollowedPage extends StatefulWidget {
|
||||
|
||||
class _FollowedPageState extends FollowTypePageState<FollowedPage> {
|
||||
@override
|
||||
final controller = Get.put(
|
||||
FollowedController(),
|
||||
tag: Utils.generateRandomString(8),
|
||||
final controller = Get.putOrFind(
|
||||
FollowedController.new,
|
||||
tag: Get.parameters['mid'],
|
||||
);
|
||||
|
||||
@override
|
||||
|
||||
@@ -25,7 +25,7 @@ abstract class FollowTypePageState<T extends StatefulWidget> extends State<T> {
|
||||
onRefresh: controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
controller: controller.scrollController,
|
||||
// controller: controller.scrollController,
|
||||
slivers: [
|
||||
ViewSliverSafeArea(
|
||||
sliver: Obx(
|
||||
|
||||
Reference in New Issue
Block a user