Changeset View
Changeset View
Standalone View
Standalone View
native/components/user-list-user.react.js
// @flow | // @flow | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { Text, Platform, Alert } from 'react-native'; | import { Text, Platform, Alert } from 'react-native'; | ||||
import type { UserListItem } from 'lib/types/user-types.js'; | import type { UserListItem, AccountUserInfo } from 'lib/types/user-types.js'; | ||||
import Button from './button.react.js'; | import Button from './button.react.js'; | ||||
import { SingleLine } from './single-line.react.js'; | import { SingleLine } from './single-line.react.js'; | ||||
import UserAvatar from '../avatars/user-avatar.react.js'; | import UserAvatar from '../avatars/user-avatar.react.js'; | ||||
import { type Colors, useColors, useStyles } from '../themes/colors.js'; | import { type Colors, useColors, useStyles } from '../themes/colors.js'; | ||||
import type { TextStyle } from '../types/styles.js'; | import type { TextStyle } from '../types/styles.js'; | ||||
// eslint-disable-next-line no-unused-vars | // eslint-disable-next-line no-unused-vars | ||||
const getUserListItemHeight = (item: UserListItem): number => { | const getUserListItemHeight = (item: UserListItem): number => { | ||||
// TODO consider parent thread notice | // TODO consider parent thread notice | ||||
return Platform.OS === 'ios' ? 31.5 : 33.5; | return Platform.OS === 'ios' ? 31.5 : 33.5; | ||||
}; | }; | ||||
type BaseProps = { | type BaseProps = { | ||||
+userInfo: UserListItem, | +userInfo: UserListItem, | ||||
+onSelect: (userID: string) => void, | +onSelect: (user: AccountUserInfo) => void, | ||||
+textStyle?: TextStyle, | +textStyle?: TextStyle, | ||||
}; | }; | ||||
type Props = { | type Props = { | ||||
...BaseProps, | ...BaseProps, | ||||
// Redux state | // Redux state | ||||
+colors: Colors, | +colors: Colors, | ||||
+styles: typeof unboundStyles, | +styles: typeof unboundStyles, | ||||
}; | }; | ||||
Show All 22 Lines | return ( | ||||
{notice} | {notice} | ||||
</Button> | </Button> | ||||
); | ); | ||||
} | } | ||||
onSelect = () => { | onSelect = () => { | ||||
const { userInfo } = this.props; | const { userInfo } = this.props; | ||||
if (!userInfo.alertText) { | if (!userInfo.alertText) { | ||||
this.props.onSelect(userInfo.id); | const { alertText, alertTitle, notice, disabled, ...accountUserInfo } = | ||||
userInfo; | |||||
this.props.onSelect(accountUserInfo); | |||||
return; | return; | ||||
} | } | ||||
Alert.alert(userInfo.alertTitle, userInfo.alertText, [{ text: 'OK' }], { | Alert.alert(userInfo.alertTitle, userInfo.alertText, [{ text: 'OK' }], { | ||||
cancelable: true, | cancelable: true, | ||||
}); | }); | ||||
}; | }; | ||||
} | } | ||||
Show All 27 Lines |