feat: New chat details design

This commit is contained in:
Krille Fear 2021-11-13 21:42:35 +01:00
parent 15ccd043d9
commit 862d23c0b9
4 changed files with 175 additions and 165 deletions

View File

@ -25,6 +25,10 @@ class ChatDetails extends StatefulWidget {
class ChatDetailsController extends State<ChatDetails> { class ChatDetailsController extends State<ChatDetails> {
List<User> members; List<User> members;
bool displaySettings = false;
void toggleDisplaySettings() =>
setState(() => displaySettings = !displaySettings);
String get roomId => VRouter.of(context).pathParameters['roomid']; String get roomId => VRouter.of(context).pathParameters['roomid'];

View File

@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -106,7 +107,7 @@ class ChatDetailsView extends StatelessWidget {
.scaffoldBackgroundColor, .scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
radius: Avatar.defaultSize / 2, radius: Avatar.defaultSize / 2,
child: const Icon(Icons.edit_outlined), child: const Icon(CupertinoIcons.pen),
) )
: null, : null,
title: Text( title: Text(
@ -136,7 +137,8 @@ class ChatDetailsView extends StatelessWidget {
? controller.setTopicAction ? controller.setTopicAction
: null, : null,
), ),
const Divider(thickness: 1), const SizedBox(height: 8),
const Divider(height: 1),
ListTile( ListTile(
title: Text( title: Text(
L10n.of(context).settings, L10n.of(context).settings,
@ -146,14 +148,19 @@ class ChatDetailsView extends StatelessWidget {
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
trailing: Icon(controller.displaySettings
? CupertinoIcons.chevron_down
: CupertinoIcons.right_chevron),
onTap: controller.toggleDisplaySettings,
), ),
if (controller.displaySettings) ...[
if (room.canSendEvent('m.room.name')) if (room.canSendEvent('m.room.name'))
ListTile( ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor: Theme.of(context)
Theme.of(context).scaffoldBackgroundColor, .scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: const Icon(Icons.people_outlined), child: const Icon(CupertinoIcons.group),
), ),
title: Text( title: Text(
L10n.of(context).changeTheNameOfTheGroup), L10n.of(context).changeTheNameOfTheGroup),
@ -164,10 +171,10 @@ class ChatDetailsView extends StatelessWidget {
if (room.joinRules == JoinRules.public) if (room.joinRules == JoinRules.public)
ListTile( ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor: Theme.of(context)
Theme.of(context).scaffoldBackgroundColor, .scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: const Icon(Icons.link_outlined), child: const Icon(CupertinoIcons.link),
), ),
onTap: controller.editAliases, onTap: controller.editAliases,
title: Text(L10n.of(context).editRoomAliases), title: Text(L10n.of(context).editRoomAliases),
@ -181,11 +188,12 @@ class ChatDetailsView extends StatelessWidget {
backgroundColor: backgroundColor:
Theme.of(context).scaffoldBackgroundColor, Theme.of(context).scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: child: const Icon(
const Icon(Icons.insert_emoticon_outlined), Icons.insert_emoticon_outlined),
), ),
title: Text(L10n.of(context).emoteSettings), title: Text(L10n.of(context).emoteSettings),
subtitle: Text(L10n.of(context).setCustomEmotes), subtitle:
Text(L10n.of(context).setCustomEmotes),
onTap: controller.goToEmoteSettings, onTap: controller.goToEmoteSettings,
), ),
PopupMenuButton( PopupMenuButton(
@ -212,7 +220,8 @@ class ChatDetailsView extends StatelessWidget {
backgroundColor: Theme.of(context) backgroundColor: Theme.of(context)
.scaffoldBackgroundColor, .scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: const Icon(Icons.public_outlined)), child: const Icon(
CupertinoIcons.checkmark_shield)),
title: Text(L10n.of(context) title: Text(L10n.of(context)
.whoIsAllowedToJoinThisGroup), .whoIsAllowedToJoinThisGroup),
subtitle: Text( subtitle: Text(
@ -222,7 +231,8 @@ class ChatDetailsView extends StatelessWidget {
), ),
), ),
PopupMenuButton( PopupMenuButton(
onSelected: controller.setHistoryVisibilityAction, onSelected:
controller.setHistoryVisibilityAction,
itemBuilder: (BuildContext context) => itemBuilder: (BuildContext context) =>
<PopupMenuEntry<HistoryVisibility>>[ <PopupMenuEntry<HistoryVisibility>>[
if (room.canChangeHistoryVisibility) if (room.canChangeHistoryVisibility)
@ -249,17 +259,18 @@ class ChatDetailsView extends StatelessWidget {
if (room.canChangeHistoryVisibility) if (room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>( PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.worldReadable, value: HistoryVisibility.worldReadable,
child: Text(HistoryVisibility.worldReadable child: Text(HistoryVisibility
.worldReadable
.getLocalizedString( .getLocalizedString(
MatrixLocals(L10n.of(context)))), MatrixLocals(L10n.of(context)))),
), ),
], ],
child: ListTile( child: ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor: Theme.of(context)
Theme.of(context).scaffoldBackgroundColor, .scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: const Icon(Icons.visibility_outlined), child: const Icon(CupertinoIcons.eye),
), ),
title: Text(L10n.of(context) title: Text(L10n.of(context)
.visibilityOfTheChatHistory), .visibilityOfTheChatHistory),
@ -279,8 +290,9 @@ class ChatDetailsView extends StatelessWidget {
PopupMenuItem<GuestAccess>( PopupMenuItem<GuestAccess>(
value: GuestAccess.canJoin, value: GuestAccess.canJoin,
child: Text( child: Text(
GuestAccess.canJoin.getLocalizedString( GuestAccess.canJoin
MatrixLocals(L10n.of(context))), .getLocalizedString(MatrixLocals(
L10n.of(context))),
), ),
), ),
if (room.canChangeGuestAccess) if (room.canChangeGuestAccess)
@ -288,8 +300,8 @@ class ChatDetailsView extends StatelessWidget {
value: GuestAccess.forbidden, value: GuestAccess.forbidden,
child: Text( child: Text(
GuestAccess.forbidden GuestAccess.forbidden
.getLocalizedString( .getLocalizedString(MatrixLocals(
MatrixLocals(L10n.of(context))), L10n.of(context))),
), ),
), ),
], ],
@ -298,10 +310,11 @@ class ChatDetailsView extends StatelessWidget {
backgroundColor: Theme.of(context) backgroundColor: Theme.of(context)
.scaffoldBackgroundColor, .scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: const Icon(Icons.info_outline), child:
const Icon(CupertinoIcons.person_alt),
), ),
title: Text( title: Text(L10n.of(context)
L10n.of(context).areGuestsAllowedToJoin), .areGuestsAllowedToJoin),
subtitle: Text( subtitle: Text(
room.guestAccess.getLocalizedString( room.guestAccess.getLocalizedString(
MatrixLocals(L10n.of(context))), MatrixLocals(L10n.of(context))),
@ -309,20 +322,22 @@ class ChatDetailsView extends StatelessWidget {
), ),
), ),
ListTile( ListTile(
title: Text(L10n.of(context).editChatPermissions), title:
Text(L10n.of(context).editChatPermissions),
subtitle: Text( subtitle: Text(
L10n.of(context).whoCanPerformWhichAction), L10n.of(context).whoCanPerformWhichAction),
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor:
Theme.of(context).scaffoldBackgroundColor, Theme.of(context).scaffoldBackgroundColor,
foregroundColor: Colors.grey, foregroundColor: Colors.grey,
child: child: const Icon(
const Icon(Icons.edit_attributes_outlined), CupertinoIcons.slider_horizontal_3),
), ),
onTap: () => onTap: () =>
VRouter.of(context).to('permissions'), VRouter.of(context).to('permissions'),
), ),
const Divider(thickness: 1), ],
const Divider(height: 1),
ListTile( ListTile(
title: Text( title: Text(
actualMembersCount > 1 actualMembersCount > 1

View File

@ -35,19 +35,12 @@ class InvitationSelectionController extends State<InvitationSelection> {
participants.removeWhere( participants.removeWhere(
(u) => ![Membership.join, Membership.invite].contains(u.membership), (u) => ![Membership.join, Membership.invite].contains(u.membership),
); );
final contacts = <User>[]; final participantsIds = participants.map((p) => p.stateKey).toList();
final userMap = <String, bool>{}; final contacts = client.rooms
for (var i = 0; i < client.rooms.length; i++) { .where((r) => r.isDirectChat)
final roomUsers = client.rooms[i].getParticipants(); .map((r) => r.getUserByMXIDSync(r.directChatMatrixID))
.toList()
for (var j = 0; j < roomUsers.length; j++) { ..removeWhere((u) => participantsIds.contains(u.stateKey));
if (userMap[roomUsers[j].id] != true &&
participants.indexWhere((u) => u.id == roomUsers[j].id) == -1) {
contacts.add(roomUsers[j]);
}
userMap[roomUsers[j].id] = true;
}
}
contacts.sort( contacts.sort(
(a, b) => a.calcDisplayname().toLowerCase().compareTo( (a, b) => a.calcDisplayname().toLowerCase().compareTo(
b.calcDisplayname().toLowerCase(), b.calcDisplayname().toLowerCase(),

View File

@ -3,9 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/fluffy_share.dart'; import 'package:fluffychat/utils/fluffy_share.dart';
import 'package:fluffychat/widgets/layouts/max_width_body.dart'; import 'package:fluffychat/widgets/layouts/max_width_body.dart';
import 'package:fluffychat/widgets/matrix.dart'; import 'package:fluffychat/widgets/matrix.dart';