Overview
Wonderous implements a sophisticated theming system centered around theAppStyle class, providing consistent colors, typography, spacing, and visual elements throughout the app.
Color System
AppColors Class
TheAppColors class (defined in lib/styles/colors.dart:6) defines the app’s core color palette:
Wonder-Specific Colors
Each wonder has unique foreground and background colors defined inlib/styles/wonders_color_extensions.dart:3:
Color Utilities
The color system includes helper methods:shift(Color c, double d)(lib/styles/colors.dart:24) - Shifts color HSL valuesColorFilterextension (lib/styles/wonders_color_extensions.dart:31) - Creates color filters for images
Theme Data Generation
ThetoThemeData() method (lib/styles/colors.dart:26) generates Material ThemeData:
Typography System
Font Families
Wonderous uses four primary font families configured inpubspec.yaml:103-131:
- Cinzel - Decorative font for quotes and drop caps
- Yeseva - Display font for wonder titles
- Tenor - Sans-serif for general titles
- Raleway - Primary content font with multiple weights (Regular, Medium, Bold, ExtraBold)
- MaShanZheng - Chinese quote font
- B612Mono - Monospace titles
Locale-Aware Font Selection
Fonts are automatically selected based on the current locale (lib/styles/styles.dart:83-95):
Text Styles
Predefined text styles with responsive scaling (lib/styles/styles.dart:97-175):
| Style | Font | Size | Use Case |
|---|---|---|---|
wonderTitle | Yeseva | 64px | Wonder names |
h1 | Tenor | 64px | Main headings |
h2 | Tenor | 32px | Section headings |
h3 | Tenor | 24px | Subsection headings |
h4 | Raleway | 14px | Small headings |
body | Raleway | 16px | Body text |
bodySmall | Raleway | 14px | Small body text |
quote1 | Cinzel | 32px | Large quotes |
quote2 | Cinzel | 21px | Medium quotes |
caption | Raleway | 14px | Italic captions |
btn | Raleway | 14px | Button text |
dropCase | Cinzel | 56px | Drop capitals |
_createFont() method which handles:
- DPI scaling based on device size
- Line height calculation
- Letter spacing (as percentage)
- Font weight
Responsive Scaling
TheAppStyle class implements device-aware scaling (lib/styles/styles.dart:10-25):
- Text sizes
- Spacing/insets
- All size-dependent values
Spacing & Layout
Insets
Consistent spacing values scaled by device (lib/styles/styles.dart:222-234):
$styles.insets.md
Corners
Border radius values (lib/styles/styles.dart:207-211):
Sizes
Layout constraints (lib/styles/styles.dart:214-219):
Shadows
Text shadow presets (lib/styles/styles.dart:237-247):
Usage Example
Accessing the Theme
The global$styles instance provides access to all theming values: