-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve notify item/room item style
Signed-off-by: Amir Movahedi <[email protected]>
- Loading branch information
Showing
6 changed files
with
77 additions
and
62 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,67 +1,67 @@ | ||
import React from 'react'; | ||
import ListItemText from '@material-ui/core/ListItemText'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import UserAvatar from 'components/userAvatar/UserAvatarComponent'; | ||
import React, { Component } from 'react'; | ||
import classNames from 'classnames'; | ||
import ListItemAvatar from '@material-ui/core/ListItemAvatar'; | ||
import Badge from '@material-ui/core/Badge'; | ||
import Typography from '@material-ui/core/Typography'; | ||
|
||
import useTheme from '@material-ui/core/styles/useTheme'; | ||
import { IRoomItemProps } from './IRoomItemProps'; | ||
import { IRoomItemState } from './IRoomItemState'; | ||
import { roomItemStyles } from './roomItemStyles'; | ||
import { Button } from '@material-ui/core'; | ||
import { useStyles } from './roomItemStyles'; | ||
|
||
export class RoomItemComponent extends Component<IRoomItemProps, IRoomItemState> { | ||
constructor(props: IRoomItemProps) { | ||
super(props); | ||
|
||
// Defaul state | ||
this.state = {}; | ||
|
||
// Binding functions to `this` | ||
this.handleOpenRoom = this.handleOpenRoom.bind(this); | ||
} | ||
export function RoomItemComponent(props: IRoomItemProps) { | ||
const classes = useStyles(); | ||
const theme = useTheme(); | ||
|
||
handleOpenRoom = (event: any) => { | ||
const handleOpenRoom = (event: any) => { | ||
event.preventDefault(); | ||
const { openRoom, room, closeRoomList } = this.props; | ||
const { openRoom, room, closeRoomList } = props; | ||
const roomId: string = room.get('roomId'); | ||
openRoom(roomId); | ||
closeRoomList(); | ||
}; | ||
|
||
render() { | ||
const { avatar, fullName, classes, room } = this.props; | ||
const roomId: string = room.get('objectId'); | ||
const unreadCount: string = room.get('unreadCount'); | ||
const lastMessageText = room.getIn(['lastMessage', 'text'], ''); | ||
return ( | ||
<Button | ||
key={`room-item-${roomId}`} | ||
className={classNames(classes.listItem)} | ||
onClick={this.handleOpenRoom} | ||
fullWidth | ||
component={'a'} | ||
> | ||
<ListItemAvatar> | ||
<UserAvatar fullName={fullName} size={40} fileName={avatar} /> | ||
</ListItemAvatar> | ||
<ListItemText | ||
className={classes.itemText} | ||
primary={fullName} | ||
secondary={ | ||
<Typography variant="body2" noWrap> | ||
{lastMessageText} | ||
</Typography> | ||
} | ||
/> | ||
const { avatar, fullName, room } = props; | ||
const roomId: string = room.get('objectId'); | ||
const unreadCount: string = room.get('unreadCount'); | ||
const lastMessageText = room.getIn(['lastMessage', 'text'], ''); | ||
return ( | ||
<Button | ||
key={`room-item-${roomId}`} | ||
className={classNames(classes.listItem)} | ||
onClick={handleOpenRoom} | ||
fullWidth | ||
component={'a'} | ||
> | ||
<ListItemAvatar> | ||
<UserAvatar fullName={fullName} size={40} fileName={avatar} /> | ||
</ListItemAvatar> | ||
<ListItemText | ||
className={classes.itemText} | ||
primary={ | ||
<Typography | ||
sx={{ textTransform: 'capitalize', color: theme.palette.text.primary }} | ||
variant="subtitle1" | ||
noWrap | ||
> | ||
{fullName} | ||
</Typography> | ||
} | ||
secondary={ | ||
<Typography | ||
sx={{ textTransform: 'none', color: theme.palette.text.secondary }} | ||
variant="body2" | ||
noWrap | ||
> | ||
{lastMessageText} | ||
</Typography> | ||
} | ||
/> | ||
|
||
<Badge badgeContent={unreadCount} color="secondary"></Badge> | ||
</Button> | ||
); | ||
} | ||
<Badge badgeContent={unreadCount} color="secondary"></Badge> | ||
</Button> | ||
); | ||
} | ||
|
||
// - Connect component to redux store | ||
export default withStyles(roomItemStyles)(RoomItemComponent); | ||
export default RoomItemComponent; |
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