Giter Club home page Giter Club logo

Comments (5)

ay42 avatar ay42 commented on August 26, 2024

@jberlana Hi,
Feels like I can be way more productive with a single repository. The idea is to have multiple packages inside a single repo.

Can you post a code snippet that produces different styles?

from swiftui-grid.

jberlana avatar jberlana commented on August 26, 2024

Hello @ay42, first of all thanks for your work.

One repository is easy to mantain but also less modular, if I only need a grid I do not see the necessity to download and compile all other packages. Maybe I am doing something wrong.

About my issue.

I have 2 screens.

Screen 1: with 2 columns grid and 100px height. When an item is tapped shows Screen 2.

Screen 2: opened after user taps on an item on Screen 1. Grid with 3 columns and 200px height.

Everything works well until i go back from Screen 2 to Screen 1, when I do that the layout of Screen 1 have changed to the styles of Screen 2. It seems there is some kind of styles caching.

Code is very straight forward, just like the one on the examples. But une Grid on each View.

from swiftui-grid.

jberlana avatar jberlana commented on August 26, 2024

This is the code on the first view, the grid which style gets broken.

  var body: some View {
    NavigationView {
      listItemsGrid()
        .navigationBarTitle(Text("Title"))
        .navigationBarItems(trailing: customBarItems)
    }
    .sheet(isPresented: $showingModal) {
      ListCreateForm(lists: self.$dataSource.lists, isPresented: self.$showingModal)
    }
  }
  
  func listItemsGrid() -> some View {
    return Grid(self.dataSource.lists) { listVM in
      self.listItemNavigationLink(listVM)
    }
    .gridStyle( ModularGridStyle(
      columns: 2,
      rows: .fixed(105),
      spacing: 16,
      padding: EdgeInsets(top: 16, leading: 16, bottom: 0, trailing: 16)) )
  }
  
  func listItemNavigationLink(_ listVM: ListViewModel) -> some View {
    NavigationLink(destination: ItemsListGridView(listVM: listVM) ) {
      ListItemView(listVM: listVM)
    }
    .buttonStyle(PlainButtonStyle())
  }

from swiftui-grid.

ay42 avatar ay42 commented on August 26, 2024

@jberlana .gridStyle overrides every style inside the scope. You can even set it in the app delegate and it will apply to every grid. In your case you just need to specify another style closer to your seconds grid like so.

  func listItemNavigationLink(_ listVM: ListViewModel) -> some View {
    NavigationLink(destination: ItemsListGridView(listVM: listVM) ) {
      ListItemView(listVM: listVM)
    }
    .buttonStyle(PlainButtonStyle())
    .gridStyle(...)
  }

Let me know if this helps.

from swiftui-grid.

ay42 avatar ay42 commented on August 26, 2024

btw @jberlana with the latest release it's possible to import separate products.

import Grid

from swiftui-grid.

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.