Skip to content

Commit 1301bdd

Browse files
authored
Merge pull request #9 from flutter-news-app-full-source-code/packages_docs
Packages docs
2 parents d8c318b + c8c6232 commit 1301bdd

File tree

11 files changed

+313
-94
lines changed

11 files changed

+313
-94
lines changed

astro.config.mjs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,29 @@ export default defineConfig({
2020
{ label: 'Core Philosophy', link: '/core-philosophy' },
2121
{ label: 'Local Setup', link: '/local-setup' },
2222
{ label: 'Deployment', link: '/deployment' },
23+
{
24+
label: 'Architecture & Customization',
25+
collapsed: true,
26+
items: [
27+
{
28+
label: 'Overview',
29+
link: '/architecture/index',
30+
},
31+
32+
{
33+
label: 'Understanding the Toolkit Architecture',
34+
link: '/architecture/toolkit-architecture',
35+
},
36+
{
37+
label: 'Taking Ownership of Packages',
38+
link: '/architecture/taking-ownership-of-packages',
39+
},
40+
{
41+
label: 'Guide: Customizing the UI Theme',
42+
link: '/architecture/guide-customizing-the-ui',
43+
},
44+
],
45+
},
2346
{
2447
label: 'API Server',
2548
collapsed: true,
@@ -36,7 +59,6 @@ export default defineConfig({
3659
{ label: 'Email Service', link: '/api-server/features/email-service' },
3760
{ label: 'Data Management', link: '/api-server/features/data-management-api' },
3861
{ label: 'RBAC', link: '/api-server/features/rbac' },
39-
{ label: 'Error Handling', link: '/api-server/features/error-handling' },
4062
],
4163
},
4264
{
@@ -59,6 +81,7 @@ export default defineConfig({
5981
{ label: 'Middleware', link: '/api-server/architecture/middleware' },
6082
{ label: 'Data Seeding & Fixtures', link: '/api-server/architecture/data-seeding-and-fixtures' },
6183
{ label: 'Generic Data Endpoint', link: '/api-server/architecture/generic-data-endpoint' },
84+
{ label: 'Error Handling', link: '/api-server/features/error-handling' },
6285
],
6386
},
6487
{
@@ -103,7 +126,7 @@ export default defineConfig({
103126
label: 'Guides',
104127
collapsed: true,
105128
items: [
106-
{ label: 'Theming & Customization', link: '/web-dashboard/guides/theming-and-customization' },
129+
{ label: 'Styling & Theming', link: '/web-dashboard/guides/styling-and-theming' },
107130
{ label: 'Localization', link: '/web-dashboard/guides/localization' },
108131
],
109132
},
File renamed without changes.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: 'Guide: Customizing the UI Theme'
3+
description: A practical, step-by-step guide to customizing the UI theme by taking ownership of the ui_kit package.
4+
---
5+
import { Steps, Aside } from '@astrojs/starlight/components';
6+
7+
This guide provides a hands-on, practical walkthrough of the most common and impactful customization task: changing the application's visual theme.
8+
9+
By following this guide, you will learn the complete, end-to-end workflow for modifying a shared package and seeing that change reflected in both the Mobile Client and the Web Dashboard. This process is the key to unlocking the full customization potential of the toolkit.
10+
11+
### The Goal
12+
13+
Our goal is to change the default blue accent color of the application to a new color, for example, deep purple. To do this, we will take ownership of the `ui_kit` package, modify its theme file, and then instruct both of our Flutter applications to use our modified version.
14+
15+
<Steps>
16+
1. **Take Ownership of the `ui_kit` Package**
17+
18+
Before you can change any code, you must have your own version of the `ui_kit` package hosted in a private repository.
19+
20+
- Follow the [**Taking Ownership of Packages**](/docs/architecture/02-taking-ownership-of-packages/) guide from start to finish, but for the `ui_kit` repository.
21+
- **Clone URL:** `https://github.com/flutter-news-app-full-source-code/ui-kit.git`
22+
23+
Once you have successfully pushed the `ui_kit` code to your own private GitHub repository, you are ready to proceed.
24+
25+
2. **Modify the Theme Code**
26+
27+
Now, open the `ui_kit` package you cloned to your local machine in your code editor (e.g., VS Code).
28+
29+
- Navigate to and open the file: `lib/src/theme/app_theme.dart`.
30+
- Locate the `_commonSubThemesData` constant. This is where you can make global changes to widget styles.
31+
- Let's change the `appBarBackgroundSchemeColor` to `primary` to make the app bar more prominent.
32+
33+
```dart title="packages/ui-kit/lib/src/theme/app_theme.dart"
34+
const FlexSubThemesData _commonSubThemesData = FlexSubThemesData(
35+
// ...
36+
// Change the app bar background color
37+
appBarBackgroundSchemeColor: SchemeColor.primary, // Changed from .surface
38+
// ...
39+
);
40+
```
41+
42+
3. **Commit and Push Your Changes**
43+
44+
Save the file, then commit and push this change to *your private* `ui_kit` repository.
45+
46+
```bash
47+
# From inside your local ui_kit directory
48+
git add .
49+
git commit -m "feat: change app bar theme color"
50+
git push
51+
```
52+
53+
4. **Update the Mobile Client**
54+
55+
Now it's time to see your change in action. Open the **Mobile Client** project (`flutter-news-app-mobile-client-full-source-code`) in your code editor.
56+
57+
- Open the `pubspec.yaml` file.
58+
- Locate the `ui_kit` dependency.
59+
- Change the `url` to point to your private repository's URL.
60+
61+
```yaml title="Mobile Client's pubspec.yaml"
62+
dependencies:
63+
# ... other dependencies
64+
ui_kit:
65+
git:
66+
# Replace this with the URL of YOUR private repository
67+
url: https://github.com/YOUR_USERNAME/YOUR_UI_KIT_REPO.git
68+
# ... other dependencies
69+
```
70+
71+
- Now, run `flutter pub upgrade` in the terminal for the Mobile Client project. This will fetch the updated code from your private repository.
72+
73+
```bash
74+
flutter pub upgrade ui_kit
75+
```
76+
77+
- Relaunch the mobile app (`flutter run`). You should now see your new theme color applied to the app bar!
78+
79+
5. **Update the Web Dashboard**
80+
81+
The final step is to apply the exact same change to the Web Dashboard, demonstrating the power of the shared package.
82+
83+
- Open the **Web Dashboard** project (`flutter-news-app-web-dashboard-full-source-code`).
84+
- Open its `pubspec.yaml` file.
85+
- Update the `ui_kit` dependency's `url` to point to your private repository, just as you did for the mobile client.
86+
- Run `flutter pub upgrade ui_kit` in the terminal for the Web Dashboard project.
87+
- Relaunch the web app (`flutter run -d chrome`). The dashboard will now also have the new app bar color.
88+
89+
</Steps>
90+
91+
### Conclusion
92+
93+
You have successfully completed the core customization workflow. You now have a privately owned and modified `ui_kit` package that is consumed by both of your client applications. You can use this exact same process to customize any other shared package in the toolkit.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: 'Architecture & Customization'
3+
description: Learn how the toolkit is structured and how to take full ownership of the shared packages to customize your applications.
4+
---
5+
import { Card, CardGrid } from '@astrojs/starlight/components';
6+
7+
Welcome to the Architecture & Customization section. This is the most important part of the documentation for developers who want to go beyond the default setup and truly make the toolkit their own.
8+
9+
Here, you will learn about the multi-repository philosophy that underpins the toolkit and, most importantly, follow a step-by-step, practical guide to customizing the shared UI package and seeing your changes reflected across both the mobile and web applications.
10+
11+
<CardGrid>
12+
<Card title="1. Understand the Toolkit Architecture" icon="file-tree">
13+
Start here to learn about the multi-repository structure and why it's designed this way.
14+
[Read more &rarr;](/docs/architecture/01-toolkit-architecture/)
15+
</Card>
16+
<Card title="2. Take Ownership of Packages" icon="key">
17+
Follow this critical guide to learn how to host the shared packages in your own private repositories.
18+
[Read more &rarr;](/docs/architecture/02-taking-ownership-of-packages/)
19+
</Card>
20+
<Card title="3. Practical Guide: Customize the UI" icon="palette">
21+
Put theory into practice with a hands-on tutorial for customizing the UI theme.
22+
[Read more &rarr;](/docs/architecture/03-guide-customizing-the-ui/)
23+
</Card>
24+
</CardGrid>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Taking Ownership of Packages
3+
description: A step-by-step guide to cloning, hosting, and managing the shared packages for customization.
4+
---
5+
import { Steps, Aside } from '@astrojs/starlight/components';
6+
7+
To unlock the full power of the Flutter News App Toolkit and make it truly your own, you must take ownership of the shared packages. The applications (Mobile Client, Web Dashboard) are designed to be customized, but the deepest and most impactful changes—like altering data models or redesigning the UI theme—happen within the shared packages.
8+
9+
This guide will walk you through the essential, one-time process of moving a shared package from the original public repository into your own private repository.
10+
11+
<Aside type="caution" title="Critical Step">
12+
This is the most important guide for customizing the toolkit. You must follow this process for **any shared package** you intend to modify.
13+
</Aside>
14+
15+
### Why You Must Host the Packages Yourself
16+
17+
- **To Enable Customization:** You cannot push changes to the original public repositories. To modify a package, you need your own version that you control.
18+
- **For Privacy and Control:** Hosting the packages in your own private repositories ensures that your proprietary changes, business logic, and customizations remain confidential.
19+
- **To Manage Updates:** It gives you full control over when and how you pull in future updates from the original toolkit.
20+
21+
### The Workflow: A Step-by-Step Guide
22+
23+
Let's walk through the process using the `core` package as an example. You will repeat these steps for any other package you wish to customize, such as `ui_kit` or `data_repository`.
24+
25+
<Steps>
26+
1. **Clone the Original Package Repository**
27+
28+
First, clone the package's repository from the public GitHub organization to your local machine. Make sure you are **not** inside another Git repository when you do this.
29+
30+
```bash
31+
# Clone the 'core' package repository
32+
git clone https://github.com/flutter-news-app-full-source-code/core.git
33+
34+
# Navigate into the newly cloned directory
35+
cd core
36+
```
37+
38+
2. **Create a New Private Repository on GitHub**
39+
40+
Go to your GitHub account and create a new **private** repository.
41+
- Name it appropriately (e.g., `my-company-core-package`).
42+
- **Do not** initialize it with a README, .gitignore, or license file, as we will be pushing an existing repository.
43+
44+
3. **Update the Git Remote URL**
45+
46+
Back in your terminal, inside the `core` directory you cloned, you need to change the Git "remote" from the original public repository to your new private one.
47+
48+
First, view the existing remote:
49+
```bash
50+
git remote -v
51+
# origin https://github.com/flutter-news-app-full-source-code/core.git (fetch)
52+
# origin https://github.com/flutter-news-app-full-source-code/core.git (push)
53+
```
54+
55+
Now, change the URL to point to your new private repository:
56+
```bash
57+
git remote set-url origin https://github.com/YOUR_USERNAME/YOUR_NEW_PRIVATE_REPO_NAME.git
58+
```
59+
Replace `YOUR_USERNAME` and `YOUR_NEW_PRIVATE_REPO_NAME` with your actual GitHub details.
60+
61+
4. **Push the Code to Your Private Repository**
62+
63+
Finally, push the package code to your new private repository.
64+
65+
```bash
66+
git push -u origin --all
67+
git push -u origin --tags
68+
```
69+
70+
</Steps>
71+
72+
**Congratulations!** You have now successfully taken ownership of the `core` package. It is now hosted in your private repository, and you are free to make any modifications you need.
73+
74+
The next step is to tell your applications (Mobile Client, Web Dashboard) to use *your* version of the package instead of the original one. The next guide, [**Guide: Customizing the UI Theme**](/docs/architecture/03-guide-customizing-the-ui/), will walk you through this process in a practical, hands-on example.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: Understanding the Toolkit Architecture
3+
description: An overview of the multi-repository architecture and how the apps and packages work together.
4+
---
5+
import { Card, CardGrid, Aside } from '@astrojs/starlight/components';
6+
7+
Welcome to the architectural overview of the Flutter News App Toolkit. Understanding the structure of the toolkit is the first and most important step to customizing it effectively and making it your own.
8+
9+
This toolkit is not a single, monolithic application. Instead, it is a collection of independent projects—three applications and a suite of shared packages—that work together. This is a deliberate and professional architectural choice that provides significant long-term benefits.
10+
11+
### The Multi-Repository Philosophy
12+
13+
The toolkit is divided into two main categories of repositories:
14+
15+
<CardGrid>
16+
<Card title="Applications" icon="laptop">
17+
These are the user-facing projects that you will build and deploy. Each one is a standalone application in its own repository.
18+
- **Mobile Client:** The Flutter app for iOS and Android.
19+
- **Web Dashboard:** The Flutter web app for administration.
20+
- **API Server:** The Dart Frog backend.
21+
</Card>
22+
<Card title="Shared Packages" icon="puzzle">
23+
These are Dart packages that contain shared code, logic, and UI components. They are consumed by the applications as dependencies.
24+
- **`core`**: Contains all shared data models and exceptions.
25+
- **`data_repository`**: Handles the business logic for data fetching.
26+
- **`ui_kit`**: Provides shared widgets, themes, and constants.
27+
- ...and many others.
28+
</Card>
29+
</CardGrid>
30+
31+
### Why Is It Structured This Way?
32+
33+
This decoupled, multi-repository approach is a best practice for building large, maintainable systems.
34+
35+
- **Code Reusability:** The `core` package ensures that the Mobile Client and the API Server are always using the exact same data models. The `ui_kit` ensures both Flutter apps have a consistent look and feel. This is the essence of **DRY (Don't Repeat Yourself)**.
36+
- **Separation of Concerns:** Each piece of the toolkit has a single, clear responsibility. The `auth_repository` only handles authentication logic. The `http_client` only handles making network requests. This makes the code easier to understand, test, and debug.
37+
- **Maintainability:** When you need to change the theme of your apps, you only need to edit the `ui_kit` package. When you need to add a new field to a data model, you only edit the `core` package. The changes then propagate to the consuming applications when you update the dependency.
38+
39+
### How It All Connects: `pubspec.yaml`
40+
41+
The link between the applications and the shared packages is the `pubspec.yaml` file in each application. When you first get the code, these files point to the original public GitHub repositories for each package.
42+
43+
```yaml title="Example from an app's pubspec.yaml"
44+
dependencies:
45+
# This app depends on the `core` package...
46+
core:
47+
# ...and it fetches it from this Git repository.
48+
git:
49+
url: https://github.com/flutter-news-app-full-source-code/core.git
50+
51+
# It also depends on the `ui_kit` package.
52+
ui_kit:
53+
git:
54+
url: https://github.com/flutter-news-app-full-source-code/ui-kit.git
55+
```
56+
57+
<Aside type="tip">
58+
To truly customize the toolkit, you will need to host these packages in your own private repositories and update this `pubspec.yaml` file to point to your versions. The next guide will walk you through this essential process.
59+
</Aside>

src/content/docs/deployment.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ title: 'Deployment: From Local to Live'
33
description: A collection of guides to help you deploy the API server, mobile app, and web dashboard to production environments.
44
---
55

6-
import { Steps } from '@astrojs/starlight/components';
6+
import { Steps, Aside } from '@astrojs/starlight/components';
77

88
Once you have the toolkit running on your local machine, the next step is to go live. These guides provide clear, step-by-step instructions for preparing and deploying each component of the toolkit to a production environment.
99

10+
<Aside type="note" title="Before You Deploy">
11+
It is highly recommended that you first complete the guides in the [**Architecture & Customization**](/docs/architecture/) section. This will ensure you have taken ownership of the shared packages and made any desired branding or functional changes before releasing your applications.
12+
</Aside>
13+
1014
<Steps>
1115
1. **Deploy the API Server**
1216

src/content/docs/local-setup.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@ We recommend following the guides in the order presented to ensure a smooth setu
2828

2929
[Go to Mobile App Setup Guide &rarr;](/docs/mobile-client/local-setup/)
3030
</Steps>
31+
32+
### Next Steps: Customize Your Toolkit
33+
34+
Congratulations! You now have the entire toolkit running locally. This is the perfect time to explore the architecture and learn how to make it your own.
35+
36+
The next logical step is to dive into our **Architecture & Customization** section, where you will learn how to take ownership of the shared packages and begin customizing your applications.
37+
38+
[**Go to Architecture & Customization &rarr;**](/docs/architecture/)

0 commit comments

Comments
 (0)