mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-05 22:56:11 +00:00
Refactor, hoist closure creation.
This commit is contained in:
@@ -7,9 +7,9 @@ Pod::Spec.new do |s|
|
||||
s.version = package['version']
|
||||
s.summary = package['description']
|
||||
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.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.requires_arc = true
|
||||
s.platforms = { :ios => "8.0", :tvos => "9.2" }
|
||||
|
||||
@@ -16,6 +16,15 @@ const touchableProps = [
|
||||
"delayLongPress",
|
||||
];
|
||||
|
||||
function hasTouchableProperty(props) {
|
||||
for (let prop of touchableProps) {
|
||||
if (props.hasOwnProperty(prop)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export default function(props, ref) {
|
||||
const extractedProps = {};
|
||||
|
||||
@@ -30,7 +39,7 @@ export default function(props, ref) {
|
||||
}
|
||||
}
|
||||
|
||||
if (touchableProps.some(key => props[key])) {
|
||||
if (hasTouchableProperty(props)) {
|
||||
extractedProps.responsible = true;
|
||||
Object.assign(extractedProps, {
|
||||
onStartShouldSetResponder:
|
||||
|
||||
@@ -93,6 +93,19 @@ export function extractFont(prop) {
|
||||
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) {
|
||||
const {
|
||||
x,
|
||||
@@ -116,13 +129,7 @@ export default function(props, container = false, TSpan) {
|
||||
children = null;
|
||||
}
|
||||
} else if (Children.count(children) > 1 || Array.isArray(children)) {
|
||||
children = Children.map(children, child => {
|
||||
if (typeof child === "string" || typeof child === "number") {
|
||||
return <TSpan>{child.toString()}</TSpan>;
|
||||
} else {
|
||||
return child;
|
||||
}
|
||||
});
|
||||
children = getChildren(children, TSpan);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user