|
1 | 1 | ---
|
2 |
| -title: Theming & Customization |
| 2 | +title: 'Guide: Theming & Customization' |
3 | 3 | description: A developer's guide to customizing the visual appearance of the web dashboard.
|
4 | 4 | ---
|
| 5 | +import { Aside } from '@astrojs/starlight/components'; |
5 | 6 |
|
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 | +The visual appearance of the Web Dashboard—including colors, fonts, and spacing—is managed centrally to ensure consistency with the Mobile Client. This is achieved through a shared `ui_kit` package. |
7 | 8 |
|
8 |
| -### Theming with `flex_color_scheme` |
| 9 | +Because this is a cross-application concern, the primary, hands-on guide for making theme customizations is located in our new **Architecture & Customization** section. This central guide walks you through the entire process, from taking ownership of the `ui_kit` package to seeing your changes reflected in both the web and mobile apps. |
9 | 10 |
|
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 | +<Aside type="tip" title="Start Here for Customization"> |
| 12 | +To learn how to properly customize the UI, please follow our comprehensive, step-by-step tutorial: |
11 | 13 |
|
12 |
| -The core of the theming is in the `lightTheme()` and `darkTheme()` functions in `app_theme.dart`. |
| 14 | +[**Guide: Customizing the UI Theme →**](/docs/architecture/03-guide-customizing-the-ui/) |
| 15 | +</Aside> |
13 | 16 |
|
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. |
| 17 | +This approach ensures that you learn the correct workflow for modifying shared code, which is the key to unlocking the full power of the toolkit. |
0 commit comments