diff --git a/lib/pages/chat_list/chat_list_header.dart b/lib/pages/chat_list/chat_list_header.dart index 4c018355c..1f7a1fbe9 100644 --- a/lib/pages/chat_list/chat_list_header.dart +++ b/lib/pages/chat_list/chat_list_header.dart @@ -23,7 +23,10 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget { return SliverAppBar( floating: true, - toolbarHeight: 175, + // #Pangea + // toolbarHeight: 72, + toolbarHeight: controller.isSearchMode ? 72 : 175, + // Pangea# pinned: FluffyThemes.isColumnMode(context) || selectMode != SelectMode.normal, scrolledUnderElevation: selectMode == SelectMode.normal ? 0 : null, @@ -32,111 +35,124 @@ class ChatListHeader extends StatelessWidget implements PreferredSizeWidget { // selectMode == SelectMode.normal ? Colors.transparent : null, // Pangea# automaticallyImplyLeading: false, - leading: selectMode == SelectMode.normal - ? null - : IconButton( - tooltip: L10n.of(context)!.cancel, - icon: const Icon(Icons.close_outlined), - onPressed: controller.cancelAction, - color: theme.colorScheme.primary, - ), - title: selectMode == SelectMode.share - ? Text( - L10n.of(context)!.share, - key: const ValueKey(SelectMode.share), - ) - // #Pangea - : Column( - children: [ - ClientChooserButton(controller), - const LearningProgressIndicators(), - ], - ), - // : TextField( - // controller: controller.searchController, - // focusNode: controller.searchFocusNode, - // textInputAction: TextInputAction.search, - // onChanged: (text) => controller.onSearchEnter( - // text, - // globalSearch: globalSearch, - // ), - // decoration: InputDecoration( - // filled: true, - // fillColor: theme.colorScheme.secondaryContainer, - // border: OutlineInputBorder( - // borderSide: BorderSide.none, - // borderRadius: BorderRadius.circular(99), + // #Pangea + // leading: selectMode == SelectMode.normal + // ? null + // : IconButton( + // tooltip: L10n.of(context)!.cancel, + // icon: const Icon(Icons.close_outlined), + // onPressed: controller.cancelAction, + // color: theme.colorScheme.primary, // ), - // contentPadding: EdgeInsets.zero, - // hintText: L10n.of(context)!.searchChatsRooms, - // hintStyle: TextStyle( - // color: theme.colorScheme.onPrimaryContainer, - // fontWeight: FontWeight.normal, - // ), - // floatingLabelBehavior: FloatingLabelBehavior.never, - // prefixIcon: controller.isSearchMode - // ? IconButton( - // tooltip: L10n.of(context)!.cancel, - // icon: const Icon(Icons.close_outlined), - // onPressed: controller.cancelSearch, - // color: theme.colorScheme.onPrimaryContainer, - // ) - // : IconButton( - // onPressed: controller.startSearch, - // icon: Icon( - // Icons.search_outlined, - // color: theme.colorScheme.onPrimaryContainer, - // ), - // ), - // suffixIcon: controller.isSearchMode && globalSearch - // ? controller.isSearching - // ? const Padding( - // padding: EdgeInsets.symmetric( - // vertical: 10.0, - // horizontal: 12, - // ), - // child: SizedBox.square( - // dimension: 24, - // child: CircularProgressIndicator.adaptive( - // strokeWidth: 2, - // ), - // ), - // ) - // : TextButton.icon( - // onPressed: controller.setServer, - // style: TextButton.styleFrom( - // shape: RoundedRectangleBorder( - // borderRadius: BorderRadius.circular(99), - // ), - // textStyle: const TextStyle(fontSize: 12), - // ), - // icon: const Icon(Icons.edit_outlined, size: 16), - // label: Text( - // controller.searchServer ?? - // Matrix.of(context).client.homeserver!.host, - // maxLines: 2, - // ), - // ) - // : SizedBox( - // width: 0, - // child: ClientChooserButton(controller), - // ), - // ), - // ), // Pangea# - actions: selectMode == SelectMode.share - ? [ - // #Pangea - // Padding( - // padding: const EdgeInsets.symmetric( - // horizontal: 16.0, - // vertical: 8.0, - // ), - // child: ClientChooserButton(controller), - // ), - // Pangea# - ] - : null, + title: + // #Pangea + // selectMode == SelectMode.share + // ? Text( + // L10n.of(context)!.share, + // key: const ValueKey(SelectMode.share), + // ) + // : + // Pangea# + Column( + children: [ + TextField( + controller: controller.searchController, + focusNode: controller.searchFocusNode, + textInputAction: TextInputAction.search, + onChanged: (text) => controller.onSearchEnter( + text, + globalSearch: globalSearch, + ), + decoration: InputDecoration( + filled: true, + fillColor: theme.colorScheme.secondaryContainer, + border: OutlineInputBorder( + borderSide: BorderSide.none, + borderRadius: BorderRadius.circular(99), + ), + contentPadding: EdgeInsets.zero, + hintText: L10n.of(context)!.searchChatsRooms, + hintStyle: TextStyle( + color: theme.colorScheme.onPrimaryContainer, + fontWeight: FontWeight.normal, + ), + floatingLabelBehavior: FloatingLabelBehavior.never, + prefixIcon: controller.isSearchMode + ? IconButton( + tooltip: L10n.of(context)!.cancel, + icon: const Icon(Icons.close_outlined), + onPressed: controller.cancelSearch, + color: theme.colorScheme.onPrimaryContainer, + ) + : IconButton( + onPressed: controller.startSearch, + icon: Icon( + Icons.search_outlined, + color: theme.colorScheme.onPrimaryContainer, + ), + ), + suffixIcon: controller.isSearchMode && globalSearch + ? controller.isSearching + ? const Padding( + padding: EdgeInsets.symmetric( + vertical: 10.0, + horizontal: 12, + ), + child: SizedBox.square( + dimension: 24, + child: CircularProgressIndicator.adaptive( + strokeWidth: 2, + ), + ), + ) + // #Pangea + : SizedBox( + width: 0, + child: ClientChooserButton(controller), + ) + // : TextButton.icon( + // onPressed: controller.setServer, + // style: TextButton.styleFrom( + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(99), + // ), + // textStyle: const TextStyle(fontSize: 12), + // ), + // icon: const Icon(Icons.edit_outlined, size: 16), + // label: Text( + // controller.searchServer ?? + // Matrix.of(context).client.homeserver!.host, + // maxLines: 2, + // ), + // ) + // Pangea# + : SizedBox( + width: 0, + child: ClientChooserButton(controller), + ), + ), + ), + if (!controller.isSearchMode) + const Padding( + padding: EdgeInsets.only(top: 16.0), + child: LearningProgressIndicators(), + ), + ], + ), + // #Pangea + // actions: selectMode == SelectMode.share + // ? [ + // Padding( + // padding: const EdgeInsets.symmetric( + // horizontal: 16.0, + // vertical: 8.0, + // ), + // child: ClientChooserButton(controller), + // ), + // ] + // : null, + // Pangea# ); } diff --git a/lib/pages/chat_list/client_chooser_button.dart b/lib/pages/chat_list/client_chooser_button.dart index 0a406fa2c..578542806 100644 --- a/lib/pages/chat_list/client_chooser_button.dart +++ b/lib/pages/chat_list/client_chooser_button.dart @@ -1,15 +1,15 @@ import 'package:adaptive_dialog/adaptive_dialog.dart'; -import 'package:fluffychat/pangea/utils/find_conversation_partner_dialog.dart'; import 'package:fluffychat/pangea/utils/logout.dart'; import 'package:fluffychat/pangea/utils/space_code.dart'; +import 'package:fluffychat/widgets/avatar.dart'; import 'package:fluffychat/widgets/matrix.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:go_router/go_router.dart'; +import 'package:keyboard_shortcuts/keyboard_shortcuts.dart'; import 'package:matrix/matrix.dart'; -import '../../utils/fluffy_share.dart'; import 'chat_list.dart'; class ClientChooserButton extends StatelessWidget { @@ -41,45 +41,30 @@ class ClientChooserButton extends StatelessWidget { ], ), ), - // PopupMenuItem( - // enabled: matrix.client.rooms.any( - // (room) => - // room.isSpace && - // room.ownPowerLevel >= ClassDefaultValues.powerLevelOfAdmin, - // ), - // value: SettingsAction.spaceAnalytics, - // child: Row( - // children: [ - // const Icon(Icons.analytics_outlined), - // const SizedBox(width: 18), - // Expanded(child: Text(L10n.of(context)!.spaceAnalytics)), - // ], - // ), - // ), - // PopupMenuItem( - // enabled: matrix.client.rooms.any( - // (room) => !room.isSpace && !room.isArchived && !room.isAnalyticsRoom, - // ), - // value: SettingsAction.myAnalytics, - // child: Row( - // children: [ - // const Icon(Icons.analytics_outlined), - // const SizedBox(width: 18), - // Expanded(child: Text(L10n.of(context)!.myLearning)), - // ], - // ), - // ), - // PopupMenuItem( - // value: SettingsAction.newGroup, - // child: Row( - // children: [ - // const Icon(Icons.group_add_outlined), - // const SizedBox(width: 18), - // Text(L10n.of(context)!.createGroup), - // ], - // ), - // ), + PopupMenuItem( + value: SettingsAction.learning, + child: Row( + children: [ + const Icon(Icons.psychology_outlined), + const SizedBox(width: 18), + Expanded(child: Text(L10n.of(context)!.learningSettings)), + ], + ), + ), // Pangea# + PopupMenuItem( + value: SettingsAction.newGroup, + child: Row( + children: [ + const Icon(Icons.group_add_outlined), + const SizedBox(width: 18), + // #Pangea + Expanded(child: Text(L10n.of(context)!.createGroup)), + // Text(L10n.of(context)!.createGroup), + // Pangea# + ], + ), + ), PopupMenuItem( value: SettingsAction.newSpace, child: Row( @@ -87,7 +72,7 @@ class ClientChooserButton extends StatelessWidget { const Icon(Icons.workspaces_outlined), const SizedBox(width: 18), // #Pangea - Expanded(child: Text(L10n.of(context)!.createNewSpace)), + Text(L10n.of(context)!.createNewSpace), // Text(L10n.of(context)!.createNewSpace), // Pangea# ], @@ -123,22 +108,10 @@ class ClientChooserButton extends StatelessWidget { children: [ const Icon(Icons.archive_outlined), const SizedBox(width: 18), - Text(L10n.of(context)!.archive), + Text(L10n.of(context)!!.archive), ], ), ),*/ - // #Pangea - PopupMenuItem( - value: SettingsAction.learning, - child: Row( - children: [ - const Icon(Icons.psychology_outlined), - const SizedBox(width: 18), - Expanded(child: Text(L10n.of(context)!.learningSettings)), - ], - ), - ), - // Pangea# PopupMenuItem( value: SettingsAction.settings, child: Row( @@ -146,13 +119,23 @@ class ClientChooserButton extends StatelessWidget { const Icon(Icons.settings_outlined), const SizedBox(width: 18), // #Pangea + Text(L10n.of(context)!.settings), // Text(L10n.of(context)!.settings), - Expanded(child: Text(L10n.of(context)!.settings)), // Pangea# ], ), ), // #Pangea + PopupMenuItem( + value: SettingsAction.logout, + child: Row( + children: [ + const Icon(Icons.logout_outlined), + const SizedBox(width: 18), + Expanded(child: Text(L10n.of(context)!.logout)), + ], + ), + ), // const PopupMenuDivider(), // for (final bundle in bundles) ...[ // if (matrix.accountBundles[bundle]!.length != 1 || @@ -223,16 +206,6 @@ class ClientChooserButton extends StatelessWidget { // ], // ), // ), - PopupMenuItem( - value: SettingsAction.logout, - child: Row( - children: [ - const Icon(Icons.logout_outlined), - const SizedBox(width: 18), - Expanded(child: Text(L10n.of(context)!.logout)), - ], - ), - ), // Pangea# ]; } @@ -248,65 +221,49 @@ class ClientChooserButton extends StatelessWidget { builder: (context, snapshot) => Stack( alignment: Alignment.center, children: [ - // #Pangea - // ...List.generate( - // clientCount, - // (index) => KeyBoardShortcuts( - // keysToPress: _buildKeyboardShortcut(index + 1), - // helpLabel: L10n.of(context)!.switchToAccount(index + 1), - // onKeysPressed: () => _handleKeyboardShortcut( - // matrix, - // index, - // context, - // ), - // child: const SizedBox.shrink(), - // ), - // ), - // KeyBoardShortcuts( - // keysToPress: { - // LogicalKeyboardKey.controlLeft, - // LogicalKeyboardKey.tab, - // }, - // helpLabel: L10n.of(context)!.nextAccount, - // onKeysPressed: () => _nextAccount(matrix, context), - // child: const SizedBox.shrink(), - // ), - // KeyBoardShortcuts( - // keysToPress: { - // LogicalKeyboardKey.controlLeft, - // LogicalKeyboardKey.shiftLeft, - // LogicalKeyboardKey.tab, - // }, - // helpLabel: L10n.of(context)!.previousAccount, - // onKeysPressed: () => _previousAccount(matrix, context), - // child: const SizedBox.shrink(), - // ), - ClipRRect( - borderRadius: BorderRadius.circular(16), + ...List.generate( + clientCount, + (index) => KeyBoardShortcuts( + keysToPress: _buildKeyboardShortcut(index + 1), + helpLabel: L10n.of(context)!.switchToAccount(index + 1), + onKeysPressed: () => _handleKeyboardShortcut( + matrix, + index, + context, + ), + child: const SizedBox.shrink(), + ), + ), + KeyBoardShortcuts( + keysToPress: { + LogicalKeyboardKey.controlLeft, + LogicalKeyboardKey.tab, + }, + helpLabel: L10n.of(context)!.nextAccount, + onKeysPressed: () => _nextAccount(matrix, context), + child: const SizedBox.shrink(), + ), + KeyBoardShortcuts( + keysToPress: { + LogicalKeyboardKey.controlLeft, + LogicalKeyboardKey.shiftLeft, + LogicalKeyboardKey.tab, + }, + helpLabel: L10n.of(context)!.previousAccount, + onKeysPressed: () => _previousAccount(matrix, context), + child: const SizedBox.shrink(), + ), + PopupMenuButton( + onSelected: (o) => _clientSelected(o, context), + itemBuilder: _bundleMenuItems, child: Material( color: Colors.transparent, - child: - // Pangea# - PopupMenuButton( - onSelected: (o) => _clientSelected(o, context), - itemBuilder: _bundleMenuItems, - // #Pangea - child: ListTile( - mouseCursor: SystemMouseCursors.click, - leading: const Icon(Icons.settings_outlined), - title: Text(L10n.of(context)!.mainMenu), - ), - // child: Material( - // color: Colors.transparent, - // borderRadius: BorderRadius.circular(99), - // child: Avatar( - // mxContent: snapshot.data?.avatarUrl, - // name: snapshot.data?.displayName ?? - // matrix.client.userID!.localpart, - // size: 32, - // ), - // ), - // Pangea# + borderRadius: BorderRadius.circular(99), + child: Avatar( + mxContent: snapshot.data?.avatarUrl, + name: snapshot.data?.displayName ?? + matrix.client.userID!.localpart, + size: 32, ), ), ), @@ -353,42 +310,30 @@ class ClientChooserButton extends StatelessWidget { case SettingsAction.newSpace: controller.createNewSpace(); break; - case SettingsAction.invite: - FluffyShare.shareInviteLink(context); - break; + // #Pangea + // case SettingsAction.invite: + // FluffyShare.shareInviteLink(context); + // break; + // Pangea# case SettingsAction.settings: context.go('/rooms/settings'); break; - case SettingsAction.archive: - context.go('/rooms/archive'); - break; - case SettingsAction.setStatus: - controller.setStatus(); // #Pangea + // case SettingsAction.archive: + // context.go('/rooms/archive'); + // break; + // case SettingsAction.setStatus: + // controller.setStatus(); + // break; case SettingsAction.learning: context.go('/rooms/settings/learning'); break; - case SettingsAction.newClass: - context.go('/rooms/newspace'); - break; case SettingsAction.joinWithClassCode: SpaceCodeUtil.joinWithSpaceCodeDialog( context, MatrixState.pangeaController, ); break; - case SettingsAction.findAConversationPartner: - findConversationPartnerDialog( - context, - MatrixState.pangeaController, - ); - break; - // case SettingsAction.spaceAnalytics: - // context.go('/rooms/analytics'); - // break; - // case SettingsAction.myAnalytics: - // context.go('/rooms/mylearning'); - // break; case SettingsAction.logout: pLogoutAction(context); break; @@ -471,17 +416,15 @@ enum SettingsAction { addAccount, newGroup, newSpace, - setStatus, - invite, - settings, - archive, // #Pangea - learning, + // setStatus, + // invite, + // Pangea# + settings, + // #Pangea + // archive, joinWithClassCode, - // spaceAnalytics, - // myAnalytics, - findAConversationPartner, + learning, logout, - newClass, // Pangea# }