Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple example does not do column/row layout under WidgetKit #17

Closed
t9mike opened this issue Dec 14, 2020 · 1 comment
Closed

Simple example does not do column/row layout under WidgetKit #17

t9mike opened this issue Dec 14, 2020 · 1 comment
Labels
bug Something isn't working confirmed

Comments

@t9mike
Copy link

t9mike commented Dec 14, 2020

This one is pretty odd. This simple WidgetKit example:

import SwiftUI
import ExyteGrid
import WidgetKit

struct GridIssue2View: View {
    var body: some View {
        Grid(tracks: [
            .fit, // label
            .fit, // value
        ], spacing: 3)
        {
            Text("A")
            Text("B")
            Text("C")
            Text("D")
        }
    }
}

struct GridIssue2View_Previews: PreviewProvider {
    static var previews: some View
    {
        GridIssue2View()
            .previewContext(WidgetPreviewContext(family: .systemSmall))
    }
}

Does not do column/row layout in preview mode:

image

But when placed in view for real widget, it renders OK in preview. Also I could place within ZStack to fix:

struct GridIssue2View: View {
    var body: some View {
        ZStack
        {
            Grid(tracks: [
                .fit, // label
                .fit, // value
            ], spacing: 3)
            {
                Text("A")
                Text("B")
                Text("C")
                Text("D")
            }
        }
    }
}

image

Similar preview example under iOS is fine. Perhaps related to ScrollView change?

iOS:

import SwiftUI
import ExyteGrid

struct GridIssue2View: View {
    var body: some View {
        Grid(tracks: [
            .fit, // label
            .fit, // value
        ], spacing: 3)
        {
            Text("A")
            Text("B")
            Text("C")
            Text("D")
        }
    }
}

struct GridIssue2View_Previews: PreviewProvider {
    static var previews: some View {
        GridIssue2View()
    }
}
@denis-obukhov
Copy link
Collaborator

To support a preview for Grid I had to apply some kind of hack (ForEach+GridViewsContaining.swift:46-68 and GridGroup.swift:20-30).
Looks like it doesn't work for widgets.

@denis-obukhov denis-obukhov added bug Something isn't working confirmed labels Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed
Projects
None yet
Development

No branches or pull requests

2 participants