67 lines
2.0 KiB
Dart
67 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|||
|
|
|
||
|
|
/// Typography for "technical values" (compose paths, hostnames, ids,
|
||
|
|
/// timestamps) and for tabular numerals. These are two distinct rules from
|
||
|
|
/// the design spec, not one:
|
||
|
|
/// - `dataMono*` swaps the font *family* to JetBrains Mono.
|
||
|
|
/// - `numericTabular` keeps the UI sans (Inter) but turns on the
|
||
|
|
/// `tnum` font feature so digits line up in columns (stat tiles,
|
||
|
|
/// numeric table cells) without looking like a code snippet.
|
||
|
|
@immutable
|
||
|
|
class AppDataStyles extends ThemeExtension<AppDataStyles> {
|
||
|
|
const AppDataStyles({
|
||
|
|
required this.dataMono,
|
||
|
|
required this.dataMonoSmall,
|
||
|
|
required this.numericTabular,
|
||
|
|
});
|
||
|
|
|
||
|
|
final TextStyle dataMono;
|
||
|
|
final TextStyle dataMonoSmall;
|
||
|
|
final TextStyle numericTabular;
|
||
|
|
|
||
|
|
static AppDataStyles resolve({required Color textColor, required Color mutedColor}) {
|
||
|
|
return AppDataStyles(
|
||
|
|
dataMono: TextStyle(
|
||
|
|
fontFamily: 'JetBrains Mono',
|
||
|
|
fontSize: 13,
|
||
|
|
color: mutedColor,
|
||
|
|
height: 1.3,
|
||
|
|
),
|
||
|
|
dataMonoSmall: TextStyle(
|
||
|
|
fontFamily: 'JetBrains Mono',
|
||
|
|
fontSize: 11.5,
|
||
|
|
color: mutedColor,
|
||
|
|
height: 1.3,
|
||
|
|
),
|
||
|
|
numericTabular: TextStyle(
|
||
|
|
fontFamily: 'Inter',
|
||
|
|
color: textColor,
|
||
|
|
fontFeatures: const [FontFeature.tabularFigures()],
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
AppDataStyles copyWith({
|
||
|
|
TextStyle? dataMono,
|
||
|
|
TextStyle? dataMonoSmall,
|
||
|
|
TextStyle? numericTabular,
|
||
|
|
}) {
|
||
|
|
return AppDataStyles(
|
||
|
|
dataMono: dataMono ?? this.dataMono,
|
||
|
|
dataMonoSmall: dataMonoSmall ?? this.dataMonoSmall,
|
||
|
|
numericTabular: numericTabular ?? this.numericTabular,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
AppDataStyles lerp(ThemeExtension<AppDataStyles>? other, double t) {
|
||
|
|
if (other is! AppDataStyles) return this;
|
||
|
|
return AppDataStyles(
|
||
|
|
dataMono: TextStyle.lerp(dataMono, other.dataMono, t)!,
|
||
|
|
dataMonoSmall: TextStyle.lerp(dataMonoSmall, other.dataMonoSmall, t)!,
|
||
|
|
numericTabular: TextStyle.lerp(numericTabular, other.numericTabular, t)!,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|