-
-
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
16 changed files
with
269 additions
and
37 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); | ||
console.log(selfUserDetail, userStatus, away); | ||
return ( | ||
<OptionRow | ||
label="Show me always as 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,63 @@ | ||
/* @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 SwitchAccountButton from './SwitchAccountButton'; | ||
import LogoutButton from './LogoutButton'; | ||
import AwayStatusSwitch from './AwayStatusSwitch'; | ||
|
||
const componentStyles = StyleSheet.create({ | ||
accountButtons: { | ||
alignItems: 'flex-end', | ||
flexDirection: 'row', | ||
marginHorizontal: 8, | ||
}, | ||
}); | ||
|
||
type PropsFromState = {| | ||
selfUserDetail: User, | ||
|}; | ||
|
||
type Props = {| | ||
...PropsFromState, | ||
dispatch: Dispatch, | ||
|}; | ||
|
||
class ProfileCard extends PureComponent<Props> { | ||
handleSetUserStatus = () => { | ||
const { dispatch } = this.props; | ||
dispatch(navigateToUserStatus()); | ||
}; | ||
|
||
handleUpdateAwayStatus = () => {}; | ||
|
||
render() { | ||
const { selfUserDetail } = this.props; | ||
|
||
return ( | ||
<View> | ||
<AccountDetails user={selfUserDetail} /> | ||
<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, props: PropsFromState) => ({ | ||
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,41 @@ | ||
/* @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, | ||
shape: 'square' | 'rounded' | 'circle', | ||
|}; | ||
|
||
/** | ||
* 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. | ||
* @prop [shape] - One of 'square', 'rounded', 'circle'. | ||
*/ | ||
class OwnAvatar extends PureComponent<Props> { | ||
static defaultProps = { | ||
size: 32, | ||
shape: 'rounded', | ||
}; | ||
|
||
render() { | ||
const { user, size, realm, shape } = this.props; | ||
const fullAvatarUrl = getAvatarFromUser(user, realm); | ||
return <ImageAvatar avatarUrl={fullAvatarUrl} size={size} shape={shape} />; | ||
} | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* @flow strict-local */ | ||
import { connect } from 'react-redux'; | ||
|
||
import React, { PureComponent } from 'react'; | ||
import { StyleSheet } from 'react-native'; | ||
|
||
import { Input, OptionButton, Screen } from '../common'; | ||
import statusSuggestions from './userStatusTextSuggestions'; | ||
|
||
const styles = StyleSheet.create({ | ||
statusTextInput: { | ||
margin: 16, | ||
}, | ||
}); | ||
|
||
type Props = {}; | ||
|
||
type Status = { | ||
statusText: string, | ||
}; | ||
|
||
class UserStatusScreen extends PureComponent<Props, Status> { | ||
state = { | ||
statusText: '', | ||
}; | ||
|
||
handleStatusTextChangeText = (statusText: string) => { | ||
this.setState({ | ||
statusText, | ||
}); | ||
}; | ||
|
||
render() { | ||
const { statusText } = this.state; | ||
return ( | ||
<Screen title="User status"> | ||
<Input | ||
style={styles.statusTextInput} | ||
placeholder="What's your status?" | ||
value={statusText} | ||
onChangeText={this.handleStatusTextChangeText} | ||
/> | ||
{statusSuggestions.map(statusSuggestion => ( | ||
<OptionButton | ||
key={statusSuggestion} | ||
label={statusSuggestion} | ||
onPress={() => { | ||
this.handleStatusTextChangeText(statusSuggestion); | ||
}} | ||
/> | ||
))} | ||
</Screen> | ||
); | ||
} | ||
} | ||
export default connect()(UserStatusScreen); |
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,8 @@ | ||
/* @flow strict-local */ | ||
export default [ | ||
'📅 In a meeting', | ||
'🚌 Commuting', | ||
'🤒 Out sick', | ||
'🌴 Vacationing', | ||
'🏠 Working remotely', | ||
]; |
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.