Skip to content

Commit

Permalink
add pulsing loading line at the bottom of NavBar
Browse files Browse the repository at this point in the history
With the recent dashboard tab changes, we can show some preliminary metrics while lazy-loading additional trips. We need some way to communicate to the user that work is being done.

This will add a pulsing line animation (aka indeterminate progress bar) at the bottom of the NavBar whenever timelineIsLoading.
  • Loading branch information
JGreenlee committed Apr 2, 2024
1 parent fe4e6eb commit 4da2761
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
17 changes: 13 additions & 4 deletions www/js/components/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import React from 'react';
import { View, StyleSheet } from 'react-native';
import color from 'color';
import { Appbar, Button, ButtonProps, Icon, useTheme } from 'react-native-paper';
import { Appbar, Button, ButtonProps, Icon, ProgressBar, useTheme } from 'react-native-paper';

const NavBar = ({ children }) => {
type NavBarProps = { children: React.ReactNode; isLoading?: boolean };
const NavBar = ({ children, isLoading }: NavBarProps) => {
const { colors } = useTheme();
return (
<Appbar.Header statusBarHeight={0} elevated={true} style={s.navBar(colors.surface)}>
{children}
<View style={{ position: 'absolute', bottom: 0, left: 0, right: 0, height: 2 }}>
<ProgressBar
visible={isLoading}
indeterminate={true}
color={colors.primary}
style={{ height: 2 }}
/>
</View>
</Appbar.Header>
);
};
Expand All @@ -16,8 +25,8 @@ export default NavBar;

// NavBarButton, a greyish button with outline, to be used inside a NavBar

type Props = ButtonProps & { icon?: string; iconSize?: number };
export const NavBarButton = ({ children, icon, iconSize, ...rest }: Props) => {
type NavBarButtonProps = ButtonProps & { icon?: string; iconSize?: number };
export const NavBarButton = ({ children, icon, iconSize, ...rest }: NavBarButtonProps) => {
const { colors } = useTheme();
const buttonColor = color(colors.onBackground).alpha(0.07).rgb().string();
const outlineColor = color(colors.onBackground).alpha(0.2).rgb().string();
Expand Down
5 changes: 3 additions & 2 deletions www/js/diary/list/LabelListScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import { displayErrorMsg } from '../../plugin/logger';

const LabelListScreen = () => {
const { filterInputs, setFilterInputs, displayedEntries } = useContext(LabelTabContext);
const { timelineMap, loadSpecificWeek, refreshTimeline } = useContext(TimelineContext);
const { timelineMap, loadSpecificWeek, timelineIsLoading, refreshTimeline } =
useContext(TimelineContext);
const { colors } = useTheme();

return (
<>
<NavBar>
<NavBar isLoading={Boolean(timelineIsLoading)}>
<FilterSelect
filters={filterInputs}
setFilters={setFilterInputs}
Expand Down
2 changes: 1 addition & 1 deletion www/js/metrics/MetricsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const MetricsTab = () => {

return (
<>
<NavBar>
<NavBar isLoading={Boolean(timelineIsLoading)}>
<Appbar.Content title={t('metrics.dashboard-tab')} />
<DateSelect
mode="range"
Expand Down

0 comments on commit 4da2761

Please sign in to comment.