mirror of
https://github.com/block/buzz.git
synced 2026-11-24 18:21:59 +00:00
## Summary - Keep neighboring carousel photos visible, add page-change haptics, and reuse appearance-style dots with native iOS glass and grouped actions. - Refine full-screen video controls with fading transport, cycling speeds, pinch-to-zoom, and double-tap reset before swipe-to-dismiss. ### Related issue N/A. Checked recent open PRs; repository issue search was unavailable. ### Testing - Mobile analysis/format checks, file-size guards, and full Flutter suite passed (2,680 tests; 4 skipped). - Built, installed, and manually verified on the connected iPhone. - `just ci` was attempted but blocked fetching a Rust dependency because this Mac could not connect to GitHub. --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: klopez4212 <klopez4212@gmail.com>
115 lines
3.5 KiB
Dart
115 lines
3.5 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/rendering.dart' show PlatformViewHitTestBehavior;
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
|
|
/// Native iOS liquid-glass pagination that supports tapping and scrubbing.
|
|
class IosGlassThemePagination extends HookWidget {
|
|
/// Creates a native theme-pagination control.
|
|
const IosGlassThemePagination({
|
|
super.key,
|
|
this.semanticLabel = 'Theme',
|
|
this.containerHeight = 30,
|
|
required this.count,
|
|
required this.selected,
|
|
required this.animateChanges,
|
|
required this.onSelected,
|
|
required this.activeColor,
|
|
required this.inactiveColor,
|
|
});
|
|
|
|
static const viewType = 'buzz/theme_pagination_glass';
|
|
|
|
/// The kind of content being paged, announced by VoiceOver.
|
|
final String semanticLabel;
|
|
|
|
/// Height of the glass pill, independent of its dots and hit target.
|
|
final double containerHeight;
|
|
|
|
final int count;
|
|
final int selected;
|
|
final bool animateChanges;
|
|
final ValueChanged<int> onSelected;
|
|
final Color activeColor;
|
|
final Color inactiveColor;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
assert(defaultTargetPlatform == TargetPlatform.iOS);
|
|
final nativeChannel = useState<MethodChannel?>(null);
|
|
final onSelectedRef = useRef(onSelected)..value = onSelected;
|
|
final isRTL = Directionality.of(context) == TextDirection.rtl;
|
|
final brightness = Theme.of(context).brightness.name;
|
|
final activeColorValue = activeColor.toARGB32();
|
|
final inactiveColorValue = inactiveColor.toARGB32();
|
|
|
|
useEffect(() {
|
|
final channel = nativeChannel.value;
|
|
if (channel == null) return null;
|
|
channel.setMethodCallHandler((call) async {
|
|
if (call.method == 'selected' && call.arguments is int) {
|
|
onSelectedRef.value(call.arguments as int);
|
|
}
|
|
});
|
|
return () => channel.setMethodCallHandler(null);
|
|
}, [nativeChannel.value]);
|
|
|
|
useEffect(
|
|
() {
|
|
final channel = nativeChannel.value;
|
|
if (channel != null) {
|
|
unawaited(
|
|
channel.invokeMethod<void>('setState', <String, Object>{
|
|
'accessibilityLabel': semanticLabel,
|
|
'isRTL': isRTL,
|
|
'containerHeight': containerHeight,
|
|
'count': count,
|
|
'selected': selected,
|
|
'animateChanges': animateChanges,
|
|
'brightness': brightness,
|
|
'activeColor': activeColorValue,
|
|
'inactiveColor': inactiveColorValue,
|
|
}),
|
|
);
|
|
}
|
|
return null;
|
|
},
|
|
[
|
|
nativeChannel.value,
|
|
semanticLabel,
|
|
isRTL,
|
|
containerHeight,
|
|
count,
|
|
selected,
|
|
animateChanges,
|
|
brightness,
|
|
activeColorValue,
|
|
inactiveColorValue,
|
|
],
|
|
);
|
|
|
|
return UiKitView(
|
|
viewType: viewType,
|
|
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
|
|
creationParams: <String, Object>{
|
|
'accessibilityLabel': semanticLabel,
|
|
'isRTL': isRTL,
|
|
'containerHeight': containerHeight,
|
|
'count': count,
|
|
'selected': selected,
|
|
'animateChanges': animateChanges,
|
|
'brightness': brightness,
|
|
'activeColor': activeColorValue,
|
|
'inactiveColor': inactiveColorValue,
|
|
},
|
|
creationParamsCodec: const StandardMessageCodec(),
|
|
onPlatformViewCreated: (viewId) {
|
|
nativeChannel.value = MethodChannel('$viewType/$viewId');
|
|
},
|
|
);
|
|
}
|
|
}
|