mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Display the list of friends of the user
This commit is contained in:
39
lib/ui/tiles/accepted_friend_tile.dart
Normal file
39
lib/ui/tiles/accepted_friend_tile.dart
Normal file
@ -0,0 +1,39 @@
|
||||
import 'package:comunic/models/friend.dart';
|
||||
import 'package:comunic/models/user.dart';
|
||||
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
||||
import 'package:comunic/utils/date_utils.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Accepted friend tile
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class AcceptedFriendTile extends StatelessWidget {
|
||||
final Friend friend;
|
||||
final User user;
|
||||
|
||||
const AcceptedFriendTile(
|
||||
{Key key, @required this.friend, @required this.user})
|
||||
: assert(friend != null),
|
||||
assert(user != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: AccountImageWidget(user: user),
|
||||
title: Text(user.displayName),
|
||||
subtitle: friend.isConnected
|
||||
? Text(
|
||||
tr(
|
||||
"Online",
|
||||
),
|
||||
style: TextStyle(color: Colors.green),
|
||||
)
|
||||
: Text(
|
||||
diffTimeFromNowToStr(friend.lastActive),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
64
lib/ui/tiles/pending_friend_tile.dart
Normal file
64
lib/ui/tiles/pending_friend_tile.dart
Normal file
@ -0,0 +1,64 @@
|
||||
import 'package:comunic/models/friend.dart';
|
||||
import 'package:comunic/models/user.dart';
|
||||
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Pending friend tile
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
typedef RespondFriendshipRequestCallback = void Function(Friend, bool);
|
||||
|
||||
class PendingFriendTile extends StatelessWidget {
|
||||
final Friend friend;
|
||||
final User user;
|
||||
final RespondFriendshipRequestCallback onRespond;
|
||||
|
||||
const PendingFriendTile(
|
||||
{Key key,
|
||||
@required this.friend,
|
||||
@required this.user,
|
||||
@required this.onRespond})
|
||||
: assert(friend != null),
|
||||
assert(user != null),
|
||||
assert(onRespond != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: AccountImageWidget(
|
||||
user: user,
|
||||
),
|
||||
isThreeLine: true,
|
||||
title: Text(user.fullName),
|
||||
subtitle: Container(
|
||||
height: 30.0,
|
||||
margin: EdgeInsets.only(top: 8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
FlatButton(
|
||||
child: Text(
|
||||
tr("Accept").toUpperCase(),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
color: Colors.green,
|
||||
onPressed: () => onRespond(friend, true),
|
||||
),
|
||||
Container(width: 8.0,),
|
||||
FlatButton(
|
||||
child: Text(
|
||||
tr("Reject").toUpperCase(),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
color: Colors.red,
|
||||
onPressed: () => onRespond(friend, false),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user