Sha256: b7dfc52e6c0686dc390970394a28266b1c8e8e86fce70ba51be8c58e8739fd61

Contents?: true

Size: 891 Bytes

Versions: 3

Compression:

Stored size: 891 Bytes

Contents

module ProMotion
  class TabBar
    class << self
      def tab_bar_item(args = {})
        title = "Untitled"
        title = args[:title] if args[:title]
        args[:tag] ||= 0

        tb_item = tab_bar_icon(args[:system_icon], args[:tag]) if args[:system_icon]
        tb_item = tab_bar_icon_custom(title, args[:icon], args[:tag]) if args[:icon]
        
        if tb_item
          tb_item.badgeValue = args[:badge_number].to_s unless args[:badge_number].nil? || tab[:badge_number] <= 0

          return tb_item
        end
        nil
      end

      def tab_bar_icon(icon, tag)
        return UITabBarItem.alloc.initWithTabBarSystemItem(icon, tag: tag)
      end

      def tab_bar_icon_custom(title, image_name, tag)
        icon_image = UIImage.imageNamed(image_name)
        return UITabBarItem.alloc.initWithTitle(title, image:icon_image, tag:tag)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ProMotion-0.1.2 lib/ProMotion/helpers/TabBar.rb
ProMotion-0.1.1 lib/ProMotion/helpers/TabBar.rb
ProMotion-0.1.0 lib/ProMotion/helpers/TabBar.rb