Add explicit surface visibility signal

Provide composable shown/current visibility for retained surfaces and migrate visibility readers away from TickerMode. This keeps ticker muting separate from painted and current-surface state.
This commit is contained in:
2026-11-10 20:28:09 +00:00
parent e0e8ca68f3
commit 7ff012880b
13 changed files with 179 additions and 25 deletions
@@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../../../ui/scale/ui_scale.dart';
import '../../../ui/motion/surface_visibility.dart';
import 'chat_stop_icon.dart';
import 'package:flutter/services.dart';
@@ -262,7 +263,7 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
/// and not covered by a dialog, sheet or another pushed route.
bool _composerIsCurrent() =>
mounted &&
TickerMode.valuesOf(context).enabled &&
SurfaceVisibility.currentOf(context) &&
(ModalRoute.of(context)?.isCurrent ?? true);
@override
@@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
import '../../../ui/floating/floating_layer.dart';
import '../../../ui/motion/motion.dart';
import '../../../ui/motion/surface_visibility.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'chat_float_binding.dart';
import 'chat_float_shortcut.dart';
@@ -322,7 +323,14 @@ class _ChatFloatSlotState extends State<_ChatFloatSlot>
onDock: widget.onDock,
onHide: widget.onHide,
// A hidden window's chat pauses its tickers like a hidden tab.
child: TickerMode(enabled: !offstage, child: widget.child),
child: TickerMode(
enabled: !offstage,
child: SurfaceVisibility(
shown: !offstage,
current: !offstage,
child: widget.child,
),
),
);
},
);
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import '../../../ui/motion/motion.dart';
import '../../../ui/motion/surface_visibility.dart';
/// Reopens a retained mobile workspace without moving it to another route.
/// Its child keeps the same element, scroll positions, panes and drafts.
@@ -68,7 +69,14 @@ class _ChatWorkspaceEntranceState extends State<ChatWorkspaceEntrance>
// Both surfaces share one route here; only the workspace entrance
// animates, so no Hero inside the chat flies or duplicates a tag.
enabled: false,
child: TickerMode(enabled: widget.visible, child: widget.child),
child: TickerMode(
enabled: widget.visible,
child: SurfaceVisibility(
shown: widget.visible,
current: widget.visible,
child: widget.child,
),
),
);
final transition = widget.cupertino
? CupertinoPageTransition(
+8 -3
View File
@@ -7,6 +7,7 @@ import 'settings_theme.dart';
import 'settings_page_body.dart';
import 'settings_topic_store.dart';
import '../../core/storage/ordered_local_storage.dart';
import '../../ui/motion/surface_visibility.dart';
enum SettingsTopic {
appearance('Appearance'),
@@ -176,9 +177,13 @@ class _SettingsTopicTabsState extends State<SettingsTopicTabs>
if (_visited.contains(topic))
TickerMode(
enabled: topic == _selected,
child: KeyedSubtree(
key: ValueKey('settings-topic-${topic.name}'),
child: Builder(builder: widget.pages[topic]!),
child: SurfaceVisibility(
shown: true,
current: topic == _selected,
child: KeyedSubtree(
key: ValueKey('settings-topic-${topic.name}'),
child: Builder(builder: widget.pages[topic]!),
),
),
)
else