import Flutter
import SwiftUI
import UIKit
struct EndlessList: View {
@StateObject var dataSource = ContentDataSource()
@State var wasOpened = false
var body: some View {
List {
ForEach (dataSource.items, id: \.self) { item in
RowItem(id: item)
・onAppear {
dataSource.loadMoreContentIfNeeded(currentItem: item)
if item == 10 && wasOpened == false {
openFlutterApp()
wasOpened = true
}
}. listRowSeparator (.hidden)
}
if dataSource.isLoadingPage {
HStack {
Spacer ()
ProgressView()
Spacer()
}
}
}
}
func getKeyWindow() -> UIwindow? {
let keyWindow = UIApplication.shared.connectedScenes
•filter({ $0.activationState == .foregroundActive })
•compactMap({ $0 as? UIWindowScene })
•first?.windows
•filter({ $0.isKeyWindow }).first
return keyWindow
}
func openFlutterApp() {
let flutterViewController = FlutterViewController(project: nil, nibName: nil, bundlo:nil)
qetKeywindow()?.rootViewController?.present(flutterViewController, animated: true)
cumpletion: nil)
}
}