Browse Source

Merge branch 'krille/minor-fixes' into 'master'

Minor fixes

See merge request ChristianPauly/fluffychat-flutter!96
yiffed
Christian Pauly 2 years ago
parent
commit
3c6786e539
  1. 27
      lib/components/list_items/public_room_list_item.dart
  2. 2
      lib/l10n/l10n.dart
  3. 26
      lib/views/chat_list.dart

27
lib/components/list_items/public_room_list_item.dart

@ -15,18 +15,33 @@ class PublicRoomListItem extends StatelessWidget { @@ -15,18 +15,33 @@ class PublicRoomListItem extends StatelessWidget {
const PublicRoomListItem(this.publicRoomEntry, {Key key}) : super(key: key);
void joinAction(BuildContext context) async {
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
Matrix.of(context).client.api.joinRoom(publicRoomEntry.roomId));
final success = await SimpleDialogs(context)
.tryRequestWithLoadingDialog(_joinRoomAndWait(context));
if (success != false) {
await Navigator.of(context).push(
AppRoute.defaultRoute(
context,
ChatView(publicRoomEntry.roomId),
ChatView(success),
),
);
}
}
Future<String> _joinRoomAndWait(BuildContext context) async {
final roomId = await Matrix.of(context)
.client
.api
.joinRoomOrAlias(publicRoomEntry.roomId);
if (Matrix.of(context).client.getRoomById(roomId) == null) {
await Matrix.of(context)
.client
.onRoomUpdate
.stream
.firstWhere((r) => r.id == roomId);
}
return roomId;
}
@override
Widget build(BuildContext context) {
final hasTopic =
@ -43,8 +58,10 @@ class PublicRoomListItem extends StatelessWidget { @@ -43,8 +58,10 @@ class PublicRoomListItem extends StatelessWidget {
subtitle: Text(
hasTopic
? publicRoomEntry.topic
: L10n.of(context).countParticipants(
publicRoomEntry.numJoinedMembers?.toString() ?? '0'),
: publicRoomEntry.numJoinedMembers == null
? L10n.of(context).joinRoom
: L10n.of(context).countParticipants(
publicRoomEntry.numJoinedMembers.toString()),
maxLines: 1,
),
onTap: () => joinAction(context),

2
lib/l10n/l10n.dart

@ -463,6 +463,8 @@ class L10n extends MatrixLocalizations { @@ -463,6 +463,8 @@ class L10n extends MatrixLocalizations {
args: [username],
);
String get joinRoom => Intl.message('Join room');
String get keysCached => Intl.message("Keys are cached", name: "keysCached");
String get keysMissing =>

26
lib/views/chat_list.dart

@ -390,17 +390,21 @@ class _ChatListState extends State<ChatList> { @@ -390,17 +390,21 @@ class _ChatListState extends State<ChatList> {
a.lastEvent.originServerTs));
return ListView.separated(
controller: _scrollController,
separatorBuilder:
(BuildContext context, int i) =>
i == totalCount - publicRoomsCount
? Material(
elevation: 2,
child: ListTile(
title: Text(L10n.of(context)
.publicRooms),
),
)
: Container(),
separatorBuilder: (BuildContext context,
int i) =>
i == totalCount - publicRoomsCount
? ListTile(
title: Text(
L10n.of(context).publicRooms +
':',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Theme.of(context)
.primaryColor,
),
),
)
: Container(),
itemCount: totalCount + 1,
itemBuilder: (BuildContext context, int i) {
if (i == 0) {

Loading…
Cancel
Save