NavigationBar بعلامات تبويب متعددة
بدّل بين الأقسام الرئيسية من الأسفل
NavigationBar بعلامات تبويب متعددة درس مجاني في Jetpack Compose Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Jetpack Compose Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Meet NavigationBar
Material 3 gives you NavigationBar, a bar pinned to the bottom that lets people jump between the top-level sections of your app. 📱
When to Use It
Reach for a NavigationBar when your app has three to five equally important destinations, like Home, Search, and Profile.
It Lives in the Scaffold
You usually drop the bar into a Scaffold bottomBar slot, so it stays fixed while the screen content scrolls above it.
Scaffold(
bottomBar = { NavigationBar { /* items */ } }
) { padding -> Content(padding) }Each Tab Is an Item
Inside the bar you add one NavigationBarItem per destination. Each item is a clickable tab with its own icon and label.
NavigationBar {
NavigationBarItem(/* ... */)
NavigationBarItem(/* ... */)
}The selected Flag
Every item needs a selected boolean. Exactly one item should be true at a time so the bar shows where the user is.
NavigationBarItem(
selected = current == "home",
onClick = { go("home") }
)Handle the Tap
The onClick lambda runs when the tab is pressed. This is where you tell your navigation to switch to that section.
Give It an Icon
The icon slot takes a Composable, usually an Icon from the Material set, so each tab is instantly recognizable.
icon = { Icon(Icons.Default.Home, contentDescription = "Home") }Add a Label
The label slot shows short text under the icon. Keep it to one clear word so it fits and reads fast.
label = { Text("Home") }A Model for Tabs
It helps to keep your tabs in a simple data class list, so the bar can loop over them instead of hard-coding each item.
data class Tab(val route: String, val icon: ImageVector, val label: String)Loop to Build the Bar
With a tab list you can forEach over it and emit one NavigationBarItem per entry, keeping the bar tidy and easy to extend.
tabs.forEach { tab ->
NavigationBarItem(/* uses tab fields */)
}Pair It with Content
The bar only switches the active section. You still pair it with a NavHost or a when block that actually swaps the screen content.
Quick Check
You added three tabs to your NavigationBar. Quick check on the basics.
Recap
You met NavigationBar: drop it in the Scaffold, add a NavigationBarItem per section with an icon, label, selected flag, and onClick. Nice work! 🎉
الأسئلة الشائعة
هل درس «NavigationBar بعلامات تبويب متعددة» مجاني؟
نعم — نص درس «NavigationBar بعلامات تبويب متعددة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Jetpack Compose Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.
ماذا ستتعلم في «NavigationBar بعلامات تبويب متعددة»؟
بدّل بين الأقسام الرئيسية من الأسفل تتمرن على Jetpack Compose Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Jetpack Compose Academy؟
لا تُشترط خبرة سابقة. Jetpack Compose Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «NavigationBar بعلامات تبويب متعددة»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Jetpack Compose Academy هذا؟
نعم. كل درس في Jetpack Compose Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- NavigationBar بعلامات تبويب متعددة
- تمييز المسار المحدد
- الحفاظ على حالة علامات التبويب عند التبديل
- TabRow والصفحات القابلة للسحب