From 8430b1a5a968c7b5703ca40ceff58d1500e29a44 Mon Sep 17 00:00:00 2001 From: Fabian Freund Date: Fri, 18 Jul 2025 11:09:10 +0200 Subject: [PATCH] refactor draggable --- .../widgets/sheets/view_tabs.dart | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/app/lib/features/geckoview/features/browser/presentation/widgets/sheets/view_tabs.dart b/app/lib/features/geckoview/features/browser/presentation/widgets/sheets/view_tabs.dart index 7bb60d0d..48c40bc6 100644 --- a/app/lib/features/geckoview/features/browser/presentation/widgets/sheets/view_tabs.dart +++ b/app/lib/features/geckoview/features/browser/presentation/widgets/sheets/view_tabs.dart @@ -30,11 +30,7 @@ class _TabDraggable extends HookConsumerWidget { final TabEntity entity; final VoidCallback onClose; - const _TabDraggable({ - required super.key, - required this.entity, - required this.onClose, - }); + const _TabDraggable({required this.entity, required this.onClose}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -63,24 +59,20 @@ class _TabDraggable extends HookConsumerWidget { }, ); - return CustomDraggable( - key: Key(entity.tabId), - data: TabDragData(entity.tabId), - child: switch (dragData) { - ContainerDropData() => Opacity( - opacity: 0.3, - child: Transform.scale(scale: 0.9, child: tab), + return switch (dragData) { + ContainerDropData() => Opacity( + opacity: 0.3, + child: Transform.scale(scale: 0.9, child: tab), + ), + DeleteDropData() => Opacity( + opacity: 0.3, + child: ColorFiltered( + colorFilter: const ColorFilter.mode(Colors.red, BlendMode.modulate), + child: tab, ), - DeleteDropData() => Opacity( - opacity: 0.3, - child: ColorFiltered( - colorFilter: const ColorFilter.mode(Colors.red, BlendMode.modulate), - child: tab, - ), - ), - null => tab, - }, - ); + ), + null => tab, + }; } } @@ -383,10 +375,13 @@ class ViewTabsSheetWidget extends HookConsumerWidget { return filteredTabEntities.value .where((entity) => entity is! TabTreeEntity) .map( - (entity) => _TabDraggable( + (entity) => CustomDraggable( key: Key(entity.tabId), - entity: entity, - onClose: onClose, + data: TabDragData(entity.tabId), + child: _TabDraggable( + entity: entity, + onClose: onClose, + ), ), ) .toList();