Skip to content

Commit

Permalink
Merge pull request #963 from UNICEFECAR/improveSearchResults
Browse files Browse the repository at this point in the history
Improve search results enhancement
  • Loading branch information
DivyaniPatel96 authored Apr 5, 2024
2 parents 4cb6530 + d18f995 commit 493553d
Show file tree
Hide file tree
Showing 34 changed files with 11,923 additions and 265 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ jobs:
npm install
# --legacy-deps=true

- name: Lint
uses: Krizzu/[email protected]
with:
ghToken: ${{ secrets.GITHUB_TOKEN }}
eslintFiles: "app"
eslintConfig: ".eslintrc.json"
eslintExt: "js, jsx, ts, tsx"
# - name: Lint
# uses: Krizzu/[email protected]
# with:
# ghToken: ${{ secrets.GITHUB_TOKEN }}
# eslintFiles: "app"
# eslintConfig: ".eslintrc.json"
#eslintExt: "js, jsx, ts, tsx"


- name: 'Create env file'
Expand Down
8 changes: 4 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,17 @@ android {
applicationId 'org.unicef.ecar.bebbo'
targetSdkVersion rootProject.ext.targetSdkVersion
resValue "string", "build_config_package", "com.myapp"
versionCode 16
versionName "1.1.10"
versionCode 19
versionName "2.1.0"
signingConfig signingConfigs.release
}
prodstaging {
minSdkVersion rootProject.ext.minSdkVersion
applicationId 'com.datamatics.bebbo'
targetSdkVersion rootProject.ext.targetSdkVersion
resValue "string", "build_config_package", "com.myapp"
versionCode 8
versionName "2.0.0"
versionCode 9
versionName "2.1.0"
signingConfig signingConfigs.release
}
xk {
Expand Down
31 changes: 0 additions & 31 deletions android/app/src/main/res/drawable/history_svg.xml

This file was deleted.

2 changes: 1 addition & 1 deletion android/app/src/release/java/org/unicef/ecar/bebbo/ReactNativeFlipper.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public class ReactNativeFlipper {
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
// Do nothing as we don't want to initialize Flipper on Release.
}
}
}
108 changes: 54 additions & 54 deletions android/gradle.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.182.0

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

# Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false

# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true
MYAPP_UPLOAD_STORE_FILE=bebborelease.keystore
MYAPP_UPLOAD_KEY_ALIAS=bebboalias
MYAPP_UPLOAD_STORE_PASSWORD=$pass$123
MYAPP_UPLOAD_KEY_PASSWORD=$pass$123
MYAPP_UPLOAD_STORE_FILE_FOLEJA=folejarelease.keystore
MYAPP_UPLOAD_KEY_ALIAS_FOLEJA=folejaalias
MYAPP_UPLOAD_STORE_PASSWORD_FOLEJA=$pass$123
MYAPP_UPLOAD_KEY_PASSWORD_FOLEJA=$pass$123
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.182.0

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

# Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false

# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true
MYAPP_UPLOAD_STORE_FILE=bebborelease.keystore
MYAPP_UPLOAD_KEY_ALIAS=bebboalias
MYAPP_UPLOAD_STORE_PASSWORD=$pass$123
MYAPP_UPLOAD_KEY_PASSWORD=$pass$123
MYAPP_UPLOAD_STORE_FILE_FOLEJA=folejarelease.keystore
MYAPP_UPLOAD_KEY_ALIAS_FOLEJA=folejaalias
MYAPP_UPLOAD_STORE_PASSWORD_FOLEJA=$pass$123
MYAPP_UPLOAD_KEY_PASSWORD_FOLEJA=$pass$123
2 changes: 1 addition & 1 deletion app/components/OverlayLoadingComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const styles = StyleSheet.create({
},
modalBackground: {
alignItems: 'center',
backgroundColor: overlaymodalBackground,
flex: 1,
flexDirection: 'column',
justifyContent: 'space-around',
backgroundColor: overlaymodalBackground,
}

});
Expand Down
1 change: 0 additions & 1 deletion app/components/shared/ArticlesStyle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const SearchBox = styled.View`
`;
export const SearchInput = styled.TextInput`
flex:1;
padding:0 15px;
text-align:${(props:any):any => props.theme.isRTL ? 'right' : 'left'};
`;
Expand Down
1 change: 1 addition & 0 deletions app/components/shared/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ transform: ${(props:any):any => props.theme.isRTL ? 'scaleX(-1)' : 'scaleX(1)'}
`;
export const OuterIconRow = styled.View`
flex-direction: row;
margin-right: 15px;
`;

export const OuterIconLeft = styled.View`
Expand Down
2 changes: 1 addition & 1 deletion app/database/schema/SearchHistorySchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ObjectSchema } from "realm";
createdAt: Date;
};
export const SearchHistorySchema: ObjectSchema = {
name: 'SerachHistory',
name: 'SearchHistory',
properties: {
keyword: { type: 'string' },
createdAt: { type: "date" },
Expand Down
26 changes: 17 additions & 9 deletions app/screens/home/DetailsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,31 +388,39 @@ const DetailsScreen = ({ route, navigation }: any): any => {
// fontFamily: '"Open Sans"' // beware to quote font family name!
});

// A method for highlighting specific words within content
const highlightWord = (content: string, query: string): string => {
const highlightWord = (content: string, query: string[]): any => {
if (typeof content !== 'string') {
return "";
return "";
}

const regex = new RegExp(`${query}`, 'gi');
const highlightedContent = content.replace(regex, '<span style="background-color: rgba(255, 141, 107, 0.4);">$&</span>');
let highlightedContent = content; // Initialize with original content

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


return highlightedContent;
}
}

const highlightTextWithoutImages = (jsonContent: string, wordToHighlight: string): string => {

const highlightTextWithoutImages = (jsonContent: string, wordToHighlight: string[]): string => {
console.log('JsonContent is', jsonContent)
const parts = jsonContent.split(/(<img[^>]*>)/i);

// Map each part and add spaces around the word if it is not inside an img tag
const modifiedParts = parts.map((part: any): any => {
if (!/<img[^>]*>/i.test(part)) {
return highlightWord(part, wordToHighlight);
}
return highlightWord(part, wordToHighlight); // Pass wordToHighlight array here
}
return part;
});
return modifiedParts.join('')
}

const highlightedTitle = queryText != undefined
? queryText.length !== 0
? highlightWord(detailDataToUse?.title, queryText)
Expand Down
Loading

0 comments on commit 493553d

Please sign in to comment.