WOW no help? can someone please tell us what's going on?
Post
Replies
Boosts
Views
Activity
@knshi
iPhone:
[1] [2]
[3] [4]
[5] [6]
[7] [8]
iPad Pro
[1] [2][3] [4]
[5] [6] [7] [8]
iPad Mini
[1] [2][3]
[4] [5] [6]
[7] [8]
@knshi Load left to right and then downward I dont know how else to describe that.... this is extremely frustrating no documentation helps or addresses this basic idea! UItableviews made it so easy to do this simple view
trying to implement it like this:
import SwiftUI
import Combine
struct SwiftUIView: View {
@State var showSheetView = false
var body: some View {
NavigationView {
Text("Content")
.navigationBarTitle("SwiftUI Tutorials")
.navigationBarItems(trailing:
Button(action: {
self.showSheetView.toggle()
}) {
Image(systemName: "bell.circle.fill")
.font(Font.system(.title))
}
)
}.sheet(isPresented: $showSheetView) {
SheetView(showSheetView: self.$showSheetView)
}
}
}
struct SheetView: View {
@Binding var showSheetView: Bool
@ObservedObject private(set) var viewModel: ViewModel
@State private var isRefreshing = false
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
})
.navigationBarTitle(viewModel.navigationBarTitle)
}
.onAppear(perform: viewModel.fetchVideos)
.sheet(isPresented: $showSheetView) {
SheetView(showSheetView: self.$showSheetView)
}
}
}
leads to: Cannot find type 'ViewModel' in scope & The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions; on line 35 and 38.
This
import SwiftUI
import Combine
struct ContentView: View {
@State private var isPresented = false
var body: some View {
Button("Show Modal with full screen") {
self.isPresented.toggle()
}
.fullScreenCover(isPresented: $isPresented, content: VideoList.init)
}
}
struct VideoList: View {
@Environment(\.presentationMode) var presentationMode
@ObservedObject private(set) var viewModel: ViewModel
@State private var isRefreshing = false
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
})
.navigationBarTitle(viewModel.navigationBarTitle)
}
.onAppear(perform: viewModel.fetchVideos)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.red)
.edgesIgnoringSafeArea(.all)
.onTapGesture {
presentationMode.wrappedValue.dismiss()
}
}
}
#if DEBUG
struct VideoList_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
VideoList(viewModel: .init())
}
}
}
#endif
creates this error on line 19: Cannot convert value of type '(Environment<Binding<PresentationMode>>, VideoList.ViewModel) -> VideoList' to expected argument type '() -> VideoList'
Does anyone have a clue? I've spent the last 3 days trying to solve this code none of the WWDC video even come closed to explaining what's going on
@KMT this is false... one can no longer log in even on non beta devices so this information is incorrect and unrelated
Also this may help https://wolvideos.web.app/landmarkData.json
The following documentation is broken https://developer.apple.com/documentation/coredata/loading_and_displaying_a_large_data_feed
same problem here! you would think Apple would want to fix errors like this
Posting the solution I tinkered around with until it actually worked... feel free to add extra refinements for future developers
Your content view
import AVKit
struct ContentView: View {
@State private var wolData = [Main]()
var body: some View {
NavigationView{List(wolData, id: \.id) { item in
NavigationLink(destination: CountryDetail(country: item)) {
HStack() {
Text(item.name)
.font(.headline)
Text(item.date)
.font(.footnote)
if #available(iOS 15.0, *) {
AsyncImage(url: URL(string: item.thumbnail))
{ image in
image
.resizable()
.scaledToFill()
} placeholder: {
Color.purple.opacity(0.1)
}
.frame(width: 20, height: 20)
} else {
// Fallback on earlier versions
}
}
}
}.onAppear(perform: loadData)}
}
}
extension ContentView
{
func loadData() {
guard let url = URL(string: "https://wolvideos.firebaseapp.com/Simple.json") else {
return
}
let request = URLRequest(url: url)
URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
if let response_obj = try? JSONDecoder().decode([Main].self, from: data) {
DispatchQueue.main.async {
self.wolData = response_obj
}
}
}
}.resume()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
your struct file
struct Main: Decodable {
var id: Int
var name: String
var interactive: String
var thumbnail: String
var date: String
var videolink: String
var sharelink: String
}
your detail file
```import SwiftUI
import AVKit
struct CountryDetail: View {
var country: Main
var body: some View {
VStack(alignment: .leading, spacing: 10) {
if #available(iOS 14.0, *) {
VideoPlayer(player: AVPlayer(url: URL(string: "https://bit.ly/swswift")!))
} else {
// Fallback on earlier versions
}
}
}
}
Looking for the answer as well... no one on either Stackoverflow or DevFourms seems to care to help
Adding .listRowBackground(/*@START_MENU_TOKEN@*//*@PLACEHOLDER=Background View@*/Color.black/*@END_MENU_TOKEN@*/) does not change color to black
.tint(.white)
.onAppear {
UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation") // Forcing the rotation to portrait
AppDelegate.orientationLock = .portrait // And making sure it stays that way
}.onDisappear {
AppDelegate.orientationLock = .all // Unlocking the rotation when leaving the view
}
.onAppear {
let appearance = UITabBarAppearance()
appearance.backgroundEffect = UIBlurEffect(style: .systemUltraThinMaterial)
appearance.backgroundColor = UIColor(Color.black.opacity(1.0))
// Use this appearance when scrolling behind the TabView:
UITabBar.appearance().standardAppearance = appearance
// Use this appearance when scrolled all the way up:
UITabBar.appearance().scrollEdgeAppearance = appearance
}
}
}
Adding this will at least get you black
.preferredColorScheme(/@START_MENU_TOKEN@/.dark/@END_MENU_TOKEN@/)