Add app source and tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
67
lib/Peach/designs/text/Text.dart
Normal file
67
lib/Peach/designs/text/Text.dart
Normal file
@@ -0,0 +1,67 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../about/internal/application/TextType.dart';
|
||||
import '../../utils/Colors.dart';
|
||||
|
||||
/// Resolves a [TextType] role to the font family that carries it. Display copy
|
||||
/// (Bold) uses Sora; body and secondary copy use Urbanist and PlusJakartaSans.
|
||||
String getTextType(TextType type) {
|
||||
switch (type) {
|
||||
case TextType.Bold:
|
||||
return 'Sora';
|
||||
case TextType.Regular:
|
||||
return 'Urbanist';
|
||||
case TextType.Light:
|
||||
return 'PlusJakartaSans';
|
||||
}
|
||||
}
|
||||
|
||||
/// The only way display copy is drawn. Never build a raw `Text`/`TextStyle`
|
||||
/// for user-facing strings — go through here so family, weight and colour stay
|
||||
/// consistent across every screen.
|
||||
///
|
||||
/// [color] defaults to the theme's primary text colour when a [BuildContext]
|
||||
/// is supplied, so a call site rarely needs to name a colour at all.
|
||||
Widget text(
|
||||
String text,
|
||||
double textSize,
|
||||
TextType type, {
|
||||
BuildContext? context,
|
||||
Color? color,
|
||||
TextAlign? align,
|
||||
int? maxLines,
|
||||
TextOverflow? overflow,
|
||||
double? letterSpacing,
|
||||
double? height,
|
||||
double? wordSpacing,
|
||||
TextDecoration? decoration,
|
||||
FontWeight? weight,
|
||||
}) {
|
||||
return Text(
|
||||
text,
|
||||
textAlign: align ?? TextAlign.left,
|
||||
maxLines: maxLines,
|
||||
overflow: overflow,
|
||||
style: TextStyle(
|
||||
decoration: decoration ?? TextDecoration.none,
|
||||
color: color ?? (context != null ? context.jp.text : colorPrimaryDark),
|
||||
fontSize: textSize,
|
||||
fontFamily: getTextType(type),
|
||||
letterSpacing: letterSpacing,
|
||||
height: height,
|
||||
wordSpacing: wordSpacing,
|
||||
fontWeight: weight ?? _weightFor(type),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
FontWeight _weightFor(TextType type) {
|
||||
switch (type) {
|
||||
case TextType.Bold:
|
||||
return FontWeight.w700;
|
||||
case TextType.Regular:
|
||||
return FontWeight.w500;
|
||||
case TextType.Light:
|
||||
return FontWeight.w400;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user