9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
57 lines
1.9 KiB
Dart
57 lines
1.9 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
|
|
import 'artifact_fullscreen.dart';
|
|
|
|
/// Lets a viewer page open its own content as the full-screen view.
|
|
///
|
|
/// The full-screen route lives on the root navigator, outside the page's
|
|
/// subtree, yet draws from the page's state: [buildFrame] builds either
|
|
/// presentation, and every [setState] redraws the full-screen route too, so
|
|
/// paging, loading and status messages show in both.
|
|
mixin ArtifactFullscreenHost<T extends StatefulWidget> on State<T> {
|
|
final ValueNotifier<int> _revision = ValueNotifier<int>(0);
|
|
|
|
/// The full-screen view's HTML zoom; each full-screen visit starts at 1.
|
|
final ValueNotifier<double> htmlZoom = ValueNotifier<double>(1);
|
|
Route<void>? _fullscreen;
|
|
|
|
/// The page's scaffold, inline or as the full-screen view.
|
|
Widget buildFrame(BuildContext context, {required bool fullscreen});
|
|
|
|
@override
|
|
void setState(VoidCallback fn) {
|
|
super.setState(fn);
|
|
_revision.value++;
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// The full-screen route closes with the page, once the tree unlocks.
|
|
final route = _fullscreen;
|
|
if (route != null) {
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
if (route.isActive) route.navigator?.removeRoute(route);
|
|
});
|
|
}
|
|
super.dispose();
|
|
}
|
|
|
|
/// Opens the full-screen view; it returns when the view closes.
|
|
Future<void> enterFullscreen() async {
|
|
if (_fullscreen != null) return;
|
|
htmlZoom.value = 1;
|
|
final route = artifactFullscreenRoute(
|
|
builder: (_) => ArtifactFullscreenScope(
|
|
htmlZoom: htmlZoom,
|
|
child: ListenableBuilder(
|
|
listenable: Listenable.merge([_revision, htmlZoom]),
|
|
builder: (context, _) => buildFrame(context, fullscreen: true),
|
|
),
|
|
),
|
|
);
|
|
_fullscreen = route;
|
|
await Navigator.of(context, rootNavigator: true).push(route);
|
|
_fullscreen = null;
|
|
}
|
|
}
|