@@ -31,7 +31,6 @@ export default function Scanner(props:ScannerProps) {
31
31
const [ viewBox , setViewBox ] = useState ( "0 0 1080 1920" ) ;
32
32
const [ pointsText , setPointsText ] = useState ( "default" ) ;
33
33
const takenShared = useSharedValue ( false ) ;
34
- const [ taken , setTaken ] = useState ( false ) ;
35
34
const photo = useRef < PhotoFile | null > ( null ) ;
36
35
const previousResults = useRef ( [ ] as DetectedQuadResult [ ] ) ;
37
36
const device = useCameraDevice ( "back" ) ;
@@ -50,13 +49,24 @@ export default function Scanner(props:ScannerProps) {
50
49
51
50
const getFrameSize = ( ) => {
52
51
let width , height ;
53
- if ( frameWidth > frameHeight && Dimensions . get ( 'window' ) . width > Dimensions . get ( 'window' ) . height ) {
54
- width = frameWidth ;
55
- height = frameHeight ;
56
- } else {
57
- console . log ( "Has rotation" ) ;
58
- width = frameHeight ;
59
- height = frameWidth ;
52
+ if ( frameWidth . value > frameHeight . value ) {
53
+ if ( Dimensions . get ( 'window' ) . width > Dimensions . get ( 'window' ) . height ) {
54
+ width = frameWidth . value ;
55
+ height = frameHeight . value ;
56
+ } else {
57
+ console . log ( "Has rotation" ) ;
58
+ width = frameHeight . value ;
59
+ height = frameWidth . value ;
60
+ }
61
+ } else if ( frameWidth . value < frameHeight . value ) {
62
+ if ( Dimensions . get ( 'window' ) . width < Dimensions . get ( 'window' ) . height ) {
63
+ width = frameWidth . value ;
64
+ height = frameHeight . value ;
65
+ } else {
66
+ console . log ( "Has rotation" ) ;
67
+ width = frameHeight . value ;
68
+ height = frameWidth . value ;
69
+ }
60
70
}
61
71
return [ width , height ] ;
62
72
}
@@ -96,7 +106,6 @@ export default function Scanner(props:ScannerProps) {
96
106
console . log ( "take photo" ) ;
97
107
if ( camera . current ) {
98
108
console . log ( "using camera" ) ;
99
- setTaken ( true ) ;
100
109
takenShared . value = true ;
101
110
await sleep ( 500 ) ;
102
111
photo . current = await camera . current . takePhoto ( ) ;
@@ -115,7 +124,6 @@ export default function Scanner(props:ScannerProps) {
115
124
}
116
125
} else {
117
126
Alert . alert ( "" , "Failed to take a photo" ) ;
118
- setTaken ( false ) ;
119
127
takenShared . value = false ;
120
128
}
121
129
}
0 commit comments