design: Big redesign of three column mode to advanced two column mode

This commit is contained in:
krille-chan 2023-08-12 11:52:20 +02:00
commit 9e13bd8dfd
No known key found for this signature in database
24 changed files with 938 additions and 765 deletions

View file

@ -1037,6 +1037,14 @@
"type": "text", "type": "text",
"placeholders": {} "placeholders": {}
}, },
"inviteContactToGroupQuestion": "Do you want to invite {contact} to the chat \"{groupName}\"?",
"@inviteContactToGroup": {
"type": "text",
"placeholders": {
"contact": {},
"groupName": {}
}
},
"inviteContactToGroup": "Invite contact to {groupName}", "inviteContactToGroup": "Invite contact to {groupName}",
"@inviteContactToGroup": { "@inviteContactToGroup": {
"type": "text", "type": "text",
@ -1044,6 +1052,10 @@
"groupName": {} "groupName": {}
} }
}, },
"noGroupDescriptionYet": "No group description created yet.",
"anyoneCanKnock": "Anyone can knock",
"noOneCanJoin": "No one can join",
"tryAgain": "Try again",
"invited": "Invited", "invited": "Invited",
"@invited": { "@invited": {
"type": "text", "type": "text",
@ -2499,5 +2511,6 @@
}, },
"profileNotFound": "The user could not be found on the server. Maybe there is a connection problem or the user doesn't exist.", "profileNotFound": "The user could not be found on the server. Maybe there is a connection problem or the user doesn't exist.",
"setTheme": "Set theme:", "setTheme": "Set theme:",
"setColorTheme": "Set color theme:" "setColorTheme": "Set color theme:",
"invite": "Invite"
} }

View file

@ -11,6 +11,7 @@ import 'package:fluffychat/pages/chat/chat.dart';
import 'package:fluffychat/pages/chat_details/chat_details.dart'; import 'package:fluffychat/pages/chat_details/chat_details.dart';
import 'package:fluffychat/pages/chat_encryption_settings/chat_encryption_settings.dart'; import 'package:fluffychat/pages/chat_encryption_settings/chat_encryption_settings.dart';
import 'package:fluffychat/pages/chat_list/chat_list.dart'; import 'package:fluffychat/pages/chat_list/chat_list.dart';
import 'package:fluffychat/pages/chat_members/chat_members.dart';
import 'package:fluffychat/pages/chat_permissions_settings/chat_permissions_settings.dart'; import 'package:fluffychat/pages/chat_permissions_settings/chat_permissions_settings.dart';
import 'package:fluffychat/pages/device_settings/device_settings.dart'; import 'package:fluffychat/pages/device_settings/device_settings.dart';
import 'package:fluffychat/pages/homeserver_picker/homeserver_picker.dart'; import 'package:fluffychat/pages/homeserver_picker/homeserver_picker.dart';
@ -31,7 +32,6 @@ import 'package:fluffychat/pages/settings_stories/settings_stories.dart';
import 'package:fluffychat/pages/settings_style/settings_style.dart'; import 'package:fluffychat/pages/settings_style/settings_style.dart';
import 'package:fluffychat/pages/story/story_page.dart'; import 'package:fluffychat/pages/story/story_page.dart';
import 'package:fluffychat/widgets/layouts/empty_page.dart'; import 'package:fluffychat/widgets/layouts/empty_page.dart';
import 'package:fluffychat/widgets/layouts/side_view_layout.dart';
import 'package:fluffychat/widgets/layouts/two_column_layout.dart'; import 'package:fluffychat/widgets/layouts/two_column_layout.dart';
import 'package:fluffychat/widgets/log_view.dart'; import 'package:fluffychat/widgets/log_view.dart';
import 'package:fluffychat/widgets/matrix.dart'; import 'package:fluffychat/widgets/matrix.dart';
@ -218,54 +218,42 @@ abstract class AppRoutes {
), ),
], ],
), ),
ShellRoute( GoRoute(
pageBuilder: (context, state, child) => defaultPageBuilder( path: ':roomid',
pageBuilder: (context, state) => defaultPageBuilder(
context, context,
SideViewLayout( ChatPage(roomId: state.pathParameters['roomid']!),
mainView: ChatPage(
roomId: state.pathParameters['roomid']!,
),
sideView: child,
hideSideView: state.fullPath == '/rooms/:roomid',
),
), ),
redirect: loggedOutRedirect,
routes: [ routes: [
GoRoute( GoRoute(
path: ':roomid', path: 'encryption',
pageBuilder: (context, state) => defaultPageBuilder( pageBuilder: (context, state) => defaultPageBuilder(
context, context,
const SizedBox.shrink(), const ChatEncryptionSettings(),
), ),
redirect: loggedOutRedirect, redirect: loggedOutRedirect,
routes: [ ),
GoRoute( GoRoute(
path: 'encryption', path: 'invite',
pageBuilder: (context, state) => defaultPageBuilder( pageBuilder: (context, state) => defaultPageBuilder(
context, context,
const ChatEncryptionSettings(), InvitationSelection(
), roomId: state.pathParameters['roomid']!,
redirect: loggedOutRedirect,
), ),
GoRoute( ),
path: 'invite', redirect: loggedOutRedirect,
pageBuilder: (context, state) => defaultPageBuilder( ),
context, GoRoute(
const InvitationSelection(), path: 'details',
), pageBuilder: (context, state) => defaultPageBuilder(
redirect: loggedOutRedirect, context,
ChatDetails(
roomId: state.pathParameters['roomid']!,
), ),
GoRoute( ),
path: 'details', routes: _chatDetailsRoutes,
pageBuilder: (context, state) => defaultPageBuilder( redirect: loggedOutRedirect,
context,
ChatDetails(
roomId: state.pathParameters['roomid']!,
),
),
routes: _chatDetailsRoutes,
redirect: loggedOutRedirect,
),
],
), ),
], ],
), ),
@ -276,6 +264,16 @@ abstract class AppRoutes {
]; ];
static final List<RouteBase> _chatDetailsRoutes = [ static final List<RouteBase> _chatDetailsRoutes = [
GoRoute(
path: 'members',
pageBuilder: (context, state) => defaultPageBuilder(
context,
ChatMembersPage(
roomId: state.pathParameters['roomid']!,
),
),
redirect: loggedOutRedirect,
),
GoRoute( GoRoute(
path: 'permissions', path: 'permissions',
pageBuilder: (context, state) => defaultPageBuilder( pageBuilder: (context, state) => defaultPageBuilder(
@ -288,7 +286,7 @@ abstract class AppRoutes {
path: 'invite', path: 'invite',
pageBuilder: (context, state) => defaultPageBuilder( pageBuilder: (context, state) => defaultPageBuilder(
context, context,
const InvitationSelection(), InvitationSelection(roomId: state.pathParameters['roomid']!),
), ),
redirect: loggedOutRedirect, redirect: loggedOutRedirect,
), ),

View file

@ -58,7 +58,11 @@ abstract class FluffyThemes {
static const Duration animationDuration = Duration(milliseconds: 250); static const Duration animationDuration = Duration(milliseconds: 250);
static const Curve animationCurve = Curves.easeInOut; static const Curve animationCurve = Curves.easeInOut;
static ThemeData buildTheme(Brightness brightness, [Color? seed]) { static ThemeData buildTheme(
BuildContext context,
Brightness brightness, [
Color? seed,
]) {
final colorScheme = ColorScheme.fromSeed( final colorScheme = ColorScheme.fromSeed(
brightness: brightness, brightness: brightness,
seedColor: seed ?? AppConfig.colorSchemeSeed ?? AppConfig.primaryColor, seedColor: seed ?? AppConfig.colorSchemeSeed ?? AppConfig.primaryColor,
@ -92,6 +96,9 @@ abstract class FluffyThemes {
filled: true, filled: true,
), ),
appBarTheme: AppBarTheme( appBarTheme: AppBarTheme(
toolbarHeight: FluffyThemes.isColumnMode(context) ? 72 : 56,
shadowColor: Colors.grey.withAlpha(64),
surfaceTintColor: colorScheme.background,
systemOverlayStyle: SystemUiOverlayStyle( systemOverlayStyle: SystemUiOverlayStyle(
statusBarColor: Colors.transparent, statusBarColor: Colors.transparent,
statusBarIconBrightness: brightness.reversed, statusBarIconBrightness: brightness.reversed,

View file

@ -8,6 +8,7 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:matrix/matrix.dart' as matrix;
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:fluffychat/pages/chat_details/chat_details_view.dart'; import 'package:fluffychat/pages/chat_details/chat_details_view.dart';
@ -31,7 +32,6 @@ class ChatDetails extends StatefulWidget {
} }
class ChatDetailsController extends State<ChatDetails> { class ChatDetailsController extends State<ChatDetails> {
List<User>? members;
bool displaySettings = false; bool displaySettings = false;
void toggleDisplaySettings() => void toggleDisplaySettings() =>
@ -42,7 +42,6 @@ class ChatDetailsController extends State<ChatDetails> {
void setDisplaynameAction() async { void setDisplaynameAction() async {
final room = Matrix.of(context).client.getRoomById(roomId!)!; final room = Matrix.of(context).client.getRoomById(roomId!)!;
final input = await showTextInputDialog( final input = await showTextInputDialog(
useRootNavigator: false,
context: context, context: context,
title: L10n.of(context)!.changeTheNameOfTheGroup, title: L10n.of(context)!.changeTheNameOfTheGroup,
okLabel: L10n.of(context)!.ok, okLabel: L10n.of(context)!.ok,
@ -103,7 +102,6 @@ class ChatDetailsController extends State<ChatDetails> {
return setAliasAction(); return setAliasAction();
} }
final select = await showConfirmationDialog( final select = await showConfirmationDialog(
useRootNavigator: false,
context: context, context: context,
title: L10n.of(context)!.editRoomAliases, title: L10n.of(context)!.editRoomAliases,
actions: [ actions: [
@ -176,7 +174,6 @@ class ChatDetailsController extends State<ChatDetails> {
final domain = room.client.userID!.domain; final domain = room.client.userID!.domain;
final input = await showTextInputDialog( final input = await showTextInputDialog(
useRootNavigator: false,
context: context, context: context,
title: L10n.of(context)!.setInvitationLink, title: L10n.of(context)!.setInvitationLink,
okLabel: L10n.of(context)!.ok, okLabel: L10n.of(context)!.ok,
@ -201,17 +198,16 @@ class ChatDetailsController extends State<ChatDetails> {
void setTopicAction() async { void setTopicAction() async {
final room = Matrix.of(context).client.getRoomById(roomId!)!; final room = Matrix.of(context).client.getRoomById(roomId!)!;
final input = await showTextInputDialog( final input = await showTextInputDialog(
useRootNavigator: false,
context: context, context: context,
title: L10n.of(context)!.setGroupDescription, title: L10n.of(context)!.setGroupDescription,
okLabel: L10n.of(context)!.ok, okLabel: L10n.of(context)!.ok,
cancelLabel: L10n.of(context)!.cancel, cancelLabel: L10n.of(context)!.cancel,
textFields: [ textFields: [
DialogTextField( DialogTextField(
hintText: L10n.of(context)!.setGroupDescription, hintText: L10n.of(context)!.noGroupDescriptionYet,
initialText: room.topic, initialText: room.topic,
minLines: 1, minLines: 4,
maxLines: 4, maxLines: 8,
) )
], ],
); );
@ -229,30 +225,90 @@ class ChatDetailsController extends State<ChatDetails> {
} }
} }
void setGuestAccessAction(GuestAccess guestAccess) => showFutureLoadingDialog( void setGuestAccess() async {
context: context, final room = Matrix.of(context).client.getRoomById(roomId!)!;
future: () => Matrix.of(context) final currentGuestAccess = room.guestAccess;
.client final newGuestAccess = await showConfirmationDialog<GuestAccess>(
.getRoomById(roomId!)! context: context,
.setGuestAccess(guestAccess), title: L10n.of(context)!.whoIsAllowedToJoinThisGroup,
); actions: GuestAccess.values
.map(
(guestAccess) => AlertDialogAction(
key: guestAccess,
label: guestAccess
.getLocalizedString(MatrixLocals(L10n.of(context)!)),
isDefaultAction: guestAccess == currentGuestAccess,
),
)
.toList(),
);
if (newGuestAccess == null || newGuestAccess == currentGuestAccess) return;
await showFutureLoadingDialog(
context: context,
future: () => room.setGuestAccess(newGuestAccess),
);
}
void setHistoryVisibilityAction(HistoryVisibility historyVisibility) => void setHistoryVisibility() async {
showFutureLoadingDialog( final room = Matrix.of(context).client.getRoomById(roomId!)!;
context: context, final currentHistoryVisibility = room.historyVisibility;
future: () => Matrix.of(context) final newHistoryVisibility =
.client await showConfirmationDialog<HistoryVisibility>(
.getRoomById(roomId!)! context: context,
.setHistoryVisibility(historyVisibility), title: L10n.of(context)!.whoIsAllowedToJoinThisGroup,
); actions: HistoryVisibility.values
.map(
(visibility) => AlertDialogAction(
key: visibility,
label: visibility
.getLocalizedString(MatrixLocals(L10n.of(context)!)),
isDefaultAction: visibility == currentHistoryVisibility,
),
)
.toList(),
);
if (newHistoryVisibility == null ||
newHistoryVisibility == currentHistoryVisibility) return;
await showFutureLoadingDialog(
context: context,
future: () => room.setHistoryVisibility(newHistoryVisibility),
);
}
void setJoinRulesAction(JoinRules joinRule) => showFutureLoadingDialog( void setJoinRules() async {
context: context, final room = Matrix.of(context).client.getRoomById(roomId!)!;
future: () => Matrix.of(context) final currentJoinRule = room.joinRules;
.client final newJoinRule = await showConfirmationDialog<JoinRules>(
.getRoomById(roomId!)! context: context,
.setJoinRules(joinRule), title: L10n.of(context)!.whoIsAllowedToJoinThisGroup,
); actions: JoinRules.values
.map(
(joinRule) => AlertDialogAction(
key: joinRule,
label:
joinRule.getLocalizedString(MatrixLocals(L10n.of(context)!)),
isDefaultAction: joinRule == currentJoinRule,
),
)
.toList(),
);
if (newJoinRule == null || newJoinRule == currentJoinRule) return;
await showFutureLoadingDialog(
context: context,
future: () async {
await room.setJoinRules(newJoinRule);
room.client.setRoomVisibilityOnDirectory(
roomId!,
visibility: {
JoinRules.public,
JoinRules.knock,
}.contains(newJoinRule)
? matrix.Visibility.public
: matrix.Visibility.private,
);
},
);
}
void goToEmoteSettings() async { void goToEmoteSettings() async {
final room = Matrix.of(context).client.getRoomById(roomId!)!; final room = Matrix.of(context).client.getRoomById(roomId!)!;
@ -337,26 +393,8 @@ class ChatDetailsController extends State<ChatDetails> {
); );
} }
void requestMoreMembersAction() async {
final room = Matrix.of(context).client.getRoomById(roomId!);
final participants = await showFutureLoadingDialog(
context: context,
future: () => room!.requestParticipants(),
);
if (participants.error == null) {
setState(() => members = participants.result);
}
}
static const fixedWidth = 360.0; static const fixedWidth = 360.0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) => ChatDetailsView(this);
members ??=
Matrix.of(context).client.getRoomById(roomId!)!.getParticipants();
return SizedBox(
width: fixedWidth,
child: ChatDetailsView(this),
);
}
} }

View file

@ -12,7 +12,6 @@ import 'package:fluffychat/utils/fluffy_share.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/widgets/avatar.dart'; import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/chat_settings_popup_menu.dart'; import 'package:fluffychat/widgets/chat_settings_popup_menu.dart';
import 'package:fluffychat/widgets/content_banner.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';
import '../../utils/url_launcher.dart'; import '../../utils/url_launcher.dart';
@ -36,406 +35,366 @@ class ChatDetailsView extends StatelessWidget {
); );
} }
controller.members!.removeWhere((u) => u.membership == Membership.leave);
final actualMembersCount = (room.summary.mInvitedMemberCount ?? 0) +
(room.summary.mJoinedMemberCount ?? 0);
final canRequestMoreMembers =
controller.members!.length < actualMembersCount;
final iconColor = Theme.of(context).textTheme.bodyLarge!.color;
return StreamBuilder( return StreamBuilder(
stream: room.onUpdate.stream, stream: room.onUpdate.stream,
builder: (context, snapshot) { builder: (context, snapshot) {
var members = room.getParticipants().toList()
..sort((b, a) => a.powerLevel.compareTo(b.powerLevel));
members = members.take(10).toList();
final actualMembersCount = (room.summary.mInvitedMemberCount ?? 0) +
(room.summary.mJoinedMemberCount ?? 0);
final canRequestMoreMembers = members.length < actualMembersCount;
final iconColor = Theme.of(context).textTheme.bodyLarge!.color;
final displayname = room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
);
return Scaffold( return Scaffold(
body: NestedScrollView( appBar: AppBar(
headerSliverBuilder: leading: const Center(child: BackButton()),
(BuildContext context, bool innerBoxIsScrolled) => <Widget>[ elevation: Theme.of(context).appBarTheme.elevation,
SliverAppBar( actions: <Widget>[
leading: IconButton( if (room.canonicalAlias.isNotEmpty)
icon: const Icon(Icons.close_outlined), IconButton(
onPressed: () => tooltip: L10n.of(context)!.share,
GoRouterState.of(context).uri.path.startsWith('/spaces/') icon: Icon(Icons.adaptive.share_outlined),
? context.pop() onPressed: () => FluffyShare.share(
: context.go( AppConfig.inviteLinkPrefix + room.canonicalAlias,
['', 'rooms', controller.roomId!].join('/'), context,
),
),
elevation: Theme.of(context).appBarTheme.elevation,
expandedHeight: 300.0,
floating: true,
pinned: true,
actions: <Widget>[
if (room.canonicalAlias.isNotEmpty)
IconButton(
tooltip: L10n.of(context)!.share,
icon: Icon(Icons.adaptive.share_outlined),
onPressed: () => FluffyShare.share(
AppConfig.inviteLinkPrefix + room.canonicalAlias,
context,
),
),
ChatSettingsPopupMenu(room, false)
],
title: Text(
room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
), ),
), ),
backgroundColor: Theme.of(context).appBarTheme.backgroundColor, ChatSettingsPopupMenu(room, false)
flexibleSpace: FlexibleSpaceBar(
background: ContentBanner(
mxContent: room.avatar,
onEdit: room.canSendEvent('m.room.avatar')
? controller.setAvatarAction
: null,
defaultIcon: Icons.group_outlined,
),
),
),
], ],
body: MaxWidthBody( title: Text(L10n.of(context)!.chatDetails),
child: ListView.builder( backgroundColor: Theme.of(context).appBarTheme.backgroundColor,
itemCount: controller.members!.length + ),
1 + body: MaxWidthBody(
(canRequestMoreMembers ? 1 : 0), child: ListView.builder(
itemBuilder: (BuildContext context, int i) => i == 0 physics: const NeverScrollableScrollPhysics(),
? Column( shrinkWrap: true,
crossAxisAlignment: CrossAxisAlignment.stretch, itemCount: members.length + 1 + (canRequestMoreMembers ? 1 : 0),
children: <Widget>[ itemBuilder: (BuildContext context, int i) => i == 0
ListTile( ? Column(
onTap: room.canSendEvent(EventTypes.RoomTopic) crossAxisAlignment: CrossAxisAlignment.stretch,
? controller.setTopicAction children: <Widget>[
: null, Row(
trailing: room.canSendEvent(EventTypes.RoomTopic) children: [
? Icon(
Icons.edit_outlined,
color: Theme.of(context)
.colorScheme
.onBackground,
)
: null,
title: Text(
L10n.of(context)!.groupDescription,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
),
if (room.topic.isNotEmpty)
Padding( Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.all(32.0),
horizontal: 16.0, child: Stack(
), children: [
child: Linkify( Material(
text: room.topic.isEmpty elevation: Theme.of(context)
? L10n.of(context)!.addGroupDescription .appBarTheme
: room.topic, .scrolledUnderElevation ??
options: const LinkifyOptions(humanize: false), 4,
linkStyle: shadowColor: Theme.of(context)
const TextStyle(color: Colors.blueAccent), .appBarTheme
style: TextStyle( .shadowColor,
fontSize: 14, shape: RoundedRectangleBorder(
color: Theme.of(context) side: BorderSide(
.textTheme color: Theme.of(context).dividerColor,
.bodyMedium! ),
.color, borderRadius: BorderRadius.circular(
decorationColor: Theme.of(context) Avatar.defaultSize * 2.5,
.textTheme
.bodyMedium!
.color,
),
onOpen: (url) =>
UrlLauncher(context, url.url).launchUrl(),
),
),
const SizedBox(height: 8),
const Divider(height: 1),
ListTile(
title: Text(
L10n.of(context)!.settings,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
trailing: Icon(
controller.displaySettings
? Icons.keyboard_arrow_down_outlined
: Icons.keyboard_arrow_right_outlined,
),
onTap: controller.toggleDisplaySettings,
),
if (controller.displaySettings) ...[
if (room.canSendEvent('m.room.name'))
ListTile(
leading: CircleAvatar(
backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: iconColor,
child: const Icon(
Icons.people_outline_outlined,
),
),
title: Text(
L10n.of(context)!.changeTheNameOfTheGroup,
),
subtitle: Text(
room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
),
),
onTap: controller.setDisplaynameAction,
),
if (room.joinRules == JoinRules.public)
ListTile(
leading: CircleAvatar(
backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: iconColor,
child: const Icon(Icons.link_outlined),
),
onTap: controller.editAliases,
title: Text(L10n.of(context)!.editRoomAliases),
subtitle: Text(
(room.canonicalAlias.isNotEmpty)
? room.canonicalAlias
: L10n.of(context)!.none,
),
),
ListTile(
leading: CircleAvatar(
backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: iconColor,
child: const Icon(
Icons.insert_emoticon_outlined,
),
),
title: Text(L10n.of(context)!.emoteSettings),
subtitle: Text(L10n.of(context)!.setCustomEmotes),
onTap: controller.goToEmoteSettings,
),
PopupMenuButton(
onSelected: controller.setJoinRulesAction,
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<JoinRules>>[
if (room.canChangeJoinRules)
PopupMenuItem<JoinRules>(
value: JoinRules.public,
child: Text(
JoinRules.public.getLocalizedString(
MatrixLocals(L10n.of(context)!),
), ),
), ),
), child: Avatar(
if (room.canChangeJoinRules) mxContent: room.avatar,
PopupMenuItem<JoinRules>( name: displayname,
value: JoinRules.invite, size: Avatar.defaultSize * 2.5,
child: Text( fontSize: 18 * 2.5,
JoinRules.invite.getLocalizedString(
MatrixLocals(L10n.of(context)!),
),
), ),
), ),
], if (room.canChangeStateEvent(
child: ListTile( EventTypes.RoomAvatar,
leading: CircleAvatar( ))
backgroundColor: Positioned(
Theme.of(context).scaffoldBackgroundColor, bottom: 0,
foregroundColor: iconColor, right: 0,
child: const Icon(Icons.shield_outlined), child: FloatingActionButton.small(
), onPressed: controller.setAvatarAction,
title: Text( heroTag: null,
L10n.of(context)!.whoIsAllowedToJoinThisGroup, child: const Icon(
), Icons.camera_alt_outlined,
subtitle: Text(
room.joinRules?.getLocalizedString(
MatrixLocals(L10n.of(context)!),
) ??
L10n.of(context)!.none,
),
),
),
PopupMenuButton(
onSelected: controller.setHistoryVisibilityAction,
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<HistoryVisibility>>[
if (room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.invited,
child: Text(
HistoryVisibility.invited
.getLocalizedString(
MatrixLocals(L10n.of(context)!),
),
),
),
if (room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.joined,
child: Text(
HistoryVisibility.joined
.getLocalizedString(
MatrixLocals(L10n.of(context)!),
),
),
),
if (room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.shared,
child: Text(
HistoryVisibility.shared
.getLocalizedString(
MatrixLocals(L10n.of(context)!),
),
),
),
if (room.canChangeHistoryVisibility)
PopupMenuItem<HistoryVisibility>(
value: HistoryVisibility.worldReadable,
child: Text(
HistoryVisibility.worldReadable
.getLocalizedString(
MatrixLocals(L10n.of(context)!),
),
),
),
],
child: ListTile(
leading: CircleAvatar(
backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: iconColor,
child: const Icon(Icons.visibility_outlined),
),
title: Text(
L10n.of(context)!.visibilityOfTheChatHistory,
),
subtitle: Text(
room.historyVisibility?.getLocalizedString(
MatrixLocals(L10n.of(context)!),
) ??
L10n.of(context)!.none,
),
),
),
if (room.joinRules == JoinRules.public)
PopupMenuButton(
onSelected: controller.setGuestAccessAction,
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<GuestAccess>>[
if (room.canChangeGuestAccess)
PopupMenuItem<GuestAccess>(
value: GuestAccess.canJoin,
child: Text(
GuestAccess.canJoin.getLocalizedString(
MatrixLocals(
L10n.of(context)!,
),
),
),
),
if (room.canChangeGuestAccess)
PopupMenuItem<GuestAccess>(
value: GuestAccess.forbidden,
child: Text(
GuestAccess.forbidden
.getLocalizedString(
MatrixLocals(
L10n.of(context)!,
),
), ),
), ),
), ),
], ],
child: ListTile( ),
leading: CircleAvatar( ),
backgroundColor: Theme.of(context) Expanded(
.scaffoldBackgroundColor, child: Column(
foregroundColor: iconColor, mainAxisAlignment: MainAxisAlignment.center,
child: const Icon( crossAxisAlignment: CrossAxisAlignment.start,
Icons.person_add_alt_1_outlined, children: [
TextButton.icon(
onPressed: () => room.canChangeStateEvent(
EventTypes.RoomName,
)
? controller.setDisplaynameAction()
: FluffyShare.share(
displayname,
context,
copyOnly: true,
),
icon: Icon(
room.canChangeStateEvent(
EventTypes.RoomName,
)
? Icons.edit_outlined
: Icons.copy_outlined,
size: 16,
),
style: TextButton.styleFrom(
foregroundColor: Theme.of(context)
.colorScheme
.onBackground,
),
label: Text(
displayname,
maxLines: 1,
overflow: TextOverflow.ellipsis,
// style: const TextStyle(fontSize: 18),
), ),
), ),
title: Text( TextButton.icon(
L10n.of(context)!.areGuestsAllowedToJoin, onPressed: () => context.go(
), '/rooms/${controller.roomId}/details/members',
subtitle: Text( ),
room.guestAccess.getLocalizedString( icon: const Icon(
MatrixLocals(L10n.of(context)!), Icons.group_outlined,
size: 14,
),
style: TextButton.styleFrom(
foregroundColor: Theme.of(context)
.colorScheme
.secondary,
),
label: Text(
L10n.of(context)!.countParticipants(
actualMembersCount,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
// style: const TextStyle(fontSize: 12),
), ),
), ),
), ],
), ),
ListTile(
title:
Text(L10n.of(context)!.editChatPermissions),
subtitle: Text(
L10n.of(context)!.whoCanPerformWhichAction,
),
leading: CircleAvatar(
backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: iconColor,
child: const Icon(
Icons.edit_attributes_outlined,
),
),
onTap: () => context
.go('/rooms/${room.id}/details/permissions'),
), ),
], ],
const Divider(height: 1), ),
ListTile( Divider(
title: Text( height: 1,
actualMembersCount > 1 color: Theme.of(context).dividerColor,
? L10n.of(context)!.countParticipants( ),
actualMembersCount.toString(), ListTile(
) onTap: room.canSendEvent(EventTypes.RoomTopic)
: L10n.of(context)!.emptyChat, ? controller.setTopicAction
style: TextStyle( : null,
color: Theme.of(context).colorScheme.secondary, trailing: room.canSendEvent(EventTypes.RoomTopic)
fontWeight: FontWeight.bold, ? Icon(
), Icons.edit_outlined,
color: Theme.of(context)
.colorScheme
.onBackground,
)
: null,
title: Text(
L10n.of(context)!.groupDescription,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold,
), ),
), ),
room.canInvite ),
? ListTile( Padding(
title: Text(L10n.of(context)!.inviteContact), padding: const EdgeInsets.symmetric(
leading: CircleAvatar( horizontal: 16.0,
backgroundColor: ),
Theme.of(context).primaryColor, child: Linkify(
foregroundColor: Colors.white, text: room.topic.isEmpty
radius: Avatar.defaultSize / 2, ? L10n.of(context)!.noGroupDescriptionYet
child: const Icon(Icons.add_outlined), : room.topic,
), options: const LinkifyOptions(humanize: false),
onTap: () => linkStyle:
context.go('/rooms/${room.id}/invite'), const TextStyle(color: Colors.blueAccent),
) style: TextStyle(
: const SizedBox.shrink(), fontSize: 14,
], fontStyle: room.topic.isEmpty
) ? FontStyle.italic
: i < controller.members!.length + 1 : FontStyle.normal,
? ParticipantListItem(controller.members![i - 1]) color:
: ListTile( Theme.of(context).textTheme.bodyMedium!.color,
title: Text( decorationColor:
L10n.of(context)!.loadCountMoreParticipants( Theme.of(context).textTheme.bodyMedium!.color,
(actualMembersCount -
controller.members!.length)
.toString(),
),
), ),
onOpen: (url) =>
UrlLauncher(context, url.url).launchUrl(),
),
),
const SizedBox(height: 16),
Divider(
height: 1,
color: Theme.of(context).dividerColor,
),
if (room.joinRules == JoinRules.public)
ListTile(
leading: CircleAvatar( leading: CircleAvatar(
backgroundColor: backgroundColor:
Theme.of(context).scaffoldBackgroundColor, Theme.of(context).scaffoldBackgroundColor,
foregroundColor: iconColor,
child: const Icon(Icons.link_outlined),
),
trailing: const Icon(Icons.chevron_right_outlined),
onTap: controller.editAliases,
title: Text(L10n.of(context)!.editRoomAliases),
subtitle: Text(
(room.canonicalAlias.isNotEmpty)
? room.canonicalAlias
: L10n.of(context)!.none,
),
),
ListTile(
leading: CircleAvatar(
backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: iconColor,
child: const Icon(
Icons.insert_emoticon_outlined,
),
),
title: Text(L10n.of(context)!.emoteSettings),
subtitle: Text(L10n.of(context)!.setCustomEmotes),
onTap: controller.goToEmoteSettings,
trailing: const Icon(Icons.chevron_right_outlined),
),
ListTile(
leading: CircleAvatar(
backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: iconColor,
child: const Icon(Icons.shield_outlined),
),
title: Text(
L10n.of(context)!.whoIsAllowedToJoinThisGroup,
),
trailing: const Icon(Icons.chevron_right_outlined),
subtitle: Text(
room.joinRules?.getLocalizedString(
MatrixLocals(L10n.of(context)!),
) ??
L10n.of(context)!.none,
),
onTap: controller.setJoinRules,
),
ListTile(
leading: CircleAvatar(
backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: iconColor,
child: const Icon(Icons.visibility_outlined),
),
trailing: const Icon(Icons.chevron_right_outlined),
title: Text(
L10n.of(context)!.visibilityOfTheChatHistory,
),
subtitle: Text(
room.historyVisibility?.getLocalizedString(
MatrixLocals(L10n.of(context)!),
) ??
L10n.of(context)!.none,
),
onTap: controller.setHistoryVisibility,
),
if (room.joinRules == JoinRules.public)
ListTile(
leading: CircleAvatar(
backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: iconColor,
child: const Icon( child: const Icon(
Icons.refresh, Icons.person_add_alt_1_outlined,
color: Colors.grey,
), ),
), ),
onTap: controller.requestMoreMembersAction, trailing: const Icon(Icons.chevron_right_outlined),
title: Text(
L10n.of(context)!.areGuestsAllowedToJoin,
),
subtitle: Text(
room.guestAccess.getLocalizedString(
MatrixLocals(L10n.of(context)!),
),
),
onTap: controller.setGuestAccess,
), ),
), ListTile(
title: Text(L10n.of(context)!.editChatPermissions),
subtitle: Text(
L10n.of(context)!.whoCanPerformWhichAction,
),
leading: CircleAvatar(
backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
foregroundColor: iconColor,
child: const Icon(
Icons.edit_attributes_outlined,
),
),
trailing: const Icon(Icons.chevron_right_outlined),
onTap: () => context
.go('/rooms/${room.id}/details/permissions'),
),
Divider(
height: 1,
color: Theme.of(context).dividerColor,
),
ListTile(
title: Text(
L10n.of(context)!.countParticipants(
actualMembersCount.toString(),
),
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
),
if (room.canInvite)
ListTile(
title: Text(L10n.of(context)!.inviteContact),
leading: CircleAvatar(
backgroundColor: Theme.of(context).primaryColor,
foregroundColor: Colors.white,
radius: Avatar.defaultSize / 2,
child: const Icon(Icons.add_outlined),
),
trailing: const Icon(Icons.chevron_right_outlined),
onTap: () => context.go('/rooms/${room.id}/invite'),
),
],
)
: i < members.length + 1
? ParticipantListItem(members[i - 1])
: ListTile(
title: Text(
L10n.of(context)!.loadCountMoreParticipants(
(actualMembersCount - members.length).toString(),
),
),
leading: CircleAvatar(
backgroundColor:
Theme.of(context).scaffoldBackgroundColor,
child: const Icon(
Icons.group_outlined,
color: Colors.grey,
),
),
onTap: () => context.go(
'/rooms/${controller.roomId!}/details/members',
),
trailing: const Icon(Icons.chevron_right_outlined),
),
), ),
), ),
); );

View file

@ -38,7 +38,12 @@ class ParticipantListItem extends StatelessWidget {
), ),
title: Row( title: Row(
children: <Widget>[ children: <Widget>[
Text(user.calcDisplayname()), Expanded(
child: Text(
user.calcDisplayname(),
overflow: TextOverflow.ellipsis,
),
),
if (permissionBatch.isNotEmpty) if (permissionBatch.isNotEmpty)
Container( Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(

View file

@ -18,6 +18,7 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget {
return SliverAppBar( return SliverAppBar(
floating: true, floating: true,
toolbarHeight: Theme.of(context).appBarTheme.toolbarHeight ?? 56,
pinned: pinned:
FluffyThemes.isColumnMode(context) || selectMode != SelectMode.normal, FluffyThemes.isColumnMode(context) || selectMode != SelectMode.normal,
scrolledUnderElevation: selectMode == SelectMode.normal ? 0 : null, scrolledUnderElevation: selectMode == SelectMode.normal ? 0 : null,

View file

@ -0,0 +1,76 @@
import 'package:flutter/material.dart';
import 'package:matrix/matrix.dart';
import '../../widgets/matrix.dart';
import 'chat_members_view.dart';
class ChatMembersPage extends StatefulWidget {
final String roomId;
const ChatMembersPage({required this.roomId, super.key});
@override
State<ChatMembersPage> createState() => ChatMembersController();
}
class ChatMembersController extends State<ChatMembersPage> {
List<User>? members;
List<User>? filteredMembers;
Object? error;
final TextEditingController filterController = TextEditingController();
void setFilter([_]) async {
final filter = filterController.text.toLowerCase().trim();
if (filter.isEmpty) {
setState(() {
filteredMembers = members
?..sort((b, a) => a.powerLevel.compareTo(b.powerLevel));
});
return;
}
setState(() {
filteredMembers = members
?.where(
(user) =>
user.displayName?.toLowerCase().contains(filter) ??
user.id.toLowerCase().contains(filter),
)
.toList()
?..sort((b, a) => a.powerLevel.compareTo(b.powerLevel));
});
}
void refreshMembers() async {
try {
setState(() {
error = null;
});
final participants = await Matrix.of(context)
.client
.getRoomById(widget.roomId)
?.requestParticipants();
setState(() {
members = participants;
});
setFilter();
} catch (e, s) {
Logs()
.d('Unable to request participants. Try again in 3 seconds...', e, s);
setState(() {
error = e;
});
}
}
@override
void initState() {
super.initState();
refreshMembers();
}
@override
Widget build(BuildContext context) => ChatMembersView(this);
}

View file

@ -0,0 +1,101 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:go_router/go_router.dart';
import 'package:fluffychat/utils/localized_exception_extension.dart';
import '../../widgets/layouts/max_width_body.dart';
import '../../widgets/matrix.dart';
import '../chat_details/participant_list_item.dart';
import 'chat_members.dart';
class ChatMembersView extends StatelessWidget {
final ChatMembersController controller;
const ChatMembersView(this.controller, {super.key});
@override
Widget build(BuildContext context) {
final room =
Matrix.of(context).client.getRoomById(controller.widget.roomId);
if (room == null) {
return Scaffold(
appBar: AppBar(
title: Text(L10n.of(context)!.oopsSomethingWentWrong),
),
body: Center(
child: Text(L10n.of(context)!.youAreNoLongerParticipatingInThisChat),
),
);
}
final members = controller.filteredMembers;
final roomCount = (room.summary.mJoinedMemberCount ?? 0) +
(room.summary.mInvitedMemberCount ?? 0);
final error = controller.error;
return Scaffold(
appBar: AppBar(
leading: const Center(child: BackButton()),
title: Text(
L10n.of(context)!.countParticipants(roomCount),
),
actions: [
IconButton(
onPressed: () => context.go('/rooms/{room.id}/invite'),
icon: const Icon(
Icons.person_add_outlined,
),
),
],
),
body: MaxWidthBody(
withScrolling: false,
child: error != null
? Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.error_outline),
Text(error.toLocalizedString(context)),
const SizedBox(height: 8),
OutlinedButton.icon(
onPressed: controller.refreshMembers,
icon: const Icon(Icons.refresh_outlined),
label: Text(L10n.of(context)!.tryAgain),
),
],
),
),
)
: members == null
? const Center(
child: Padding(
padding: EdgeInsets.all(16.0),
child: CircularProgressIndicator.adaptive(),
),
)
: ListView.builder(
shrinkWrap: true,
itemCount: members.length + 1,
itemBuilder: (context, i) => i == 0
? Padding(
padding: const EdgeInsets.all(16.0),
child: TextField(
controller: controller.filterController,
onChanged: controller.setFilter,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.search_outlined),
hintText: L10n.of(context)!.search,
),
),
)
: ParticipantListItem(members[i - 1]),
),
),
);
}
}

View file

@ -1,7 +1,6 @@
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';
import 'package:go_router/go_router.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:fluffychat/pages/chat_permissions_settings/chat_permissions_settings.dart'; import 'package:fluffychat/pages/chat_permissions_settings/chat_permissions_settings.dart';
@ -19,17 +18,10 @@ class ChatPermissionsSettingsView extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: GoRouterState.of(context).uri.path.startsWith('/spaces/') leading: const Center(child: BackButton()),
? null
: IconButton(
icon: const Icon(Icons.close_outlined),
onPressed: () =>
context.go(['', 'rooms', controller.roomId!].join('/')),
),
title: Text(L10n.of(context)!.editChatPermissions), title: Text(L10n.of(context)!.editChatPermissions),
), ),
body: MaxWidthBody( body: MaxWidthBody(
withScrolling: true,
child: StreamBuilder( child: StreamBuilder(
stream: controller.onChanged, stream: controller.onChanged,
builder: (context, _) { builder: (context, _) {

View file

@ -33,7 +33,6 @@ class DevicesSettingsController extends State<DevicesSettings> {
void removeDevicesAction(List<Device> devices) async { void removeDevicesAction(List<Device> devices) async {
if (await showOkCancelAlertDialog( if (await showOkCancelAlertDialog(
useRootNavigator: false,
context: context, context: context,
title: L10n.of(context)!.areYouSure, title: L10n.of(context)!.areYouSure,
okLabel: L10n.of(context)!.yes, okLabel: L10n.of(context)!.yes,
@ -68,7 +67,6 @@ class DevicesSettingsController extends State<DevicesSettings> {
void renameDeviceAction(Device device) async { void renameDeviceAction(Device device) async {
final displayName = await showTextInputDialog( final displayName = await showTextInputDialog(
useRootNavigator: false,
context: context, context: context,
title: L10n.of(context)!.changeDeviceName, title: L10n.of(context)!.changeDeviceName,
okLabel: L10n.of(context)!.ok, okLabel: L10n.of(context)!.ok,

View file

@ -39,6 +39,8 @@ class DevicesSettingsView extends StatelessWidget {
); );
} }
return ListView.builder( return ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: controller.notThisDevice.length + 1, itemCount: controller.notThisDevice.length + 1,
itemBuilder: (BuildContext context, int i) { itemBuilder: (BuildContext context, int i) {
if (i == 0) { if (i == 0) {

View file

@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:go_router/go_router.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:fluffychat/pages/invitation_selection/invitation_selection_view.dart'; import 'package:fluffychat/pages/invitation_selection/invitation_selection_view.dart';
@ -14,7 +13,11 @@ import 'package:fluffychat/widgets/matrix.dart';
import '../../utils/localized_exception_extension.dart'; import '../../utils/localized_exception_extension.dart';
class InvitationSelection extends StatefulWidget { class InvitationSelection extends StatefulWidget {
const InvitationSelection({Key? key}) : super(key: key); final String roomId;
const InvitationSelection({
Key? key,
required this.roomId,
}) : super(key: key);
@override @override
InvitationSelectionController createState() => InvitationSelectionController createState() =>
@ -28,7 +31,7 @@ class InvitationSelectionController extends State<InvitationSelection> {
List<Profile> foundProfiles = []; List<Profile> foundProfiles = [];
Timer? coolDown; Timer? coolDown;
String? get roomId => GoRouterState.of(context).pathParameters['roomid']; String? get roomId => widget.roomId;
Future<List<User>> getContacts(BuildContext context) async { Future<List<User>> getContacts(BuildContext context) async {
final client = Matrix.of(context).client; final client = Matrix.of(context).client;
@ -37,12 +40,10 @@ 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 participantsIds = participants.map((p) => p.stateKey).toList();
final contacts = client.rooms final contacts = client.rooms
.where((r) => r.isDirectChat) .where((r) => r.isDirectChat)
.map((r) => r.unsafeGetUserFromMemoryOrFallback(r.directChatMatrixID!)) .map((r) => r.unsafeGetUserFromMemoryOrFallback(r.directChatMatrixID!))
.toList() .toList();
..removeWhere((u) => participantsIds.contains(u.stateKey));
contacts.sort( contacts.sort(
(a, b) => a.calcDisplayname().toLowerCase().compareTo( (a, b) => a.calcDisplayname().toLowerCase().compareTo(
b.calcDisplayname().toLowerCase(), b.calcDisplayname().toLowerCase(),
@ -51,17 +52,19 @@ class InvitationSelectionController extends State<InvitationSelection> {
return contacts; return contacts;
} }
void inviteAction(BuildContext context, String id) async { void inviteAction(BuildContext context, String id, String displayname) async {
final room = Matrix.of(context).client.getRoomById(roomId!)!; final room = Matrix.of(context).client.getRoomById(roomId!)!;
if (OkCancelResult.ok != if (OkCancelResult.ok !=
await showOkCancelAlertDialog( await showOkCancelAlertDialog(
context: context, context: context,
title: L10n.of(context)!.inviteContactToGroup( title: L10n.of(context)!.inviteContact,
message: L10n.of(context)!.inviteContactToGroupQuestion(
displayname,
room.getLocalizedDisplayname( room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!), MatrixLocals(L10n.of(context)!),
), ),
), ),
okLabel: L10n.of(context)!.yes, okLabel: L10n.of(context)!.invite,
cancelLabel: L10n.of(context)!.cancel, cancelLabel: L10n.of(context)!.cancel,
)) { )) {
return; return;
@ -118,19 +121,6 @@ class InvitationSelectionController extends State<InvitationSelection> {
], ],
); );
} }
final participants = Matrix.of(context)
.client
.getRoomById(roomId!)!
.getParticipants()
.where(
(user) =>
[Membership.join, Membership.invite].contains(user.membership),
)
.toList();
foundProfiles.removeWhere(
(profile) =>
participants.indexWhere((u) => u.id == profile.userId) != -1,
);
}); });
} }

View file

@ -1,7 +1,6 @@
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';
import 'package:go_router/go_router.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:fluffychat/pages/invitation_selection/invitation_selection.dart'; import 'package:fluffychat/pages/invitation_selection/invitation_selection.dart';
@ -20,104 +19,152 @@ class InvitationSelectionView extends StatelessWidget {
final groupName = room.name.isEmpty ? L10n.of(context)!.group : room.name; final groupName = room.name.isEmpty ? L10n.of(context)!.group : room.name;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: GoRouterState.of(context).uri.path.startsWith('/spaces/') leading: const Center(child: BackButton()),
? null
: IconButton(
icon: const Icon(Icons.close_outlined),
onPressed: () =>
context.go(['', 'rooms', controller.roomId!].join('/')),
),
titleSpacing: 0, titleSpacing: 0,
title: SizedBox( title: Text(L10n.of(context)!.inviteContact),
height: 44, ),
child: Padding( body: MaxWidthBody(
padding: const EdgeInsets.only(right: 12.0), child: Column(
child: TextField( children: [
textInputAction: TextInputAction.search, Padding(
decoration: InputDecoration( padding: const EdgeInsets.all(16.0),
hintText: L10n.of(context)!.inviteContactToGroup(groupName), child: TextField(
suffixIcon: controller.loading textInputAction: TextInputAction.search,
? const Padding( decoration: InputDecoration(
padding: EdgeInsets.symmetric( hintText: L10n.of(context)!.inviteContactToGroup(groupName),
vertical: 10.0, prefixIcon: controller.loading
horizontal: 12, ? const Padding(
), padding: EdgeInsets.symmetric(
child: SizedBox.square( vertical: 10.0,
dimension: 24, horizontal: 12,
child: CircularProgressIndicator.adaptive( ),
strokeWidth: 2, child: SizedBox.square(
dimension: 24,
child: CircularProgressIndicator.adaptive(
strokeWidth: 2,
),
),
)
: const Icon(Icons.search_outlined),
),
onChanged: controller.searchUserWithCoolDown,
),
),
StreamBuilder<Object>(
stream: room.onUpdate.stream,
builder: (context, snapshot) {
final participants =
room.getParticipants().map((user) => user.id).toSet();
return controller.foundProfiles.isNotEmpty
? ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: controller.foundProfiles.length,
itemBuilder: (BuildContext context, int i) =>
_InviteContactListTile(
avatarUrl: controller.foundProfiles[i].avatarUrl,
displayname: controller
.foundProfiles[i].displayName ??
controller.foundProfiles[i].userId.localpart ??
L10n.of(context)!.user,
userId: controller.foundProfiles[i].userId,
isMember: participants
.contains(controller.foundProfiles[i].userId),
onTap: () => controller.inviteAction(
context,
controller.foundProfiles[i].userId,
controller.foundProfiles[i].displayName ??
controller.foundProfiles[i].userId.localpart ??
L10n.of(context)!.user,
), ),
), ),
) )
: const Icon(Icons.search_outlined), : FutureBuilder<List<User>>(
), future: controller.getContacts(context),
onChanged: controller.searchUserWithCoolDown, builder: (BuildContext context, snapshot) {
if (!snapshot.hasData) {
return const Center(
child: CircularProgressIndicator.adaptive(
strokeWidth: 2,
),
);
}
final contacts = snapshot.data!;
return ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: contacts.length,
itemBuilder: (BuildContext context, int i) =>
_InviteContactListTile(
avatarUrl: contacts[i].avatarUrl,
displayname: contacts[i].displayName ??
contacts[i].id.localpart ??
L10n.of(context)!.user,
userId: contacts[i].id,
isMember: participants.contains(contacts[i].id),
onTap: () => controller.inviteAction(
context,
contacts[i].id,
contacts[i].displayName ??
contacts[i].id.localpart ??
L10n.of(context)!.user,
),
),
);
},
);
},
), ),
), ],
), ),
), ),
body: MaxWidthBody( );
withScrolling: true, }
child: controller.foundProfiles.isNotEmpty }
? ListView.builder(
physics: const NeverScrollableScrollPhysics(), class _InviteContactListTile extends StatelessWidget {
shrinkWrap: true, final String userId;
itemCount: controller.foundProfiles.length, final String displayname;
itemBuilder: (BuildContext context, int i) => ListTile( final Uri? avatarUrl;
leading: Avatar( final bool isMember;
mxContent: controller.foundProfiles[i].avatarUrl, final void Function() onTap;
name: controller.foundProfiles[i].displayName ??
controller.foundProfiles[i].userId, const _InviteContactListTile({
), Key? key,
title: Text( required this.userId,
controller.foundProfiles[i].displayName ?? required this.displayname,
controller.foundProfiles[i].userId.localpart!, required this.avatarUrl,
), required this.isMember,
subtitle: Text(controller.foundProfiles[i].userId), required this.onTap,
onTap: () => controller.inviteAction( }) : super(key: key);
context,
controller.foundProfiles[i].userId, @override
), Widget build(BuildContext context) {
), return Opacity(
) opacity: isMember ? 0.5 : 1,
: FutureBuilder<List<User>>( child: ListTile(
future: controller.getContacts(context), leading: Avatar(
builder: (BuildContext context, snapshot) { mxContent: avatarUrl,
if (!snapshot.hasData) { name: displayname,
return const Center( ),
child: CircularProgressIndicator.adaptive(strokeWidth: 2), title: Text(
); displayname,
} maxLines: 1,
final contacts = snapshot.data!; overflow: TextOverflow.ellipsis,
return ListView.builder( ),
physics: const NeverScrollableScrollPhysics(), subtitle: Text(
shrinkWrap: true, userId,
itemCount: contacts.length, maxLines: 1,
itemBuilder: (BuildContext context, int i) => ListTile( overflow: TextOverflow.ellipsis,
leading: Avatar( style: TextStyle(
mxContent: contacts[i].avatarUrl, color: Theme.of(context).colorScheme.secondary,
name: contacts[i].calcDisplayname(), ),
), ),
title: Text( onTap: isMember ? null : onTap,
contacts[i].calcDisplayname(), trailing: isMember
maxLines: 1, ? Text(L10n.of(context)!.participant)
overflow: TextOverflow.ellipsis, : const Icon(Icons.person_add_outlined),
), ),
subtitle: Text(
contacts[i].id,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
),
),
onTap: () =>
controller.inviteAction(context, contacts[i].id),
),
);
},
),
),
); );
} }
} }

View file

@ -45,7 +45,7 @@ class NewPrivateChatView extends StatelessWidget {
children: [ children: [
Expanded( Expanded(
child: MaxWidthBody( child: MaxWidthBody(
withScrolling: true, withFrame: false,
child: Container( child: Container(
margin: const EdgeInsets.all(_qrCodePadding), margin: const EdgeInsets.all(_qrCodePadding),
alignment: Alignment.center, alignment: Alignment.center,
@ -98,7 +98,6 @@ class NewPrivateChatView extends StatelessWidget {
), ),
), ),
MaxWidthBody( MaxWidthBody(
withScrolling: false,
child: Padding( child: Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Form( child: Form(

View file

@ -24,7 +24,6 @@ class SettingsChatView extends StatelessWidget {
body: ListTileTheme( body: ListTileTheme(
iconColor: Theme.of(context).textTheme.bodyLarge!.color, iconColor: Theme.of(context).textTheme.bodyLarge!.color,
child: MaxWidthBody( child: MaxWidthBody(
withScrolling: true,
child: Column( child: Column(
children: [ children: [
ListTile( ListTile(

View file

@ -59,6 +59,7 @@ class EmotesSettingsView extends StatelessWidget {
: null, : null,
body: MaxWidthBody( body: MaxWidthBody(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
if (!controller.readonly) if (!controller.readonly)
Container( Container(
@ -116,120 +117,114 @@ class EmotesSettingsView extends StatelessWidget {
onChanged: controller.setIsGloballyActive, onChanged: controller.setIsGloballyActive,
), ),
if (!controller.readonly || controller.room != null) if (!controller.readonly || controller.room != null)
Divider( const Divider(thickness: 1),
height: 2, imageKeys.isEmpty
thickness: 2, ? Center(
color: Theme.of(context).primaryColor, child: Padding(
), padding: const EdgeInsets.all(16),
Expanded( child: Text(
child: imageKeys.isEmpty L10n.of(context)!.noEmotesFound,
? Center( style: const TextStyle(fontSize: 20),
child: Padding(
padding: const EdgeInsets.all(16),
child: Text(
L10n.of(context)!.noEmotesFound,
style: const TextStyle(fontSize: 20),
),
), ),
) ),
: ListView.separated( )
separatorBuilder: (BuildContext context, int i) => : ListView.separated(
const SizedBox.shrink(), shrinkWrap: true,
itemCount: imageKeys.length + 1, physics: const NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int i) { separatorBuilder: (BuildContext context, int i) =>
if (i >= imageKeys.length) { const SizedBox.shrink(),
return Container(height: 70); itemCount: imageKeys.length + 1,
} itemBuilder: (BuildContext context, int i) {
final imageCode = imageKeys[i]; if (i >= imageKeys.length) {
final image = controller.pack!.images[imageCode]!; return Container(height: 70);
final textEditingController = TextEditingController(); }
textEditingController.text = imageCode; final imageCode = imageKeys[i];
final useShortCuts = final image = controller.pack!.images[imageCode]!;
(PlatformInfos.isWeb || PlatformInfos.isDesktop); final textEditingController = TextEditingController();
return ListTile( textEditingController.text = imageCode;
leading: Container( final useShortCuts =
width: 180.0, (PlatformInfos.isWeb || PlatformInfos.isDesktop);
height: 38, return ListTile(
padding: const EdgeInsets.symmetric(horizontal: 8), leading: Container(
decoration: BoxDecoration( width: 180.0,
borderRadius: height: 38,
const BorderRadius.all(Radius.circular(10)), padding: const EdgeInsets.symmetric(horizontal: 8),
color: Theme.of(context).secondaryHeaderColor, decoration: BoxDecoration(
), borderRadius:
child: Shortcuts( const BorderRadius.all(Radius.circular(10)),
shortcuts: !useShortCuts color: Theme.of(context).secondaryHeaderColor,
),
child: Shortcuts(
shortcuts: !useShortCuts
? {}
: {
LogicalKeySet(LogicalKeyboardKey.enter):
SubmitLineIntent(),
},
child: Actions(
actions: !useShortCuts
? {} ? {}
: { : {
LogicalKeySet(LogicalKeyboardKey.enter): SubmitLineIntent: CallbackAction(
SubmitLineIntent(), onInvoke: (i) {
controller.submitImageAction(
imageCode,
textEditingController.text,
image,
textEditingController,
);
return null;
},
),
}, },
child: Actions( child: TextField(
actions: !useShortCuts readOnly: controller.readonly,
? {} controller: textEditingController,
: { autocorrect: false,
SubmitLineIntent: CallbackAction( minLines: 1,
onInvoke: (i) { maxLines: 1,
controller.submitImageAction( decoration: InputDecoration(
imageCode, hintText: L10n.of(context)!.emoteShortcode,
textEditingController.text, prefixText: ': ',
image, suffixText: ':',
textEditingController, prefixStyle: TextStyle(
); color:
return null; Theme.of(context).colorScheme.secondary,
}, fontWeight: FontWeight.bold,
),
},
child: TextField(
readOnly: controller.readonly,
controller: textEditingController,
autocorrect: false,
minLines: 1,
maxLines: 1,
decoration: InputDecoration(
hintText: L10n.of(context)!.emoteShortcode,
prefixText: ': ',
suffixText: ':',
prefixStyle: TextStyle(
color: Theme.of(context)
.colorScheme
.secondary,
fontWeight: FontWeight.bold,
),
suffixStyle: TextStyle(
color: Theme.of(context)
.colorScheme
.secondary,
fontWeight: FontWeight.bold,
),
border: InputBorder.none,
), ),
onSubmitted: (s) => suffixStyle: TextStyle(
controller.submitImageAction( color:
imageCode, Theme.of(context).colorScheme.secondary,
s, fontWeight: FontWeight.bold,
image,
textEditingController,
), ),
border: InputBorder.none,
),
onSubmitted: (s) =>
controller.submitImageAction(
imageCode,
s,
image,
textEditingController,
), ),
), ),
), ),
), ),
title: _EmoteImage(image.url), ),
trailing: controller.readonly title: _EmoteImage(image.url),
? null trailing: controller.readonly
: InkWell( ? null
onTap: () => : InkWell(
controller.removeImageAction(imageCode), onTap: () =>
child: const Icon( controller.removeImageAction(imageCode),
Icons.delete_outlined, child: const Icon(
color: Colors.red, Icons.delete_outlined,
size: 32.0, color: Colors.red,
), size: 32.0,
), ),
); ),
}, );
), },
), ),
], ],
), ),
), ),

View file

@ -23,7 +23,6 @@ class SettingsNotificationsView extends StatelessWidget {
title: Text(L10n.of(context)!.notifications), title: Text(L10n.of(context)!.notifications),
), ),
body: MaxWidthBody( body: MaxWidthBody(
withScrolling: true,
child: StreamBuilder( child: StreamBuilder(
stream: Matrix.of(context) stream: Matrix.of(context)
.client .client

View file

@ -20,7 +20,6 @@ class SettingsSecurityView extends StatelessWidget {
body: ListTileTheme( body: ListTileTheme(
iconColor: Theme.of(context).colorScheme.onBackground, iconColor: Theme.of(context).colorScheme.onBackground,
child: MaxWidthBody( child: MaxWidthBody(
withScrolling: true,
child: Column( child: Column(
children: [ children: [
ListTile( ListTile(

View file

@ -24,7 +24,6 @@ class SettingsStyleView extends StatelessWidget {
), ),
backgroundColor: Theme.of(context).colorScheme.surface, backgroundColor: Theme.of(context).colorScheme.surface,
body: MaxWidthBody( body: MaxWidthBody(
withScrolling: true,
child: Column( child: Column(
children: [ children: [
ListTile( ListTile(

View file

@ -36,8 +36,9 @@ class FluffyChatApp extends StatelessWidget {
builder: (context, themeMode, primaryColor) => MaterialApp.router( builder: (context, themeMode, primaryColor) => MaterialApp.router(
title: AppConfig.applicationName, title: AppConfig.applicationName,
themeMode: themeMode, themeMode: themeMode,
theme: FluffyThemes.buildTheme(Brightness.light, primaryColor), theme: FluffyThemes.buildTheme(context, Brightness.light, primaryColor),
darkTheme: FluffyThemes.buildTheme(Brightness.dark, primaryColor), darkTheme:
FluffyThemes.buildTheme(context, Brightness.dark, primaryColor),
scrollBehavior: CustomScrollBehavior(), scrollBehavior: CustomScrollBehavior(),
localizationsDelegates: L10n.localizationsDelegates, localizationsDelegates: L10n.localizationsDelegates,
supportedLocales: L10n.supportedLocales, supportedLocales: L10n.supportedLocales,

View file

@ -2,15 +2,19 @@ import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluffychat/config/app_config.dart';
class MaxWidthBody extends StatelessWidget { class MaxWidthBody extends StatelessWidget {
final Widget? child; final Widget? child;
final double maxWidth; final double maxWidth;
final bool withFrame;
final bool withScrolling; final bool withScrolling;
const MaxWidthBody({ const MaxWidthBody({
this.child, this.child,
this.maxWidth = 600, this.maxWidth = 600,
this.withScrolling = false, this.withFrame = true,
this.withScrolling = true,
Key? key, Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
@ -18,21 +22,33 @@ class MaxWidthBody extends StatelessWidget {
return SafeArea( return SafeArea(
child: LayoutBuilder( child: LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
final paddingVal = max(0, (constraints.maxWidth - maxWidth) / 2);
final hasPadding = paddingVal > 0;
final padding = EdgeInsets.symmetric( final padding = EdgeInsets.symmetric(
vertical: hasPadding ? 32 : 0,
horizontal: max(0, (constraints.maxWidth - maxWidth) / 2), horizontal: max(0, (constraints.maxWidth - maxWidth) / 2),
); );
return withScrolling final childWithPadding = Padding(
? SingleChildScrollView( padding: padding,
physics: const ScrollPhysics(), child: withFrame && hasPadding
child: Padding( ? Material(
padding: padding, elevation:
Theme.of(context).appBarTheme.scrolledUnderElevation ??
4,
clipBehavior: Clip.hardEdge,
borderRadius: BorderRadius.circular(
AppConfig.borderRadius,
),
shadowColor: Theme.of(context).appBarTheme.shadowColor,
child: child, child: child,
), )
) : child,
: Padding( );
padding: padding, if (!withScrolling) return childWithPadding;
child: child, return SingleChildScrollView(
); physics: const ScrollPhysics(),
child: childWithPadding,
);
}, },
), ),
); );

View file

@ -1,61 +0,0 @@
import 'package:flutter/material.dart';
import 'package:fluffychat/config/themes.dart';
class SideViewLayout extends StatelessWidget {
final Widget mainView;
final Widget sideView;
final bool hideSideView;
const SideViewLayout({
Key? key,
required this.mainView,
required this.sideView,
required this.hideSideView,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final sideView = this.sideView;
const sideViewWidth = 360.0;
final threeColumnMode = FluffyThemes.isThreeColumnMode(context);
return Stack(
children: [
AnimatedPositioned(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
top: 0,
left: 0,
bottom: 0,
right: !threeColumnMode || hideSideView ? 0 : sideViewWidth,
child: ClipRRect(child: mainView),
),
AnimatedPositioned(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
bottom: 0,
top: 0,
right: 0,
left: !threeColumnMode && !hideSideView ? 0 : null,
width: hideSideView
? 0
: !threeColumnMode
? null
: sideViewWidth,
child: hideSideView
? const SizedBox.shrink()
: Container(
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
border: Border(
left: BorderSide(
color: Theme.of(context).dividerColor,
),
),
),
child: sideView,
),
),
],
);
}
}

View file

@ -25,8 +25,8 @@ class LockScreenState extends State<LockScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
theme: FluffyThemes.buildTheme(Brightness.light), theme: FluffyThemes.buildTheme(context, Brightness.light),
darkTheme: FluffyThemes.buildTheme(Brightness.dark), darkTheme: FluffyThemes.buildTheme(context, Brightness.dark),
localizationsDelegates: L10n.localizationsDelegates, localizationsDelegates: L10n.localizationsDelegates,
supportedLocales: L10n.supportedLocales, supportedLocales: L10n.supportedLocales,
home: Builder( home: Builder(