Commit 461ee79
committed
feat: Major Project Refactoring and New 'Hello World (with template)' Feature
This commit introduces a significant refactoring of the iOS project, reorganizing the codebase into a more modular and maintainable structure. All feature-specific code has been moved into a new `Features` directory, while shared components (Models, Views) are now centralized under a `Shared` directory.
Key changes include:
- **Project Structure Reorganization**:
- Created `FirebaseAIExample/Features` to house individual feature modules (e.g., `Chat`, `FunctionCalling`, `GenerativeAIText`, `Grounding`, `Imagen`, `Multimodal`).
- Created `FirebaseAIExample/Shared` for common models, views, and utilities.
- Updated `FirebaseAIExample.xcodeproj/project.pbxproj` to reflect the new file paths and group structure.
- **New Feature: 'Hello world (with template)'**:
- Implemented `GenerateContentFromTemplateScreen` and `GenerateContentFromTemplateViewModel` under `Features/GenerativeAIText`.
- This feature demonstrates server-side template generation using the `apple-qs-greeting` template.
- Registered the new feature in `ContentView` and added a corresponding `Sample` entry in `Sample.swift` with the title "Hello world (with template)".
- **Bug Fixes and Best Practices**:
- **Security Fix**: Replaced insecure API key initialization in `GenerateContentFromTemplateViewModel` with the secure `FirebaseAI.firebaseAI(backend:)` factory method.
- **Compile Error Resolution**: Moved shared UI components (`ProgressOverlay.swift`, `ErrorDetailsView.swift`) into `FirebaseAIExample/Shared/Views` to resolve compile errors and ensure global accessibility.
- **Centralized BackendOption**: Extracted the `BackendOption` enum into its own file (`FirebaseAIExample/Shared/Models/BackendOption.swift`) for better code organization and reusability.
This refactoring significantly improves the project's scalability, readability, and adherence to modern Swift/SwiftUI architectural patterns.1 parent bfba576 commit 461ee79
File tree
38 files changed
+537
-685
lines changed- firebaseai
- FirebaseAIExample.xcodeproj
- FirebaseAIExample
- Assets.xcassets/AppIcon.appiconset
- Features
- Chat
- Models
- Screens
- ViewModels
- Views
- FunctionCalling
- Screens
- Services
- ViewModels
- GenerativeAIText
- Screens
- ViewModels
- Grounding
- Screens
- ViewModels
- Views
- Imagen
- Multimodal
- Models
- Screens
- ViewModels
- Views
- GenerativeAITextExample
- Screens
- ViewModels
- Preview Content/Preview Assets.xcassets
- MultimodalExample/Preview Content/Preview Assets.xcassets
38 files changed
+537
-685
lines changedLarge diffs are not rendered by default.
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
4 | 27 | | |
5 | 28 | | |
6 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 16 | + | |
24 | 17 | | |
25 | 18 | | |
26 | 19 | | |
| |||
107 | 100 | | |
108 | 101 | | |
109 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
110 | 107 | | |
111 | 108 | | |
112 | 109 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
0 commit comments