Skip to content

chore: add ComplexViews to APM screen #1351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions examples/default/src/components/CustomGap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { type DimensionValue, View } from 'react-native';

// Define the component type with static properties
interface CustomGapComponent extends React.FC<{ height?: DimensionValue; width?: DimensionValue }> {
small: JSX.Element;
smallV: JSX.Element;
smallH: JSX.Element;
large: JSX.Element;
largeV: JSX.Element;
largeH: JSX.Element;
}

const defaultDimensionValue = 16;

// Define the CustomGap component
const CustomGap: CustomGapComponent = ({ height, width }) => {
return (
<View
style={{ width: width ?? defaultDimensionValue, height: height ?? defaultDimensionValue }}
/>
);
};

// Assign static properties for predefined gaps
CustomGap.small = <CustomGap height={8} width={8} />;
CustomGap.large = <CustomGap height={32} width={32} />;
CustomGap.smallV = <CustomGap height={8} />;
CustomGap.largeV = <CustomGap height={32} />;
CustomGap.smallH = <CustomGap width={8} />;
CustomGap.largeH = <CustomGap width={32} />;

export default CustomGap;
17 changes: 14 additions & 3 deletions examples/default/src/screens/apm/APMScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import type { HomeStackParamList } from '../../navigation/HomeStack';
import React, { useState } from 'react';
import { ListTile } from '../../components/ListTile';
import { Screen } from '../../components/Screen';
import { Text, Switch } from 'react-native';
import { StyleSheet, Switch, Text, View } from 'react-native';
import { APM } from 'instabug-reactnative';
import { showNotification } from '../../utils/showNotification';
import CustomGap from '../../components/CustomGap';

export const APMScreen: React.FC<NativeStackScreenProps<HomeStackParamList, 'APM'>> = ({
navigation,
Expand All @@ -17,16 +18,26 @@ export const APMScreen: React.FC<NativeStackScreenProps<HomeStackParamList, 'APM
APM.setEnabled(value);
showNotification('APM status', 'APM enabled set to ' + value);
};
const styles = StyleSheet.create({
switch: {
flexDirection: 'row',
justifyContent: 'space-between',
},
});

return (
<Screen>
<Text>Enable APM:</Text>
<Switch onValueChange={toggleSwitch} value={isEnabled} />
<View style={styles.switch}>
<Text>Enable APM:</Text>
<Switch onValueChange={toggleSwitch} value={isEnabled} />
</View>
{CustomGap.smallV}
<ListTile title="End App launch" onPress={() => APM.endAppLaunch()} />
<ListTile title="Network Screen" onPress={() => navigation.navigate('NetworkTraces')} />
<ListTile title="Traces" onPress={() => navigation.navigate('ExecutionTraces')} />
<ListTile title="Flows" onPress={() => navigation.navigate('AppFlows')} />
<ListTile title="WebViews" onPress={() => navigation.navigate('WebViews')} />
<ListTile title="Complex Views" onPress={() => navigation.navigate('ComplexViews')} />
</Screen>
);
};