fluffychat/lib/utils/room_extension.dart

22 lines
723 B
Dart
Raw Normal View History

2020-01-19 15:07:42 +01:00
import 'package:famedlysdk/famedlysdk.dart';
2020-01-20 13:46:39 +01:00
import 'package:fluffychat/i18n/i18n.dart';
2020-01-19 15:07:42 +01:00
import 'package:flutter/material.dart';
extension LocalizedRoomDisplayname on Room {
String getLocalizedDisplayname(BuildContext context) {
if ((this.name?.isEmpty ?? true) &&
(this.canonicalAlias?.isEmpty ?? true) &&
2020-01-19 16:56:13 +01:00
!this.isDirectChat &&
(this.mHeroes != null && this.mHeroes.isNotEmpty)) {
2020-01-20 13:46:39 +01:00
return I18n.of(context).groupWith(this.displayname);
2020-01-19 15:07:42 +01:00
}
2020-02-16 08:46:45 +01:00
if ((this.name?.isEmpty ?? true) &&
(this.canonicalAlias?.isEmpty ?? true) &&
!this.isDirectChat &&
(this.mHeroes?.isEmpty ?? true)) {
return I18n.of(context).emptyChat;
}
2020-01-19 15:07:42 +01:00
return this.displayname;
}
}