Commit 82af9ae8 authored by Wilko Manger's avatar Wilko Manger

Show message when viewing room that the user left

parent 3b54eeea
...@@ -24,7 +24,7 @@ import 'package:pattle/src/di.dart' as di; ...@@ -24,7 +24,7 @@ import 'package:pattle/src/di.dart' as di;
class ChatBloc { class ChatBloc {
JoinedRoom room; Room room;
int _eventCount = 20; int _eventCount = 20;
...@@ -125,8 +125,9 @@ class ChatBloc { ...@@ -125,8 +125,9 @@ class ChatBloc {
} }
Future<void> sendMessage(String text) async { Future<void> sendMessage(String text) async {
final room = this.room;
// TODO: Check if text is just whitespace // TODO: Check if text is just whitespace
if (text.isNotEmpty) { if (room is JoinedRoom && text.isNotEmpty) {
// Refresh the list every time the sent state changes. // Refresh the list every time the sent state changes.
await for (var sentState in room.send(TextMessage(body: text))) { await for (var sentState in room.send(TextMessage(body: text))) {
await loadEvents(); await loadEvents();
......
...@@ -36,7 +36,7 @@ class ChatPageState extends State<ChatPage> { ...@@ -36,7 +36,7 @@ class ChatPageState extends State<ChatPage> {
final me = di.getLocalUser(); final me = di.getLocalUser();
final ChatBloc bloc = ChatBloc(); final ChatBloc bloc = ChatBloc();
final JoinedRoom room; final Room room;
ScrollController scrollController = ScrollController(); ScrollController scrollController = ScrollController();
double get scrollLoadRange => scrollController.position.maxScrollExtent - 700; double get scrollLoadRange => scrollController.position.maxScrollExtent - 700;
...@@ -136,15 +136,17 @@ class ChatPageState extends State<ChatPage> { ...@@ -136,15 +136,17 @@ class ChatPageState extends State<ChatPage> {
} }
Widget _buildInput() { Widget _buildInput() {
return Material( const elevation = 8.0;
elevation: 8, if (bloc.room is JoinedRoom) {
color: LightColors.red[50], return Material(
child: Padding( elevation: elevation,
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 16), color: LightColors.red[50],
child: Material( child: Padding(
elevation: 8, padding: EdgeInsets.symmetric(vertical: 8, horizontal: 16),
borderRadius: BorderRadius.circular(8), child: Material(
child: TextField( elevation: elevation,
borderRadius: BorderRadius.circular(8),
child: TextField(
controller: textController, controller: textController,
textInputAction: TextInputAction.newline, textInputAction: TextInputAction.newline,
autocorrect: true, autocorrect: true,
...@@ -163,11 +165,24 @@ class ChatPageState extends State<ChatPage> { ...@@ -163,11 +165,24 @@ class ChatPageState extends State<ChatPage> {
textController.clear(); textController.clear();
} }
) )
),
), ),
)
)
);
} else {
return Material(
elevation: elevation,
color: Colors.white,
child: Padding(
padding: EdgeInsets.all(16),
child: Text(l(context).cantSendMessages,
textAlign: TextAlign.center,
), ),
) )
) );
); }
} }
Widget _buildLoadingIndicator() { Widget _buildLoadingIndicator() {
......
...@@ -44,6 +44,9 @@ class Strings { ...@@ -44,6 +44,9 @@ class Strings {
final groupName = 'Group name'; final groupName = 'Group name';
final participants = 'Participants'; final participants = 'Participants';
final cantSendMessages
= 'You can\'t send messages to this group because you\'re no longer a participant.';
final connectionLost = final connectionLost =
'Connection has been lost.\n' 'Connection has been lost.\n'
'Make sure your phone has an active internet connection.'; 'Make sure your phone has an active internet connection.';
......
...@@ -215,14 +215,14 @@ packages: ...@@ -215,14 +215,14 @@ packages:
name: matrix_sdk name: matrix_sdk
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.3" version: "0.13.1"
matrix_sdk_sqflite: matrix_sdk_sqflite:
dependency: "direct main" dependency: "direct main"
description: description:
name: matrix_sdk_sqflite name: matrix_sdk_sqflite
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.8.0" version: "0.9.0"
meta: meta:
dependency: transitive dependency: transitive
description: description:
......
...@@ -12,8 +12,8 @@ dependencies: ...@@ -12,8 +12,8 @@ dependencies:
injector: ^1.0.6 injector: ^1.0.6
matrix_sdk: ^0.12.3 matrix_sdk: ^0.13.1
matrix_sdk_sqflite: ^0.8.0 matrix_sdk_sqflite: ^0.9.0
rxdart: ^0.21.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