Skip to content
Snippets Groups Projects
Unverified Commit ec3efc71 authored by Matiss Janis Aboltins's avatar Matiss Janis Aboltins Committed by GitHub
Browse files

:art: (mobile) settings page header (#887)

parent ba59deae
No related branches found
No related tags found
No related merge requests found
import React from 'react'; import React from 'react';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { styles } from '../style'; import { colors, styles } from '../style';
import { isMobile } from '../util';
import { Modal, View, Text } from './common'; import { Modal, View, Text } from './common';
let PageTypeContext = React.createContext({ type: 'page' }); let PageTypeContext = React.createContext({ type: 'page' });
const HORIZONTAL_PADDING = isMobile() ? 10 : 20;
export function PageTypeProvider({ type, current, children }) { export function PageTypeProvider({ type, current, children }) {
return ( return (
<PageTypeContext.Provider value={{ type, current }}> <PageTypeContext.Provider value={{ type, current }}>
...@@ -19,15 +22,50 @@ export function usePageType() { ...@@ -19,15 +22,50 @@ export function usePageType() {
return React.useContext(PageTypeContext); return React.useContext(PageTypeContext);
} }
function PageTitle({ name }) { function PageTitle({ name, style }) {
if (isMobile()) {
return (
<View
style={[
{
alignItems: 'center',
backgroundColor: colors.b2,
color: 'white',
flexDirection: 'row',
flex: '1 0 auto',
fontSize: 18,
fontWeight: 500,
height: 50,
justifyContent: 'center',
overflowY: 'auto',
},
style,
]}
>
{name}
</View>
);
}
return ( return (
<Text style={{ fontSize: 25, fontWeight: 500, marginBottom: 15 }}> <Text
style={[
{
fontSize: 25,
fontWeight: 500,
paddingLeft: HORIZONTAL_PADDING,
paddingRight: HORIZONTAL_PADDING,
marginBottom: 15,
},
style,
]}
>
{name} {name}
</Text> </Text>
); );
} }
export function Page({ title, modalSize, children }) { export function Page({ title, modalSize, children, titleStyle }) {
let { type, current } = usePageType(); let { type, current } = usePageType();
let history = useHistory(); let history = useHistory();
...@@ -51,9 +89,21 @@ export function Page({ title, modalSize, children }) { ...@@ -51,9 +89,21 @@ export function Page({ title, modalSize, children }) {
} }
return ( return (
<View style={[styles.page, { paddingLeft: 20, paddingRight: 20, flex: 1 }]}> <View style={isMobile() ? undefined : styles.page}>
<PageTitle name={title} /> <PageTitle name={title} style={titleStyle} />
{children} <View
style={
isMobile()
? { overflowY: 'auto', padding: HORIZONTAL_PADDING }
: {
paddingLeft: HORIZONTAL_PADDING,
paddingRight: HORIZONTAL_PADDING,
flex: 1,
}
}
>
{children}
</View>
</View> </View>
); );
} }
...@@ -10,6 +10,7 @@ import Wallet from '../../icons/v1/Wallet'; ...@@ -10,6 +10,7 @@ import Wallet from '../../icons/v1/Wallet';
import { colors, styles } from '../../style'; import { colors, styles } from '../../style';
import { withThemeColor } from '../../util/withThemeColor'; import { withThemeColor } from '../../util/withThemeColor';
import { Button, Text, TextOneLine, View } from '../common'; import { Button, Text, TextOneLine, View } from '../common';
import { Page } from '../Page';
import CellValue from '../spreadsheet/CellValue'; import CellValue from '../spreadsheet/CellValue';
export function AccountHeader({ name, amount }) { export function AccountHeader({ name, amount }) {
...@@ -195,53 +196,30 @@ export class AccountList extends React.Component { ...@@ -195,53 +196,30 @@ export class AccountList extends React.Component {
} }
const accountContent = ( const accountContent = (
<View style={{ overflowY: 'auto' }}> <Page title="Accounts">
<View <AccountHeader name="Budgeted" amount={getOnBudgetBalance()} />
style={{ {budgetedAccounts.map((acct, idx) => (
alignItems: 'center', <AccountCard
backgroundColor: colors.b2, account={acct}
color: 'white', key={acct.id}
flexDirection: 'row', updated={updatedAccounts.includes(acct.id)}
flex: '1 0 auto', getBalanceQuery={getBalanceQuery}
fontSize: 18, onSelect={onSelectAccount}
fontWeight: 500, />
height: 50, ))}
justifyContent: 'center',
overflowY: 'auto',
}}
>
Accounts
</View>
<View
style={{
backgroundColor: colors.n10,
overflowY: 'auto',
padding: 10,
}}
>
<AccountHeader name="Budgeted" amount={getOnBudgetBalance()} />
{budgetedAccounts.map((acct, idx) => (
<AccountCard
account={acct}
key={acct.id}
updated={updatedAccounts.includes(acct.id)}
getBalanceQuery={getBalanceQuery}
onSelect={onSelectAccount}
/>
))}
<AccountHeader name="Off budget" amount={getOffBudgetBalance()} /> <AccountHeader name="Off budget" amount={getOffBudgetBalance()} />
{offbudgetAccounts.map((acct, idx) => ( {offbudgetAccounts.map((acct, idx) => (
<AccountCard <AccountCard
account={acct} account={acct}
key={acct.id} key={acct.id}
updated={updatedAccounts.includes(acct.id)} updated={updatedAccounts.includes(acct.id)}
getBalanceQuery={getBalanceQuery} getBalanceQuery={getBalanceQuery}
onSelect={onSelectAccount} onSelect={onSelectAccount}
/> />
))} ))}
{/*<Label {/*<Label
title="RECENT TRANSACTIONS" title="RECENT TRANSACTIONS"
style={{ style={{
textAlign: 'center', textAlign: 'center',
...@@ -250,8 +228,7 @@ export class AccountList extends React.Component { ...@@ -250,8 +228,7 @@ export class AccountList extends React.Component {
marginLeft: 10 marginLeft: 10
}} }}
/>*/} />*/}
</View> </Page>
</View>
); );
return ( return (
......
...@@ -128,7 +128,17 @@ function Settings({ ...@@ -128,7 +128,17 @@ function Settings({
marginInline: globalPrefs.floatingSidebar && !isMobile() ? 'auto' : 0, marginInline: globalPrefs.floatingSidebar && !isMobile() ? 'auto' : 0,
}} }}
> >
<Page title="Settings"> <Page
title="Settings"
titleStyle={
isMobile()
? {
backgroundColor: colors.n11,
color: colors.n1,
}
: undefined
}
>
<View style={{ flexShrink: 0, gap: 30 }}> <View style={{ flexShrink: 0, gap: 30 }}>
{isMobile() && ( {isMobile() && (
<View <View
...@@ -173,7 +183,7 @@ function Settings({ ...@@ -173,7 +183,7 @@ function Settings({
); );
} }
export default withThemeColor(colors.n10)( export default withThemeColor(colors.n11)(
connect( connect(
state => ({ state => ({
prefs: state.prefs.local, prefs: state.prefs.local,
......
---
category: Enhancements
authors: [MatissJanis]
---
Mobile: unify "settings" page header with the style of "accounts" page
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment