19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 19
def formDescriptorCellDidSelectedWithFormController(controller)
return if self.rowDescriptor.disabled
self.formViewController.view.endEditing(true)
size = if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad
[400, 440]
else
UIScreen.mainScreen.bounds.size
end
color_chooser = PMXLColorChooser.alloc.initWithFrame [[0, 0], size]
color_chooser.delegate = self
color_chooser.color = self.rowDescriptor.value || UIColor.whiteColor
if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad
controller = UIViewController.new
controller.view = color_chooser
@popover = UIPopoverController.alloc.initWithContentViewController controller
@popover.popoverContentSize = color_chooser.frame.size
f = self.contentView.convertRect(@color_view.frame, toView: self.formViewController.view)
@popover.presentPopoverFromRect(f,
inView: self.formViewController.view,
permittedArrowDirections: UIPopoverArrowDirectionAny,
animated: true)
else
controller = UIViewController.new
controller.view = color_chooser
navigation_controller = UINavigationController.alloc.initWithRootViewController(controller)
navigation_controller.navigationBar.translucent = false
right = UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemDone,
target: self,
action: 'hide_picker:')
controller.navigationItem.rightBarButtonItem = right
if self.formViewController.presentedViewController
self.formViewController.dismissViewControllerAnimated(true,
completion: -> {
self.formViewController.presentViewController(navigation_controller,
animated: true,
completion: nil)
})
else
self.formViewController.presentViewController(navigation_controller,
animated: true,
completion: nil)
end
end
end
|