diff --git a/src/expandableCalendar/Context/Presenter.spec.js b/src/expandableCalendar/Context/Presenter.spec.js index 555a9910f6..f4c054e9e6 100644 --- a/src/expandableCalendar/Context/Presenter.spec.js +++ b/src/expandableCalendar/Context/Presenter.spec.js @@ -1,6 +1,6 @@ const {default: Presenter} = require('./Presenter'); import XDate from 'xdate'; -import {UPDATE_SOURCES} from '../commons'; +import {UpdateSources} from '../commons'; import {toMarkingFormat} from '../../interface'; @@ -14,7 +14,7 @@ describe('Context provider tests', () => { const today1 = XDate(); const today2 = new Date(); const todayDate = toMarkingFormat(XDate()); - const updateSources = UPDATE_SOURCES.CALENDAR_INIT; + const updateSources = UpdateSources.CALENDAR_INIT; describe('isPastDate function tests', () => { it('Expect to get true while passing a past date', () => { diff --git a/src/expandableCalendar/Context/Provider.tsx b/src/expandableCalendar/Context/Provider.tsx index 0dcce9bf2f..99d96a9a9a 100644 --- a/src/expandableCalendar/Context/Provider.tsx +++ b/src/expandableCalendar/Context/Provider.tsx @@ -13,7 +13,7 @@ import Presenter from './Presenter'; const commons = require('../commons'); -const updateSources = commons.UPDATE_SOURCES; +const updateSources = commons.UpdateSources; const TOP_POSITION = 65; interface Props { diff --git a/src/expandableCalendar/WeekCalendar/presenter.spec.js b/src/expandableCalendar/WeekCalendar/presenter.spec.js index f106891dd0..31922aa561 100644 --- a/src/expandableCalendar/WeekCalendar/presenter.spec.js +++ b/src/expandableCalendar/WeekCalendar/presenter.spec.js @@ -1,4 +1,4 @@ -const {UPDATE_SOURCES} = require('../commons'); +const {UpdateSources} = require('../commons'); const {default: Presenter} = require('./presenter'); describe('WeekCalendar presenter tests', () => { @@ -17,7 +17,7 @@ describe('WeekCalendar presenter tests', () => { prevDate: '2021-01-13' }; - const makeContext = (datesInWeek = twoDaysSameWeek, updateSource = UPDATE_SOURCES.WEEK_SCROLL) => { + const makeContext = (datesInWeek = twoDaysSameWeek, updateSource = UpdateSources.WEEK_SCROLL) => { return { ...datesInWeek, updateSource @@ -59,7 +59,7 @@ describe('WeekCalendar presenter tests', () => { }); it('Expect component to update when dates are not in the same week', () => { - const context = makeContext(twoDaysDifferentWeek, UPDATE_SOURCES.PAGE_SCROLL); + const context = makeContext(twoDaysDifferentWeek, UpdateSources.PAGE_SCROLL); const prevContext = makeContext(twoSomeDays); const {shouldComponentUpdate} = makeUUT(); const shouldUpdate = shouldComponentUpdate(context, prevContext); @@ -145,7 +145,7 @@ describe('WeekCalendar presenter tests', () => { const {onDayPress} = makeUUT({context}); onDayPress(context, {dateString: '2021-01-22'}); - expect(setDate).toBeCalledWith('2021-01-22', UPDATE_SOURCES.DAY_PRESS); + expect(setDate).toBeCalledWith('2021-01-22', UpdateSources.DAY_PRESS); }); }); diff --git a/src/expandableCalendar/WeekCalendar/presenter.ts b/src/expandableCalendar/WeekCalendar/presenter.ts index a07d929d96..879627d1ed 100644 --- a/src/expandableCalendar/WeekCalendar/presenter.ts +++ b/src/expandableCalendar/WeekCalendar/presenter.ts @@ -12,7 +12,7 @@ import {WeekCalendarProps} from './index'; const commons = require('../commons'); -const updateSources = commons.UPDATE_SOURCES; +const updateSources = commons.UpdateSources; // must be a positive number const NUMBER_OF_PAGES = 2; diff --git a/src/expandableCalendar/agendaList.tsx b/src/expandableCalendar/agendaList.tsx index ffcce54f50..a54ed3e5bc 100644 --- a/src/expandableCalendar/agendaList.tsx +++ b/src/expandableCalendar/agendaList.tsx @@ -15,7 +15,7 @@ import asCalendarConsumer from './asCalendarConsumer'; const commons = require('./commons'); -const updateSources = commons.UPDATE_SOURCES; +const updateSources = commons.UpdateSources; interface Props extends SectionListProps { /** day format in section title. Formatting values: http://arshaw.com/xdate/#Formatting */ diff --git a/src/expandableCalendar/commons.ts b/src/expandableCalendar/commons.ts index 606fc6718e..36a6151ff1 100644 --- a/src/expandableCalendar/commons.ts +++ b/src/expandableCalendar/commons.ts @@ -1,4 +1,4 @@ -import {Platform, Dimensions, I18nManager} from 'react-native'; +import {Platform, Dimensions, I18nManager, PlatformIOSStatic} from 'react-native'; const {height, width} = Dimensions.get('window'); @@ -8,11 +8,10 @@ export const isIos = Platform.OS === 'ios'; export const screenWidth = width; export const screenHeight = height; export const screenAspectRatio = screenWidth < screenHeight ? screenHeight / screenWidth : screenWidth / screenHeight; -// @ts-expect-error -export const isTablet = Platform.isPad || (screenAspectRatio < 1.6 && Math.max(screenWidth, screenHeight) >= 900); +export const isTablet = (Platform as PlatformIOSStatic).isPad || (screenAspectRatio < 1.6 && Math.max(screenWidth, screenHeight) >= 900); export const todayString = 'today'; -export enum UPDATE_SOURCES { +export enum UpdateSources { CALENDAR_INIT = 'calendarInit', TODAY_PRESS = 'todayPress', LIST_DRAG = 'listDrag', diff --git a/src/expandableCalendar/index.tsx b/src/expandableCalendar/index.tsx index ebb2cef719..8b98b939a7 100644 --- a/src/expandableCalendar/index.tsx +++ b/src/expandableCalendar/index.tsx @@ -22,7 +22,7 @@ import Week from './week'; const commons = require('./commons'); -const updateSources = commons.UPDATE_SOURCES; +const updateSources = commons.UpdateSources; enum Positions { CLOSED = 'closed', OPEN = 'open' diff --git a/src/types.ts b/src/types.ts index fb54c6167b..305a7b2206 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,9 +1,9 @@ import {ColorValue, ViewStyle, TextStyle} from 'react-native'; -import {UPDATE_SOURCES} from './expandableCalendar/commons'; +import {UpdateSources} from './expandableCalendar/commons'; export type Direction = 'left' | 'right'; -export type UpdateSource = keyof typeof UPDATE_SOURCES; +export type UpdateSource = keyof typeof UpdateSources; export type DateData = { year: number, month: number,