Skip to content

Commit d666d9a

Browse files
committed
feat: add View Hierarchy and Replies state management screens
- Introduced `ViewHierarchyScreen` and `RepliesStateScreen` for managing respective states. - Updated `HomeStack` to include new screens in navigation. - Enhanced `BugReportingScreen` with options to navigate to the new screens and manage their states. - Added state management for enabling/disabling View Hierarchy and Replies features.
1 parent 1bc3fd9 commit d666d9a

File tree

4 files changed

+121
-2
lines changed

4 files changed

+121
-2
lines changed

examples/default/src/navigation/HomeStack.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ import {
2323
InvocationOptionsScreen,
2424
type InvocationOptionsScreenProp,
2525
} from '../screens/bug-reporting/InvocationOptionsScreen';
26+
import {
27+
ViewHierarchyScreen,
28+
type ViewHierarchyScreenProp,
29+
} from '../screens/bug-reporting/ViewHierarchyScreen';
30+
import {
31+
RepliesStateScreen,
32+
type RepliesStateScreenProp,
33+
} from '../screens/bug-reporting/RepliesStateScreen';
2634
import { CrashReportingScreen } from '../screens/CrashReportingScreen';
2735
import { FeatureRequestsScreen } from '../screens/FeatureRequestsScreen';
2836
import { HomeScreen } from '../screens/HomeScreen';
@@ -72,6 +80,8 @@ export type HomeStackParamList = {
7280
InvocationEvents: InvocationEventsScreenProp;
7381
SessionProfiler: SessionProfilerScreenProp;
7482
InvocationOptions: InvocationOptionsScreenProp;
83+
ViewHierarchy: ViewHierarchyScreenProp;
84+
RepliesState: RepliesStateScreenProp;
7585

7686
CrashReporting: undefined;
7787
FeatureRequests: undefined;
@@ -149,6 +159,16 @@ export const HomeStackNavigator: React.FC = () => {
149159
component={InvocationOptionsScreen}
150160
options={{ title: 'Invocation Options' }}
151161
/>
162+
<HomeStack.Screen
163+
name="ViewHierarchy"
164+
component={ViewHierarchyScreen}
165+
options={{ title: 'View Hierarchy' }}
166+
/>
167+
<HomeStack.Screen
168+
name="RepliesState"
169+
component={RepliesStateScreen}
170+
options={{ title: 'Replies State' }}
171+
/>
152172

153173
<HomeStack.Screen
154174
name="CrashReporting"

examples/default/src/screens/bug-reporting/BugReportingScreen.tsx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Instabug, {
77
ExtendedBugReportMode,
88
WelcomeMessageMode,
99
InvocationEvent,
10+
Replies,
1011
} from 'instabug-reactnative';
1112

1213
import { ListTile } from '../../components/ListTile';
@@ -35,6 +36,8 @@ export const BugReportingScreen: React.FC<
3536
);
3637
const [disclaimerText, setDisclaimerText] = useState<string>('');
3738
const [isSessionProfilerEnabled, setIsSessionProfilerEnabled] = useState<boolean>(true);
39+
const [isViewHierarchyEnabled, setIsViewHierarchyEnabled] = useState<boolean>(false);
40+
const [isRepliesEnabled, setIsRepliesEnabled] = useState<boolean>(true);
3841

3942
return (
4043
<ScrollView flex={1} bg="gray.100">
@@ -193,6 +196,38 @@ export const BugReportingScreen: React.FC<
193196
testID="id_session_profiler"
194197
/>
195198

199+
<ListTile
200+
title="View Hierarchy"
201+
subtitle={isViewHierarchyEnabled ? 'Enabled' : 'Disabled'}
202+
onPress={() => {
203+
navigation.navigate('ViewHierarchy', {
204+
isEnabled: isViewHierarchyEnabled,
205+
setIsEnabled: (enabled: boolean) => {
206+
setIsViewHierarchyEnabled(enabled);
207+
BugReporting.setViewHierarchyEnabled(enabled);
208+
navigation.goBack();
209+
},
210+
});
211+
}}
212+
testID="id_view_hierarchy"
213+
/>
214+
215+
<ListTile
216+
title="Replies"
217+
subtitle={isRepliesEnabled ? 'Enabled' : 'Disabled'}
218+
onPress={() => {
219+
navigation.navigate('RepliesState', {
220+
isEnabled: isRepliesEnabled,
221+
setIsEnabled: (enabled: boolean) => {
222+
setIsRepliesEnabled(enabled);
223+
Replies.setEnabled(enabled);
224+
navigation.goBack();
225+
},
226+
});
227+
}}
228+
testID="id_replies"
229+
/>
230+
196231
<Divider my={5} />
197232

198233
<ListTile title="Show" onPress={() => Instabug.show()} testID="id_show_button" />
@@ -214,8 +249,6 @@ export const BugReportingScreen: React.FC<
214249
testID="id_send_question"
215250
/>
216251

217-
<Divider my={5} />
218-
219252
<ListTile
220253
title="Welcome message Beta"
221254
onPress={() => Instabug.showWelcomeMessage(WelcomeMessageMode.beta)}
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 { Screen } from '../../components/Screen';
3+
import { ListTile } from '../../components/ListTile';
4+
import type { NativeStackScreenProps } from '@react-navigation/native-stack';
5+
import type { HomeStackParamList } from '../../navigation/HomeStack';
6+
7+
export interface RepliesStateScreenProp {
8+
isEnabled: boolean;
9+
setIsEnabled: (enabled: boolean) => void;
10+
}
11+
12+
export const RepliesStateScreen: React.FC<
13+
NativeStackScreenProps<HomeStackParamList, 'RepliesState'>
14+
> = ({ navigation, route }) => {
15+
const { isEnabled, setIsEnabled } = route.params;
16+
17+
return (
18+
<Screen>
19+
<ListTile
20+
title="Enabled"
21+
onPress={() => setIsEnabled(true)}
22+
testID="id_enabled"
23+
subtitle={isEnabled ? 'Selected' : undefined}
24+
/>
25+
<ListTile
26+
title="Disabled"
27+
onPress={() => setIsEnabled(false)}
28+
testID="id_disabled"
29+
subtitle={!isEnabled ? 'Selected' : undefined}
30+
/>
31+
</Screen>
32+
);
33+
};
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 { Screen } from '../../components/Screen';
3+
import { ListTile } from '../../components/ListTile';
4+
import type { NativeStackScreenProps } from '@react-navigation/native-stack';
5+
import type { HomeStackParamList } from '../../navigation/HomeStack';
6+
7+
export interface ViewHierarchyScreenProp {
8+
isEnabled: boolean;
9+
setIsEnabled: (enabled: boolean) => void;
10+
}
11+
12+
export const ViewHierarchyScreen: React.FC<
13+
NativeStackScreenProps<HomeStackParamList, 'ViewHierarchy'>
14+
> = ({ navigation, route }) => {
15+
const { isEnabled, setIsEnabled } = route.params;
16+
17+
return (
18+
<Screen>
19+
<ListTile
20+
title="Enabled"
21+
onPress={() => setIsEnabled(true)}
22+
testID="id_enabled"
23+
subtitle={isEnabled ? 'Selected' : undefined}
24+
/>
25+
<ListTile
26+
title="Disabled"
27+
onPress={() => setIsEnabled(false)}
28+
testID="id_disabled"
29+
subtitle={!isEnabled ? 'Selected' : undefined}
30+
/>
31+
</Screen>
32+
);
33+
};

0 commit comments

Comments
 (0)