First real content under app/. Lays the whole Tier 0 foundation in one
commit because the pieces depend on each other circularly (kernel →
extension → widgets → built-ins all reference types from the layer
below); splitting would leave intermediate commits that don't compile.
Key shapes:
* bare WidgetsApp root — no Material, no Cupertino, no Scaffold.
ClideTheme InheritedWidget is the only source of tokens.
* ClideKernel InheritedWidget aggregates 18 services (settings,
project, extensions, theme, panels, events, ipc, commands +
palette + keybindings, clipboard, files, notify, dialog, tray,
secrets, os, net, focus, log, i18n). ExtensionContext exposes
them through a stable interface.
* ClideExtension + sealed ContributionPoint hierarchy (Tab,
StatusItem, Toolbar, Command, TrayItem, LayoutPreset). One
manifest ships N contributions into kernel slots.
* Three-tier theme pipeline: palette (named colors) → semantic
roles → ~60 surface tokens. Defaults at each layer so legacy
palette-only themes produce a complete SurfaceTokens.
* A11y baked in from day one — every interactive primitive wraps
in Semantics(label:, hint:, button:); ensureSemantics() at boot;
theme/contrast.dart helper exposes token pairs for the WCAG
gate in the a11y test suite.
* i18n ported from fframe's L10n pattern (text-driven, namespaced
JSON catalogs, caller-supplied placeholders) with a proper
locale fallback chain (exact → language → default → placeholder)
fframe lacks.
* Four Tier-0 built-ins live (default-layout, welcome, ipc-status,
theme-picker) plus 17 id-reserving stubs so later tiers fill in
without rename churn.
.gitignore extended to cover app/ sub-package artefacts and the
Playwright harness scratch dirs.
Co-Authored-By: Claude <noreply@anthropic.com>
105 lines
2.9 KiB
Dart
105 lines
2.9 KiB
Dart
import 'package:clide_app/extension/src/contribution.dart';
|
|
import 'package:clide_app/kernel/src/panels/registry.dart';
|
|
import 'package:clide_app/kernel/src/panels/slot_id.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
/// Current, runtime layout state: which slots are visible, at what size,
|
|
/// and in what positions. Persisted through `settings`.
|
|
///
|
|
/// The registry knows which slots *exist* and which contributions are
|
|
/// mounted. The arrangement knows which slots are *currently* shown and
|
|
/// how big they are — user-modifiable via drag-resize.
|
|
class LayoutArrangement extends ChangeNotifier {
|
|
LayoutArrangement();
|
|
|
|
final Map<SlotId, _SlotState> _state = {};
|
|
|
|
void applyPreset(LayoutPresetContribution preset) {
|
|
_state.clear();
|
|
for (final slot in preset.slots) {
|
|
_state[slot.slot] = _SlotState(
|
|
position: slot.position,
|
|
size: slot.defaultSize,
|
|
minSize: slot.minSize,
|
|
maxSize: slot.maxSize,
|
|
visible: slot.visible,
|
|
);
|
|
}
|
|
notifyListeners();
|
|
}
|
|
|
|
Iterable<SlotId> get slotsInOrder => _state.keys;
|
|
|
|
SlotPosition? positionOf(SlotId id) => _state[id]?.position;
|
|
double? sizeOf(SlotId id) => _state[id]?.size;
|
|
double? minSizeOf(SlotId id) => _state[id]?.minSize;
|
|
double? maxSizeOf(SlotId id) => _state[id]?.maxSize;
|
|
bool isVisible(SlotId id) => _state[id]?.visible ?? false;
|
|
|
|
void setSize(SlotId id, double size) {
|
|
final s = _state[id];
|
|
if (s == null) return;
|
|
final clamped =
|
|
size.clamp(s.minSize ?? 0, s.maxSize ?? double.infinity).toDouble();
|
|
if (s.size == clamped) return;
|
|
_state[id] = s.copyWith(size: clamped);
|
|
notifyListeners();
|
|
}
|
|
|
|
void setVisible(SlotId id, bool visible) {
|
|
final s = _state[id];
|
|
if (s == null || s.visible == visible) return;
|
|
_state[id] = s.copyWith(visible: visible);
|
|
notifyListeners();
|
|
}
|
|
|
|
/// Convenience for the default-layout extension: register all slots
|
|
/// it provides into a [PanelRegistry] with defaults from this preset.
|
|
void registerSlotsInto(
|
|
PanelRegistry registry,
|
|
LayoutPresetContribution preset,
|
|
) {
|
|
for (final slot in preset.slots) {
|
|
registry.registerSlot(SlotDefinition(
|
|
id: slot.slot,
|
|
position: slot.position,
|
|
defaultSize: slot.defaultSize,
|
|
minSize: slot.minSize,
|
|
maxSize: slot.maxSize,
|
|
));
|
|
}
|
|
}
|
|
}
|
|
|
|
class _SlotState {
|
|
const _SlotState({
|
|
required this.position,
|
|
this.size,
|
|
this.minSize,
|
|
this.maxSize,
|
|
this.visible = true,
|
|
});
|
|
|
|
final SlotPosition position;
|
|
final double? size;
|
|
final double? minSize;
|
|
final double? maxSize;
|
|
final bool visible;
|
|
|
|
_SlotState copyWith({
|
|
SlotPosition? position,
|
|
double? size,
|
|
double? minSize,
|
|
double? maxSize,
|
|
bool? visible,
|
|
}) {
|
|
return _SlotState(
|
|
position: position ?? this.position,
|
|
size: size ?? this.size,
|
|
minSize: minSize ?? this.minSize,
|
|
maxSize: maxSize ?? this.maxSize,
|
|
visible: visible ?? this.visible,
|
|
);
|
|
}
|
|
}
|