Comments (6)
Ciao @CPiersigilli, non vedo errori nel modo in cui stai usando Section
.
Qual è l'errore di compilazione con Xcode?
Comunque considera che così stai dividendo la finestra in N sezioni e creando N diverse griglie.
Se il tuo scopo è avere un'unica griglia divisa in sezioni non è attualmente possibile con WaterfallGrid
.
Hi, I don't see errors in the way you are using Section
.
What's the Xcode compile error?
This creates N sections and N grids.
If your goal is to have a single grid with multiple sections is not currently possible with WaterfallGrid
.
import SwiftUI
import WaterfallGrid
struct ContentView: View {
let images: [String] = Generator.Images.random()
var body: some View {
ForEach(0..<3, id: \.self) { section in
Section {
Text("Section N. \(section)")
WaterfallGrid((0..<self.images.count), id: \.self) { index in
Image(self.images[index])
.resizable()
.aspectRatio(contentMode: .fit)
}.gridStyle(columns: 4)
}
}
}
}
from waterfallgrid.
Lo screenshot che hai postato è quello che vorrei, ma con il codice che allego sotto, molto simile al tuo:
import SwiftUI
import Photos
import WaterfallGrid
struct ContentView: View {
@State private var thumbnails = [Thumbnail]()
@State private var numColumsStr = "5"
var body: some View {
NavigationView {
ForEach(0..<3, id: \.self) { section in
Section {
Text("Section N. \(section)")
WaterfallGrid(0..<self.thumbnails.count, id: \.self) { i in
ThumbnailView(thumb: self.thumbnails[i])
}
.gridStyle(columns: Int(self.numColumsStr) ?? 5)
}
}
}
.navigationViewStyle(StackNavigationViewStyle())
.onAppear {
let fetchOptions = PHFetchOptions()
fetchOptions.fetchLimit = 40
fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
let fetchAssets = PHAsset.fetchAssets(with: fetchOptions)
for index in 0..<fetchAssets.count {
let asset = fetchAssets.object(at: index)
self.thumbnails.append(Thumbnail(asset: asset))
}
}
}
}
ottengo questo:
L'immagine che si ottiene da ThumbnailView(thumb: self.thumbnails[i])
è ottenuta dalla PhotoLibrary
. Se elimino la possibilità di visualizzare le sezioni:
import SwiftUI
import Photos
import WaterfallGrid
struct ContentView: View {
@State private var thumbnails = [Thumbnail]()
@State private var numColumsStr = "5"
var body: some View {
NavigationView {
// ForEach(0..<3, id: \.self) { section in
// Section {
// Text("Section N. \(section)")
WaterfallGrid(0..<self.thumbnails.count, id: \.self) { i in
ThumbnailView(thumb: self.thumbnails[i])
}
.gridStyle(columns: Int(self.numColumsStr) ?? 5)
// }
// }
}
.navigationViewStyle(StackNavigationViewStyle())
.onAppear {
let fetchOptions = PHFetchOptions()
fetchOptions.fetchLimit = 40
fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
let fetchAssets = PHAsset.fetchAssets(with: fetchOptions)
for index in 0..<fetchAssets.count {
let asset = fetchAssets.object(at: index)
self.thumbnails.append(Thumbnail(asset: asset))
}
}
}
}
le immagini vengono visualizzate correttamente, come puoi vedere nello screenshot sotto riportato:
from waterfallgrid.
Se possono esserti utili, ti invio i codici relativi a ThumbnailView(thumb: self.thumbnails[i])
ed alla struct Thumbnail
.
Per ultimare una app, che ho scritto per il mio piccolo studio di ingegneria, sono alla ricerca di un codice che mi permetta di visualizzare le foto come indicato negli screenshot sopra, non potendo utilizzare, in SwiftUI, CollectionView
.
from waterfallgrid.
Uno strano comportamento con NavigationView
in macOS e Catalyst, secondo me.
Rimuovi la navigation view se non ti serve o prova a racchiudere tutte le view dentro un contenitore (VStack, Group):
I think it may be something to do with NavigationView
in macOS and Catalyst.
If not needed just remove it or try to embed everything inside a view container (VStack, Group):
NavigationView {
VStack {
...
}
}
from waterfallgrid.
Il tuo suggerimento ha migliorato un po' la situazione, ma ancora il risultato non è soddisfacente, infatti le immagini si riescono a vedere tutte esclusivamente scrollando all'interno della sezione, pur avendo inserito nel codice il modificatore .frame(height: 480)
, come puoi vedere nello screenshot sotto:
Il codice che ho utilizzato è:
NavigationView {
VStack() {
ForEach(0..<3, id: \.self) { section in
Section {
Text("Section N. \(section)")
WaterfallGrid(0..<self.thumbnails.count, id: \.self) { i in
ThumbnailView(thumb: self.thumbnails[i])
.onTapGesture {
self.thumbnails[i].isSelected.toggle()
}
}
.frame(height: 480)
.gridStyle(columns: Int(self.numColumsStr) ?? 5)
}
}
.navigationBarTitle("Ultime 20 Immagini", displayMode: .inline)
.navigationBarItems(trailing:
TextField("5", text: $numColumsStr)
)
}
}
Inoltre, altra anomalia, è quella che le immagini si vedono soltanto dopo aver modificato il numero delle colonne da TextField("5", text: $numColumsStr)
.
Dal tuo README.md
ho letto che il tuo repository è stato scritto prendendo spunto da SwiftUI Grid
, che ho testato con migliori risultati, rispetto al tuo, ma con un errore persistente, che non consente l'aggiornamento della view. Che cosa ne pensi?
from waterfallgrid.
Ciao, scusa il ritardo nella risposta.
Nel primo post, ho provato ad anticiparti che sarebbe stato questo il comportamento:
Così stai chiedendo alla vista principale di dividersi in tanti spazi e all'interno di ognuno di questi stai aggiungendo N diverse griglie. Le singole griglie a questo punto hanno una piccola porzione dello schermo per visualizzare il loro contenuto e il resto accessibile tramite scroll.
Se il tuo scopo è avere un'unica griglia divisa in sezioni non è attualmente possibile con WaterfallGrid.
Hi, sorry for the delay.
Above I tried to explain that isn't currently possible to have sections in a single grid.
With your code, you are splitting the main view into N parts and creating N grids. A single grid has then a small portion of the screen to display its content.
If your goal is to have a single grid with multiple sections is not currently possible with WaterfallGrid.
from waterfallgrid.
Related Issues (20)
- Support for async images with placeholder?
- Getting Cannot convert value of type 'some View' to closure result type '_' HOT 3
- iOS 14 HOT 6
- Can I use in Rxswift?
- Grid missing inside scrollview HOT 2
- Can't see on Canvas, on in Preview Mode HOT 1
- Bound preference ElementPreferenceKey tried to update multiple times per frame HOT 3
- Waterfall Grid Sample App not displaying full content in CardsGrid when 1 or 2 assets in grid HOT 3
- Invalid frame dimension (negative or non-finite) HOT 2
- Use Kingfisher on the waterfall grid
- Cannot find 'WaterfallGrid' in scope
- Grid 1 HOT 1
- Nondeterministic layout bug HOT 5
- The size of the picture is not displayed properly in the waterfall flow HOT 2
- How to solve the lazy loading problem, very stuck HOT 1
- Problem with pagination / Load more
- Span over columns HOT 1
- If there are less than two images to be displayed, nothing will be displayed. HOT 3
- Item sizes are all the same in Column / Horizontal Layout
- unable to show all imgs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from waterfallgrid.