ရိုးရိုးလေး ရှင်းပြမယ်
Mini Project Part 3: Todo App — Polish & Navigation ကို ရိုးရိုးလေးနားလည်မယ်
Empty state (todo list ဗလာဖြစ်နေရင် 'No todos yet!' ပြသခြင်း) က UX polish ရဲ့ အရေးကြီးတဲ့ အစိတ်အပိုင်းပါ — FlatList ရဲ့ ListEmptyComponent prop ကို သုံးပြီး implement လုပ်လို့ရပါတယ်။ Todo item ကို press လိုက်ရင် Detail screen ဆီ navigate (React Navigation, ယခင်အခန်းများကနေ) လုပ်ပြီး, todo ရဲ့ full detail/edit screen ကို ပြသနိုင်ပါတယ်။
Problem → Why → Solution
ပြဿနာ — ဘာကြောင့် ဒီ concept လိုတာလဲ
Delete button ကို TouchableOpacity outer (item press) ထဲမှာ nest ထားပြီး, delete icon ကို press လိုက်တာနဲ့ item detail navigate ပါ ချက်ချင်း trigger ဖြစ်ခြင်း (event propagation issue — stopPropagation logic လိုအပ်နိုင်)
ဖြစ်လေ့ရှိတဲ့အမှား
Empty state ကို implement မလုပ်ဘဲ blank screen အဖြစ် ထားခဲ့ခြင်း — user confuse ဖြစ်နိုင်
Core Concept — အလုပ်လုပ်ပုံကိုနားလည်မယ်
Mini Project Part 3: Todo App — Polish & Navigation ကို Debug build တစ်ခုတည်းဖြင့်မဆုံးဖြတ်ဘဲ release device ပေါ်တွင် startup, JS/UI frame rate, memory, network, crash recovery, permissions, signing နဲ့ store requirements ဖြင့်စစ်ပါ။ New Architecture compatibility နဲ့ dependency support ကို upgrade တိုင်းအတည်ပြုပါ။
- Project requirements
- Components + state + services
- စမ်းသပ်ပြီး UI
Mini Project Part 3: Todo App — Polish & Navigation ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်
အဓိက Syntax / Pattern
<FlatList
data={todos}
keyExtractor={(item) => item.id}
ListEmptyComponent={
<Text style={styles.emptyText}>No todos yet! Add one above 👆</Text>
}
renderItem={({ item }) => (
<TouchableOpacity
style={styles.todoItem}
onPress={() => navigation.navigate('TodoDetail', { todoId: item.id })}
>
<Text>{item.done ? '☑️' : '☐'} {item.text}</Text>
<TouchableOpacity onPress={() => deleteTodo(item.id)}>
<Text>🗑️</Text>
</TouchableOpacity>
</TouchableOpacity>
)}
/>Mini Project Part 3: Todo App — Polish & Navigation ကို Debug build တစ်ခုတည်းဖြင့်မဆုံးဖြတ်ဘဲ release device ပေါ်တွင် startup, JS/UI frame rate, memory, network, crash recovery, permissions, signing နဲ့ store requirements ဖြင့်စစ်ပါ။ New Architecture compatibility နဲ့ dependency support ကို upgrade တိုင်းအတည်ပြုပါ။
Code ကို အဆင့်လိုက်ဖတ်မယ်
- Project requirements
<FlatListEmpty state (todo list ဗလာဖြစ်နေရင် 'No todos yet!' ပြသခြင်း) က UX polish ရဲ့ အရေးကြီးတဲ့ အစိတ်အပိုင်းပါ — FlatList ရဲ့ ListEmptyComponent prop ကို သုံးပြီး implement လုပ်လို့ရပါတယ်။ Todo item ကို press လိုက်ရင် Detail screen ဆီ navigate (React Navigation, ယခင်အခန်းများကနေ) လုပ်ပြီး, todo ရဲ့ full detail/edit screen ကို ပြသနိုင်ပါတယ်။
- Components + state + services
onPress={() => navigation.navigate('TodoDetail', { to...Mini Project Part 3: Todo App — Polish & Navigation ကို Debug build တစ်ခုတည်းဖြင့်မဆုံးဖြတ်ဘဲ release device ပေါ်တွင် startup, JS/UI frame rate, memory, network, crash recovery, permissions, signing နဲ့ store requirements ဖြင့်စစ်ပါ။ New Architecture compatibility နဲ့ dependency support ကို upgrade တိုင်းအတည်ပြုပါ။
- စမ်းသပ်ပြီး UI
/>Mini Project Part 3: Todo App — Polish & Navigation example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။
- Project requirements
- Components + state + services
- စမ်းသပ်ပြီး UI
Success
Mini Project Part 3: Todo App — Polish & Navigation ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်
Failure
Delete button ကို TouchableOpacity outer (item press) ထဲမှာ nest ထားပြီး, delete icon ကို press လိုက်တာနဲ့ item detail navigate ပါ ချက်ချင်း trigger ဖြစ်ခြင်း (event propagation issue — stopPropagation logic လိုအပ်နိုင်)
ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
Empty state (todo list ဗလာဖြစ်နေရင် 'No todos yet!' ပြသခြင်း) က UX polish ရဲ့ အရေးကြီးတဲ့ အစိတ်အပိုင်းပါ — FlatList ရဲ့ ListEmptyComponent prop ကို သုံးပြီး implement လုပ်လို့ရပါတယ်။ Todo item ကို press လိုက်ရင် Detail screen ဆီ navigate (React Navigation, ယခင်အခန်းများကနေ) လုပ်ပြီး, todo ရဲ့ full detail/edit screen ကို ပြသနိုင်ပါတယ်။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
FlatList ThemeListEmptyComponent={<Text>No todos yet! Add one above.</Text>} ကို ထည့်ရင် todos array ဗလာဖြစ်ချိန်မှာသာ ပေါ်ပါတယ်။ Todo item ရဲ့ onPress ကို navigation.navigate('TodoDetail', { todoId: item.id }) ဖြင့် ချိတ်ဆက်ပြီး, TodoDetail screen ထဲမှာ route.params.todoId ကနေ todo ကို ရှာပြသနိုင်ပါတယ် (React Navigation ရဲ့ route params pattern)။
Code နမူနာ
<FlatList
data={todos}
keyExtractor={(item) => item.id}
ListEmptyComponent={
<Text style={styles.emptyText}>No todos yet! Add one above 👆</Text>
}
renderItem={({ item }) => (
<TouchableOpacity
style={styles.todoItem}
onPress={() => navigation.navigate('TodoDetail', { todoId: item.id })}
>
<Text>{item.done ? '☑️' : '☐'} {item.text}</Text>
<TouchableOpacity onPress={() => deleteTodo(item.id)}>
<Text>🗑️</Text>
</TouchableOpacity>
</TouchableOpacity>
)}
/>Todo list ဗလာနေချိန် empty state message ပေါ်ပြီး, todo item ကို press လိုက်ရင် Detail screen ဆီ navigate ဖြစ်သွားမည်။၅ မိနစ် စမ်းကြည့်
Todo App ကို ListEmptyComponent + navigation (Detail screen) ဖြင့် ပြီးပြည့်စုံအောင် ဆက်လက် တည်ဆောက်ကြည့်ပါ — ဒါက tutorial တစ်ခုလုံးရဲ့ capstone project ဖြစ်ပါတယ်။
သတိလေးတစ်ချက်
Nested TouchableOpacity (item press + delete button press) ကို React Native မှာ event bubbling behavior က platform (iOS/Android) အလိုက် အနည်းငယ် ကွာနိုင်ပါတယ် — device နှစ်မျိုးလုံးမှာ test လုပ်ကြည့်ပါ။
Real-world usage
လက်တွေ့ Project မှာ ဘယ်လိုသုံးမလဲ
Mini Project Part 3: Todo App — Polish & Navigation example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။
Mini challenge
ကိုယ်တိုင်တည်ဆောက်ကြည့်ပါ
Mini Project Part 3: Todo App — Polish & Navigation example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။
- Example ကို copy မလုပ်ဘဲ ပြန်ရေးပါ
- Normal input နဲ့ edge case စမ်းပါ
- Run မလုပ်မီ compiler/output result ကိုခန့်မှန်းပါ
<FlatList
data={todos}
keyExtractor={(item) => item.id}
ListEmptyComponent={
<Text style={styles.emptyText}>No todos yet! Add one above 👆</Text>
}
renderItem={({ item }) => (
<TouchableOpacity
style={styles.todoItem}
onPress={() => navigation.navigate('TodoDetail', { todoId: item.id })}
>
<Text>{item.done ? '☑️' : '☐'} {item.text}</Text>
<TouchableOpacity onPress={() => deleteTodo(item.id)}>
<Text>🗑️</Text>
</TouchableOpacity>
</TouchableOpacity>
)}
/>ရလဒ်: Mini Project Part 3: Todo App — Polish & Navigation ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်
အရိပ်အမြွက် ကြည့်ရန်
Mini Project Part 3: Todo App — Polish & Navigation example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။
Quick Quiz 1 / 3
Quick Quiz 2 / 3
Quick Quiz 3 / 3
ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ
- Project requirements → Components + state + services → စမ်းသပ်ပြီး UI
- Mini Project Part 3: Todo App — Polish & Navigation ကို Debug build တစ်ခုတည်းဖြင့်မဆုံးဖြတ်ဘဲ release device ပေါ်တွင် startup, JS/UI frame rate, memory, network, crash recovery, permissions, signing နဲ့ store requirements ဖြင့်စစ်ပါ။ New Architecture compatibility နဲ့ dependency support ကို upgrade တိုင်းအတည်ပြုပါ။
- Delete button ကို TouchableOpacity outer (item press) ထဲမှာ nest ထားပြီး, delete icon ကို press လိုက်တာနဲ့ item detail navigate ပါ ချက်ချင်း trigger ဖြစ်ခြင်း (event propagation issue — stopPropagation logic လိုအပ်နိုင်)
- Mini Project Part 3: Todo App — Polish & Navigation example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။
React Native Documentation — React Native