SwiftUI: Status bar color for specific view - swiftui

I have a specific view in my application where I need the status bar to be white (dark mode).
I've tried setting the .preferredColorScheme(.dark) but as the documentation mentions, that affects all the views in my window which is not what I'm looking for.
I've taken a look at this but it seems to be done using SceneDelgate which I am not making use of.
Is there any workaround to this?

For iOS 16, you can set .toolbarColorScheme for a specific View. Unfortunately, this is not supported on older iOS Versions. As a workaround that does not involve SceneDelegate, you could manipulate UIToolBar.appearance() directly with a new tint color. This has nothing to do with the preferred color scheme (e.g., light or dark mode), but could have the same effect.

Related

How to implement vertical scroll page on watchOS with SwiftUI

I want to implement a vertical scroll page like system workout app.
Now I can get a similar effect with this:
    TabView {
      page1
        .rotationEffect(.degrees(90))
      page2
        .rotationEffect(.degrees(90))
    }.tabViewStyle(.page(indexDisplayMode: .automatic))
    .rotationEffect(.degrees(-90))
But not good as system workout app does. It supports digital crown and dynamic show indicator and custom color.
So , how to implement that vertical scroll effect?
https://github.com/fredyshox/PageView
This repo works well except crown supports.

How Do I Change NavigationBar Color For WatchOS?

I am building watchOS app and I am trying to change navigationBar background color from black to transparent, but I am not able to find anything. I saw this question which was asked in 2015, according to which it is impossible to change navigationBar color in watchOS. I was wondering if now there is any API for that.
Thanks for any help.
This is about Color in the human-interface-guidelines from apple:
Make sure your app’s colors work well in both light and dark
appearance modes. With the exception of watchOS, which always uses a
pure black background, the platforms offer a dark alternative to the
default light appearance. Dark Mode uses a darker color palette for
all screens, views, menus, and controls, and can increase vibrancy — a
subtle effect that dynamically blends foreground and background colors
— to make foreground content stand out against darker backgrounds.
System colors automatically support both appearances; if you use a
custom color, you need to supply both light and dark variants. For
guidance, see Dark Mode.

how to change apache superset's chart's background color?

Per How to Change Apache Superset Template from the Superset User Interface? , I was able to change the CSS template for Superset dashboard. But the charts inside the dashboard are not affected. e.g. most of the charts have white colored background(e.g. Piechart) and some people dislike it. How to change the chart background color? I mean change it for all charts or for one chart.
Disclaimer: This should work, but is a bit hacky and could have long-term support implications:
I've been fiddling with a "dark mode" dashboard just to kick the tires on this. Here's a screenshot just for fun:
So... what did I do?
Click "Edit Dashboard" in the top right of your screenshot
When in edit mode, the top right menu has an option to "Edit CSS"
Use your browser's inspector to hack away! That said, here are a couple of key ingredients:
.dashboard-component{ background: whatever} - sets the main background of each viz card, but you'll still see many components still have white backgrounds within these wrappers.
.slice_container svg{
background-color: transparent !important;
} - this overrides the white background of the components I ran into (including Pie charts!).
If viz components use SVG you can get pretty clever with inspecting/overriding various bits. A couple of gotchas with the above:
If a viz component contains multiple SVG elements, this may have side effects.
If a viz uses canvas instead of svg you will run into more trouble
In the worst case scenario, you may need to check out the superset-ui-plugins repo and make tweaks. This dev process isn't super straightforward, but some of us are working to improve that.
Easiest solution for me is using dark reader extension.

Add drop shadow to ListView (Icon mode)?

If you look at the thumbnail images in Windows Explorer you'll notice that they have a drop shadow, is this effect associated with the ListView control or does Windows Explorer does some extra coding to accomplish this effect?
Edit:
So it turned out that Windows uses another control. So my question now is how can I add a drop shadow to the "normal" ListView.
For a standard list view, you may want to use a technique called custom draw (https://msdn.microsoft.com/en-us/library/windows/desktop/ff919569(v=vs.85).aspx).
Basically, you ask your list view not to draw its items, but instead send you some window messages for you to draw them yourself. This is a very flexible but also troublesome technique, because you need to handle many things (like whether an item is selected/disabled, font, color etc.)
The drop shadow you see in Windows Explorer is not publicly available for you to use. So you will have to custom-draw the items (NM_CUSTOMDRAW) by yourself.
Not sure if such effect is available in GDI/GDI+, but Direct2D does have one: https://learn.microsoft.com/en-us/windows/win32/direct2d/drop-shadow

How do I ensure an eyedropper tool returns a consistent value, despite differing display profiles?

I'm in the unenviable position of working with a huge established codebase for an application that needs to work on both Windows and OSX. A section that I'm currently working on contains some legacy code for an eyedropper/color picker tool. Unfortunately I don't have a lot of experience developing for the Mac, so I'm hoping someone can shed some light on my problem.
The eyedropper colors are slightly wrong in some cases, and I traced the problem to a difference between the expected CGColorSpaceRef which is set by a call to CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB ) and the actual color space set by the primary display profile. Setting the OS display profile to generic RGB removes the discrepancy, but I want the eyedropper to get a consistent color no matter what the display profile is.
Would retrieving the primary monitor display profile and using that instead of the generic RGB one ensure that the eyedropper tool gets a consistent value? I found the CGColorSpaceCreateWithPlatformColorSpace(...) function, but according to the documentation it has been deprecated since OSX 10.6. What would be the current way to handle this in Quartz?
I feel a little constricted on this, since I have neither the authority or expertise to make major changes such as adding dependencies on additional frameworks.
NSColor has this function:
-(void)getRed:(CGFloat *)red green:(CGFloat *)green blue:(CGFloat *)blue alpha:(CGFloat *)alpha
Which will return RGB components converted from device-dependent colorspaces.
Example taken from Radiant Color Picker
CGFloat red, green, blue, a;
NSColor *colorAsRGB = [_color colorUsingColorSpaceName:NSDeviceRGBColorSpace];
[colorAsRGB getRed:&red green:&green blue:&blue alpha:&a];
Relevant links:
NSColor
Working With Colorspaces