react95-native
Version:
Refreshed Windows 95 style UI components for your React Native app
92 lines (89 loc) • 2.64 kB
JavaScript
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { withTheme } from '../../core/theming';
import { Panel, Button, Text, CloseIcon } from '../..';
const Window = ({
active = true,
children,
onClose,
onMaximize,
onMinimize,
style = {},
theme,
title = '',
...rest
}) => {
return /*#__PURE__*/React.createElement(Panel, _extends({
theme: theme,
variant: "raised",
elevation: 4,
style: [styles.window, {
backgroundColor: theme.material
}, style]
}, rest), /*#__PURE__*/React.createElement(View, {
style: [styles.titleBar, styles.flex, {
backgroundColor: active ? theme.headerBackground : theme.headerNotActiveBackground
}]
}, /*#__PURE__*/React.createElement(View, {
style: [styles.flex]
}, /*#__PURE__*/React.createElement(Text, {
theme: theme,
bold: true // TODO: truncate window title when window is really small
,
ellipsizeMode: "tail",
numberOfLines: 1,
style: [styles.titleBarText, {
color: active ? theme.headerText : theme.headerNotActiveText
}]
}, title)), /*#__PURE__*/React.createElement(View, {
style: [styles.flex]
}, /*#__PURE__*/React.createElement(View, {
style: [styles.flex, styles.buttonGroup]
}, onMinimize && /*#__PURE__*/React.createElement(Button, {
theme: theme,
onPress: onMinimize,
style: [styles.button]
}, "_"), onMaximize && /*#__PURE__*/React.createElement(Button, {
theme: theme,
onPress: onMaximize,
style: [styles.button]
}, "[]")), onClose && /*#__PURE__*/React.createElement(Button, {
theme: theme,
onPress: onClose,
style: [styles.button]
}, /*#__PURE__*/React.createElement(CloseIcon, null)))), children);
};
const styles = StyleSheet.create({
flex: {
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-between',
alignContent: 'center',
alignItems: 'center'
},
window: {
position: 'relative',
paddingVertical: 6,
paddingHorizontal: 6
},
titleBar: {
height: 36,
margin: 2,
paddingRight: 4,
paddingLeft: 8
},
titleBarText: {
flexShrink: 1
},
buttonGroup: {
marginRight: 6
},
button: {
height: 28,
width: 32,
padding: 0
}
});
export default withTheme(Window);
//# sourceMappingURL=Window.js.map