Sha256: 38b782c70659d390a43d26737d4f10686be7ad0a7133b0c7f5523c1e0c7f5e37

Contents?: true

Size: 1.52 KB

Versions: 10

Compression:

Stored size: 1.52 KB

Contents

module MotionPrime
  module ScreenIndicatorsMixin
    def show_activity_indicator
      if @activity_indicator_view.nil?
        @activity_indicator_view = UIActivityIndicatorView.gray
        @activity_indicator_view.center = CGPointMake(view.center.x, view.center.y)
        view.addSubview @activity_indicator_view
      end
      @activity_indicator_view.startAnimating
    end

    def hide_activity_indicator
      return unless @activity_indicator_view
      @activity_indicator_view.stopAnimating
    end

    def show_progress_indicator(text = nil, options = {})
      options[:styles] ||= []
      options[:styles] << :base_progress_indicator
      options[:styles] << :"#{self.class_name_without_kvo.underscore.gsub('_screen', '')}_indicator"
      options[:details_label_text] = text

      if @progress_indicator_view.nil?
        options[:add_to_view] ||= self.view
        @progress_indicator_view = self.progress_hud(options).view
      else
        self.setup(@progress_indicator_view, options.except(:add_to_view))
        @progress_indicator_view.show options.has_key?(:animated) ? options[:animatetd] : true
      end
    end

    def hide_progress_indicator(animated = true)
      @progress_indicator_view.try(:hide, animated)
    end

    def show_notice(message, time = 1.0, type = :notice)
      hud_type = case type.to_s
      when 'alert' then MBAlertViewHUDTypeExclamationMark
      else MBAlertViewHUDTypeCheckmark
      end
      MBHUDView.hudWithBody message,
        type: hud_type, hidesAfter: time, show: true
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
motion-prime-0.7.0 motion-prime/screens/extensions/_indicators_mixin.rb
motion-prime-0.6.0 motion-prime/screens/extensions/_indicators_mixin.rb
motion-prime-0.5.7 motion-prime/screens/extensions/_indicators_mixin.rb
motion-prime-0.5.6 motion-prime/screens/extensions/_indicators_mixin.rb
motion-prime-0.5.5 motion-prime/screens/extensions/_indicators_mixin.rb
motion-prime-0.5.4 motion-prime/screens/extensions/_indicators_mixin.rb
motion-prime-0.5.3 motion-prime/screens/extensions/_indicators_mixin.rb
motion-prime-0.5.2 motion-prime/screens/extensions/_indicators_mixin.rb
motion-prime-0.5.1 motion-prime/screens/extensions/_indicators_mixin.rb
motion-prime-0.5.0 motion-prime/screens/extensions/_indicators_mixin.rb