Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: Support Advanced UI customization #1411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

AyaMahmoud148
Copy link
Contributor

Description of the change

Support Advanced UI customization

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issues

Issue links go here

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests

Code review

  • This pull request has a descriptive title and information useful to a reviewer
  • Issue from task tracker has a link to this pull request

@InstabugCI
Copy link
Collaborator

InstabugCI commented Jul 7, 2025

Coverage Report

Label Coverage Status
JavaScript 90.3%
Android 50.1%
iOS 48.5%

Generated by 🚫 dangerJS against c828d0a

Comment on lines +1508 to +1517
try {
Typeface typeface = Typeface.createFromAsset(getReactApplicationContext().getAssets(), "fonts/" + fileName);
return typeface;
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about extracting this to a new function instead of writing the same logic twice ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we still have the same logic written twice, I was thinking something more like

    public static Typeface loadTypefaceFromAssets(Context context, String fileName) {
        try {
            return Typeface.createFromAsset(context.getAssets(), "fonts/" + fileName);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

then drop the double try catch blocks

@kholood-ea
Copy link
Contributor

Great effort @AyaMahmoud148 👏🏻

@AyaMahmoud148 AyaMahmoud148 requested a review from kholood-ea July 10, 2025 09:25
Comment on lines +1372 to +1386
if (themeConfig.hasKey("primaryColor")) {
builder.setPrimaryColor(getColor(themeConfig, "primaryColor"));
}
if (themeConfig.hasKey("secondaryTextColor")) {
builder.setSecondaryTextColor(getColor(themeConfig, "secondaryTextColor"));
}
if (themeConfig.hasKey("primaryTextColor")) {
builder.setPrimaryTextColor(getColor(themeConfig, "primaryTextColor"));
}
if (themeConfig.hasKey("titleTextColor")) {
builder.setTitleTextColor(getColor(themeConfig, "titleTextColor"));
}
if (themeConfig.hasKey("backgroundColor")) {
builder.setBackgroundColor(getColor(themeConfig, "backgroundColor"));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for colors instead of adding a check for every one we can extract the logic

private void applyColorIfPresent(ReadableMap config, com.instabug.library.model.IBGTheme.Builder builder, String key, Consumer<Integer> setter) {
    if (config.hasKey(key)) {
        setter.accept(getColor(config, key));
    }
}

then call it for each color

applyColorIfPresent(themeConfig, builder, "primaryColor", builder::setPrimaryColor);

Comment on lines +1388 to +1395
if (themeConfig.hasKey("primaryTextStyle")) {
builder.setPrimaryTextStyle(getTextStyle(themeConfig, "primaryTextStyle"));
}
if (themeConfig.hasKey("secondaryTextStyle")) {
builder.setSecondaryTextStyle(getTextStyle(themeConfig, "secondaryTextStyle"));
}
if (themeConfig.hasKey("ctaTextStyle")) {
builder.setCtaTextStyle(getTextStyle(themeConfig, "ctaTextStyle"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as previous comment

private void setFontIfPresent(ReadableMap themeConfig, com.instabug.library.model.IBGTheme.Builder builder,
String fileKey, String assetKey, String fontType) {
if (themeConfig.hasKey(fileKey) || themeConfig.hasKey(assetKey)) {
Typeface typeface = getTypeface(themeConfig, fileKey, assetKey);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we might not need both fileKey and assetKey inside then lets have a function that does one thing for each of them and not drop all the logic inside getTypeface

  public static Typeface loadTypefaceFromFile(Context context, String fileName) {
...
    }
  public static Typeface loadTypefaceFromAssets(Context context, String assetKey) {
...
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants