SwiftUI Catalyst App - Testing and Fix

Опубликовано: 06 Октябрь 2024
на канале: Lawrence Tsang
11
0

Testing continue,

1. fix from Minimized State to Normal, UI not update.

ContentView Add
.onReceive(NotificationCenter.default.publisher( for: UIApplication.willEnterForegroundNotification ))
{ _ in
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500))
{
self.isInForeground = true
}
}
.onReceive(NotificationCenter.default.publisher( for: UIApplication.didEnterBackgroundNotification ))
{ _ in
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500))
{
self.isInForeground = false
}
}

_ add on top
// force refresh on restore from minimized state
if isInForeground
{
Color.init(0x111111,0.77)
.preference(key: RenderBoxSizeKey.self, value: g.size)
}


________________________________
UIImage leaks, on Catalyst ONLY


Change the Old Methods to what was recommended by WWDC 2016
DO NOT use UIGraphicsBeginImageContext()

Also, wrap methods inside AutoRelease Pool

_______________________________
Pasteboard leaks, minimized, not 100% fix.

Use Combine Manager for Pasteboard Operations.

_______________________________
SwiftUI 2.0 has many build in animations, demo.
Testing a spinning gyro wheel as progress ring.
Wheel idea comes from here:
https://swiftui-lab.com/swiftui-anima...
and
https://gist.github.com/swiftui-lab/e...




Resources:
MacOS 11.2.3
Xcode 12.4