kopia lustrzana https://gitlab.com/mysocialportal/relatica
81 wiersze
1.8 KiB
Dart
81 wiersze
1.8 KiB
Dart
class Connection {
|
|
final ConnectionStatus status;
|
|
|
|
final String name;
|
|
|
|
final String id;
|
|
|
|
final Uri profileUrl;
|
|
|
|
final String network;
|
|
|
|
final Uri avatarUrl;
|
|
|
|
Connection(
|
|
{this.status = ConnectionStatus.unknown,
|
|
this.name = '',
|
|
this.id = '',
|
|
Uri? profileUrl,
|
|
this.network = '',
|
|
Uri? avatarUrl})
|
|
: profileUrl = profileUrl ?? Uri(),
|
|
avatarUrl = avatarUrl ?? Uri();
|
|
|
|
Connection copy(
|
|
{ConnectionStatus? status,
|
|
String? name,
|
|
String? id,
|
|
Uri? profileUrl,
|
|
String? network,
|
|
Uri? avatarUrl}) =>
|
|
Connection(
|
|
status: status ?? this.status,
|
|
name: name ?? this.name,
|
|
id: id ?? this.id,
|
|
profileUrl: profileUrl ?? this.profileUrl,
|
|
network: network ?? this.network,
|
|
avatarUrl: avatarUrl ?? this.avatarUrl,
|
|
);
|
|
|
|
@override
|
|
String toString() {
|
|
return 'Connection{status: $status, name: $name, id: $id, profileUrl: $profileUrl, network: $network, avatar: $avatarUrl}';
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is Connection && runtimeType == other.runtimeType && id == other.id;
|
|
|
|
@override
|
|
int get hashCode => id.hashCode;
|
|
}
|
|
|
|
enum ConnectionStatus {
|
|
youFollowThem,
|
|
theyFollowYou,
|
|
mutual,
|
|
you,
|
|
none,
|
|
unknown,
|
|
}
|
|
|
|
extension FriendStatusWriter on ConnectionStatus {
|
|
String label() {
|
|
switch (this) {
|
|
case ConnectionStatus.youFollowThem:
|
|
return "You Follow Them";
|
|
case ConnectionStatus.theyFollowYou:
|
|
return "They Follow You";
|
|
case ConnectionStatus.mutual:
|
|
return "Follow each other";
|
|
case ConnectionStatus.none:
|
|
return "Not connected";
|
|
case ConnectionStatus.you:
|
|
return "You";
|
|
case ConnectionStatus.unknown:
|
|
return 'Unknown';
|
|
}
|
|
}
|
|
}
|