dont use complex widget as consumer child to avoid rebuild issues

This commit is contained in:
Fabian Freund
2025-10-08 07:47:28 +02:00
parent ddccf4cb73
commit f7cb836d15
@@ -218,7 +218,65 @@ class BrowserScreen extends HookConsumerWidget {
}, },
), ),
body: Consumer( body: Consumer(
child: DragTarget<TabDragData>( builder: (context, ref, child) {
ref.listen(bottomSheetControllerProvider, (previous, next) {
if (sheetController.value != null) {
sheetController.value!.close();
sheetController.value = null;
}
if (next != null) {
final relativeSafeArea = MediaQuery.of(
context,
).relativeSafeArea();
final controller = Scaffold.of(context).showBottomSheet((
context,
) {
bool dismissOnThreshold(
DraggableScrollableNotification notification,
) {
if (notification.extent <= 0.1) {
ref
.read(bottomSheetControllerProvider.notifier)
.requestDismiss();
return true;
}
return false;
}
final sheet = switch (next) {
ViewTabsSheet() =>
NotificationListener<DraggableScrollableNotification>(
key: ValueKey(next),
onNotification: dismissOnThreshold,
child: _ViewTabsSheet(maxChildSize: relativeSafeArea),
),
final EditUrlSheet parameter =>
NotificationListener<DraggableScrollableNotification>(
key: ValueKey(parameter),
onNotification: dismissOnThreshold,
child: _ViewUrlSheet(
initialTabState: parameter.tabState,
maxChildSize: relativeSafeArea,
),
),
};
return sheet;
});
unawaited(
controller.closed.whenComplete(() {
ref.read(bottomSheetControllerProvider.notifier).closed();
}),
);
sheetController.value = controller;
}
});
return DragTarget<TabDragData>(
onMove: (details) { onMove: (details) {
ref ref
.read(willAcceptDropProvider.notifier) .read(willAcceptDropProvider.notifier)
@@ -305,7 +363,9 @@ class BrowserScreen extends HookConsumerWidget {
lastBackButtonPress.value = null; lastBackButtonPress.value = null;
await ref await ref
.read(readerableScreenControllerProvider.notifier) .read(
readerableScreenControllerProvider.notifier,
)
.toggleReaderView(false); .toggleReaderView(false);
return true; return true;
@@ -379,66 +439,7 @@ class BrowserScreen extends HookConsumerWidget {
), ),
); );
}, },
),
builder: (context, ref, child) {
ref.listen(bottomSheetControllerProvider, (previous, next) {
if (sheetController.value != null) {
sheetController.value!.close();
sheetController.value = null;
}
if (next != null) {
final relativeSafeArea = MediaQuery.of(
context,
).relativeSafeArea();
final controller = Scaffold.of(context).showBottomSheet((
context,
) {
bool dismissOnThreshold(
DraggableScrollableNotification notification,
) {
if (notification.extent <= 0.1) {
ref
.read(bottomSheetControllerProvider.notifier)
.requestDismiss();
return true;
}
return false;
}
final sheet = switch (next) {
ViewTabsSheet() =>
NotificationListener<DraggableScrollableNotification>(
key: ValueKey(next),
onNotification: dismissOnThreshold,
child: _ViewTabsSheet(maxChildSize: relativeSafeArea),
),
final EditUrlSheet parameter =>
NotificationListener<DraggableScrollableNotification>(
key: ValueKey(parameter),
onNotification: dismissOnThreshold,
child: _ViewUrlSheet(
initialTabState: parameter.tabState,
maxChildSize: relativeSafeArea,
),
),
};
return sheet;
});
unawaited(
controller.closed.whenComplete(() {
ref.read(bottomSheetControllerProvider.notifier).closed();
}),
); );
sheetController.value = controller;
}
});
return child!;
}, },
), ),
floatingActionButton: ReaderAppearanceButton(), floatingActionButton: ReaderAppearanceButton(),