Skip to content
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

QR Code Importing/Exporting #58

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.CAMERA" />
</manifest>
2 changes: 2 additions & 0 deletions app/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ newArchEnabled=false
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true

VisionCamera_enableCodeScanner=true
2 changes: 2 additions & 0 deletions app/ios/EagleScout/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
</dict>
</dict>
</dict>
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to your Camera.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UILaunchStoryboardName</key>
Expand Down
159 changes: 159 additions & 0 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"react-native-haptic-feedback": "^2.2.0",
"react-native-linear-gradient": "^2.8.3",
"react-native-pager-view": "^6.2.1",
"react-native-qrcode-styled": "^0.3.1",
"react-native-reanimated": "^3.7.2",
"react-native-safe-area-context": "^4.7.2",
"react-native-screens": "^3.25.0",
Expand All @@ -47,6 +48,7 @@
"react-native-svg": "^13.13.0",
"react-native-toast-message": "^2.1.6",
"react-native-url-polyfill": "^2.0.0",
"react-native-vision-camera": "^3.9.2",
"rn-emoji-keyboard": "^1.6.1"
},
"devDependencies": {
Expand Down
13 changes: 13 additions & 0 deletions app/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import ChangePassword from './screens/settings-flow/ChangePassword';
import ResetPassword from './screens/login-flow/ResetPassword';
import {MatchBetting} from './screens/match-betting-flow/MatchBetting';
import {MatchBettingNavigator} from './screens/match-betting-flow/MatchBettingNavigator';
import {QrViewSplitter} from './screens/qr-export-flow/QrViewSplitter';

const CustomLightTheme = {
dark: false,
Expand Down Expand Up @@ -453,6 +454,18 @@ const MyStack = ({themePreference, setThemePreference, setOled}) => {
}}
component={MatchBettingNavigator}
/>
<Tab.Screen
name="QrView"
options={{
tabBarButton: () => null,
headerShown: false,
tabBarShowLabel: false,
tabBarStyle: {
backgroundColor: colors.background,
},
}}
component={QrViewSplitter}
/>
</>
)}
</Tab.Navigator>
Expand Down
4 changes: 3 additions & 1 deletion app/src/FormHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class FormHelper {
*/

static async saveFormOffline(dataToSubmit) {
dataToSubmit.createdAt = new Date();
if (!dataToSubmit.createdAt) {
dataToSubmit.createdAt = new Date();
}

await AsyncStorage.setItem(
'form-' + dataToSubmit.createdAt.getUTCMilliseconds(),
Expand Down
44 changes: 44 additions & 0 deletions app/src/components/camera/QrScannerModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {useEffect} from 'react';
import {Text} from 'react-native-svg';
import {
Camera,
Code,
useCameraDevice,
useCameraPermission,
useCodeScanner,
} from 'react-native-vision-camera';
import {Modal, StyleSheet} from 'react-native';

export const QrScannerModal = ({
onCodeScanned,
}: {
onCodeScanned: (codes: Code[]) => void;
}) => {
const {hasPermission, requestPermission} = useCameraPermission();
const device = useCameraDevice('back');
const codeScanner = useCodeScanner({
codeTypes: ['qr'],
onCodeScanned,
});
useEffect(() => {
if (!hasPermission) {
requestPermission();
}
}, [hasPermission, requestPermission]);
if (!device || !codeScanner) {
return null;
}
if (!hasPermission) {
return <Text>Requesting camera permission...</Text>;
}
return (
<Modal visible={true}>
<Camera
style={StyleSheet.absoluteFill}
codeScanner={codeScanner}
device={device}
isActive={true}
/>
</Modal>
);
};
19 changes: 19 additions & 0 deletions app/src/screens/data-flow/DataHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,25 @@ const DataHome = ({navigation}) => {
</Svg>
)}
/>
<ListItem
text={'Scan QR Code'}
onPress={() => {
navigation.navigate('QrView', {
type: 'import',
});
}}
caretVisible={false}
disabled={internetStatus !== InternetStatus.CONNECTED}
icon={() => (
<Svg
width="16"
height="16"
fill={colors.text}
viewBox="0 0 16 16">
<Path d="M8.5 1a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2a.5.5 0 0 1 .5-.5zM9 1.5a.5.5 0 0 1 1 0v2a.5.5 0 0 1-1 0v-2zm-1 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zM8 3a.5.5 0 0 1 .5.5v10a.5.5 0 0 1-1 0v-10A.5.5 0 0 1 8 3z" />
</Svg>
)}
/>
<ListItem
text={'Manage Users'}
onPress={() => {
Expand Down
Loading