Skip to content

Commit 17dbf8f

Browse files
author
hy
committed
fix:优化日历组件在移动端展示
1 parent f9f3696 commit 17dbf8f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

packages/core/src/Calendar/index.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState } from 'react';
2-
import { View, Text, ViewProps, StyleSheet, TouchableOpacity, Dimensions, Platform } from 'react-native';
2+
import { View, Text, ViewProps, TextProps, StyleSheet, TouchableOpacity, Dimensions, Platform } from 'react-native';
33
import Icon from '../Icon';
44
import Ellipsis from '../Ellipsis';
55
import { getMonths, getWeeksArray, daysArrProps, getType, getNameLen } from './utils';
@@ -112,7 +112,7 @@ const Calendar = (props: CalendarProps) => {
112112

113113
let nameLen = getNameLen(day.lunarHolidays);
114114
let lineHeight =
115-
lunarHoliday === true && Platform.OS === 'ios' ? 0 : lunarHoliday === true ? MainWidth < 1000 ? 18 : 55 : MainWidth < 1000 ? MainWidth / 7 - 4.5 : MainWidth / 14.5;
115+
lunarHoliday === true && Platform.OS === 'ios' ? 0 : lunarHoliday === true ? 18 : MainWidth / 7 - 4.5;
116116
let paddingTop = lunarHoliday === true ? 4 : 0;
117117
let colorType = '';
118118
if (day.colorType === '') {
@@ -211,9 +211,9 @@ const Calendar = (props: CalendarProps) => {
211211
setCurrentMonth(toMonth);
212212
setCurrentDays(toDays);
213213
};
214-
// const goCurrentDay = (day: number) => {
215-
// setCurrentDays(day);
216-
// };
214+
const goCurrentDay = (day: number) => {
215+
setCurrentDays(day);
216+
};
217217

218218
return (
219219
<View style={{ flex: 1, position: 'relative' }}>
@@ -298,10 +298,10 @@ const styles = StyleSheet.create({
298298
},
299299
calendarWeekdays: {
300300
flexDirection: 'row',
301-
justifyContent: 'space-around',
301+
justifyContent: 'space-between',
302302
alignItems: 'center',
303-
paddingHorizontal: MainWidth < 1000 ? MainWidth / 7 - 33 : MainWidth / 30,
304-
paddingTop: 12,
303+
paddingHorizontal: MainWidth / 7 - 33,
304+
paddingTop: 10,
305305
},
306306
calendarWedText: {
307307
color: '#616161',
@@ -312,12 +312,12 @@ const styles = StyleSheet.create({
312312
},
313313
weekDay: {
314314
flexDirection: 'row',
315-
paddingHorizontal: 22,
315+
paddingHorizontal: 2,
316316
},
317317
dateBase: {
318-
marginHorizontal: 8,
319-
width: MainWidth < 1000 ? MainWidth / 7 - 4.5 : MainWidth / 14,
320-
height: MainHeight < 300 ? MainWidth / 7 - 4.5 : MainWidth / 14,
318+
marginHorizontal: 2,
319+
width: MainWidth / 7 - 4.5,
320+
height: MainWidth / 7 - 4.5,
321321
...Platform.select({
322322
ios: {},
323323
android: {
@@ -327,15 +327,15 @@ const styles = StyleSheet.create({
327327
},
328328
currentMonth: {
329329
backgroundColor: '#329BCB',
330-
borderRadius: 60,
330+
borderRadius: 50,
331331
},
332332
selectMonth: {
333333
borderWidth: 1,
334334
borderColor: '#329BCB',
335-
borderRadius: 60,
335+
borderRadius: 50,
336336
},
337337
otherMonth: {
338-
borderRadius: 60,
338+
borderRadius: 50,
339339
},
340340
dayText: {
341341
textAlign: 'center',

0 commit comments

Comments
 (0)