diff --git a/packages/shared/src/components/common/AppVersion.tsx b/packages/shared/src/components/common/AppVersion.tsx new file mode 100644 index 00000000..1780da37 --- /dev/null +++ b/packages/shared/src/components/common/AppVersion.tsx @@ -0,0 +1,30 @@ +import React from 'react' +import { StyleSheet, Text } from 'react-native' + +import { ThemeConsumer } from '../context/ThemeContext' + +const pkg = require('shared/package.json') // tslint:disable-line + +const styles = StyleSheet.create({ + appVersion: { + alignSelf: 'center', + fontSize: 14, + lineHeight: 18, + textAlign: 'center', + }, +}) + +export function AppVersion() { + return ( + + {({ theme }) => ( + {`v${pkg.version}`} + )} + + ) +} diff --git a/packages/shared/src/components/modals/SettingsModal.tsx b/packages/shared/src/components/modals/SettingsModal.tsx index 112558f2..c2e7697e 100644 --- a/packages/shared/src/components/modals/SettingsModal.tsx +++ b/packages/shared/src/components/modals/SettingsModal.tsx @@ -1,21 +1,33 @@ import hoistNonReactStatics from 'hoist-non-react-statics' import React, { PureComponent } from 'react' -import { ScrollView, Text, TouchableOpacity, View } from 'react-native' +import { ScrollView, Text, View } from 'react-native' import { connect } from 'react-redux' import * as actions from '../../redux/actions' -import * as colors from '../../styles/colors' +import * as selectors from '../../redux/selectors' import { contentPadding } from '../../styles/variables' import { ExtractPropsFromConnector } from '../../types' import { ModalColumn } from '../columns/ModalColumn' +import { AppVersion } from '../common/AppVersion' +import { Avatar } from '../common/Avatar' import { Button } from '../common/Button' +import { H2 } from '../common/H2' +import { Link } from '../common/Link' +import { Spacer } from '../common/Spacer' import { DimensionsConsumer } from '../context/DimensionsContext' +import { ThemeConsumer } from '../context/ThemeContext' import { ThemePreference } from '../widgets/ThemePreference' export interface SettingsModalProps {} const connectToStore = connect( - null, + (state: any) => { + const user = selectors.currentUserSelector(state) + + return { + username: (user && user.login) || '', + } + }, { logout: actions.logout }, ) @@ -23,6 +35,8 @@ class SettingsModalComponent extends PureComponent< SettingsModalProps & ExtractPropsFromConnector > { render() { + const { username } = this.props + return ( + + + {({ theme }) => ( + + {({ width }) => { + if (!username) return null + if (!(width <= 420)) return null + + return ( + <> + + +

Account

+ + + + + + Logged as{' '} + + + {username} + + + + + + + + + ) + }} +
+ )} +
- - {({ width }) => - width <= 420 && ( - - - - ) - } - + + +
) } diff --git a/packages/shared/src/components/widgets/ThemePreference.tsx b/packages/shared/src/components/widgets/ThemePreference.tsx index 20a3d530..ab022286 100644 --- a/packages/shared/src/components/widgets/ThemePreference.tsx +++ b/packages/shared/src/components/widgets/ThemePreference.tsx @@ -88,12 +88,12 @@ class ThemePreferenceComponent extends PureComponent< alignItems: 'center', justifyContent: 'center', marginRight: contentPadding / 2, - width: 32, - height: 32, - borderRadius: 32 / 2, + width: 28, + height: 28, + borderRadius: 28 / 2, backgroundColor: theme.backgroundColor, borderWidth: StyleSheet.hairlineWidth, - borderColor: theme.foregroundColorMuted50, + borderColor: theme.backgroundColorDarker08, }} > + + )} diff --git a/packages/shared/src/screens/LoginScreen.tsx b/packages/shared/src/screens/LoginScreen.tsx index 06647762..0ceed09d 100644 --- a/packages/shared/src/screens/LoginScreen.tsx +++ b/packages/shared/src/screens/LoginScreen.tsx @@ -8,6 +8,7 @@ import { import { connect } from 'react-redux' import { GitHubLoginButton } from '../components/buttons/GitHubLoginButton' +import { AppVersion } from '../components/common/AppVersion' import { Screen } from '../components/common/Screen' import { ThemeConsumer } from '../components/context/ThemeContext' import { executeOAuth } from '../libs/oauth' @@ -17,7 +18,6 @@ import { contentPadding } from '../styles/variables' import { ExtractPropsFromConnector } from '../types' const logo = require('shared/assets/logo.png') // tslint:disable-line -const pkg = require('shared/package.json') // tslint:disable-line const serverURL = 'https://micro-oauth-pmkvlpfaua.now.sh' @@ -185,12 +185,7 @@ export class LoginScreenComponent extends PureComponent< > TweetDeck for GitHub - {`v${pkg.version}`} +