-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: wip * refactor: wip * chore: wip
- Loading branch information
Showing
10 changed files
with
393 additions
and
194 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import { | ||
StyleSheet, | ||
Text, | ||
TouchableOpacity, | ||
View, | ||
FlatList, | ||
} from 'react-native'; | ||
import React from 'react'; | ||
import { useNavigation } from '@react-navigation/native'; | ||
import { | ||
RouteName, | ||
type HomeStackNavigationProps, | ||
type HomeStackParamList, | ||
} from './routes.type'; | ||
import TurboImage from '../../../src'; | ||
|
||
const ListItem = ({ | ||
name, | ||
destination, | ||
}: { | ||
name: string; | ||
destination: keyof HomeStackParamList; | ||
}) => { | ||
const navigation = useNavigation<HomeStackNavigationProps>(); | ||
const handlePress = () => { | ||
navigation.push(destination); | ||
}; | ||
return ( | ||
<TouchableOpacity onPress={handlePress}> | ||
<Text style={styles.itemTitle}>{name}</Text> | ||
</TouchableOpacity> | ||
); | ||
}; | ||
|
||
const ButtonItem = ({ | ||
title, | ||
handlePress, | ||
}: { | ||
title: string; | ||
handlePress: () => void; | ||
}) => { | ||
return ( | ||
<TouchableOpacity style={styles.button} onPress={handlePress}> | ||
<Text style={styles.buttonTitle}>{title}</Text> | ||
</TouchableOpacity> | ||
); | ||
}; | ||
const routes = [ | ||
{ name: 'Grid', destination: RouteName.Grid }, | ||
{ name: 'Cache', destination: RouteName.Cache }, | ||
{ name: 'Process', destination: RouteName.Process }, | ||
]; | ||
|
||
const HomeScreen = () => { | ||
const handleClearMemoryCache = async () => { | ||
return await TurboImage.clearMemoryCache(); | ||
}; | ||
const handleClearDiskCache = async () => { | ||
return await TurboImage.clearDiskCache(); | ||
}; | ||
return ( | ||
<View> | ||
<FlatList | ||
data={routes} | ||
renderItem={({ item }) => ( | ||
<ListItem | ||
name={item.name} | ||
destination={item.destination as keyof HomeStackParamList} | ||
/> | ||
)} | ||
keyExtractor={(item) => item.name} | ||
/> | ||
<ButtonItem | ||
title="Clean Memory Cache" | ||
handlePress={handleClearMemoryCache} | ||
/> | ||
<ButtonItem title="Clean Disk Cache" handlePress={handleClearDiskCache} /> | ||
</View> | ||
); | ||
}; | ||
|
||
export default HomeScreen; | ||
|
||
const styles = StyleSheet.create({ | ||
itemTitle: { | ||
paddingVertical: 10, | ||
paddingHorizontal: 20, | ||
fontSize: 20, | ||
fontWeight: 'bold', | ||
}, | ||
buttonTitle: { | ||
paddingVertical: 10, | ||
paddingHorizontal: 20, | ||
fontSize: 20, | ||
fontWeight: 'bold', | ||
color: 'white', | ||
}, | ||
button: { | ||
backgroundColor: '#f54338', | ||
padding: 5, | ||
borderRadius: 5, | ||
margin: 5, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { RouteProp } from '@react-navigation/native'; | ||
import type { | ||
NativeStackNavigationProp, | ||
NativeStackScreenProps, | ||
} from '@react-navigation/native-stack'; | ||
|
||
export type HomeStackParamList = { | ||
Home: undefined; | ||
Cache: undefined; | ||
Grid: undefined; | ||
Process: undefined; | ||
}; | ||
|
||
export type HomeStackProps = NativeStackScreenProps<HomeStackParamList>; | ||
export type HomeStackNavigationProps = | ||
NativeStackNavigationProp<HomeStackParamList>; | ||
|
||
export type HomeRouteType<K extends keyof HomeStackParamList> = RouteProp< | ||
HomeStackParamList, | ||
K | ||
>; | ||
|
||
export enum RouteName { | ||
HomeStack = 'HomeStack', | ||
Home = 'Home', | ||
Cache = 'Cache', | ||
Grid = 'Grid', | ||
Process = 'Process', | ||
} |
Oops, something went wrong.