Skip to content
This repository has been archived by the owner on Dec 27, 2020. It is now read-only.

GRID: gridStyle changes when there are multiple grids on the app. #60

Closed
jberlana opened this issue Dec 15, 2019 · 5 comments
Closed

GRID: gridStyle changes when there are multiple grids on the app. #60

jberlana opened this issue Dec 15, 2019 · 5 comments
Assignees
Milestone

Comments

@jberlana
Copy link

Hello,

First of all thank you for this library.

I have 2 Grids in my app, the items on the first grid displays a second grid. This grids have different cell styles, when I go back from the second grid to the first one the style of the first one have changed, now it have the style of the second grid...

This behaviour does not exists on the previous version.

Why now on the same package there are things I am not using? Charts, Sliders and other stuff, make more sense have it separated in different packages.

Thanks for your reply.

@ay42 ay42 self-assigned this Dec 15, 2019
@ay42 ay42 added this to the Release 1.0.0 milestone Dec 15, 2019
@ay42
Copy link
Member

ay42 commented Dec 15, 2019

@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?

@ay42 ay42 mentioned this issue Dec 15, 2019
@jberlana
Copy link
Author

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.

@jberlana
Copy link
Author

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())
  }

@ay42
Copy link
Member

ay42 commented Dec 30, 2019

@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.

@ay42
Copy link
Member

ay42 commented Dec 30, 2019

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

import Grid

@ay42 ay42 closed this as completed Mar 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants