diff --git a/lib/config/app_config.dart b/lib/config/app_config.dart index ac9b54f36..c6dae0aa7 100644 --- a/lib/config/app_config.dart +++ b/lib/config/app_config.dart @@ -71,6 +71,7 @@ abstract class AppConfig { static bool hideRedactedEvents = false; static bool hideUnknownEvents = true; static bool hideUnimportantStateEvents = true; + static bool separateChatTypes = false; static bool autoplayImages = true; static bool sendTypingNotifications = true; static bool sendPublicReadReceipts = true; diff --git a/lib/config/setting_keys.dart b/lib/config/setting_keys.dart index 5b795b08e..7c0e50df8 100644 --- a/lib/config/setting_keys.dart +++ b/lib/config/setting_keys.dart @@ -4,6 +4,7 @@ abstract class SettingKeys { static const String hideUnknownEvents = 'chat.fluffy.hideUnknownEvents'; static const String hideUnimportantStateEvents = 'chat.fluffy.hideUnimportantStateEvents'; + static const String separateChatTypes = 'chat.fluffy.separateChatTypes'; static const String sentry = 'sentry'; static const String theme = 'theme'; static const String amoledEnabled = 'amoled_enabled'; diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 79ad16e43..c8772f9e8 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -54,8 +54,9 @@ enum PopupMenuAction { enum ActiveFilter { allChats, - unread, + messages, groups, + unread, spaces, } @@ -64,6 +65,8 @@ extension LocalizedActiveFilter on ActiveFilter { switch (this) { case ActiveFilter.allChats: return L10n.of(context)!.all; + case ActiveFilter.messages: + return L10n.of(context)!.messages; case ActiveFilter.unread: return L10n.of(context)!.unread; case ActiveFilter.groups: @@ -101,115 +104,25 @@ class ChatListController extends State context.push('/rooms/newspace'); } - ActiveFilter activeFilter = ActiveFilter.allChats; + ActiveFilter activeFilter = AppConfig.separateChatTypes + ? ActiveFilter.messages + : ActiveFilter.allChats; String? _activeSpaceId; String? get activeSpaceId => _activeSpaceId; - void setActiveSpace(String spaceId) => setState(() { - _activeSpaceId = spaceId; - }); + void setActiveSpace(String spaceId) async { + await Matrix.of(context).client.getRoomById(spaceId)!.postLoad(); + + setState(() { + _activeSpaceId = spaceId; + }); + } + void clearActiveSpace() => setState(() { _activeSpaceId = null; }); - void addChatAction() async { - if (activeSpaceId == null) { - // #Pangea - // context.go('/rooms/newprivatechat'); - context.go('/rooms/newgroup'); - // Pangea# - return; - } - - final roomType = await showConfirmationDialog( - context: context, - title: L10n.of(context)!.addChatOrSubSpace, - actions: [ - AlertDialogAction( - key: AddRoomType.subspace, - label: L10n.of(context)!.createNewSpace, - ), - AlertDialogAction( - key: AddRoomType.chat, - label: L10n.of(context)!.createGroup, - ), - ], - ); - if (roomType == null) return; - - final names = await showTextInputDialog( - context: context, - title: roomType == AddRoomType.subspace - ? L10n.of(context)!.createNewSpace - : L10n.of(context)!.createGroup, - textFields: [ - DialogTextField( - hintText: roomType == AddRoomType.subspace - ? L10n.of(context)!.spaceName - : L10n.of(context)!.groupName, - minLines: 1, - maxLines: 1, - maxLength: 64, - validator: (text) { - if (text == null || text.isEmpty) { - return L10n.of(context)!.pleaseChoose; - } - return null; - }, - ), - DialogTextField( - hintText: L10n.of(context)!.chatDescription, - minLines: 4, - maxLines: 8, - maxLength: 255, - ), - ], - okLabel: L10n.of(context)!.create, - cancelLabel: L10n.of(context)!.cancel, - ); - if (names == null) return; - final client = Matrix.of(context).client; - final result = await showFutureLoadingDialog( - context: context, - future: () async { - late final String roomId; - final activeSpace = client.getRoomById(activeSpaceId!)!; - await activeSpace.postLoad(); - - if (roomType == AddRoomType.subspace) { - roomId = await client.createSpace( - name: names.first, - topic: names.last.isEmpty ? null : names.last, - visibility: activeSpace.joinRules == JoinRules.public - ? sdk.Visibility.public - : sdk.Visibility.private, - ); - } else { - roomId = await client.createGroupChat( - groupName: names.first, - preset: activeSpace.joinRules == JoinRules.public - ? CreateRoomPreset.publicChat - : CreateRoomPreset.privateChat, - visibility: activeSpace.joinRules == JoinRules.public - ? sdk.Visibility.public - : sdk.Visibility.private, - initialState: names.length > 1 && names.last.isNotEmpty - ? [ - sdk.StateEvent( - type: sdk.EventTypes.RoomTopic, - content: {'topic': names.last}, - ), - ] - : null, - ); - } - await activeSpace.setSpaceChild(roomId); - }, - ); - if (result.error != null) return; - } - void onChatTap(Room room) async { if (room.membership == Membership.invite) { final inviterId = @@ -327,11 +240,18 @@ class ChatListController extends State bool Function(Room) getRoomFilterByActiveFilter(ActiveFilter activeFilter) { switch (activeFilter) { case ActiveFilter.allChats: + // #Pangea + // return (room) => true; + return (room) => !room.isAnalyticsRoom; + // Pangea# + case ActiveFilter.messages: return (room) => - true // #Pangea + !room.isSpace && + room.isDirectChat + // #Pangea && !room.isAnalyticsRoom; - // Pangea#; + // Pangea# case ActiveFilter.groups: return (room) => !room.isSpace && @@ -1142,8 +1062,6 @@ enum InviteActions { block, } -enum AddRoomType { chat, subspace } - enum ChatContextAction { open, goToSpace, diff --git a/lib/pages/chat_list/chat_list_body.dart b/lib/pages/chat_list/chat_list_body.dart index 47dcd7eb0..2f5aa96ff 100644 --- a/lib/pages/chat_list/chat_list_body.dart +++ b/lib/pages/chat_list/chat_list_body.dart @@ -165,9 +165,12 @@ class ChatListViewBody extends StatelessWidget { shrinkWrap: true, scrollDirection: Axis.horizontal, children: [ - ActiveFilter.allChats, - ActiveFilter.unread, + if (AppConfig.separateChatTypes) + ActiveFilter.messages + else + ActiveFilter.allChats, ActiveFilter.groups, + ActiveFilter.unread, if (spaceDelegateCandidates.isNotEmpty && !controller.widget.displayNavigationRail) ActiveFilter.spaces, diff --git a/lib/pages/chat_list/chat_list_view.dart b/lib/pages/chat_list/chat_list_view.dart index 683b372de..0cf684fc2 100644 --- a/lib/pages/chat_list/chat_list_view.dart +++ b/lib/pages/chat_list/chat_list_view.dart @@ -147,9 +147,14 @@ class ChatListView extends StatelessWidget { // child: // Pangea# selectMode == SelectMode.normal && - !controller.isSearchMode + !controller.isSearchMode && + controller.activeSpaceId == null ? FloatingActionButton.extended( - onPressed: controller.addChatAction, + // #Pangea + // onPressed: () => + // context.go('/rooms/newprivatechat'), + onPressed: () => context.go('/rooms/newgroup'), + // Pangea# icon: const Icon(Icons.add_outlined), label: Text( L10n.of(context)!.chat, diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index 987ee5dbb..53777162d 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -11,8 +11,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:go_router/go_router.dart'; +import 'package:matrix/matrix.dart' as sdk; import 'package:matrix/matrix.dart'; +enum AddRoomType { chat, subspace } + class SpaceView extends StatefulWidget { final String spaceId; final void Function() onBack; @@ -158,6 +161,95 @@ class _SpaceViewState extends State { } } + void _addChatOrSubspace() async { + final roomType = await showConfirmationDialog( + context: context, + title: L10n.of(context)!.addChatOrSubSpace, + actions: [ + AlertDialogAction( + key: AddRoomType.subspace, + label: L10n.of(context)!.createNewSpace, + ), + AlertDialogAction( + key: AddRoomType.chat, + label: L10n.of(context)!.createGroup, + ), + ], + ); + if (roomType == null) return; + + final names = await showTextInputDialog( + context: context, + title: roomType == AddRoomType.subspace + ? L10n.of(context)!.createNewSpace + : L10n.of(context)!.createGroup, + textFields: [ + DialogTextField( + hintText: roomType == AddRoomType.subspace + ? L10n.of(context)!.spaceName + : L10n.of(context)!.groupName, + minLines: 1, + maxLines: 1, + maxLength: 64, + validator: (text) { + if (text == null || text.isEmpty) { + return L10n.of(context)!.pleaseChoose; + } + return null; + }, + ), + DialogTextField( + hintText: L10n.of(context)!.chatDescription, + minLines: 4, + maxLines: 8, + maxLength: 255, + ), + ], + okLabel: L10n.of(context)!.create, + cancelLabel: L10n.of(context)!.cancel, + ); + if (names == null) return; + final client = Matrix.of(context).client; + final result = await showFutureLoadingDialog( + context: context, + future: () async { + late final String roomId; + final activeSpace = client.getRoomById(widget.spaceId)!; + await activeSpace.postLoad(); + + if (roomType == AddRoomType.subspace) { + roomId = await client.createSpace( + name: names.first, + topic: names.last.isEmpty ? null : names.last, + visibility: activeSpace.joinRules == JoinRules.public + ? sdk.Visibility.public + : sdk.Visibility.private, + ); + } else { + roomId = await client.createGroupChat( + groupName: names.first, + preset: activeSpace.joinRules == JoinRules.public + ? CreateRoomPreset.publicChat + : CreateRoomPreset.privateChat, + visibility: activeSpace.joinRules == JoinRules.public + ? sdk.Visibility.public + : sdk.Visibility.private, + initialState: names.length > 1 && names.last.isNotEmpty + ? [ + StateEvent( + type: EventTypes.RoomTopic, + content: {'topic': names.last}, + ), + ] + : null, + ); + } + await activeSpace.setSpaceChild(roomId); + }, + ); + if (result.error != null) return; + } + @override Widget build(BuildContext context) { final room = Matrix.of(context).client.getRoomById(widget.spaceId); @@ -350,22 +442,55 @@ class _SpaceViewState extends State { itemCount: joinedRooms.length + 1, itemBuilder: (context, i) { if (i == 0) { - return SearchTitle( - title: L10n.of(context)!.joinedChats, - icon: const Icon(Icons.chat_outlined), + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (room.canChangeStateEvent( + EventTypes.SpaceChild, + ) && + filter.isEmpty) ...[ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 1, + ), + child: Material( + borderRadius: BorderRadius.circular( + AppConfig.borderRadius, + ), + clipBehavior: Clip.hardEdge, + child: ListTile( + onTap: _addChatOrSubspace, + leading: const CircleAvatar( + radius: Avatar.defaultSize / 2, + child: Icon(Icons.add_outlined), + ), + title: Text( + L10n.of(context)!.addChatOrSubSpace, + style: const TextStyle(fontSize: 14), + ), + ), + ), + ), + ], + SearchTitle( + title: L10n.of(context)!.joinedChats, + icon: const Icon(Icons.chat_outlined), + ), + ], ); } i--; - final room = joinedRooms[i]; + final joinedRoom = joinedRooms[i]; return ChatListItem( - room, + joinedRoom, filter: filter, - onTap: () => widget.onChatTab(room), + onTap: () => widget.onChatTab(joinedRoom), onLongPress: (context) => widget.onChatContext( - room, + joinedRoom, context, ), - activeChat: widget.activeChat == room.id, + activeChat: widget.activeChat == joinedRoom.id, ); }, ), diff --git a/lib/pages/new_group/new_group.dart b/lib/pages/new_group/new_group.dart index aa4a2504b..aa3c54708 100644 --- a/lib/pages/new_group/new_group.dart +++ b/lib/pages/new_group/new_group.dart @@ -35,8 +35,6 @@ class NewGroup extends StatefulWidget { class NewGroupController extends State { TextEditingController nameController = TextEditingController(); - TextEditingController topicController = TextEditingController(); - bool publicGroup = false; bool groupCanBeFound = true; @@ -132,6 +130,7 @@ class NewGroupController extends State { } } } + // Pangea# final roomId = await client.createGroupChat( // #Pangea @@ -140,24 +139,6 @@ class NewGroupController extends State { // preset: publicGroup // ? sdk.CreateRoomPreset.publicChat // : sdk.CreateRoomPreset.privateChat, - // groupName: nameController.text.isNotEmpty ? nameController.text : null, - // initialState: [ - // if (topicController.text.isNotEmpty) - // sdk.StateEvent( - // type: sdk.EventTypes.RoomTopic, - // content: {'topic': topicController.text}, - // ), - // if (avatar != null) - // sdk.StateEvent( - // type: sdk.EventTypes.RoomAvatar, - // content: {'url': avatarUrl.toString()}, - // ), - // ], - initialState: [ - if (addConversationBotKey.currentState?.addBot ?? false) - addConversationBotKey.currentState!.botOptions.toStateEvent, - ], - groupName: nameController.text, preset: sdk.CreateRoomPreset.publicChat, powerLevelContentOverride: await ClassChatPowerLevels.powerLevelOverrideForClassChat( @@ -169,6 +150,18 @@ class NewGroupController extends State { BotName.byEnvironment, ], // Pangea# + groupName: nameController.text.isNotEmpty ? nameController.text : null, + initialState: [ + if (avatar != null) + sdk.StateEvent( + type: sdk.EventTypes.RoomAvatar, + content: {'url': avatarUrl.toString()}, + ), + // #Pangea + if (addConversationBotKey.currentState?.addBot ?? false) + addConversationBotKey.currentState!.botOptions.toStateEvent, + // Pangea# + ], ); if (!mounted) return; if (publicGroup && groupCanBeFound) { diff --git a/lib/pages/new_group/new_group_view.dart b/lib/pages/new_group/new_group_view.dart index 84bfbfbc5..0acf89605 100644 --- a/lib/pages/new_group/new_group_view.dart +++ b/lib/pages/new_group/new_group_view.dart @@ -41,61 +41,43 @@ class NewGroupView extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ const SizedBox(height: 16), + InkWell( + borderRadius: BorderRadius.circular(90), + onTap: controller.loading ? null : controller.selectPhoto, + child: CircleAvatar( + radius: Avatar.defaultSize, + child: avatar == null + ? const Icon(Icons.add_a_photo_outlined) + : ClipRRect( + borderRadius: BorderRadius.circular(90), + child: Image.memory( + avatar, + width: Avatar.defaultSize, + height: Avatar.defaultSize, + fit: BoxFit.cover, + ), + ), + ), + ), + const SizedBox(height: 32), Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Row( - children: [ - InkWell( - borderRadius: BorderRadius.circular(90), - onTap: controller.loading ? null : controller.selectPhoto, - child: CircleAvatar( - radius: Avatar.defaultSize / 2, - child: avatar == null - ? const Icon(Icons.camera_alt_outlined) - : ClipRRect( - borderRadius: BorderRadius.circular(90), - child: Image.memory( - avatar, - width: Avatar.defaultSize, - height: Avatar.defaultSize, - fit: BoxFit.cover, - ), - ), - ), - ), - const SizedBox(width: 16), - Expanded( - child: TextField( - // #Pangea - maxLength: 64, - // Pangea# - controller: controller.nameController, - autocorrect: false, - readOnly: controller.loading, - decoration: InputDecoration( - prefixIcon: const Icon(Icons.people_outlined), - hintText: L10n.of(context)!.groupName, - ), - ), - ), - ], + child: TextField( + // #Pangea + maxLength: 64, + // Pangea# + autofocus: true, + controller: controller.nameController, + autocorrect: false, + readOnly: controller.loading, + decoration: InputDecoration( + prefixIcon: const Icon(Icons.people_outlined), + hintText: L10n.of(context)!.groupName, + ), ), ), const SizedBox(height: 16), // #Pangea - // Padding( - // padding: const EdgeInsets.symmetric(horizontal: 16.0), - // child: TextField( - // controller: controller.topicController, - // minLines: 4, - // maxLines: 4, - // maxLength: 255, - // readOnly: controller.loading, - // decoration: InputDecoration( - // hintText: L10n.of(context)!.addChatDescription, - // ), - // ), - // ), RoomCapacityButton( key: controller.addCapacityKey, ), @@ -109,7 +91,6 @@ class NewGroupView extends StatelessWidget { startOpen: true, activeSpaceId: controller.activeSpaceId, ), - // const SizedBox(height: 16), // SwitchListTile.adaptive( // secondary: const Icon(Icons.public_outlined), // title: Text(L10n.of(context)!.groupIsPublic), @@ -154,18 +135,18 @@ class NewGroupView extends StatelessWidget { // ), // onPressed: // controller.loading ? null : controller.submitAction, - // child: controller.loading - // ? const LinearProgressIndicator() - // : Row( - // children: [ - // Expanded( - // child: Text( - // L10n.of(context)!.createGroupAndInviteUsers, + // child: controller.loading + // ? const LinearProgressIndicator() + // : Row( + // children: [ + // Expanded( + // child: Text( + // L10n.of(context)!.createGroupAndInviteUsers, + // ), + // ), + // Icon(Icons.adaptive.arrow_forward_outlined), + // ], // ), - // ), - // Icon(Icons.adaptive.arrow_forward_outlined), - // ], - // ), // ), // ), // ), diff --git a/lib/pages/new_space/new_space_view.dart b/lib/pages/new_space/new_space_view.dart index 9ef9c9849..034d049f7 100644 --- a/lib/pages/new_space/new_space_view.dart +++ b/lib/pages/new_space/new_space_view.dart @@ -1,4 +1,3 @@ -import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/pangea/pages/class_settings/p_class_widgets/room_capacity_button.dart'; import 'package:fluffychat/pangea/widgets/class/add_space_toggles.dart'; import 'package:fluffychat/widgets/avatar.dart'; @@ -15,17 +14,9 @@ class NewSpaceView extends StatelessWidget { @override Widget build(BuildContext context) { - // #Pangea - final activeColor = Theme.of(context).brightness == Brightness.dark - ? AppConfig.primaryColorLight - : AppConfig.primaryColor; - // Pangea# final avatar = controller.avatar; return Scaffold( appBar: AppBar( - // #Pangea - centerTitle: true, - // Pangea# title: Text(L10n.of(context)!.createNewSpace), ), // #Pangea @@ -41,7 +32,57 @@ class NewSpaceView extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ + const SizedBox(height: 16), + InkWell( + borderRadius: BorderRadius.circular(90), + onTap: controller.loading ? null : controller.selectPhoto, + child: CircleAvatar( + radius: Avatar.defaultSize, + child: avatar == null + ? const Icon(Icons.add_a_photo_outlined) + : ClipRRect( + borderRadius: BorderRadius.circular(90), + child: Image.memory( + avatar, + width: Avatar.defaultSize, + height: Avatar.defaultSize, + fit: BoxFit.cover, + ), + ), + ), + ), + const SizedBox(height: 32), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: TextField( + autofocus: true, + controller: controller.nameController, + autocorrect: false, + readOnly: controller.loading, + decoration: InputDecoration( + prefixIcon: const Icon(Icons.people_outlined), + hintText: L10n.of(context)!.spaceName, + // #Pangea + // errorText: controller.nameError, + // Pangea# + ), + ), + ), + const SizedBox(height: 16), // #Pangea + RoomCapacityButton( + key: controller.addCapacityKey, + ), + AddToSpaceToggles( + key: controller.addToSpaceKey, + startOpen: true, + spaceMode: true, + ), + // SwitchListTile.adaptive( + // title: Text(L10n.of(context)!.spaceIsPublic), + // value: controller.publicGroup, + // onChanged: controller.setPublicGroup, + // ), // ListTile( // trailing: const Padding( // padding: EdgeInsets.symmetric(horizontal: 16.0), @@ -49,124 +90,6 @@ class NewSpaceView extends StatelessWidget { // ), // subtitle: Text(L10n.of(context)!.newSpaceDescription), // ), - // const SizedBox(height: 16), - // Pangea# - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - InkWell( - borderRadius: BorderRadius.circular(90), - onTap: controller.loading ? null : controller.selectPhoto, - child: CircleAvatar( - radius: Avatar.defaultSize / 2, - child: avatar == null - ? const Icon(Icons.camera_alt_outlined) - : ClipRRect( - borderRadius: BorderRadius.circular(90), - child: Image.memory( - avatar, - width: Avatar.defaultSize, - height: Avatar.defaultSize, - fit: BoxFit.cover, - ), - ), - ), - ), - const SizedBox(width: 16), - Expanded( - child: TextField( - // #Pangea - maxLength: 64, - // Pangea# - controller: controller.nameController, - autocorrect: false, - readOnly: controller.loading, - decoration: InputDecoration( - prefixIcon: const Icon(Icons.people_outlined), - hintText: L10n.of(context)!.spaceName, - // #Pangea - // errorText: controller.nameError, - // Pangea# - ), - ), - ), - ], - ), - ), - const SizedBox(height: 16), - // #Pangea - // Padding( - // padding: const EdgeInsets.symmetric(horizontal: 16.0), - // child: TextField( - // controller: controller.topicController, - // minLines: 4, - // maxLines: 4, - // maxLength: 255, - // readOnly: controller.loading, - // decoration: InputDecoration( - // hintText: L10n.of(context)!.addChatDescription, - // errorText: controller.topicError, - // ), - // ), - // ), - // const SizedBox(height: 16), - - RoomCapacityButton( - key: controller.addCapacityKey, - ), - // commenting out language settings in spaces for now - // LanguageSettings( - // key: controller.languageSettingsKey, - // roomId: null, - // startOpen: true, - // initialSettings: - // Matrix.of(context).client.lastUpdatedLanguageSettings, - // ), - AddToSpaceToggles( - key: controller.addToSpaceKey, - startOpen: true, - spaceMode: true, - ), - // Commenting out pangea room rules for now - // if (controller.rulesEditorKey.currentState != null) - // RoomRulesEditor( - // key: controller.rulesEditorKey, - // roomId: null, - // startOpen: false, - // initialRules: controller.rulesEditorKey.currentState!.rules, - // ), - - // Commenting out pangea room rules for now - // if (controller.rulesEditorKey.currentState == null) - // FutureBuilder( - // future: Matrix.of(context).client.lastUpdatedRoomRules, - // builder: (context, snapshot) { - // if (snapshot.connectionState == ConnectionState.done) { - // return RoomRulesEditor( - // key: controller.rulesEditorKey, - // roomId: null, - // startOpen: false, - // initialRules: snapshot.data, - // ); - // } else { - // return const Padding( - // padding: EdgeInsets.all(16.0), - // child: Center( - // child: - // CircularProgressIndicator.adaptive(strokeWidth: 2), - // ), - // ); - // } - // }, - // ), - - // SwitchListTile.adaptive( - // title: Text(L10n.of(context)!.spaceIsPublic), - // value: controller.publicGroup, - // onChanged: controller.setPublicGroup, - // ), // Padding( // padding: const EdgeInsets.all(16.0), // child: SizedBox( diff --git a/lib/pages/settings_style/settings_style_view.dart b/lib/pages/settings_style/settings_style_view.dart index 0b505d597..86f48fe87 100644 --- a/lib/pages/settings_style/settings_style_view.dart +++ b/lib/pages/settings_style/settings_style_view.dart @@ -185,6 +185,12 @@ class SettingsStyleView extends StatelessWidget { storeKey: SettingKeys.showPresences, defaultValue: AppConfig.showPresences, ), + SettingsSwitchListTile.adaptive( + title: L10n.of(context)!.separateChatTypes, + onChanged: (b) => AppConfig.separateChatTypes = b, + storeKey: SettingKeys.separateChatTypes, + defaultValue: AppConfig.separateChatTypes, + ), Divider( height: 1, color: Theme.of(context).dividerColor, diff --git a/lib/widgets/avatar.dart b/lib/widgets/avatar.dart index 64453070e..39af2e756 100644 --- a/lib/widgets/avatar.dart +++ b/lib/widgets/avatar.dart @@ -45,14 +45,16 @@ class Avatar extends StatelessWidget { final noPic = mxContent == null || mxContent.toString().isEmpty || mxContent.toString() == 'null'; + final textColor = name?.lightColorAvatar; final textWidget = Container( - color: name?.lightColorAvatar, + color: textColor, alignment: Alignment.center, child: Text( fallbackLetters, style: TextStyle( color: Colors.white, - fontSize: (size / 2.5).roundToDouble(), + fontWeight: FontWeight.bold, + fontSize: (size / 3).roundToDouble(), ), ), ); @@ -64,7 +66,9 @@ class Avatar extends StatelessWidget { width: size, height: size, child: Material( - color: Theme.of(context).colorScheme.surfaceContainerLowest, + color: Theme.of(context).brightness == Brightness.light + ? Colors.white + : Colors.black, shape: RoundedRectangleBorder( borderRadius: borderRadius, side: border ?? BorderSide.none, @@ -79,7 +83,13 @@ class Avatar extends StatelessWidget { fit: BoxFit.cover, width: size, height: size, - placeholder: (_) => textWidget, + placeholder: (_) => Center( + child: Icon( + Icons.person_2, + color: Theme.of(context).colorScheme.tertiary, + size: size / 1.5, + ), + ), ), ), ), diff --git a/lib/widgets/matrix.dart b/lib/widgets/matrix.dart index 7b9ab0ec2..0f85950ff 100644 --- a/lib/widgets/matrix.dart +++ b/lib/widgets/matrix.dart @@ -485,6 +485,10 @@ class MatrixState extends State with WidgetsBindingObserver { store.getBool(SettingKeys.hideUnimportantStateEvents) ?? AppConfig.hideUnimportantStateEvents; + AppConfig.separateChatTypes = + store.getBool(SettingKeys.separateChatTypes) ?? + AppConfig.separateChatTypes; + AppConfig.autoplayImages = store.getBool(SettingKeys.autoplayImages) ?? AppConfig.autoplayImages;