Files
sign-detector/lib/ui/atoms/app_text.dart
T
2026-09-27 19:12:14 +03:00

138 lines
3.0 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:sign_checker/theme/tokens.dart';
class AppText extends StatelessWidget {
const AppText(
this.data, {
super.key,
this.style = AppTypography.body,
this.color = AppColors.label,
this.maxLines,
this.overflow,
this.textAlign,
});
const AppText.largeTitle(
this.data, {
super.key,
this.color = AppColors.label,
this.maxLines,
this.overflow,
this.textAlign,
}) : style = AppTypography.largeTitle;
const AppText.title(
this.data, {
super.key,
this.color = AppColors.label,
this.maxLines,
this.overflow,
this.textAlign,
}) : style = AppTypography.title2;
const AppText.headline(
this.data, {
super.key,
this.color = AppColors.label,
this.maxLines,
this.overflow,
this.textAlign,
}) : style = AppTypography.headline;
const AppText.body(
this.data, {
super.key,
this.color = AppColors.label,
this.maxLines,
this.overflow,
this.textAlign,
}) : style = AppTypography.body;
const AppText.callout(
this.data, {
super.key,
this.color = AppColors.secondaryLabel,
this.maxLines,
this.overflow,
this.textAlign,
}) : style = AppTypography.callout;
const AppText.subhead(
this.data, {
super.key,
this.color = AppColors.secondaryLabel,
this.maxLines,
this.overflow,
this.textAlign,
}) : style = AppTypography.subhead;
const AppText.footnote(
this.data, {
super.key,
this.color = AppColors.secondaryLabel,
this.maxLines,
this.overflow,
this.textAlign,
}) : style = AppTypography.footnote;
const AppText.caption(
this.data, {
super.key,
this.color = AppColors.tertiaryLabel,
this.maxLines,
this.overflow,
this.textAlign,
}) : style = AppTypography.caption1;
final String data;
final TextStyle style;
final Color color;
final int? maxLines;
final TextOverflow? overflow;
final TextAlign? textAlign;
@override
Widget build(BuildContext context) {
return Text(
data,
maxLines: maxLines,
overflow: overflow,
textAlign: textAlign,
style: GoogleFonts.inter(
textStyle: style,
color: AppColors.of(context, color),
),
);
}
}
class AppSectionHeader extends StatelessWidget {
const AppSectionHeader(this.text, {super.key, this.padding});
final String text;
final EdgeInsetsGeometry? padding;
@override
Widget build(BuildContext context) {
return Padding(
padding:
padding ??
const EdgeInsets.fromLTRB(
AppSpacing.gutter,
AppSpacing.s4,
AppSpacing.gutter,
AppSpacing.s2,
),
child: Text(
text.toUpperCase(),
style: GoogleFonts.inter(
textStyle: AppTypography.footnote,
color: AppColors.of(context, AppColors.secondaryLabel),
letterSpacing: 0.4,
),
),
);
}
}