mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-15 13:43:56 +08:00
@@ -8,7 +8,7 @@ import 'package:get/get.dart';
|
|||||||
|
|
||||||
class FollowItem extends StatelessWidget {
|
class FollowItem extends StatelessWidget {
|
||||||
final FollowItemModel item;
|
final FollowItemModel item;
|
||||||
final bool? isOwner;
|
final bool isOwner;
|
||||||
final ValueChanged? afterMod;
|
final ValueChanged? afterMod;
|
||||||
final ValueChanged<UserModel>? onSelect;
|
final ValueChanged<UserModel>? onSelect;
|
||||||
|
|
||||||
@@ -16,15 +16,38 @@ class FollowItem extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.item,
|
required this.item,
|
||||||
this.afterMod,
|
this.afterMod,
|
||||||
this.isOwner,
|
bool? isOwner,
|
||||||
this.onSelect,
|
this.onSelect,
|
||||||
});
|
}) : isOwner = isOwner ?? false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final colorScheme = ColorScheme.of(context);
|
final colorScheme = ColorScheme.of(context);
|
||||||
|
Widget? followBtn;
|
||||||
|
if (isOwner) {
|
||||||
|
final isFollow = item.attribute != -1;
|
||||||
|
followBtn = FilledButton.tonal(
|
||||||
|
onPressed: () => RequestUtils.actionRelationMod(
|
||||||
|
context: context,
|
||||||
|
mid: item.mid,
|
||||||
|
isFollow: isFollow,
|
||||||
|
afterMod: afterMod,
|
||||||
|
),
|
||||||
|
style: FilledButton.styleFrom(
|
||||||
|
visualDensity: .compact,
|
||||||
|
tapTargetSize: .shrinkWrap,
|
||||||
|
padding: const .symmetric(horizontal: 15),
|
||||||
|
foregroundColor: isFollow ? colorScheme.outline : null,
|
||||||
|
backgroundColor: isFollow ? colorScheme.onInverseSurface : null,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'${isFollow ? '已' : ''}关注',
|
||||||
|
style: const TextStyle(fontSize: 12),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
return Material(
|
return Material(
|
||||||
type: MaterialType.transparency,
|
type: .transparency,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (onSelect != null) {
|
if (onSelect != null) {
|
||||||
@@ -42,10 +65,7 @@ class FollowItem extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const .symmetric(horizontal: 12, vertical: 10),
|
||||||
horizontal: 12,
|
|
||||||
vertical: 10,
|
|
||||||
),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
PendantAvatar(
|
PendantAvatar(
|
||||||
@@ -58,19 +78,19 @@ class FollowItem extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
spacing: 3,
|
spacing: 3,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: .start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
item.uname!,
|
item.uname!,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: .ellipsis,
|
||||||
style: const TextStyle(fontSize: 14),
|
style: const TextStyle(fontSize: 14),
|
||||||
),
|
),
|
||||||
if (item.sign != null)
|
if (item.sign != null)
|
||||||
Text(
|
Text(
|
||||||
item.sign!,
|
item.sign!,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: .ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: colorScheme.outline,
|
color: colorScheme.outline,
|
||||||
@@ -79,30 +99,7 @@ class FollowItem extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (isOwner ?? false)
|
?followBtn,
|
||||||
FilledButton.tonal(
|
|
||||||
onPressed: () => RequestUtils.actionRelationMod(
|
|
||||||
context: context,
|
|
||||||
mid: item.mid,
|
|
||||||
isFollow: item.attribute != -1,
|
|
||||||
afterMod: afterMod,
|
|
||||||
),
|
|
||||||
style: FilledButton.styleFrom(
|
|
||||||
visualDensity: .compact,
|
|
||||||
tapTargetSize: .shrinkWrap,
|
|
||||||
padding: const .symmetric(horizontal: 15),
|
|
||||||
foregroundColor: item.attribute == -1
|
|
||||||
? null
|
|
||||||
: colorScheme.outline,
|
|
||||||
backgroundColor: item.attribute == -1
|
|
||||||
? null
|
|
||||||
: colorScheme.onInverseSurface,
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
'${item.attribute == -1 ? '' : '已'}关注',
|
|
||||||
style: const TextStyle(fontSize: 12),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user