Skip to content

Commit

Permalink
Merge branch 'master' into version_3.3.16
Browse files Browse the repository at this point in the history
  • Loading branch information
sephina authored Mar 12, 2024
2 parents 7b98259 + 058ea39 commit 362815c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions examples/client/Locomotion/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ target 'Locomotion' do
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
end
if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useContext, useEffect, useState } from 'react';
import PhoneInput from 'react-native-phone-number-input';
import PhoneInput, { PhoneInputProps } from 'react-native-phone-number-input';
import Config from 'react-native-config';
import { AsYouType } from 'libphonenumber-js';
import { ThemeContext } from 'styled-components';
Expand All @@ -8,14 +8,17 @@ import i18n from '../../I18n';
import codes from './codes.json';
import { ERROR_COLOR } from '../../context/theme';

type SupportIsoCode = PhoneInputProps['defaultCode'];
const ALL_SUPPORTED_ISO_CODES_FROM_LIB: SupportIsoCode[] = [];

const PhoneNumberInput = ({
onPhoneNumberChange,
autoFocus,
error,
value,
}: any) => {
const [isFocused, setIsFocused] = useState(false);
const [defaultCode, setDefaultCode] = useState(null);
const [defaultCode, setDefaultCode] = useState<SupportIsoCode | null>(null);
const theme = useContext(ThemeContext);
const asYouTypePhoneNumber = new AsYouType();

Expand All @@ -28,11 +31,19 @@ const PhoneNumberInput = ({
asYouTypePhoneNumber.isValid(),
);
};
const getSafeIsoCode = (rawCode: string) : SupportIsoCode => {
const code = Config.OVERWRITE_COUNTRY_CODE || rawCode;
if (ALL_SUPPORTED_ISO_CODES_FROM_LIB.includes(code as SupportIsoCode)) {
return (code as SupportIsoCode);
}
return (Config.DEFAULT_COUNTRY_CODE as SupportIsoCode);
};

const setIsoCode = async () => {
const mobileIso = await getInputIsoCode();
const rawMobileIso = await getInputIsoCode();
const safeCode = getSafeIsoCode(rawMobileIso);
setTimeout(() => {
setDefaultCode(Config.OVERWRITE_COUNTRY_CODE || mobileIso);
setDefaultCode(safeCode);
}, 50);
};

Expand Down

0 comments on commit 362815c

Please sign in to comment.