Skip to content

feat: update sample app #1400

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

Open
wants to merge 21 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f84ec58
Set bug report types
ahmedAlaaInstabug Apr 29, 2025
1ede7e2
Set bug report types
ahmedAlaaInstabug Apr 29, 2025
7928d88
feat: add bug reporting state management screen
MoKamall May 30, 2025
79caa2c
feat: enhance bug reporting functionality
MoKamall May 31, 2025
1aac4ba
feat: add View Hierarchy and Replies state management screens
MoKamall May 31, 2025
b1dfdb4
fix: update crash reporting method for non-fatal native crashes
MoKamall Jun 1, 2025
41383b1
feat: add crash reporting screens and enhance navigation
MoKamall Jun 2, 2025
6b448ce
feat: add User Consent screen and update navigation
MoKamall Jun 2, 2025
2edc0f1
fix: yarn format
MoKamall Aug 5, 2025
25048ee
chore: update podfile
MoKamall Aug 5, 2025
dc5bfc5
fix: generate podfile.lock with 1.14
MoKamall Aug 6, 2025
e723898
chore: podfile update
MoKamall Aug 6, 2025
9a2e2aa
Release: v15.0.2
ahmedAlaaInstabug Aug 7, 2025
28c4914
Merge remote-tracking branch 'origin/feat/update-sample-app' into fea…
ahmedAlaaInstabug Aug 7, 2025
cc2ca2d
Release: v15.0.2
ahmedAlaaInstabug Aug 7, 2025
0570d70
fix: lint errors
MoKamall Aug 7, 2025
a930b08
Merge branch 'feat/add-more-BG-scenarios' into feat/update-sample-app
ahmedAlaaInstabug Aug 14, 2025
ee3ffbb
add new scenarios
ahmedAlaaInstabug Aug 15, 2025
753eae0
feat: add accessibilityLabel to support Android Appium
MoKamall Aug 19, 2025
01e3b6d
chore: update AndroidManifest permissions with Service Media Projection
MoKamall Aug 19, 2025
125e053
chore: run yarn format:fix
MoKamall Aug 21, 2025
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
1 change: 1 addition & 0 deletions examples/default/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION"/>

<application
android:name=".MainApplication"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ public String getName() {
}

@ReactMethod
public void sendNativeNonFatal(final String exceptionObject) {
public void sendNativeNonFatal() {
final IBGNonFatalException exception = new IBGNonFatalException.Builder(new IllegalStateException("Test exception"))
.build();
CrashReporting.report(exception);

}

@ReactMethod
Expand Down
3 changes: 3 additions & 0 deletions examples/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@react-native-community/netinfo": "^11.4.1",
"@react-native-community/slider": "^4.5.5",
"@react-navigation/bottom-tabs": "^6.5.7",
"@react-navigation/material-top-tabs": "6.5.3",
"@react-navigation/native": "^6.1.6",
"@react-navigation/native-stack": "^6.9.12",
"axios": "^1.7.4",
Expand All @@ -28,10 +29,12 @@
"react-native-config": "^1.5.3",
"react-native-gesture-handler": "^2.13.4",
"react-native-maps": "1.10.3",
"react-native-pager-view": "^6.9.1",
"react-native-reanimated": "^3.16.1",
"react-native-safe-area-context": "^4.12.0",
"react-native-screens": "^3.35.0",
"react-native-svg": "^15.8.0",
"react-native-tab-view": "^3.5.2",
"react-native-vector-icons": "^10.2.0",
"react-native-webview": "^13.13.2",
"react-query": "^3.39.3"
Expand Down
5 changes: 4 additions & 1 deletion examples/default/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { nativeBaseTheme } from './theme/nativeBaseTheme';
import { navigationTheme } from './theme/navigationTheme';

import { QueryClient, QueryClientProvider } from 'react-query';
import { CallbackHandlersProvider } from './contexts/callbackContext';

const queryClient = new QueryClient();

Expand Down Expand Up @@ -89,7 +90,9 @@ export const App: React.FC = () => {
<NativeBaseProvider theme={nativeBaseTheme}>
<QueryClientProvider client={queryClient}>
<NavigationContainer onStateChange={Instabug.onStateChange} theme={navigationTheme}>
<RootTabNavigator />
<CallbackHandlersProvider>
<RootTabNavigator />
</CallbackHandlersProvider>
</NavigationContainer>
</QueryClientProvider>
</NativeBaseProvider>
Expand Down
12 changes: 9 additions & 3 deletions examples/default/src/components/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface InputFieldProps {
maxLength?: number;
accessibilityLabel?: string;
flex?: number;
testID?: string;
}

export const InputField = forwardRef<TextInput, InputFieldProps>(
Expand All @@ -34,6 +35,7 @@ export const InputField = forwardRef<TextInput, InputFieldProps>(
maxLength,
keyboardType,
errorText,
testID,
...restProps
},
ref,
Expand All @@ -43,11 +45,14 @@ export const InputField = forwardRef<TextInput, InputFieldProps>(
<TextInput
ref={ref}
placeholder={placeholder}
placeholderTextColor={'gray'}
style={[styles.textInput, style]}
maxLength={maxLength}
accessibilityLabel={accessibilityLabel}
accessible={true}
accessibilityLabel={accessibilityLabel ?? testID}
keyboardType={keyboardType}
value={value}
testID={testID}
onChangeText={onChangeText}
{...restProps}
/>
Expand All @@ -63,9 +68,10 @@ const styles = StyleSheet.create({
borderWidth: 1,
borderColor: '#ccc',
paddingVertical: 10,
paddingHorizontal: 24,
fontSize: 16,
paddingHorizontal: 16,
fontSize: 12,
borderRadius: 5,
color: 'black',
},
errorText: {
color: '#ff0000',
Expand Down
32 changes: 29 additions & 3 deletions examples/default/src/components/ListTile.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,51 @@
import React, { PropsWithChildren } from 'react';

import { Box, HStack, Pressable, Text } from 'native-base';
import { Box, HStack, Pressable, Text, VStack } from 'native-base';

interface ListTileProps extends PropsWithChildren {
title: string;
subtitle?: string;
onPress?: () => void;
testID?: string;
truncateSubtitle?: boolean;
accessibilityLabel?: string;
}

export const ListTile: React.FC<ListTileProps> = ({ title, onPress, children }) => {
export const ListTile: React.FC<ListTileProps> = ({
title,
subtitle,
onPress,
children,
testID,
truncateSubtitle = false,
accessibilityLabel,
}) => {
return (
<Pressable
onPress={onPress}
p="4"
rounded="2"
testID={testID}
accessibilityLabel={accessibilityLabel ?? testID}
shadow="1"
accessible={true}
borderBottomWidth="1"
borderColor="coolGray.300"
bg="coolGray.100"
_pressed={{ bg: 'coolGray.200' }}>
<HStack justifyContent="space-between" alignItems="center">
<Text>{title}</Text>
<VStack space={2}>
<Text>{title}</Text>
{subtitle && (
<Text
fontSize="xs"
color="coolGray.500"
numberOfLines={truncateSubtitle ? 1 : undefined}
ellipsizeMode={truncateSubtitle ? 'tail' : undefined}>
{subtitle}
</Text>
)}
</VStack>
<Box width={160}>{children}</Box>
</HStack>
</Pressable>
Expand Down
8 changes: 7 additions & 1 deletion examples/default/src/components/PlatformListTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ interface PlatformListTileProps extends PropsWithChildren {
title: string;
onPress?: () => void;
platform?: 'ios' | 'android';
testID?: string;
accessibilityLabel?: string;
}

export const PlatformListTile: React.FC<PlatformListTileProps> = ({
title,
onPress,
platform,
children,
testID,
accessibilityLabel,
}) => {
if (Platform.OS === platform || !platform) {
return (
Expand All @@ -25,7 +29,9 @@ export const PlatformListTile: React.FC<PlatformListTileProps> = ({
borderBottomWidth="1"
borderColor="coolGray.300"
bg="coolGray.100"
_pressed={{ bg: 'coolGray.200' }}>
_pressed={{ bg: 'coolGray.200' }}
testID={testID}
accessibilityLabel={accessibilityLabel ?? testID}>
<HStack justifyContent="space-between" alignItems="center">
<Text>{title}</Text>
<Box width={160}>{children}</Box>
Expand Down
21 changes: 18 additions & 3 deletions examples/default/src/components/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,33 @@ interface SelectItem<T> {
label: string;
value: T;
isInitial?: boolean;
testID?: string;
accessibilityLabel?: string;
}

interface SelectProps<T> {
label: string;
items: SelectItem<T>[];
onValueChange: (value: T) => void;
testID?: string;
accessibilityLabel?: string;
}

export function Select<T>({ label, items, onValueChange }: SelectProps<T>) {
export function Select<T>({
label,
items,
onValueChange,
testID,
accessibilityLabel,
}: SelectProps<T>) {
const initialItem = items.find((i) => i.isInitial) ?? items[0];
const [selectedItem, setSelectedItem] = useState(initialItem);

return (
<NativeBaseSelect
height="10"
placeholder={label}
accessibilityLabel={label}
accessibilityLabel={accessibilityLabel ?? testID}
selectedValue={selectedItem.label}
onValueChange={(value) => {
const item = items.find((i) => i.label === value)!;
Expand All @@ -35,7 +45,12 @@ export function Select<T>({ label, items, onValueChange }: SelectProps<T>) {
endIcon: <CheckIcon size="4" />,
}}>
{items.map((item) => (
<NativeBaseSelect.Item key={item.label} label={item.label} value={item.label} />
<NativeBaseSelect.Item
key={item.label}
label={item.label}
value={item.label}
testID={testID}
/>
))}
</NativeBaseSelect>
);
Expand Down
56 changes: 56 additions & 0 deletions examples/default/src/contexts/callbackContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React, { createContext, useContext, useState } from 'react';

// A single key/value pair
export type KeyValuePair = { key: string; value: string };

// An item that contains multiple key/value pairs
export type Item = {
id: string;
fields: KeyValuePair[]; // list of key/value pairs
};

// CallbackHandlersType = { [title: string]: Item[] }
export type CallbackHandlersType = Record<string, Item[]>;

type CallbackHandlersContextType = {
callbackHandlers: CallbackHandlersType;
clearList: (title: string) => void;
addItem: (title: string, item: Item) => void;
};

const CallbackHandlersContext = createContext<CallbackHandlersContextType | undefined>(undefined);

export const CallbackHandlersProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const [callbackHandlers, setCallbackHandlers] = useState<CallbackHandlersType>({});

// Clears all items under a specific title
const clearList = (title: string) => {
setCallbackHandlers((prev) => ({ ...prev, [title]: [] }));
};

// Adds an item (with multiple key/value pairs) to a specific title list
const addItem = (title: string, item: Item) => {
setCallbackHandlers((prev) => {
const existingList = prev[title] || [];
return {
...prev,
[title]: [...existingList, item],
};
});
};

return (
<CallbackHandlersContext.Provider value={{ callbackHandlers, clearList, addItem }}>
{children}
</CallbackHandlersContext.Provider>
);
};

// Hook to use the context
export const useCallbackHandlers = () => {
const ctx = useContext(CallbackHandlersContext);
if (!ctx) {
throw new Error('useCallbackHandlers must be used within CallbackHandlersProvider');
}
return ctx;
};
Loading