Make add/remove friend buttons more obviously clickable

This commit is contained in:
Nutcake 2023-05-05 13:15:20 +02:00
parent e76d5390c0
commit cb87c08be6
2 changed files with 27 additions and 4 deletions

View file

@ -45,6 +45,7 @@ class NotificationClient {
channelDescription: _messageChannel.description, channelDescription: _messageChannel.description,
importance: fln.Importance.high, importance: fln.Importance.high,
priority: fln.Priority.max, priority: fln.Priority.max,
actions: [], //TODO: Make clicking message notification open chat of specified user.
styleInformation: fln.MessagingStyleInformation( styleInformation: fln.MessagingStyleInformation(
fln.Person( fln.Person(
name: uname, name: uname,

View file

@ -24,20 +24,44 @@ class _UserListTileState extends State<UserListTile> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final colorScheme = Theme
.of(context)
.colorScheme;
final style = _localAdded ? IconButton.styleFrom(
foregroundColor: colorScheme.onBackground,
side: BorderSide(
color: colorScheme.error,
width: 2
),
) : IconButton.styleFrom(
foregroundColor: colorScheme.onBackground,
side: BorderSide(
color: colorScheme.primary,
width: 2
),
);
return ListTile( return ListTile(
leading: GenericAvatar(imageUri: Aux.neosDbToHttp(widget.user.userProfile?.iconUrl),), leading: GenericAvatar(imageUri: Aux.neosDbToHttp(widget.user.userProfile?.iconUrl),),
title: Text(widget.user.username), title: Text(widget.user.username),
subtitle: Text(_regDateFormat.format(widget.user.registrationDate)), subtitle: Text(_regDateFormat.format(widget.user.registrationDate)),
trailing: IconButton( trailing: IconButton(
splashRadius: 24,
iconSize: 20,
icon: _localAdded ? const Icon(Icons.person_remove) : const Icon(Icons.person_add),
style: style,
onPressed: _loading ? null : () async { onPressed: _loading ? null : () async {
setState(() { setState(() {
_loading = true; _loading = true;
}); });
try { try {
if (_localAdded) { if (_localAdded) {
await UserApi.removeUserAsFriend(ClientHolder.of(context).apiClient, user: widget.user); await UserApi.removeUserAsFriend(ClientHolder
.of(context)
.apiClient, user: widget.user);
} else { } else {
await UserApi.addUserAsFriend(ClientHolder.of(context).apiClient, user: widget.user); await UserApi.addUserAsFriend(ClientHolder
.of(context)
.apiClient, user: widget.user);
} }
} catch (e, s) { } catch (e, s) {
FlutterError.reportError(FlutterErrorDetails(exception: e, stack: s)); FlutterError.reportError(FlutterErrorDetails(exception: e, stack: s));
@ -62,8 +86,6 @@ class _UserListTileState extends State<UserListTile> {
}); });
widget.onChange?.call(); widget.onChange?.call();
}, },
splashRadius: 24,
icon: _localAdded ? const Icon(Icons.person_remove_alt_1) : const Icon(Icons.person_add_alt_1),
), ),
); );
} }