diff --git a/demo/src/screens/PlaygroundScreen.tsx b/demo/src/screens/PlaygroundScreen.tsx
index 0bda100e67..5d96aefc65 100644
--- a/demo/src/screens/PlaygroundScreen.tsx
+++ b/demo/src/screens/PlaygroundScreen.tsx
@@ -1,18 +1,33 @@
import React, {Component} from 'react';
-import {View, Text, Card, TextField, Button} from 'react-native-ui-lib';
+import {View, Icon, Assets, Colors} from 'react-native-ui-lib';
export default class PlaygroundScreen extends Component {
render() {
return (
-
-
-
- Playground Screen
-
-
-
+
+
);
diff --git a/src/assets/internal/icons/addFlat.svg b/src/assets/internal/icons/addFlat.svg
new file mode 100644
index 0000000000..34ff28a1a1
--- /dev/null
+++ b/src/assets/internal/icons/addFlat.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/assets/internal/icons/heart.svg b/src/assets/internal/icons/heart.svg
new file mode 100644
index 0000000000..9fbe923f00
--- /dev/null
+++ b/src/assets/internal/icons/heart.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/assets/internal/icons/index.js b/src/assets/internal/icons/index.js
index e959377ab2..8cad3cca2b 100644
--- a/src/assets/internal/icons/index.js
+++ b/src/assets/internal/icons/index.js
@@ -46,5 +46,11 @@ export const icons = {
},
get xSmall() {
return require('./xSmall.png');
+ },
+ get addFlat() {
+ return require('./addFlat.svg').default;
+ },
+ get heart() {
+ return require('./heart.svg').default;
}
};
diff --git a/src/components/svgImage/index.tsx b/src/components/svgImage/index.tsx
index f7c16ddd5f..302c297f7a 100644
--- a/src/components/svgImage/index.tsx
+++ b/src/components/svgImage/index.tsx
@@ -1,4 +1,5 @@
import React from 'react';
+import {StyleProp, ImageStyle, ColorValue} from 'react-native';
import {isSvg, isSvgUri} from '../../utils/imageUtils';
import {SvgPackage, SvgCssUri} from '../../optionalDependencies';
import {LogService} from 'services';
@@ -6,18 +7,37 @@ import {LogService} from 'services';
const SvgXml = SvgPackage?.SvgXml;
// const SvgProps = SvgPackage?.SvgProps; TODO: not sure how (or if) we can use their props
+type SvgTintProps = {
+ fill?: ColorValue;
+ stroke?: ColorValue;
+};
+
+const createSvgTintProps = (style: StyleProp | undefined,
+ tintColor: string | null | undefined): SvgTintProps | undefined => {
+ const svgProps: SvgTintProps = {};
+ const effectiveTintColor =
+ (style && typeof style === 'object' && 'tintColor' in style ? style.tintColor : undefined) || tintColor;
+
+ if (effectiveTintColor) {
+ svgProps.fill = effectiveTintColor;
+ svgProps.stroke = effectiveTintColor;
+ }
+ return svgProps;
+};
+
export interface SvgImageProps {
/**
* the asset tint
*/
tintColor?: string | null;
data: any; // TODO: I thought this should be string | React.ReactNode but it doesn't work properly
+ style?: StyleProp | undefined;
}
function SvgImage(props: SvgImageProps) {
// tintColor crashes Android, so we're removing this until we properly support it.
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
- const {data, tintColor, ...others} = props;
+ const {data, tintColor, style, ...others} = props;
if (!SvgXml) {
// eslint-disable-next-line max-len
@@ -31,7 +51,8 @@ function SvgImage(props: SvgImageProps) {
return ;
} else if (data) {
const File = data; // Must be with capital letter
- return ;
+ const svgProps = createSvgTintProps(style, tintColor);
+ return ;
}
return null;