Skip to content

Commit

Permalink
Merge branch 'release/1.0' into fix_ios
Browse files Browse the repository at this point in the history
* release/1.0: (62 commits)
  fix UT due to migration to getContext DI
  fix styling on tizenwear
  add RNV_SKIP_LINKING env to androidRunner
  use build folder only when bundling assets
  add react-native-photo-editor for ios + fix copying of builds folder from external pluginTemplatess
  clean code
  remove unnecessary changes
  add react-native-photo-editor overrides
  fix fetchAndMovePhoto
  add PhotoEditor for android
  fix kaios sim run command
  update logger
  small fix
  regen schema, move rnvNewPatchDependencies to bootstrapConfig, add template spec for testing schemas
  add await
  alternative execute
  add tests for getAndroidDeviceToRunOn
  fix UTs, linter
  additional c cleanup
  more c cleanup
  ...

# Conflicts:
#	packages/sdk-apple/src/runner.ts
  • Loading branch information
pavjacko committed Mar 15, 2024
2 parents aff8e93 + 3cbd336 commit 58a4129
Show file tree
Hide file tree
Showing 229 changed files with 3,289 additions and 2,608 deletions.
1 change: 1 addition & 0 deletions .github/workflows/rnvUnitTest.yml
Expand Up @@ -20,6 +20,7 @@ jobs:
run: |
yarn
yarn bootstrap
yarn lint
yarn test
env:
CI: true
Expand Down
3 changes: 1 addition & 2 deletions packages/app-harness/appConfigs/base/renative.json
Expand Up @@ -31,8 +31,7 @@
"{{resolvePackage(react-native-vector-icons)}}/Fonts"
],
"excludedPlugins": [
"@react-native-firebase/app",
"react-native-photo-editor"
"@react-native-firebase/app"
]
},
"platforms": {
Expand Down
7 changes: 0 additions & 7 deletions packages/app-harness/buildHooks/tsconfig.json

This file was deleted.

6 changes: 4 additions & 2 deletions packages/app-harness/package.json
Expand Up @@ -53,10 +53,12 @@
"react-native-gesture-handler": "2.14.1",
"react-native-orientation-locker": "1.5.0",
"react-native-permissions": "4.1.4",
"react-native-photo-editor": "1.0.13",
"react-native-photo-editor": "github:AppGyver/react-native-photo-editor#v0.1.2",
"react-native-splash-screen": "3.3.0",
"react-native-tvos": "0.73.1-3",
"react-native-web": "0.19.9"
"react-native-web": "0.19.9",
"react-native-fs": "2.20.0",
"rn-fetch-blob": "0.12.0"
},
"devDependencies": {
"@flexn/assets-renative-outline": "0.3.3",
Expand Down
39 changes: 35 additions & 4 deletions packages/app-harness/renative.json
Expand Up @@ -12,7 +12,7 @@
"react-native-splash-screen": {
"android": {
"templateAndroid": {
"MainActivity_java": {
"MainActivity_kt": {
"createMethods": ["SplashScreen.show(this)"],
"imports": ["org.devio.rn.splashscreen.SplashScreen"]
}
Expand Down Expand Up @@ -40,13 +40,14 @@
"TestNativeModule": {
"android": {
"templateAndroid": {
"MainApplication_java": {
"MainApplication_kt": {
"packages": ["MyAppPackage"]
}
},
"forceLinking": true
}
},
"rn-fetch-blob": { "tvos": { "disabled": true }, "version": "0.12.0" },
"react-native-carplay": {
"ios": {
"templateXcode": {
Expand Down Expand Up @@ -100,6 +101,11 @@
"tag": "manifest",
"android:name": "",
"children": [
{
"tag": "uses-permission ",
"android:name": "android.permission.WRITE_EXTERNAL_STORAGE",
"children": []
},
{
"tag": "application",
"android:name": ".MainApplication",
Expand All @@ -126,10 +132,29 @@
"podName": "iOSPhotoEditor",
"git": "https://github.com/prscX/photo-editor",
"commit": "4924e9ec984d25d03644e58aa148282642171de9",
"buildType": "dynamic"
"buildType": "dynamic",
"templateXcode": {
"Podfile": {
"header": ["plugin 'cocoapods-user-defined-build-types'", "enable_user_defined_build_types!"]
},
"project_pbxproj": {
"resourceFiles": [
"Resources/arrow1.png",
"Resources/arrow2.png",
"Resources/arrow3.png",
"Resources/arrow4.png",
"Resources/arrow5.png"
],
"sourceFiles": ["RNPhotoEditor/RNPhotoEditor.m"],
"headerFiles": ["RNPhotoEditor/RNPhotoEditor.h"]
}
}
},
"tvos": {
"disabled": true
},
"pluginDependencies": null,
"version": "1.0.13"
"version": "github:AppGyver/react-native-photo-editor#v0.1.2"
},
"react-native-permissions": {
"ios": {
Expand Down Expand Up @@ -208,6 +233,12 @@
},
"NSContactsUsageDescription": {
"desc": "Contacts usage description"
},
"NSPhotoLibraryAddUsageDescription": {
"desc": "Application needs permission to write photos..."
},
"NSPhotoLibraryUsageDescription": {
"desc": "iOS 10 needs permission to write photos..."
}
}
}
Expand Down
75 changes: 58 additions & 17 deletions packages/app-harness/src/app/index.tsx
@@ -1,41 +1,66 @@
import React, { useEffect, useState } from 'react';
import { Button, Image, ScrollView, Text, View } from 'react-native';
import { Api } from '@rnv/renative';
import { OrientationLocker, PORTRAIT, LANDSCAPE } from '../components/OrientationLocker';
import { NewModuleButton } from '../components/NewModuleButton';
import { SplashScreen } from '../components/SplashScreen';
import { useSplashScreen } from '../components/SplashScreen';
import { ICON_LOGO, testProps } from '../config';
import styles from '../styles';
import { addNotificationListeners, removeNotificationListeners } from '../components/Notifications';
import { requestPermissions } from '../components/Permissions';
import { TestCase } from '../components/TestCase';

const App = () => {
import config from '../../package.json';
import { LoggerProvider, useLoggerContext } from '../context';
import { NotificationCallback } from '../components/types';
import { PhotoEditorButton } from '../components/PhotoEditor';

const App = () => (
<LoggerProvider>
<AppContent />
</LoggerProvider>
);

const AppContent = () => {
const [showVideo, setShowVideo] = useState(false);
const { logDebug, logs } = useLoggerContext();
const { SplashScreen } = useSplashScreen();

useEffect(() => {
SplashScreen.hide();
addNotificationListeners();
addNotificationListeners(handleNotification);

return () => {
removeNotificationListeners();
removeNotificationListeners(handleNotification);
};
}, []);

const handleNotification: NotificationCallback = (message) => logDebug(message);

const handleRequestPermissions = async () => {
try {
const permission = await requestPermissions();
logDebug(`Permissions: ${permission}`);
} catch (error) {
logDebug(`${error}`);
}
};

return (
<View style={{ flex: 1 }}>
<View style={styles.wrapper}>
<View style={styles.header}>
<Image
style={styles.logo}
source={ICON_LOGO}
{...testProps('template-starter-home-screen-renative-image')}
/>
<Text
style={{ color: 'black', fontWeight: 'bold', marginHorizontal: 10 }}
{...testProps('app-harness-home-screen-intro-text')}
>
<Text style={styles.introText} {...testProps('app-harness-home-screen-intro-text')}>
ReNative Harness
</Text>
<View style={{ flex: 1, alignItems: 'flex-end' }}>
<Text style={{ color: 'black' }}>v1.0.0-rc.12, platform: macos, formFactor: desktop</Text>
<Text style={styles.dynamicText}>
{`v${config.version}, platform: ${Api.platform}, factor: ${Api.formFactor}, engine: ${Api.engine}`}
</Text>
</View>
</View>

Expand All @@ -58,8 +83,8 @@ const App = () => {
<TestCase id={3} title="Orientation support ">
<OrientationLocker
orientation={PORTRAIT}
onChange={(orientation) => console.log('onChange', orientation)}
onDeviceChange={(orientation) => console.log('onDeviceChange', orientation)}
onChange={(orientation) => logDebug(`onChange ${orientation}`)}
onDeviceChange={(orientation) => logDebug(`onDeviceChange ${orientation}`)}
/>
<Button title="Toggle Video" onPress={() => setShowVideo(!showVideo)} />
{showVideo && (
Expand All @@ -72,25 +97,41 @@ const App = () => {
)}
</TestCase>
<TestCase id={4} title="Permissions">
<Button onPress={requestPermissions} title="Request permissions" />
<Button onPress={handleRequestPermissions} title="Request permissions" />
</TestCase>
<TestCase id={5} title="Image Support">
<Image source={ICON_LOGO} style={{ width: 100, height: 100 }} />
</TestCase>
<TestCase id={6} title="Splash Screen">
<Button onPress={() => SplashScreen.show()} title="Show SplashScreen" />
</TestCase>
<TestCase id={7} title="PhotoEditor">
<PhotoEditorButton />
</TestCase>
</ScrollView>
</View>
<View
<ScrollView
style={{
backgroundColor: '#EEEEEE',
height: 100,
maxHeight: '20%',
width: '100%',
borderTopWidth: 1,
borderTopColor: 'black',
padding: 10,
}}
contentContainerStyle={{
paddingBottom: 10,
}}
>
<Text style={{ color: 'black' }}>Logs:</Text>
</View>
<Text style={[styles.dynamicText, { fontWeight: 'bold' }]}>{`Logs: `}</Text>
{logs
? logs.map((it, idx) => (
<Text key={idx} style={styles.dynamicText}>
{it}
</Text>
))
: null}
</ScrollView>
</View>
);
};
Expand Down
@@ -1,17 +1,23 @@
import React from 'react';
import { NativeModules, Button } from 'react-native';
import { useLoggerContext } from '../../context';

export const NewModuleButton = () => {
const { TestNativeModule } = NativeModules;
const { logDebug } = useLoggerContext();
const callback = (error: any, result: string) => {
if (error) {
console.log(error);
logDebug(error);
} else {
console.log(result);
logDebug(result);
}
};
const onPress = () => {
TestNativeModule.createTestEvent('testName', 'testLocation', callback);
if (TestNativeModule) {
TestNativeModule.createTestEvent('testName', 'testLocation', callback);
} else {
logDebug('NativeModules not supported for this platform');
}
};
return <Button title="Click to invoke native module!" color="#841584" onPress={onPress} />;
};
@@ -1,9 +1,11 @@
import React from 'react';
import { Button } from 'react-native';
import { useLoggerContext } from '../../context';

export const NewModuleButton = () => {
const { logDebug } = useLoggerContext();
const onPress = () => {
console.log('NativeModules not supported in web');
logDebug('NativeModules not supported in web');
};
return <Button title="Click to invoke native module!" color="#841584" onPress={onPress} />;
};
@@ -1,10 +1,11 @@
import PushNotificationIOS from '@react-native-community/push-notification-ios';
import { NotificationCallback, NotificationError } from '../types';

export const addNotificationListeners = () => {
export const addNotificationListeners = (callback: NotificationCallback) => {
PushNotificationIOS.requestPermissions();
PushNotificationIOS.addEventListener('notification', onRemoteNotification);
PushNotificationIOS.addEventListener('register', onRegistered);
PushNotificationIOS.addEventListener('registrationError', onError);
PushNotificationIOS.addEventListener('register', onRegistered(callback));
PushNotificationIOS.addEventListener('registrationError', onError(callback));
};

export const removeNotificationListeners = () => {
Expand All @@ -13,12 +14,12 @@ export const removeNotificationListeners = () => {
PushNotificationIOS.removeEventListener('registrationError');
};

const onRegistered = (deviceToken) => {
console.log(`Device Token: ${deviceToken}`);
const onRegistered = (callback: NotificationCallback) => (deviceToken: string) => {
callback(`Device Token: ${deviceToken}`);
};

const onError = (error) => {
console.log(`Error on notification register: ${error}`);
const onError = (callback: NotificationCallback) => (error: NotificationError) => {
callback(`Error on notification register: ${error.message}`);
};

const onRemoteNotification = (notification) => {
Expand Down
10 changes: 6 additions & 4 deletions packages/app-harness/src/components/Notifications/index.ts
@@ -1,7 +1,9 @@
export const addNotificationListeners = () => {
console.log('addNotificationListeners not supported on this platform');
import { NotificationCallback } from '../types';

export const addNotificationListeners = (callback: NotificationCallback) => {
callback('addNotificationListeners not supported on this platform');
};

export const removeNotificationListeners = () => {
console.log('removeNotificationListeners not supported on this platform');
export const removeNotificationListeners = (callback: NotificationCallback) => {
callback('removeNotificationListeners not supported on this platform');
};
@@ -1,7 +1,5 @@
import { request, PERMISSIONS } from 'react-native-permissions';

export const requestPermissions = () => {
request(PERMISSIONS.IOS.CONTACTS).then((result) => {
console.log(result);
});
return request(PERMISSIONS.IOS.CONTACTS);
};
2 changes: 1 addition & 1 deletion packages/app-harness/src/components/Permissions/index.ts
@@ -1,3 +1,3 @@
export const requestPermissions = () => {
console.log('requestPermissions not supported on this platform');
return 'requestPermissions not supported on this platform';
};
40 changes: 40 additions & 0 deletions packages/app-harness/src/components/PhotoEditor/index.mobile.tsx
@@ -0,0 +1,40 @@
import React, { useEffect } from 'react';
import { Button, Image } from 'react-native';
import { RNPhotoEditor } from 'react-native-photo-editor';
import RNFS from 'react-native-fs';
import RNFetchBlob from 'rn-fetch-blob';
import { useLoggerContext } from '../../context';
import { ICON_LOGO } from '../../config';

export const PhotoEditorButton = () => {
const { logDebug } = useLoggerContext();
const photoPath = RNFS.DocumentDirectoryPath + ICON_LOGO;
useEffect(() => {
const fetchAndMovePhoto = async () => {
const binaryFile = Image.resolveAssetSource(ICON_LOGO);
try {
const resp = await RNFetchBlob.config({ fileCache: true }).fetch('GET', binaryFile.uri);
if (await RNFS.exists(photoPath)) {
await RNFS.unlink(photoPath);
}
await RNFS.moveFile(resp.path(), photoPath);
logDebug('FILE WRITTEN!');
} catch (error) {
logDebug(`${error}`);
}
};
fetchAndMovePhoto();
}, []);
const handlePhotoEditor = () => {
RNPhotoEditor.Edit({
path: photoPath,
onDone: () => {
logDebug('on done');
},
onCancel: () => {
logDebug('on cancel');
},
});
};
return <Button onPress={handlePhotoEditor} title="Show PhotoEditor" />;
};

0 comments on commit 58a4129

Please sign in to comment.