Giter Site home page Giter Site logo

Comments (9)

shaps80 avatar shaps80 commented on June 3, 2024

Perhaps I forgot to 'finish' implementing this correctly. Thanks!

from composed.

JosephDuffy avatar JosephDuffy commented on June 3, 2024

Perhaps I forgot to 'finish' implementing this correctly. Thanks!

This could be quite useful, maybe with a method of extending it to support other states (e.g. errors). Somehow passing this up from the Sections would be pretty amazing!

from composed.

shaps80 avatar shaps80 commented on June 3, 2024

So I agree in having some kind of 'state' so you could support other types of backgrounds, etc...

As for passing up from the section's, that's actually very similar to how the early DataSource's worked if you remember. But because its 'global' we decided it 'felt odd' to do it that way.

If multiple sections have a different opinion on what it should be, how do you resolve that? If you remember our solution back then, was to have a special type called GlobalDataSource which could only be used as a top-level parent. Ensuring it could make those calls decisively.

Anyway, just reflecting on the old days ahahaha!

from composed.

JosephDuffy avatar JosephDuffy commented on June 3, 2024

As for passing up from the section's, that's actually very similar to how the early DataSource's worked if you remember. But because its 'global' we decided it 'felt odd' to do it that way.

If multiple sections have a different opinion on what it should be, how do you resolve that? If you remember our solution back then, was to have a special type called GlobalDataSource which could only be used as a top-level parent. Ensuring it could make those calls decisively.

I think it would have to be something along the lines of "the first section that provides a background" but there's a similar issue with the FlatSection: which section's header should be used? Maybe this specific example can be worked around by adding extra supplementary views between cells (if that's possible?), but a more library-wide solution to this would also be nice.

Currently FlatSection ignores the headers and footers of its children since there's no obviously good way to handle this using our existing infrastructure.

Perhaps we can open a discussion for this once my time on this project isn't as focussed on performance and correctness.

from composed.

shaps80 avatar shaps80 commented on June 3, 2024

Yeah I tend to agree. I'm not sure this is truly 'solvable' btw. If you look at Compositional layouts for example. You can add multiple headers to a single section (they stack) but again there's no meaningful way to associate nested section headers such that they relate to the original content appropriately. Also, the layout would determine how this should be represented, something Composed should never be responsible for.

Thinking about it like that, perhaps the conversation would be how we expose an API that allows you to fetch all headers for a given section and/or its children, so you can make smart choices in your layout?

from composed.

JosephDuffy avatar JosephDuffy commented on June 3, 2024

Thinking about it like that, perhaps the conversation would be how we expose an API that allows you to fetch all headers for a given section and/or its children, so you can make smart choices in your layout?

Updating header/footers to be an array could be a good option. How does a collection view reference multiple headers for example? I thought they were always at index 0 of the section, can they be at other indexes?

from composed.

shaps80 avatar shaps80 commented on June 3, 2024

TLDR

Headers and footers (as a concept) are specific to the layout. They are not 'free' in a custom layout either.

Longer version:

A layout adds attributes for supplementary view types. The concept of a header/footer is more of an API consideration and Visual representation. So Flow Layout for example, exposes dedicated elementKind values for headers and footers for convenience. The collectionView then uses those pre-defined types in those specific layouts, to call the appropriate API instead of the usual supplementaryViewForElementOfKind.

If you checkout the original FlowLayout I made in the Composed org, you can see how I used the same approach to make that API work.

Since compositional layouts are declarative, they allow you to define a stacking order for multiple headers/footers. Internally, it'll just use separate indexes for each I assume, although haven't tested this.

This is kind of why I never wanted to handle this directly (at leasts initially) because each layout is different. So I built-in the most common case (single section, single header, single footer) and then exposed a fallback on the CoordinatorDelegate for those special cases, so a consumer could handle those there (although perhaps not ideal)

from composed.

JosephDuffy avatar JosephDuffy commented on June 3, 2024

I hadn't thought about multiple headers/footers being usable before but I see what you mean now.

Once you get to the collection view level there are functions purely based on "give me the supplementary view of kind X at index Y". Maybe we can do something similar? Allow sections to provide an array of supplementary views independent of layout and then it's up to the consumer how/if any of these get displayed.

This would provide a solution for the flat sections:

  • Section A
    • A:0
    • A:1
  • Section B

If section b has a header it can return a supplementary view for index 0 but when flattened it would just be at index 2. Flow layouts would probably just ignore this but another layout could be used to then display the header. I don't see this being a likely scenario (since flattening sections is mainly used for sticky headers) but it's nice to not have to include a bunch of caveats with it.

Hopefully this keeps Composed focussed on the composition of the data while not preventing any kind of layout.

from composed.

shaps80 avatar shaps80 commented on June 3, 2024

Yeah I guess that makes sense. The concept of headers and footers is fairly presentational in general if you think about it. Yes, grouping of data isn't unusual, but that doesn't naturally imply a 'view' for repenting a header, even less so a footer.

That being said, I definitely think it has a large enough use-case to warrant consideration.

from composed.

Related Issues (10)

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.