Class: Tgios::PhotoController

Inherits:
ExtendedUIViewController show all
Includes:
LoadingIndicator
Defined in:
lib/tgios/photo_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LoadingIndicator

#add_loading_indicator_to, #start_loading, #stop_loading

Methods inherited from ExtendedUIViewController

#dealloc, #dismissViewControllerAnimated, #hook, #prepareForRelease, #unhook, #viewDidDisappear

Instance Attribute Details

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/tgios/photo_controller.rb', line 4

def url
  @url
end

Instance Method Details

#onPrepareForReleaseObject



32
33
# File 'lib/tgios/photo_controller.rb', line 32

def onPrepareForRelease
end

#viewDidLoadObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tgios/photo_controller.rb', line 6

def viewDidLoad
  super
  self.view.backgroundColor = :black.uicolor

  add_loading_indicator_to(self.view)
  unless @url.nil?
    start_loading
    image_loader = ImageLoader.new(@url)
    image_loader.on(:image_loaded) do |image, success|
      stop_loading
      if success
        ap 'image loaded'
        # TODO: use motion layout or other way to handle frame size (or allow full screen)
        small_frame = self.view.bounds
        small_frame.size.height -= 20 + 44 if small_frame == UIScreen.mainScreen.bounds

        scroll_view = PhotoScrollView.alloc.initWithFrame(small_frame, image: image)
        self.view.addSubview(scroll_view)
      end
      image_loader.prepareForRelease
    end
    image_loader.load

  end
end