Skip to content

Commit b14aa15

Browse files
committed
Refactor TimeRange component: Remove unused comments and clean up code
1 parent 252a33e commit b14aa15

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

src/components/time-range/index.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,26 @@ import Animated, {
77
useAnimatedScrollHandler,
88
} from 'react-native-reanimated';
99

10-
/**
11-
* Props for the TimeRange component
12-
* @property {(durationHours: number) => void} onDurationChange - Callback triggered when the selected duration changes
13-
*/
10+
1411
type TimeRangeProps = {
1512
onDurationChange?: (durationHours: number) => void;
1613
};
1714

1815
const SCALE_FACTOR = 2.5;
19-
const ITEM_HEIGHT = 36 * SCALE_FACTOR; // Height of each time item in pixels
20-
const TimeRangeHeight = ITEM_HEIGHT; // Visible area shows a single time option
16+
const ITEM_HEIGHT = 36 * SCALE_FACTOR;
17+
const TimeRangeHeight = ITEM_HEIGHT;
2118
const ArrowWrapperHeight = 24 * SCALE_FACTOR;
2219
const ArrowIconSize = 10 * SCALE_FACTOR;
2320
const LabelFontSize = 28 * SCALE_FACTOR;
2421
const ListWidth = 100 * SCALE_FACTOR;
25-
const ContainerHeight = TimeRangeHeight + ArrowWrapperHeight * 2; // Extra space for arrow indicators
22+
const ContainerHeight = TimeRangeHeight + ArrowWrapperHeight * 2;
2623
const DurationOptions = Array.from({ length: 10 }, (_, index) => index + 1);
2724
const DurationSnapOffsets = DurationOptions.map((_, index) => index * ITEM_HEIGHT);
2825
const DurationLabels = DurationOptions.map(hours => `${hours} hr`);
2926

3027
export const TimeRange: React.FC<TimeRangeProps> = ({
3128
onDurationChange,
3229
}) => {
33-
/**
34-
* Renders individual time items in the list
35-
* @param {Object} param0 - Item data and index
36-
* @returns {JSX.Element} Rendered time item
37-
*/
3830
const renderItem = useCallback(
3931
({ item, index }: { item: string; index: number }) => (
4032
<View key={index} style={styles.timeItem}>
@@ -44,10 +36,7 @@ export const TimeRange: React.FC<TimeRangeProps> = ({
4436
[],
4537
);
4638

47-
/**
48-
* Handles scroll events and interpolates the selected time
49-
* Uses Reanimated worklet for smooth performance
50-
*/
39+
5140
const onScroll = useAnimatedScrollHandler({
5241
onScroll: event => {
5342
const { contentOffset } = event;
@@ -70,7 +59,6 @@ export const TimeRange: React.FC<TimeRangeProps> = ({
7059
<FontAwesome name="chevron-up" size={ArrowIconSize} color="#ffffff" />
7160
</View>
7261
<View>
73-
7462
<Animated.FlatList
7563
onScroll={onScroll}
7664
decelerationRate="fast"

video.gif

-12.8 MB
Binary file not shown.

0 commit comments

Comments
 (0)