1+ import {
2+ useRepo ,
3+ useRepoTopics ,
4+ useRepoReadme ,
5+ useRepoContents ,
6+ useCreateFork ,
7+ useBranches ,
8+ } from "../../../../lib/api/hooks" ;
19import {
210 ActivityIndicator ,
3- FlatList ,
411 Linking ,
512 Pressable ,
613 ScrollView ,
@@ -9,14 +16,6 @@ import {
916 Text ,
1017 View ,
1118} from "react-native" ;
12- import {
13- useRepo ,
14- useRepoTopics ,
15- useRepoReadme ,
16- useRepoContents ,
17- useCreateFork ,
18- useBranches ,
19- } from "../../../../lib/api/hooks" ;
2019import { LanguageDot } from "../../../../components/ui/LanguageDot" ;
2120import { Markdown } from "../../../../components/ui/Markdown" ;
2221import { useLocalSearchParams , useRouter } from "expo-router" ;
@@ -319,23 +318,8 @@ function BranchesTab({ owner, repo }: { owner: string; repo: string }) {
319318 }
320319
321320 return (
322- < FlatList
323- data = { branches }
324- keyExtractor = { item => item . name }
325- contentContainerStyle = { styles . tabContent }
326- onEndReached = { ( ) => {
327- if ( hasNextPage && ! isFetchingNextPage ) fetchNextPage ( ) ;
328- } }
329- onEndReachedThreshold = { 0.3 }
330- ListFooterComponent = {
331- isFetchingNextPage ? (
332- < ActivityIndicator
333- style = { { paddingVertical : 16 } }
334- color = { theme . primary }
335- />
336- ) : null
337- }
338- ListEmptyComponent = {
321+ < View style = { styles . tabContent } >
322+ { branches . length === 0 ? (
339323 < View style = { styles . emptyState } >
340324 < Ionicons
341325 name = "git-branch-outline"
@@ -346,50 +330,73 @@ function BranchesTab({ owner, repo }: { owner: string; repo: string }) {
346330 No branches
347331 </ Text >
348332 </ View >
349- }
350- renderItem = { ( { item } ) => (
351- < View
352- style = { [
353- styles . branchRow ,
354- { backgroundColor : theme . surface , borderColor : theme . border } ,
355- ] }
356- >
357- < Ionicons
358- name = "git-branch-outline"
359- size = { 16 }
360- color = { theme . muted }
361- />
362- < Text
363- style = { [ styles . branchName , { color : theme . text } ] }
364- numberOfLines = { 1 }
333+ ) : (
334+ branches . map ( item => (
335+ < View
336+ key = { item . name }
337+ style = { [
338+ styles . branchRow ,
339+ { backgroundColor : theme . surface , borderColor : theme . border } ,
340+ ] }
365341 >
366- { item . name }
367- </ Text >
368- { item . name === defaultBranch && (
369- < View
370- style = { [
371- styles . branchBadge ,
372- {
373- backgroundColor : theme . primary + "20" ,
374- borderColor : theme . primary ,
375- } ,
376- ] }
377- >
378- < Text style = { [ styles . branchBadgeText , { color : theme . primary } ] } >
379- default
380- </ Text >
381- </ View >
382- ) }
383- { item . protected && (
384342 < Ionicons
385- name = "lock-closed -outline"
386- size = { 14 }
343+ name = "git-branch -outline"
344+ size = { 16 }
387345 color = { theme . muted }
388346 />
389- ) }
390- </ View >
347+ < Text
348+ style = { [ styles . branchName , { color : theme . text } ] }
349+ numberOfLines = { 1 }
350+ >
351+ { item . name }
352+ </ Text >
353+ { item . name === defaultBranch && (
354+ < View
355+ style = { [
356+ styles . branchBadge ,
357+ {
358+ backgroundColor : theme . primary + "20" ,
359+ borderColor : theme . primary ,
360+ } ,
361+ ] }
362+ >
363+ < Text
364+ style = { [ styles . branchBadgeText , { color : theme . primary } ] }
365+ >
366+ default
367+ </ Text >
368+ </ View >
369+ ) }
370+ { item . protected && (
371+ < Ionicons
372+ name = "lock-closed-outline"
373+ size = { 14 }
374+ color = { theme . muted }
375+ />
376+ ) }
377+ </ View >
378+ ) )
379+ ) }
380+ { isFetchingNextPage && (
381+ < ActivityIndicator
382+ style = { { paddingVertical : 16 } }
383+ color = { theme . primary }
384+ />
385+ ) }
386+ { hasNextPage && ! isFetchingNextPage && (
387+ < Pressable
388+ style = { [
389+ styles . loadMoreBtn ,
390+ { borderColor : theme . border , backgroundColor : theme . surface } ,
391+ ] }
392+ onPress = { ( ) => fetchNextPage ( ) }
393+ >
394+ < Text style = { [ styles . loadMoreText , { color : theme . primary } ] } >
395+ Load more
396+ </ Text >
397+ </ Pressable >
391398 ) }
392- / >
399+ </ View >
393400 ) ;
394401}
395402
@@ -921,6 +928,17 @@ const styles = StyleSheet.create({
921928 fontSize : 11 ,
922929 fontWeight : "600" ,
923930 } ,
931+ loadMoreBtn : {
932+ alignItems : "center" ,
933+ paddingVertical : 12 ,
934+ marginTop : 8 ,
935+ borderRadius : 8 ,
936+ borderWidth : StyleSheet . hairlineWidth ,
937+ } ,
938+ loadMoreText : {
939+ fontSize : 14 ,
940+ fontWeight : "500" ,
941+ } ,
924942 breadcrumb : { marginBottom : 8 } ,
925943 breadcrumbContent : { flexDirection : "row" , alignItems : "center" } ,
926944 breadcrumbItem : { flexDirection : "row" , alignItems : "center" } ,
0 commit comments