Code Monkey home page Code Monkey logo

Comments (6)

GantMan avatar GantMan commented on June 28, 2024

Let me rephrase to see if I've understood. You have some subviews that are not anchored to a particular controller, and you'd like a centralized location to style these and apply them when you place these styled subviews?

Universal styles can be found in the Application stylesheet (stylesheets/application_stylesheet.rb). It's a great spot to include any universal styles. Then when you add the views they'll have access to those styles.

Would that be what you need?

from rmq.

KamilLelonek avatar KamilLelonek commented on June 28, 2024

Hi, thanks for your response.

My case is as follows:

I have a container view, which contains a couple of views. These views are swipeable so at one time only one is visible. I have also tab bar which allows me to change view on tab click. I'd like to have these views separate from each others so that each of them implements its own stylesheet. I want to just append in my controller a subview as a class of this particular custom view without knowing about its inner structure and styles.

Another example:

I have a validable input (UITextField), e.g. email or phone number. This input should responds to changes and style itself different depending on provided input (change color, font, border). I want to append just ValidableEmailTextField and don't bother about its inner styles.

The last one to be clear enough:

In my controller I allow user to either input friend's email or choose it from contacts list. I want to build that interface by appending just two views: ValidableEmailTextField and FriendsListTableView. My controller's stylesheet should only place list container under input and nothing more. Both text field and table view should come with their own styles and my controller shouldn't know about them at all.

TL;DR
I need to have reusable components extending UIView with own styles and include them without knowing about their stylesheets.

from rmq.

squidpunch avatar squidpunch commented on June 28, 2024

For what it is worth. The way I have been doing this on a project of mine is creating a structure like this:

app/controllers/example_controller.rb

  def viewDidLoad
    super
    rmq.stylesheet = ExampleStylesheet
  end

app/stylesheets/controller_stylesheet.rb

class ExampleControllerStylesheet < ApplicationStylesheet
  include SharableItemStylesheet

app/stylesheets/sharable_item_stylesheet.rb

module SharableItemStylesheet
  # shared view items
end

this allows for me to create shareable objects with their own defined styles and enclosed in a stylesheet for the control. I think thats what you were asking for. The drawback is you have to include the stylesheets into the controller that is using them - etc.

would be interesting in reading a different option if one exists.

from rmq.

KamilLelonek avatar KamilLelonek commented on June 28, 2024

I see. I found this solution in docs too. It seems this is the only way to do that.

from rmq.

GantMan avatar GantMan commented on June 28, 2024

As for the validatable text fields that should change styles, we've got EXACTLY that brewing for the 0.7 release. If you pull down the RMQ app, you'll see a nice example (super awesome thanks to @squidpunch for the progress he's made). Check out the code: example image attached here:

image

I know if the style is set, and you could call "reapply_styles" this should work nicely. Maybe your subviews can have their style already set (not sure on the exact situation without code). As for now it only remembers the last style. But I know @twerth is looking at fixing styles to maintain history.

from rmq.

twerth avatar twerth commented on June 28, 2024

FYI, rmq's generators will create these things for you:

rmq create view example_view
rmq create table_view_controller example_table
rmq create collection_view_controller example_collection

from rmq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.