From fa7d72ace1e5a2b13a2cbf43310fc3bbcd3c6f90 Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Fri, 16 Jan 2026 09:49:44 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20Kh=E1=BB=9Fi=20t=E1=BA=A1o=20d=E1=BB=B1?= =?UTF-8?q?=20=C3=A1n=20Swift=20c=C6=A1=20b=E1=BA=A3n=20v=E1=BB=9Bi=20c?= =?UTF-8?q?=E1=BA=A5u=20h=C3=ACnh=20Git=20v=C3=A0=20k=E1=BA=BF=20ho?= =?UTF-8?q?=E1=BA=A1ch=20ki=E1=BB=83m=20th=E1=BB=AD=20XCTest.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/app-client-base-swift/AppClientBaseSwift | 1 + .../AppClientBaseSwift.xctestplan | 33 ++++ apps/app-client-base-swift/README.md | 165 ++++++++++++++++++ 3 files changed, 199 insertions(+) create mode 160000 apps/app-client-base-swift/AppClientBaseSwift create mode 100644 apps/app-client-base-swift/AppClientBaseSwift.xctestplan create mode 100644 apps/app-client-base-swift/README.md diff --git a/apps/app-client-base-swift/AppClientBaseSwift b/apps/app-client-base-swift/AppClientBaseSwift new file mode 160000 index 00000000..9f3cfadc --- /dev/null +++ b/apps/app-client-base-swift/AppClientBaseSwift @@ -0,0 +1 @@ +Subproject commit 9f3cfadcc31a96c4dc40437b186a0af22e83e465 diff --git a/apps/app-client-base-swift/AppClientBaseSwift.xctestplan b/apps/app-client-base-swift/AppClientBaseSwift.xctestplan new file mode 100644 index 00000000..1ba872ce --- /dev/null +++ b/apps/app-client-base-swift/AppClientBaseSwift.xctestplan @@ -0,0 +1,33 @@ +{ + "configurations" : [ + { + "id" : "C5F2D2E7-8F4A-4B3C-9D1E-6A5B4C3D2E1F", + "name" : "Test Scheme Action", + "options" : { + + } + } + ], + "defaultOptions" : { + "testTimeoutsEnabled" : true + }, + "testTargets" : [ + { + "parallelizable" : true, + "target" : { + "containerPath" : "container:AppClientBaseSwift.xcodeproj", + "identifier" : "AppClientBaseSwiftTests", + "name" : "AppClientBaseSwiftTests" + } + }, + { + "parallelizable" : true, + "target" : { + "containerPath" : "container:AppClientBaseSwift.xcodeproj", + "identifier" : "AppClientBaseSwiftUITests", + "name" : "AppClientBaseSwiftUITests" + } + } + ], + "version" : 1 +} diff --git a/apps/app-client-base-swift/README.md b/apps/app-client-base-swift/README.md new file mode 100644 index 00000000..4c5146f2 --- /dev/null +++ b/apps/app-client-base-swift/README.md @@ -0,0 +1,165 @@ +# App Client Base Swift + +Ứng dụng iOS native cho nền tảng GoodGo, xây dựng bằng Swift và SwiftUI. + +## 📱 Tổng quan + +App client iOS native sử dụng kiến trúc MVVM với SwiftUI, tương tự như `app-client-base-net` (MAUI) nhưng dành riêng cho nền tảng Apple. + +## 🛠️ Công nghệ + +| Công nghệ | Phiên bản | Mục đích | +|-----------|-----------|----------| +| Swift | 5.9+ | Ngôn ngữ lập trình | +| SwiftUI | iOS 15+ | UI Framework | +| Xcode | 15+ | IDE | +| URLSession | Native | Networking | +| Keychain | Native | Secure Storage | + +## 📂 Cấu trúc thư mục + +``` +AppClientBaseSwift/ +├── App/ +│ └── AppClientBaseSwiftApp.swift # @main entry point +├── Core/ +│ ├── Constants/ +│ │ └── Constants.swift # App-wide constants +│ └── Extensions/ +│ ├── View+Extensions.swift # SwiftUI View helpers +│ └── String+Extensions.swift # String utilities +├── Models/ +│ └── User.swift # User data model +├── ViewModels/ +│ └── HomeViewModel.swift # MVVM ViewModel +├── Views/ +│ └── Screens/ +│ ├── ContentView.swift # Main tab container +│ ├── WelcomeView.swift # Onboarding screen +│ ├── HomeView.swift # Home tab +│ ├── ExploreView.swift # Explore tab +│ └── ProfileView.swift # Profile tab +├── Services/ +│ ├── APIService.swift # HTTP client +│ └── AuthManager.swift # Authentication +├── Resources/ +│ ├── Assets.xcassets/ # Images & Colors +│ ├── en.lproj/ # English strings +│ └── vi.lproj/ # Vietnamese strings +└── Info.plist # App configuration +``` + +## 🚀 Bắt đầu + +### Yêu cầu + +- macOS 14.0+ (Sonoma) +- Xcode 15.0+ +- iOS 15.0+ target + +### Mở project + +1. Mở Xcode +2. Chọn **File > Open** hoặc nhấn `⌘O` +3. Chọn thư mục `app-client-base-swift` +4. Build và chạy trên Simulator (`⌘R`) + +### Tạo Xcode Project (Nếu chưa có) + +Do project này chỉ chứa source files, bạn cần tạo Xcode project: + +```bash +# Mở Xcode và tạo project mới +# 1. File > New > Project +# 2. Chọn "App" template +# 3. Product Name: AppClientBaseSwift +# 4. Team: Chọn team của bạn +# 5. Organization Identifier: vn.goodgo +# 6. Interface: SwiftUI +# 7. Language: Swift +# 8. Lưu vào thư mục app-client-base-swift +# 9. Xóa các file generated và thay thế bằng files trong thư mục này +``` + +## 🎨 Kiến trúc + +### MVVM Pattern + +``` +┌─────────────────────────────────────────────────────────────┐ +│ VIEW (SwiftUI) │ +│ ContentView, HomeView, ExploreView, ProfileView │ +├─────────────────────────────────────────────────────────────┤ +│ │ +│ ┌──────────────────────────────────┐ │ +│ │ @StateObject │ │ +│ │ @EnvironmentObject │ │ +│ └──────────────────────────────────┘ │ +│ │ │ +├────────────────────────────▼────────────────────────────────┤ +│ VIEWMODEL │ +│ HomeViewModel (ObservableObject) │ +│ - @Published properties │ +│ - async/await methods │ +├─────────────────────────────────────────────────────────────┤ +│ │ +│ ┌──────────────────────────────────┐ │ +│ │ Protocol / Dependency │ │ +│ │ Injection │ │ +│ └──────────────────────────────────┘ │ +│ │ │ +├────────────────────────────▼────────────────────────────────┤ +│ SERVICES │ +│ APIService, AuthManager │ +└─────────────────────────────────────────────────────────────┘ +``` + +### Key Features + +- **SwiftUI**: UI declarative hiện đại +- **Async/Await**: Xử lý bất đồng bộ native +- **Keychain**: Lưu trữ token bảo mật +- **Localization**: Hỗ trợ đa ngôn ngữ (VI/EN) +- **Dark Mode**: Hỗ trợ giao diện tối + +## 📋 Conventions + +### Coding Style + +```swift +// ViewModel với ObservableObject +@MainActor +class HomeViewModel: ObservableObject { + @Published var isLoading: Bool = false + + func loadData() async { + // Async data loading + } +} + +// View với MVVM binding +struct HomeView: View { + @StateObject private var viewModel = HomeViewModel() + + var body: some View { + // SwiftUI body + } +} +``` + +### Comments (Bilingual) + +```swift +/// Load home screen data +/// Tải dữ liệu màn hình home +func loadData() async { } +``` + +## 🔗 Liên kết + +- [app-client-base-net](../app-client-base-net) - .NET MAUI client +- [web-client](../web-client) - Web client + +## 📄 License + +Copyright © 2026 GoodGo. All rights reserved.