Files
clide/lib/kernel/src/text_zoom.dart
T
jpmschweitzerandClaude 044d1b2ff1
test / unit + widget + golden + a11y (push) Failing after 30s
test / integration_test (xvfb) (push) Has been skipped
test / bundle smoke (xvfb 5s) (push) Has been skipped
test / daemon subprocess + web WASM smoke (push) Has been skipped
test / dart doc (lib API) (push) Failing after 1m1s
lift text-zoom into kernel, surface it in the palette (T-114)
Workspace text-zoom (Ctrl +/-/0) was local state on _RootShellState,
reachable only via the keymap intent path. Lifted to a kernel TextZoom
ChangeNotifier so the new `view.zoomIn/Out/Reset` palette commands
mutate the same number the keymap does — closing T-114's "discoverable
in the palette" item.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-18 09:04:43 +02:00

29 lines
837 B
Dart

import 'package:flutter/foundation.dart';
/// Workspace-wide text zoom factor.
///
/// Owned by the kernel rather than the root widget so command-palette
/// entries, the keymap layer, and any future menu/CLI surface can mutate
/// the same number. The root `MediaQuery` listens via [ChangeNotifier].
class TextZoom extends ChangeNotifier {
TextZoom();
static const double minScale = 0.6;
static const double maxScale = 2.0;
static const double stepScale = 0.05;
double _scale = 1.0;
double get scale => _scale;
void increase() => _setScale(_scale + stepScale);
void decrease() => _setScale(_scale - stepScale);
void reset() => _setScale(1.0);
void _setScale(double next) {
final clamped = next.clamp(minScale, maxScale);
if (clamped == _scale) return;
_scale = clamped;
notifyListeners();
}
}