Skip to content

Commit

Permalink
Asserting with gain and height + dismissable keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
bryzettler committed Aug 9, 2023
1 parent 9e21947 commit 2eb1cdd
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 94 deletions.
8 changes: 4 additions & 4 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ SPEC CHECKSUMS:
BEMCheckBox: 5ba6e37ade3d3657b36caecc35c8b75c6c2b1a4e
boost: 57d2868c099736d80fcd648bf211b4431e51a558
BVLinearGradient: 34a999fda29036898a09c6a6b728b0b4189e1a44
Charts: ce0768268078eee0336f122c3c4ca248e4e204c5
Charts: 354f86803d11d9c35de280587fef50d1af063978
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
EXApplication: d8f53a7eee90a870a75656280e8d4b85726ea903
EXBarCodeScanner: 8e23fae8d267dbef9f04817833a494200f1fce35
Expand All @@ -861,17 +861,17 @@ SPEC CHECKSUMS:
FBLazyVector: f1897022b53abf1469d6ad692ee2c69f57d967f3
FBReactNativeSpec: 627fd07f1b9d498c9fa572e76d7f1a6b1ee9a444
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
glog: 791fe035093b84822da7f0870421a25839ca7870
helium-react-native-sdk: 32c0a7e3abc733a7f3d291013b2db31475fc6980
hermes-engine: 0784cadad14b011580615c496f77e0ae112eed75
hermes-engine: 7a53ccac09146018a08239c5425625fdb79a6162
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
MapboxCommon: fdf7fd31c90b7b607cd9c63e37797f023c01d860
MapboxCoreMaps: 24270c7c6b8cb71819fc2f3c549db9620ee4d019
MapboxMaps: cb76511b98d3b95c74b0771ed105bc69f30ace6b
MapboxMobileEvents: de50b3a4de180dd129c326e09cd12c8adaaa46d6
MultiplatformBleAdapter: 5a6a897b006764392f9cef785e4360f54fb9477d
OneSignalXCFramework: 81ceac017a290f23793443323090cfbe888f74ea
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
RCT-Folly: 85766c3226c7ec638f05ad7cb3cf6a268d6c4241
RCTRequired: bd6045fbd511da5efe6db89eecb21e4e36bd7cbf
RCTTypeSafety: c06d9f906faa69dd1c88223204c3a24767725fd8
React: b9ea33557ef1372af247f95d110fbdea114ed3b2
Expand Down
167 changes: 91 additions & 76 deletions src/features/collectables/AssertLocationScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ import React, {
useRef,
} from 'react'
import { useTranslation } from 'react-i18next'
import { Alert, KeyboardAvoidingView } from 'react-native'
import {
Alert,
KeyboardAvoidingView,
Keyboard,
TouchableWithoutFeedback,
} from 'react-native'
import { Config } from 'react-native-config'
import { Edge } from 'react-native-safe-area-context'
import 'text-encoding-polyfill'
Expand Down Expand Up @@ -141,14 +146,16 @@ const AssertLocationScreen = () => {
])

useEffect(() => {
if (iotInfoAcc?.info?.gain) {
setGain(`${iotInfoAcc?.info?.gain / 10}`)
}
if (!elevGainVisible) {
if (iotInfoAcc?.info?.gain) {
setGain(`${iotInfoAcc?.info?.gain / 10}`)
}

if (iotInfoAcc?.info?.elevation) {
setElevation(`${iotInfoAcc?.info?.elevation}`)
if (iotInfoAcc?.info?.elevation) {
setElevation(`${iotInfoAcc?.info?.elevation}`)
}
}
}, [iotInfoAcc, setGain, setElevation])
}, [iotInfoAcc, elevGainVisible, setGain, setElevation])

const resetGain = useCallback(
() =>
Expand Down Expand Up @@ -574,78 +581,86 @@ const AssertLocationScreen = () => {
edges={backEdges}
onClose={hideElevGain}
>
<KeyboardAvoidingView style={{ flex: 1 }} behavior="padding">
<SafeAreaBox
edges={safeEdges}
backgroundColor="transparent"
flex={1}
padding="m"
marginHorizontal="s"
marginVertical="xs"
>
<Box flexGrow={1} justifyContent="center">
<Text
textAlign="left"
variant="subtitle2"
adjustsFontSizeToFit
>
{t('assertLocationScreen.antennaSetup')}
</Text>
<Text
variant="subtitle4"
color="secondaryText"
marginBottom="m"
>
{t('assertLocationScreen.antennaSetupDescription')}
</Text>
<Box
width="100%"
backgroundColor="secondary"
borderRadius="l"
paddingVertical="xs"
>
<TextInput
variant="transparent"
textInputProps={{
placeholder: t('assertLocationScreen.gainPlaceholder'),
onChangeText: (val) => setGain(val),
multiline: true,
value: gain,
returnKeyType: 'next',
keyboardType: 'decimal-pad',
}}
/>
<Box height={1} width="100%" backgroundColor="black200" />
<TextInput
variant="transparent"
textInputProps={{
placeholder: t(
<TouchableWithoutFeedback onPress={() => Keyboard.dismiss()}>
<KeyboardAvoidingView style={{ flex: 1 }} behavior="padding">
<SafeAreaBox
edges={safeEdges}
backgroundColor="transparent"
flex={1}
padding="m"
marginHorizontal="s"
marginVertical="xs"
>
<Box flexGrow={1} justifyContent="center">
<Text
textAlign="left"
variant="subtitle2"
adjustsFontSizeToFit
>
{t('assertLocationScreen.antennaSetup')}
</Text>
<Text
variant="subtitle4"
color="secondaryText"
marginBottom="m"
>
{t('assertLocationScreen.antennaSetupDescription')}
</Text>
<Box
width="100%"
backgroundColor="secondary"
borderRadius="l"
paddingVertical="xs"
>
<TextInput
variant="transparent"
floatingLabel={`${t(
'assertLocationScreen.gainPlaceholder',
)}`}
textInputProps={{
placeholder: t(
'assertLocationScreen.gainPlaceholder',
),
onChangeText: setGain,
value: gain,
keyboardType: 'decimal-pad',
}}
/>
<Box height={1} width="100%" backgroundColor="black200" />
<TextInput
variant="transparent"
floatingLabel={`${t(
'assertLocationScreen.elevationPlaceholder',
),
onChangeText: (val) => setElevation(val),
value: elevation,
keyboardType: 'decimal-pad',
}}
)}`}
textInputProps={{
placeholder: t(
'assertLocationScreen.elevationPlaceholder',
),
onChangeText: setElevation,
value: elevation,
keyboardType: 'decimal-pad',
}}
/>
</Box>
</Box>
<Box>
<ButtonPressable
height={BUTTON_HEIGHT}
flexGrow={1}
borderRadius="round"
backgroundColor="white"
backgroundColorOpacityPressed={0.7}
backgroundColorDisabled="white"
backgroundColorDisabledOpacity={0.0}
titleColorDisabled="grey600"
title={asserting ? '' : t('assertLocationScreen.title')}
titleColor="black"
onPress={handleAssertLocationPress}
/>
</Box>
</Box>
<Box>
<ButtonPressable
height={BUTTON_HEIGHT}
flexGrow={1}
borderRadius="round"
backgroundColor="white"
backgroundColorOpacityPressed={0.7}
backgroundColorDisabled="white"
backgroundColorDisabledOpacity={0.0}
titleColorDisabled="grey600"
title={asserting ? '' : t('assertLocationScreen.title')}
titleColor="black"
onPress={handleAssertLocationPress}
/>
</Box>
</SafeAreaBox>
</KeyboardAvoidingView>
</SafeAreaBox>
</KeyboardAvoidingView>
</TouchableWithoutFeedback>
</BackScreen>
</ReAnimatedBlurBox>
) : undefined}
Expand Down
10 changes: 3 additions & 7 deletions src/hooks/useIotInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import {
iotInfoKey,
rewardableEntityConfigKey,
} from '@helium/helium-entity-manager-sdk'
import { useIdlAccount } from '@helium/helium-react-hooks'
import { IDL } from '@helium/idls/lib/esm/helium_entity_manager'
import { useAnchorAccount } from '@helium/helium-react-hooks'
import { HeliumEntityManager } from '@helium/idls/lib/types/helium_entity_manager'
import { PublicKey } from '@solana/web3.js'
import { IOT_SUB_DAO_KEY } from '@utils/constants'
Expand All @@ -21,11 +20,8 @@ export const useIotInfo = (
): UseAccountState<IotHotspotInfoV0> | undefined => {
const [iotConfigKey] = rewardableEntityConfigKey(IOT_SUB_DAO_KEY, 'IOT')
const [iotInfo] = iotInfoKey(iotConfigKey, entityKey || '')

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return useIdlAccount<HeliumEntityManager>(
iotInfo,
IDL as HeliumEntityManager,
type,
)
return useAnchorAccount<HeliumEntityManager, type>(iotInfo, type)
}
10 changes: 3 additions & 7 deletions src/hooks/useMobileInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import {
mobileInfoKey,
rewardableEntityConfigKey,
} from '@helium/helium-entity-manager-sdk'
import { useIdlAccount } from '@helium/helium-react-hooks'
import { IDL } from '@helium/idls/lib/esm/helium_entity_manager'
import { useAnchorAccount } from '@helium/helium-react-hooks'
import { HeliumEntityManager } from '@helium/idls/lib/types/helium_entity_manager'
import { PublicKey } from '@solana/web3.js'
import { MOBILE_SUB_DAO_KEY } from '@utils/constants'
Expand All @@ -24,11 +23,8 @@ export const useMobileInfo = (
'MOBILE',
)
const [mobileInfo] = mobileInfoKey(mobileConfigKey, entityKey || '')

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return useIdlAccount<HeliumEntityManager>(
mobileInfo,
IDL as HeliumEntityManager,
type,
)
return useAnchorAccount<HeliumEntityManager, type>(mobileInfo, type)
}

0 comments on commit 2eb1cdd

Please sign in to comment.