Post

Replies

Boosts

Views

Activity

Reply to Get the current screen brightness programatically.
Ah.Thanks, but I know about this. This brightness setting does not directly tell us what the screen brightness is... The Settings > Display & Brightness page has the Brightness control, but the brightness is also controlled by... Appearance: Light/Dark (can have different brightness settings) Automatic (overrides Brightness depending on ambient light meter) Options (switches between light & dark mode) The colour and maybe the brightness too is affected by... Brightness: TrueTone on/off Night Shift Some of these settings cannot be reached from the app software. I am pretty sure the Automatic and TrueTone states are unreachable from the application software. The display hardware must know how bright it should actually make the display. That is the value I want to get to.
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’22
Reply to Get the current screen brightness programatically.
I have measured the screen brightness for different UIScreen.main.brightness settings with as many of the other Display & Brightness settings disabled. With Brightness = 1.0, my iPhone 12 mini display white is 250 nits. For Brightness down to about 0.5, the brightness fits 250*pow(UIScreen.main.brightness, 2.2) reasonably well. The 2.2 gamma is approximately the sRGB toe curve. Below that, the brightness is higher than this formula. I cannot fit this using any offset and gamma in the sRGB formula. This is probably a better thing for the user, as otherwise the bottom en of the Brightness control would be very dark, and they might not be able to see to turn it up again. The 250 nits value is a nice round number. Do all devices of the same model fit the same number? Is there some way to get this value for recent models? Is there a formula for the brightness function? Is it the same for all recent models? The 2.2 gamma function seems to work over the brightness range I expect people to work with. If Brightness is set to 0.75, for example, I can come up with a reasonable figure for the RGB=1 white brightness. But can we improve on that?
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’22
Reply to Can 'long press' replace 'hover' when there is no mouse?
I can do this... MyView .onLongPressGesture { myShowDialogFlag = true } .confirmationDialog( MyHelpString, isPresented: $myShowDialogFlag ) I would like... MyView .helpDialog( MyHelpString ) Press and hold. Any view with .helpDialog() would trap the LongPushGesture, and stick up the dialog. The dialog would be dismissed without needing a boolean flag in the View itself. If there is no View with a .helpDialog() there should be a bottom-level message saying something to the effect... "This is how you look for help, but there is no help where you are pointing". It works fine in my head. It is very like the .help() tooltips for buttons. I have had an iPhone for less than a month, and I have been writing Swift for less than that, so I am no expert. I feel this should be possible, but I can't see how to do it. Any ideas?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’22
Reply to SwiftUI Link to open Bundle files in browser
Done using WKWebView. A bit longer but it works. If you have links, you will have to support goBack() as it is not provided by default, and you get stuck in the link. struct WebView: UIViewRepresentable {     typealias UIViewType = WKWebView     var webView: WKWebView       init() {         webView = WKWebView(frame: .zero)         webView.load(URLRequest(url: Bundle.main.url(forResource: "ByEye", withExtension: "pdf")!))     }     func makeUIView(context: Context) -> WKWebView { webView }     func updateUIView(_ uiView: WKWebView, context: Context) { } } struct ManualView: View {     var webView = WebView()     var body: some View {         webView     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’22
Reply to Saving WKWebView view state with interactionState.
I have a partial fix for this. I found the ManualView was being recreated from scratch whenever the page was opened. I have re-arranged the code so the current ManualView is reselected by the TabView, with the scroll in the same place. I would like to see how interactionState works, but I don't need it now. There is one odd, special case. If you follow a link in ManualView, and then swipe to go back, you still go back to page one, and there is a three second pause on my iPhone.
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’23