fluffychat/lib/utils/room_extension.dart
Marcel 7a3ef82546 [Tests] Add login widget tests
[I18n] Make logic wisget test compatible

Took 1 hour 5 minutes
2020-02-20 21:55:57 +01:00

22 lines
723 B
Dart

import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:flutter/material.dart';
extension LocalizedRoomDisplayname on Room {
String getLocalizedDisplayname(BuildContext context) {
if ((this.name?.isEmpty ?? true) &&
(this.canonicalAlias?.isEmpty ?? true) &&
!this.isDirectChat &&
(this.mHeroes != null && this.mHeroes.isNotEmpty)) {
return I18n.tr(context).groupWith(this.displayname);
}
if ((this.name?.isEmpty ?? true) &&
(this.canonicalAlias?.isEmpty ?? true) &&
!this.isDirectChat &&
(this.mHeroes?.isEmpty ?? true)) {
return I18n.tr(context).emptyChat;
}
return this.displayname;
}
}