Skip to content

Commit 53ea209

Browse files
authored
Merge pull request #3040 from StoDevX/module-calendar
[module] frogpond/ccc-calendar, frogpond/event-list, and frogpond/add-to-device-calendar
2 parents dbf50a7 + 60fb51c commit 53ea209

File tree

23 files changed

+180
-74
lines changed

23 files changed

+180
-74
lines changed

source/components/add-to-calendar.js renamed to modules/add-to-device-calendar/add-to-calendar.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// @flow
2+
23
import * as React from 'react'
3-
import type {EventType} from '../views/calendar/types'
4-
import {addToCalendar} from '../views/calendar/calendar-util'
4+
import type {EventType} from '@frogpond/event-type'
5+
import {addToCalendar} from './lib'
56
import delay from 'delay'
67

78
type Props = {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// @flow
2+
3+
export {AddToCalendar} from './add-to-calendar'

source/views/calendar/calendar-util.js renamed to modules/add-to-device-calendar/lib.js

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
11
// @flow
22

3-
import {Platform, Alert, Linking, Share} from 'react-native'
4-
import RNCalendarEvents from 'react-native-calendar-events'
5-
import type {EventType} from './types'
3+
import type {EventType} from '@frogpond/event-type'
64
import {notify} from '@frogpond/analytics'
7-
import {detailTimes} from './times'
8-
9-
export function shareEvent(event: EventType): Promise<any> {
10-
const title = event.title
11-
const times = getTimes(event)
12-
const location = event.location
13-
const description = event.description
14-
const message = `${title}\n\n${times}\n\n${location}\n\n${description}`.trim()
15-
return Share.share({message})
16-
.then(result => console.log(result))
17-
.catch(error => console.log(error.message))
18-
}
5+
import RNCalendarEvents from 'react-native-calendar-events'
6+
import {Alert, Linking, Platform} from 'react-native'
197

208
export function addToCalendar(event: EventType): Promise<boolean> {
219
return RNCalendarEvents.authorizationStatus()
@@ -89,13 +77,3 @@ async function requestCalendarAccess(): Promise<boolean> {
8977

9078
return true
9179
}
92-
93-
export function getTimes(event: EventType) {
94-
const {allDay, start, end} = detailTimes(event)
95-
96-
if (allDay) {
97-
return `All-Day on ${event.startTime.format('MMM D.')}`
98-
}
99-
100-
return `${start}${end ? ' to ' + end : ''}`
101-
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "@frogpond/add-to-device-calendar",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"author": "",
7+
"license": "ISC",
8+
"scripts": {
9+
"test": "jest"
10+
},
11+
"peerDependencies": {
12+
"react": "^16.0.0",
13+
"react-native": "^0.55.4",
14+
"react-native-calendar-events": "1.6.3"
15+
},
16+
"dependencies": {
17+
"@frogpond/analytics": "^1.0.0",
18+
"@frogpond/event-type": "^1.0.0",
19+
"delay": "4.0.1"
20+
}
21+
}

source/views/calendar/calendar-ccc.js renamed to modules/ccc-calendar/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
// @flow
22

33
import * as React from 'react'
4-
import {EventList} from './event-list'
54
import {reportNetworkProblem} from '@frogpond/analytics'
6-
import type {TopLevelViewPropsType} from '../types'
7-
import type {EventType, PoweredBy} from './types'
5+
import type {NavigationScreenProp} from 'react-navigation'
6+
import {EventList, type PoweredBy} from '@frogpond/event-list'
7+
import {type EventType} from '@frogpond/event-type'
88
import moment from 'moment-timezone'
99
import delay from 'delay'
1010
import {LoadingView} from '@frogpond/notice'
1111
import {API} from '@frogpond/api'
1212
const TIMEZONE = 'America/Winnipeg'
1313

14-
type Props = TopLevelViewPropsType & {
14+
type Props = {
1515
calendar:
1616
| string
1717
| {type: 'google', id: string}
1818
| {type: 'reason', url: string}
1919
| {type: 'ics', url: string},
2020
detailView?: string,
2121
eventMapper?: EventType => EventType,
22+
navigation: NavigationScreenProp<*>,
2223
poweredBy: ?PoweredBy,
2324
}
2425

modules/ccc-calendar/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "@frogpond/ccc-calendar",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"author": "",
7+
"license": "ISC",
8+
"scripts": {
9+
"test": "jest"
10+
},
11+
"peerDependencies": {
12+
"react": "^16.0.0",
13+
"react-navigation": "^2.13.0",
14+
"moment-timezone": "^0.5.21",
15+
"delay": "4.0.1"
16+
},
17+
"dependencies": {
18+
"@frogpond/analytics": "^1.0.0",
19+
"@frogpond/api": "^1.0.0",
20+
"@frogpond/event-list": "^1.0.0",
21+
"@frogpond/event-type": "^1.0.0",
22+
"@frogpond/notice": "^1.0.0"
23+
}
24+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// @flow
2+
3+
import {Share} from 'react-native'
4+
5+
import type {EventType} from '@frogpond/event-type'
6+
import {detailTimes} from './times'
7+
8+
export function shareEvent(event: EventType): Promise<mixed> {
9+
const title = event.title
10+
const times = getTimes(event)
11+
const location = event.location
12+
const description = event.description
13+
14+
const message = `${title}\n\n${times}\n\n${location}\n\n${description}`.trim()
15+
16+
return Share.share({message}).catch(error => console.log(error.message))
17+
}
18+
19+
export function getTimes(event: EventType) {
20+
const {allDay, start, end} = detailTimes(event)
21+
22+
if (allDay) {
23+
return `All-Day on ${event.startTime.format('MMM D.')}`
24+
}
25+
26+
return `${start}${end ? ' to ' + end : ''}`
27+
}

source/views/calendar/event-detail.android.js renamed to modules/event-list/event-detail.android.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
// @flow
22
import * as React from 'react'
33
import {Text, ScrollView, StyleSheet} from 'react-native'
4-
import type {EventType, PoweredBy} from './types'
5-
import type {TopLevelViewPropsType} from '../types'
4+
import type {EventType} from '@frogpond/event-type'
5+
import type {PoweredBy} from './types'
6+
import {NavigationScreenProp} from 'react-navigation'
67
import {ShareButton} from '@frogpond/navigation-buttons'
78
import {openUrl} from '@frogpond/open-url'
89
import {Card} from '@frogpond/silly-card'
910
import * as c from '@frogpond/colors'
1011
import {ButtonCell} from '@frogpond/tableview'
1112
import {shareEvent, getTimes} from './calendar-util'
12-
import {AddToCalendar} from '../../components/add-to-calendar'
13+
import {AddToCalendar} from '@frogpond/add-to-device-calendar'
1314
import {ListFooter} from '@frogpond/lists'
1415

1516
const styles = StyleSheet.create({
@@ -59,15 +60,18 @@ function Links({urls}: {urls: Array<string>}) {
5960
) : null
6061
}
6162

62-
type Props = TopLevelViewPropsType & {
63-
navigation: {
64-
state: {params: {event: EventType, poweredBy: ?PoweredBy}},
65-
},
63+
type Navigation = NavigationScreenProp<{
64+
params: {event: EventType, poweredBy: ?PoweredBy},
65+
}>
66+
67+
type Props = {
68+
navigation: Navigation,
6669
}
6770

6871
export class EventDetail extends React.PureComponent<Props> {
69-
static navigationOptions = ({navigation}: any) => {
72+
static navigationOptions = ({navigation}: {navigation: Navigation}) => {
7073
const {event} = navigation.state.params
74+
7175
return {
7276
title: event.title,
7377
headerRight: <ShareButton onPress={() => shareEvent(event)} />,

source/views/calendar/event-detail.ios.js renamed to modules/event-list/event-detail.ios.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import {
77
ButtonCell,
88
SelectableCell,
99
} from '@frogpond/tableview'
10-
import type {EventType, PoweredBy} from './types'
11-
import type {TopLevelViewPropsType} from '../types'
10+
import type {EventType} from '@frogpond/event-type'
11+
import type {PoweredBy} from './types'
12+
import type {NavigationScreenProp} from 'react-navigation'
1213
import {ShareButton} from '@frogpond/navigation-buttons'
1314
import {ListFooter} from '@frogpond/lists'
1415
import {shareEvent, getTimes} from './calendar-util'
15-
import {AddToCalendar} from '../../components/add-to-calendar'
16+
import {AddToCalendar} from '@frogpond/add-to-device-calendar'
1617

1718
function MaybeSection({header, content}: {header: string, content: string}) {
1819
return content.trim() ? (
@@ -22,15 +23,18 @@ function MaybeSection({header, content}: {header: string, content: string}) {
2223
) : null
2324
}
2425

25-
type Props = TopLevelViewPropsType & {
26-
navigation: {
27-
state: {params: {event: EventType, poweredBy: ?PoweredBy}},
28-
},
26+
type Navigation = NavigationScreenProp<{
27+
params: {event: EventType, poweredBy: ?PoweredBy},
28+
}>
29+
30+
type Props = {
31+
navigation: Navigation,
2932
}
3033

3134
export class EventDetail extends React.Component<Props> {
32-
static navigationOptions = ({navigation}: any) => {
35+
static navigationOptions = ({navigation}: {navigation: Navigation}) => {
3336
const {event} = navigation.state.params
37+
3438
return {
3539
title: event.title,
3640
headerRight: <ShareButton onPress={() => shareEvent(event)} />,

0 commit comments

Comments
 (0)