Skip to content

Commit

Permalink
fix: add check for ios platform for using fragment view
Browse files Browse the repository at this point in the history
  • Loading branch information
Subhash703 committed Jul 24, 2024
1 parent 71a5ccd commit 064f2c3
Show file tree
Hide file tree
Showing 15 changed files with 377 additions and 474 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
import in.juspay.hypersdk.core.SdkTracker;
import in.juspay.services.HyperServices;

public class HyperViewManager extends ViewGroupManager<FrameLayout> {
public class HyperFragmentViewManager extends ViewGroupManager<FrameLayout> {

private static final String NAME = "HyperViewManager";
private static final String NAME = "HyperFragmentViewManager";
private static final int COMMAND_PROCESS = 175;

private final ReactApplicationContext reactContext;

public HyperViewManager(ReactApplicationContext reactContext) {
public HyperFragmentViewManager(ReactApplicationContext reactContext) {
this.reactContext = reactContext;
}

Expand Down Expand Up @@ -111,7 +111,7 @@ public void receiveCommand(@NonNull FrameLayout root, String commandId, @Nullabl
LogConstants.CATEGORY_LIFECYCLE,
LogConstants.SUBCATEGORY_HYPER_SDK,
LogConstants.SDK_TRACKER_LABEL,
"Exception in HyperViewManager.createCommand",
"Exception in HyperFragmentViewManager.createCommand",
e
);
}
Expand All @@ -131,7 +131,7 @@ public void doFrame(long frameTimeNanos) {
LogConstants.CATEGORY_LIFECYCLE,
LogConstants.SUBCATEGORY_HYPER_SDK,
LogConstants.SDK_TRACKER_LABEL,
"Exception in HyperViewManager.doFrame",
"Exception in HyperFragmentViewManager.doFrame",
e
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext r
@Override
@SuppressWarnings("rawtypes")
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
return Collections.singletonList(new HyperViewManager(reactContext));
return Collections.singletonList(new HyperFragmentViewManager(reactContext));
}
}

This file was deleted.

Binary file not shown.

This file was deleted.

2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {
// Hyper SDK
clientId = 'geddit'
hyperSDKVersion = "2.1.25"
excludedMicroSDKs = ["hyperapay"]
excludedMicroSDKs = []
}
repositories {
google()
Expand Down
2 changes: 2 additions & 0 deletions example/ios/HyperSdkReactExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = GE8BT8LF5K;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = HyperSdkReactExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -519,6 +520,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = GE8BT8LF5K;
INFOPLIST_FILE = HyperSdkReactExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Binary file added example/ios/assets/images/promotion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
678 changes: 342 additions & 336 deletions example/ios/main.jsbundle

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { createStackNavigator } from '@react-navigation/stack';
import { NavigationContainer } from '@react-navigation/native';
import HomeScreen from './HomeScreen';
import ProcessScreen from './ProcessScreen';
import OfferScreen from './OfferScreen';

const AppNavigator = createStackNavigator();

Expand All @@ -27,11 +26,6 @@ const App = () => (
component={ProcessScreen}
options={{ title: 'Process Screen' }}
/>
<AppNavigator.Screen
name="OfferScreen"
component={OfferScreen}
options={{ title: 'Offer Screen' }}
/>
</AppNavigator.Navigator>
</NavigationContainer>
);
Expand Down
10 changes: 0 additions & 10 deletions example/src/OfferScreen.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions example/src/ProcessScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from 'react-native';
// import { Picker } from '@react-native-picker/picker';
import CheckBox from '@react-native-community/checkbox';
import HyperSdkReact, { HyperView } from 'hyper-sdk-react';
import HyperSdkReact, { HyperFragmentView } from 'hyper-sdk-react';
import HyperAPIUtils from './API';
import HyperUtils from './Utils';
import { useNavigation } from '@react-navigation/native';
Expand Down Expand Up @@ -122,7 +122,7 @@ class ProcessScreen extends React.Component {
this.otp = '';
this.sdkPresent = '';
this.walletMobile = '';
this.flyerPayload = JSON.stringify(HyperUtils.generateFlyerPayload());
this.flyerPayload = JSON.stringify({});

if (this.service === 'pp') {
this.state.pickerSelected = 'paymentPage';
Expand Down Expand Up @@ -899,7 +899,7 @@ class ProcessScreen extends React.Component {
/>
<View style={styles.containerSon}>
{this.state.isPayloadGenerated ? (
<HyperView
<HyperFragmentView
height={250}
namespace={'quickPay'}
payload={
Expand Down Expand Up @@ -960,7 +960,7 @@ class ProcessScreen extends React.Component {
]}
>
{this.state.isPayloadGenerated ? (
<HyperView
<HyperFragmentView
height={103}
payload={
this.service === 'pp'
Expand Down
16 changes: 2 additions & 14 deletions example/src/Utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const getClientAuthToken = (resp: string) => {
};

const services = {
ec: 'in.juspay.flyer',
ec: 'in.juspay.hyperapi',
pp: 'in.juspay.hyperpay',
};

Expand Down Expand Up @@ -147,16 +147,6 @@ const generateNBTxnPayload = (
};
};

const generateFlyerPayload = () => {
return {
requestId: uuidv4(),
service: services.ec,
payload: {
action: 'process',
},
};
};

const generateCardTxnPayload = (
orderId: string,
clientAuthToken: string,
Expand Down Expand Up @@ -429,7 +419,7 @@ const alertCallbackResponse = (screen: string, resp: any) => {
var data = JSON.parse(resp);
var event: string = data.event || '';
var payload = JSON.stringify(data.payload) || '';
console.log(screen + ': callback response' + resp);
console.log(screen + ': callback response' + payload);
showCopyAlert(screen + ': ' + event, payload);
// console.warn(screen, resp);
};
Expand Down Expand Up @@ -512,7 +502,6 @@ type HyperUtils = {
generateDeviceReadyPayload(sdkPresent: string): {};
showCopyAlert(title: string, body: any): void;
alertCallbackResponse(screen: string, resp: any): void;
generateFlyerPayload(): {};
};

export default {
Expand Down Expand Up @@ -540,5 +529,4 @@ export default {
generateDeviceReadyPayload,
showCopyAlert,
alertCallbackResponse,
generateFlyerPayload,
} as HyperUtils;
28 changes: 19 additions & 9 deletions src/HyperView.tsx → src/HyperFragmentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,55 @@ import {
UIManager,
findNodeHandle,
requireNativeComponent,
Platform,
} from 'react-native';

export interface HyperViewProps {
export interface HyperFragmentViewProps {
height?: number;
width?: number;
namespace: string;
payload: string;
}
var HyperFragmentViewManager: any;

const HyperViewManager = requireNativeComponent('HyperViewManager');
if (Platform.OS === 'android') {
HyperFragmentViewManager = requireNativeComponent('HyperFragmentViewManager');
}

const createFragment = (viewId: number, namespace: string, payload: string) => {
UIManager.dispatchViewManagerCommand(
viewId,
//@ts-ignore
UIManager.HyperViewManager.Commands.process.toString(),
UIManager.HyperFragmentViewManager.Commands.process.toString(),
[viewId, namespace, payload]
);
};

const HyperView: React.FC<HyperViewProps> = ({
const HyperFragmentView: React.FC<HyperFragmentViewProps> = ({
height,
width,
namespace,
payload,
}) => {
const ref = React.useRef<View | null>(null);
React.useEffect(() => {
const viewId = findNodeHandle(ref.current);
if (viewId) {
createFragment(viewId, namespace, payload);
if (Platform.OS == 'android') {
const viewId = findNodeHandle(ref.current);
if (viewId) {
createFragment(viewId, namespace, payload);
}
}
}, [namespace, payload]);

if (!HyperFragmentViewManager) {
return null;
}

return (
<View style={{ height: height, width: width }}>
<HyperViewManager ref={ref} />
<HyperFragmentViewManager ref={ref} />
</View>
);
};

export default HyperView;
export default HyperFragmentView;
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const HyperSdkReact = NativeModules.HyperSdkReact
}
);

export { default as HyperView } from './HyperView';
export { default as HyperFragmentView } from './HyperFragmentView';

if (Platform.OS === 'android') {
HyperSdkReact.updateBaseViewController = () => {};
Expand Down

0 comments on commit 064f2c3

Please sign in to comment.