Skip to content

Commit 312fad4

Browse files
committed
docs(web-dashboard): add theming and customization guide
- Explain the theming system in the web dashboard - Describe how to customize colors using flex_color_scheme - Provide instructions for changing font and spacing - Include file paths and code examples for theming customization
1 parent 3a5d12a commit 312fad4

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: Theming & Customization
3+
description: A developer's guide to customizing the visual appearance of the web dashboard.
4+
---
5+
6+
The web dashboard's visual theme is managed through a centralized and flexible system, making it easy to customize the appearance to match your brand. The theming is handled within the shared `ui_kit` package, primarily in the `packages/ui-kit/lib/src/theme/app_theme.dart` file.
7+
8+
### Theming with `flex_color_scheme`
9+
10+
We use the powerful [`flex_color_scheme`](https://pub.dev/packages/flex_color_scheme) package to create and manage our `ThemeData`. This package simplifies the process of creating consistent and beautiful color schemes and component themes.
11+
12+
The core of the theming is in the `lightTheme()` and `darkTheme()` functions in `app_theme.dart`.
13+
14+
### Customizing Colors
15+
16+
You can change the entire color palette of the dashboard by modifying the `FlexScheme` used.
17+
18+
1. **Open `app.dart`:** Navigate to `apps/flutter-news-app-web-dashboard-full-source-code/lib/app/view/app.dart`.
19+
2. **Locate the Theme Generation:** Find the `build` method of the `_AppViewState` widget.
20+
3. **Change the `FlexScheme`:** The `accentTheme` from the user's settings is converted to a `FlexScheme`. You can change which `AppAccentTheme` enum value is the default in the `AppBloc` or modify the `toFlexScheme` extension to use different schemes from the `FlexScheme` enum.
21+
22+
```dart title="lib/app/view/app.dart"
23+
extension AppAccentThemeExtension on AppAccentTheme {
24+
FlexScheme get toFlexScheme {
25+
switch (this) {
26+
case AppAccentTheme.defaultBlue:
27+
// Change this to another FlexScheme, e.g., FlexScheme.deepPurple
28+
return FlexScheme.materialHc;
29+
case AppAccentTheme.newsRed:
30+
return FlexScheme.redWine;
31+
case AppAccentTheme.graphiteGray:
32+
return FlexScheme.outerSpace;
33+
}
34+
}
35+
}
36+
```
37+
38+
### Customizing Fonts
39+
40+
The application uses Google Fonts by default. You can change the default font or add new ones.
41+
42+
1. **Open `app_theme.dart`:** Navigate to `packages/ui-kit/lib/src/theme/app_theme.dart`.
43+
2. **Modify `_getGoogleFontTextTheme`:** This function maps a font family name (string) to a `GoogleFonts` text theme function. You can add new cases for other fonts available in the `google_fonts` package.
44+
3. **Update `_supportedFontFamilies`:** In `apps/flutter-news-app-web-dashboard-full-source-code/lib/settings/view/settings_page.dart`, add the new font family name to the `_supportedFontFamilies` list to make it available in the user's settings.
45+
46+
### Customizing Spacing
47+
48+
Consistent spacing is managed by the `AppSpacing` class in `packages/ui-kit/lib/src/constants/app_spacing.dart`. If you need to adjust the global spacing values (e.g., change the small spacing from `8.0` to `10.0`), you can do so in this file, and the changes will be reflected across the entire application.

0 commit comments

Comments
 (0)