@robin-ux/native 0.1.0
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.
- package/.eslintrc.js +5 -0
- package/README.md +35 -0
- package/android/build.gradle +43 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/robinuxnative/RobinUxNativeModule.kt +50 -0
- package/android/src/main/java/expo/modules/robinuxnative/RobinUxNativeView.kt +30 -0
- package/build/RobinUxNative.types.d.ts +18 -0
- package/build/RobinUxNative.types.d.ts.map +1 -0
- package/build/RobinUxNative.types.js +2 -0
- package/build/RobinUxNative.types.js.map +1 -0
- package/build/RobinUxNativeModule.d.ts +10 -0
- package/build/RobinUxNativeModule.d.ts.map +1 -0
- package/build/RobinUxNativeModule.js +4 -0
- package/build/RobinUxNativeModule.js.map +1 -0
- package/build/RobinUxNativeModule.web.d.ts +10 -0
- package/build/RobinUxNativeModule.web.d.ts.map +1 -0
- package/build/RobinUxNativeModule.web.js +12 -0
- package/build/RobinUxNativeModule.web.js.map +1 -0
- package/build/RobinUxNativeView.d.ts +4 -0
- package/build/RobinUxNativeView.d.ts.map +1 -0
- package/build/RobinUxNativeView.js +7 -0
- package/build/RobinUxNativeView.js.map +1 -0
- package/build/RobinUxNativeView.web.d.ts +4 -0
- package/build/RobinUxNativeView.web.d.ts.map +1 -0
- package/build/RobinUxNativeView.web.js +7 -0
- package/build/RobinUxNativeView.web.js.map +1 -0
- package/build/components/Badge.d.ts +36 -0
- package/build/components/Badge.d.ts.map +1 -0
- package/build/components/Badge.js +78 -0
- package/build/components/Badge.js.map +1 -0
- package/build/components/Button.d.ts +43 -0
- package/build/components/Button.d.ts.map +1 -0
- package/build/components/Button.js +120 -0
- package/build/components/Button.js.map +1 -0
- package/build/components/DynamicStatusBar.d.ts +30 -0
- package/build/components/DynamicStatusBar.d.ts.map +1 -0
- package/build/components/DynamicStatusBar.js +70 -0
- package/build/components/DynamicStatusBar.js.map +1 -0
- package/build/components/Input.d.ts +73 -0
- package/build/components/Input.d.ts.map +1 -0
- package/build/components/Input.js +138 -0
- package/build/components/Input.js.map +1 -0
- package/build/components/SegmentedControl.d.ts +40 -0
- package/build/components/SegmentedControl.d.ts.map +1 -0
- package/build/components/SegmentedControl.js +73 -0
- package/build/components/SegmentedControl.js.map +1 -0
- package/build/components/Text.d.ts +32 -0
- package/build/components/Text.d.ts.map +1 -0
- package/build/components/Text.js +51 -0
- package/build/components/Text.js.map +1 -0
- package/build/components/index.d.ts +13 -0
- package/build/components/index.d.ts.map +1 -0
- package/build/components/index.js +13 -0
- package/build/components/index.js.map +1 -0
- package/build/index.d.ts +7 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +10 -0
- package/build/index.js.map +1 -0
- package/build/theme/ThemeContext.d.ts +22 -0
- package/build/theme/ThemeContext.d.ts.map +1 -0
- package/build/theme/ThemeContext.js +35 -0
- package/build/theme/ThemeContext.js.map +1 -0
- package/build/theme/ThemeProvider.d.ts +33 -0
- package/build/theme/ThemeProvider.d.ts.map +1 -0
- package/build/theme/ThemeProvider.js +31 -0
- package/build/theme/ThemeProvider.js.map +1 -0
- package/build/theme/defaultTheme.d.ts +18 -0
- package/build/theme/defaultTheme.d.ts.map +1 -0
- package/build/theme/defaultTheme.js +77 -0
- package/build/theme/defaultTheme.js.map +1 -0
- package/build/theme/index.d.ts +6 -0
- package/build/theme/index.d.ts.map +1 -0
- package/build/theme/index.js +7 -0
- package/build/theme/index.js.map +1 -0
- package/build/theme/types.d.ts +40 -0
- package/build/theme/types.d.ts.map +1 -0
- package/build/theme/types.js +2 -0
- package/build/theme/types.js.map +1 -0
- package/build/utils/index.d.ts +3 -0
- package/build/utils/index.d.ts.map +1 -0
- package/build/utils/index.js +3 -0
- package/build/utils/index.js.map +1 -0
- package/build/utils/styles.d.ts +88 -0
- package/build/utils/styles.d.ts.map +1 -0
- package/build/utils/styles.js +150 -0
- package/build/utils/styles.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/RobinUxNative.podspec +29 -0
- package/ios/RobinUxNativeModule.swift +48 -0
- package/ios/RobinUxNativeView.swift +38 -0
- package/package.json +69 -0
- package/src/RobinUxNative.types.ts +19 -0
- package/src/RobinUxNativeModule.ts +12 -0
- package/src/RobinUxNativeModule.web.ts +15 -0
- package/src/RobinUxNativeView.tsx +11 -0
- package/src/RobinUxNativeView.web.tsx +15 -0
- package/src/components/Badge.tsx +101 -0
- package/src/components/Button.tsx +176 -0
- package/src/components/DynamicStatusBar.tsx +93 -0
- package/src/components/Input.tsx +248 -0
- package/src/components/SegmentedControl.tsx +107 -0
- package/src/components/Text.tsx +107 -0
- package/src/components/index.ts +23 -0
- package/src/index.ts +70 -0
- package/src/theme/ThemeContext.ts +38 -0
- package/src/theme/ThemeProvider.tsx +45 -0
- package/src/theme/defaultTheme.ts +91 -0
- package/src/theme/index.ts +12 -0
- package/src/theme/types.ts +52 -0
- package/src/utils/index.ts +19 -0
- package/src/utils/styles.ts +188 -0
- package/tsconfig.json +9 -0
package/.eslintrc.js
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# robin-ux-native
|
|
2
|
+
|
|
3
|
+
Native components for android and iOS
|
|
4
|
+
|
|
5
|
+
# API documentation
|
|
6
|
+
|
|
7
|
+
- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/robin-ux-native/)
|
|
8
|
+
- [Documentation for the main branch](https://docs.expo.dev/versions/unversioned/sdk/robin-ux-native/)
|
|
9
|
+
|
|
10
|
+
# Installation in managed Expo projects
|
|
11
|
+
|
|
12
|
+
For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](#api-documentation). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
|
|
13
|
+
|
|
14
|
+
# Installation in bare React Native projects
|
|
15
|
+
|
|
16
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
17
|
+
|
|
18
|
+
### Add the package to your npm dependencies
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
npm install robin-ux-native
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Configure for Android
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Configure for iOS
|
|
30
|
+
|
|
31
|
+
Run `npx pod-install` after installing the npm package.
|
|
32
|
+
|
|
33
|
+
# Contributing
|
|
34
|
+
|
|
35
|
+
Contributions are very welcome! Please refer to guidelines described in the [contributing guide]( https://github.com/expo/expo#contributing).
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
|
|
3
|
+
group = 'expo.modules.robinuxnative'
|
|
4
|
+
version = '0.1.0'
|
|
5
|
+
|
|
6
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
|
+
apply from: expoModulesCorePlugin
|
|
8
|
+
applyKotlinExpoModulesCorePlugin()
|
|
9
|
+
useCoreDependencies()
|
|
10
|
+
useExpoPublishing()
|
|
11
|
+
|
|
12
|
+
// If you want to use the managed Android SDK versions from expo-modules-core, set this to true.
|
|
13
|
+
// The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
|
|
14
|
+
// Most of the time, you may like to manage the Android SDK versions yourself.
|
|
15
|
+
def useManagedAndroidSdkVersions = false
|
|
16
|
+
if (useManagedAndroidSdkVersions) {
|
|
17
|
+
useDefaultAndroidSdkVersions()
|
|
18
|
+
} else {
|
|
19
|
+
buildscript {
|
|
20
|
+
// Simple helper that allows the root project to override versions declared by this library.
|
|
21
|
+
ext.safeExtGet = { prop, fallback ->
|
|
22
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
project.android {
|
|
26
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 36)
|
|
27
|
+
defaultConfig {
|
|
28
|
+
minSdkVersion safeExtGet("minSdkVersion", 24)
|
|
29
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 36)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
android {
|
|
35
|
+
namespace "expo.modules.robinuxnative"
|
|
36
|
+
defaultConfig {
|
|
37
|
+
versionCode 1
|
|
38
|
+
versionName "0.1.0"
|
|
39
|
+
}
|
|
40
|
+
lintOptions {
|
|
41
|
+
abortOnError false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package expo.modules.robinuxnative
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
import java.net.URL
|
|
6
|
+
|
|
7
|
+
class RobinUxNativeModule : Module() {
|
|
8
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
9
|
+
// that describes the module's functionality and behavior.
|
|
10
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
11
|
+
override fun definition() = ModuleDefinition {
|
|
12
|
+
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
13
|
+
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
14
|
+
// The module will be accessible from `requireNativeModule('RobinUxNative')` in JavaScript.
|
|
15
|
+
Name("RobinUxNative")
|
|
16
|
+
|
|
17
|
+
// Defines constant property on the module.
|
|
18
|
+
Constant("PI") {
|
|
19
|
+
Math.PI
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Defines event names that the module can send to JavaScript.
|
|
23
|
+
Events("onChange")
|
|
24
|
+
|
|
25
|
+
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
|
26
|
+
Function("hello") {
|
|
27
|
+
"Hello world! 👋"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Defines a JavaScript function that always returns a Promise and whose native code
|
|
31
|
+
// is by default dispatched on the different thread than the JavaScript runtime runs on.
|
|
32
|
+
AsyncFunction("setValueAsync") { value: String ->
|
|
33
|
+
// Send an event to JavaScript.
|
|
34
|
+
sendEvent("onChange", mapOf(
|
|
35
|
+
"value" to value
|
|
36
|
+
))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Enables the module to be used as a native view. Definition components that are accepted as part of
|
|
40
|
+
// the view definition: Prop, Events.
|
|
41
|
+
View(RobinUxNativeView::class) {
|
|
42
|
+
// Defines a setter for the `url` prop.
|
|
43
|
+
Prop("url") { view: RobinUxNativeView, url: URL ->
|
|
44
|
+
view.webView.loadUrl(url.toString())
|
|
45
|
+
}
|
|
46
|
+
// Defines an event that the view can send to JavaScript.
|
|
47
|
+
Events("onLoad")
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package expo.modules.robinuxnative
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.webkit.WebView
|
|
5
|
+
import android.webkit.WebViewClient
|
|
6
|
+
import expo.modules.kotlin.AppContext
|
|
7
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
8
|
+
import expo.modules.kotlin.views.ExpoView
|
|
9
|
+
|
|
10
|
+
class RobinUxNativeView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
|
|
11
|
+
// Creates and initializes an event dispatcher for the `onLoad` event.
|
|
12
|
+
// The name of the event is inferred from the value and needs to match the event name defined in the module.
|
|
13
|
+
private val onLoad by EventDispatcher()
|
|
14
|
+
|
|
15
|
+
// Defines a WebView that will be used as the root subview.
|
|
16
|
+
internal val webView = WebView(context).apply {
|
|
17
|
+
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
18
|
+
webViewClient = object : WebViewClient() {
|
|
19
|
+
override fun onPageFinished(view: WebView, url: String) {
|
|
20
|
+
// Sends an event to JavaScript. Triggers a callback defined on the view component in JavaScript.
|
|
21
|
+
onLoad(mapOf("url" to url))
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
init {
|
|
27
|
+
// Adds the WebView to the view hierarchy.
|
|
28
|
+
addView(webView)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
export type OnLoadEventPayload = {
|
|
3
|
+
url: string;
|
|
4
|
+
};
|
|
5
|
+
export type RobinUxNativeModuleEvents = {
|
|
6
|
+
onChange: (params: ChangeEventPayload) => void;
|
|
7
|
+
};
|
|
8
|
+
export type ChangeEventPayload = {
|
|
9
|
+
value: string;
|
|
10
|
+
};
|
|
11
|
+
export type RobinUxNativeViewProps = {
|
|
12
|
+
url: string;
|
|
13
|
+
onLoad: (event: {
|
|
14
|
+
nativeEvent: OnLoadEventPayload;
|
|
15
|
+
}) => void;
|
|
16
|
+
style?: StyleProp<ViewStyle>;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=RobinUxNative.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RobinUxNative.types.d.ts","sourceRoot":"","sources":["../src/RobinUxNative.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,kBAAkB,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7D,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RobinUxNative.types.js","sourceRoot":"","sources":["../src/RobinUxNative.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StyleProp, ViewStyle } from 'react-native';\n\nexport type OnLoadEventPayload = {\n url: string;\n};\n\nexport type RobinUxNativeModuleEvents = {\n onChange: (params: ChangeEventPayload) => void;\n};\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\nexport type RobinUxNativeViewProps = {\n url: string;\n onLoad: (event: { nativeEvent: OnLoadEventPayload }) => void;\n style?: StyleProp<ViewStyle>;\n};\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NativeModule } from 'expo';
|
|
2
|
+
import { RobinUxNativeModuleEvents } from './RobinUxNative.types';
|
|
3
|
+
declare class RobinUxNativeModule extends NativeModule<RobinUxNativeModuleEvents> {
|
|
4
|
+
PI: number;
|
|
5
|
+
hello(): string;
|
|
6
|
+
setValueAsync(value: string): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: RobinUxNativeModule;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=RobinUxNativeModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RobinUxNativeModule.d.ts","sourceRoot":"","sources":["../src/RobinUxNativeModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,OAAO,mBAAoB,SAAQ,YAAY,CAAC,yBAAyB,CAAC;IAC/E,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,IAAI,MAAM;IACf,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAC5C;;AAGD,wBAAyE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RobinUxNativeModule.js","sourceRoot":"","sources":["../src/RobinUxNativeModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAUzD,yDAAyD;AACzD,eAAe,mBAAmB,CAAsB,eAAe,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from 'expo';\n\nimport { RobinUxNativeModuleEvents } from './RobinUxNative.types';\n\ndeclare class RobinUxNativeModule extends NativeModule<RobinUxNativeModuleEvents> {\n PI: number;\n hello(): string;\n setValueAsync(value: string): Promise<void>;\n}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<RobinUxNativeModule>('RobinUxNative');\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NativeModule } from 'expo';
|
|
2
|
+
import { RobinUxNativeModuleEvents } from './RobinUxNative.types';
|
|
3
|
+
declare class RobinUxNativeModule extends NativeModule<RobinUxNativeModuleEvents> {
|
|
4
|
+
PI: number;
|
|
5
|
+
setValueAsync(value: string): Promise<void>;
|
|
6
|
+
hello(): string;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: typeof RobinUxNativeModule;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=RobinUxNativeModule.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RobinUxNativeModule.web.d.ts","sourceRoot":"","sources":["../src/RobinUxNativeModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,YAAY,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,cAAM,mBAAoB,SAAQ,YAAY,CAAC,yBAAyB,CAAC;IACvE,EAAE,SAAW;IACP,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAGjD,KAAK;CAGN;;AAED,wBAA6E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { registerWebModule, NativeModule } from 'expo';
|
|
2
|
+
class RobinUxNativeModule extends NativeModule {
|
|
3
|
+
PI = Math.PI;
|
|
4
|
+
async setValueAsync(value) {
|
|
5
|
+
this.emit('onChange', { value });
|
|
6
|
+
}
|
|
7
|
+
hello() {
|
|
8
|
+
return 'Hello world! 👋';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export default registerWebModule(RobinUxNativeModule, 'RobinUxNativeModule');
|
|
12
|
+
//# sourceMappingURL=RobinUxNativeModule.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RobinUxNativeModule.web.js","sourceRoot":"","sources":["../src/RobinUxNativeModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIvD,MAAM,mBAAoB,SAAQ,YAAuC;IACvE,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;IACb,KAAK,CAAC,aAAa,CAAC,KAAa;QAC/B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACnC,CAAC;IACD,KAAK;QACH,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF;AAED,eAAe,iBAAiB,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { registerWebModule, NativeModule } from 'expo';\n\nimport { RobinUxNativeModuleEvents } from './RobinUxNative.types';\n\nclass RobinUxNativeModule extends NativeModule<RobinUxNativeModuleEvents> {\n PI = Math.PI;\n async setValueAsync(value: string): Promise<void> {\n this.emit('onChange', { value });\n }\n hello() {\n return 'Hello world! 👋';\n }\n}\n\nexport default registerWebModule(RobinUxNativeModule, 'RobinUxNativeModule');\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RobinUxNativeView.d.ts","sourceRoot":"","sources":["../src/RobinUxNativeView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAK/D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAEtE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
const NativeView = requireNativeView('RobinUxNative');
|
|
4
|
+
export default function RobinUxNativeView(props) {
|
|
5
|
+
return <NativeView {...props}/>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=RobinUxNativeView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RobinUxNativeView.js","sourceRoot":"","sources":["../src/RobinUxNativeView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,UAAU,GACd,iBAAiB,CAAC,eAAe,CAAC,CAAC;AAErC,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAA6B;IACrE,OAAO,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACnC,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\n\nimport { RobinUxNativeViewProps } from './RobinUxNative.types';\n\nconst NativeView: React.ComponentType<RobinUxNativeViewProps> =\n requireNativeView('RobinUxNative');\n\nexport default function RobinUxNativeView(props: RobinUxNativeViewProps) {\n return <NativeView {...props} />;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RobinUxNativeView.web.d.ts","sourceRoot":"","sources":["../src/RobinUxNativeView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAUtE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export default function RobinUxNativeView(props) {
|
|
3
|
+
return (<div>
|
|
4
|
+
<iframe style={{ flex: 1 }} src={props.url} onLoad={() => props.onLoad({ nativeEvent: { url: props.url } })}/>
|
|
5
|
+
</div>);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=RobinUxNativeView.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RobinUxNativeView.web.js","sourceRoot":"","sources":["../src/RobinUxNativeView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,KAA6B;IACrE,OAAO,CACL,CAAC,GAAG,CACF;MAAA,CAAC,MAAM,CACL,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CACnB,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CACf,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAEpE;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\n\nimport { RobinUxNativeViewProps } from './RobinUxNative.types';\n\nexport default function RobinUxNativeView(props: RobinUxNativeViewProps) {\n return (\n <div>\n <iframe\n style={{ flex: 1 }}\n src={props.url}\n onLoad={() => props.onLoad({ nativeEvent: { url: props.url } })}\n />\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export type BadgeStatus = 'active' | 'archived' | 'draft' | string;
|
|
4
|
+
export interface BadgeProps {
|
|
5
|
+
/** Status or label to display */
|
|
6
|
+
status: BadgeStatus;
|
|
7
|
+
/** Badge size */
|
|
8
|
+
size?: 'sm' | 'md';
|
|
9
|
+
/** Custom container style */
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
11
|
+
/** Custom color override */
|
|
12
|
+
customColor?: {
|
|
13
|
+
background: string;
|
|
14
|
+
text: string;
|
|
15
|
+
border: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Badge component for displaying status or labels.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <Badge status="active" />
|
|
24
|
+
* <Badge status="draft" size="sm" />
|
|
25
|
+
* <Badge
|
|
26
|
+
* status="Custom"
|
|
27
|
+
* customColor={{
|
|
28
|
+
* background: '#e0f2fe',
|
|
29
|
+
* text: '#0369a1',
|
|
30
|
+
* border: '#7dd3fc',
|
|
31
|
+
* }}
|
|
32
|
+
* />
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function Badge({ status, size, style, customColor }: BadgeProps): React.JSX.Element;
|
|
36
|
+
//# sourceMappingURL=Badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../src/components/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAQ,SAAS,EAAE,MAAM,cAAc,CAAC;AAK1D,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAEnE,MAAM,WAAW,UAAU;IACzB,iCAAiC;IACjC,MAAM,EAAE,WAAW,CAAC;IACpB,iBAAiB;IACjB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,6BAA6B;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,4BAA4B;IAC5B,WAAW,CAAC,EAAE;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,EAAE,MAAM,EAAE,IAAW,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,UAAU,qBA4D5E"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useThemeSafe } from '../theme';
|
|
4
|
+
import { borderRadius, spacing, useThemedStyles } from '../utils/styles';
|
|
5
|
+
import { Text } from './Text';
|
|
6
|
+
/**
|
|
7
|
+
* Badge component for displaying status or labels.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <Badge status="active" />
|
|
12
|
+
* <Badge status="draft" size="sm" />
|
|
13
|
+
* <Badge
|
|
14
|
+
* status="Custom"
|
|
15
|
+
* customColor={{
|
|
16
|
+
* background: '#e0f2fe',
|
|
17
|
+
* text: '#0369a1',
|
|
18
|
+
* border: '#7dd3fc',
|
|
19
|
+
* }}
|
|
20
|
+
* />
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function Badge({ status, size = 'md', style, customColor }) {
|
|
24
|
+
const { colors } = useThemeSafe();
|
|
25
|
+
// Default status colors
|
|
26
|
+
const getStatusColors = () => {
|
|
27
|
+
if (customColor)
|
|
28
|
+
return customColor;
|
|
29
|
+
switch (status) {
|
|
30
|
+
case 'active':
|
|
31
|
+
return {
|
|
32
|
+
background: colors.success + '15', // 15% opacity
|
|
33
|
+
text: colors.success,
|
|
34
|
+
border: colors.success + '30', // 30% opacity
|
|
35
|
+
};
|
|
36
|
+
case 'archived':
|
|
37
|
+
return {
|
|
38
|
+
background: colors.foregroundTertiary + '15',
|
|
39
|
+
text: colors.foregroundTertiary,
|
|
40
|
+
border: colors.foregroundTertiary + '30',
|
|
41
|
+
};
|
|
42
|
+
case 'draft':
|
|
43
|
+
return {
|
|
44
|
+
background: colors.warning + '15',
|
|
45
|
+
text: colors.warning,
|
|
46
|
+
border: colors.warning + '30',
|
|
47
|
+
};
|
|
48
|
+
default:
|
|
49
|
+
return {
|
|
50
|
+
background: colors.muted,
|
|
51
|
+
text: colors.foregroundSecondary,
|
|
52
|
+
border: colors.border,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const statusColors = getStatusColors();
|
|
57
|
+
const styles = useThemedStyles(() => ({
|
|
58
|
+
badge: {
|
|
59
|
+
backgroundColor: statusColors.background,
|
|
60
|
+
borderWidth: 1,
|
|
61
|
+
borderColor: statusColors.border,
|
|
62
|
+
borderRadius: borderRadius.full,
|
|
63
|
+
paddingHorizontal: size === 'sm' ? spacing.sm : spacing.md,
|
|
64
|
+
paddingVertical: size === 'sm' ? spacing.xs : spacing.sm,
|
|
65
|
+
alignSelf: 'flex-start',
|
|
66
|
+
},
|
|
67
|
+
text: {
|
|
68
|
+
color: statusColors.text,
|
|
69
|
+
fontSize: size === 'sm' ? 10 : 12,
|
|
70
|
+
fontWeight: '600',
|
|
71
|
+
textTransform: 'capitalize',
|
|
72
|
+
},
|
|
73
|
+
}));
|
|
74
|
+
return (<View style={[styles.badge, style]}>
|
|
75
|
+
<Text style={styles.text}>{status}</Text>
|
|
76
|
+
</View>);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=Badge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../src/components/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,O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,CAAC,MAAM;iBACtB,CAAC;QACN,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IAEvC,MAAM,MAAM,GAAG,eAAe,CAAC,GAAG,EAAE,CAAC,CAAC;QACpC,KAAK,EAAE;YACL,eAAe,EAAE,YAAY,CAAC,UAAU;YACxC,WAAW,EAAE,CAAC;YACd,WAAW,EAAE,YAAY,CAAC,MAAM;YAChC,YAAY,EAAE,YAAY,CAAC,IAAI;YAC/B,iBAAiB,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE;YAC1D,eAAe,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE;YACxD,SAAS,EAAE,YAAqB;SACjC;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,YAAY,CAAC,IAAI;YACxB,QAAQ,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;YACjC,UAAU,EAAE,KAAc;YAC1B,aAAa,EAAE,YAAqB;SACrC;KACF,CAAC,CAAC,CAAC;IAEJ,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CACjC;MAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAC1C;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { StyleProp, View, ViewStyle } from 'react-native';\nimport { useThemeSafe } from '../theme';\nimport { borderRadius, spacing, useThemedStyles } from '../utils/styles';\nimport { Text } from './Text';\n\nexport type BadgeStatus = 'active' | 'archived' | 'draft' | string;\n\nexport interface BadgeProps {\n /** Status or label to display */\n status: BadgeStatus;\n /** Badge size */\n size?: 'sm' | 'md';\n /** Custom container style */\n style?: StyleProp<ViewStyle>;\n /** Custom color override */\n customColor?: {\n background: string;\n text: string;\n border: string;\n };\n}\n\n/**\n * Badge component for displaying status or labels.\n *\n * @example\n * ```tsx\n * <Badge status=\"active\" />\n * <Badge status=\"draft\" size=\"sm\" />\n * <Badge\n * status=\"Custom\"\n * customColor={{\n * background: '#e0f2fe',\n * text: '#0369a1',\n * border: '#7dd3fc',\n * }}\n * />\n * ```\n */\nexport function Badge({ status, size = 'md', style, customColor }: BadgeProps) {\n const { colors } = useThemeSafe();\n\n // Default status colors\n const getStatusColors = () => {\n if (customColor) return customColor;\n\n switch (status) {\n case 'active':\n return {\n background: colors.success + '15', // 15% opacity\n text: colors.success,\n border: colors.success + '30', // 30% opacity\n };\n case 'archived':\n return {\n background: colors.foregroundTertiary + '15',\n text: colors.foregroundTertiary,\n border: colors.foregroundTertiary + '30',\n };\n case 'draft':\n return {\n background: colors.warning + '15',\n text: colors.warning,\n border: colors.warning + '30',\n };\n default:\n return {\n background: colors.muted,\n text: colors.foregroundSecondary,\n border: colors.border,\n };\n }\n };\n\n const statusColors = getStatusColors();\n\n const styles = useThemedStyles(() => ({\n badge: {\n backgroundColor: statusColors.background,\n borderWidth: 1,\n borderColor: statusColors.border,\n borderRadius: borderRadius.full,\n paddingHorizontal: size === 'sm' ? spacing.sm : spacing.md,\n paddingVertical: size === 'sm' ? spacing.xs : spacing.sm,\n alignSelf: 'flex-start' as const,\n },\n text: {\n color: statusColors.text,\n fontSize: size === 'sm' ? 10 : 12,\n fontWeight: '600' as const,\n textTransform: 'capitalize' as const,\n },\n }));\n\n return (\n <View style={[styles.badge, style]}>\n <Text style={styles.text}>{status}</Text>\n </View>\n );\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Ionicons } from "@expo/vector-icons";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { TouchableOpacityProps, View } from "react-native";
|
|
4
|
+
export type ButtonVariant = "primary" | "secondary" | "ghost" | "destructive";
|
|
5
|
+
export type ButtonSize = "sm" | "md" | "lg";
|
|
6
|
+
export interface ButtonProps extends Omit<TouchableOpacityProps, "style"> {
|
|
7
|
+
/** Button visual variant */
|
|
8
|
+
variant?: ButtonVariant;
|
|
9
|
+
/** Button size */
|
|
10
|
+
size?: ButtonSize;
|
|
11
|
+
/** Show loading spinner */
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
/** Disable button interactions */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** Icon name from Ionicons */
|
|
16
|
+
icon?: keyof typeof Ionicons.glyphMap;
|
|
17
|
+
/** Icon position relative to children */
|
|
18
|
+
iconPosition?: "left" | "right";
|
|
19
|
+
/** Button content */
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
/** Custom style */
|
|
22
|
+
style?: TouchableOpacityProps["style"];
|
|
23
|
+
/** Ref to the button view */
|
|
24
|
+
ref?: React.RefObject<View | null>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Button component with variants, sizes, and icon support.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <Button variant="primary" onPress={handlePress}>
|
|
32
|
+
* Submit
|
|
33
|
+
* </Button>
|
|
34
|
+
*
|
|
35
|
+
* <Button variant="secondary" icon="add" size="sm">
|
|
36
|
+
* Add Item
|
|
37
|
+
* </Button>
|
|
38
|
+
*
|
|
39
|
+
* <Button variant="ghost" icon="settings" />
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function Button({ variant, size, loading, disabled, icon, iconPosition, children, style, ref, ...props }: ButtonProps): React.JSX.Element;
|
|
43
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,Q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
|
|
3
|
+
import { ActivityIndicator, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
4
|
+
import { useThemeSafe } from "../theme";
|
|
5
|
+
import { borderRadius, spacing } from "../utils/styles";
|
|
6
|
+
import { Text } from "./Text";
|
|
7
|
+
/**
|
|
8
|
+
* Button component with variants, sizes, and icon support.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Button variant="primary" onPress={handlePress}>
|
|
13
|
+
* Submit
|
|
14
|
+
* </Button>
|
|
15
|
+
*
|
|
16
|
+
* <Button variant="secondary" icon="add" size="sm">
|
|
17
|
+
* Add Item
|
|
18
|
+
* </Button>
|
|
19
|
+
*
|
|
20
|
+
* <Button variant="ghost" icon="settings" />
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function Button({ variant = "primary", size = "md", loading = false, disabled = false, icon, iconPosition = "left", children, style, ref, ...props }) {
|
|
24
|
+
const { colors } = useThemeSafe();
|
|
25
|
+
const isDisabled = disabled || loading;
|
|
26
|
+
// Size configurations
|
|
27
|
+
const sizeConfigs = {
|
|
28
|
+
sm: {
|
|
29
|
+
paddingVertical: spacing.sm,
|
|
30
|
+
paddingHorizontal: spacing.md,
|
|
31
|
+
fontSize: 14,
|
|
32
|
+
iconSize: 16,
|
|
33
|
+
},
|
|
34
|
+
md: {
|
|
35
|
+
paddingVertical: 14,
|
|
36
|
+
paddingHorizontal: spacing.lg,
|
|
37
|
+
fontSize: 16,
|
|
38
|
+
iconSize: 20,
|
|
39
|
+
},
|
|
40
|
+
lg: {
|
|
41
|
+
paddingVertical: 18,
|
|
42
|
+
paddingHorizontal: spacing.xl,
|
|
43
|
+
fontSize: 18,
|
|
44
|
+
iconSize: 24,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const sizeConfig = sizeConfigs[size];
|
|
48
|
+
// Variant styles
|
|
49
|
+
const variantStyles = {
|
|
50
|
+
primary: {
|
|
51
|
+
backgroundColor: isDisabled ? colors.primaryLight : colors.primary,
|
|
52
|
+
textColor: colors.background,
|
|
53
|
+
},
|
|
54
|
+
secondary: {
|
|
55
|
+
backgroundColor: isDisabled ? colors.muted : colors.backgroundSecondary,
|
|
56
|
+
textColor: colors.foreground,
|
|
57
|
+
},
|
|
58
|
+
ghost: {
|
|
59
|
+
backgroundColor: "transparent",
|
|
60
|
+
textColor: colors.foreground,
|
|
61
|
+
},
|
|
62
|
+
destructive: {
|
|
63
|
+
backgroundColor: isDisabled ? colors.muted : colors.destructive,
|
|
64
|
+
textColor: colors.destructiveForeground,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
const currentVariant = variantStyles[variant];
|
|
68
|
+
const buttonStyle = [
|
|
69
|
+
styles.button,
|
|
70
|
+
{
|
|
71
|
+
backgroundColor: currentVariant.backgroundColor,
|
|
72
|
+
paddingVertical: sizeConfig.paddingVertical,
|
|
73
|
+
paddingHorizontal: sizeConfig.paddingHorizontal,
|
|
74
|
+
opacity: isDisabled ? 0.5 : 1,
|
|
75
|
+
},
|
|
76
|
+
style,
|
|
77
|
+
];
|
|
78
|
+
const renderContent = () => {
|
|
79
|
+
if (loading) {
|
|
80
|
+
return <ActivityIndicator size="small" color={currentVariant.textColor}/>;
|
|
81
|
+
}
|
|
82
|
+
const iconElement = icon ? (<Ionicons name={icon} size={sizeConfig.iconSize} color={currentVariant.textColor} style={children && iconPosition === "left" ? styles.iconLeft : children && iconPosition === "right" ? styles.iconRight : undefined}/>) : null;
|
|
83
|
+
if (!children) {
|
|
84
|
+
return iconElement;
|
|
85
|
+
}
|
|
86
|
+
return (<View style={styles.content}>
|
|
87
|
+
{iconPosition === "left" && iconElement}
|
|
88
|
+
<Text style={{
|
|
89
|
+
color: currentVariant.textColor,
|
|
90
|
+
fontSize: sizeConfig.fontSize,
|
|
91
|
+
fontWeight: "600",
|
|
92
|
+
}}>
|
|
93
|
+
{children}
|
|
94
|
+
</Text>
|
|
95
|
+
{iconPosition === "right" && iconElement}
|
|
96
|
+
</View>);
|
|
97
|
+
};
|
|
98
|
+
return (<TouchableOpacity style={buttonStyle} disabled={isDisabled} activeOpacity={0.7} ref={ref} {...props}>
|
|
99
|
+
{renderContent()}
|
|
100
|
+
</TouchableOpacity>);
|
|
101
|
+
}
|
|
102
|
+
const styles = StyleSheet.create({
|
|
103
|
+
button: {
|
|
104
|
+
borderRadius: borderRadius.full,
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
justifyContent: "center",
|
|
107
|
+
},
|
|
108
|
+
content: {
|
|
109
|
+
flexDirection: "row",
|
|
110
|
+
alignItems: "center",
|
|
111
|
+
justifyContent: "center",
|
|
112
|
+
},
|
|
113
|
+
iconLeft: {
|
|
114
|
+
marginRight: spacing.sm,
|
|
115
|
+
},
|
|
116
|
+
iconRight: {
|
|
117
|
+
marginLeft: spacing.sm,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,gBAAgB,EAAyB,IAAI,EAAa,MAAM,cAAc,CAAC;AACvH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAiC9B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,OAAO,GAAG,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,IAAI,EAAE,YAAY,GAAG,MAAM,EAAE,QAAQ,EA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,IAAI,CACD,KAAK,CAAC,CAAC;gBACH,KAAK,EAAE,cAAc,CAAC,SAAS;gBAC/B,QAAQ,EAAE,UAAU,CAAC,QAAQ;gBAC7B,UAAU,EAAE,KAAK;aACpB,CAAC,CAEF;oBAAA,CAAC,QAAQ,CACb;gBAAA,EAAE,IAAI,CACN;gBAAA,CAAC,YAAY,KAAK,OAAO,IAAI,WAAW,CAC5C;YAAA,EAAE,IAAI,CAAC,CACV,CAAC;IACN,CAAC,CAAC;IAEF,OAAO,CACH,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAChG;YAAA,CAAC,aAAa,EAAE,CACpB;QAAA,EAAE,gBAAgB,CAAC,CACtB,CAAC;AACN,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC7B,MAAM,EAAE;QACJ,YAAY,EAAE,YAAY,CAAC,IAAI;QAC/B,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KAC3B;IACD,OAAO,EAAE;QACL,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KAC3B;IACD,QAAQ,EAAE;QACN,WAAW,EAAE,OAAO,CAAC,EAAE;KAC1B;IACD,SAAS,EAAE;QACP,UAAU,EAAE,OAAO,CAAC,EAAE;KACzB;CACJ,CAAC,CAAC","sourcesContent":["import { Ionicons } from \"@expo/vector-icons\";\nimport React from \"react\";\nimport { ActivityIndicator, StyleSheet, TouchableOpacity, TouchableOpacityProps, View, ViewStyle } from \"react-native\";\nimport { useThemeSafe } from \"../theme\";\nimport { borderRadius, spacing } from \"../utils/styles\";\nimport { Text } from \"./Text\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"ghost\" | \"destructive\";\nexport type ButtonSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface ButtonProps extends Omit<TouchableOpacityProps, \"style\"> {\n /** Button visual variant */\n variant?: ButtonVariant;\n /** Button size */\n size?: ButtonSize;\n /** Show loading spinner */\n loading?: boolean;\n /** Disable button interactions */\n disabled?: boolean;\n /** Icon name from Ionicons */\n icon?: keyof typeof Ionicons.glyphMap;\n /** Icon position relative to children */\n iconPosition?: \"left\" | \"right\";\n /** Button content */\n children?: React.ReactNode;\n /** Custom style */\n style?: TouchableOpacityProps[\"style\"];\n /** Ref to the button view */\n ref?: React.RefObject<View | null>;\n}\n\ninterface SizeConfig {\n paddingVertical: number;\n paddingHorizontal: number;\n fontSize: number;\n iconSize: number;\n}\n\n/**\n * Button component with variants, sizes, and icon support.\n *\n * @example\n * ```tsx\n * <Button variant=\"primary\" onPress={handlePress}>\n * Submit\n * </Button>\n *\n * <Button variant=\"secondary\" icon=\"add\" size=\"sm\">\n * Add Item\n * </Button>\n *\n * <Button variant=\"ghost\" icon=\"settings\" />\n * ```\n */\nexport function Button({ variant = \"primary\", size = \"md\", loading = false, disabled = false, icon, iconPosition = \"left\", children, style, ref, ...props }: ButtonProps) {\n const { colors } = useThemeSafe();\n\n const isDisabled = disabled || loading;\n\n // Size configurations\n const sizeConfigs: Record<ButtonSize, SizeConfig> = {\n sm: {\n paddingVertical: spacing.sm,\n paddingHorizontal: spacing.md,\n fontSize: 14,\n iconSize: 16,\n },\n md: {\n paddingVertical: 14,\n paddingHorizontal: spacing.lg,\n fontSize: 16,\n iconSize: 20,\n },\n lg: {\n paddingVertical: 18,\n paddingHorizontal: spacing.xl,\n fontSize: 18,\n iconSize: 24,\n },\n };\n\n const sizeConfig = sizeConfigs[size];\n\n // Variant styles\n const variantStyles: Record<ButtonVariant, { backgroundColor: string; textColor: string }> = {\n primary: {\n backgroundColor: isDisabled ? colors.primaryLight : colors.primary,\n textColor: colors.background,\n },\n secondary: {\n backgroundColor: isDisabled ? colors.muted : colors.backgroundSecondary,\n textColor: colors.foreground,\n },\n ghost: {\n backgroundColor: \"transparent\",\n textColor: colors.foreground,\n },\n destructive: {\n backgroundColor: isDisabled ? colors.muted : colors.destructive,\n textColor: colors.destructiveForeground,\n },\n };\n\n const currentVariant = variantStyles[variant];\n\n const buttonStyle: ViewStyle[] = [\n styles.button,\n {\n backgroundColor: currentVariant.backgroundColor,\n paddingVertical: sizeConfig.paddingVertical,\n paddingHorizontal: sizeConfig.paddingHorizontal,\n opacity: isDisabled ? 0.5 : 1,\n },\n style as ViewStyle,\n ];\n\n const renderContent = () => {\n if (loading) {\n return <ActivityIndicator size=\"small\" color={currentVariant.textColor} />;\n }\n\n const iconElement = icon ? (\n <Ionicons\n name={icon}\n size={sizeConfig.iconSize}\n color={currentVariant.textColor}\n style={children && iconPosition === \"left\" ? styles.iconLeft : children && iconPosition === \"right\" ? styles.iconRight : undefined}\n />\n ) : null;\n\n if (!children) {\n return iconElement;\n }\n\n return (\n <View style={styles.content}>\n {iconPosition === \"left\" && iconElement}\n <Text\n style={{\n color: currentVariant.textColor,\n fontSize: sizeConfig.fontSize,\n fontWeight: \"600\",\n }}\n >\n {children}\n </Text>\n {iconPosition === \"right\" && iconElement}\n </View>\n );\n };\n\n return (\n <TouchableOpacity style={buttonStyle} disabled={isDisabled} activeOpacity={0.7} ref={ref} {...props}>\n {renderContent()}\n </TouchableOpacity>\n );\n}\n\nconst styles = StyleSheet.create({\n button: {\n borderRadius: borderRadius.full,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n content: {\n flexDirection: \"row\",\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n iconLeft: {\n marginRight: spacing.sm,\n },\n iconRight: {\n marginLeft: spacing.sm,\n },\n});\n"]}
|