More aesthetic and perf improvements to the menu drawer

zio/stable
Paul Frazee 2022-12-12 10:48:36 -06:00
parent 5fa3c16d0d
commit 03d9fd3179
2 changed files with 79 additions and 54 deletions

View File

@ -32,7 +32,8 @@ export const Menu = ({
useEffect(() => { useEffect(() => {
if (visible) { if (visible) {
// trigger a refresh in case memberships have changed recently // trigger a refresh in case memberships have changed recently
store.me.refreshMemberships() // TODO this impacts performance, need to find the right time to do this
// store.me.refreshMemberships()
} }
}, [store, visible]) }, [store, visible])
@ -97,34 +98,37 @@ export const Menu = ({
return ( return (
<View style={styles.view}> <View style={styles.view}>
<TouchableOpacity
onPress={() => onNavigate(`/profile/${store.me.handle}`)}
style={styles.profileCard}>
<UserAvatar
size={60}
displayName={store.me.displayName}
handle={store.me.handle}
avatar={store.me.avatar}
/>
<View style={s.flex1}>
<Text style={styles.profileCardDisplayName}>
{store.me.displayName}
</Text>
<Text style={styles.profileCardHandle}>{store.me.handle}</Text>
</View>
</TouchableOpacity>
<TouchableOpacity <TouchableOpacity
style={styles.searchBtn} style={styles.searchBtn}
onPress={() => onNavigate('/search')}> onPress={() => onNavigate('/search')}>
<MagnifyingGlassIcon <MagnifyingGlassIcon
style={{color: colors.gray5} as StyleProp<ViewStyle>} style={{color: colors.gray5} as StyleProp<ViewStyle>}
size={21} size={25}
/> />
<Text style={styles.searchBtnLabel}>Search</Text> <Text style={styles.searchBtnLabel}>Search</Text>
</TouchableOpacity> </TouchableOpacity>
<View style={styles.section}> <View style={styles.section}>
<MenuItem
icon={
<UserAvatar
size={24}
displayName={store.me.displayName}
handle={store.me.handle}
avatar={store.me.avatar}
/>
}
label={store.me.displayName || store.me.handle}
bold
url={`/profile/${store.me.handle}`}
/>
<MenuItem <MenuItem
icon={ icon={
<HomeIcon <HomeIcon
style={{color: colors.gray5} as StyleProp<ViewStyle>} style={{color: colors.gray6} as StyleProp<ViewStyle>}
size="24" size="26"
/> />
} }
label="Home" label="Home"
@ -133,45 +137,24 @@ export const Menu = ({
<MenuItem <MenuItem
icon={ icon={
<BellIcon <BellIcon
style={{color: colors.gray5} as StyleProp<ViewStyle>} style={{color: colors.gray6} as StyleProp<ViewStyle>}
size="24" size="28"
/> />
} }
label="Notifications" label="Notifications"
url="/notifications" url="/notifications"
count={store.me.notificationCount} count={store.me.notificationCount}
/> />
<MenuItem
icon={
<CogIcon
style={{color: colors.gray6} as StyleProp<ViewStyle>}
size="24"
strokeWidth={2}
/>
}
label="Settings"
url="/settings"
/>
</View> </View>
<View style={styles.section}> <View style={styles.section}>
<Text style={styles.heading}>Scenes</Text> <Text style={styles.heading}>Scenes</Text>
<MenuItem
icon={
<UserGroupIcon
style={{color: colors.gray6} as StyleProp<ViewStyle>}
size="24"
/>
}
label="Create a scene"
onPress={onPressCreateScene}
/>
{store.me.memberships {store.me.memberships
? store.me.memberships.memberships.map((membership, i) => ( ? store.me.memberships.memberships.map((membership, i) => (
<MenuItem <MenuItem
key={i} key={i}
icon={ icon={
<UserAvatar <UserAvatar
size={24} size={34}
displayName={membership.displayName} displayName={membership.displayName}
handle={membership.handle} handle={membership.handle}
avatar={membership.avatar} avatar={membership.avatar}
@ -183,6 +166,29 @@ export const Menu = ({
)) ))
: undefined} : undefined}
</View> </View>
<View style={styles.section}>
<MenuItem
icon={
<UserGroupIcon
style={{color: colors.gray6} as StyleProp<ViewStyle>}
size="30"
/>
}
label="Create a scene"
onPress={onPressCreateScene}
/>
<MenuItem
icon={
<CogIcon
style={{color: colors.gray6} as StyleProp<ViewStyle>}
size="30"
strokeWidth={2}
/>
}
label="Settings"
url="/settings"
/>
</View>
<View style={styles.footer}> <View style={styles.footer}>
<Text style={s.gray4}> <Text style={s.gray4}>
Build version {VersionNumber.appVersion} ({VersionNumber.buildVersion} Build version {VersionNumber.appVersion} ({VersionNumber.buildVersion}
@ -212,6 +218,24 @@ const styles = StyleSheet.create({
paddingHorizontal: 4, paddingHorizontal: 4,
}, },
profileCard: {
flexDirection: 'row',
alignItems: 'center',
margin: 10,
marginBottom: 6,
},
profileCardDisplayName: {
marginLeft: 12,
fontSize: 24,
fontWeight: 'bold',
color: colors.gray7,
},
profileCardHandle: {
marginLeft: 12,
fontSize: 18,
color: colors.gray6,
},
searchBtn: { searchBtn: {
flexDirection: 'row', flexDirection: 'row',
backgroundColor: colors.gray1, backgroundColor: colors.gray1,
@ -223,7 +247,7 @@ const styles = StyleSheet.create({
}, },
searchBtnLabel: { searchBtnLabel: {
marginLeft: 8, marginLeft: 8,
fontSize: 18, fontSize: 19,
color: colors.gray6, color: colors.gray6,
}, },
@ -231,17 +255,17 @@ const styles = StyleSheet.create({
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
paddingVertical: 8, paddingVertical: 8,
paddingHorizontal: 2, paddingHorizontal: 6,
}, },
menuItemIconWrapper: { menuItemIconWrapper: {
width: 30, width: 36,
height: 30, height: 36,
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
marginRight: 10, marginRight: 12,
}, },
menuItemLabel: { menuItemLabel: {
fontSize: 17, fontSize: 19,
color: colors.gray7, color: colors.gray7,
}, },
menuItemLabelBold: { menuItemLabelBold: {

View File

@ -245,18 +245,19 @@ export const MobileShell: React.FC = observer(() => {
? {transform: [{translateX: swipeTranslateX}]} ? {transform: [{translateX: swipeTranslateX}]}
: undefined : undefined
let menuTranslateX let menuTranslateX
const menuDrawerWidth = winDim.width - 100
if (isMenuActive) { if (isMenuActive) {
// menu is active, interpret swipes as closes // menu is active, interpret swipes as closes
menuTranslateX = Animated.multiply(swipeGestureInterp, winDim.width * -1) menuTranslateX = Animated.multiply(swipeGestureInterp, menuDrawerWidth * -1)
} else if (!store.nav.tab.canGoBack) { } else if (!store.nav.tab.canGoBack) {
// at back of history, interpret swipes as opens // at back of history, interpret swipes as opens
menuTranslateX = Animated.subtract( menuTranslateX = Animated.subtract(
winDim.width * -1, menuDrawerWidth * -1,
Animated.multiply(swipeGestureInterp, winDim.width), Animated.multiply(swipeGestureInterp, menuDrawerWidth),
) )
} else { } else {
// not at back of history, leave off screen // not at back of history, leave off screen
menuTranslateX = winDim.width * -1 menuTranslateX = menuDrawerWidth * -1
} }
const menuSwipeTransform = { const menuSwipeTransform = {
transform: [{translateX: menuTranslateX}], transform: [{translateX: menuTranslateX}],
@ -369,7 +370,7 @@ export const MobileShell: React.FC = observer(() => {
}, },
)} )}
</ScreenContainer> </ScreenContainer>
{menuSwipingDirection !== 0 ? ( {isMenuActive || menuSwipingDirection !== 0 ? (
<Animated.View style={[styles.screenMask, menuSwipeOpacity]} /> <Animated.View style={[styles.screenMask, menuSwipeOpacity]} />
) : undefined} ) : undefined}
<Animated.View style={[styles.menuDrawer, menuSwipeTransform]}> <Animated.View style={[styles.menuDrawer, menuSwipeTransform]}>
@ -500,14 +501,14 @@ const styles = StyleSheet.create({
left: 0, left: 0,
right: 0, right: 0,
backgroundColor: '#000', backgroundColor: '#000',
opacity: 0.5, opacity: 0.6,
}, },
menuDrawer: { menuDrawer: {
position: 'absolute', position: 'absolute',
top: 0, top: 0,
bottom: 0, bottom: 0,
left: 0, left: 0,
right: 0, right: 100,
}, },
topBarProtector: { topBarProtector: {
position: 'absolute', position: 'absolute',