GithubHelp home page GithubHelp logo

Comments (5)

paololeonardi avatar paololeonardi commented on June 18, 2024

Thanks!

Sorry, I'm not sure I understood your question.
Are you talking about the elements of the grid? Do you have an example of what you are trying to achieve?

from waterfallgrid.

alelordelo avatar alelordelo commented on June 18, 2024

Hi Paolo. Sorry, my question was not so clear! : )

I mean to use some Text or Rectangle to prototype a grid without data, when you are in early stage of designing the UI and don't have data yet.

Example bellow with a List

import SwiftUI

struct ListView: View {
    var body: some View {
        
        List {
            Rectangle()
            Text("Hello, World!")

        }
    }
}

struct ListView_Previews: PreviewProvider {
    static var previews: some View {
        ListView()
    }
}


`

Screenshot 2019-12-02 at 11 14 42

from waterfallgrid.

paololeonardi avatar paololeonardi commented on June 18, 2024

Oh, I see! Currently is not possible.
But it's a feature that I would definitely like to include.

The Grid initializer needs to be updated in a way that can accept @ViewBuilder as a parameter.
https://developer.apple.com/documentation/swiftui/viewbuilder

from waterfallgrid.

alelordelo avatar alelordelo commented on June 18, 2024

thanks Paolo! I managed to make it work, and now I am trying to make a button that Swtches between List and your Grid.

I posted a question on Stack Overflow. Do you know how to do it?

https://stackoverflow.com/questions/59145490/swiftui-switch-between-list-and-grid-collection-view

from waterfallgrid.

paololeonardi avatar paololeonardi commented on June 18, 2024

I believe they already pointed you in the right direction.
The problem with your code is the return type different from the expected some View.

One solution is to move the if-else statement inside a "container" like Group, the opaque View generated won't change no matter the state of the boolean.

From there you can call .navigationBarTitle, .navigationBarItems etc. without compile errors.

NavigationView {
    Group {
        if showgrid == true {
            WaterfallGrid(...)
        } else {
            List(...)
        }
    }
    .navigationBarTitle(...)
    .navigationBarItems(...)
}

from waterfallgrid.

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.