Make chat selection instant and add bulk selection to direct chats

This commit is contained in:
zjs81 committed 2026-11-23 20:46:50 -07:00
1 parent d4a6839413
commit 834bec7ea0
26 files changed
+1311 -213

No files matched your search

+28 -8
View File
@@ -4,14 +4,27 @@ import 'package:provider/provider.dart';
import '../services/chat_text_scale_service.dart';
/// Gesture wrapper that exposes two-finger pinch-to-zoom for chat scrollables.
/// Double-tap resets the scale. Only the wrapper itself listens to gestures;
/// child scrollables keep their normal touch handling.
/// Double-tap resets the scale, but only while the text is zoomed (or the
/// caller supplies [onDoubleTap]) and [enabled] is true: a double-tap
/// recognizer in the gesture arena makes every single tap on the child wait
/// 300 ms, so it is left out wherever taps must be instant. Only the wrapper
/// itself listens to gestures; child scrollables keep their normal touch
/// handling.
class ChatZoomWrapper extends StatefulWidget {
const ChatZoomWrapper({super.key, required this.child, this.onDoubleTap});
const ChatZoomWrapper({
super.key,
required this.child,
this.onDoubleTap,
this.enabled = true,
});
final Widget child;
final VoidCallback? onDoubleTap;
/// When false (e.g. while selecting messages) no double-tap is recognized,
/// so taps on the child are never delayed or swallowed.
final bool enabled;
@override
State<ChatZoomWrapper> createState() => _ChatZoomWrapperState();
}
@@ -22,14 +35,21 @@ class _ChatZoomWrapperState extends State<ChatZoomWrapper> {
@override
Widget build(BuildContext context) {
final service = context.read<ChatTextScaleService>();
final zoomed = context.select<ChatTextScaleService, bool>(
(s) => s.scale != 1.0,
);
final allowDoubleTap =
widget.enabled && (zoomed || widget.onDoubleTap != null);
return GestureDetector(
behavior: HitTestBehavior.translucent,
onDoubleTap: () {
service.reset();
service.persist();
widget.onDoubleTap?.call();
},
onDoubleTap: allowDoubleTap
? () {
service.reset();
service.persist();
widget.onDoubleTap?.call();
}
: null,
onScaleStart: (details) {
if (details.pointerCount != 2) return;
_startScale = service.scale;