@@ -7,6 +7,7 @@ import { T, useTranslate } from '@tolgee/react';
77import BigNumber from 'bignumber.js' ;
88import { ReactNode , useEffect , useState } from 'react' ;
99import { Keyboard , View } from 'react-native' ;
10+ import { KeyboardAvoidingView } from 'react-native-keyboard-controller' ;
1011import IconButton from '@/components/presentation/foundation/gesture-wrappers/icon-button' ;
1112import Button from '@/components/presentation/foundation/gesture-wrappers/button' ;
1213import {
@@ -114,97 +115,104 @@ export default function WeightDialog(props: WeightDialogProps) {
114115
115116 return (
116117 < Portal >
117- < Dialog visible = { props . open } onDismiss = { props . onClose } >
118- < Dialog . Title >
119- { props . label ?? < T keyName = "weight.weight.label" /> }
120- </ Dialog . Title >
121- < Dialog . Content >
122- < View style = { { gap : spacing [ 2 ] } } >
123- < View
124- style = { {
125- flexDirection : 'row' ,
126- gap : spacing [ 2 ] ,
127- justifyContent : 'center' ,
128- alignItems : 'center' ,
129- } }
130- >
131- < TextInput
132- testID = "weight-input"
133- selectTextOnFocus
134- mode = "outlined"
135- inputMode = "decimal"
136- keyboardType = "decimal-pad"
137- submitBehavior = "blurAndSubmit"
138- returnKeyType = "done"
139- autoFocus
140- value = { text }
141- onChangeText = { handleTextChange }
118+ < KeyboardAvoidingView
119+ behavior = { 'height' }
120+ style = { { flex : 1 , pointerEvents : props . open ? 'box-none' : 'none' } }
121+ >
122+ < Dialog visible = { props . open } onDismiss = { props . onClose } >
123+ < Dialog . Title >
124+ { props . label ?? < T keyName = "weight.weight.label" /> }
125+ </ Dialog . Title >
126+ < Dialog . Content >
127+ < View style = { { gap : spacing [ 2 ] } } >
128+ < View
142129 style = { {
143- backgroundColor : theme . colors . elevation . level3 ,
144- flex : 1 ,
130+ flexDirection : 'row' ,
131+ gap : spacing [ 2 ] ,
132+ justifyContent : 'center' ,
133+ alignItems : 'center' ,
145134 } }
146- />
135+ >
136+ < TextInput
137+ testID = "weight-input"
138+ selectTextOnFocus
139+ mode = "outlined"
140+ inputMode = "decimal"
141+ keyboardType = "decimal-pad"
142+ submitBehavior = "blurAndSubmit"
143+ returnKeyType = "done"
144+ autoFocus
145+ value = { text }
146+ onChangeText = { handleTextChange }
147+ style = { {
148+ backgroundColor : theme . colors . elevation . level3 ,
149+ flex : 1 ,
150+ } }
151+ />
147152
148- < SelectButton
149- testID = "weight-dialog-unit-selector"
150- options = { [
151- { label : 'kg' , value : 'kilograms' } ,
152- { label : 'lbs' , value : 'pounds' } ,
153- { label : 'Unit' , value : 'nil' , disabledAndHidden : true } ,
154- ] }
155- value = { editorWeightUnit }
156- onMenuOpen = { ( ) => Keyboard . dismiss ( ) }
157- onChange = { ( unit ) => setEditorWeightUnit ( unit ) }
158- />
159- </ View >
160- < View
161- style = { {
162- flexDirection : 'row' ,
163- gap : spacing [ 2 ] ,
164- alignItems : 'center' ,
165- } }
166- >
167- { props . allowNegative && (
168- < Tooltip title = { t ( 'exercise.toggle_negative.button' ) } >
169- < IconButton
170- mode = "outlined"
171- icon = { 'plusMinus' }
172- onPress = { ( ) => {
173- setEditorWeightValue ( editorWeightValue ?. multipliedBy ( - 1 ) ) ;
174- setText (
175- localeFormatBigNumber (
153+ < SelectButton
154+ testID = "weight-dialog-unit-selector"
155+ options = { [
156+ { label : 'kg' , value : 'kilograms' } ,
157+ { label : 'lbs' , value : 'pounds' } ,
158+ { label : 'Unit' , value : 'nil' , disabledAndHidden : true } ,
159+ ] }
160+ value = { editorWeightUnit }
161+ onMenuOpen = { ( ) => Keyboard . dismiss ( ) }
162+ onChange = { ( unit ) => setEditorWeightUnit ( unit ) }
163+ />
164+ </ View >
165+ < View
166+ style = { {
167+ flexDirection : 'row' ,
168+ gap : spacing [ 2 ] ,
169+ alignItems : 'center' ,
170+ } }
171+ >
172+ { props . allowNegative && (
173+ < Tooltip title = { t ( 'exercise.toggle_negative.button' ) } >
174+ < IconButton
175+ mode = "outlined"
176+ icon = { 'plusMinus' }
177+ onPress = { ( ) => {
178+ setEditorWeightValue (
176179 editorWeightValue ?. multipliedBy ( - 1 ) ,
177- ) ,
178- ) ;
179- } }
180- />
181- </ Tooltip >
182- ) }
183- < IconButton
184- icon = { 'minus' }
185- mode = "outlined"
186- testID = "decrement-weight"
187- onPress = { decrementWeight }
188- />
189- < IconButton
190- icon = { 'plus' }
191- mode = "outlined"
192- testID = "increment-weight"
193- onPress = { incrementWeight }
194- />
180+ ) ;
181+ setText (
182+ localeFormatBigNumber (
183+ editorWeightValue ?. multipliedBy ( - 1 ) ,
184+ ) ,
185+ ) ;
186+ } }
187+ />
188+ </ Tooltip >
189+ ) }
190+ < IconButton
191+ icon = { 'minus' }
192+ mode = "outlined"
193+ testID = "decrement-weight"
194+ onPress = { decrementWeight }
195+ />
196+ < IconButton
197+ icon = { 'plus' }
198+ mode = "outlined"
199+ testID = "increment-weight"
200+ onPress = { incrementWeight }
201+ />
202+ </ View >
203+ { props . children }
195204 </ View >
196- { props . children }
197- </ View >
198- </ Dialog . Content >
199- < Dialog . Actions >
200- < Button onPress = { props . onClose } testID = "close" >
201- < T keyName = "generic.close.button" />
202- </ Button >
203- < Button onPress = { onSaveClick } testID = "save" >
204- < T keyName = "generic.save.button" />
205- </ Button >
206- </ Dialog . Actions >
207- </ Dialog >
205+ </ Dialog . Content >
206+ < Dialog . Actions >
207+ < Button onPress = { props . onClose } testID = "close" >
208+ < T keyName = "generic.close.button" />
209+ </ Button >
210+ < Button onPress = { onSaveClick } testID = "save" >
211+ < T keyName = "generic.save.button" />
212+ </ Button >
213+ </ Dialog . Actions >
214+ </ Dialog >
215+ </ KeyboardAvoidingView >
208216 </ Portal >
209217 ) ;
210218}
0 commit comments