react-native-paper-dates 0.11.5 → 0.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/Time/AmPmSwitcher.js +13 -10
- package/lib/commonjs/Time/AmPmSwitcher.js.map +1 -1
- package/lib/commonjs/Time/AnalogClock.js +6 -7
- package/lib/commonjs/Time/AnalogClock.js.map +1 -1
- package/lib/commonjs/Time/AnalogClockHours.js +16 -17
- package/lib/commonjs/Time/AnalogClockHours.js.map +1 -1
- package/lib/commonjs/Time/AnalogClockMinutes.js +8 -7
- package/lib/commonjs/Time/AnalogClockMinutes.js.map +1 -1
- package/lib/commonjs/Time/TimeInput.js +9 -7
- package/lib/commonjs/Time/TimeInput.js.map +1 -1
- package/lib/commonjs/Time/TimeInputs.js +22 -9
- package/lib/commonjs/Time/TimeInputs.js.map +1 -1
- package/lib/commonjs/Time/TimePicker.js +4 -3
- package/lib/commonjs/Time/TimePicker.js.map +1 -1
- package/lib/commonjs/Time/TimePickerModal.js +20 -12
- package/lib/commonjs/Time/TimePickerModal.js.map +1 -1
- package/lib/commonjs/Time/timeUtils.js +14 -19
- package/lib/commonjs/Time/timeUtils.js.map +1 -1
- package/lib/commonjs/utils.js +9 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/Time/AmPmSwitcher.js +14 -11
- package/lib/module/Time/AmPmSwitcher.js.map +1 -1
- package/lib/module/Time/AnalogClock.js +6 -7
- package/lib/module/Time/AnalogClock.js.map +1 -1
- package/lib/module/Time/AnalogClockHours.js +16 -17
- package/lib/module/Time/AnalogClockHours.js.map +1 -1
- package/lib/module/Time/AnalogClockMinutes.js +8 -7
- package/lib/module/Time/AnalogClockMinutes.js.map +1 -1
- package/lib/module/Time/TimeInput.js +10 -8
- package/lib/module/Time/TimeInput.js.map +1 -1
- package/lib/module/Time/TimeInputs.js +23 -10
- package/lib/module/Time/TimeInputs.js.map +1 -1
- package/lib/module/Time/TimePicker.js +4 -3
- package/lib/module/Time/TimePicker.js.map +1 -1
- package/lib/module/Time/TimePickerModal.js +20 -12
- package/lib/module/Time/TimePickerModal.js.map +1 -1
- package/lib/module/Time/timeUtils.js +15 -20
- package/lib/module/Time/timeUtils.js.map +1 -1
- package/lib/module/utils.js +9 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/Time/AmPmSwitcher.d.ts +3 -1
- package/lib/typescript/Time/timeUtils.d.ts +1 -1
- package/lib/typescript/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/Time/AmPmSwitcher.tsx +15 -9
- package/src/Time/AnalogClock.tsx +16 -9
- package/src/Time/AnalogClockHours.tsx +18 -16
- package/src/Time/AnalogClockMinutes.tsx +7 -7
- package/src/Time/TimeInput.tsx +21 -6
- package/src/Time/TimeInputs.tsx +82 -58
- package/src/Time/TimePicker.tsx +18 -2
- package/src/Time/TimePickerModal.tsx +35 -14
- package/src/Time/timeUtils.ts +23 -17
- package/src/utils.ts +9 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import Color from 'color';
|
|
3
|
-
import { useTheme } from 'react-native-paper';
|
|
4
|
-
|
|
5
|
-
export const circleSize = 215;
|
|
3
|
+
import { useTheme } from 'react-native-paper';
|
|
4
|
+
export const circleSize = 256;
|
|
6
5
|
export const hourTypes = {
|
|
7
6
|
am: 'am',
|
|
8
7
|
pm: 'pm'
|
|
@@ -128,11 +127,7 @@ export function useSwitchColors(highlighted) {
|
|
|
128
127
|
const backgroundColor = React.useMemo(() => {
|
|
129
128
|
if (theme.dark) {
|
|
130
129
|
if (highlighted) {
|
|
131
|
-
return Color(theme.colors.primary).hex();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (theme.isV3) {
|
|
135
|
-
return Color(theme.colors.surface).lighten(1.4).hex();
|
|
130
|
+
return theme.isV3 ? theme.colors.tertiaryContainer : Color(theme.colors.primary).hex();
|
|
136
131
|
}
|
|
137
132
|
|
|
138
133
|
return theme.colors.backdrop;
|
|
@@ -150,11 +145,11 @@ export function useSwitchColors(highlighted) {
|
|
|
150
145
|
}, [highlighted, theme]);
|
|
151
146
|
const color = React.useMemo(() => {
|
|
152
147
|
if (highlighted && !theme.dark) {
|
|
153
|
-
return theme.colors.primary;
|
|
148
|
+
return theme.isV3 ? theme.colors.onSurfaceVariant : theme.colors.primary;
|
|
154
149
|
}
|
|
155
150
|
|
|
156
151
|
if (highlighted && theme.dark) {
|
|
157
|
-
return theme.colors.background;
|
|
152
|
+
return theme.isV3 ? theme.colors.onTertiaryContainer : theme.colors.background;
|
|
158
153
|
}
|
|
159
154
|
|
|
160
155
|
if (theme.isV3) {
|
|
@@ -173,38 +168,38 @@ export function useInputColors(highlighted) {
|
|
|
173
168
|
const backgroundColor = React.useMemo(() => {
|
|
174
169
|
if (theme.dark) {
|
|
175
170
|
if (highlighted) {
|
|
176
|
-
return Color(theme.colors.primary).hex();
|
|
171
|
+
return theme.isV3 ? theme.colors.primaryContainer : Color(theme.colors.primary).hex();
|
|
177
172
|
}
|
|
178
173
|
|
|
179
|
-
return Color(theme.colors.surface).lighten(1.4).hex();
|
|
174
|
+
return theme.isV3 ? theme.colors.surfaceVariant : Color(theme.colors.surface).lighten(1.4).hex();
|
|
180
175
|
}
|
|
181
176
|
|
|
182
177
|
if (highlighted) {
|
|
183
178
|
if (theme.isV3) {
|
|
184
|
-
return
|
|
179
|
+
return theme.colors.secondaryContainer;
|
|
185
180
|
}
|
|
186
181
|
|
|
187
182
|
return Color(theme.colors.primary).lighten(1).hex();
|
|
188
183
|
}
|
|
189
184
|
|
|
190
185
|
if (theme.isV3) {
|
|
191
|
-
return
|
|
186
|
+
return theme.colors.surfaceVariant;
|
|
192
187
|
}
|
|
193
188
|
|
|
194
189
|
return Color(theme.colors.surface).darken(0.1).hex();
|
|
195
190
|
}, [highlighted, theme]);
|
|
196
191
|
const color = React.useMemo(() => {
|
|
197
|
-
if (highlighted && !theme.dark) {
|
|
198
|
-
return theme.colors.primary;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
192
|
if (theme.isV3) {
|
|
202
193
|
if (!highlighted) {
|
|
203
|
-
return theme.colors.onBackground;
|
|
194
|
+
return theme.isV3 ? theme.colors.onSurface : theme.colors.onBackground;
|
|
204
195
|
}
|
|
205
196
|
|
|
206
|
-
return theme.colors.
|
|
197
|
+
return theme.isV3 ? theme.colors.onPrimaryContainer : theme.colors.onBackground;
|
|
207
198
|
} else {
|
|
199
|
+
if (highlighted && !theme.dark) {
|
|
200
|
+
return theme.colors.primary;
|
|
201
|
+
}
|
|
202
|
+
|
|
208
203
|
return theme.colors.text;
|
|
209
204
|
}
|
|
210
205
|
}, [highlighted, theme]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Color","useTheme","circleSize","hourTypes","am","pm","getHourType","hours","undefined","inputTypes","keyboard","picker","reverseInputTypes","inputTypeIcons","getTimeInputTypeIcon","inputType","inputIconMap","clockTypes","minutes","outerHeight","_30","Math","PI","_12","_360","_90","snap","angle","step","a","diff","getHourTypeFromOffset","left","top","size","w","x","y","distance","sqrt","maxPm","getMinutes","handAngle","minute","parseInt","toFixed","getHours","hourType","hour","getAngle","atan","useSwitchColors","highlighted","theme","backgroundColor","useMemo","dark","colors","primary","hex","isV3","surface","lighten","backdrop","primaryContainer","color","background","onSurfaceVariant","placeholder","useInputColors","outline","darken","onBackground","text","toHourInputFormat","is24Hour","toHourOutputFormat","newHours","previousHours"],"sources":["timeUtils.ts"],"sourcesContent":["import * as React from 'react'\nimport Color from 'color'\nimport { MD2Theme, useTheme } from 'react-native-paper'\n\n// 250? when bigger?\nexport const circleSize = 215\n\nexport type PossibleHourTypes = 'am' | 'pm'\nexport type HourTypeMap = {\n [hourType in PossibleHourTypes]: PossibleHourTypes\n}\nexport const hourTypes: HourTypeMap = {\n am: 'am',\n pm: 'pm',\n}\n\nexport function getHourType(hours: number): PossibleHourTypes | undefined {\n if (hours >= 0 && hours <= 12) {\n return hourTypes.am\n }\n if (hours > 12 && hours <= 24) {\n return hourTypes.pm\n }\n return undefined\n}\n\nexport type PossibleInputTypes = 'keyboard' | 'picker'\nexport type InputTypeMap = {\n [inputType in PossibleInputTypes]: PossibleInputTypes\n}\nexport const inputTypes: InputTypeMap = {\n keyboard: 'keyboard',\n picker: 'picker',\n}\n\nexport const reverseInputTypes: InputTypeMap = {\n keyboard: 'picker',\n picker: 'keyboard',\n}\ntype InputIconMap = {\n [inputType in PossibleInputTypes]: string\n}\nexport const inputTypeIcons: InputIconMap = {\n keyboard: 'keyboard-outline',\n picker: 'clock-outline',\n}\n\nexport const getTimeInputTypeIcon = (\n inputType: PossibleInputTypes,\n inputIconMap?: InputIconMap\n) => {\n return (\n inputIconMap?.[reverseInputTypes[inputType]] ||\n inputTypeIcons?.[reverseInputTypes[inputType]]\n )\n}\n\nexport type PossibleClockTypes = 'hours' | 'minutes'\nexport type ClockTypeMap = {\n [clockType in PossibleClockTypes]: PossibleClockTypes\n}\nexport const clockTypes: ClockTypeMap = {\n minutes: 'minutes',\n hours: 'hours',\n}\n\n// Code inspiration and copied from: https://github.com/ShaneGH/analogue-time-picker/blob/master/src/utils/angle.ts\n\nconst outerHeight = 34\nconst _30 = Math.PI / 6\nconst _12 = Math.PI / 30\nconst _360 = Math.PI * 2\nconst _90 = Math.PI / 2\n\n/** Snap an angle to a given step. E.g. if angle = 22° and step = 10°, round down to 20° */\nexport function snap(angle: number, step: number) {\n let a = angle\n while (a < 0) a += _360\n let diff = a % step\n\n if (diff <= step / 2) {\n return angle - diff\n }\n\n return angle - diff + step\n}\n\n// detect am / pm based on offset\nexport function getHourTypeFromOffset(\n left: number,\n top: number,\n size: number\n): PossibleHourTypes {\n const w = size / 2\n const x = w - left\n const y = size / 2 - top\n\n const distance = Math.sqrt(x * x + y * y)\n const maxPm = w - outerHeight\n\n return distance > maxPm ? hourTypes.am : hourTypes.pm\n}\n\n// Calculate the minute from the hand angle\nexport function getMinutes(handAngle: number) {\n handAngle = snap(handAngle, _12)\n\n let minute = parseInt((((handAngle - _90) % _360) / _12).toFixed(), 10)\n while (minute < 0) minute += 60\n while (minute >= 60) minute -= 60\n\n return minute\n}\n\n// Calculate the hour from the hand angle\nexport function getHours(\n handAngle: number,\n hourType: PossibleHourTypes | undefined\n) {\n handAngle = snap(handAngle, _30)\n\n let hour = parseInt((((handAngle - _90) % _360) / _30).toFixed(), 10)\n if (hour < 0) hour += 12\n if (hour >= 12) hour -= 12\n\n if (hourType === hourTypes.am) {\n if (hour <= 0) {\n hour += 12\n } else if (hour >= 12) {\n hour -= 12\n }\n }\n if (hourType === hourTypes.pm) {\n if (hour <= 0) {\n hour += 12\n } else if (hour > 12) {\n hour -= 12\n }\n }\n\n return hour\n}\n\n/** Get the angle of the left/top co-ordinate from the center of the width.height box */\nexport function getAngle(left: number, top: number, size: number) {\n const x = size / 2 - left\n const y = size / 2 - top\n\n // tan O = y / x\n let angle = x ? Math.atan(y / x) : y < 0 ? -_90 : _90\n if (x < 0) {\n // reflect along vertical axis\n angle = -angle + 2 * (_90 + angle)\n }\n\n return angle\n}\n\nexport function useSwitchColors(highlighted: boolean) {\n const theme = useTheme()\n const backgroundColor = React.useMemo<string>(() => {\n if (theme.dark) {\n if (highlighted) {\n return Color(theme.colors.primary).hex()\n }\n if (theme.isV3) {\n return Color(theme.colors.surface).lighten(1.4).hex()\n }\n return theme.colors.backdrop\n }\n\n if (highlighted) {\n if (theme.isV3) {\n return theme.colors.primaryContainer\n }\n\n return Color(theme.colors.primary).lighten(1).hex()\n }\n return theme.colors.surface\n }, [highlighted, theme])\n\n const color = React.useMemo<string>(() => {\n if (highlighted && !theme.dark) {\n return theme.colors.primary\n }\n if (highlighted && theme.dark) {\n return theme.colors.background\n }\n if (theme.isV3) {\n return theme.colors.onSurfaceVariant\n } else {\n return (theme as any as MD2Theme).colors.placeholder\n }\n }, [highlighted, theme])\n\n return { backgroundColor, color }\n}\n\nexport function useInputColors(highlighted: boolean) {\n const theme = useTheme()\n const backgroundColor = React.useMemo<string>(() => {\n if (theme.dark) {\n if (highlighted) {\n return Color(theme.colors.primary).hex()\n }\n return Color(theme.colors.surface).lighten(1.4).hex()\n }\n\n if (highlighted) {\n if (theme.isV3) {\n return Color(theme.colors.primaryContainer).hex()\n }\n return Color(theme.colors.primary).lighten(1).hex()\n }\n if (theme.isV3) {\n return Color(theme.colors.outline).lighten(0.9).hex()\n }\n return Color(theme.colors.surface).darken(0.1).hex()\n }, [highlighted, theme])\n\n const color = React.useMemo<string>(() => {\n if (highlighted && !theme.dark) {\n return theme.colors.primary\n }\n if (theme.isV3) {\n if (!highlighted) {\n return theme.colors.onBackground\n }\n return theme.colors.background\n } else {\n return (theme as any as MD2Theme).colors.text\n }\n }, [highlighted, theme])\n\n return { backgroundColor, color }\n}\n\nexport function toHourInputFormat(hours: number, is24Hour: boolean): number {\n if (hours === 24) {\n return 0\n }\n if (is24Hour) {\n return hours\n }\n if (hours > 12) {\n return hours - 12\n }\n return hours\n}\n\nexport function toHourOutputFormat(\n newHours: number,\n previousHours: number,\n is24Hour: boolean\n): number {\n if (is24Hour) {\n return newHours\n }\n if (previousHours > 12 && newHours < 12) {\n return newHours + 12\n }\n return newHours\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,OAAOC,KAAP,MAAkB,OAAlB;AACA,SAAmBC,QAAnB,QAAmC,oBAAnC,C,CAEA;;AACA,OAAO,MAAMC,UAAU,GAAG,GAAnB;AAMP,OAAO,MAAMC,SAAsB,GAAG;EACpCC,EAAE,EAAE,IADgC;EAEpCC,EAAE,EAAE;AAFgC,CAA/B;AAKP,OAAO,SAASC,WAAT,CAAqBC,KAArB,EAAmE;EACxE,IAAIA,KAAK,IAAI,CAAT,IAAcA,KAAK,IAAI,EAA3B,EAA+B;IAC7B,OAAOJ,SAAS,CAACC,EAAjB;EACD;;EACD,IAAIG,KAAK,GAAG,EAAR,IAAcA,KAAK,IAAI,EAA3B,EAA+B;IAC7B,OAAOJ,SAAS,C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R,WAAL,EAAkB;QAChB,OAAOC,KAAK,CAACI,MAAN,CAAae,YAApB;MACD;;MACD,OAAOnB,KAAK,CAACI,MAAN,CAAaS,UAApB;IACD,CALD,MAKO;MACL,OAAQb,KAAD,CAA2BI,MAA3B,CAAkCgB,IAAzC;IACD;EACF,CAZa,EAYX,CAACrB,WAAD,EAAcC,KAAd,CAZW,CAAd;EAcA,OAAO;IAAEC,eAAF;IAAmBW;EAAnB,CAAP;AACD;AAED,OAAO,SAASS,iBAAT,CAA2BnE,KAA3B,EAA0CoE,QAA1C,EAAqE;EAC1E,IAAIpE,KAAK,KAAK,EAAd,EAAkB;IAChB,OAAO,CAAP;EACD;;EACD,IAAIoE,QAAJ,EAAc;IACZ,OAAOpE,KAAP;EACD;;EACD,IAAIA,KAAK,GAAG,EAAZ,EAAgB;IACd,OAAOA,KAAK,GAAG,EAAf;EACD;;EACD,OAAOA,KAAP;AACD;AAED,OAAO,SAASqE,kBAAT,CACLC,QADK,EAELC,aAFK,EAGLH,QAHK,EAIG;EACR,IAAIA,QAAJ,EAAc;IACZ,OAAOE,QAAP;EACD;;EACD,IAAIC,aAAa,GAAG,EAAhB,IAAsBD,QAAQ,GAAG,EAArC,EAAyC;IACvC,OAAOA,QAAQ,GAAG,EAAlB;EACD;;EACD,OAAOA,QAAP;AACD"}
|
|
1
|
+
{"version":3,"names":["React","Color","useTheme","circleSize","hourTypes","am","pm","getHourType","hours","undefined","inputTypes","keyboard","picker","reverseInputTypes","inputTypeIcons","getTimeInputTypeIcon","inputType","inputIconMap","clockTypes","minutes","outerHeight","_30","Math","PI","_12","_360","_90","snap","angle","step","a","diff","getHourTypeFromOffset","left","top","size","w","x","y","distance","sqrt","maxPm","getMinutes","handAngle","minute","parseInt","toFixed","getHours","hourType","hour","getAngle","atan","useSwitchColors","highlighted","theme","backgroundColor","useMemo","dark","isV3","colors","tertiaryContainer","primary","hex","backdrop","primaryContainer","lighten","surface","color","onSurfaceVariant","onTertiaryContainer","background","placeholder","useInputColors","surfaceVariant","secondaryContainer","darken","onSurface","onBackground","onPrimaryContainer","text","toHourInputFormat","is24Hour","toHourOutputFormat","newHours","previousHours"],"sources":["timeUtils.ts"],"sourcesContent":["import * as React from 'react'\nimport Color from 'color'\nimport { MD2Theme, useTheme } from 'react-native-paper'\n\nexport const circleSize = 256\n\nexport type PossibleHourTypes = 'am' | 'pm'\nexport type HourTypeMap = {\n [hourType in PossibleHourTypes]: PossibleHourTypes\n}\nexport const hourTypes: HourTypeMap = {\n am: 'am',\n pm: 'pm',\n}\n\nexport function getHourType(hours: number): PossibleHourTypes | undefined {\n if (hours >= 0 && hours <= 12) {\n return hourTypes.am\n }\n if (hours > 12 && hours <= 24) {\n return hourTypes.pm\n }\n return undefined\n}\n\nexport type PossibleInputTypes = 'keyboard' | 'picker'\nexport type InputTypeMap = {\n [inputType in PossibleInputTypes]: PossibleInputTypes\n}\nexport const inputTypes: InputTypeMap = {\n keyboard: 'keyboard',\n picker: 'picker',\n}\n\nexport const reverseInputTypes: InputTypeMap = {\n keyboard: 'picker',\n picker: 'keyboard',\n}\ntype InputIconMap = {\n [inputType in PossibleInputTypes]: string\n}\nexport const inputTypeIcons: InputIconMap = {\n keyboard: 'keyboard-outline',\n picker: 'clock-outline',\n}\n\nexport const getTimeInputTypeIcon = (\n inputType: PossibleInputTypes,\n inputIconMap?: InputIconMap\n) => {\n return (\n inputIconMap?.[reverseInputTypes[inputType]] ||\n inputTypeIcons?.[reverseInputTypes[inputType]]\n )\n}\n\nexport type PossibleClockTypes = 'hours' | 'minutes'\nexport type ClockTypeMap = {\n [clockType in PossibleClockTypes]: PossibleClockTypes\n}\nexport const clockTypes: ClockTypeMap = {\n minutes: 'minutes',\n hours: 'hours',\n}\n\n// Code inspiration and copied from: https://github.com/ShaneGH/analogue-time-picker/blob/master/src/utils/angle.ts\n\nconst outerHeight = 34\nconst _30 = Math.PI / 6\nconst _12 = Math.PI / 30\nconst _360 = Math.PI * 2\nconst _90 = Math.PI / 2\n\n/** Snap an angle to a given step. E.g. if angle = 22° and step = 10°, round down to 20° */\nexport function snap(angle: number, step: number) {\n let a = angle\n while (a < 0) a += _360\n let diff = a % step\n\n if (diff <= step / 2) {\n return angle - diff\n }\n\n return angle - diff + step\n}\n\n// detect am / pm based on offset\nexport function getHourTypeFromOffset(\n left: number,\n top: number,\n size: number\n): PossibleHourTypes {\n const w = size / 2\n const x = w - left\n const y = size / 2 - top\n\n const distance = Math.sqrt(x * x + y * y)\n const maxPm = w - outerHeight\n\n return distance > maxPm ? hourTypes.am : hourTypes.pm\n}\n\n// Calculate the minute from the hand angle\nexport function getMinutes(handAngle: number) {\n handAngle = snap(handAngle, _12)\n\n let minute = parseInt((((handAngle - _90) % _360) / _12).toFixed(), 10)\n while (minute < 0) minute += 60\n while (minute >= 60) minute -= 60\n\n return minute\n}\n\n// Calculate the hour from the hand angle\nexport function getHours(\n handAngle: number,\n hourType: PossibleHourTypes | undefined\n) {\n handAngle = snap(handAngle, _30)\n\n let hour = parseInt((((handAngle - _90) % _360) / _30).toFixed(), 10)\n if (hour < 0) hour += 12\n if (hour >= 12) hour -= 12\n\n if (hourType === hourTypes.am) {\n if (hour <= 0) {\n hour += 12\n } else if (hour >= 12) {\n hour -= 12\n }\n }\n if (hourType === hourTypes.pm) {\n if (hour <= 0) {\n hour += 12\n } else if (hour > 12) {\n hour -= 12\n }\n }\n\n return hour\n}\n\n/** Get the angle of the left/top co-ordinate from the center of the width.height box */\nexport function getAngle(left: number, top: number, size: number) {\n const x = size / 2 - left\n const y = size / 2 - top\n\n // tan O = y / x\n let angle = x ? Math.atan(y / x) : y < 0 ? -_90 : _90\n if (x < 0) {\n // reflect along vertical axis\n angle = -angle + 2 * (_90 + angle)\n }\n\n return angle\n}\n\nexport function useSwitchColors(highlighted: boolean) {\n const theme = useTheme()\n const backgroundColor = React.useMemo<string>(() => {\n if (theme.dark) {\n if (highlighted) {\n return theme.isV3\n ? theme.colors.tertiaryContainer\n : Color(theme.colors.primary).hex()\n }\n return theme.colors.backdrop\n }\n\n if (highlighted) {\n if (theme.isV3) {\n return theme.colors.primaryContainer\n }\n\n return Color(theme.colors.primary).lighten(1).hex()\n }\n return theme.colors.surface\n }, [highlighted, theme])\n\n const color = React.useMemo<string>(() => {\n if (highlighted && !theme.dark) {\n return theme.isV3 ? theme.colors.onSurfaceVariant : theme.colors.primary\n }\n if (highlighted && theme.dark) {\n return theme.isV3\n ? theme.colors.onTertiaryContainer\n : theme.colors.background\n }\n if (theme.isV3) {\n return theme.colors.onSurfaceVariant\n } else {\n return (theme as any as MD2Theme).colors.placeholder\n }\n }, [highlighted, theme])\n\n return { backgroundColor, color }\n}\n\nexport function useInputColors(highlighted: boolean) {\n const theme = useTheme()\n const backgroundColor = React.useMemo<string>(() => {\n if (theme.dark) {\n if (highlighted) {\n return theme.isV3\n ? theme.colors.primaryContainer\n : Color(theme.colors.primary).hex()\n }\n return theme.isV3\n ? theme.colors.surfaceVariant\n : Color(theme.colors.surface).lighten(1.4).hex()\n }\n\n if (highlighted) {\n if (theme.isV3) {\n return theme.colors.secondaryContainer\n }\n return Color(theme.colors.primary).lighten(1).hex()\n }\n if (theme.isV3) {\n return theme.colors.surfaceVariant\n }\n return Color(theme.colors.surface).darken(0.1).hex()\n }, [highlighted, theme])\n\n const color = React.useMemo<string>(() => {\n if (theme.isV3) {\n if (!highlighted) {\n return theme.isV3 ? theme.colors.onSurface : theme.colors.onBackground\n }\n return theme.isV3\n ? theme.colors.onPrimaryContainer\n : theme.colors.onBackground\n } else {\n if (highlighted && !theme.dark) {\n return theme.colors.primary\n }\n return (theme as any as MD2Theme).colors.text\n }\n }, [highlighted, theme])\n\n return { backgroundColor, color }\n}\n\nexport function toHourInputFormat(hours: number, is24Hour: boolean): number {\n if (hours === 24) {\n return 0\n }\n if (is24Hour) {\n return hours\n }\n if (hours > 12) {\n return hours - 12\n }\n return hours\n}\n\nexport function toHourOutputFormat(\n newHours: number,\n previousHours: number,\n is24Hour: boolean\n): number {\n if (is24Hour) {\n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EACD,IAAIA,KAAK,GAAG,EAAZ,EAAgB;IACd,OAAOA,KAAK,GAAG,EAAf;EACD;;EACD,OAAOA,KAAP;AACD;AAED,OAAO,SAAS0E,kBAAT,CACLC,QADK,EAELC,aAFK,EAGLH,QAHK,EAIG;EACR,IAAIA,QAAJ,EAAc;IACZ,OAAOE,QAAP;EACD;;EACD,IAAIC,aAAa,GAAG,EAAhB,IAAsBD,QAAQ,GAAG,EAArC,EAAyC;IACvC,OAAOA,QAAQ,GAAG,EAAlB;EACD;;EACD,OAAOA,QAAP;AACD"}
|
package/lib/module/utils.js
CHANGED
|
@@ -22,6 +22,15 @@ export function useHeaderTextColor() {
|
|
|
22
22
|
export function useTextColorOnPrimary() {
|
|
23
23
|
const theme = useTheme();
|
|
24
24
|
const isDark = !Color(theme.colors.primary).isLight();
|
|
25
|
+
|
|
26
|
+
if (theme.isV3) {
|
|
27
|
+
if (isDark && theme.dark) {
|
|
28
|
+
return theme.colors.onSurface;
|
|
29
|
+
} else {
|
|
30
|
+
return theme.colors.onPrimary;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
return isDark ? '#fff' : '#000';
|
|
26
35
|
}
|
|
27
36
|
export function range(start, end) {
|
package/lib/module/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","overlay","useTheme","Color","useLatest","value","ref","useRef","current","useHeaderBackgroundColor","theme","dark","mode","colors","surface","primary","useHeaderColorIsLight","background","isLight","useHeaderTextColor","useTextColorOnPrimary","isDark","range","start","end","Array","fill","map","_","i","lightenBy","color","ratio","lightness","darkenBy"],"sources":["utils.ts"],"sourcesContent":["import * as React from 'react'\nimport {\n DefaultTheme,\n MD3DarkTheme,\n overlay,\n useTheme,\n} from 'react-native-paper'\nimport Color from 'color'\n\nexport type PaperTheme = typeof MD3DarkTheme | typeof DefaultTheme\n\nexport function useLatest<T>(value: T) {\n const ref = React.useRef(value)\n ref.current = value\n return ref\n}\n\nexport function useHeaderBackgroundColor() {\n const theme = useTheme()\n return theme.dark && theme.mode === 'adaptive'\n ? overlay(4, theme.colors.surface)\n : theme.colors.primary\n}\n\nexport function useHeaderColorIsLight() {\n const theme = useTheme()\n const background =\n theme.dark && theme.mode === 'adaptive'\n ? theme.colors.surface\n : theme.colors.primary\n return Color(background).isLight()\n}\n\nexport function useHeaderTextColor() {\n const isLight = useHeaderColorIsLight()\n return !isLight ? '#fff' : '#000'\n}\n\nexport function useTextColorOnPrimary() {\n const theme = useTheme()\n const isDark = !Color(theme.colors.primary).isLight()\n return isDark ? '#fff' : '#000'\n}\n\nexport function range(start: number, end: number) {\n return Array(end - start + 1)\n .fill(null)\n .map((_, i) => start + i)\n}\n\nexport function lightenBy(color: Color, ratio: number) {\n const lightness = color.lightness()\n return color.lightness(lightness + (100 - lightness) * ratio)\n}\n\nexport function darkenBy(color: Color, ratio: number) {\n const lightness = color.lightness()\n return color.lightness(lightness - lightness * ratio)\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAGEC,OAHF,EAIEC,QAJF,QAKO,oBALP;AAMA,OAAOC,KAAP,MAAkB,OAAlB;AAIA,OAAO,SAASC,SAAT,CAAsBC,KAAtB,EAAgC;EACrC,MAAMC,GAAG,GAAGN,KAAK,CAACO,MAAN,CAAaF,KAAb,CAAZ;EACAC,GAAG,CAACE,OAAJ,GAAcH,KAAd;EACA,OAAOC,GAAP;AACD;AAED,OAAO,SAASG,wBAAT,GAAoC;EACzC,MAAMC,KAAK,GAAGR,QAAQ,EAAtB;EACA,OAAOQ,KAAK,CAACC,IAAN,IAAcD,KAAK,CAACE,IAAN,KAAe,UAA7B,GACHX,OAAO,CAAC,CAAD,EAAIS,KAAK,CAACG,MAAN,CAAaC,OAAjB,CADJ,GAEHJ,KAAK,CAACG,MAAN,CAAaE,OAFjB;AAGD;AAED,OAAO,SAASC,qBAAT,GAAiC;EACtC,MAAMN,KAAK,GAAGR,QAAQ,EAAtB;EACA,MAAMe,UAAU,GACdP,KAAK,CAACC,IAAN,IAAcD,KAAK,CAACE,IAAN,KAAe,UAA7B,GACIF,KAAK,CAACG,MAAN,CAAaC,OADjB,GAEIJ,KAAK,CAACG,MAAN,CAAaE,OAHnB;EAIA,OAAOZ,KAAK,CAACc,UAAD,CAAL,CAAkBC,OAAlB,EAAP;AACD;AAED,OAAO,SAASC,kBAAT,GAA8B;EACnC,MAAMD,OAAO,GAAGF,qBAAqB,EAArC;EACA,OAAO,CAACE,OAAD,GAAW,MAAX,GAAoB,MAA3B;AACD;AAED,OAAO,SAASE,qBAAT,GAAiC;EACtC,MAAMV,KAAK,GAAGR,QAAQ,EAAtB;EACA,MAAMmB,MAAM,GAAG,CAAClB,KAAK,CAACO,KAAK,CAACG,MAAN,CAAaE,OAAd,CAAL,CAA4BG,OAA5B,EAAhB;
|
|
1
|
+
{"version":3,"names":["React","overlay","useTheme","Color","useLatest","value","ref","useRef","current","useHeaderBackgroundColor","theme","dark","mode","colors","surface","primary","useHeaderColorIsLight","background","isLight","useHeaderTextColor","useTextColorOnPrimary","isDark","isV3","onSurface","onPrimary","range","start","end","Array","fill","map","_","i","lightenBy","color","ratio","lightness","darkenBy"],"sources":["utils.ts"],"sourcesContent":["import * as React from 'react'\nimport {\n DefaultTheme,\n MD3DarkTheme,\n overlay,\n useTheme,\n} from 'react-native-paper'\nimport Color from 'color'\n\nexport type PaperTheme = typeof MD3DarkTheme | typeof DefaultTheme\n\nexport function useLatest<T>(value: T) {\n const ref = React.useRef(value)\n ref.current = value\n return ref\n}\n\nexport function useHeaderBackgroundColor() {\n const theme = useTheme()\n return theme.dark && theme.mode === 'adaptive'\n ? overlay(4, theme.colors.surface)\n : theme.colors.primary\n}\n\nexport function useHeaderColorIsLight() {\n const theme = useTheme()\n const background =\n theme.dark && theme.mode === 'adaptive'\n ? theme.colors.surface\n : theme.colors.primary\n return Color(background).isLight()\n}\n\nexport function useHeaderTextColor() {\n const isLight = useHeaderColorIsLight()\n return !isLight ? '#fff' : '#000'\n}\n\nexport function useTextColorOnPrimary() {\n const theme = useTheme()\n const isDark = !Color(theme.colors.primary).isLight()\n\n if (theme.isV3) {\n if (isDark && theme.dark) {\n return theme.colors.onSurface\n } else {\n return theme.colors.onPrimary\n }\n }\n\n return isDark ? '#fff' : '#000'\n}\n\nexport function range(start: number, end: number) {\n return Array(end - start + 1)\n .fill(null)\n .map((_, i) => start + i)\n}\n\nexport function lightenBy(color: Color, ratio: number) {\n const lightness = color.lightness()\n return color.lightness(lightness + (100 - lightness) * ratio)\n}\n\nexport function darkenBy(color: Color, ratio: number) {\n const lightness = color.lightness()\n return color.lightness(lightness - lightness * ratio)\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAGEC,OAHF,EAIEC,QAJF,QAKO,oBALP;AAMA,OAAOC,KAAP,MAAkB,OAAlB;AAIA,OAAO,SAASC,SAAT,CAAsBC,KAAtB,EAAgC;EACrC,MAAMC,GAAG,GAAGN,KAAK,CAACO,MAAN,CAAaF,KAAb,CAAZ;EACAC,GAAG,CAACE,OAAJ,GAAcH,KAAd;EACA,OAAOC,GAAP;AACD;AAED,OAAO,SAASG,wBAAT,GAAoC;EACzC,MAAMC,KAAK,GAAGR,QAAQ,EAAtB;EACA,OAAOQ,KAAK,CAACC,IAAN,IAAcD,KAAK,CAACE,IAAN,KAAe,UAA7B,GACHX,OAAO,CAAC,CAAD,EAAIS,KAAK,CAACG,MAAN,CAAaC,OAAjB,CADJ,GAEHJ,KAAK,CAACG,MAAN,CAAaE,OAFjB;AAGD;AAED,OAAO,SAASC,qBAAT,GAAiC;EACtC,MAAMN,KAAK,GAAGR,QAAQ,EAAtB;EACA,MAAMe,UAAU,GACdP,KAAK,CAACC,IAAN,IAAcD,KAAK,CAACE,IAAN,KAAe,UAA7B,GACIF,KAAK,CAACG,MAAN,CAAaC,OADjB,GAEIJ,KAAK,CAACG,MAAN,CAAaE,OAHnB;EAIA,OAAOZ,KAAK,CAAC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|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { PossibleInputTypes } from './timeUtils';
|
|
2
|
+
export default function AmPmSwitcher({ onChange, hours, inputType, }: {
|
|
2
3
|
hours: number;
|
|
3
4
|
onChange: (newHours: number) => any;
|
|
5
|
+
inputType: PossibleInputTypes;
|
|
4
6
|
}): JSX.Element;
|
|
@@ -6,7 +6,7 @@ export declare function useLatest<T>(value: T): React.MutableRefObject<T>;
|
|
|
6
6
|
export declare function useHeaderBackgroundColor(): string;
|
|
7
7
|
export declare function useHeaderColorIsLight(): boolean;
|
|
8
8
|
export declare function useHeaderTextColor(): "#fff" | "#000";
|
|
9
|
-
export declare function useTextColorOnPrimary():
|
|
9
|
+
export declare function useTextColorOnPrimary(): string;
|
|
10
10
|
export declare function range(start: number, end: number): number[];
|
|
11
11
|
export declare function lightenBy(color: Color, ratio: number): Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | Color<string | number | any | ArrayLike<number> | {
|
|
12
12
|
[key: string]: any;
|
package/package.json
CHANGED
|
@@ -3,24 +3,28 @@ import { View, StyleSheet } from 'react-native'
|
|
|
3
3
|
import { MD2Theme, Text, TouchableRipple, useTheme } from 'react-native-paper'
|
|
4
4
|
import { useMemo } from 'react'
|
|
5
5
|
import Color from 'color'
|
|
6
|
-
import { useSwitchColors } from './timeUtils'
|
|
6
|
+
import { inputTypes, PossibleInputTypes, useSwitchColors } from './timeUtils'
|
|
7
7
|
import { DisplayModeContext } from './TimePicker'
|
|
8
8
|
|
|
9
9
|
export default function AmPmSwitcher({
|
|
10
10
|
onChange,
|
|
11
11
|
hours,
|
|
12
|
+
inputType,
|
|
12
13
|
}: {
|
|
13
14
|
hours: number
|
|
14
15
|
onChange: (newHours: number) => any
|
|
16
|
+
inputType: PossibleInputTypes
|
|
15
17
|
}) {
|
|
16
18
|
const { setMode, mode } = React.useContext(DisplayModeContext)
|
|
17
19
|
const theme = useTheme()
|
|
18
20
|
const backgroundColor = useMemo<string>(() => {
|
|
19
|
-
if (theme.
|
|
20
|
-
return
|
|
21
|
+
if (theme.isV3) {
|
|
22
|
+
return theme.colors.outline
|
|
21
23
|
}
|
|
22
24
|
return Color(
|
|
23
|
-
theme.
|
|
25
|
+
theme.dark
|
|
26
|
+
? Color(theme.colors.surface).lighten(1.2).hex()
|
|
27
|
+
: theme.colors.surface
|
|
24
28
|
)
|
|
25
29
|
.darken(0.1)
|
|
26
30
|
.hex()
|
|
@@ -31,9 +35,12 @@ export default function AmPmSwitcher({
|
|
|
31
35
|
<View
|
|
32
36
|
style={[
|
|
33
37
|
styles.root,
|
|
38
|
+
// eslint-disable-next-line react-native/no-inline-styles
|
|
34
39
|
{
|
|
35
40
|
borderColor: backgroundColor,
|
|
36
|
-
borderRadius: theme.roundness,
|
|
41
|
+
borderRadius: theme.roundness * 2,
|
|
42
|
+
height: inputType === inputTypes.keyboard ? 72 : 80,
|
|
43
|
+
marginBottom: inputType === 'keyboard' ? 24 : 0,
|
|
37
44
|
},
|
|
38
45
|
]}
|
|
39
46
|
>
|
|
@@ -79,7 +86,7 @@ function SwitchButton({
|
|
|
79
86
|
const { backgroundColor, color } = useSwitchColors(selected)
|
|
80
87
|
|
|
81
88
|
let textFont = theme?.isV3
|
|
82
|
-
? theme.fonts.
|
|
89
|
+
? theme.fonts.titleMedium
|
|
83
90
|
: (theme as any as MD2Theme).fonts.medium
|
|
84
91
|
|
|
85
92
|
return (
|
|
@@ -114,14 +121,13 @@ function SwitchButton({
|
|
|
114
121
|
|
|
115
122
|
const styles = StyleSheet.create({
|
|
116
123
|
root: {
|
|
117
|
-
width:
|
|
118
|
-
height: 80,
|
|
124
|
+
width: 52,
|
|
119
125
|
borderWidth: 1,
|
|
120
126
|
overflow: 'hidden',
|
|
121
127
|
},
|
|
122
128
|
switchSeparator: {
|
|
123
129
|
height: 1,
|
|
124
|
-
width:
|
|
130
|
+
width: 52,
|
|
125
131
|
},
|
|
126
132
|
switchButton: {
|
|
127
133
|
flex: 1,
|
package/src/Time/AnalogClock.tsx
CHANGED
|
@@ -127,10 +127,10 @@ function AnalogClock({
|
|
|
127
127
|
style={[
|
|
128
128
|
styles.clock,
|
|
129
129
|
{
|
|
130
|
-
backgroundColor: theme.
|
|
130
|
+
backgroundColor: theme.isV3
|
|
131
|
+
? theme.colors.surfaceVariant
|
|
132
|
+
: theme.dark
|
|
131
133
|
? Color(theme.colors.surface).lighten(1.4).hex()
|
|
132
|
-
: theme.isV3
|
|
133
|
-
? Color(theme.colors.outline).lighten(0.9).hex()
|
|
134
134
|
: Color(theme.colors.surface).darken(0.1).hex(),
|
|
135
135
|
},
|
|
136
136
|
]}
|
|
@@ -145,7 +145,15 @@ function AnalogClock({
|
|
|
145
145
|
transform: [
|
|
146
146
|
{ rotate: -90 + pointerNumber * degreesPerNumber + 'deg' },
|
|
147
147
|
{
|
|
148
|
-
translateX:
|
|
148
|
+
translateX:
|
|
149
|
+
circleSize / 4 -
|
|
150
|
+
(focused === clockTypes.hours &&
|
|
151
|
+
pointerNumber >= 0 &&
|
|
152
|
+
pointerNumber < 13
|
|
153
|
+
? 0
|
|
154
|
+
: 4) +
|
|
155
|
+
(focused === clockTypes.minutes ? 4 : 0) -
|
|
156
|
+
dynamicSize / 2,
|
|
149
157
|
},
|
|
150
158
|
],
|
|
151
159
|
width: circleSize / 2 - 4 - dynamicSize,
|
|
@@ -194,16 +202,15 @@ const styles = StyleSheet.create({
|
|
|
194
202
|
},
|
|
195
203
|
center: { justifyContent: 'center', alignItems: 'center' },
|
|
196
204
|
endPoint: {
|
|
197
|
-
borderRadius:
|
|
198
|
-
height:
|
|
199
|
-
width:
|
|
205
|
+
borderRadius: 24,
|
|
206
|
+
height: 48,
|
|
207
|
+
width: 48,
|
|
200
208
|
position: 'absolute',
|
|
201
209
|
right: 0,
|
|
202
|
-
bottom: -
|
|
210
|
+
bottom: -23,
|
|
203
211
|
},
|
|
204
212
|
line: {
|
|
205
213
|
position: 'absolute',
|
|
206
|
-
marginBottom: -1,
|
|
207
214
|
height: 2,
|
|
208
215
|
borderRadius: 4,
|
|
209
216
|
},
|
|
@@ -33,7 +33,11 @@ function AnalogClockHours({
|
|
|
33
33
|
>
|
|
34
34
|
<View style={styles.outerHourInner}>
|
|
35
35
|
{/* Display 00 instead of 12 for AM hours */}
|
|
36
|
-
<Text
|
|
36
|
+
<Text
|
|
37
|
+
style={hours === i + 1 ? { color } : null}
|
|
38
|
+
variant="bodyLarge"
|
|
39
|
+
selectable={false}
|
|
40
|
+
>
|
|
37
41
|
{mode === 'AM' && !is24Hour && i + 1 === 12 ? '00' : i + 1}
|
|
38
42
|
</Text>
|
|
39
43
|
</View>
|
|
@@ -56,11 +60,11 @@ function AnalogClockHours({
|
|
|
56
60
|
<Text
|
|
57
61
|
selectable={false}
|
|
58
62
|
style={[
|
|
59
|
-
styles.innerHourText,
|
|
60
63
|
i + 13 === hours || (i + 13 === 24 && hours === 0)
|
|
61
64
|
? { color }
|
|
62
65
|
: null,
|
|
63
66
|
]}
|
|
67
|
+
variant="bodyLarge"
|
|
64
68
|
>
|
|
65
69
|
{i + 13 === 24 ? '00' : i + 13}
|
|
66
70
|
</Text>
|
|
@@ -78,27 +82,25 @@ const styles = StyleSheet.create({
|
|
|
78
82
|
justifyContent: 'center',
|
|
79
83
|
alignItems: 'center',
|
|
80
84
|
zIndex: 20,
|
|
81
|
-
width:
|
|
82
|
-
height:
|
|
83
|
-
marginLeft: -
|
|
84
|
-
marginTop: -
|
|
85
|
-
|
|
86
|
-
borderRadius: 25,
|
|
85
|
+
width: 48,
|
|
86
|
+
height: 48,
|
|
87
|
+
marginLeft: -24,
|
|
88
|
+
marginTop: -24,
|
|
89
|
+
borderRadius: 24,
|
|
87
90
|
},
|
|
88
|
-
outerHourInner: { borderRadius:
|
|
91
|
+
outerHourInner: { borderRadius: 24 },
|
|
89
92
|
innerHourRoot: {
|
|
90
93
|
position: 'absolute',
|
|
91
94
|
zIndex: 20,
|
|
92
95
|
justifyContent: 'center',
|
|
93
96
|
alignItems: 'center',
|
|
94
|
-
width:
|
|
95
|
-
height:
|
|
96
|
-
marginLeft: -
|
|
97
|
-
marginTop: -
|
|
98
|
-
borderRadius:
|
|
97
|
+
width: 48,
|
|
98
|
+
height: 48,
|
|
99
|
+
marginLeft: -24,
|
|
100
|
+
marginTop: -24,
|
|
101
|
+
borderRadius: 24,
|
|
99
102
|
},
|
|
100
|
-
innerHourInner: { borderRadius:
|
|
101
|
-
innerHourText: { fontSize: 13 },
|
|
103
|
+
innerHourInner: { borderRadius: 24 },
|
|
102
104
|
})
|
|
103
105
|
|
|
104
106
|
function getHourNumbers(
|
|
@@ -33,6 +33,7 @@ function AnalogClockMinutes({ minutes }: { minutes: number }) {
|
|
|
33
33
|
<Text
|
|
34
34
|
style={isCurrent ? { color } : undefined}
|
|
35
35
|
selectable={false}
|
|
36
|
+
variant="bodyLarge"
|
|
36
37
|
>
|
|
37
38
|
{isZero ? '00' : currentMinutes}
|
|
38
39
|
</Text>
|
|
@@ -50,14 +51,13 @@ const styles = StyleSheet.create({
|
|
|
50
51
|
justifyContent: 'center',
|
|
51
52
|
alignItems: 'center',
|
|
52
53
|
zIndex: 20,
|
|
53
|
-
width:
|
|
54
|
-
height:
|
|
55
|
-
marginLeft: -
|
|
56
|
-
marginTop: -
|
|
57
|
-
|
|
58
|
-
borderRadius: 25,
|
|
54
|
+
width: 48,
|
|
55
|
+
height: 48,
|
|
56
|
+
marginLeft: -24,
|
|
57
|
+
marginTop: -24,
|
|
58
|
+
borderRadius: 24,
|
|
59
59
|
},
|
|
60
|
-
outerHourInner: { borderRadius:
|
|
60
|
+
outerHourInner: { borderRadius: 24 },
|
|
61
61
|
innerHourRoot: {
|
|
62
62
|
position: 'absolute',
|
|
63
63
|
zIndex: 20,
|
package/src/Time/TimeInput.tsx
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
TextInput,
|
|
5
|
+
TextInputProps,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Platform,
|
|
8
|
+
} from 'react-native'
|
|
3
9
|
import { useTheme, TouchableRipple } from 'react-native-paper'
|
|
4
10
|
|
|
5
11
|
import Color from 'color'
|
|
@@ -68,10 +74,17 @@ function TimeInput(
|
|
|
68
74
|
ref={ref}
|
|
69
75
|
style={[
|
|
70
76
|
styles.input,
|
|
77
|
+
// eslint-disable-next-line react-native/no-inline-styles
|
|
71
78
|
{
|
|
72
79
|
color,
|
|
73
80
|
backgroundColor,
|
|
74
|
-
borderRadius: theme.roundness,
|
|
81
|
+
borderRadius: theme.roundness * 2,
|
|
82
|
+
borderColor:
|
|
83
|
+
theme.isV3 && highlighted
|
|
84
|
+
? theme.colors.onPrimaryContainer
|
|
85
|
+
: undefined,
|
|
86
|
+
borderWidth: theme.isV3 && highlighted ? 2 : 0,
|
|
87
|
+
height: inputType === inputTypes.keyboard ? 72 : 80,
|
|
75
88
|
},
|
|
76
89
|
]}
|
|
77
90
|
value={formattedValue}
|
|
@@ -89,11 +102,14 @@ function TimeInput(
|
|
|
89
102
|
StyleSheet.absoluteFill,
|
|
90
103
|
styles.buttonOverlay,
|
|
91
104
|
{
|
|
92
|
-
// backgroundColor: 'blue',
|
|
93
105
|
borderRadius: theme.roundness,
|
|
94
106
|
},
|
|
95
107
|
]}
|
|
96
|
-
rippleColor={
|
|
108
|
+
rippleColor={
|
|
109
|
+
Platform.OS !== 'ios'
|
|
110
|
+
? Color(theme.colors.onSurface).fade(0.7).hex()
|
|
111
|
+
: undefined
|
|
112
|
+
}
|
|
97
113
|
onPress={() => onPress(clockType)}
|
|
98
114
|
borderless={true}
|
|
99
115
|
>
|
|
@@ -107,11 +123,10 @@ function TimeInput(
|
|
|
107
123
|
const styles = StyleSheet.create({
|
|
108
124
|
root: { position: 'relative', height: 80, width: 96 },
|
|
109
125
|
input: {
|
|
110
|
-
fontSize:
|
|
126
|
+
fontSize: 57,
|
|
111
127
|
textAlign: 'center',
|
|
112
128
|
textAlignVertical: 'center',
|
|
113
129
|
width: 96,
|
|
114
|
-
height: 80,
|
|
115
130
|
},
|
|
116
131
|
buttonOverlay: { overflow: 'hidden' },
|
|
117
132
|
})
|