@@ -9,13 +9,55 @@ import {
9
9
} from "@/api/types" ;
10
10
import { space } from "@/styles" ;
11
11
12
+ const superscripts = "⁰¹²³⁴⁵⁶⁷⁸⁹" . split ( "" ) ;
13
+ const subscripts = "₀₁₂₃₄₅₆₇₈₉" . split ( "" ) ;
14
+
15
+ function numberToScript ( number : number , scripts : string [ ] ) {
16
+ return number
17
+ . toString ( 10 )
18
+ . split ( "" )
19
+ . map ( ( digit ) => {
20
+ const index = 9 - ( "9" . charCodeAt ( 0 ) - digit . charCodeAt ( 0 ) ) ;
21
+ return scripts [ index ] ;
22
+ } )
23
+ . join ( "" ) ;
24
+ }
25
+
26
+ function numbersToFraction ( numerator : number , denominator : number ) {
27
+ const numeratorAsString = numberToScript ( numerator , superscripts ) ;
28
+ const denominatorAsString = numberToScript ( denominator , subscripts ) ;
29
+ return `${ numeratorAsString } \u2044${ denominatorAsString } ` ;
30
+ }
31
+
12
32
interface ExerciseSetProps {
33
+ index : number ;
34
+ total : number ;
13
35
set : PlanItemSet ;
14
36
stepSize : number ;
15
37
onSetChange : ( set : PlanItemSet ) => void ;
16
38
}
17
39
18
- export function ExerciseSet ( props : ExerciseSetProps ) {
40
+ export function ExerciseSet ( { index, total, ...props } : ExerciseSetProps ) {
41
+ return (
42
+ < Layout
43
+ style = { {
44
+ width : "100%" ,
45
+ flexDirection : "row" ,
46
+ justifyContent : "space-around" ,
47
+ alignItems : "center" ,
48
+ } }
49
+ >
50
+ < Text style = { { fontSize : space [ 5 ] , fontWeight : "bold" } } >
51
+ { numbersToFraction ( index + 1 , total ) }
52
+ </ Text >
53
+ < ConcreteExerciseSet { ...props } />
54
+ </ Layout >
55
+ ) ;
56
+ }
57
+
58
+ function ConcreteExerciseSet (
59
+ props : Pick < ExerciseSetProps , "set" | "stepSize" | "onSetChange" > ,
60
+ ) {
19
61
if ( isPlanItemSetOfType ( "REPETITIONS" , props . set ) ) {
20
62
return < RepetitionsSet { ...props } set = { props . set } /> ;
21
63
} else if ( isPlanItemSetOfType ( "TIME" , props . set ) ) {
@@ -28,7 +70,6 @@ export function ExerciseSet(props: ExerciseSetProps) {
28
70
29
71
interface PlanItemRepetitionsSetProps {
30
72
set : PlanItemRepetitionsSet ;
31
- stepSize : number ;
32
73
onSetChange : ( set : PlanItemRepetitionsSet ) => void ;
33
74
}
34
75
@@ -42,7 +83,7 @@ function RepetitionsSet({ set, onSetChange }: PlanItemRepetitionsSetProps) {
42
83
gap : space [ 3 ] ,
43
84
} }
44
85
>
45
- < Text style = { { opacity : 0 , fontSize : 24 } } > WDH</ Text >
86
+ < Text style = { { opacity : 0 , fontSize : space [ 5 ] } } > WDH</ Text >
46
87
< ValueControls
47
88
defaultValue = { set . repetitions ?? 0 }
48
89
onIncrease = { ( ) =>
@@ -55,14 +96,13 @@ function RepetitionsSet({ set, onSetChange }: PlanItemRepetitionsSetProps) {
55
96
onSetChange ( { ...set , repetitions : Math . round ( repetitions ) } )
56
97
}
57
98
/>
58
- < Text style = { { fontSize : 24 } } > WDH</ Text >
99
+ < Text style = { { fontSize : space [ 5 ] } } > WDH</ Text >
59
100
</ Layout >
60
101
) ;
61
102
}
62
103
63
104
interface PlanItemTimeSetProps {
64
105
set : PlanItemTimeSet ;
65
- stepSize : number ;
66
106
onSetChange : ( set : PlanItemTimeSet ) => void ;
67
107
}
68
108
@@ -76,14 +116,14 @@ function TimeSet({ set, onSetChange }: PlanItemTimeSetProps) {
76
116
gap : space [ 3 ] ,
77
117
} }
78
118
>
79
- < Text style = { { opacity : 0 , fontSize : 24 } } > Sekunden</ Text >
119
+ < Text style = { { opacity : 0 , fontSize : space [ 5 ] } } > Sekunden</ Text >
80
120
< ValueControls
81
121
defaultValue = { set . time ?? 0 }
82
122
onIncrease = { ( ) => onSetChange ( { ...set , time : set . time + 1 } ) }
83
123
onDecrease = { ( ) => onSetChange ( { ...set , time : set . time - 1 } ) }
84
124
onSet = { ( time ) => onSetChange ( { ...set , time : Math . round ( time ) } ) }
85
125
/>
86
- < Text style = { { fontSize : 24 } } > Sekunden</ Text >
126
+ < Text style = { { fontSize : space [ 5 ] } } > Sekunden</ Text >
87
127
</ Layout >
88
128
) ;
89
129
}
@@ -95,21 +135,15 @@ interface PlanItemWeightSetProps {
95
135
}
96
136
function WeightSet ( { set, stepSize, onSetChange } : PlanItemWeightSetProps ) {
97
137
return (
98
- < Layout
99
- style = { {
100
- width : "100%" ,
101
- flexDirection : "row" ,
102
- justifyContent : "space-around" ,
103
- } }
104
- >
138
+ < >
105
139
< Layout
106
140
style = { {
107
141
flexDirection : "row" ,
108
142
alignItems : "center" ,
109
143
gap : space [ 3 ] ,
110
144
} }
111
145
>
112
- < Text style = { { opacity : 0 , fontSize : 24 } } > KG</ Text >
146
+ < Text style = { { opacity : 0 , fontSize : space [ 5 ] } } > KG</ Text >
113
147
< ValueControls
114
148
defaultValue = { set . repetitions ?? 0 }
115
149
onIncrease = { ( ) =>
@@ -122,7 +156,7 @@ function WeightSet({ set, stepSize, onSetChange }: PlanItemWeightSetProps) {
122
156
onSetChange ( { ...set , repetitions : Math . round ( repetitions ) } )
123
157
}
124
158
/>
125
- < Text style = { { opacity : 0 , fontSize : 24 } } > KG</ Text >
159
+ < Text style = { { opacity : 0 , fontSize : space [ 5 ] } } > KG</ Text >
126
160
</ Layout >
127
161
< Layout
128
162
style = { {
@@ -131,7 +165,7 @@ function WeightSet({ set, stepSize, onSetChange }: PlanItemWeightSetProps) {
131
165
gap : space [ 3 ] ,
132
166
} }
133
167
>
134
- < Text style = { { opacity : 0 , fontSize : 24 } } > KG</ Text >
168
+ < Text style = { { opacity : 0 , fontSize : space [ 5 ] } } > KG</ Text >
135
169
< ValueControls
136
170
defaultValue = { set . weight ?? 0 }
137
171
onIncrease = { ( ) =>
@@ -142,9 +176,9 @@ function WeightSet({ set, stepSize, onSetChange }: PlanItemWeightSetProps) {
142
176
}
143
177
onSet = { ( weight ) => onSetChange ( { ...set , weight } ) }
144
178
/>
145
- < Text style = { { fontSize : 24 } } > KG</ Text >
179
+ < Text style = { { fontSize : space [ 5 ] } } > KG</ Text >
146
180
</ Layout >
147
- </ Layout >
181
+ </ >
148
182
) ;
149
183
}
150
184
@@ -170,21 +204,21 @@ function ValueControls({
170
204
>
171
205
< Icon
172
206
fill = "white"
173
- style = { { height : space [ 10 ] , width : space [ 10 ] } }
207
+ style = { { height : space [ 9 ] , width : space [ 9 ] } }
174
208
name = "chevron-up-outline"
175
209
onPress = { onIncrease }
176
210
/>
177
211
< Input
178
- style = { { width : 100 } }
212
+ style = { { minWidth : 96 } }
179
213
keyboardType = "decimal-pad"
180
214
defaultValue = { defaultValue . toString ( ) }
181
215
size = "large"
182
- textStyle = { { fontSize : 24 , textAlign : "center" } }
216
+ textStyle = { { fontSize : space [ 5 ] , textAlign : "center" } }
183
217
onEndEditing = { ( event ) => onSet ( parseFloat ( event . nativeEvent . text ) ) }
184
218
/>
185
219
< Icon
186
220
fill = "white"
187
- style = { { height : space [ 10 ] , width : space [ 10 ] } }
221
+ style = { { height : space [ 9 ] , width : space [ 9 ] } }
188
222
name = "chevron-down-outline"
189
223
onPress = { onDecrease }
190
224
/>
0 commit comments