class MotionHybrid::Toast
Attributes
options[R]
responders[R]
title[R]
Public Class Methods
new(title, options = {})
click to toggle source
# File lib/motion-hybrid/views/toast.rb, line 13 def initialize(title, options = {}) @title, @options = title, options @responders = [CRToastInteractionResponder.interactionResponderWithInteractionType(CRToastInteractionTypeSwipeUp, automaticallyDismiss: true, block: nil)] end
Public Instance Methods
background_color()
click to toggle source
# File lib/motion-hybrid/views/toast.rb, line 27 def background_color '#ffffff'.to_color end
image()
click to toggle source
# File lib/motion-hybrid/views/toast.rb, line 31 def image if options[:image_url] image_data = NSData.dataWithContentsOfURL(NSURL.URLWithString(options[:image_url])) retinafy UIImage.imageWithData(image_data) end end
show(&block)
click to toggle source
# File lib/motion-hybrid/views/toast.rb, line 18 def show(&block) responders << CRToastInteractionResponder.interactionResponderWithInteractionType(CRToastInteractionTypeTapOnce, automaticallyDismiss: true, block: -> (i) { block.call }) if block_given? CRToastManager.showNotificationWithOptions(kcr_options, completionBlock: nil) end
text_color()
click to toggle source
# File lib/motion-hybrid/views/toast.rb, line 23 def text_color '#333'.to_color end
Private Instance Methods
kcr_options()
click to toggle source
# File lib/motion-hybrid/views/toast.rb, line 44 def kcr_options { KCRToastTextKey => title, KCRToastSubtitleTextKey => options[:subtitle].presence, KCRToastTextColorKey => text_color, KCRToastBackgroundColorKey => background_color, KCRToastSubtitleTextColorKey => text_color, KCRToastImageKey => image, KCRToastFontKey => options[:subtitle].present? ? UIFont.boldSystemFontOfSize(13) : UIFont.systemFontOfSize(18), KCRToastTimeIntervalKey => options[:subtitle].present? ? 5 : nil, KCRToastInteractionRespondersKey => responders } end
retinafy(image)
click to toggle source
# File lib/motion-hybrid/views/toast.rb, line 40 def retinafy(image) UIImage.imageWithCGImage(image.CGImage, scale: 2, orientation: image.imageOrientation) end