I would like to have a dark background for the window's title bar of an Electron app. I've tried to force the usage of dark theme with:
app.on("ready", () => {
createWindow();
nativeTheme.themeSource = "dark";
});
Unfortunately, it doesn't change anything. The window's title bar remains light/grey.
How to get a dark window's title bar in Electron?
Alternatively, you can use titlebarInset instead by overlaying the traffic light buttons into your ElectronJS application. See more details about that here:
https://www.electronjs.org/docs/latest/api/browser-window#new-browserwindowoptions:%7E:text=hiddenInset,the%20window%20edge:~:text=hiddenInset,the%20window%20edge.
Related
I've implemented the pinned top app bar scroll container, and it works for changing the app bar color on scroll, however the status bar color isn't affected at all.
Here's what I have:
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
Scaffold(
Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
// just a wrapper for CenterAlignedTopAppBar
StandardTopAppBar("Home", scrollBehavior = scrollBehavior)
}
){ ... }
If it's relevant, in order to detect if the soft keyboard is present, I enabled:
WindowCompat.setDecorFitsSystemWindows(window, false)
And my status bar color in initially set in my Theme. It was set to primary color when I autogenerated the project in android studios, but I changed it to surface color to match the appbar standards:
if (!view.isInEditMode) {
SideEffect {
(view.context as Activity).window.statusBarColor = colorScheme.surface.toArgb()
//(view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb()
ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = !darkTheme // changed from just darkTheme
}
}
tl;dr; top app bar color changes on scroll, but status bar does not. What is the correct pattern to use here? I looked through some of the pinnedScrollBehavior code, and I don't see anything that would invoke status bar changes, so I'm wondering if I'm supposed to have the status bar be transparent and change the insets for the appbar? Or should I manually hook into the scroll logic and change the color myself? Any help is appreciated!
In Theme.kt, inside the YourAppTheme() function add.
WindowCompat.setDecorFitsSystemWindows(window, false)
Doing this will display contents below StatusBar and NavigationBar* (
Only on older versions of Jetpack Compose. In newer versions, PaddingValues are correctly set by default. ).
Now set the StatusBar and NavigationBar color to Color.Transparent.
// make sure to use the compose color package, not the default one
import androidx.compose.ui.graphics.Color
window.statusBarColor = Color.Transparent.toArgb()
window.navigationBarColor = Color.Transparent.toArgb()
You also need to make sure that the padding values for the direct child of Scaffold() are correctly set using the padding values passed in the callback from the Scaffold() composable.
Set the correct StatusBar and NavigationBar icon colors for the theme.
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightStatusBars = !darkTheme
WindowCompat.getInsetsController(window, window.decorView).isAppearanceLightNavigationBars = !darkTheme
If you're using ModalBottomSheetLayout or BottomSheetScaffold, you also need to set Insets inside your BottomSheet composable to prevent NavigationBar from overlapping app content using,
Modifier.windowInsetsPadding(WindowInsets.navigationBars)
Edit
In Material3, window.setDecorFitsSystemWindows() is only compatible > API Level 30.
Use WindowCompat.setDecorFitsSystemWindows(window, false) for backwards compatibility.
Slack on the Mac at least removed the title bar but still has the control buttons. How do I duplicate this effect? Is there an electron option I missing or did slack rollout there own control buttons?
You can do this with Electron by setting the titleBarStyle option.
To use it:
var winObj = new BrowserWindow({
titleBarStyle: 'hidden',
});
This will hide the title bar but still keep the traffic lights in the corner.
Here are different values for the titleBarStyle option:
default
Results in the standard gray opaque Mac title bar.
hidden (Used in the example).
Results in a hidden title bar and a full size content window, yet the title bar still has the standard window controls ("traffic lights") in the top left.
hiddenInset
Results in a hidden title bar with an alternative look where the traffic light buttons are slightly more inset from the window edge.
See the docs for the BrowserWindow options (search for titleBarStyle).
In a project created in Titanium Appcelerator/Alloy I created a simple window with a TabGroup button. That button opens a modal window, which contains a NavigationBar.
Without specifying anything in the TSS files, a gray tint is applied to both the TabGroup and the NavigationBar(s). I'd like to remove it and make everything translucent, as it would look natively.
Moreover, you can see that the NavigationBar of the modal window is translucent during the opening animation, and then it suddenly becomes gray after the navigation.
If you want nav buttons in header-bar area, then your only solution is to use these two properties:
1- Window's barColor property
2- Window's translucent property
Using first property, you can set any background color in navigation header area, and setting 2nd one to false - you can remove the transparency which will show the actual color you apply using 1st property.
Moreover, you can use Window's navTintColor to tweaks tint changes in navigation header
+
You can apply font & color using Window's titleAttributes property.
titleAttributes : {
color : 'white',
font : { fontFamily : 'some-family', fontSize : 18 },
},
Here's a sample app I have created which shows demo of manual Modal Window animation for further fully customisation: Sample App for manual Modal Animation
As shown on Apple's September 2012 keynote, the status bar tint color varies between apps in iOS 6. For instance, Safari and Maps use a black status bar whereas Mail adds a blue tint to it.
Is it possible to set that tint color, or at least force it to black?
You can do it from the plist like Comradsky mention or in xcode 4.5, they added an option for it in the project summary.
Update:
several people were confused by this answer. Just to clarify, you cannot set the status bar tint to any color you want. What is described above is only to change the status bar tint during launch and choose the iOS 6 default status bar color behavior (which picks the color of the bottom row of pixels from your navigation bar).
I've just found how to do it !
In your "Project Summary", in "Status Bar", set "Style" and "Tinting" to "Default.
Then, jump into you xib or storyboard and add a UINavigationBar just below the status bar.
Set the UINavigationBar "Style" to "Default" and select the "Tinting" of your choice.
Run! :-)
If, like me, you don't want any UINavigationBar visible in your Interface, all you want to do is putting the UINavigationBar behind all the Objects, or set the "Alpha" to zero.
You can do that in a tricky way..
In the Project Summary select Status Bar Style Black Transculent from the drop down menu.
In application: didFinishLaunchingWithOptions: enter the following line of code:
self.window.backgroundColor = [UIColor greenColor]; //example color
It works fine for me.
The tint color seems to be determined by the average color of the bottom pixel row of the app's header bar.
See here:
http://www.cultofmac.com/173928/how-ios-6s-cool-new-adaptive-status-bar-works/
It is very easy to do:
just put up an UINavigationBar in your .xib/storyboard, make sure the style is default.
then add a tint. no matter how many views, with different tinted UINavigationBar's, you have your status bar will change its color.
There is no way in iOS 5. You can just change your bar style.
In iOS 6 you can do it in the info.plist:
It is now possible to set status bar tint parameters in your app’s
Info.plist file. You might do this to ensure that the status bar color
matches the navigation bar color of your app during startup. To set
the status bar tint, add the UIStatusBarTintParameters key to your
Info.plist file. The value of this key is a dictionary with the
appropriate values describing the navigation bar your app has at
startup time. Inside the dictionary should be the UINavigationBar key,
whose value is also a dictionary. That dictionary contains the initial
navigation bar’s style (with the Style key) and whether it’s
translucent (with the Translucent key). If your navigation bar uses
them, you can also specify its tint color (with the TintColor key), or
the name of its custom background image (with the BackgroundImage
key).
Check out this link here
Edit:You can also do this in the project summary.
In the contacts app, the search bar is shown with a white background and it blends in well with the surrounding UI. The only style choices in Interface Builder don't seem to show a way to host just the search bar, but instead includes chrome around it to make it look slightly 3d.
Is there a way to get rid of the surrounding chrome and simply have the search bar overlaid on my own view's background (which happens to be flat black)?
You could use the UIBarStyleBlack .barStyle, or set the .tintColor to black, or set the .translucent to YES.
However, there's no documented way to change the background image of a search bar.
You may use a UITextField with a custom .background and .leftView to simulate the look of a UISearchBar.