From 4c3002c20b92ca50d29e9be6899d157e8edf7603 Mon Sep 17 00:00:00 2001 From: Clement Date: Sat, 5 Oct 2024 23:08:39 -0300 Subject: [PATCH 01/10] can open the item menu on the right click for requests --- lib/widgets/card_sidebar_request.dart | 149 +++++++++++++------------- lib/widgets/menu_item_card.dart | 26 +++++ 2 files changed, 103 insertions(+), 72 deletions(-) diff --git a/lib/widgets/card_sidebar_request.dart b/lib/widgets/card_sidebar_request.dart index ab8a4706..f8063be9 100644 --- a/lib/widgets/card_sidebar_request.dart +++ b/lib/widgets/card_sidebar_request.dart @@ -49,81 +49,86 @@ class SidebarRequestCard extends StatelessWidget { String nm = (name != null && name!.trim().isNotEmpty) ? name! : getRequestTitleFromUrl(url); - return Tooltip( - message: nm, - triggerMode: TooltipTriggerMode.manual, - waitDuration: const Duration(seconds: 1), - child: Card( - shape: const RoundedRectangleBorder( - borderRadius: kBorderRadius8, - ), - elevation: isSelected ? 1 : 0, - surfaceTintColor: isSelected ? surfaceTint : null, - color: isSelected - ? Theme.of(context).colorScheme.brightness == Brightness.dark - ? colorVariant - : color - : color, - margin: EdgeInsets.zero, - child: InkWell( - borderRadius: kBorderRadius8, - hoverColor: colorVariant, - focusColor: colorVariant.withOpacity(0.5), - onTap: inEditMode ? null : onTap, - // onDoubleTap: inEditMode ? null : onDoubleTap, - onSecondaryTap: onSecondaryTap, - child: Padding( - padding: EdgeInsets.only( - left: 6, - right: isSelected ? 6 : 10, - top: 5, - bottom: 5, - ), - child: SizedBox( - height: 20, - child: Row( - children: [ - MethodBox(method: method), - kHSpacer4, - Expanded( - child: inEditMode - ? TextFormField( - key: ValueKey("$id-name"), - initialValue: name, - // controller: controller, - focusNode: focusNode, - //autofocus: true, - style: Theme.of(context).textTheme.bodyMedium, - onTapOutside: (_) { - onTapOutsideNameEditor?.call(); - //FocusScope.of(context).unfocus(); - }, - onFieldSubmitted: (value) { - onTapOutsideNameEditor?.call(); - }, - onChanged: onChangedNameEditor, - decoration: const InputDecoration( - isCollapsed: true, - contentPadding: EdgeInsets.zero, - border: InputBorder.none, + return GestureDetector( + onSecondaryTapUp: (details) { + showItemCardMenu(context, details, onMenuSelected); + }, + child: Tooltip( + message: nm, + triggerMode: TooltipTriggerMode.manual, + waitDuration: const Duration(seconds: 1), + child: Card( + shape: const RoundedRectangleBorder( + borderRadius: kBorderRadius8, + ), + elevation: isSelected ? 1 : 0, + surfaceTintColor: isSelected ? surfaceTint : null, + color: isSelected + ? Theme.of(context).colorScheme.brightness == Brightness.dark + ? colorVariant + : color + : color, + margin: EdgeInsets.zero, + child: InkWell( + borderRadius: kBorderRadius8, + hoverColor: colorVariant, + focusColor: colorVariant.withOpacity(0.5), + onTap: inEditMode ? null : onTap, + // onDoubleTap: inEditMode ? null : onDoubleTap, + onSecondaryTap: onSecondaryTap, + child: Padding( + padding: EdgeInsets.only( + left: 6, + right: isSelected ? 6 : 10, + top: 5, + bottom: 5, + ), + child: SizedBox( + height: 20, + child: Row( + children: [ + MethodBox(method: method), + kHSpacer4, + Expanded( + child: inEditMode + ? TextFormField( + key: ValueKey("$id-name"), + initialValue: name, + // controller: controller, + focusNode: focusNode, + //autofocus: true, + style: Theme.of(context).textTheme.bodyMedium, + onTapOutside: (_) { + onTapOutsideNameEditor?.call(); + //FocusScope.of(context).unfocus(); + }, + onFieldSubmitted: (value) { + onTapOutsideNameEditor?.call(); + }, + onChanged: onChangedNameEditor, + decoration: const InputDecoration( + isCollapsed: true, + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + ), + ) + : Text( + nm, + softWrap: false, + overflow: TextOverflow.fade, ), - ) - : Text( - nm, - softWrap: false, - overflow: TextOverflow.fade, - ), - ), - Visibility( - visible: isSelected && !inEditMode, - child: SizedBox( - width: 28, - child: ItemCardMenu( - onSelected: onMenuSelected, + ), + Visibility( + visible: isSelected && !inEditMode, + child: SizedBox( + width: 28, + child: ItemCardMenu( + onSelected: onMenuSelected, + ), ), ), - ), - ], + ], + ), ), ), ), diff --git a/lib/widgets/menu_item_card.dart b/lib/widgets/menu_item_card.dart index 5aa9fadb..e31a68b4 100644 --- a/lib/widgets/menu_item_card.dart +++ b/lib/widgets/menu_item_card.dart @@ -41,3 +41,29 @@ class ItemCardMenu extends StatelessWidget { ); } } + +/// Open the item card menu where the right click has been released +Future showItemCardMenu( + BuildContext context, + TapUpDetails details, + Function(ItemMenuOption)? onSelected, +) async { + showMenu( + context: context, + position: RelativeRect.fromLTRB( + details.globalPosition.dx, + details.globalPosition.dy, + details.globalPosition.dx, + details.globalPosition.dy, + ), + items: ItemMenuOption.values + .map>( + (e) => PopupMenuItem( + onTap: () => onSelected?.call(e), + value: e, + child: Text(e.label), + ), + ) + .toList(), + ); +} From f280e2c95aee7384b7ba0b403bc4e6b3d331429c Mon Sep 17 00:00:00 2001 From: Clement Date: Sat, 5 Oct 2024 23:10:29 -0300 Subject: [PATCH 02/10] can open the item menu on the right click for variables --- lib/widgets/card_sidebar_environment.dart | 141 ++++++++++++---------- 1 file changed, 74 insertions(+), 67 deletions(-) diff --git a/lib/widgets/card_sidebar_environment.dart b/lib/widgets/card_sidebar_environment.dart index 48f153ed..ba548753 100644 --- a/lib/widgets/card_sidebar_environment.dart +++ b/lib/widgets/card_sidebar_environment.dart @@ -48,76 +48,83 @@ class SidebarEnvironmentCard extends StatelessWidget { bool isSelected = selectedId == id; bool inEditMode = editRequestId == id; String nm = getEnvironmentTitle(name); - return Tooltip( - message: nm, - triggerMode: TooltipTriggerMode.manual, - waitDuration: const Duration(seconds: 1), - child: Card( - shape: const RoundedRectangleBorder( - borderRadius: kBorderRadius8, - ), - elevation: isSelected ? 1 : 0, - surfaceTintColor: isSelected ? surfaceTint : null, - color: isSelected && !isGlobal - ? colorScheme.brightness == Brightness.dark - ? colorVariant - : color - : color, - margin: EdgeInsets.zero, - child: InkWell( - borderRadius: kBorderRadius8, - hoverColor: colorVariant, - focusColor: colorVariant.withOpacity(0.5), - onTap: inEditMode ? null : onTap, - onSecondaryTap: onSecondaryTap, - child: Padding( - padding: EdgeInsets.only( - left: 6, - right: isSelected ? 6 : 10, - top: 5, - bottom: 5, - ), - child: SizedBox( - height: 20, - child: Row( - children: [ - kHSpacer4, - Expanded( - child: inEditMode - ? TextFormField( - key: ValueKey("$id-name"), - initialValue: name, - focusNode: focusNode, - style: Theme.of(context).textTheme.bodyMedium, - onTapOutside: (_) { - onTapOutsideNameEditor?.call(); - }, - onFieldSubmitted: (value) { - onTapOutsideNameEditor?.call(); - }, - onChanged: onChangedNameEditor, - decoration: const InputDecoration( - isCollapsed: true, - contentPadding: EdgeInsets.zero, - border: InputBorder.none, + return GestureDetector( + onSecondaryTapUp: (isGlobal) + ? null + : (TapUpDetails details) { + showItemCardMenu(context, details, onMenuSelected); + }, + child: Tooltip( + message: nm, + triggerMode: TooltipTriggerMode.manual, + waitDuration: const Duration(seconds: 1), + child: Card( + shape: const RoundedRectangleBorder( + borderRadius: kBorderRadius8, + ), + elevation: isSelected ? 1 : 0, + surfaceTintColor: isSelected ? surfaceTint : null, + color: isSelected && !isGlobal + ? colorScheme.brightness == Brightness.dark + ? colorVariant + : color + : color, + margin: EdgeInsets.zero, + child: InkWell( + borderRadius: kBorderRadius8, + hoverColor: colorVariant, + focusColor: colorVariant.withOpacity(0.5), + onTap: inEditMode ? null : onTap, + onSecondaryTap: onSecondaryTap, + child: Padding( + padding: EdgeInsets.only( + left: 6, + right: isSelected ? 6 : 10, + top: 5, + bottom: 5, + ), + child: SizedBox( + height: 20, + child: Row( + children: [ + kHSpacer4, + Expanded( + child: inEditMode + ? TextFormField( + key: ValueKey("$id-name"), + initialValue: name, + focusNode: focusNode, + style: Theme.of(context).textTheme.bodyMedium, + onTapOutside: (_) { + onTapOutsideNameEditor?.call(); + }, + onFieldSubmitted: (value) { + onTapOutsideNameEditor?.call(); + }, + onChanged: onChangedNameEditor, + decoration: const InputDecoration( + isCollapsed: true, + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + ), + ) + : Text( + nm, + softWrap: false, + overflow: TextOverflow.fade, ), - ) - : Text( - nm, - softWrap: false, - overflow: TextOverflow.fade, - ), - ), - Visibility( - visible: isSelected && !inEditMode && !isGlobal, - child: SizedBox( - width: 28, - child: ItemCardMenu( - onSelected: onMenuSelected, + ), + Visibility( + visible: isSelected && !inEditMode && !isGlobal, + child: SizedBox( + width: 28, + child: ItemCardMenu( + onSelected: onMenuSelected, + ), ), ), - ), - ], + ], + ), ), ), ), From 38c94b6080b4345d65382280bd2e791230671389 Mon Sep 17 00:00:00 2001 From: Clement Date: Sat, 5 Oct 2024 23:48:10 -0300 Subject: [PATCH 03/10] add test --- test/widgets/menu_item_card_test.dart | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/widgets/menu_item_card_test.dart b/test/widgets/menu_item_card_test.dart index 52cbcabf..fceb5d6d 100644 --- a/test/widgets/menu_item_card_test.dart +++ b/test/widgets/menu_item_card_test.dart @@ -1,7 +1,9 @@ +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:apidash/widgets/menu_item_card.dart'; import 'package:apidash/consts.dart'; +import 'package:path/path.dart'; import '../test_consts.dart'; void main() { @@ -49,4 +51,32 @@ void main() { expect(changedValue, ItemMenuOption.duplicate); }); + + testWidgets('showItemCardMenu shows the menu at the right position', + (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Builder( + builder: (BuildContext context) { + return GestureDetector( + onTapUp: (details) { + showItemCardMenu( + context, details, (ItemMenuOption option) {}); + }, + child: const Text('Show Menu'), + ); + }, + ), + ), + ), + ); + + await tester.tap(find.text('Show Menu')); + await tester.pumpAndSettle(); + + for (var option in ItemMenuOption.values) { + expect(find.text(option.label), findsOneWidget); + } + }); } From cbf4a508b4df94b5cce12deaa814eaa5be9264c6 Mon Sep 17 00:00:00 2001 From: Clement Date: Sat, 5 Oct 2024 23:53:39 -0300 Subject: [PATCH 04/10] remove unused imports --- test/widgets/menu_item_card_test.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/widgets/menu_item_card_test.dart b/test/widgets/menu_item_card_test.dart index fceb5d6d..d223eeb6 100644 --- a/test/widgets/menu_item_card_test.dart +++ b/test/widgets/menu_item_card_test.dart @@ -1,9 +1,7 @@ -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:apidash/widgets/menu_item_card.dart'; import 'package:apidash/consts.dart'; -import 'package:path/path.dart'; import '../test_consts.dart'; void main() { From 121c103763d8c3556d755aded2b73356ff896182 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Mon, 21 Oct 2024 05:03:06 +0530 Subject: [PATCH 05/10] fixes --- lib/screens/home_page/collection_pane.dart | 3 + lib/widgets/card_sidebar_request.dart | 152 ++++++++++----------- 2 files changed, 78 insertions(+), 77 deletions(-) diff --git a/lib/screens/home_page/collection_pane.dart b/lib/screens/home_page/collection_pane.dart index b30eded2..7d31ce63 100644 --- a/lib/screens/home_page/collection_pane.dart +++ b/lib/screens/home_page/collection_pane.dart @@ -223,6 +223,9 @@ class RequestItem extends ConsumerWidget { ref.read(selectedIdStateProvider.notifier).state = id; kHomeScaffoldKey.currentState?.closeDrawer(); }, + onSecondaryTap: () { + ref.read(selectedIdStateProvider.notifier).state = id; + }, // onDoubleTap: () { // ref.read(selectedIdStateProvider.notifier).state = id; // ref.read(selectedIdEditStateProvider.notifier).state = id; diff --git a/lib/widgets/card_sidebar_request.dart b/lib/widgets/card_sidebar_request.dart index f8063be9..5e5e57a4 100644 --- a/lib/widgets/card_sidebar_request.dart +++ b/lib/widgets/card_sidebar_request.dart @@ -49,86 +49,84 @@ class SidebarRequestCard extends StatelessWidget { String nm = (name != null && name!.trim().isNotEmpty) ? name! : getRequestTitleFromUrl(url); - return GestureDetector( - onSecondaryTapUp: (details) { - showItemCardMenu(context, details, onMenuSelected); - }, - child: Tooltip( - message: nm, - triggerMode: TooltipTriggerMode.manual, - waitDuration: const Duration(seconds: 1), - child: Card( - shape: const RoundedRectangleBorder( - borderRadius: kBorderRadius8, - ), - elevation: isSelected ? 1 : 0, - surfaceTintColor: isSelected ? surfaceTint : null, - color: isSelected - ? Theme.of(context).colorScheme.brightness == Brightness.dark - ? colorVariant - : color - : color, - margin: EdgeInsets.zero, - child: InkWell( - borderRadius: kBorderRadius8, - hoverColor: colorVariant, - focusColor: colorVariant.withOpacity(0.5), - onTap: inEditMode ? null : onTap, - // onDoubleTap: inEditMode ? null : onDoubleTap, - onSecondaryTap: onSecondaryTap, - child: Padding( - padding: EdgeInsets.only( - left: 6, - right: isSelected ? 6 : 10, - top: 5, - bottom: 5, - ), - child: SizedBox( - height: 20, - child: Row( - children: [ - MethodBox(method: method), - kHSpacer4, - Expanded( - child: inEditMode - ? TextFormField( - key: ValueKey("$id-name"), - initialValue: name, - // controller: controller, - focusNode: focusNode, - //autofocus: true, - style: Theme.of(context).textTheme.bodyMedium, - onTapOutside: (_) { - onTapOutsideNameEditor?.call(); - //FocusScope.of(context).unfocus(); - }, - onFieldSubmitted: (value) { - onTapOutsideNameEditor?.call(); - }, - onChanged: onChangedNameEditor, - decoration: const InputDecoration( - isCollapsed: true, - contentPadding: EdgeInsets.zero, - border: InputBorder.none, - ), - ) - : Text( - nm, - softWrap: false, - overflow: TextOverflow.fade, + return Tooltip( + message: nm, + triggerMode: TooltipTriggerMode.manual, + waitDuration: const Duration(seconds: 1), + child: Card( + shape: const RoundedRectangleBorder( + borderRadius: kBorderRadius8, + ), + elevation: isSelected ? 1 : 0, + surfaceTintColor: isSelected ? surfaceTint : null, + color: isSelected + ? Theme.of(context).colorScheme.brightness == Brightness.dark + ? colorVariant + : color + : color, + margin: EdgeInsets.zero, + child: InkWell( + borderRadius: kBorderRadius8, + hoverColor: colorVariant, + focusColor: colorVariant.withOpacity(0.5), + onTap: inEditMode ? null : onTap, + // onDoubleTap: inEditMode ? null : onDoubleTap, + onSecondaryTapUp: (details) { + onSecondaryTap?.call(); + showItemCardMenu(context, details, onMenuSelected); + }, + child: Padding( + padding: EdgeInsets.only( + left: 6, + right: isSelected ? 6 : 10, + top: 5, + bottom: 5, + ), + child: SizedBox( + height: 20, + child: Row( + children: [ + MethodBox(method: method), + kHSpacer4, + Expanded( + child: inEditMode + ? TextFormField( + key: ValueKey("$id-name"), + initialValue: name, + // controller: controller, + focusNode: focusNode, + //autofocus: true, + style: Theme.of(context).textTheme.bodyMedium, + onTapOutside: (_) { + onTapOutsideNameEditor?.call(); + //FocusScope.of(context).unfocus(); + }, + onFieldSubmitted: (value) { + onTapOutsideNameEditor?.call(); + }, + onChanged: onChangedNameEditor, + decoration: const InputDecoration( + isCollapsed: true, + contentPadding: EdgeInsets.zero, + border: InputBorder.none, ), - ), - Visibility( - visible: isSelected && !inEditMode, - child: SizedBox( - width: 28, - child: ItemCardMenu( - onSelected: onMenuSelected, - ), + ) + : Text( + nm, + softWrap: false, + overflow: TextOverflow.fade, + ), + ), + Visibility( + visible: isSelected && !inEditMode, + child: SizedBox( + width: 28, + child: ItemCardMenu( + onSelected: onMenuSelected, ), ), - ], - ), + ), + ], ), ), ), From f63346ae9aa7247b564f5cdb72866ce2fdb436b8 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Mon, 21 Oct 2024 05:10:21 +0530 Subject: [PATCH 06/10] show only in mobile --- lib/consts.dart | 1 + lib/widgets/card_sidebar_request.dart | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/consts.dart b/lib/consts.dart index e4775069..6a840fe2 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -172,6 +172,7 @@ const kPb15 = EdgeInsets.only( const kPb70 = EdgeInsets.only( bottom: 70, ); +const kSizedBoxEmpty = SizedBox(); const kHSpacer2 = SizedBox(width: 2); const kHSpacer4 = SizedBox(width: 4); const kHSpacer5 = SizedBox(width: 5); diff --git a/lib/widgets/card_sidebar_request.dart b/lib/widgets/card_sidebar_request.dart index 5e5e57a4..207900a4 100644 --- a/lib/widgets/card_sidebar_request.dart +++ b/lib/widgets/card_sidebar_request.dart @@ -117,15 +117,17 @@ class SidebarRequestCard extends StatelessWidget { overflow: TextOverflow.fade, ), ), - Visibility( - visible: isSelected && !inEditMode, - child: SizedBox( - width: 28, - child: ItemCardMenu( - onSelected: onMenuSelected, - ), - ), - ), + kIsMobile + ? Visibility( + visible: isSelected && !inEditMode, + child: SizedBox( + width: 28, + child: ItemCardMenu( + onSelected: onMenuSelected, + ), + ), + ) + : kSizedBoxEmpty, ], ), ), From e2358c48d14c72f97cf7b8404a4ec75045f1c4c0 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Mon, 21 Oct 2024 05:32:27 +0530 Subject: [PATCH 07/10] Update ui_providers_test.dart --- test/providers/ui_providers_test.dart | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/providers/ui_providers_test.dart b/test/providers/ui_providers_test.dart index e8fd0582..579939b5 100644 --- a/test/providers/ui_providers_test.dart +++ b/test/providers/ui_providers_test.dart @@ -13,6 +13,7 @@ import 'package:apidash/screens/settings_page.dart'; import 'package:apidash/screens/history/history_page.dart'; import 'package:apidash/widgets/widgets.dart'; import 'package:extended_text_field/extended_text_field.dart'; +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_portal/flutter_portal.dart'; @@ -279,7 +280,7 @@ void main() { }); testWidgets( - 'selectedIdEditStateProvider should not be null after rename button has been tapped', + 'selectedIdEditStateProvider should not be null after Duplicate button has been tapped', (tester) async { await tester.pumpWidget( ProviderScope( @@ -304,7 +305,11 @@ void main() { await tester.pump(); await tester.tap(find.byType(RequestItem)); await tester.pump(); - await tester.tap(find.byIcon(Icons.more_vert).at(1)); + //await tester.tap(find.byIcon(Icons.more_vert).at(1)); + await tester.tap( + find.byType(RequestItem), + buttons: kSecondaryButton, + ); await tester.pumpAndSettle(); // Tap on the "Duplicate" option in the menu @@ -344,7 +349,11 @@ void main() { await tester.pump(); await tester.tap(find.byType(RequestItem)); await tester.pump(); - await tester.tap(find.byIcon(Icons.more_vert).at(1)); + // await tester.tap(find.byIcon(Icons.more_vert).at(1)); + await tester.tap( + find.byType(RequestItem), + buttons: kSecondaryButton, + ); await tester.pumpAndSettle(); // Tap on the "Rename" option in the menu From 87b388b7f6e1a4e89a71ac3563c65e5eb59dbc68 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Mon, 21 Oct 2024 06:39:11 +0530 Subject: [PATCH 08/10] Fix unfocus issue --- lib/widgets/card_sidebar_request.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widgets/card_sidebar_request.dart b/lib/widgets/card_sidebar_request.dart index 207900a4..2c6167bd 100644 --- a/lib/widgets/card_sidebar_request.dart +++ b/lib/widgets/card_sidebar_request.dart @@ -98,8 +98,8 @@ class SidebarRequestCard extends StatelessWidget { //autofocus: true, style: Theme.of(context).textTheme.bodyMedium, onTapOutside: (_) { + FocusScope.of(context).unfocus(); onTapOutsideNameEditor?.call(); - //FocusScope.of(context).unfocus(); }, onFieldSubmitted: (value) { onTapOutsideNameEditor?.call(); From 048e99d5e4850ed9fe31bdb3031a893610ec2780 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Mon, 21 Oct 2024 06:42:34 +0530 Subject: [PATCH 09/10] Update card_sidebar_environment.dart --- lib/widgets/card_sidebar_environment.dart | 147 +++++++++++----------- 1 file changed, 73 insertions(+), 74 deletions(-) diff --git a/lib/widgets/card_sidebar_environment.dart b/lib/widgets/card_sidebar_environment.dart index ba548753..65ca48a9 100644 --- a/lib/widgets/card_sidebar_environment.dart +++ b/lib/widgets/card_sidebar_environment.dart @@ -48,83 +48,82 @@ class SidebarEnvironmentCard extends StatelessWidget { bool isSelected = selectedId == id; bool inEditMode = editRequestId == id; String nm = getEnvironmentTitle(name); - return GestureDetector( - onSecondaryTapUp: (isGlobal) - ? null - : (TapUpDetails details) { - showItemCardMenu(context, details, onMenuSelected); - }, - child: Tooltip( - message: nm, - triggerMode: TooltipTriggerMode.manual, - waitDuration: const Duration(seconds: 1), - child: Card( - shape: const RoundedRectangleBorder( - borderRadius: kBorderRadius8, - ), - elevation: isSelected ? 1 : 0, - surfaceTintColor: isSelected ? surfaceTint : null, - color: isSelected && !isGlobal - ? colorScheme.brightness == Brightness.dark - ? colorVariant - : color - : color, - margin: EdgeInsets.zero, - child: InkWell( - borderRadius: kBorderRadius8, - hoverColor: colorVariant, - focusColor: colorVariant.withOpacity(0.5), - onTap: inEditMode ? null : onTap, - onSecondaryTap: onSecondaryTap, - child: Padding( - padding: EdgeInsets.only( - left: 6, - right: isSelected ? 6 : 10, - top: 5, - bottom: 5, - ), - child: SizedBox( - height: 20, - child: Row( - children: [ - kHSpacer4, - Expanded( - child: inEditMode - ? TextFormField( - key: ValueKey("$id-name"), - initialValue: name, - focusNode: focusNode, - style: Theme.of(context).textTheme.bodyMedium, - onTapOutside: (_) { - onTapOutsideNameEditor?.call(); - }, - onFieldSubmitted: (value) { - onTapOutsideNameEditor?.call(); - }, - onChanged: onChangedNameEditor, - decoration: const InputDecoration( - isCollapsed: true, - contentPadding: EdgeInsets.zero, - border: InputBorder.none, - ), - ) - : Text( - nm, - softWrap: false, - overflow: TextOverflow.fade, + return Tooltip( + message: nm, + triggerMode: TooltipTriggerMode.manual, + waitDuration: const Duration(seconds: 1), + child: Card( + shape: const RoundedRectangleBorder( + borderRadius: kBorderRadius8, + ), + elevation: isSelected ? 1 : 0, + surfaceTintColor: isSelected ? surfaceTint : null, + color: isSelected && !isGlobal + ? colorScheme.brightness == Brightness.dark + ? colorVariant + : color + : color, + margin: EdgeInsets.zero, + child: InkWell( + borderRadius: kBorderRadius8, + hoverColor: colorVariant, + focusColor: colorVariant.withOpacity(0.5), + onTap: inEditMode ? null : onTap, + // onSecondaryTap: onSecondaryTap, + onSecondaryTapUp: (isGlobal) + ? null + : (details) { + onSecondaryTap?.call(); + showItemCardMenu(context, details, onMenuSelected); + }, + child: Padding( + padding: EdgeInsets.only( + left: 6, + right: isSelected ? 6 : 10, + top: 5, + bottom: 5, + ), + child: SizedBox( + height: 20, + child: Row( + children: [ + kHSpacer4, + Expanded( + child: inEditMode + ? TextFormField( + key: ValueKey("$id-name"), + initialValue: name, + focusNode: focusNode, + style: Theme.of(context).textTheme.bodyMedium, + onTapOutside: (_) { + onTapOutsideNameEditor?.call(); + }, + onFieldSubmitted: (value) { + onTapOutsideNameEditor?.call(); + }, + onChanged: onChangedNameEditor, + decoration: const InputDecoration( + isCollapsed: true, + contentPadding: EdgeInsets.zero, + border: InputBorder.none, ), - ), - Visibility( - visible: isSelected && !inEditMode && !isGlobal, - child: SizedBox( - width: 28, - child: ItemCardMenu( - onSelected: onMenuSelected, - ), + ) + : Text( + nm, + softWrap: false, + overflow: TextOverflow.fade, + ), + ), + Visibility( + visible: isSelected && !inEditMode && !isGlobal, + child: SizedBox( + width: 28, + child: ItemCardMenu( + onSelected: onMenuSelected, ), ), - ], - ), + ), + ], ), ), ), From 576d543309ab989088bbcd7f628b865aae68405e Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Mon, 21 Oct 2024 06:54:48 +0530 Subject: [PATCH 10/10] fixes env card --- lib/screens/envvar/environments_pane.dart | 3 +++ lib/widgets/card_sidebar_environment.dart | 1 + lib/widgets/card_sidebar_request.dart | 20 +++++++++----------- test/providers/ui_providers_test.dart | 6 +----- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/screens/envvar/environments_pane.dart b/lib/screens/envvar/environments_pane.dart index 34d58e4b..48f2eed4 100644 --- a/lib/screens/envvar/environments_pane.dart +++ b/lib/screens/envvar/environments_pane.dart @@ -193,6 +193,9 @@ class EnvironmentItem extends ConsumerWidget { ref.read(selectedEnvironmentIdStateProvider.notifier).state = id; kEnvScaffoldKey.currentState?.closeDrawer(); }, + onSecondaryTap: () { + ref.read(selectedEnvironmentIdStateProvider.notifier).state = id; + }, focusNode: ref.watch(nameTextFieldFocusNodeProvider), onChangedNameEditor: (value) { value = value.trim(); diff --git a/lib/widgets/card_sidebar_environment.dart b/lib/widgets/card_sidebar_environment.dart index 65ca48a9..69426df0 100644 --- a/lib/widgets/card_sidebar_environment.dart +++ b/lib/widgets/card_sidebar_environment.dart @@ -96,6 +96,7 @@ class SidebarEnvironmentCard extends StatelessWidget { focusNode: focusNode, style: Theme.of(context).textTheme.bodyMedium, onTapOutside: (_) { + FocusScope.of(context).unfocus(); onTapOutsideNameEditor?.call(); }, onFieldSubmitted: (value) { diff --git a/lib/widgets/card_sidebar_request.dart b/lib/widgets/card_sidebar_request.dart index 2c6167bd..27cbabf6 100644 --- a/lib/widgets/card_sidebar_request.dart +++ b/lib/widgets/card_sidebar_request.dart @@ -117,17 +117,15 @@ class SidebarRequestCard extends StatelessWidget { overflow: TextOverflow.fade, ), ), - kIsMobile - ? Visibility( - visible: isSelected && !inEditMode, - child: SizedBox( - width: 28, - child: ItemCardMenu( - onSelected: onMenuSelected, - ), - ), - ) - : kSizedBoxEmpty, + Visibility( + visible: isSelected && !inEditMode, + child: SizedBox( + width: 28, + child: ItemCardMenu( + onSelected: onMenuSelected, + ), + ), + ), ], ), ), diff --git a/test/providers/ui_providers_test.dart b/test/providers/ui_providers_test.dart index 579939b5..ff2102a6 100644 --- a/test/providers/ui_providers_test.dart +++ b/test/providers/ui_providers_test.dart @@ -349,11 +349,7 @@ void main() { await tester.pump(); await tester.tap(find.byType(RequestItem)); await tester.pump(); - // await tester.tap(find.byIcon(Icons.more_vert).at(1)); - await tester.tap( - find.byType(RequestItem), - buttons: kSecondaryButton, - ); + await tester.tap(find.byIcon(Icons.more_vert).at(1)); await tester.pumpAndSettle(); // Tap on the "Rename" option in the menu