@@ -14,7 +14,7 @@ import {Row} from '../../components/layout'
1414import type { TopLevelViewPropsType } from '../../types'
1515import { parseHours , blankSchedule } from '../lib'
1616import * as c from '../../components/colors'
17- import DatePicker from 'react-native- datepicker'
17+ import { DatePicker } from '../../components/ datepicker'
1818import { Touchable } from '../../components/touchable'
1919import { DeleteButtonCell } from '../../components/cells/delete-button'
2020import { CellToggle } from '../../components/cells/toggle'
@@ -114,14 +114,13 @@ class WeekTogglesIOS extends React.PureComponent {
114114 const allDays = [ 'Mo' , 'Tu' , 'We' , 'Th' , 'Fr' , 'Sa' , 'Su' ]
115115
116116 return (
117- < Row justifyContent = "center" >
118- { allDays . map ( ( day , i ) =>
117+ < Row justifyContent = "center" alignItems = "stretch" >
118+ { allDays . map ( day =>
119119 < ToggleButton
120120 key = { day }
121121 text = { day }
122122 active = { this . props . days . includes ( day ) }
123123 onPress = { this . toggleDay }
124- style = { i === allDays . length - 1 && styles . finalCell }
125124 /> ,
126125 ) }
127126 </ Row >
@@ -149,9 +148,7 @@ class WeekTogglesAndroid extends React.PureComponent {
149148 value = { this . props . days . includes ( day ) }
150149 onChange = { ( ) => this . toggleDay ( day ) }
151150 />
152- { i === allDays . length - 1 && styles . finalCell
153- ? null
154- : < ListSeparator force = { true } /> }
151+ { i === allDays . length - 1 ? null : < ListSeparator force = { true } /> }
155152 </ View > ,
156153 ) }
157154 </ View >
@@ -164,17 +161,16 @@ class ToggleButton extends React.PureComponent {
164161 active : boolean ,
165162 text : string ,
166163 onPress : ( newState : string ) => any ,
167- style ?: any ,
168164 }
169165
170166 onPress = ( ) => this . props . onPress ( this . props . text )
171167
172168 render ( ) {
173- const { text, style , active} = this . props
169+ const { text, active} = this . props
174170 return (
175171 < Touchable
176172 highlight = { false }
177- containerStyle = { [ style , styles . dayWrapper , active && styles . activeDay ] }
173+ containerStyle = { [ styles . dayWrapper , active && styles . activeDay ] }
178174 onPress = { this . onPress }
179175 >
180176 < Text style = { [ styles . dayText , active && styles . activeDayText ] } >
@@ -191,32 +187,40 @@ class DatePickerCell extends React.PureComponent {
191187 props : {
192188 date : moment ,
193189 title : string ,
194- onChange ?: ( date : moment ) => any ,
195- _ref ?: ( ref : any ) => any ,
190+ onChange : ( date : moment ) => any ,
196191 }
197192
198193 _picker: any
199194 openPicker = ( ) => this . _picker . onPressDate ( )
200195
201- getRef = ( ref : any ) => {
202- this . _picker = ref
203- this . props . _ref && this . props . _ref ( ref )
204- }
196+ getRef = ( ref : any ) => ( this . _picker = ref )
205197
206198 onChange = ( newDate : moment ) => {
207- console . log ( newDate )
208- this . props . onChange && this . props . onChange ( newDate )
199+ const oldMoment = moment ( )
200+
201+ oldMoment . hours ( newDate . hours ( ) )
202+ oldMoment . minutes ( newDate . minutes ( ) )
203+
204+ this . props . onChange ( oldMoment )
209205 }
210206
211207 render ( ) {
212- const { date, title} = this . props
208+ const format = 'h:mm A'
209+
213210 const accessory = (
214- < Date _ref = { this . getRef } date = { date . toDate ( ) } onChange = { this . onChange } />
211+ < DatePicker
212+ ref = { this . getRef }
213+ initialDate = { this . props . date }
214+ minuteInterval = { 5 }
215+ mode = "time"
216+ format = { format }
217+ onDateChange = { this . onChange }
218+ />
215219 )
216220
217221 return (
218222 < Cell
219- title = { title }
223+ title = { this . props . title }
220224 cellStyle = "RightDetail"
221225 cellAccessoryView = { accessory }
222226 onPress = { this . openPicker }
@@ -225,51 +229,13 @@ class DatePickerCell extends React.PureComponent {
225229 }
226230}
227231
228- const Date = ( { date, onChange, _ref} ) => {
229- const format = 'h:mma'
230-
231- const callback = ( newDateString : string ) => {
232- const oldMoment = moment ( date )
233- const newMoment = moment ( newDateString , format )
234-
235- oldMoment . hours ( newMoment . hours ( ) )
236- oldMoment . minutes ( newMoment . minutes ( ) )
237-
238- onChange ( oldMoment )
239- }
240-
241- return (
242- < DatePicker
243- ref = { _ref }
244- date = { date }
245- style = { styles . datePicker }
246- mode = "time"
247- format = { format }
248- is24Hour = { false }
249- confirmBtnText = "Confirm"
250- cancelBtnText = "Cancel"
251- showIcon = { false }
252- onDateChange = { callback }
253- customStyles = { {
254- dateInput : styles . datePickerInput ,
255- dateText : styles . datePickerText ,
256- } }
257- />
258- )
259- }
260-
261232const styles = StyleSheet . create ( {
262233 dayWrapper : {
263234 flex : 1 ,
264235 alignItems : 'center' ,
265236 paddingVertical : 10 ,
266237 paddingHorizontal : 2 ,
267238 backgroundColor : c . white ,
268- //borderRightWidth: StyleSheet.hairlineWidth,
269- //borderRightColor: c.iosSeparator,
270- } ,
271- finalCell : {
272- borderRightWidth : 0 ,
273239 } ,
274240 activeDay : {
275241 backgroundColor : c . brickRed ,
@@ -280,15 +246,4 @@ const styles = StyleSheet.create({
280246 activeDayText : {
281247 color : c . white ,
282248 } ,
283- datePicker : {
284- width : null ,
285- } ,
286- datePickerInput : {
287- flex : 0 ,
288- borderWidth : 0 ,
289- } ,
290- datePickerText : {
291- color : c . iosDisabledText ,
292- fontSize : 16 ,
293- } ,
294249} )
0 commit comments