Skip to content

Commit 8231535

Browse files
Merge pull request #206 from iM-GeeKy/iM-GeeKy/material-you
Material You
2 parents 4b656c8 + 51d35db commit 8231535

18 files changed

+174
-117
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"react": "^18.2.0",
6868
"react-native": "^0.69.5",
6969
"react-native-builder-bob": "^0.18.3",
70-
"react-native-paper": "^4.12.4",
70+
"react-native-paper": "^5.0.0-rc.6",
7171
"release-it": "^15.4.0",
7272
"typescript": "^4.7.4"
7373
},

src/Date/AnimatedCrossView.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,24 @@ import { Animated, StyleSheet, View } from 'react-native'
33
import { useTheme } from 'react-native-paper'
44

55
export default function AnimatedCrossView({
6-
// visible,
76
collapsed,
87
calendar,
98
calendarEdit,
109
}: {
1110
calendar: any
1211
calendarEdit: any
13-
// visible: boolean
1412
collapsed: boolean
1513
}) {
1614
const theme = useTheme()
1715
const calendarOpacity = React.useRef<Animated.Value>(
1816
new Animated.Value(collapsed ? 1 : 0)
1917
)
2018
React.useEffect(() => {
21-
// if (visible) {
2219
Animated.timing(calendarOpacity.current, {
2320
toValue: collapsed ? 1 : 0,
2421
duration: 250,
2522
useNativeDriver: true,
2623
}).start()
27-
// }
2824
}, [collapsed])
2925

3026
return (

src/Date/Calendar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type BaseCalendarProps = {
3434
startYear?: number
3535
endYear?: number
3636

37-
// here they are optional but in final implemenation they are required
37+
// here they are optional but in final implementation they are required
3838
date?: CalendarDate
3939
dates?: CalendarDates
4040
startDate?: CalendarDate
@@ -101,7 +101,7 @@ function Calendar(
101101

102102
const selectColor = useMemo<string>(() => {
103103
if (theme.dark) {
104-
return darkenBy(Color(theme.colors.primary), 0.9).hex()
104+
return darkenBy(Color(theme.colors.primary), 0.1).hex()
105105
}
106106
return lightenBy(Color(theme.colors.primary), 0.9).hex()
107107
}, [theme])

src/Date/DatePickerModalContentHeader.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import * as React from 'react'
22
import { View, StyleSheet } from 'react-native'
3-
import { IconButton, Text } from 'react-native-paper'
3+
import { IconButton, Text, useTheme } from 'react-native-paper'
44
import type { ModeType } from './Calendar'
55
import type { LocalState } from './DatePickerModalContent'
66
import { useHeaderTextColor } from '../utils'
77
import Color from 'color'
88
import { getTranslation } from '../translations/utils'
9+
import type {
10+
Fonts,
11+
MD3Typescale,
12+
} from 'react-native-paper/lib/typescript/types'
913

1014
export interface HeaderPickProps {
1115
moreLabel?: string
@@ -61,15 +65,22 @@ export default function DatePickerModalContentHeader(
6165
editIcon = 'pencil',
6266
calendarIcon = 'calendar',
6367
} = props
64-
68+
const theme = useTheme()
6569
const label = getLabel(props.locale, props.mode, props.label)
6670

6771
const color = useHeaderTextColor()
6872
const allowEditing = mode !== 'multiple'
73+
74+
let textFont = (theme.fonts as Fonts)?.medium
75+
76+
if (theme.isV3) {
77+
textFont = (theme.fonts as MD3Typescale)?.bodyLarge
78+
}
79+
6980
return (
7081
<View style={[styles.header]}>
7182
<View>
72-
<Text style={[styles.label, { color }]}>
83+
<Text style={[styles.label, { color, ...textFont }]}>
7384
{uppercase ? label.toUpperCase() : label}
7485
</Text>
7586
<View style={styles.headerContentContainer}>
@@ -97,7 +108,7 @@ export default function DatePickerModalContentHeader(
97108
? getTranslation(props.locale, 'typeInDate')
98109
: getTranslation(props.locale, 'pickDateFromCalendar')
99110
}
100-
color={color}
111+
iconColor={color}
101112
onPress={onToggle}
102113
/>
103114
) : null}

src/Date/DatePickerModalHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export default function DatePickerModalHeader(
4242
<Appbar.Content title={''} />
4343
<Button
4444
color={color}
45+
textColor={color}
4546
onPress={props.onSave}
4647
disabled={props.saveLabelDisabled || false}
4748
uppercase={props.uppercase || true}

src/Date/DateRangeInput.tsx

Lines changed: 0 additions & 75 deletions
This file was deleted.

src/Date/Day.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import * as React from 'react'
2-
import { DarkTheme, Text, TouchableRipple } from 'react-native-paper'
2+
import { Theme, Text, TouchableRipple } from 'react-native-paper'
33
import { StyleSheet, View } from 'react-native'
44
import DayRange from './DayRange'
55
import { daySize } from './dateUtils'
6+
import type {
7+
Fonts,
8+
MD3Typescale,
9+
} from 'react-native-paper/lib/typescript/types'
610

711
function EmptyDayPure() {
812
return <View style={styles.empty} />
913
}
1014
export const EmptyDay = React.memo(EmptyDayPure)
1115

1216
function Day(props: {
13-
theme: typeof DarkTheme
17+
theme: Theme
1418
textColorOnPrimary: string
1519
day: number
1620
month: number
@@ -41,7 +45,6 @@ function Day(props: {
4145
textColorOnPrimary,
4246
theme,
4347
} = props
44-
// console.log(month, { day })
4548
const onPress = React.useCallback(() => {
4649
onPressDate(new Date(year, month, day))
4750
}, [onPressDate, year, month, day])
@@ -55,6 +58,12 @@ function Day(props: {
5558
const textColor =
5659
selected || (inRange && theme.dark) ? textColorOnPrimary : undefined
5760

61+
let textFont = (theme.fonts as Fonts)?.medium
62+
63+
if (theme.isV3) {
64+
textFont = (theme.fonts as MD3Typescale)?.bodyMedium
65+
}
66+
5867
return (
5968
<View style={[styles.root, disabled && styles.disabled]}>
6069
<DayRange
@@ -83,7 +92,10 @@ function Day(props: {
8392
]}
8493
>
8594
<Text
86-
style={textColor ? { color: textColor } : undefined}
95+
style={[
96+
textColor ? { color: textColor } : undefined,
97+
{ ...textFont },
98+
]}
8799
selectable={false}
88100
>
89101
{day}

src/Date/DayName.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
import * as React from 'react'
22
import { StyleSheet, View } from 'react-native'
3-
import { Text, useTheme } from 'react-native-paper'
3+
import { Text, Theme, useTheme } from 'react-native-paper'
4+
import type {
5+
Fonts,
6+
MD3Typescale,
7+
} from 'react-native-paper/lib/typescript/types'
48

59
function DayName({ label }: { label: string }) {
6-
const theme = useTheme()
10+
const theme: Theme = useTheme()
11+
12+
let textFont = (theme.fonts as Fonts)?.medium
13+
14+
if (theme.isV3) {
15+
textFont = (theme.fonts as MD3Typescale)?.bodyMedium
16+
}
17+
718
return (
819
<View style={styles.dayName}>
9-
<Text
10-
style={[styles.dayNameLabel, theme.fonts.medium]}
11-
selectable={false}
12-
>
20+
<Text style={[styles.dayNameLabel, { ...textFont }]} selectable={false}>
1321
{label}
1422
</Text>
1523
</View>

src/Date/Month.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ import type {
2929
} from './Calendar'
3030
import { dayNamesHeight } from './DayNames'
3131
import { useTextColorOnPrimary } from '../utils'
32+
import type {
33+
Fonts,
34+
MD3Typescale,
35+
} from 'react-native-paper/lib/typescript/types'
3236

3337
interface BaseMonthProps {
3438
locale: undefined | string
@@ -244,6 +248,12 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
244248
date,
245249
])
246250

251+
let textFont = (theme.fonts as Fonts)?.medium
252+
253+
if (theme.isV3) {
254+
textFont = (theme.fonts as MD3Typescale)?.bodyMedium
255+
}
256+
247257
return (
248258
<View style={[styles.month, { height: getMonthHeight(scrollMode, index) }]}>
249259
<View
@@ -278,7 +288,7 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
278288
]}
279289
>
280290
<Text
281-
style={[styles.monthLabel, theme.fonts.medium]}
291+
style={[styles.monthLabel, { ...textFont }]}
282292
selectable={false}
283293
>
284294
{monthName} {year}

src/Date/Swiper.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ function VerticalScroller({
157157
right: 0,
158158
position: 'absolute',
159159
height: getMonthHeight('vertical', visibleIndexes[vi]),
160-
// transform: `translateY(${getMonthsOffset('vertical', vi)}px)`,
161160
}}
162161
>
163162
{renderItem({

0 commit comments

Comments
 (0)