मी एक साधा होम व्ह्यू लिहिला आहे जो माझ्या सर्व प्लेलिस्ट प्रदर्शित करण्यासाठी LazyVGrid वापरतो. SwiftData च्या @Query वापरून प्लेलिस्टची चौकशी केली आहे, पण UI का गोठते हे मला माहीत नाही. डेटाबेसमध्ये फक्त एकच प्लेलिस्ट आहे, त्यामुळे जास्त डेटामुळे हे होऊ शकत नाही.
movierulz ui, ui, material ui, ui ux designer, ui design, ui ux design, ui ux, one ui 6, nse: gmrp&ui, gmrp&ui share price
मी क्वेरी योग्यरित्या वापरत आहे का?
माझ्या घराचे दृश्य खालीलप्रमाणे आहे:
import SwiftUI
import SwiftData
enum stateMode {
case deleteMode
case updateMode
case normalMode
}
struct Home: View {
@State private var mode: stateMode = .normalMode
var columns: [GridItem] {
return [
GridItem(.flexible(), spacing: 10, alignment: .center),
GridItem(.flexible(), spacing: 10, alignment: .center),
GridItem(.flexible(), spacing: 10, alignment: .center)
]
}
@Query var playList : [PlayListModel] = []
var body: some View {
NavigationStack {
ScrollView {
LazyVGrid(columns: columns, spacing: 20) {
ForEach(playList) { playlist in
Button {
} label: {
PlaylistItemView(/*playlist: playlist,*/ mode: mode)
}
}
}
}
.toolbar {
ToolbarItemGroup {
Menu {
Button(action: {
withAnimation {
mode = .deleteMode
}
}) {
Label("Delete Mode", systemImage: "trash.circle.fill")
}
Button(action: {
withAnimation {
mode = .updateMode
}
}) {
Label("Update Mode", systemImage: "arrow.clockwise.circle.fill")
}
} label: {
Image(systemName: "ellipsis.circle")
}
}
}
}
}
}
struct PlaylistItemView: View {
let mode: stateMode
var body: some View {
VStack {
if mode == .normalMode {
Image(systemName: "tv")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 50, height: 50)
.padding()
} else if mode == .deleteMode {
Image(systemName: "trash.circle.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 50, height: 50)
.padding()
} else {
Image(systemName: "arrow.clockwise.circle.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 50, height: 50)
.padding()
}
Text("TEST")
.foregroundColor(.white)
}
.background(Color.black.opacity(0.2))
.cornerRadius(10)
}
}
// the data mode:
import Foundation
import SwiftData
@Model
final class PlayListModel {
var id = UUID()
var timestamp: Date
var playlistName: String
var playlistUrl: String
var lastUpdate: Date
@Relationship(deleteRule: .cascade, inverse: \PlaylistGroup.playlistModel)
var groups: [PlaylistGroup]
init(timestamp: Date, playlistName: String, playlistUrl: String, lastUpdate: Date) {
self.timestamp = timestamp
self.playlistName = playlistName
self.playlistUrl = playlistUrl
self.lastUpdate = lastUpdate
self.groups = []
}
}
@Model
class PlaylistGroup: Hashable, Identifiable {
var id = UUID()
var groupName: String
var playlistModel: PlayListModel
@Relationship(deleteRule: .cascade, inverse: \PlaylistItem.group)
var playlistItems: [PlaylistItem]
init(id: UUID = UUID(), groupName: String, playlistModel: PlayListModel) {
self.id = id
self.groupName = groupName
self.playlistModel = playlistModel
self.playlistItems = []
}
// Required for Hashable conformance
static func == (lhs: PlaylistGroup, rhs: PlaylistGroup) -> Bool {
lhs.id == rhs.id
}
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}
@Model
class PlaylistItem: Hashable, Identifiable {
var id = UUID()
var duration: Int?
var tvgId: String?
var tvgName: String?
var tvgCountry: String?
var tvgLanguage: String?
var tvgLogo: String?
var tvgChno: String?
var tvgShift: String?
var groupTitle: String
var seasonNumber: Int?
var episodeNumber: Int?
var kind: String?
var url: URL?
var lastPlay: Date
var group: PlaylistGroup?
init(id: UUID = UUID(), duration: Int? = nil, tvgId: String? = nil, tvgName: String? = nil, tvgCountry: String? = nil, tvgLanguage: String? = nil, tvgLogo: String? = nil, tvgChno: String? = nil, tvgShift: String? = nil, groupTitle: String, seasonNumber: Int? = nil, episodeNumber: Int? = nil, kind: String? = nil, url: URL? = nil, lastPlay: Date) {
self.id = id
self.duration = duration
self.tvgId = tvgId
self.tvgName = tvgName
self.tvgCountry = tvgCountry
self.tvgLanguage = tvgLanguage
self.tvgLogo = tvgLogo
self.tvgChno = tvgChno
self.tvgShift = tvgShift
self.groupTitle = groupTitle
self.seasonNumber = seasonNumber
self.episodeNumber = episodeNumber
self.kind = kind
self.url = url
self.lastPlay = lastPlay
}
// Required for Hashable conformance
static func == (lhs: PlaylistItem, rhs: PlaylistItem) -> Bool {
lhs.id == rhs.id
}
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}
you may be interested in this blog here:-
Class-UKG-English-Question-Paper PPT
Understanding SAP S/4HANA Overview Key Features and Benefits