colinta / teacup

This project has been sunset in favor of MotionKit
github.com/motion-kit/motion-kit
Other
602 stars 85 forks source link

[REQ] Loaded View Symbol #94

Closed GantMan closed 10 years ago

GantMan commented 11 years ago

Caution

This may already exist in some way, and I'm not seeing it.

Current Behaviour

During a layout block you can specify a symbol of the loading UIView for styling.

class RootController < UIViewController
  stylesheet :root_style

  layout :root do
    #...
  end
end

This is great. Though it tightly couples the stylesheet to that particular layout block.

Request

I'm requesting a level of abstraction between the two. A special Teacup keyword that identifies the loading view.

EXAMPLE

Teacup::Stylesheet.new :root_style do

  style Teacup::LoadingView,
    backgroundColor: 'background'.uicolor

end

Benefit 1: Styles that import could abstract away application wide styles on the view. Like the above background pattern.

Benefit 2: Would make Teacup play nicely with other forms of loading (Like ProMotion) where the layout block is inaccessible and attributes would have to manually be set.

EXAMPLE the will_appear code could be removed and placed in the abstracted stylesheet.

class HomeScreen < PM::Screen
  stylesheet :home_screen

    def will_appear
      #the following line could be eliminated!
      set_attributes self.view, stylename: :home_view
    end
end

Follow Up

Please let me know if you have questions/concerns with this philosophy. I'd be more than happy to help if you could point me in the right direction of how you'd see this behavior implemented.

colinta commented 10 years ago

There's a lot going on in this one, especially the ProMotion integration concerns. It seems like there are more issues there, like making sure restyle! is called. For now anyway, I think just assigning a root class is appropriate... A project that shows an ideal "promotion+teacup" integration would be great, though, and would help me think about how this could be improved!

GantMan commented 10 years ago

Take A look at the Ruby trivia app here: https://github.com/IconoclastLabs/rubytrivia

No big deal if you squash this one. Just dreamcode requests.