From 1958194e5ec2ca5234b6835280e17e4841402e23 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Wed, 1 Jul 2020 17:10:48 -0400 Subject: [PATCH 1/4] Refactor settings screen --- components/AppInfoFooter.js | 31 +++++++ components/BrowserListItem.js | 34 +++++++ components/ButtonListItem.js | 25 +++++ components/ServerListItem.js | 79 ++++++++++++++++ constants/Links.js | 5 + models/ServerModel.js | 53 +++++++++++ navigation/AppNavigator.js | 7 +- package.json | 1 + screens/HomeScreen.js | 51 +++-------- screens/NewSettingsScreen.js | 168 ++++++++++++++++++++++++++++++++++ stores/RootStore.js | 6 ++ stores/ServerStore.js | 19 +++- stores/SettingStore.js | 7 +- utils/Icons.js | 13 +++ utils/JellyfinValidator.js | 4 +- yarn.lock | 7 ++ 16 files changed, 464 insertions(+), 46 deletions(-) create mode 100644 components/AppInfoFooter.js create mode 100644 components/BrowserListItem.js create mode 100644 components/ButtonListItem.js create mode 100644 components/ServerListItem.js create mode 100644 models/ServerModel.js create mode 100644 screens/NewSettingsScreen.js create mode 100644 utils/Icons.js diff --git a/components/AppInfoFooter.js b/components/AppInfoFooter.js new file mode 100644 index 000000000..dd9dd76ad --- /dev/null +++ b/components/AppInfoFooter.js @@ -0,0 +1,31 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +import React from 'react'; +import { StyleSheet, View } from 'react-native'; +import { colors, Text } from 'react-native-elements'; +import Constants from 'expo-constants'; + +import { getAppName } from '../utils/Device'; + +const AppInfoFooter = () => ( + + {`${getAppName()}`} + {`${Constants.nativeAppVersion} (${Constants.nativeBuildVersion})`} + {`Expo Version: ${Constants.expoVersion}`} + +); + +const styles = StyleSheet.create({ + container: { + margin: 15 + }, + text: { + color: colors.grey4, + fontSize: 15 + } +}); + +export default AppInfoFooter; diff --git a/components/BrowserListItem.js b/components/BrowserListItem.js new file mode 100644 index 000000000..7526184cd --- /dev/null +++ b/components/BrowserListItem.js @@ -0,0 +1,34 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +import React from 'react'; +import { ListItem } from 'react-native-elements'; +import PropTypes from 'prop-types'; + +import { openBrowser } from '../utils/WebBrowser'; + +const BrowserListItem = ({item, index}) => ( + { + openBrowser(item.url); + }} + /> +); + +BrowserListItem.propTypes = { + item: PropTypes.shape({ + name: PropTypes.string.isRequired, + icon: PropTypes.string.isRequired, + url: PropTypes.string.isRequired + }).isRequired, + index: PropTypes.number.isRequired +}; + +export default BrowserListItem; diff --git a/components/ButtonListItem.js b/components/ButtonListItem.js new file mode 100644 index 000000000..99e718e0b --- /dev/null +++ b/components/ButtonListItem.js @@ -0,0 +1,25 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +import React from 'react'; +import { StyleSheet } from 'react-native'; +import { Button } from 'react-native-elements'; +import PropTypes from 'prop-types'; + +const ButtonListItem = ({item}) => ( +