Skip to content

Commit

Permalink
Fix - Bug fix for country selection and child profile scroll issue
Browse files Browse the repository at this point in the history
  • Loading branch information
DivyaniPatel96 committed May 8, 2024
1 parent 2a919b4 commit 49e0535
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 57 deletions.
5 changes: 5 additions & 0 deletions app/components/shared/HeaderContainerStyle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export const HeaderTitleView = styled.View`
padding: 10px;
justify-content: center;
`;
export const HeaderTitleExpectedView = styled.View`
flex: 14;
padding: 10px;
justify-content: center;
`;
export const HomeHeaderTitleView = styled.View`
flex: 4;
padding-verticle: 10px;
Expand Down
8 changes: 7 additions & 1 deletion app/redux/reducers/localizationSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { act } from 'react-test-renderer';

interface SelectedLocalizationType {
countryId: number;
countrySelectedId: number;
languageCode: string;
luxonLocale: string;
locale: string;
selectedLocale: string;
pluralShow: boolean;
sponsors: Array<any>;
restartOnLangChange: string;
Expand All @@ -24,7 +26,9 @@ const initialState: SelectedLocalizationType = {
restartOnLangChange: 'no',
AppLayoutDirection: 'ltr',
AppLayoutDirectionScreen: 'LanguageSelection',
AppLayoutDirectionParams: {}
AppLayoutDirectionParams: {},
countrySelectedId: 0,
selectedLocale: ''
};

export const localizationSlice = createSlice({
Expand All @@ -42,9 +46,11 @@ export const localizationSlice = createSlice({
} else {
console.log('country default is', action.payload)
state.countryId = action.payload.countryId;
state.countrySelectedId = action.payload.countryId;
state.languageCode = action.payload.languages[0].languageCode;
state.luxonLocale = action.payload.languages[0].luxonLocale;
state.locale = action.payload.languages[0].locale;
state.selectedLocale = action.payload.languages[0].locale;
state.pluralShow = action.payload.languages[0].pluralShow;
}
},
Expand Down
5 changes: 3 additions & 2 deletions app/screens/AddExpectingChildProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
HeaderIconPress,
HeaderIconView,
HeaderRowView,
HeaderTitleExpectedView,
HeaderTitleView
} from '@components/shared/HeaderContainerStyle';
import DateTimePickerModal from "react-native-modal-datetime-picker";
Expand Down Expand Up @@ -190,11 +191,11 @@ const AddExpectingChildProfile = ({ route, navigation }: Props): any => {
<IconML name={'ic_back'} color="#FFF" size={15} />
</HeaderIconPress>
</HeaderIconView>
<HeaderTitleView>
<HeaderTitleExpectedView>
<Heading2w style={styles.headerTitleTextColor} numberOfLines={1}>
{childData && childData?.uuid != '' && childData?.uuid != null && childData?.uuid != undefined ? t('babyNotificationUpdateBtn') : t('expectChildAddTxt2')}
</Heading2w>
</HeaderTitleView>
</HeaderTitleExpectedView>
<HeaderActionView style={styles.headerActionView}>
{childList?.length > 1 && childData && childData?.uuid != '' ? (
<Pressable style={styles.pressableView} onPress={(): any => {
Expand Down
5 changes: 4 additions & 1 deletion app/screens/home/ChildProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ const ChildProfile = ({ navigation }: Props): any => {
</HeaderRowView>
<FlexCol style={styles.flexCol}>
<AreaContainer>
<View style={styles.areaContainerInnerView}>
<ScrollView showsVerticalScrollIndicator={false}>
<View style={styles.areaContainerInnerView}>
<ScrollView style={[styles.autoHeight, { maxHeight: (windowHeight - parentViewHeight - profileViewHeight) - 140 }]} nestedScrollEnabled={true}>
{SortedchildList.length > 0
? SortedchildList.map((item: any, index: number) => {
Expand Down Expand Up @@ -525,6 +526,8 @@ const ChildProfile = ({ navigation }: Props): any => {
</ShiftFromTop30>

</View>
</ScrollView>

</AreaContainer>
</FlexCol>
<OverlayLoadingComponent loading={profileLoading} />
Expand Down
12 changes: 6 additions & 6 deletions app/screens/home/DetailsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ const DetailsScreen = ({ route, navigation }: any): any => {
fromScreen === "VaccinationTab" || fromScreen === "FirebaseVaccinationTab" || fromScreen === "FirebaseArticles" || fromScreen === "HealthCheckupsTab" || fromScreen === "FirebaseHealthCheckupsTab"
|| fromScreen === "AddChildHealthCheckup" || fromScreen === "AddChildVaccination" || fromScreen === "MileStone" || fromScreen === "FavArticles" || fromScreen === "SupportChat") {
if (detailData.type == "Article") {
const articleVisitCount: any = realm?.objects<ViewDetailsEntity>('ViewDetails').filter((item:any)=>item.id ===detailData.id)
const articleVisitCount: any = realm?.objects<ViewDetailsEntity>('ArticleActivityView').filter((item:any)=>item.id ===detailData.id)
console.log('articleVisitCount visit count', articleVisitCount);
realm?.write(() => {
const articleEvent = realm.create('ViewDetails', {
const articleEvent = realm.create('ArticleActivityView', {
id: detailData?.id,
type: 'Article',
isViewed: true,
Expand All @@ -368,10 +368,10 @@ const DetailsScreen = ({ route, navigation }: any): any => {
console.log('Artcile Evrnt', articleEvent);
});
} else {
const activityVisitCount: any = realm?.objects<ViewDetailsEntity>('ViewDetails').filter((item:any)=>item.id ===detailData.id)
const activityVisitCount: any = realm?.objects<ViewDetailsEntity>('ArticleActivityView').filter((item:any)=>item.id ===detailData.id)
console.log('Activity visit count', activityVisitCount,detailData?.id);
realm?.write(() => {
const activityEvent = realm.create('ViewDetails', {
const activityEvent = realm.create('ArticleActivityView', {
id: detailData?.id,
type: 'Activity',
isViewed: true,
Expand Down Expand Up @@ -430,9 +430,9 @@ const DetailsScreen = ({ route, navigation }: any): any => {
let highlightedContent = content; // Initialize with original content

query.forEach((item) => {
const regex = new RegExp(`${item}`, 'gi');
const regex = new RegExp(`\\b(${item.trim()}\\s*)`, 'gi');
if(item.length>2){
highlightedContent = highlightedContent.replace(regex, '<span style="background-color: rgba(255, 141, 107, 0.4);">$&</span>');
highlightedContent = highlightedContent.replace(regex, '<span style="background-color: rgba(255, 141, 107, 0.4);">$1</span>');
}
});

Expand Down
46 changes: 24 additions & 22 deletions app/screens/home/bottomTabs/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
import DateTimePicker from '@react-native-community/datetimepicker';
import {
Heading1Centerr, Heading3Centerr, Heading3Regular, Heading4Center, ShiftFromTop20,
ShiftFromTop25,
ShiftFromTopBottom10,
SideSpacing25
} from '@styles/typography';
Expand Down Expand Up @@ -153,7 +154,7 @@ const Home = ({ route, navigation }: any): any => {

};
useEffect(() => {

const backHandler = BackHandler.addEventListener(
'hardwareBackPress',
onBackPress,
Expand Down Expand Up @@ -244,25 +245,25 @@ const Home = ({ route, navigation }: any): any => {
const relbebboprod = '1.1.5';
const relfolejadev = '0.2.0';
const relfolejaprod = '1.1.0';

useLayoutEffect(
React.useCallback(() => {
const task = InteractionManager.runAfterInteractions(() => {
if (netInfo.isConnected) {
synchronizeEvents(netInfo.isConnected);
}

// Expensive task
});

return () => task.cancel();
}, [])
);
useEffect(()=>{
console.log('Active child is',activeChild)
},[isFoucused])
useEffect(()=>{
// setModalVisible(false);
useEffect(() => {
console.log('Active child is', activeChild)
}, [isFoucused])
useEffect(() => {
// setModalVisible(false);

async function fetchNetInfo(): Promise<any> {
console.log(bufferAgeBracket, "---userIsOnboarded----", userIsOnboarded);
Expand Down Expand Up @@ -352,8 +353,8 @@ const Home = ({ route, navigation }: any): any => {
saveinDB: true,
},
];
// const apiJsonDataarticleall = apiJsonDataGet(String(bufferAgeBracket), "all");
const apiJsonDataarticleall = apiJsonDataGet("all");
// const apiJsonDataarticleall = apiJsonDataGet(String(bufferAgeBracket), "all");
const apiJsonDataarticleall = apiJsonDataGet("all");
if (apiJsonDataarticleall.length > 0) {
apiJsonDatarelatedvideoart.push(apiJsonDataarticleall[0])
}
Expand Down Expand Up @@ -472,7 +473,7 @@ const Home = ({ route, navigation }: any): any => {
else {
fetchNetInfo();
}
},[netInfo.isConnected])
}, [netInfo.isConnected])
const ondobChange = (event: any, selectedDate: any): any => {
setShow(Platform.OS === 'ios');
setdate1(selectedDate);
Expand All @@ -496,15 +497,15 @@ const Home = ({ route, navigation }: any): any => {
textColor="#FFF"
setProfileLoading={setProfileLoading}
/>

{
(netInfo && netInfo.isConnected == false) ?
<OfflineBar><Heading3Centerr>{t('noInternet')}</Heading3Centerr></OfflineBar> : null
}
<ScrollView style={styles.scrollView}>
<FlexCol>
<BabyNotification />


{show && (
<DateTimePicker
Expand All @@ -530,16 +531,17 @@ const Home = ({ route, navigation }: any): any => {
display="spinner"
onChange={ondobChange2}
/>
)}
<DailyReads />
<FeatureDivideArea>
)}
<DailyReads />
<FeatureDivideArea>
<DailyHomeNotification />
</FeatureDivideArea>
<ChildInfo
headerColor={headerColorChildInfo}
backgroundColor={backgroundColorChildInfo}
/>

<ShiftFromTop25>
<ChildInfo
headerColor={headerColorChildInfo}
backgroundColor={backgroundColorChildInfo}
/>
</ShiftFromTop25>
<ChildMilestones />
<PlayingTogether />
<AdviceAndArticles />
Expand Down
52 changes: 27 additions & 25 deletions app/screens/localization/CountryLanguageConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,19 @@ const CountryLanguageConfirmation = ({ route }: Props): any => {
const countryId = useAppSelector(
(state: any) => state.selectedCountry.countryId,
);
const countrySelectedId = useAppSelector(
(state: any) => state.selectedCountry.countrySelectedId,
);

const AppLayoutDirection = useAppSelector(
(state: any) => state.selectedCountry.AppLayoutDirection,
);
const locale = useAppSelector(
(state: any) => state.selectedCountry.locale,
);
const selectedLocale = useAppSelector(
(state: any) => state.selectedCountry.selectedLocale,
);
const incrementalSyncDT = useAppSelector((state: any) =>
(state.utilsData.incrementalSyncDT),
);
Expand All @@ -111,7 +117,7 @@ const CountryLanguageConfirmation = ({ route }: Props): any => {
const { t, i18n } = useTranslation();
console.log(I18nManager.isRTL, "---is rtl val");
useEffect(() => {
console.log('Route Params is here......', languageCode);
console.log('Route Params is here......', countrySelectedId,locale,languageCode);
if (!route.params.language) {
console.log('Language data not available');
} else if (Array.isArray(route.params.language)) {
Expand Down Expand Up @@ -217,59 +223,55 @@ const CountryLanguageConfirmation = ({ route }: Props): any => {
const countrySponsorsData = sponsors.find(
(country: any) => country.id === selectedCountry.countryId,
)
console.log('Seleted country is', countrySponsorsData)
console.log('selectedCountry country is', selectedCountry)

setSponsorsData(countrySponsorsData);
const foundCountry = getCountryByCountryCode(RNLocalize.getCountry());
console.log('Found country is', foundCountry)
if (foundCountry != undefined && foundCountry != null) {
console.log('params is here', route.params);
if (Object.keys(route.params).length !== 0) {
setCountryData(selectedCountry);
setNewLanguage(route.params.language)
} else {
console.log('Country is here', selectedDefaultCountry, selectedLanguage,locale,countryId);
if (selectedCountry == foundCountry || selectedCountry.countryId == 126) {
if (countrySelectedId==0) {
setCountryData(foundCountry);
const languagesWithLuxonLocale = foundCountry?.languages?.filter((lang: any) => lang.luxonLocale === selectedDefaultCountry || extractLanguageCode(lang.luxonLocale) === selectedLanguage);
if (languagesWithLuxonLocale?.length != 0) {
console.log('Country is here new', languagesWithLuxonLocale[0]);
setNewLanguage(languagesWithLuxonLocale[0])
setNewLanguage(languagesWithLuxonLocale[0]);
} else {
const selectedLanData = foundCountry?.languages?.filter((lang: any) => lang.languageCode === languageCode);
if(selectedLanData.length>0){
setNewLanguage(selectedLanData[0])
}else{
setNewLanguage(foundCountry.languages[0])
}
}
} else {
setCountryData(selectedCountry);
const languagesWithLuxonLocale = selectedCountry?.languages?.filter((lang: any) => lang.luxonLocale === selectedDefaultCountry || extractLanguageCode(lang.luxonLocale) === selectedLanguage);
const languagesWithLuxonLocale = selectedCountry?.languages?.filter((lang: any) => lang.locale === locale);
if (languagesWithLuxonLocale?.length != 0) {
console.log('Country is here new', languagesWithLuxonLocale[0]);
setNewLanguage(languagesWithLuxonLocale[0])
} else {
const selectedLanData = selectedCountry?.languages?.filter((lang: any) => lang.languageCode === languageCode);
console.log('selected lan data is',selectedLanData);
if(selectedLanData.length>0){
setNewLanguage(selectedLanData[0])
}else{
setNewLanguage(foundCountry.languages[0])
}
}
}
// setNewLanguage(foundCountry.languages[0])
}
} else {
if(selectedCountry?.languages.length > 0){
const filteredLanguage = selectedCountry?.languages?.filter((language:any)=>language.languageCode==selectedLanguage);
setNewLanguage(filteredLanguage[0]);
setCountryData(selectedCountry);
let filteredLanguage:any= null;
if(selectedLocale !== ''){
filteredLanguage = selectedCountry?.languages?.filter((lang:any)=>lang.locale === locale);
}else{
setNewLanguage(selectedCountry?.languages[0]);
filteredLanguage = selectedCountry?.languages?.filter((lang:any) => lang.luxonLocale === selectedDefaultCountry || extractLanguageCode(lang.luxonLocale) === selectedLanguage);
}
setCountryData(selectedCountry);
if(filteredLanguage.length > 0){
setNewLanguage(filteredLanguage[0]);
}else{
setNewLanguage(selectedCountry?.languages[0]);
}
}
}
}, [isVisible]);
useEffect(() => {
console.log('New Language is', newLanguage)
}, [newLanguage])

useFocusEffect(
React.useCallback(() => {
const backAction = (): any => {
Expand Down

0 comments on commit 49e0535

Please sign in to comment.