Skip to content

Commit

Permalink
added profile image onto the homescreen
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Rowe committed Aug 16, 2021
1 parent d9a5b47 commit e10c18a
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 7 deletions.
1 change: 0 additions & 1 deletion public/assets/shapes.svg

This file was deleted.

31 changes: 31 additions & 0 deletions src/components/ProfileIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react'
import PropTypes from 'prop-types'
import { createUseStyles } from 'react-jss'

export const useProfileIconStyles = createUseStyles({
container: {
width: 40,
height: 40,
textAlign: 'center',
lineHeight: '40px',
overflow: 'hidden',
position: 'relative',
borderRadius: '50%',
backgroundColor: 'white',
boxShadow: 'var(--boxShadow)'
}
})

export const ProfileIcon = ({ icon, ...rest }) => {
const classes = useProfileIconStyles()

return (
<div className={classes.container} {...rest}>
<img src={icon} alt="profile-icon" />
</div>
)
}

ProfileIcon.propTypes = {
icon: PropTypes.string
}
1 change: 1 addition & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './FullPageLoader'
export * from './Logo'
export * from './Modal'
export * from './Popover'
export * from './ProfileIcon'
export * from './ProgressBar'
export * from './PullToRefresh'
export * from './Tag'
Expand Down
9 changes: 8 additions & 1 deletion src/modules/home/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,17 @@ export const useHomeViewStyles = createUseStyles(theme => ({
rotateIcon: {
transform: 'rotateZ(-180deg)',
bottom: theme.spacing(3.5)
},
profileIcon: {
top: theme.spacing(2),
right: theme.spacing(2),
zIndex: 100,
position: 'absolute'
}
}))

export const useHomeHooks = () => {
const { inGroup, allowance } = useUser()
const { inGroup, allowance, profileImage } = useUser()
const { cards, loading: walletLoading } = useWallet()
const { data = {}, loading, refetch } = useQuery(UserTransactions, { variables: { inGroup } })
const onRefresh = useCallback(e => refetch().then(e.detail.complete), [refetch])
Expand Down Expand Up @@ -148,6 +154,7 @@ export const useHomeHooks = () => {
amountLeft: _loading ? 0 : amountLeft,
groupSpent: _loading ? 0 : groupSpent,
transactions,
profileImage,
loading: _loading
}
}
13 changes: 10 additions & 3 deletions src/modules/home/views/HomeView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useCallback, useState } from 'react'
import clsx from 'clsx'
import { menuController } from '@ionic/core'
import { IonText, IonIcon } from '@ionic/react'
import AnimateHeight from 'react-animate-height'
import AnimatedNumber from 'react-animated-number'
Expand All @@ -9,7 +10,7 @@ import { chevronDown } from 'ionicons/icons'

import { useHomeViewStyles, useHomeHooks } from '../util'
import { PageContainer, Loading } from 'template'
import { Fab, PullToRefresh, Card, ProgressBar } from 'components'
import { Fab, PullToRefresh, Card, ProgressBar, ProfileIcon } from 'components'
import { currency } from 'utils'
import routes from 'routes'
import { StaggeredList } from 'animation'
Expand All @@ -19,7 +20,8 @@ const DURATION = 1500

const Home = () => {
const [expand, updateExpansion] = useState(false)
const { inGroup, amountLeft, percentage, groupSpent, creditCards, transactions, loading, onRefresh } = useHomeHooks()
const { inGroup, amountLeft, percentage, groupSpent, creditCards, transactions, loading, onRefresh, profileImage } =
useHomeHooks()
const classes = useHomeViewStyles({ cardsPresent: creditCards.length })

const handleOpenSummary = useCallback(
Expand All @@ -28,11 +30,16 @@ const Home = () => {
)

const handleCloseSumary = useCallback(() => expand && updateExpansion(false), [expand])
const toggleMenu = useCallback(() => menuController.toggle(), [])

return (
<PageContainer loading={loading}>
{!loading && <PullToRefresh onRefresh={onRefresh} />}

<div className={classes.profileIcon}>
<ProfileIcon icon={profileImage} onClick={toggleMenu} />
</div>

<div className={clsx(classes.header, expand && classes.expandedHeader)}>
<AnimatedNumber
component="h2"
Expand All @@ -51,7 +58,7 @@ const Home = () => {
)}
</div>

{(inGroup || creditCards.length > 0) && (
{creditCards.length > 0 && (
<div className={clsx(classes.summary, expand && classes.expandedSummary)} onClick={handleOpenSummary}>
<AnimateHeight height={expand ? 'auto' : 68} duration={550} delay={100}>
<div className={classes.cardList}>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/transaction/views/EditTransactionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const EditTransaction = ({ dismissModal, ...defaultValues }) => {

<FieldController name="description" placeholder="memo" component={Input} />

<FieldController type="popover" name="card" label="Put on Card" options={cardOptions} component={Select} />
<FieldController name="card" label="Put on Card" options={cardOptions} component={Select} />

<FieldController name="date" component={DatePicker} />

Expand Down
2 changes: 1 addition & 1 deletion src/modules/transaction/views/NewTransactionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const NewTransactionPage = ({ history }) => {

<FieldController name="description" placeholder="memo" component={Input} />

<FieldController type="popover" name="card" label="Put on Card" options={cardOptions} component={Select} />
<FieldController name="card" label="Put on Card" options={cardOptions} component={Select} />

{inGroup && <FieldController label="Group Purchase" name="group" component={Checkbox} />}

Expand Down
1 change: 1 addition & 0 deletions src/modules/user/user.gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const UserFragment = gql`
inGroup
income
allowance
profileImage
defaultCard {
id
}
Expand Down

0 comments on commit e10c18a

Please sign in to comment.