Files
swiftcontrol/lib/utils/window_size.dart
Jonas Acker 5228e83c10 feat(theme): one light/dark theme factory with legible muted text
BkTheme.build() builds both brightnesses from one place: shared Geist
typography, radius 0.7, the brand blue as primary in light and a lifted
brand blue (with a dark foreground) in dark. Dark surfaces are one
neutral grey family instead of navy cards on a grey page.

- light mutedForeground #A1A1AA (2.56:1) -> #71717A (>= 4.5:1 on white
  and on the activity rail)
- phone widths get shadcn size scaling 1.25 instead of shrinking text
  to 0.9, so icon buttons reach a finger-sized target
- bkAccent() and the onboarding accent ternary are gone: primary is
  the brand colour in both themes now
- activity rail, markdown text and instruction-link borders use theme
  tokens instead of brightness ternaries
- adds a window-size helper (compact/medium/expanded + named legacy
  breakpoints) and a WCAG contrast test helper

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 08:16:50 +02:00

59 lines
2.2 KiB
Dart

import 'package:flutter/widgets.dart';
/// The app's window-size classes, following the Material 3 split
/// (compact < 600 < medium < 840 < expanded).
enum WindowSize {
compact,
medium,
expanded;
static WindowSize fromWidth(double width) {
if (width < Breakpoints.compact) return WindowSize.compact;
if (width < Breakpoints.medium) return WindowSize.medium;
return WindowSize.expanded;
}
static WindowSize of(BuildContext context) => fromWidth(MediaQuery.sizeOf(context).width);
bool get isCompact => this == WindowSize.compact;
}
/// Every width the layout switches on, named in one place.
///
/// The size classes are [compact] and [medium]. The others predate them and
/// are kept at their exact values on purpose — moving them onto a class
/// boundary would change a layout at widths riders already use.
abstract final class Breakpoints {
/// Below this the window is a phone: stacked layouts, bottom help pill,
/// compact scaling. Upper edge of [WindowSize.compact].
static const double compact = 600;
/// Upper edge of [WindowSize.medium].
static const double medium = 840;
/// From here the home screen shows the activity log as a permanent rail
/// and onboarding shows its step rail, instead of swiping between tabs.
static const double twoPane = 800;
/// Below this, network-check rows drop their right-hand value column and
/// the troubleshooter header moves its run stamp into the body.
static const double networkValueColumn = 640;
/// Below this the keymap explanation stacks its controller picture above
/// the button list.
static const double keymapSideBySide = 860;
/// App picker in onboarding: five columns from here, three below.
static const double onboardingAppGridWide = 560;
/// Zwift Click v2 card: below this it stacks its content.
static const double clickV2Narrow = 380;
/// Smallest main window on desktop. Narrow enough to use as a sidebar next
/// to a trainer app, wide enough that the compact layout still fits.
static const Size minDesktopWindow = Size(360, 560);
}
/// Shorthand for `WindowSize.of(context).isCompact`.
bool isCompactWindow(BuildContext context) => MediaQuery.sizeOf(context).width < Breakpoints.compact;