Commit 17969371 authored by Wilko Manger's avatar Wilko Manger

Render chat creation events

parent 1e047d57
......@@ -99,6 +99,10 @@ class ChatBloc {
}
}
shouldIgnore = shouldIgnore ||
event is JoinEvent && event is! DisplayNameChangeEvent
&& room.creator.isIdenticalTo(event.content.subject);
if (ignoredEvents.contains(event.runtimeType) || shouldIgnore) {
continue;
}
......
......@@ -17,6 +17,7 @@
import 'package:flutter/material.dart';
import 'package:matrix_sdk/matrix_sdk.dart';
import 'package:pattle/src/ui/main/chat/widgets/state/creation_bubble.dart';
import 'package:pattle/src/ui/main/models/chat_item.dart';
import 'image_bubble.dart';
......@@ -74,10 +75,10 @@ abstract class Bubble extends Item {
);
} else if (item.event is MemberChangeEvent) {
return MemberBubble(
item: item,
previousItem: previousItem,
nextItem: nextItem,
isMine: isMine
item: item,
previousItem: previousItem,
nextItem: nextItem,
isMine: isMine
);
} else if (item.event is RedactedEvent) {
return RedactedBubble(
......@@ -86,6 +87,13 @@ abstract class Bubble extends Item {
nextItem: nextItem,
isMine: isMine,
);
} else if (item.event is RoomCreationEvent) {
return CreationBubble(
item: item,
previousItem: previousItem,
nextItem: nextItem,
isMine: isMine,
);
} else {
return null;
}
......
// Copyright (C) 2019 Wilko Manger
// Copyright (C) 2019 Mathieu Velten (FLA signed)
//
// This file is part of Pattle.
//
// Pattle is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pattle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Pattle. If not, see <https://www.gnu.org/licenses/>.
import 'package:flutter/material.dart';
import 'package:matrix_sdk/matrix_sdk.dart';
import 'package:pattle/src/ui/main/models/chat_item.dart';
import 'package:pattle/src/ui/resources/localizations.dart';
import 'package:pattle/src/ui/util/user.dart';
import 'state_bubble.dart';
class CreationBubble extends StateBubble {
@override
final RoomCreationEvent event;
CreationBubble({
@required ChatEvent item,
@required ChatItem previousItem,
@required ChatItem nextItem,
@required bool isMine
}) :
event = item.event,
super(
item: item,
previousItem: previousItem,
nextItem: nextItem,
isMine: isMine
);
@protected
@override
Widget buildContent(BuildContext context) {
// Keep default body1 font size so it is a bit smaller
// since it is less important than a message
// size 14
return RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: Theme.of(context).textTheme.body1,
children: l(context).createdThisGroup(TextSpan(
text: displayNameOf(event.room.creator),
style: TextStyle(
fontWeight: FontWeight.w600
)
))
)
);
}
}
\ No newline at end of file
......@@ -70,6 +70,10 @@ class Strings {
final enterPassword = 'Enter password';
final wrongPasswordError = 'Wrong password. Please try again';
// Room creation event
List<TextSpan> createdThisGroup(TextSpan name)
=> [name, TextSpan(text: ' created this group')];
// Member change events
List<TextSpan> changedTheirNameTo(TextSpan oldName, TextSpan newName)
=> [oldName, TextSpan(text: ' changed their name to '), newName];
......
......@@ -74,12 +74,16 @@ FutureOr<String> nameOf(BuildContext context, Room room) {
List<Type> ignoredEventsOf(Room room, {@required bool isOverview}) {
List<Type> ignored = [
RedactionEvent,
AvatarUrlChangeEvent
AvatarChangeEvent
];
if (isOverview) {
ignored.add(DisplayNameChangeEvent);
}
if (room.isDirect) {
ignored.add(RoomCreationEvent);
}
return ignored;
}
\ No newline at end of file
......@@ -215,14 +215,14 @@ packages:
name: matrix_sdk
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.0"
version: "0.10.0"
matrix_sdk_sqflite:
dependency: "direct main"
description:
name: matrix_sdk_sqflite
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.0"
version: "0.7.0"
meta:
dependency: transitive
description:
......
......@@ -12,8 +12,8 @@ dependencies:
injector: ^1.0.6
matrix_sdk: ^0.9.0
matrix_sdk_sqflite: ^0.6.0
matrix_sdk: ^0.10.0
matrix_sdk_sqflite: ^0.7.0
rxdart: ^0.21.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment