Halkyon's shared packages
A pub workspace of the Dart packages Halkyon's apps share: halkyon_ui, Halkyon's look (the theme, fonts, layout and shared widgets, with texts in English and German), halkyon_core's low-level primitives and halkyon_interop's cross-app contracts. Dart 3.13 with LeanCode's lints, configured once at the root; apps take a package by git, pinned to a signed commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
commit
80fa7b9628
2 changed files with 6762 additions and 0 deletions
3
packages/halkyon_ui/lib/src/layout/readable_width.dart
Normal file
3
packages/halkyon_ui/lib/src/layout/readable_width.dart
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
/// The widest body text should run: about 720 dp, which keeps lines within
|
||||
/// the 60 to 80 characters that read most easily.
|
||||
const double readableContentMaxWidth = 720;
|
||||
41
packages/halkyon_ui/lib/src/layout/window_size.dart
Normal file
41
packages/halkyon_ui/lib/src/layout/window_size.dart
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import 'package:material_ui/material_ui.dart';
|
||||
|
||||
/// Material 3's window size classes, by width in logical pixels: compact
|
||||
/// below 600, medium to 840, expanded to 1200, large to 1600, extra large
|
||||
/// beyond.
|
||||
///
|
||||
/// Layouts branch on two of the lines: from medium on, navigation is a rail
|
||||
/// at the side instead of a bar at the bottom; from expanded on, the layout
|
||||
/// is a desktop one (sheets open as dialogs, a screen may show two
|
||||
/// columns). Expanded rather than medium for the latter because medium
|
||||
/// windows are mostly tablets, used by touch, and expanded ones mostly
|
||||
/// desktops.
|
||||
enum WindowSize {
|
||||
compact,
|
||||
medium,
|
||||
expanded,
|
||||
large,
|
||||
extraLarge;
|
||||
|
||||
/// The class of a window [width] wide.
|
||||
factory fromWidth(double width) => switch (width) {
|
||||
< 600 => compact,
|
||||
< 840 => medium,
|
||||
< 1200 => expanded,
|
||||
< 1600 => large,
|
||||
_ => extraLarge,
|
||||
};
|
||||
|
||||
/// Whether navigation is a rail rather than a bottom bar.
|
||||
bool get isAtLeastMedium => index >= medium.index;
|
||||
|
||||
/// Whether the layout is a desktop one.
|
||||
bool get isAtLeastExpanded => index >= expanded.index;
|
||||
}
|
||||
|
||||
/// `context.windowSize`: the class of the window [BuildContext] is in.
|
||||
extension WindowSizeOf on BuildContext {
|
||||
/// Rebuilds the caller when the window's width changes.
|
||||
WindowSize get windowSize =>
|
||||
WindowSize.fromWidth(MediaQuery.sizeOf(this).width);
|
||||
}
|
||||
Reference in a new issue