Skip to content

Commit

Permalink
Mobile payees and rules pages
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Dec 5, 2023
1 parent dc87264 commit 2bb4c56
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 21 deletions.
2 changes: 2 additions & 0 deletions packages/desktop-client/src/components/FinancesApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ function FinancesApp() {
<Route path="/budget" element={<MobileNavTabs />} />
<Route path="/accounts" element={<MobileNavTabs />} />
<Route path="/settings" element={<MobileNavTabs />} />
<Route path="/payees" element={<MobileNavTabs />} />
<Route path="/rules" element={<MobileNavTabs />} />
<Route path="*" element={null} />
</Routes>
</View>
Expand Down
12 changes: 10 additions & 2 deletions packages/desktop-client/src/components/ManageRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { type RuleEntity } from 'loot-core/src/types/models';

import useCategories from '../hooks/useCategories';
import useSelected, { SelectedProvider } from '../hooks/useSelected';
import { useResponsive } from '../ResponsiveProvider';
import { theme } from '../style';

import Button from './common/Button';
Expand Down Expand Up @@ -253,6 +254,8 @@ function ManageRulesContent({
setHoveredRule(id);
}, []);

const { isNarrowWidth } = useResponsive();

if (rules === null) {
return null;
}
Expand All @@ -266,14 +269,16 @@ function ManageRulesContent({
alignItems: 'center',
padding: isModal ? '0 13px 15px' : '0 0 15px',
flexShrink: 0,
justifyContent: 'space-between',
flexWrap: 'wrap',
}}
>
<View
style={{
color: theme.pageTextLight,
flexDirection: 'row',
alignItems: 'center',
width: '50%',
justifySelf: 'flex-start',
}}
>
<Text>
Expand All @@ -286,11 +291,14 @@ function ManageRulesContent({
</ExternalLink>
</Text>
</View>
<View style={{ flex: 1 }} />
<Search
placeholder="Filter rules..."
value={filter}
onChange={setFilter}
style={{
justifySelf: 'flex-end',
...(isNarrowWidth && { flexBasis: '100%', marginTop: 10 }),
}}
/>
</View>
<View style={{ flex: 1 }}>
Expand Down
14 changes: 13 additions & 1 deletion packages/desktop-client/src/components/ManageRulesPage.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import React from 'react';

import { useResponsive } from '../ResponsiveProvider';
import { theme } from '../style';

import ManageRules from './ManageRules';
import { Page } from './Page';

export function ManageRulesPage() {
const { isNarrowWidth } = useResponsive();
return (
<Page title="Rules">
<Page
title="Rules"
titleStyle={{
...(isNarrowWidth && {
backgroundColor: theme.mobileHeaderBackground,
color: theme.mobileHeaderText,
}),
}}
>
<ManageRules isModal={false} payeeId={null} />
</Page>
);
Expand Down
11 changes: 7 additions & 4 deletions packages/desktop-client/src/components/common/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type ChangeEvent, type Ref } from 'react';

import SvgRemove from '../../icons/v2/Remove';
import SearchAlternate from '../../icons/v2/SearchAlternate';
import { theme } from '../../style';
import { type CSSProperties, theme } from '../../style';

import Button from './Button';
import InputWithContent from './InputWithContent';
Expand All @@ -13,25 +13,28 @@ type SearchProps = {
onChange: (value: string) => unknown;
placeholder: string;
isInModal?: boolean;
width?: number;
style?: CSSProperties;
};

const DEFAULT_WIDTH = 250;

export default function Search({
inputRef,
value,
onChange,
placeholder,
isInModal = false,
width = 250,
style,
}: SearchProps) {
return (
<InputWithContent
inputRef={inputRef}
style={{
width,
width: style?.width || DEFAULT_WIDTH,
flex: '',
borderColor: isInModal ? null : 'transparent',
backgroundColor: isInModal ? null : theme.formInputBackground,
...style,
}}
focusStyle={
isInModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ export default function MobileNavTabs() {
Icon: Calendar,
},
{
name: 'Payees (Soon)',
path: '/payees/soon',
name: 'Payees',
path: '/payees',
style: navTabStyle,
Icon: StoreFront,
},
{
name: 'Rules (Soon)',
path: '/rules/soon',
name: 'Rules',
path: '/rules',
style: navTabStyle,
Icon: Tuning,
},
Expand Down
22 changes: 14 additions & 8 deletions packages/desktop-client/src/components/payees/ManagePayees.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import useSelected, {
} from '../../hooks/useSelected';
import useStableCallback from '../../hooks/useStableCallback';
import ExpandArrow from '../../icons/v0/ExpandArrow';
import { useResponsive } from '../../ResponsiveProvider';
import { theme } from '../../style';
import Button from '../common/Button';
import Search from '../common/Search';
Expand Down Expand Up @@ -220,6 +221,7 @@ export const ManagePayees = forwardRef(
let payeesById = getPayeesById(payees);

let [menuOpen, setMenuOpen] = useState(false);
const { isNarrowWidth } = useResponsive();

return (
<View style={{ height: '100%' }}>
Expand All @@ -228,9 +230,16 @@ export const ManagePayees = forwardRef(
flexDirection: 'row',
alignItems: 'center',
padding: '0 0 15px',
justifyContent: 'space-between',
flexWrap: 'wrap-reverse',
}}
>
<View style={{ flexShrink: 0 }}>
<View
style={{
flexDirection: 'row',
justifySelf: 'flex-start',
}}
>
<Button
type="bare"
style={{ marginRight: 10 }}
Expand All @@ -253,12 +262,6 @@ export const ManagePayees = forwardRef(
onMerge={onMerge}
/>
)}
</View>
<View
style={{
flexShrink: 0,
}}
>
{(orphanedOnly ||
(orphanedPayees && orphanedPayees.length > 0)) && (
<Button
Expand All @@ -280,12 +283,15 @@ export const ManagePayees = forwardRef(
</Button>
)}
</View>
<View style={{ flex: 1 }} />
<Search
id="filter-input"
placeholder="Filter payees..."
value={filter}
onChange={applyFilter}
style={{
justifySelf: 'flex-end',
...(isNarrowWidth && { flexBasis: '100%', marginBottom: 10 }),
}}
/>
</View>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import React from 'react';
import { useLocation } from 'react-router-dom';

import { useResponsive } from '../../ResponsiveProvider';
import { theme } from '../../style';
import { Page } from '../Page';

import ManagePayeesWithData from './ManagePayeesWithData';

export function ManagePayeesPage() {
let location = useLocation();
const { isNarrowWidth } = useResponsive();
return (
<Page title="Payees">
<Page
title="Payees"
titleStyle={{
...(isNarrowWidth && {
backgroundColor: theme.mobileHeaderBackground,
color: theme.mobileHeaderText,
}),
}}
>
<ManagePayeesWithData
initialSelectedIds={
location.state && location.state.selectedPayee
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export default function ScheduleLink({
<Search
inputRef={searchInput}
isInModal
width={300}
style={{
width: 300,
}}
placeholder="Filter schedules…"
value={filter}
onChange={setFilter}
Expand Down

0 comments on commit 2bb4c56

Please sign in to comment.