بناء نظام تصميم مخصص
وسّع السمة باستخدام رموزك الخاصة
بناء نظام تصميم مخصص درس مجاني في Jetpack Compose Academy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Jetpack Compose Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Beyond the Defaults
Real brands need more than Material's built-ins. A design system bundles your colors, type, shapes, and extra tokens into one reusable theme. 🏗️
Wrap MaterialTheme
You start by writing your own AppTheme Composable that configures MaterialTheme, giving the whole app a single, named entry point.
@Composable
fun AppTheme(content: @Composable () -> Unit) { /* ... */ }Pass Your Tokens In
Inside AppTheme you hand MaterialTheme your custom colorScheme, typography, and shapes, so every screen inherits your brand automatically.
MaterialTheme(
colorScheme = brandColors,
typography = brandType,
shapes = brandShapes
) { content() }Material Misses Some Tokens
Some brand values, like a success green or a custom spacing unit, have no Material role. You add these as your own extra tokens.
Hold Extra Colors
You group extra colors in a small data class, a tidy home for brand values Material does not provide out of the box.
data class BrandColors(
val success: Color,
val warning: Color
)CompositionLocal
To share custom tokens down the tree without passing parameters, you use a CompositionLocal, Compose's built-in ambient value mechanism.
Create the Local
You declare a staticCompositionLocalOf with a default, creating a channel any Composable can read your brand colors from.
val LocalBrand = staticCompositionLocalOf { defaultBrand }Provide the Values
In AppTheme you wrap content in a CompositionLocalProvider, feeding your brand tokens into the tree alongside MaterialTheme.
CompositionLocalProvider(LocalBrand provides brand) {
MaterialTheme(/* ... */) { content() }
}Read Custom Tokens
Anywhere below, a Composable reads LocalBrand.current to grab your custom values, mirroring how MaterialTheme exposes its own.
val success = LocalBrand.current.successOffer a Clean API
Many teams expose an object so calls read like AppTheme.brand.success, a friendly facade over the CompositionLocal underneath.
One Source of Truth
Now colors, type, shapes, and custom tokens all flow from a single theme, so the app stays consistent and effortless to evolve. ✨
Quick Check
You need a brand color Material has no role for, shared app-wide. What do you reach for?
Recap: Your Own Theme
You wrapped MaterialTheme in an AppTheme, added extra tokens via CompositionLocal, and gave your app one branded source of truth. 🎉
تعلم Kotlin مع معلم ذكاء اصطناعي — مجانًا
اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.
- الدورات
- 30
- الدروس
- 120
الأسئلة الشائعة
هل درس «بناء نظام تصميم مخصص» مجاني؟
نعم — نص درس «بناء نظام تصميم مخصص» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Jetpack Compose Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.
ماذا ستتعلم في «بناء نظام تصميم مخصص»؟
وسّع السمة باستخدام رموزك الخاصة تتمرن على Jetpack Compose Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Jetpack Compose Academy؟
لا تُشترط خبرة سابقة. Jetpack Compose Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «بناء نظام تصميم مخصص»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Jetpack Compose Academy هذا؟
نعم. كل درس في Jetpack Compose Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- MaterialTheme وأنظمة الألوان
- الطباعة ورموز الأشكال
- الوضع الداكن واللون الديناميكي
- بناء نظام تصميم مخصص