Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ android {

dependencies {
implementation project(':expo-modules-core')
implementation 'com.facebook.react:react-android'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.16.1'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import android.view.inputmethod.InputConnection
import android.view.inputmethod.InputConnectionWrapper
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import com.facebook.react.common.assets.ReactFontManager
import expo.modules.kotlin.AppContext
import expo.modules.kotlin.viewevent.EventDispatcher
import expo.modules.kotlin.views.ExpoView
Expand Down Expand Up @@ -276,8 +277,9 @@ class T3ComposerEditorView(context: Context, appContext: AppContext) : ExpoView(
editor.typeface = if (fontFamily.contains("Mono", ignoreCase = true)) {
Typeface.MONOSPACE
} else {
Typeface.DEFAULT
ReactFontManager.getInstance().getTypeface(fontFamily, Typeface.NORMAL, context.assets)
}
applyLineHeight()
editor.applyPlaceholder()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.graphics.RectF
import android.graphics.Typeface
import android.text.TextPaint
import android.text.TextUtils
import com.facebook.react.common.assets.ReactFontManager
import kotlin.math.ceil
import kotlin.math.min

Expand All @@ -29,14 +30,14 @@ class T3ContextChip(

private val paint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply {
textSize = fontSize
typeface = Typeface.create("sans-serif-medium", Typeface.NORMAL)
typeface = chipTypeface()
color = this@T3ContextChip.color
}
private val em = fontSize

private val detailPaint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply {
textSize = fontSize * 0.84f
typeface = Typeface.create("sans-serif-medium", Typeface.NORMAL)
typeface = chipTypeface()
color = this@T3ContextChip.color
}
private val detailText = if (content.detail.isEmpty()) "" else " ${content.detail}"
Expand Down Expand Up @@ -86,6 +87,18 @@ class T3ContextChip(
}

companion object {
private const val CHIP_FONT_FAMILY = "DMSans-Medium"

// Matches the iOS chips; builds without the bundled font keep the platform medium.
private fun chipTypeface(): Typeface {
val fonts = ReactFontManager.getInstance()
return if (CHIP_FONT_FAMILY in fonts.customFontFamilies) {
fonts.getTypeface(CHIP_FONT_FAMILY, Typeface.NORMAL, null)
} else {
Typeface.create("sans-serif-medium", Typeface.NORMAL)
}
}

fun color(
value: String,
fallback: Int
Expand Down
Loading