mirror of
https://github.com/block/buzz.git
synced 2026-11-28 04:01:45 +00:00
## Summary - Organize mobile Messages into configurable flat sections. See All keeps the list and its search position when opening a conversation, and supports side-by-side browsing on an unfolded Duo. - Use the same 16-point Messages gutter in booklet and open Duo layouts. The regular iPhone uses 20 points. Align navigation actions and use native inline titles on See All. - Update mobile typography and spacing across chat rows, message bubbles, drafts, and the composer. Render code proportionally to the 17-point message body. ## Device review Compare the leading edges of the section headings and channel icons in Messages on the open Duo and in booklet mode. Open See All and check that its rows follow the same column. --------- Signed-off-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
104 lines
3.0 KiB
Dart
104 lines
3.0 KiB
Dart
import 'dart:async';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
|
|
/// Duration of a section opening and its chevron rotation.
|
|
const Duration sectionExpandDuration = Duration(milliseconds: 220);
|
|
|
|
/// Duration of a section closing.
|
|
const Duration sectionCollapseDuration = Duration(milliseconds: 170);
|
|
|
|
/// Easing shared by section bodies and chevrons.
|
|
const Curve sectionExpandCurve = Cubic(0.23, 1, 0.32, 1);
|
|
|
|
/// Easing for the closing section body.
|
|
const Curve sectionCollapseCurve = Curves.easeInCubic;
|
|
|
|
/// Shared Channels and Me section expansion, including reduced-motion support.
|
|
class CollapsibleSectionBody extends HookWidget {
|
|
final bool expanded;
|
|
final Widget child;
|
|
|
|
const CollapsibleSectionBody({
|
|
super.key,
|
|
required this.expanded,
|
|
required this.child,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final reducedMotion = MediaQuery.of(context).disableAnimations;
|
|
final controller = useAnimationController(
|
|
duration: reducedMotion ? Duration.zero : sectionExpandDuration,
|
|
reverseDuration: reducedMotion ? Duration.zero : sectionCollapseDuration,
|
|
initialValue: expanded ? 1 : 0,
|
|
);
|
|
final curvedAnimation = useMemoized(
|
|
() => CurvedAnimation(
|
|
parent: controller,
|
|
curve: sectionExpandCurve,
|
|
reverseCurve: sectionCollapseCurve,
|
|
),
|
|
[controller],
|
|
);
|
|
final shouldRender = useState(expanded);
|
|
|
|
useEffect(() => curvedAnimation.dispose, [curvedAnimation]);
|
|
|
|
useEffect(() {
|
|
void handleStatus(AnimationStatus status) {
|
|
if (status == AnimationStatus.dismissed && !expanded) {
|
|
shouldRender.value = false;
|
|
}
|
|
}
|
|
|
|
controller.addStatusListener(handleStatus);
|
|
return () => controller.removeStatusListener(handleStatus);
|
|
}, [controller, expanded]);
|
|
|
|
useEffect(() {
|
|
controller.duration = reducedMotion
|
|
? Duration.zero
|
|
: sectionExpandDuration;
|
|
controller.reverseDuration = reducedMotion
|
|
? Duration.zero
|
|
: sectionCollapseDuration;
|
|
|
|
if (expanded) {
|
|
shouldRender.value = true;
|
|
if (reducedMotion) {
|
|
controller.value = 1;
|
|
} else {
|
|
unawaited(controller.forward());
|
|
}
|
|
} else if (reducedMotion) {
|
|
controller.value = 0;
|
|
shouldRender.value = false;
|
|
} else {
|
|
unawaited(controller.reverse());
|
|
}
|
|
|
|
return null;
|
|
}, [controller, expanded, reducedMotion]);
|
|
|
|
return ClipRect(
|
|
child: AnimatedBuilder(
|
|
animation: curvedAnimation,
|
|
child: shouldRender.value ? child : const SizedBox.shrink(),
|
|
builder: (context, child) {
|
|
final value = curvedAnimation.value.clamp(0.0, 1.0);
|
|
|
|
return Align(
|
|
alignment: Alignment.topCenter,
|
|
heightFactor: value,
|
|
child: ExcludeSemantics(
|
|
excluding: !expanded,
|
|
child: IgnorePointer(ignoring: !expanded, child: child),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|