Skip to content

Commit

Permalink
Implement on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekzaw committed Jan 29, 2024
1 parent b6b4b20 commit ae836b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@ public class MarkdownStyle {
@ColorInt
private final int mPreBackgroundColor;

@ColorInt
private final int mMentionHereColor;

@ColorInt
private final int mMentionHereBackgroundColor;

@ColorInt
private final int mMentionUserColor;

@ColorInt
private final int mMentionUserBackgroundColor;

Expand All @@ -66,7 +72,9 @@ public MarkdownStyle(@NonNull ReadableMap map, @NonNull Context context) {
mPreFontFamily = parseString(map, "pre", "fontFamily");
mPreColor = parseColor(map, "pre", "color", context);
mPreBackgroundColor = parseColor(map, "pre", "backgroundColor", context);
mMentionHereColor = parseColor(map, "mentionHere", "color", context);
mMentionHereBackgroundColor = parseColor(map, "mentionHere", "backgroundColor", context);
mMentionUserColor = parseColor(map, "mentionUser", "color", context);
mMentionUserBackgroundColor = parseColor(map, "mentionUser", "backgroundColor", context);
}

Expand Down Expand Up @@ -156,11 +164,21 @@ public int getPreBackgroundColor() {
return mPreBackgroundColor;
}

@ColorInt
public int getMentionHereColor() {
return mMentionHereColor;
}

@ColorInt
public int getMentionHereBackgroundColor() {
return mMentionHereBackgroundColor;
}

@ColorInt
public int getMentionUserColor() {
return mMentionUserColor;
}

@ColorInt
public int getMentionUserBackgroundColor() {
return mMentionUserBackgroundColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ private void applyRange(SpannableStringBuilder ssb, String type, int start, int
setSpan(ssb, new MarkdownStrikethroughSpan(), start, end);
break;
case "mention-here":
setSpan(ssb, new MarkdownBoldSpan(), start, end);
setSpan(ssb, new MarkdownForegroundColorSpan(mMarkdownStyle.getMentionHereColor()), start, end);
setSpan(ssb, new MarkdownBackgroundColorSpan(mMarkdownStyle.getMentionHereBackgroundColor()), start, end);
break;
case "mention-user":
setSpan(ssb, new MarkdownBoldSpan(), start, end);
// TODO: change mention color when it mentions current user
setSpan(ssb, new MarkdownForegroundColorSpan(mMarkdownStyle.getMentionUserColor()), start, end);
setSpan(ssb, new MarkdownBackgroundColorSpan(mMarkdownStyle.getMentionUserBackgroundColor()), start, end);
break;
case "syntax":
Expand Down

0 comments on commit ae836b0

Please sign in to comment.