Merge branch 'main' into tor_proxy

This commit is contained in:
Fabian Freund
2025-09-15 06:21:24 +02:00
3 changed files with 198 additions and 248 deletions
@@ -57,8 +57,6 @@ class BrowserScreen extends HookConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final scaffoldKey = useMemoized(() => GlobalKey<ScaffoldState>());
final eventService = ref.watch(eventServiceProvider); final eventService = ref.watch(eventServiceProvider);
final sheetDisplayed = ref.watch( final sheetDisplayed = ref.watch(
@@ -106,56 +104,6 @@ class BrowserScreen extends HookConsumerWidget {
); );
final sheetController = useRef<PersistentBottomSheetController?>(null); final sheetController = useRef<PersistentBottomSheetController?>(null);
ref.listen(bottomSheetControllerProvider, (previous, next) {
final state = scaffoldKey.currentState;
if (state != null) {
if (sheetController.value != null) {
sheetController.value!.close();
sheetController.value = null;
}
if (next != null) {
final relativeSafeArea = MediaQuery.of(context).relativeSafeArea();
sheetController.value = state.showBottomSheet((context) {
bool dismissOnThreshold(
DraggableScrollableNotification notification,
) {
if (notification.extent <= 0.1) {
ref.read(bottomSheetControllerProvider.notifier).dismiss();
return true;
} else {
ref
.read(bottomSheetExtendProvider.notifier)
.add(notification.extent);
}
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;
});
}
}
});
return PopScope( return PopScope(
//We need this for BackButtonListener to work downstream //We need this for BackButtonListener to work downstream
@@ -164,7 +112,6 @@ class BrowserScreen extends HookConsumerWidget {
child: Theme( child: Theme(
data: themeData, data: themeData,
child: Scaffold( child: Scaffold(
key: scaffoldKey,
extendBodyBehindAppBar: tabInFullScreen, extendBodyBehindAppBar: tabInFullScreen,
bottomNavigationBar: HookConsumer( bottomNavigationBar: HookConsumer(
builder: (context, ref, child) { builder: (context, ref, child) {
@@ -265,7 +212,8 @@ class BrowserScreen extends HookConsumerWidget {
); );
}, },
), ),
body: DragTarget<TabDragData>( body: Consumer(
child: DragTarget<TabDragData>(
onMove: (details) { onMove: (details) {
ref ref
.read(willAcceptDropProvider.notifier) .read(willAcceptDropProvider.notifier)
@@ -323,7 +271,9 @@ class BrowserScreen extends HookConsumerWidget {
} }
if (overlayBuilder != null) { if (overlayBuilder != null) {
ref.read(overlayControllerProvider.notifier).dismiss(); ref
.read(overlayControllerProvider.notifier)
.dismiss();
return true; return true;
} }
@@ -422,6 +372,63 @@ 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();
sheetController.value = Scaffold.of(context).showBottomSheet((
context,
) {
bool dismissOnThreshold(
DraggableScrollableNotification notification,
) {
if (notification.extent <= 0.1) {
ref
.read(bottomSheetControllerProvider.notifier)
.dismiss();
return true;
} else {
ref
.read(bottomSheetExtendProvider.notifier)
.add(notification.extent);
}
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;
});
}
});
return child!;
},
),
floatingActionButton: ReaderAppearanceButton(), floatingActionButton: ReaderAppearanceButton(),
), ),
), ),
@@ -37,65 +37,8 @@ class DraggableScrollableHeader extends StatefulWidget {
super.key, super.key,
required this.controller, required this.controller,
required this.child, required this.child,
this.velocitySensitivity = 0.35, // Higher = more sensitive to velocity
this.maxVelocity = 2500.0, // Maximum velocity to consider
this.minVelocity = 150.0, // Minimum velocity to trigger momentum
this.animationDuration = const Duration(milliseconds: 300),
this.animationCurve = Curves.decelerate,
this.dragSensitivity = 1.0, // Controls drag responsiveness
}); });
@override
State<DraggableScrollableHeader> createState() =>
_DraggableScrollableHeaderState();
}
class _DraggableScrollableHeaderState extends State<DraggableScrollableHeader>
with TickerProviderStateMixin {
late AnimationController _animationController;
late Animation<double>? _animation;
@override
void initState() {
super.initState();
_animationController = AnimationController(
vsync: this,
duration: widget.animationDuration,
);
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
Future<void> _animateToPosition(
double targetSize, {
Duration? customDuration,
}) async {
if (customDuration != null) {
_animationController.duration = customDuration;
} else {
_animationController.duration = widget.animationDuration;
}
_animation = Tween<double>(begin: widget.controller.size, end: targetSize)
.animate(
CurvedAnimation(
parent: _animationController,
curve: widget.animationCurve,
),
);
_animationController.reset();
await _animationController.forward();
_animation!.addListener(() {
widget.controller.jumpTo(_animation!.value);
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return GestureDetector(
+1 -1
View File
@@ -2,7 +2,7 @@ name: weblibre
description: "The Privacy-Focused & AI-Powered Research Browser" description: "The Privacy-Focused & AI-Powered Research Browser"
publish_to: 'none' publish_to: 'none'
resolution: workspace resolution: workspace
version: 0.9.23-alpha-1+26 version: 0.9.23-alpha-2+26
environment: environment:
sdk: '>=3.8.0 <4.0.0' sdk: '>=3.8.0 <4.0.0'