@oxyhq/services
Version:
147 lines (145 loc) • 5.23 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.GroupedItem = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _vectorIcons = require("@expo/vector-icons");
var _useColorScheme = require("../hooks/useColorScheme.js");
var _colorUtils = require("../utils/colorUtils.js");
var _themeUtils = require("../utils/themeUtils.js");
var _theme = require("../constants/theme.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
// @ts-ignore - MaterialCommunityIcons is available at runtime
const GroupedItemComponent = ({
icon,
iconColor,
title,
subtitle,
onPress,
isFirst = false,
isLast = false,
showChevron = false,
disabled = false,
customContent,
customIcon,
accessibilityLabel,
accessibilityHint
}) => {
const hookColorScheme = (0, _useColorScheme.useColorScheme)();
const colorScheme = (0, _themeUtils.normalizeColorScheme)(hookColorScheme);
// GroupedItem is a leaf component without a theme prop, so it should directly use Colors
// instead of useThemeStyles which expects a theme prop from screen components
const colors = _theme.Colors[colorScheme];
// Use fallback color when iconColor is not provided
const finalIconColor = iconColor || colors.iconSecurity;
const itemStyles = (0, _react.useMemo)(() => [styles.groupedItem, isFirst && styles.firstGroupedItem, isLast && styles.lastGroupedItem, {
backgroundColor: colors.card
}], [colors.card, isFirst, isLast]);
const content = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: styles.groupedItemContent,
children: [customIcon ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: styles.actionIcon,
children: customIcon
}) : icon ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: [styles.iconContainer, {
backgroundColor: finalIconColor
}],
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.MaterialCommunityIcons, {
name: icon,
size: 22,
color: (0, _colorUtils.darkenColor)(finalIconColor)
})
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: styles.actionTextContainer,
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.actionButtonText, {
color: colors.text
}],
children: title
}), subtitle && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.actionButtonSubtext, {
color: colors.secondaryText
}],
children: subtitle
})]
}), customContent, showChevron && /*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.Ionicons, {
name: "chevron-forward",
size: 20,
color: colors.icon
})]
});
if (onPress && !disabled) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
style: itemStyles,
onPress: onPress,
activeOpacity: 0.7,
accessibilityRole: "button",
accessibilityLabel: accessibilityLabel || title,
accessibilityHint: accessibilityHint || subtitle,
accessibilityState: {
disabled
},
children: content
});
}
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: itemStyles,
accessibilityRole: "text",
accessibilityLabel: accessibilityLabel || title,
children: content
});
};
GroupedItemComponent.displayName = 'GroupedItem';
const GroupedItem = exports.GroupedItem = /*#__PURE__*/(0, _react.memo)(GroupedItemComponent);
const styles = _reactNative.StyleSheet.create({
groupedItem: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
overflow: 'hidden',
width: '100%'
},
firstGroupedItem: {
borderTopLeftRadius: 18,
borderTopRightRadius: 18
},
lastGroupedItem: {
borderBottomLeftRadius: 18,
borderBottomRightRadius: 18
},
groupedItemContent: {
flexDirection: 'row',
alignItems: 'center',
paddingVertical: 8,
paddingHorizontal: 10,
width: '100%',
gap: 10
},
actionIcon: {
// marginRight handled by gap
},
iconContainer: {
width: 36,
height: 36,
borderRadius: 18,
alignItems: 'center',
justifyContent: 'center'
// marginRight handled by gap
},
actionTextContainer: {
flex: 1
},
actionButtonText: {
fontSize: 14,
fontWeight: '400'
},
actionButtonSubtext: {
fontSize: 12,
marginTop: 2
}
});
var _default = exports.default = GroupedItem;
//# sourceMappingURL=GroupedItem.js.map