From 3d5a6cb218c89f0e346d7570fd97348760ce07c7 Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Thu, 15 Jan 2026 23:07:55 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20Th=C3=AAm=20c=C3=A1c=20t=C3=A0i=20li?= =?UTF-8?q?=E1=BB=87u=20h=C6=B0=E1=BB=9Bng=20d=E1=BA=ABn=20v=C3=A0=20tham?= =?UTF-8?q?=20kh=E1=BA=A3o=20m=E1=BB=9Bi=20cho=20k=E1=BB=B9=20n=C4=83ng=20?= =?UTF-8?q?MAUI=20Branding=20Expert=20v=C3=A0=20MAUI=20Enterprise=20Archit?= =?UTF-8?q?ect.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .agent/skills/maui-branding-expert/SKILL.md | 281 +++++++++++ .../guidelines/accessibility-rules.md | 101 ++++ .../guidelines/handler-customization.md | 446 ++++++++++++++++++ .../guidelines/resource-architecture.md | 344 ++++++++++++++ .../guidelines/typography-theme.md | 130 +++++ .../references/REFERENCE.md | 189 ++++++++ .../skills/maui-enterprise-architect/SKILL.md | 360 ++++++++++++++ .../guidelines/di-setup.md | 343 ++++++++++++++ .../guidelines/mvvm-rules.md | 294 ++++++++++++ .../guidelines/shell-nav.md | 308 ++++++++++++ .../guidelines/xaml-perf.md | 398 ++++++++++++++++ 11 files changed, 3194 insertions(+) create mode 100644 .agent/skills/maui-branding-expert/SKILL.md create mode 100644 .agent/skills/maui-branding-expert/guidelines/accessibility-rules.md create mode 100644 .agent/skills/maui-branding-expert/guidelines/handler-customization.md create mode 100644 .agent/skills/maui-branding-expert/guidelines/resource-architecture.md create mode 100644 .agent/skills/maui-branding-expert/guidelines/typography-theme.md create mode 100644 .agent/skills/maui-branding-expert/references/REFERENCE.md create mode 100644 .agent/skills/maui-enterprise-architect/SKILL.md create mode 100644 .agent/skills/maui-enterprise-architect/guidelines/di-setup.md create mode 100644 .agent/skills/maui-enterprise-architect/guidelines/mvvm-rules.md create mode 100644 .agent/skills/maui-enterprise-architect/guidelines/shell-nav.md create mode 100644 .agent/skills/maui-enterprise-architect/guidelines/xaml-perf.md diff --git a/.agent/skills/maui-branding-expert/SKILL.md b/.agent/skills/maui-branding-expert/SKILL.md new file mode 100644 index 00000000..2f44080b --- /dev/null +++ b/.agent/skills/maui-branding-expert/SKILL.md @@ -0,0 +1,281 @@ +--- +name: maui-branding-expert +description: Xây dựng hệ thống UI/UX chuẩn Enterprise cho .NET MAUI, bao gồm Resource Dictionary, Control Templates, Custom Handlers và Accessibility. Use for Design System, branding controls, hoặc khi cần standardized UI components. +compatibility: ".NET 9+ MAUI, CommunityToolkit.Maui 9+" +metadata: + author: Velik Ho + version: "1.0" + references: "Microsoft .NET MAUI Documentation, Enterprise Application Patterns" +--- + +# .NET MAUI Branding Controls Workflow + +Bạn là một chuyên gia về UI/UX và XAML trong .NET MAUI. Nhiệm vụ của bạn là hiện thực hóa Design System thành code có khả năng tái sử dụng cao (Reusability) và dễ bảo trì (Maintainability). **Tuyệt đối không hard-code màu sắc hay kích thước trực tiếp trong View.** + +## When to Use This Skill / Khi Nào Sử Dụng + +Use this skill when: +- Xây dựng Design System / UI Kit cho app +- Tạo custom branded controls (BrandButton, BrandEntry, CardView...) +- Thiết lập Resource Dictionary architecture +- Tùy chỉnh native controls với Handlers +- Đảm bảo Accessibility (WCAG) compliance + +**DO NOT use when:** +- Simple prototyping / Làm prototype nhanh +- Single-use UI components / Component dùng 1 lần +- Blazor Hybrid apps (use CSS/Blazor patterns) + +## Overview / Tổng Quan + +``` +┌──────────────────────────────────────────────────────────────────┐ +│ WORKFLOW XÂY DỰNG BRANDING CONTROLS │ +├──────────────────────────────────────────────────────────────────┤ +│ │ +│ ┌─────────────┐ ┌─────────────────┐ │ +│ │ PHASE 1 │────►│ PHASE 2 │ │ +│ │ RESOURCE │ │ CONTROL │ │ +│ │ DICTIONARY │ │ CUSTOMIZATION │ │ +│ │ - Colors │ │ - Styles (L1) │ │ +│ │ - Typography│ │ - Templates(L2) │ │ +│ │ - Theme │ │ - Handlers (L3) │ │ +│ └─────────────┘ └────────┬────────┘ │ +│ │ │ +│ ▼ │ +│ ┌─────────────┐ ┌─────────────────┐ │ +│ │ PHASE 4 │◄────│ PHASE 3 │ │ +│ │ ACCESSIBILITY│ │ HANDLER │ │ +│ │ │ │ MODIFICATION │ │ +│ │ - Semantic │ │ - AppendMapping │ │ +│ │ - HeadingLv │ │ - PlatformView │ │ +│ │ - FontScale │ │ - Partial Class │ │ +│ └─────────────┘ └─────────────────┘ │ +│ │ +└──────────────────────────────────────────────────────────────────┘ +``` + +--- + +## Phase 1: Resource Dictionary Architecture / Kiến Trúc Resource + +**Goal**: Tổ chức tài nguyên UI để dễ dàng thay đổi thương hiệu (Re-branding). + +**Detailed Guide**: [Resource Architecture](./guidelines/resource-architecture.md) + +### Nguyên tắc cốt lõi + +1. **Phân tách Resource** - Không gộp tất cả vào `App.xaml` + ``` + Resources/Styles/ + ├── Colors.xaml # Bảng màu (Color Palette) + ├── Typography.xaml # Font, FontSize, LineHeight + └── Theme.xaml # Styles cho controls + ``` + +2. **Merged Dictionaries** - Gộp files theo thứ tự ưu tiên trong `App.xaml` + +3. **AppThemeBinding** - Luôn định nghĩa màu cho cả Light/Dark Mode + +### Quick Pattern + +```xml + +{AppThemeBinding + Light=#2196F3, Dark=#64B5F6} +{AppThemeBinding + Light=#FFFFFF, Dark=#1E1E1E} +``` + +--- + +## Phase 2: Control Customization Strategy / Chiến Lược Tùy Biến + +**Goal**: Tùy chỉnh controls theo thứ tự ưu tiên phù hợp. + +**Detailed Guide**: [Handler Customization](./guidelines/handler-customization.md) + +### Thứ tự ưu tiên + +| Level | Method | Use When | +|-------|--------|----------| +| **L1** | XAML Styles + VSM | Thay đổi cơ bản (màu, bo góc, hover) | +| **L2** | ControlTemplate | Thay đổi cấu trúc visual hoàn toàn | +| **L3** | Handlers | Can thiệp Native API (bỏ underline, đổi cursor) | + +### Level 1: XAML Styles + +```xml + +``` + +### Level 2: ControlTemplate + +```xml + + + + + +``` + +### Level 3: Handlers (Advanced) + +```csharp +// BẮT BUỘC: Sử dụng AppendToMapping, KHÔNG dùng Custom Renderer +EntryHandler.Mapper.AppendToMapping("BrandEntry", (handler, view) => +{ +#if ANDROID + handler.PlatformView.SetBackgroundColor(Android.Graphics.Color.Transparent); +#elif IOS + handler.PlatformView.BorderStyle = UIKit.UITextBorderStyle.None; +#endif +}); +``` + +--- + +## Phase 3: Handler Modification / Sửa Đổi Handler + +**Goal**: Can thiệp sâu vào Native View một cách an toàn. + +**Detailed Guide**: [Handler Customization](./guidelines/handler-customization.md) + +### Key Patterns + +1. **AppendToMapping** - Thêm tùy chỉnh vào cuối chuỗi xử lý mặc định +2. **PrependToMapping** - Thêm vào đầu chuỗi (ít dùng) +3. **ModifyMapping** - Thay thế hoàn toàn (nguy hiểm, tránh dùng) + +### Cross-Platform Partial Classes + +Khi code native quá dài, tách thành Partial Classes: + +```csharp +// Services/BrandingService.cs (shared) +public partial class BrandingService +{ + public partial void ConfigureEntry(IEntry entry); +} + +// Platforms/Android/Services/BrandingService.cs +public partial class BrandingService +{ + public partial void ConfigureEntry(IEntry entry) + { + // Android-specific implementation + } +} +``` + +--- + +## Phase 4: Accessibility (Enterprise Required) / Tính Năng Truy Cập + +**Goal**: Tuân thủ chuẩn WCAG cho ứng dụng Enterprise. + +**Detailed Guide**: [Accessibility Rules](./guidelines/accessibility-rules.md) + +### Key Requirements + +1. **SemanticProperties** - Thay thế AutomationProperties (đã cũ) + ```xml +