Skip to content

Commit

Permalink
Reimplement canvas using view classes (#80)
Browse files Browse the repository at this point in the history
Replaces Brian's original procedural code with view classes. The views are rudimentary implementations of iOS UIKit-style UIViews.
  • Loading branch information
taneliang authored Jul 28, 2020
1 parent 515e2cf commit e55e8ea
Show file tree
Hide file tree
Showing 23 changed files with 2,312 additions and 1,461 deletions.
23 changes: 2 additions & 21 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// @flow

import type {FlamechartData, ReactLane, ReactProfilerData} from './types';
import type {FlamechartData, ReactProfilerData} from './types';

import React, {useState, useCallback} from 'react';
import {unstable_batchedUpdates} from 'react-dom';

import {getLaneHeight} from './canvas/canvasUtils';
import {REACT_TOTAL_NUM_LANES} from './constants';
import ImportPage from './ImportPage';
import CanvasPage from './CanvasPage';

Expand All @@ -15,7 +13,6 @@ export default function App() {
null,
);
const [flamechart, setFlamechart] = useState<FlamechartData | null>(null);
const [schedulerCanvasHeight, setSchedulerCanvasHeight] = useState<number>(0);

const handleDataImported = useCallback(
(
Expand All @@ -25,27 +22,11 @@ export default function App() {
unstable_batchedUpdates(() => {
setProfilerData(importedProfilerData);
setFlamechart(importedFlamechart);

const lanesToRender: ReactLane[] = Array.from(
Array(REACT_TOTAL_NUM_LANES).keys(),
);
// TODO: Figure out if this is necessary
setSchedulerCanvasHeight(
lanesToRender.reduce((height, lane) => {
return height + getLaneHeight(importedProfilerData, lane);
}, 0),
);
});
},
);
if (profilerData && flamechart) {
return (
<CanvasPage
profilerData={profilerData}
flamechart={flamechart}
schedulerCanvasHeight={schedulerCanvasHeight}
/>
);
return <CanvasPage profilerData={profilerData} flamechart={flamechart} />;
} else {
return <ImportPage onDataImported={handleDataImported} />;
}
Expand Down
Loading

1 comment on commit e55e8ea

@vercel
Copy link

@vercel vercel bot commented on e55e8ea Jul 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.