-
-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
332 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* @flow strict-local */ | ||
import React, { PureComponent } from 'react'; | ||
import { connect } from 'react-redux'; | ||
|
||
import type { Dispatch, GlobalState, User, UserStatusMapObject } from '../types'; | ||
import { OptionRow } from '../common'; | ||
import { getSelfUserDetail, getUserStatus } from '../selectors'; | ||
import { updateUserAwayStatus } from '../user-status/userStatusActions'; | ||
|
||
type PropsFromState = {| | ||
selfUserDetail: User, | ||
userStatus: UserStatusMapObject, | ||
|}; | ||
|
||
type Props = {| | ||
...PropsFromState, | ||
dispatch: Dispatch, | ||
|}; | ||
|
||
class AwayStatusSwitch extends PureComponent<Props> { | ||
handleUpdateAwayStatus = (away: boolean) => { | ||
const { dispatch } = this.props; | ||
dispatch(updateUserAwayStatus(away)); | ||
}; | ||
|
||
render() { | ||
const { selfUserDetail, userStatus } = this.props; | ||
const selfUserStatus = userStatus[selfUserDetail.user_id]; | ||
const away = !!(selfUserStatus && selfUserStatus.away); | ||
|
||
return ( | ||
<OptionRow | ||
label="Set yourself to away" | ||
defaultValue={away} | ||
onValueChange={this.handleUpdateAwayStatus} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
export default connect((state: GlobalState) => ({ | ||
selfUserDetail: getSelfUserDetail(state), | ||
userStatus: getUserStatus(state), | ||
}))(AwayStatusSwitch); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* @flow strict-local */ | ||
import React, { PureComponent } from 'react'; | ||
import { StyleSheet, View } from 'react-native'; | ||
import { connect } from 'react-redux'; | ||
|
||
import type { Dispatch, GlobalState, User } from '../types'; | ||
import { getSelfUserDetail } from '../selectors'; | ||
import { ZulipButton } from '../common'; | ||
import { navigateToUserStatus } from '../actions'; | ||
import AccountDetails from './AccountDetails'; | ||
import AwayStatusSwitch from './AwayStatusSwitch'; | ||
import SwitchAccountButton from './SwitchAccountButton'; | ||
import LogoutButton from './LogoutButton'; | ||
|
||
const componentStyles = StyleSheet.create({ | ||
accountButtons: { | ||
alignItems: 'flex-end', | ||
flexDirection: 'row', | ||
marginHorizontal: 8, | ||
}, | ||
}); | ||
|
||
type Props = {| | ||
dispatch: Dispatch, | ||
selfUserDetail: User, | ||
|}; | ||
|
||
class ProfileCard extends PureComponent<Props> { | ||
handleSetUserStatus = () => { | ||
const { dispatch } = this.props; | ||
dispatch(navigateToUserStatus()); | ||
}; | ||
|
||
render() { | ||
const { selfUserDetail } = this.props; | ||
|
||
return ( | ||
<View> | ||
<AccountDetails user={selfUserDetail} /> | ||
<AwayStatusSwitch /> | ||
<ZulipButton | ||
style={componentStyles.accountButtons} | ||
secondary | ||
text="Set a status" | ||
onPress={this.handleSetUserStatus} | ||
/> | ||
<View style={componentStyles.accountButtons}> | ||
<SwitchAccountButton /> | ||
<LogoutButton /> | ||
</View> | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
export default connect((state: GlobalState) => ({ | ||
selfUserDetail: getSelfUserDetail(state), | ||
}))(ProfileCard); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* @flow strict-local */ | ||
import React, { PureComponent } from 'react'; | ||
import { connect } from 'react-redux'; | ||
|
||
import type { GlobalState, User } from '../types'; | ||
import { getCurrentRealm, getSelfUserDetail } from '../selectors'; | ||
import ImageAvatar from './ImageAvatar'; | ||
import { getAvatarFromUser } from '../utils/avatar'; | ||
|
||
type Props = {| | ||
user: User, | ||
size: number, | ||
realm: string, | ||
|}; | ||
|
||
/** | ||
* Renders an image of the current user's avatar | ||
* | ||
* @prop [size] - Sets width and height in pixels. | ||
* @prop [user] - Current presence for this user used to determine status. | ||
* @prop [realm] - Current realm url, used if avatarUrl is relative. | ||
*/ | ||
class OwnAvatar extends PureComponent<Props> { | ||
render() { | ||
const { user, size, realm } = this.props; | ||
const fullAvatarUrl = getAvatarFromUser(user, realm); | ||
return <ImageAvatar avatarUrl={fullAvatarUrl} size={size} shape="circle" />; | ||
} | ||
} | ||
|
||
export default connect((state: GlobalState) => ({ | ||
realm: getCurrentRealm(state), | ||
user: getSelfUserDetail(state), | ||
}))(OwnAvatar); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.