kirakira/lib/presentation/theme/theme.dart

143 lines
4.2 KiB
Dart

import "package:flutter/material.dart";
import "package:smol_mail/presentation/theme/app_colors.dart";
const _seedColor = Color.fromRGBO(63, 207, 142, 1);
const _darkSurface = Color.fromRGBO(1, 17, 29, 1);
TextTheme _textTheme(TextTheme base, Color mutedColor) {
return base.copyWith(
bodySmall: base.bodySmall?.copyWith(
fontFamily: "Inter",
fontSize: 16,
fontWeight: FontWeight.normal,
),
bodyMedium: base.bodyMedium?.copyWith(
fontFamily: "Inter",
fontSize: 20,
fontWeight: FontWeight.w500,
),
bodyLarge: base.bodyLarge?.copyWith(
fontFamily: "Inter",
fontSize: 24,
fontWeight: FontWeight.bold,
),
titleMedium: base.titleMedium?.copyWith(
fontSize: 14,
fontWeight: FontWeight.w300,
),
titleLarge: base.titleLarge?.copyWith(
fontFamily: "Inter",
fontSize: 35,
fontWeight: FontWeight.w900,
),
labelSmall: base.labelSmall?.copyWith(
fontFamily: "Inter",
fontSize: 16,
color: mutedColor,
fontWeight: FontWeight.w700,
),
);
}
ThemeData _buildTheme(ColorScheme scheme, AppColors appColors) {
return ThemeData(
colorScheme: scheme,
// ThemeData defaults this legacy field to Colors.grey[900] on a dark
// theme when unset, which is nearly invisible against our dark surfaces —
// several screens still read it via Theme.of(context).primaryColor.
primaryColor: scheme.primary,
scaffoldBackgroundColor: scheme.surface,
extensions: [appColors],
appBarTheme: AppBarTheme(
backgroundColor: scheme.surface,
iconTheme: IconThemeData(color: scheme.onSurface, size: 30),
titleTextStyle: TextStyle(
color: scheme.onSurface,
fontFamily: "Inter",
fontWeight: FontWeight.w900,
fontSize: 30,
),
elevation: 0.0,
),
textTheme: _textTheme(
ThemeData(brightness: scheme.brightness).textTheme,
scheme.onSurfaceVariant,
),
snackBarTheme: SnackBarThemeData(
backgroundColor: scheme.inverseSurface,
contentTextStyle: TextStyle(
fontFamily: "Inter",
fontSize: 16,
color: scheme.onInverseSurface,
),
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
backgroundColor: scheme.primary,
foregroundColor: scheme.onPrimary,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)),
textStyle: const TextStyle(
fontFamily: "Inter",
fontSize: 17,
fontWeight: FontWeight.w500,
),
),
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
foregroundColor: scheme.primary,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)),
textStyle: const TextStyle(
fontFamily: "Inter",
fontWeight: FontWeight.w500,
fontSize: 17,
),
),
),
// Without this, an empty/unfocused field's resting label inherits
// bodyLarge (24px bold) — that's what made "Host" etc. look huge.
inputDecorationTheme: InputDecorationTheme(
labelStyle: TextStyle(
fontFamily: "Inter",
fontSize: 16,
fontWeight: FontWeight.normal,
color: scheme.onSurfaceVariant,
),
floatingLabelStyle: TextStyle(
fontFamily: "Inter",
fontSize: 14,
fontWeight: FontWeight.w500,
color: scheme.primary,
),
hintStyle: TextStyle(
fontFamily: "Inter",
fontSize: 16,
fontWeight: FontWeight.normal,
color: scheme.onSurfaceVariant,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide.none,
),
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
),
useMaterial3: true,
);
}
final ThemeData appThemeDark = _buildTheme(
ColorScheme.fromSeed(
seedColor: _seedColor,
brightness: Brightness.dark,
).copyWith(surface: _darkSurface),
AppColors.dark,
);
final ThemeData appThemeLight = _buildTheme(
ColorScheme.fromSeed(
seedColor: _seedColor,
brightness: Brightness.light,
),
AppColors.light,
);