Skip to content

Commit a9863bb

Browse files
Merge pull request #1351 from Instabug/chore/enhance-apm-screen-sample-app
chore: add ComplexViews to APM screen
2 parents 16050df + 4834b3b commit a9863bb

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react';
2+
import { type DimensionValue, View } from 'react-native';
3+
4+
// Define the component type with static properties
5+
interface CustomGapComponent extends React.FC<{ height?: DimensionValue; width?: DimensionValue }> {
6+
small: JSX.Element;
7+
smallV: JSX.Element;
8+
smallH: JSX.Element;
9+
large: JSX.Element;
10+
largeV: JSX.Element;
11+
largeH: JSX.Element;
12+
}
13+
14+
const defaultDimensionValue = 16;
15+
16+
// Define the CustomGap component
17+
const CustomGap: CustomGapComponent = ({ height, width }) => {
18+
return (
19+
<View
20+
style={{ width: width ?? defaultDimensionValue, height: height ?? defaultDimensionValue }}
21+
/>
22+
);
23+
};
24+
25+
// Assign static properties for predefined gaps
26+
CustomGap.small = <CustomGap height={8} width={8} />;
27+
CustomGap.large = <CustomGap height={32} width={32} />;
28+
CustomGap.smallV = <CustomGap height={8} />;
29+
CustomGap.largeV = <CustomGap height={32} />;
30+
CustomGap.smallH = <CustomGap width={8} />;
31+
CustomGap.largeH = <CustomGap width={32} />;
32+
33+
export default CustomGap;

examples/default/src/screens/apm/APMScreen.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import type { HomeStackParamList } from '../../navigation/HomeStack';
33
import React, { useState } from 'react';
44
import { ListTile } from '../../components/ListTile';
55
import { Screen } from '../../components/Screen';
6-
import { Text, Switch } from 'react-native';
6+
import { StyleSheet, Switch, Text, View } from 'react-native';
77
import { APM } from 'instabug-reactnative';
88
import { showNotification } from '../../utils/showNotification';
9+
import CustomGap from '../../components/CustomGap';
910

1011
export const APMScreen: React.FC<NativeStackScreenProps<HomeStackParamList, 'APM'>> = ({
1112
navigation,
@@ -17,16 +18,26 @@ export const APMScreen: React.FC<NativeStackScreenProps<HomeStackParamList, 'APM
1718
APM.setEnabled(value);
1819
showNotification('APM status', 'APM enabled set to ' + value);
1920
};
21+
const styles = StyleSheet.create({
22+
switch: {
23+
flexDirection: 'row',
24+
justifyContent: 'space-between',
25+
},
26+
});
2027

2128
return (
2229
<Screen>
23-
<Text>Enable APM:</Text>
24-
<Switch onValueChange={toggleSwitch} value={isEnabled} />
30+
<View style={styles.switch}>
31+
<Text>Enable APM:</Text>
32+
<Switch onValueChange={toggleSwitch} value={isEnabled} />
33+
</View>
34+
{CustomGap.smallV}
2535
<ListTile title="End App launch" onPress={() => APM.endAppLaunch()} />
2636
<ListTile title="Network Screen" onPress={() => navigation.navigate('NetworkTraces')} />
2737
<ListTile title="Traces" onPress={() => navigation.navigate('ExecutionTraces')} />
2838
<ListTile title="Flows" onPress={() => navigation.navigate('AppFlows')} />
2939
<ListTile title="WebViews" onPress={() => navigation.navigate('WebViews')} />
40+
<ListTile title="Complex Views" onPress={() => navigation.navigate('ComplexViews')} />
3041
</Screen>
3142
);
3243
};

0 commit comments

Comments
 (0)