-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
styleLightContent not working on iphone 11 #189
Comments
@Simbaclaws , Hi friends, I'm also having the same problem, have you got an answer about this? |
Dear @aacassandra, personally because of this bug I decided to use a different native runtime then cordova since I was using ionic framework version 4+. Nowadays some cordova plugins tend to have issues with newer versions of operating systems from android and iOS. And it depends on the maintainers of these specifically made cordova plugins to update them rather then have a company backed solution for all of the plugins you'll need. I'm using a native runtime for web apps called: capacitor. This is a native runtime created by the ionic team (from the ionic company) instead of individual maintainers. Currently I'm using status bar from capacitor in order to style my status bar correctly across newer and older versions of ios and android. Here are 2 services that I made in ionic angular to get information about the platform you're using and to set the statusbar according to the current platform you are on in either a "dark" or "light" mode. Information service using capacitor: import { Injectable } from '@angular/core';
import { Plugins } from '@capacitor/core';
import { Platform } from '@ionic/angular';
const { Device } = Plugins;
@Injectable({
providedIn: 'root'
})
export class InformationService {
constructor(
private platform: Platform
) { }
async givePlatform() {
return this.platform.ready().then(async ()=>{
const info = await Device.getInfo();
return info.platform;
});
}
} statusbar service using capacitor: import { InformationService } from './information.service';
import { Injectable } from '@angular/core';
import { Plugins, StatusBarStyle } from '@capacitor/core';
const { StatusBar } = Plugins;
@Injectable({
providedIn: 'root'
})
export class StatusbarService {
constructor(
private info: InformationService
) { }
changeStatusBar(color) {
this.info.givePlatform().then((platform) => {
if (platform !== 'web') {
if (color === 'dark') {
StatusBar.setStyle({
style: StatusBarStyle.Dark
});
if (platform === 'android') {
StatusBar.setBackgroundColor({
color: '#121212'
});
} else if (platform === 'ios') {
StatusBar.setBackgroundColor({
color: '#000000'
});
}
} else if (color === 'light') {
StatusBar.setStyle({
style: StatusBarStyle.Light
});
StatusBar.setBackgroundColor({
color: '#ffffff'
});
}
StatusBar.setOverlaysWebView({
overlay: false
});
}});
}
} This can be used like so: this.statusbar.changeStatusbar('dark'); where statusbar is the imported service. In my case my app's theme had different dark colors for ios and android, hence I made a platform check that changed the bar color based on the platform. You can change this if you like. Be weary (all of this is ionic 4+ with angular). I am pretty sure you can add capacitor using any of your beloved frameworks. In my case I also made a theming service that handles all theming related stuff regarding light and dark mode. This might not be related to the current cordova plugin issue we're having, but this is how I solved it with an alternative solution in my app. |
Hi @Simbaclaws , thank you for your quick response. i see you have no problem when using statusbar with capacitor (angular). I'm using the latest ionic with vuejs3, but not the typescript version, and I'm using the statusbar of the capacitor. as you mentioned above. only functions to hide and show the statusbar only. but when I try the function below.
it doesn't work out as expected. Likewise using cordova-plugin-statusbar also doesn't work for this time, I set the statusbar light / dark directly via xcode (deployment info) I say, thank you for your quick response. |
Hey @aacassandra, I think you should set both the style and the background. The style is meant to show dark or light icons in the statusbar. The background is to set the specific background color for that specific style. So if the style is dark the icons in the bar will be light, and the background should then be set to dark. For example: StatusBar.setStyle({
style: StatusBarStyle.Dark
});
StatusBar.setBackgroundColor({
color: '#000000'
}); StatusBarStyle.Dark == light icons in statusbar You probably want to use both of them. Your language is quite readable to me, you have nothing to worry about ;) EDIT: Also I think you realize that putting these StatusBar.setStyle underneath each other like in your example, will cause the bar to be changed to the one that was set as last style. But I think your example was meant to show which functions to use, rather than using them in that specific order if I'm not mistaken? |
wow, thanks friends. works well now. |
Bug Report
Problem
When creating a dark background color of the statusbar by for example:
StatusBar.backgroundColorByHexString('#000000');
and then doing:
StatusBar.styleLightContent();
then the text will be black on a black background on ios.
What is expected to happen?
The text should become a light variant on a dark background.
What does actually happen?
The text is dark on a dark background.
Command or Code
StatusBar.styleLightContent();
Environment, Platform, Device
Both on a real device as well as the emulator.
Version information
Checklist
The following issue might be related: #188
The text was updated successfully, but these errors were encountered: