Commit b3905c4e authored by Wilko Manger's avatar Wilko Manger

Handle room upgrades

parent 8bd943e4
......@@ -101,10 +101,13 @@ class ChatBloc {
}
}
shouldIgnore = shouldIgnore ||
shouldIgnore |=
event is JoinEvent && event is! DisplayNameChangeEvent
&& room.creator.isIdenticalTo(event.content.subject);
// Don't show creation events in rooms that are replacements
shouldIgnore |= event is RoomCreationEvent && room.isReplacement;
if (ignoredEvents.contains(event.runtimeType) || shouldIgnore) {
continue;
}
......
......@@ -18,6 +18,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/chat/widgets/state/upgrade_bubble.dart';
import 'package:pattle/src/ui/main/models/chat_item.dart';
import 'image_bubble.dart';
......@@ -94,6 +95,13 @@ abstract class Bubble extends Item {
nextItem: nextItem,
isMine: isMine,
);
} else if (item.event is RoomUpgradeEvent) {
return UpgradeBubble(
item: item,
previousItem: previousItem,
nextItem: nextItem,
isMine: isMine,
);
} else {
return null;
}
......
......@@ -44,23 +44,14 @@ class CreationBubble extends StateBubble {
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
)
))
List<TextSpan> buildContentSpans(BuildContext context) =>
l(context).createdThisGroup(
TextSpan(
text: displayNameOf(event.room.creator),
style: defaultEmphasisTextStyle
)
);
}
}
\ No newline at end of file
......@@ -46,22 +46,11 @@ class MemberBubble extends StateBubble {
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: spanFor(context, event,
style: TextStyle(
fontWeight: FontWeight.w600
)
)
)
);
}
@protected
List<TextSpan> buildContentSpans(BuildContext context) => spanFor(
context,
event,
style: defaultEmphasisTextStyle
);
}
\ No newline at end of file
......@@ -43,8 +43,26 @@ abstract class StateBubble extends Bubble {
isMine: isMine
);
TextStyle defaultTextStyle(BuildContext context)
=> Theme.of(context).textTheme.body1;
TextStyle get defaultEmphasisTextStyle => TextStyle(
fontWeight: FontWeight.w600
);
@protected
Widget buildContent(BuildContext context);
List<TextSpan> buildContentSpans(BuildContext context);
@protected
Widget buildContent(BuildContext context) {
return RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: defaultTextStyle(context),
children: buildContentSpans(context)
)
);
}
@override
Widget build(BuildContext context) {
......
// 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 UpgradeBubble extends StateBubble {
@override
final RoomUpgradeEvent event;
UpgradeBubble({
@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
List<TextSpan> buildContentSpans(BuildContext context) =>
l(context).upgradedThisGroup(
TextSpan(
text: displayNameOf(event.sender),
style: defaultEmphasisTextStyle
)
);
}
\ No newline at end of file
......@@ -36,6 +36,11 @@ class ChatOverviewBloc {
// Get all rooms and push them as a single list
await for(Room room in _user.rooms.get()) {
// Don't show rooms that have been upgraded
if (room.isUpgraded) {
continue;
}
final ignoredEvents = ignoredEventsOf(room, isOverview: true);
// TODO: Add optional filter argument to up to call
......
......@@ -86,6 +86,10 @@ class Strings {
List<TextSpan> createdThisGroup(TextSpan name)
=> [name, TextSpan(text: ' created this group')];
// Room upgrade event
List<TextSpan> upgradedThisGroup(TextSpan name)
=> [name, TextSpan(text: ' upgraded this group')];
// Member change events
List<TextSpan> changedTheirNameTo(TextSpan oldName, TextSpan newName)
=> [oldName, TextSpan(text: ' changed their name to '), newName];
......
......@@ -213,14 +213,14 @@ packages:
name: matrix_sdk
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.3"
version: "0.17.1"
matrix_sdk_sqflite:
dependency: "direct main"
description:
name: matrix_sdk_sqflite
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0"
version: "0.13.0"
meta:
dependency: transitive
description:
......
......@@ -12,8 +12,8 @@ dependencies:
injector: ^1.0.6
matrix_sdk: ^0.16.3
matrix_sdk_sqflite: ^0.12.0
matrix_sdk: ^0.17.1
matrix_sdk_sqflite: ^0.13.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