Skip to content

Commit

Permalink
#8: Add highlighting of current timing point in TP list
Browse files Browse the repository at this point in the history
  • Loading branch information
lehnerpat committed May 28, 2022
1 parent 85293cb commit d10a392
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
22 changes: 19 additions & 3 deletions src/track-player/TimingPointsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ import { HasUuid } from "../common/utils/uuid";
import { FixedSizeList, ListChildComponentProps } from "react-window";
import PopupState, { bindTrigger, bindMenu } from "material-ui-popup-state";
import { formatDistanceMeters, formatTimeSec } from "./track-info-formatting";
import { Theme, lighten } from "@mui/material/styles";

interface TimingPointsListProps {
timingPoints: ReadonlyArray<TimingPoint & HasUuid>;
onDeleteTimingPoint: (uuid: string) => void;
precedingIndex: number;
}

// TODO: highlight current timing points
// TODO: autoscroll when option is on
export const TimingPointsList: FC<TimingPointsListProps> = (props) => {
return (
Expand All @@ -47,11 +48,26 @@ export const TimingPointsList: FC<TimingPointsListProps> = (props) => {

class ItemRenderer extends PureComponent<ListChildComponentProps<TimingPointsListProps>> {
render() {
const { timingPoints, onDeleteTimingPoint } = this.props.data;
const { timingPoints, onDeleteTimingPoint, precedingIndex } = this.props.data;
const timingPoint = timingPoints[this.props.index];
const isCurrent = this.props.index === precedingIndex || this.props.index === precedingIndex + 1;

return (
<ListItem style={this.props.style} key={timingPoint.uuid} component="div" disablePadding dense sx={{ px: 1 }}>
<ListItem
style={this.props.style}
key={timingPoint.uuid}
component="div"
disablePadding
dense
sx={[
{ px: 1 },
isCurrent &&
((theme: Theme) => ({
backgroundColor: lighten(theme.palette.background.paper, 0.2),
fontWeight: "bold",
})),
]}
>
<TimingPointData timingPoint={timingPoint} />
<DeleteMenu timingPoint={timingPoint} onDeleteTimingPoint={onDeleteTimingPoint} />
</ListItem>
Expand Down
12 changes: 8 additions & 4 deletions src/track-player/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { augmentUuid, HasUuid } from "../common/utils/uuid";
import { formatDistanceMeters, formatTimeSec } from "./track-info-formatting";
import { TimingPointsList } from "./TimingPointsList";

//eslint-disable-next-line @typescript-eslint/no-unused-vars
const Placeholder: FC<{ width?: number | string; height?: number | string; text?: string }> = ({
width,
height,
Expand Down Expand Up @@ -178,9 +179,6 @@ export const TrackPlayer: FC<TrackPlayerProps> = ({ initialTrack }) => {
const showMapAsOverlay = !isEditingModeOn;

const straightRailOptionsState = usePickedState(viewOptionsState, "straightRailsOverlay");
// TODO: show total path length & video duration in editing mode
// TODO: allow editing of title editing mode
// TODO: show track UUID & video URL in editing mode

return (
<div>
Expand Down Expand Up @@ -262,7 +260,11 @@ export const TrackPlayer: FC<TrackPlayerProps> = ({ initialTrack }) => {
</Box>
<Box width={300}>
<>
<TimingPointsListMemo timingPoints={timingPoints} onDeleteTimingPoint={deleteTimingPointById} />
<TimingPointsListMemo
timingPoints={timingPoints}
onDeleteTimingPoint={deleteTimingPointById}
precedingIndex={precedingTrackPointIndex}
/>
{/* <Placeholder width={300} height={350} text="TP List" /> */}
</>
</Box>
Expand All @@ -286,6 +288,8 @@ const VideoInfoArea: FC<VideoInfoAreaProps> = ({
onPathUploaded,
onReversePathClicked,
}) => (
// TODO: show UUID & video duration in editing mode
// TODO: allow editing of title editing mode
<Card raised sx={{ p: 2 }}>
<Stack direction="row" spacing={1}>
<Box flexGrow={1}>
Expand Down

0 comments on commit d10a392

Please sign in to comment.