I would like to run this the same way as I do it's Swift counterpart. In the Swift version I'm loading the json into a parser that loads the list in id (highest to lowest) and displays the thumbnail image and title (provided by the json) and when clicked it shows the video of the attached ID.
I'm currently seeing nothing similar to the SwiftUI (list view in particular) setup, if you can provide any resources or examples to as such I would appreciate it.
Here is one of the SwiftUI files
import SwiftUI
import Combine
struct VideoList: View {
@Environment(\.presentationMode) private var presentationMode
@ObservedObject private(set) var viewModel: ViewModel
@State private var isRefreshing = false
var btnBack : some View { Button(action: {
self.presentationMode.wrappedValue.dismiss()
}) {
HStack {
Image("Home") // set image here
.aspectRatio(contentMode: .fit)
.foregroundColor(.white)
}
}
}
var body: some View {
NavigationView {
List(viewModel.videos.sorted { $0.id > $1.id}, id: \.id) { video in
NavigationLink(
destination: VideoDetails(viewModel: VideoDetails.ViewModel(video: video))) {
VideoRow(video: video)
}
}
.onPullToRefresh(isRefreshing: $isRefreshing, perform: {
self.viewModel.fetchVideos()
})
.onReceive(viewModel.$videos, perform: { _ in
self.isRefreshing = false
})
}
.onAppear(perform: viewModel.fetchVideos)
.navigationViewStyle(StackNavigationViewStyle())
.navigationBarBackButtonHidden(true)
.navigationBarItems(leading: btnBack)
}
}
Here is a clip from the json it is loading
{
"videos": [
{
"id": 97,
"name": "name",
"thumbnail": "https://videodelivery.net//thumbnails/thumbnail.jpg",
"description": "October 11th, 2020",
"video_link": "https://videodelivery.net//manifest/video.m3u8"
},
{
"id": 96,
"name": "name",
"thumbnail": "https://videodelivery.net//thumbnails/thumbnail.jpg",
"description": "October 11th, 2020",
"video_link": "https://videodelivery.net//manifest/video.m3u8"
},