mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-03 15:14:18 +00:00
Refactor, hoist closure creation.
This commit is contained in:
+2
-2
@@ -7,9 +7,9 @@ Pod::Spec.new do |s|
|
|||||||
s.version = package['version']
|
s.version = package['version']
|
||||||
s.summary = package['description']
|
s.summary = package['description']
|
||||||
s.license = package['license']
|
s.license = package['license']
|
||||||
s.homepage = 'https://github.com/magicismight/react-native-svg'
|
s.homepage = 'https://github.com/react-native-community/react-native-svg'
|
||||||
s.authors = 'Horcrux Chen'
|
s.authors = 'Horcrux Chen'
|
||||||
s.source = { :git => 'https://github.com/magicismight/react-native-svg.git', :tag => s.version }
|
s.source = { :git => 'https://github.com/react-native-community/react-native-svg.git', :tag => s.version }
|
||||||
s.source_files = 'ios/**/*.{h,m}'
|
s.source_files = 'ios/**/*.{h,m}'
|
||||||
s.requires_arc = true
|
s.requires_arc = true
|
||||||
s.platforms = { :ios => "8.0", :tvos => "9.2" }
|
s.platforms = { :ios => "8.0", :tvos => "9.2" }
|
||||||
|
|||||||
@@ -16,6 +16,15 @@ const touchableProps = [
|
|||||||
"delayLongPress",
|
"delayLongPress",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function hasTouchableProperty(props) {
|
||||||
|
for (let prop of touchableProps) {
|
||||||
|
if (props.hasOwnProperty(prop)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
export default function(props, ref) {
|
export default function(props, ref) {
|
||||||
const extractedProps = {};
|
const extractedProps = {};
|
||||||
|
|
||||||
@@ -30,7 +39,7 @@ export default function(props, ref) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (touchableProps.some(key => props[key])) {
|
if (hasTouchableProperty(props)) {
|
||||||
extractedProps.responsible = true;
|
extractedProps.responsible = true;
|
||||||
Object.assign(extractedProps, {
|
Object.assign(extractedProps, {
|
||||||
onStartShouldSetResponder:
|
onStartShouldSetResponder:
|
||||||
|
|||||||
@@ -93,6 +93,19 @@ export function extractFont(prop) {
|
|||||||
return { ...font, ...ownedFont };
|
return { ...font, ...ownedFont };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getChildren(children, TSpan) {
|
||||||
|
const reactChildren = Children.toArray(children);
|
||||||
|
const result = [];
|
||||||
|
for (let child of reactChildren) {
|
||||||
|
if (typeof child === "string" || typeof child === "number") {
|
||||||
|
result.push(<TSpan>{child.toString()}</TSpan>);
|
||||||
|
} else {
|
||||||
|
result.push(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
export default function(props, container = false, TSpan) {
|
export default function(props, container = false, TSpan) {
|
||||||
const {
|
const {
|
||||||
x,
|
x,
|
||||||
@@ -116,13 +129,7 @@ export default function(props, container = false, TSpan) {
|
|||||||
children = null;
|
children = null;
|
||||||
}
|
}
|
||||||
} else if (Children.count(children) > 1 || Array.isArray(children)) {
|
} else if (Children.count(children) > 1 || Array.isArray(children)) {
|
||||||
children = Children.map(children, child => {
|
children = getChildren(children, TSpan);
|
||||||
if (typeof child === "string" || typeof child === "number") {
|
|
||||||
return <TSpan>{child.toString()}</TSpan>;
|
|
||||||
} else {
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user