48 lines
1.8 KiB
Dart
48 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'app_design.dart';
|
|
import 'app_design_tokens.dart';
|
|
import 'app_theme.dart';
|
|
import 'compact_controls.dart';
|
|
import 'compact_typography.dart';
|
|
|
|
/// Compact's corner radius: every card, field, button, chip, menu, dialog,
|
|
/// sheet, tooltip, snack bar, bubble and window takes it.
|
|
const double compactRadius = 6;
|
|
|
|
/// The Compact design's theme: Default's Material 3 colours and surfaces,
|
|
/// packed for a big monitor and long runs and chats. A smaller type scale
|
|
/// ([compactTextTheme]), Material's compact visual density, 18px icons, and
|
|
/// [compactRadius] corners on every surface. On a touch device controls keep
|
|
/// a 40px tap target (Material's padded target under compact density); on a
|
|
/// pointer device they shrink to their drawn size.
|
|
ThemeData compactTheme(Brightness brightness, {String? fontFamily}) {
|
|
final standard = brightness == Brightness.dark
|
|
? appDarkTheme(fontFamily: fontFamily)
|
|
: appLightTheme(fontFamily: fontFamily);
|
|
final textTheme = compactTextTheme(standard.textTheme);
|
|
final themed = standard.copyWith(
|
|
visualDensity: VisualDensity.compact,
|
|
materialTapTargetSize: DesignDensity.pointerPlatform
|
|
? MaterialTapTargetSize.shrinkWrap
|
|
: MaterialTapTargetSize.padded,
|
|
textTheme: textTheme,
|
|
primaryTextTheme: compactTextTheme(standard.primaryTextTheme),
|
|
iconTheme: standard.iconTheme.copyWith(
|
|
size: DesignDensity.compact.iconSize,
|
|
),
|
|
primaryIconTheme: standard.primaryIconTheme.copyWith(
|
|
size: DesignDensity.compact.iconSize,
|
|
),
|
|
extensions: const [
|
|
AppDesignTokens(
|
|
design: AppDesign.compact,
|
|
radius: compactRadius,
|
|
reading: compactReading,
|
|
density: DesignDensity.compact,
|
|
),
|
|
],
|
|
);
|
|
return compactControls(themed);
|
|
}
|