Krille/remove status feature
This commit is contained in:
parent
61ceb7d723
commit
e3f1fc757c
13 changed files with 372 additions and 651 deletions
19
lib/utils/fluffy_share.dart
Normal file
19
lib/utils/fluffy_share.dart
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import 'package:bot_toast/bot_toast.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:share/share.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
abstract class FluffyShare {
|
||||
static Future<void> share(String text, BuildContext context) async {
|
||||
if (PlatformInfos.isMobile) {
|
||||
return Share.share(text);
|
||||
}
|
||||
await Clipboard.setData(
|
||||
ClipboardData(text: text),
|
||||
);
|
||||
BotToast.showText(text: L10n.of(context).copiedToClipboard);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,21 +4,37 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|||
|
||||
import 'date_time_extension.dart';
|
||||
|
||||
extension on PresenceType {
|
||||
String getLocalized(BuildContext context) {
|
||||
switch (this) {
|
||||
case PresenceType.online:
|
||||
return L10n.of(context).online;
|
||||
case PresenceType.unavailable:
|
||||
return L10n.of(context).unavailable;
|
||||
case PresenceType.offline:
|
||||
default:
|
||||
return L10n.of(context).offline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension PresenceExtension on Presence {
|
||||
bool get isUserStatus => presence?.statusMsg?.isNotEmpty ?? false;
|
||||
String getLocalizedLastActiveAgo(BuildContext context) {
|
||||
if (presence.lastActiveAgo != null && presence.lastActiveAgo != 0) {
|
||||
return L10n.of(context).lastActiveAgo(DateTime.fromMillisecondsSinceEpoch(
|
||||
DateTime.now().millisecondsSinceEpoch - presence.lastActiveAgo)
|
||||
.localizedTimeShort(context));
|
||||
}
|
||||
return L10n.of(context).lastSeenLongTimeAgo;
|
||||
}
|
||||
|
||||
String getLocalizedStatusMessage(BuildContext context) {
|
||||
if (presence.statusMsg?.isNotEmpty ?? false) {
|
||||
return presence.statusMsg;
|
||||
}
|
||||
if (presence.lastActiveAgo != null ?? presence.lastActiveAgo != 0) {
|
||||
return L10n.of(context).lastActiveAgo(
|
||||
DateTime.fromMillisecondsSinceEpoch(presence.lastActiveAgo)
|
||||
.localizedTimeShort(context));
|
||||
}
|
||||
if (presence.currentlyActive) {
|
||||
return L10n.of(context).currentlyActive;
|
||||
}
|
||||
return L10n.of(context).lastSeenLongTimeAgo;
|
||||
return presence.presence.getLocalized(context);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
class UserStatus {
|
||||
String statusMsg;
|
||||
String userId;
|
||||
int receivedAt;
|
||||
|
||||
UserStatus();
|
||||
|
||||
UserStatus.fromJson(Map<String, dynamic> json) {
|
||||
statusMsg = json['status_msg'];
|
||||
userId = json['user_id'];
|
||||
receivedAt = json['received_at'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['status_msg'] = statusMsg;
|
||||
data['user_id'] = userId;
|
||||
data['received_at'] = receivedAt;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue