Files
buzz/mobile/lib/shared/widgets/ios_navigation_metrics.dart
klopez4212 6cf4582002 Use native iOS navigation bars with large titles and avatars (#8052)
## Summary

Use UIKit navigation bars across iOS pages, with large titles that
collapse into the toolbar on scroll and a light native blur. Home uses
the active community name as its title and shows community and profile
avatars with centered emoji and stable loading, without flashing back to
icons. Channel headers retain the member count, tap-to-settings title,
and Huddle action. Their ultra-thin native material has a soft lower
edge and stays visible at the timeline bottom. The hidden title-layout
scroll view has its automatic edge effects disabled so it cannot add a
second backdrop.

| Expanded Home | Scrolled Home | Settings |
| --- | --- | --- |
| <img
src="https://raw.githubusercontent.com/block/buzz/47a77d3ff1d30fc74f7488c1a4427e41bbb85c4e/pr-8052--home.png"
alt="home" width="240"> | <img
src="https://raw.githubusercontent.com/block/buzz/47a77d3ff1d30fc74f7488c1a4427e41bbb85c4e/pr-8052--scrolled.png"
alt="scrolled" width="240"> | <img
src="https://raw.githubusercontent.com/block/buzz/47a77d3ff1d30fc74f7488c1a4427e41bbb85c4e/pr-8052--settings.png"
alt="settings" width="240"> |

Channel title, member count, and Huddle control:

<img
src="https://raw.githubusercontent.com/block/buzz/47a77d3ff1d30fc74f7488c1a4427e41bbb85c4e/pr-8052--channel.png"
alt="Channel navigation" width="280">

### Related issue

No matching open issue found.

### Testing

- Added causal regressions for Profile/Edit Photo native titles,
metrics-only collapse changes, and native-header suppression throughout
channel/thread reaction and action backdrops. Each regression fails when
its corresponding fix is removed.

- Mobile formatting and analysis passed. Full mobile test rerun passed:
2,622 tests, 4 skipped, plus 3 push-disabled build tests.
- Native iPhone Air regression passed: repeated title expansion/collapse
and scroll material behavior.
- Navigation and blur were accepted on the connected iPhone using the
existing profile. Simulator snapshots use real community data. The
subsequent review fixes have widget coverage; fresh physical-device
verification of Profile states, Dynamic Type changes, and message
backdrops is pending.
- Full repository `just ci` was blocked by local disk exhaustion while
compiling Rust dependencies.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
2026-10-03 18:10:03 +01:00

57 lines
1.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
/// UIKit's measured navigation geometry, with a first-frame bootstrap size.
class IosNavigationMetrics {
const IosNavigationMetrics({
this.compactHeight = 44,
this.largeTitleHeight = 52,
});
final double compactHeight;
final double largeTitleHeight;
static IosNavigationMetrics of(BuildContext context) =>
_MetricsScope.of(context)?.value ?? const IosNavigationMetrics();
static void update(BuildContext context, Map<Object?, Object?> values) {
final notifier = _MetricsScope.of(context);
if (notifier == null) return;
final compact = (values['compactHeight'] as num?)?.toDouble();
final expanded = (values['expandedHeight'] as num?)?.toDouble();
if (compact == null || !compact.isFinite || compact <= 0) return;
final extra = expanded == null
? notifier.value.largeTitleHeight
: expanded - compact;
if (!extra.isFinite || extra < 0) return;
if ((notifier.value.compactHeight - compact).abs() < 0.1 &&
(notifier.value.largeTitleHeight - extra).abs() < 0.1) {
return;
}
notifier.value = IosNavigationMetrics(
compactHeight: compact,
largeTitleHeight: extra,
);
}
}
/// Shares measured UIKit spacing across routes and their body insets.
class IosNavigationMetricsHost extends HookWidget {
const IosNavigationMetricsHost({super.key, required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
final metrics = useValueNotifier(const IosNavigationMetrics());
return _MetricsScope(notifier: metrics, child: child);
}
}
class _MetricsScope
extends InheritedNotifier<ValueNotifier<IosNavigationMetrics>> {
const _MetricsScope({required super.notifier, required super.child});
static ValueNotifier<IosNavigationMetrics>? of(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<_MetricsScope>()?.notifier;
}