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