Compare commits

...

1 Commits

Author SHA1 Message Date
5b381eb3b9
Init react-native project 2023-11-18 19:34:08 +01:00
12 changed files with 13898 additions and 0 deletions

35
reactnative/.gitignore vendored Normal file
View File

@ -0,0 +1,35 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
# dependencies
node_modules/
# Expo
.expo/
dist/
web-build/
# Native
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision
# Metro
.metro-health-check*
# debug
npm-debug.*
yarn-debug.*
yarn-error.*
# macOS
.DS_Store
*.pem
# local env files
.env*.local
# typescript
*.tsbuildinfo

83
reactnative/App.tsx Normal file
View File

@ -0,0 +1,83 @@
import { FlashList } from '@shopify/flash-list';
import { StatusBar } from 'expo-status-bar';
import { useRef, useState } from 'react';
import { LayoutAnimation, Pressable, StyleSheet, Text, View } from 'react-native';
export default function App() {
const generateArray = (size: number) => {
const arr = new Array(size);
for (let i = 0; i < size; i++) {
arr[i] = i;
}
return arr;
};
const [refreshing, setRefreshing] = useState(false);
const [data, setData] = useState(generateArray(100));
const list = useRef<FlashList<number> | null>(null);
const removeItem = (item: number) => {
setData(
data.filter((dataItem) => {
return dataItem !== item;
})
);
list.current?.prepareForLayoutAnimationRender();
// after removing the item, we start animation
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
};
const renderItem = ({ item }: { item: number }) => {
const backgroundColor = item % 2 === 0 ? "#00a1f1" : "#ffbb00";
return (
<Pressable
onPress={() => {
removeItem(item);
}}
>
<View
style={{
...styles.container,
backgroundColor: item > 97 ? "red" : backgroundColor,
height: item % 2 === 0 ? 100 : 200,
}}
>
<Text>Cell Id: {item}</Text>
</View>
</Pressable>
);
};
return (
<FlashList
ref={list}
style={{flexGrow: 1, width: '100%', height: 50, backgroundColor: '#88F'}}
refreshing={refreshing}
onRefresh={() => {
setRefreshing(true);
setTimeout(() => {
setRefreshing(false);
}, 2000);
}}
keyExtractor={(item: number) => {
return item.toString();
}}
getItemType={(item: number) => {
return item > 97 ? "even" : "odd";
}}
renderItem={renderItem}
estimatedItemSize={100}
data={data}
/>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f8f',
alignItems: 'center',
justifyContent: 'center',
},
});

4
reactnative/Makefile Normal file
View File

@ -0,0 +1,4 @@
run:
npx expo start

30
reactnative/app.json Normal file
View File

@ -0,0 +1,30 @@
{
"expo": {
"name": "simplecloudnotifier",
"slug": "simplecloudnotifier",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
}
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
reactnative/assets/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};

13710
reactnative/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

24
reactnative/package.json Normal file
View File

@ -0,0 +1,24 @@
{
"name": "simplecloudnotifier",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"expo": "~49.0.10",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-native": "0.72.4",
"@shopify/flash-list": "1.4.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@types/react": "~18.2.14",
"typescript": "^5.1.3"
},
"private": true
}

View File

@ -0,0 +1,6 @@
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true
}
}