iT邦幫忙

2023 iThome 鐵人賽

DAY 26
0
自我挑戰組

基礎學習Flutter系列 第 26

Day26-功能資料(記錄)

  • 分享至 

  • xImage
  •  
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)
 }
}

上一篇
Day25-學習[Building for iOS with Flutter](記錄)
下一篇
Day27-webView資料(記錄)
系列文
基礎學習Flutter30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言