Update build files

This commit is contained in:
Brent Vatne
2020-12-01 20:44:36 -08:00
parent b0d2898fcd
commit 6625c21a56
7 changed files with 30 additions and 188 deletions
+7 -5
View File
@@ -1,5 +1,5 @@
import React, { ComponentClass } from "react";
import { TextProps, TouchableHighlightProps, ViewProps } from "react-native";
import { TextProps, TouchableHighlightProps, ViewProps, OpaqueColorValue } from "react-native";
export { DEFAULT_ICON_COLOR, DEFAULT_ICON_SIZE } from "./vendor/react-native-vector-icons/lib/create-icon-set";
export interface IconButtonProps<GLYPHS extends string> extends ViewProps, TouchableHighlightProps {
/**
@@ -16,10 +16,11 @@ export interface IconButtonProps<GLYPHS extends string> extends ViewProps, Touch
*/
name: GLYPHS;
/**
* Color of the icon
* Color of the icon. Can be a string or OpaqueColorValue (returned from
* PlatformColor(..))
*
*/
color?: string;
color?: string | OpaqueColorValue;
}
export interface IconProps<GLYPHS extends string> extends TextProps {
/**
@@ -36,10 +37,11 @@ export interface IconProps<GLYPHS extends string> extends TextProps {
*/
name: GLYPHS;
/**
* Color of the icon
* Color of the icon. Can be a string or OpaqueColorValue (returned from
* PlatformColor(..))
*
*/
color?: string;
color?: string | OpaqueColorValue;
}
export declare type GlyphMap<G extends string> = {
[K in G]: number;
File diff suppressed because one or more lines are too long
@@ -1,18 +1,20 @@
/* eslint-disable react/no-unused-prop-types */
import isEqual from 'lodash.isequal';
import pick from 'lodash.pick';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { TabBarIOS } from './react-native';
import isEqual from "lodash.isequal";
import pick from "lodash.pick";
import React, { PureComponent } from "react";
import PropTypes from "prop-types";
const TabBarIOS = {
Item: function () {},
};
const ICON_PROP_NAMES = ['iconName', 'iconSize', 'iconColor'];
const ICON_PROP_NAMES = ["iconName", "iconSize", "iconColor"];
const SELECTED_ICON_PROP_NAMES = [
...ICON_PROP_NAMES,
'selectedIconName',
'selectedIconColor',
"selectedIconName",
"selectedIconColor",
];
const arePropsEqual = keys => (prevProps, nextProps) =>
const arePropsEqual = (keys) => (prevProps, nextProps) =>
isEqual(pick(prevProps, keys), pick(nextProps, keys));
const areIconPropsEqual = arePropsEqual(ICON_PROP_NAMES);
@@ -1,10 +0,0 @@
/* eslint-disable react/no-unused-prop-types */
import React, { PureComponent } from 'react';
export default function createTabBarItemIOSComponent(IconNamePropType, getImageSource) {
return class TabBarItemIOS extends PureComponent {
render() {
return null;
}
};
}
@@ -1,145 +0,0 @@
/* eslint-disable react/no-unused-prop-types */
import isEqual from 'lodash/isEqual';
import pick from 'lodash/pick';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { ToolbarAndroid } from 'react-native';
const ICON_PROP_NAMES = ['iconSize', 'iconColor', 'titleColor'];
const LOGO_ICON_PROP_NAMES = [...ICON_PROP_NAMES, 'logoName'];
const NAV_ICON_PROP_NAMES = [...ICON_PROP_NAMES, 'navIconName'];
const OVERFLOW_ICON_PROP_NAMES = [...ICON_PROP_NAMES, 'overflowIconName'];
const ACTIONS_PROP_NAMES = [...ICON_PROP_NAMES, 'actions'];
const arePropsEqual = keys => (prevProps, nextProps) =>
isEqual(pick(prevProps, keys), pick(nextProps, keys));
const areLogoIconPropsEqual = arePropsEqual(LOGO_ICON_PROP_NAMES);
const areNavIconPropsEqual = arePropsEqual(NAV_ICON_PROP_NAMES);
const areOverflowIconPropsEqual = arePropsEqual(OVERFLOW_ICON_PROP_NAMES);
const areActionPropsEqual = arePropsEqual(ACTIONS_PROP_NAMES);
export default function createToolbarAndroidComponent(
IconNamePropType,
getImageSource
) {
return class IconToolbarAndroid extends PureComponent {
static propTypes = {
logoName: IconNamePropType,
navIconName: IconNamePropType,
overflowIconName: IconNamePropType,
actions: PropTypes.arrayOf(
PropTypes.shape({
title: PropTypes.string.isRequired,
iconName: IconNamePropType,
iconSize: PropTypes.number,
iconColor: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
show: PropTypes.oneOf(['always', 'ifRoom', 'never']),
showWithText: PropTypes.bool,
})
),
iconSize: PropTypes.number,
iconColor: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
titleColor: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
};
static defaultProps = {
iconSize: 24,
};
state = {
logo: undefined,
navIcon: undefined,
overflowIcon: undefined,
actions: undefined,
};
componentDidMount() {
this.updateLogoIconSource();
this.updateNavIconSource();
this.updateOverflowIconSource();
this.updateActionIconSources();
}
componentDidUpdate(prevProps) {
if (!areLogoIconPropsEqual(prevProps, this.props)) {
this.updateLogoIconSource();
}
if (!areNavIconPropsEqual(prevProps, this.props)) {
this.updateNavIconSource();
}
if (!areOverflowIconPropsEqual(prevProps, this.props)) {
this.updateOverflowIconSource();
}
if (!areActionPropsEqual(prevProps, this.props)) {
this.updateActionIconSources();
}
}
async updateLogoIconSource() {
const { logoName, iconSize, iconColor, titleColor } = this.props;
if (logoName) {
const logo = await getImageSource(
logoName,
iconSize,
iconColor || titleColor
);
this.setState({ logo });
// eslint-disable-next-line react/destructuring-assignment
} else if (this.state.logo) {
this.setState({ logo: undefined });
}
}
async updateNavIconSource() {
const { navIconName, iconSize, iconColor, titleColor } = this.props;
if (navIconName) {
const navIcon = await getImageSource(
navIconName,
iconSize,
iconColor || titleColor
);
this.setState({ navIcon });
// eslint-disable-next-line react/destructuring-assignment
} else if (this.state.navIcon) {
this.setState({ navIcon: undefined });
}
}
async updateOverflowIconSource() {
const { overflowIconName, iconSize, iconColor, titleColor } = this.props;
if (overflowIconName) {
const overflowIcon = await getImageSource(
overflowIconName,
iconSize,
iconColor || titleColor
);
this.setState({ overflowIcon });
// eslint-disable-next-line react/destructuring-assignment
} else if (this.state.overflowIcon) {
this.setState({ overflowIcon: undefined });
}
}
async updateActionIconSources() {
const { actions, iconSize, iconColor, titleColor } = this.props;
const updatedActions = await Promise.all(
(actions || []).map(action => {
if (action.iconName) {
return getImageSource(
action.iconName,
action.iconSize || iconSize,
action.iconColor || iconColor || titleColor
).then(icon => ({ ...action, icon }));
}
return Promise.resolve(action);
})
);
this.setState({ actions: updatedActions });
}
render() {
return <ToolbarAndroid {...this.props} {...this.state} />;
}
};
}
@@ -1,9 +0,0 @@
/* eslint-disable react/no-unused-prop-types */
import React, { PureComponent } from 'react';
export default function createToolbarAndroidComponent(IconNamePropType, getImageSource) {
return class IconToolbarAndroid extends PureComponent {
render() {
return null;
}
};
}
@@ -1,18 +1,20 @@
/* eslint-disable react/no-unused-prop-types */
import isEqual from 'lodash.isequal';
import pick from 'lodash.pick';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { TabBarIOS } from './react-native';
import isEqual from "lodash.isequal";
import pick from "lodash.pick";
import React, { PureComponent } from "react";
import PropTypes from "prop-types";
const TabBarIOS = {
Item: function () {},
};
const ICON_PROP_NAMES = ['iconName', 'iconSize', 'iconColor'];
const ICON_PROP_NAMES = ["iconName", "iconSize", "iconColor"];
const SELECTED_ICON_PROP_NAMES = [
...ICON_PROP_NAMES,
'selectedIconName',
'selectedIconColor',
"selectedIconName",
"selectedIconColor",
];
const arePropsEqual = keys => (prevProps, nextProps) =>
const arePropsEqual = (keys) => (prevProps, nextProps) =>
isEqual(pick(prevProps, keys), pick(nextProps, keys));
const areIconPropsEqual = arePropsEqual(ICON_PROP_NAMES);