@bm-fe/react-native-ui-components 1.0.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,51 @@
1
+ plugins {
2
+ id 'com.android.library'
3
+ id 'org.jetbrains.kotlin.android'
4
+ }
5
+
6
+ android {
7
+ namespace 'com.bitmart.react'
8
+ compileSdk 35
9
+
10
+ defaultConfig {
11
+ minSdk 24
12
+
13
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14
+ consumerProguardFiles "consumer-rules.pro"
15
+ }
16
+
17
+ buildTypes {
18
+ release {
19
+ minifyEnabled false
20
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21
+ }
22
+ }
23
+ compileOptions {
24
+ coreLibraryDesugaringEnabled true
25
+ sourceCompatibility JavaVersion.VERSION_11
26
+ targetCompatibility JavaVersion.VERSION_11
27
+ }
28
+ kotlinOptions {
29
+ jvmTarget = '17'
30
+ }
31
+ buildFeatures {
32
+ viewBinding true
33
+ }
34
+ }
35
+
36
+ dependencies {
37
+ coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4'
38
+ implementation 'androidx.core:core-ktx:1.13.1'
39
+ implementation 'androidx.appcompat:appcompat:1.7.0'
40
+ implementation 'com.google.android.material:material:1.12.0'
41
+ api("com.facebook.react:react-android")
42
+ api("com.facebook.react:hermes-android")
43
+
44
+ implementation('com.bitmart.android:design:0.1.0-alpha') {
45
+ exclude group: 'android', module: 'lint-rtl-resource-detector-publish'
46
+ }
47
+
48
+ // SVG support for button icons
49
+ implementation 'io.coil-kt:coil:2.5.0'
50
+ implementation 'io.coil-kt:coil-svg:2.5.0'
51
+ }
@@ -0,0 +1 @@
1
+ # Consumer ProGuard rules for design module.
@@ -0,0 +1 @@
1
+ # Add project specific ProGuard rules here.
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android" />
@@ -0,0 +1,42 @@
1
+ package com.bitmart.react.design
2
+
3
+ import coil.ImageLoader
4
+ import coil.decode.DataSource
5
+ import coil.decode.ImageSource
6
+ import coil.fetch.Fetcher
7
+ import coil.fetch.SourceResult
8
+ import coil.request.Options
9
+ import okio.Buffer
10
+
11
+ /**
12
+ * Wrapper so Coil does not map our data through StringMapper (which would turn String into Uri
13
+ * and truncate SVG at '#' in e.g. fill="#ffffff").
14
+ */
15
+ data class SvgStringData(val svg: String)
16
+
17
+ /**
18
+ * Coil Fetcher for raw SVG XML string. Uses [SvgStringData] so the string is never parsed as URI.
19
+ */
20
+ class DataUriFetcher(
21
+ private val data: SvgStringData,
22
+ private val options: Options,
23
+ ) : Fetcher {
24
+
25
+ override suspend fun fetch(): SourceResult {
26
+ val svgContent = data.svg
27
+ val bytes = svgContent.toByteArray(Charsets.UTF_8)
28
+ val source = Buffer().write(bytes)
29
+ val imageSource = ImageSource(source, options.context)
30
+ return SourceResult(
31
+ source = imageSource,
32
+ mimeType = "image/svg+xml",
33
+ dataSource = DataSource.MEMORY,
34
+ )
35
+ }
36
+
37
+ class Factory : Fetcher.Factory<SvgStringData> {
38
+ override fun create(data: SvgStringData, options: Options, imageLoader: ImageLoader): Fetcher? {
39
+ return if (data.svg.isNotBlank()) DataUriFetcher(data, options) else null
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,35 @@
1
+ package com.bitmart.react.design
2
+
3
+ import android.util.Log
4
+ import com.facebook.react.ReactPackage
5
+ import com.facebook.react.bridge.NativeModule
6
+ import com.facebook.react.bridge.ReactApplicationContext
7
+ import com.facebook.react.uimanager.ViewManager
8
+
9
+ /**
10
+ * DesignComponentPackage - 注册 BitMart Design 组件库的 Native UI 组件
11
+ *
12
+ * 包含的 ViewManager:
13
+ * - PrimaryXLargeViewManager: 通用按钮组件(使用原生 Button,支持所有样式)
14
+ * - TextButtonViewManager: 文本按钮组件(使用原生 Button,支持 TextButton 样式)
15
+ */
16
+ class DesignComponentPackage : ReactPackage {
17
+
18
+ companion object {
19
+ private const val TAG = "DesignComponentPackage"
20
+ }
21
+
22
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
23
+ Log.d(TAG, "🟢 DesignComponentPackage.createNativeModules called")
24
+ // 目前没有 Native Module,只有 ViewManager
25
+ return emptyList()
26
+ }
27
+
28
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
29
+ Log.d(TAG, "🟢 DesignComponentPackage.createViewManagers called - registering ViewManagers")
30
+ return listOf(
31
+ PrimaryXLargeViewManager(), // ⭐ 通用按钮:支持所有样式(Primary, Secondary, Green, Red, White)
32
+ TextButtonViewManager() // ⭐ 文本按钮:支持 TextButton 样式
33
+ )
34
+ }
35
+ }