Merge branch 'add-group-prefix' into 'master'

Add group prefix

See merge request ChristianPauly/fluffychat-flutter!18
This commit is contained in:
Christian Pauly 2020-01-08 19:46:38 +00:00
commit ce853894c6
6 changed files with 30 additions and 7 deletions

View File

@ -1,4 +1,6 @@
# Version 0.2.3 - 2020-01-XX
### New features
- 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/utils/chat_time.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/utils/room_name_calculator.dart';
import 'package:fluffychat/views/chat.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
@ -85,7 +86,7 @@ class ChatListItem extends StatelessWidget {
children: <Widget>[
Expanded(
child: Text(
room.displayname,
RoomNameCalculator(room).name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),

View File

@ -4,6 +4,7 @@ import 'dart:io';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:famedlysdk/famedlysdk.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/views/chat.dart';
import 'package:flutter/foundation.dart';
@ -283,7 +284,7 @@ class MatrixState extends State<Matrix> {
// The person object for the android message style notification
final person = Person(
name: room.displayname,
name: RoomNameCalculator(room).name,
icon: room.avatar.mxc.isEmpty
? null
: await downloadAndSaveContent(
@ -318,7 +319,7 @@ class MatrixState extends State<Matrix> {
var platformChannelSpecifics = NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await _flutterLocalNotificationsPlugin.show(
0, room.displayname, body, platformChannelSpecifics,
0, RoomNameCalculator(room).name, body, platformChannelSpecifics,
payload: roomId);
} catch (exception) {
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/list_items/message.dart';
import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/utils/room_name_calculator.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
@ -183,7 +184,7 @@ class _ChatState extends State<Chat> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(room.displayname),
Text(RoomNameCalculator(room).name),
AnimatedContainer(
duration: Duration(milliseconds: 500),
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/matrix.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/invitation_selection.dart';
import 'package:flutter/foundation.dart';
@ -99,7 +100,7 @@ class _ChatDetailsState extends State<ChatDetails> {
),
secondScaffold: Scaffold(
appBar: AppBar(
title: Text(widget.room.displayname),
title: Text(RoomNameCalculator(widget.room).name),
actions: <Widget>[ChatSettingsPopupMenu(widget.room, false)],
),
body: ListView.builder(
@ -127,7 +128,8 @@ class _ChatDetailsState extends State<ChatDetails> {
border: InputBorder.none,
labelText: "Edit group name",
labelStyle: TextStyle(color: Colors.black),
hintText: (widget.room.displayname),
hintText:
(RoomNameCalculator(widget.room).name),
),
),
)