Files
buzz/mobile/lib/features/channels/jump_to_latest_button.dart
klopez4212 da818eddc2 Polish mobile timeline and emoji interactions (#6297)
## Summary

- Align mobile home avatars and share the same sticky-date and Latest
controls across channels and threads.
- Stabilize thread tail navigation and emoji category scrolling.
- Remove iOS glass compositing artifacts and match long-press blur
across action surfaces.

## Why

Threads and emoji selection used competing scroll and compositing paths,
causing rebounds, flicker, and inconsistent controls.

## Testing

- `just mobile-check`
- `flutter test` (1,529 tests)
- Signed Release installed, launched, and reviewed on a connected iPhone

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Signed-off-by: Kenny Lopez <klopez4212@gmail.com>
Signed-off-by: Watcher <bb7abfd757d0af7b66569d02ab9c0316b616f9d0c151ecf5b964344c462e7f8f@buzz.block.builderlab.xyz>
Co-authored-by: Carl <3c4caeafb646d23867f1c4832e68211d77e2561946171625f75c3ce1a3f2670f@buzz.block.builderlab.xyz>
Co-authored-by: Watcher <bb7abfd757d0af7b66569d02ab9c0316b616f9d0c151ecf5b964344c462e7f8f@buzz.block.builderlab.xyz>
2026-08-20 09:45:56 +01:00

129 lines
4.3 KiB
Dart

import 'dart:async';
import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../shared/theme/theme.dart';
import 'message_action_backdrop_state.dart';
/// Shared channel/thread motion for an explicit return-to-latest action.
const jumpToLatestScrollDuration = Duration(milliseconds: 220);
const jumpToLatestScrollCurve = Curves.easeOutCubic;
/// Compact conversation control that returns a detached timeline to its tail.
class JumpToLatestButton extends HookWidget {
final String id;
final VoidCallback onPressed;
const JumpToLatestButton({
required this.onPressed,
this.id = 'channel',
super.key,
});
static const _iosViewType = 'buzz/jump_to_latest_glass';
@override
Widget build(BuildContext context) {
final nativeChannel = useState<MethodChannel?>(null);
final onPressedRef = useRef(onPressed)..value = onPressed;
final brightness = context.theme.brightness.name;
useEffect(() {
final channel = nativeChannel.value;
if (channel == null) return null;
channel.setMethodCallHandler((call) async {
if (call.method == 'pressed') onPressedRef.value();
});
return () => channel.setMethodCallHandler(null);
}, [nativeChannel.value]);
useEffect(() {
final channel = nativeChannel.value;
if (channel != null) {
unawaited(channel.invokeMethod<void>('setBrightness', brightness));
}
return null;
}, [nativeChannel.value, brightness]);
final borderColor = context.colors.onSurface.withValues(alpha: 0.08);
final usesNativeIosGlass = defaultTargetPlatform == TargetPlatform.iOS;
Widget buildFlutterSurface() {
return Material(
color: Colors.transparent,
child: InkResponse(
containedInkWell: true,
customBorder: const CircleBorder(),
onTap: onPressed,
radius: Grid.sm,
child: Align(
key: ValueKey('$id-jump-to-latest-visual-anchor'),
alignment: Alignment.bottomCenter,
child: ClipOval(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
child: Container(
key: ValueKey('$id-jump-to-latest-surface'),
width: Grid.lg,
height: Grid.lg,
decoration: BoxDecoration(
color: context.colors.surface.withValues(alpha: 0.72),
shape: BoxShape.circle,
border: Border.all(color: borderColor),
),
child: Icon(
LucideIcons.arrowDown,
size: Grid.gutter,
color: context.colors.onSurfaceVariant,
),
),
),
),
),
),
);
}
return Semantics(
button: true,
label: 'Jump to latest message',
child: Tooltip(
excludeFromSemantics: true,
message: 'Jump to latest message',
child: SizedBox.square(
dimension: Grid.xl,
child: ValueListenableBuilder<bool>(
valueListenable: messageActionBackdropActive,
builder: (context, backdropActive, _) {
if (!usesNativeIosGlass || backdropActive) {
return buildFlutterSurface();
}
return SizedBox.expand(
key: ValueKey('$id-jump-to-latest-surface'),
child: UiKitView(
key: ValueKey('$id-jump-to-latest-ios-glass'),
viewType: _iosViewType,
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
creationParams: <String, Object>{'brightness': brightness},
creationParamsCodec: const StandardMessageCodec(),
onPlatformViewCreated: (viewId) {
nativeChannel.value = MethodChannel(
'$_iosViewType/$viewId',
);
},
),
);
},
),
),
),
);
}
}