Skip to content

Commit 1a35278

Browse files
committed
Refactor App component: Replace button implementation with Footer component and clean up unused styles
1 parent 1d4d261 commit 1a35278

File tree

3 files changed

+73
-96
lines changed

3 files changed

+73
-96
lines changed

App.tsx

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { useFonts } from "expo-font";
22
import { useRef } from 'react';
3-
import { Platform, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
3+
import { StyleSheet, View } from 'react-native';
44
import { GestureHandlerRootView } from 'react-native-gesture-handler';
55
import { useSharedValue } from 'react-native-reanimated';
66
import { SafeAreaProvider } from 'react-native-safe-area-context';
77
import { BottomTab } from './src/components/bottom-tab';
88
import { CircularDraggableSlider, CircularDraggableSliderRefType } from './src/components/circle-time';
9+
import { Footer } from "./src/components/footer";
910
import { Header } from "./src/components/header";
1011
import { Queued } from "./src/components/queued";
1112
import { TimeRange } from './src/components/time-range';
@@ -39,21 +40,7 @@ export default function App() {
3940
}}
4041
/>
4142
</View>
42-
<View style={styles.buttonsWrapper}>
43-
<TouchableOpacity
44-
style={styles.confirmButton}
45-
onPress={() => console.log('Confirm pressed')}
46-
>
47-
<Text style={styles.confirmButtonText}>Confirm</Text>
48-
</TouchableOpacity>
49-
50-
<TouchableOpacity
51-
style={styles.backButton}
52-
onPress={() => console.log('Back pressed')}
53-
>
54-
<Text style={styles.backButtonText}>← Back</Text>
55-
</TouchableOpacity>
56-
</View>
43+
<Footer />
5744
<BottomTab />
5845
</View>
5946
</GestureHandlerRootView>
@@ -99,50 +86,7 @@ const styles = StyleSheet.create({
9986
container: {
10087
flexDirection: "row",
10188
alignItems: 'center',
102-
backgroundColor: '#000',
10389
flex: 1,
10490
},
105-
buttonsWrapper: {
106-
paddingHorizontal: 20,
107-
paddingBottom: 8,
108-
gap: 12,
109-
},
110-
confirmButton: {
111-
backgroundColor: '#FFFFFF',
112-
borderRadius: 16,
113-
paddingVertical: 16,
114-
alignItems: 'center',
115-
justifyContent: 'center',
116-
// iOS shadow
117-
...Platform.select({
118-
ios: {
119-
shadowColor: '#FFFFFF',
120-
shadowOffset: { width: 0, height: 4 },
121-
shadowOpacity: 0.3,
122-
shadowRadius: 8,
123-
},
124-
android: {
125-
elevation: 8,
126-
},
127-
}),
128-
},
129-
confirmButtonText: {
130-
color: '#504e4eff',
131-
fontSize: 16,
132-
fontWeight: '600',
133-
},
134-
backButton: {
135-
backgroundColor: 'transparent',
136-
borderRadius: 16,
137-
paddingVertical: 16,
138-
alignItems: 'center',
139-
justifyContent: 'center',
140-
borderWidth: 1,
141-
borderColor: '#333333',
142-
},
143-
backButtonText: {
144-
color: '#FFFFFF',
145-
fontSize: 16,
146-
fontWeight: '600',
147-
},
91+
14892
});

src/components/circle-time/index.tsx

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,14 @@ import { LineTime } from './line-time';
1818

1919

2020
export type DraggableSliderProps = {
21-
// Total number of lines in the slider
2221
linesAmount: number;
23-
// Maximum height of a line
2422
maxLineHeight: number;
25-
// Minimum height of a line
2623
minLineHeight: number;
27-
// Optional: Offset for determining big lines, defaults to 10
28-
// That means that every 10th line will be a big line
2924
bigLineIndexOffset?: number;
30-
// Optional: The width of each line, defaults to 1.5
3125
lineWidth?: number;
32-
// Optional: Shared value representing the color of the indicator line
3326
indicatorColor?: string;
34-
// Optional: The color of the lines (default is #c6c6c6)
3527
lineColor?: string;
36-
// Optional: The color of the big lines (default is #c6c6c6)
3728
bigLineColor?: string;
38-
// Optional: The color of the medium lines (default is #c6c6c6)
3929
mediumLineColor?: string;
4030
selectedDuration?: SharedValue<number>;
4131
};
@@ -69,13 +59,10 @@ export const CircularDraggableSlider = forwardRef<
6959
) => {
7060
const progress = useSharedValue(0);
7161
const isTimerEnabled = useSharedValue(false);
72-
const distanceBetweenTwoTicksRad = (2 * Math.PI) / linesAmount;
7362
const diameter = 2 * Math.PI * radius;
7463
const distanceBetweenTwoTicks = diameter / linesAmount;
7564
const listWidth = diameter;
7665

77-
78-
// Offset set to 0 for 90-degree rotation (indicator at right side)
7966
const offset = 0;
8067
const progressRadiants = useDerivedValue(() => {
8168
return interpolate(
@@ -85,15 +72,6 @@ export const CircularDraggableSlider = forwardRef<
8572
);
8673
}, [listWidth]);
8774

88-
useAnimatedReaction(
89-
() => progressRadiants.value,
90-
radiants => {
91-
const amountOfSeconds = Math.round(
92-
(radiants - offset) / distanceBetweenTwoTicksRad,
93-
);
94-
},
95-
);
96-
9775
useAnimatedReaction(
9876
() => selectedDuration?.value ?? null,
9977
duration => {
@@ -122,7 +100,7 @@ export const CircularDraggableSlider = forwardRef<
122100
{
123101
height: radius * 2,
124102
width: radius * 2,
125-
right: 50,
103+
right: 60,
126104
transform: [
127105
{
128106
translateY: WindowHeight / 2 - radius - 36,
@@ -134,17 +112,10 @@ export const CircularDraggableSlider = forwardRef<
134112
<Animated.View pointerEvents="none">
135113

136114
{new Array(linesAmount).fill(0).map((_, index) => {
137-
// Determine line type based on position
138115
const isBigLine = index % bigLineIndexOffset === 0;
139-
140-
// Calculate the midpoint between consecutive big lines
141116
const midpointOffset = bigLineIndexOffset / 2;
142117
const isMediumLine = !isBigLine && index % bigLineIndexOffset === midpointOffset;
143-
144-
// Calculate medium line height as the average of max and min
145118
const mediumLineHeight = (maxLineHeight + minLineHeight) / 2;
146-
147-
// Determine height based on line type
148119
let height: number;
149120
let color: string;
150121

@@ -193,21 +164,20 @@ export const CircularDraggableSlider = forwardRef<
193164
})}
194165
</Animated.View>
195166
<LinearGradient
196-
// Background Linear Gradient
197-
colors={['rgba(0,0,0,1)', 'rgba(0,0,0,0.9)', 'transparent']}
167+
colors={['#000000', '#000000', '#000000', '#00000070', 'transparent']}
198168
start={{
199169
x: 0,
200170
y: 0
201171
}}
202172
end={{
203-
x: 1,
173+
x: 1.1,
204174
y: 0
205175
}}
206176
style={{
207177
position: 'absolute',
208178
height: radius * 2 + 94,
209-
width: radius + 20,
210-
left: -30,
179+
width: radius * 2 + 94,
180+
left: -220,
211181
top: -(WindowHeight / 2 - radius + 8),
212182
// backgroundColor: 'red',
213183
borderRadius: 1000
@@ -284,11 +254,11 @@ const styles = StyleSheet.create({
284254
height: LABEL_HEIGHT,
285255
alignItems: 'center',
286256
justifyContent: 'center',
257+
left: 10
287258
},
288259
hourLabelText: {
289260
color: '#d8d8d8',
290261
fontFamily: 'SF-Pro-Rounded-Bold',
291262
fontSize: 20,
292-
left: 10
293263
},
294264
});

src/components/footer/index.tsx

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { StyleSheet, Text, TouchableOpacity, View } from "react-native"
2+
3+
4+
5+
export const Footer = () => {
6+
return (
7+
<View style={styles.buttonsWrapper}>
8+
<TouchableOpacity
9+
style={styles.confirmButton}
10+
onPress={() => console.log('Confirm pressed')}
11+
>
12+
<Text style={styles.confirmButtonText}>Confirm</Text>
13+
</TouchableOpacity>
14+
15+
<TouchableOpacity
16+
style={styles.backButton}
17+
onPress={() => console.log('Back pressed')}
18+
>
19+
<Text style={styles.backButtonText}>← Back</Text>
20+
</TouchableOpacity>
21+
</View>
22+
)
23+
}
24+
25+
26+
const styles = StyleSheet.create({
27+
buttonsWrapper: {
28+
paddingHorizontal: 20,
29+
paddingBottom: 8,
30+
gap: 10,
31+
},
32+
confirmButton: {
33+
backgroundColor: '#FFFFFF',
34+
borderRadius: 16,
35+
paddingVertical: 16,
36+
alignItems: 'center',
37+
justifyContent: 'center',
38+
shadowColor: '#FFFFFF',
39+
shadowOffset: { width: 0, height: 4 },
40+
shadowOpacity: 0.3,
41+
shadowRadius: 8,
42+
elevation: 8,
43+
},
44+
confirmButtonText: {
45+
color: '#504e4eff',
46+
fontSize: 16,
47+
fontWeight: '600',
48+
},
49+
backButton: {
50+
backgroundColor: 'transparent',
51+
borderRadius: 16,
52+
paddingVertical: 16,
53+
alignItems: 'center',
54+
justifyContent: 'center',
55+
borderWidth: 1,
56+
borderColor: '#333333',
57+
},
58+
backButtonText: {
59+
color: '#FFFFFF',
60+
fontSize: 16,
61+
fontWeight: '600',
62+
},
63+
})

0 commit comments

Comments
 (0)