Add group prefix

This commit is contained in:
Christian Pauly 2020-01-08 20:43:30 +01:00
parent c686c8ce0e
commit 8b3101c7e3
6 changed files with 30 additions and 7 deletions

View file

@ -2,3 +2,5 @@
### New features ### New features
- Added changelog - Added changelog
- Added copy button - Added copy button
### Fixes
- Groups without name now have a "Group with" prefix

View file

@ -2,6 +2,7 @@ import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/message_content.dart'; import 'package:fluffychat/components/message_content.dart';
import 'package:fluffychat/utils/chat_time.dart'; import 'package:fluffychat/utils/chat_time.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/utils/room_name_calculator.dart';
import 'package:fluffychat/views/chat.dart'; import 'package:fluffychat/views/chat.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:toast/toast.dart'; import 'package:toast/toast.dart';
@ -85,7 +86,7 @@ class ChatListItem extends StatelessWidget {
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Text( child: Text(
room.displayname, RoomNameCalculator(room).name,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),

View file

@ -4,6 +4,7 @@ import 'dart:io';
import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/utils/room_name_calculator.dart';
import 'package:fluffychat/utils/sqflite_store.dart'; import 'package:fluffychat/utils/sqflite_store.dart';
import 'package:fluffychat/views/chat.dart'; import 'package:fluffychat/views/chat.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@ -283,7 +284,7 @@ class MatrixState extends State<Matrix> {
// The person object for the android message style notification // The person object for the android message style notification
final person = Person( final person = Person(
name: room.displayname, name: RoomNameCalculator(room).name,
icon: room.avatar.mxc.isEmpty icon: room.avatar.mxc.isEmpty
? null ? null
: await downloadAndSaveContent( : await downloadAndSaveContent(
@ -318,7 +319,7 @@ class MatrixState extends State<Matrix> {
var platformChannelSpecifics = NotificationDetails( var platformChannelSpecifics = NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await _flutterLocalNotificationsPlugin.show( await _flutterLocalNotificationsPlugin.show(
0, room.displayname, body, platformChannelSpecifics, 0, RoomNameCalculator(room).name, body, platformChannelSpecifics,
payload: roomId); payload: roomId);
} catch (exception) { } catch (exception) {
print("[Push] Error while processing notification: " + print("[Push] Error while processing notification: " +

View file

@ -0,0 +1,16 @@
import 'package:famedlysdk/famedlysdk.dart';
class RoomNameCalculator {
final Room room;
const RoomNameCalculator(this.room);
String get name {
if (room.name.isEmpty &&
room.canonicalAlias.isEmpty &&
!room.isDirectChat) {
return "Group with ${room.displayname}";
}
return room.displayname;
}
}

View file

@ -7,6 +7,7 @@ import 'package:fluffychat/components/adaptive_page_layout.dart';
import 'package:fluffychat/components/chat_settings_popup_menu.dart'; import 'package:fluffychat/components/chat_settings_popup_menu.dart';
import 'package:fluffychat/components/list_items/message.dart'; import 'package:fluffychat/components/list_items/message.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/utils/room_name_calculator.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
@ -183,7 +184,7 @@ class _ChatState extends State<Chat> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text(room.displayname), Text(RoomNameCalculator(room).name),
AnimatedContainer( AnimatedContainer(
duration: Duration(milliseconds: 500), duration: Duration(milliseconds: 500),
height: typingText.isEmpty ? 0 : 20, height: typingText.isEmpty ? 0 : 20,

View file

@ -8,6 +8,7 @@ import 'package:fluffychat/components/content_banner.dart';
import 'package:fluffychat/components/list_items/participant_list_item.dart'; import 'package:fluffychat/components/list_items/participant_list_item.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/utils/room_name_calculator.dart';
import 'package:fluffychat/views/chat_list.dart'; import 'package:fluffychat/views/chat_list.dart';
import 'package:fluffychat/views/invitation_selection.dart'; import 'package:fluffychat/views/invitation_selection.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@ -99,7 +100,7 @@ class _ChatDetailsState extends State<ChatDetails> {
), ),
secondScaffold: Scaffold( secondScaffold: Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(widget.room.displayname), title: Text(RoomNameCalculator(widget.room).name),
actions: <Widget>[ChatSettingsPopupMenu(widget.room, false)], actions: <Widget>[ChatSettingsPopupMenu(widget.room, false)],
), ),
body: ListView.builder( body: ListView.builder(
@ -127,7 +128,8 @@ class _ChatDetailsState extends State<ChatDetails> {
border: InputBorder.none, border: InputBorder.none,
labelText: "Edit group name", labelText: "Edit group name",
labelStyle: TextStyle(color: Colors.black), labelStyle: TextStyle(color: Colors.black),
hintText: (widget.room.displayname), hintText:
(RoomNameCalculator(widget.room).name),
), ),
), ),
) )