This repository has been archived by the owner on Mar 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #773 from textileio/andrew/small-group-view-update
Small group view update
- Loading branch information
Showing
15 changed files
with
209 additions
and
240 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,76 @@ | ||
import React from 'react' | ||
import { View, Text, TouchableOpacity } from 'react-native' | ||
import TextileImage from '../TextileImage' | ||
import Avatar from '../Avatar' | ||
import Icon from '../Icon' | ||
import * as s from '../../Themes/Constants' | ||
import { ThreadFilesInfo } from '../../NativeModules/Textile' | ||
|
||
import styles, { cardImageStyle, ICON_WIDTH, ROW_COLUMN } from './statics/styles' | ||
|
||
interface ScreenProps { | ||
id: string | ||
name: string | ||
authors: string[] | ||
thumb?: ThreadFilesInfo | ||
onPress: (groupCardProps: any) => void | ||
} | ||
|
||
const GroupCard = (props: ScreenProps) => { | ||
const { name, authors, thumb } = props | ||
const getCallback = () => { | ||
return () => { | ||
props.onPress(props) | ||
} | ||
} | ||
const getThumb = (): JSX.Element => { | ||
if (thumb) { | ||
return ( | ||
<View style={styles.imageContainer}> | ||
<View style={styles.imageStretch}> | ||
<TextileImage | ||
target={thumb.target} | ||
index={0} | ||
forMinWidth={ICON_WIDTH} | ||
resizeMode={'cover'} | ||
style={{height: ROW_COLUMN}} | ||
/> | ||
</View> | ||
</View> | ||
) | ||
} | ||
return ( | ||
<Icon | ||
style={styles.iconStyle} | ||
name={'camera'} | ||
size={ICON_WIDTH} | ||
color={s.COLOR_FONT_DARK_ON_LIGHT_LIGHT} | ||
/> | ||
) | ||
} | ||
return ( | ||
<TouchableOpacity | ||
style={styles.groupCard} | ||
activeOpacity={0.95} | ||
// ts-ignore | ||
onPress={getCallback()} | ||
> | ||
<View style={styles.groupLeftColumn}> | ||
{getThumb()} | ||
</View> | ||
<View style={styles.groupMiddleColumn}> | ||
<Text numberOfLines={2} style={styles.groupName}>{name}</Text> | ||
</View> | ||
<View style={styles.groupRightColumn}> | ||
<View style={styles.avatarContainer}> | ||
{ authors.slice(0, 8).map((authorId: string, i: number) => { | ||
const imageStyle = cardImageStyle(authors, i) | ||
return (<Avatar key={authorId} style={imageStyle} peerId={authorId} />) | ||
})} | ||
</View> | ||
</View> | ||
</TouchableOpacity> | ||
) | ||
} | ||
|
||
export default GroupCard |
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,97 @@ | ||
import { StyleSheet, ImageStyle } from 'react-native' | ||
import * as s from '../../../Themes/Constants' | ||
|
||
export const ROW_HEIGHT = 90 | ||
export const ROW_COLUMN = 60 | ||
|
||
export const ICON_WIDTH = ROW_COLUMN * 0.5 | ||
|
||
export function cardImageStyle (list: string[], index: number): ImageStyle { | ||
const baseStyle = { | ||
margin: 0, | ||
padding: 0, | ||
borderWidth: 2, | ||
borderColor: s.COLOR_BACKGROUND_PRIMARY | ||
} as ImageStyle | ||
|
||
if (index >= 8) { | ||
return { | ||
display: 'none' | ||
} | ||
} | ||
|
||
const marginLeft = index === 0 || index === 4 ? 0 : -(0.27 * ROW_COLUMN) | ||
const marginBottom = list.length >= 4 ? -(0.44 * ROW_COLUMN) : 0 | ||
const marginTop = 0 | ||
return { | ||
...baseStyle, | ||
width: ROW_COLUMN * 0.66, | ||
backgroundColor: 'white', // avoids any transparencies blending | ||
marginBottom, | ||
marginLeft, | ||
marginTop, | ||
alignSelf: list.length >= 4 ? 'flex-start' : 'center' | ||
} | ||
} | ||
|
||
export default StyleSheet.create({ | ||
groupCard: { | ||
flex: 1, | ||
flexDirection: 'row', | ||
height: ROW_HEIGHT, | ||
marginHorizontal: 22, | ||
alignSelf: 'center', | ||
borderBottomColor: s.COLOR_GREY_LIGHT, | ||
borderBottomWidth: 1 | ||
}, | ||
groupRightColumn: { | ||
width: ROW_COLUMN * 2, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
flexDirection: 'row' | ||
}, | ||
avatarContainer: { | ||
width: ROW_COLUMN * 2, | ||
height: ROW_HEIGHT / 2, | ||
flexWrap: 'wrap', | ||
justifyContent: 'flex-end', | ||
flexDirection: 'row', | ||
flex: 1 | ||
}, | ||
groupMiddleColumn: { | ||
alignItems: 'flex-start', | ||
justifyContent: 'center', | ||
paddingLeft: 18, | ||
flex: 1 | ||
}, | ||
groupName: { | ||
fontFamily: 'BentonSans', | ||
fontSize: 16, | ||
color: s.COLOR_FONT_DARK_ON_LIGHT_MEDIUM | ||
}, | ||
groupLeftColumn: { | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
width: ICON_WIDTH * 1.5 | ||
}, | ||
iconStyle: { | ||
margin: 0, | ||
padding: 0, | ||
width: ICON_WIDTH | ||
}, | ||
imageContainer: { | ||
overflow: 'hidden', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
borderRadius: 2, | ||
width: ROW_COLUMN, | ||
height: ROW_COLUMN | ||
}, | ||
imageStretch: { | ||
position: 'absolute', | ||
top: 0, | ||
bottom: 0, | ||
left: 0, | ||
right: 0 | ||
} | ||
}) |
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.