Darkmode and multiwindows / scenes - ios13

i'm trying to implement ios13 darkmode within multi scene application.
Unfortunately when i dismiss a scene dragging it over the screen edge the method traitCollectionDidChange is called several times with always different values, causing my UI to flicker between dark and light mode.
What's wrong?
Here is my implementation
func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
print("THEME instance: \(self)")
let currentTraitCollection = self.traitCollection
var hasUserInterfaceStyleChanged = false
hasUserInterfaceStyleChanged = previousTraitCollection.hasDifferentColorAppearanceCompared(to: currentTraitCollection)
print("THEME hasUserInterfaceStyleChanged = \(hasUserInterfaceStyleChanged ? "YES" : "NO")")
if hasUserInterfaceStyleChanged {
let userInterfaceStyle = currentTraitCollection.userInterfaceStyle // Either .unspecified, .light, or .dark
switch userInterfaceStyle {
case .unspecified:
print("THEME UIUserInterfaceStyleUnspecified")
case .light:
print("THEME UIUserInterfaceStyleLight")
case .dark:
print("THEME UIUserInterfaceStyleDark")
}
} else {
print("THEME NOT CHANGED")
}
}
Here is the logged statements in console
When new scene comes in...
THEME instance: <MainControllerViewController: 0x117e55910>
THEME hasUserInterfaceStyleChanged = YES
THEME UIUserInterfaceStyleLight
When added scene goes away...
THEME instance: <MainControllerViewController: 0x117e55910>
THEME hasUserInterfaceStyleChanged = YES
THEME UIUserInterfaceStyleDark
THEME instance: <MainControllerViewController: 0x117e55910>
THEME hasUserInterfaceStyleChanged = YES
THEME UIUserInterfaceStyleLight
THEME instance: <MainControllerViewController: 0x117e55910>
THEME hasUserInterfaceStyleChanged = NO
THEME NOT CHANGED
THEME instance: <MainControllerViewController: 0x117e55910>
THEME hasUserInterfaceStyleChanged = YES
THEME UIUserInterfaceStyleDark
THEME instance: <MainControllerViewController: 0x117e55910>
THEME hasUserInterfaceStyleChanged = YES
THEME UIUserInterfaceStyleLight
in meantime i have no changed to dark mode (always light)...so i expect just THEME NOT CHANGED.

I was struggling with the same issue and the solution I worked out is in the SceneDelegate.
A UIScene has multiple states:
.foregroundActive
.foregroundInactive
.background
.unattached
When you are resizing windows in slide over, or in this case, removing one from slide over, traitCollectionDidChange gets called for each of them. This means that you are updating the userInterfaceStyle for scenes in the .background, .foregroundInactive, and .unattached states. This is what's causing the flickering.
The solution is to not use traitCollectionDidChange, but to use a delegate method in SceneDelegate called windowScene(_:didUpdate:interfaceOrientation:traitCollection:).
Per Apple's docs this method:
Notifies you when the size, orientation, or traits of a scene change.
The added benefit of this is that we can check the .activationState of the scene before updating the userInterfaceStyle.
func windowScene(_ windowScene: UIWindowScene, didUpdate previousCoordinateSpace: UICoordinateSpace, interfaceOrientation previousInterfaceOrientation: UIInterfaceOrientation, traitCollection previousTraitCollection: UITraitCollection) {
let currentTraitCollection = windowScene.traitCollection
if windowScene.activationState == .foregroundActive {
if currentTraitCollection.userInterfaceStyle != previousTraitCollection.userInterfaceStyle {
if currentTraitCollection.userInterfaceStyle == .light {
//update to light theme
} else {
//update to dark theme
}
}
}
}

Related

how to change p-table background color when theme changes to dark theme in ngx-admin angular

I am using ngx-admin template and for my table. I don't use ng2-smart-table.
I tried to change whole page to dark theme. full page changed to dark mode except table. The table is still white color.
How can i change The table color to dark theme when theme change to dark theme.
I attach screen shot of my issue.
I need the table also has to change dark theme. How can i do?
themes = [
{
value: 'default',
name: 'Light',
},
{
value: 'dark',
name: 'Dark',
},
{
value: 'cosmic',
name: 'Cosmic',
},
{
value: 'corporate',
name: 'Corporate',
},
];
currentTheme = 'default';
You will first need to research primeng themes and how to import them into your project and utilize them.
But for answering this question since ngx-admin doesn't natively handle all the colors for primeng on theme change. You will have to subscribe to the theme changes in the nebular theme and update tables yourself.
themeClass: string = 'light-theme';
constructor(private themeService: NbThemeService) {
this.themeService.onThemeChange()
.subscribe((theme) => {
// Here is where you will know which theme is currently applied and you can do logic. For example (if setting theme by class):
this.themeClass = theme?.name == 'light' ? 'light-theme' : 'dark-theme';
});
}

How to change Project Theme Dynamically in Aurelia

I want to change my project theme dynamically.I created different themes files like as "Blue",Red","Light","Black" etc .As my Given code below "light-theme.scss" is my theme file which I am requiring in App.html above from "ezmax-home-pages.scss" which is main file.
Basically light-theme file is importing in main file and changeing project theme.Its working for me .But there are many theme files.I cant change theme file path manually every time.
I google and find many solutions but none of those worked.I found that you cant use any variable in require tag etc Kindly tell is there any solution for my problem.
<require from="./assets/css/light-theme.scss"></require>
<require from="./assets/css/ezmax-home-pages.scss"></require>
Light theme
:root {
--themeColor: #007ACC;
--otherButtonColor: #26a69a;
--cancelButtonColor: rgb(244, 67, 54);
--themeBackColor: #F5F5F5;
--themeElementColor: #fff;
--themeAltColor: #f8fafb;
--themeNormalColor: #fff;
--themetxtColor: #000;
--themeAlttxtColor: #8997a6;
--themeDarkBorderColor: #D7D7DB;
--themeBorderColor: #e8eaed;
--themeDarkAltColor: #f0f4f6;
}
I want to make dynamic approach where i can change theme file path by selecting theme file name from drop-down like and code will change path of my theme file and project theme change dynamically.
Aamir. In your case, as you have webpack for bundling, you'd have to manage users stylesheets separate from the source code. If not, with every new customer you'd be forced to recompile and publish.
A solution is to have a repository with customers's stylesheets and build something like this:
themes = [
{
title: "default",
url:
"https://bootswatch.com/_vendor/bootstrap/dist/css/bootstrap.min.css"
},
{
title: "cerulean",
url: "https://bootswatch.com/4/cerulean/bootstrap.min.css"
},
{
title: 'darkly',
url: 'https://bootswatch.com/4/darkly/bootstrap.min.css'
}
];
activate() {
this.changeTheme(this.themes[0]);
}
changeTheme(theme) {
const head = document.getElementsByTagName("head")[0];
const itemId = 'css-sheet';
let link = document.getElementById(itemId);
if (!link) {
link = document.createElement("link");
link.id = itemId;
link.rel = "stylesheet";
link.type = "text/css";
link.href = theme.url; <-- here occurs the switch
link.media = "all";
head.appendChild(link);
} else {
link.href = theme.url;
}
}
This example works by choosing the theme from a dropdown menu. In your case, the url of the sheet should be inferred from the customer's profile.
A working example with external stylesheets is available on the following link https://codesandbox.io/s/aurelia-dynamic-css-enrge?fontsize=14.
Wish you the best.

Choose between different style for an Ember.JS application

The issue I have is that I can't find a way to 'change' the css style within my application.
The thing that I want to access is for example: I have a red theme, but I want that the user can choose an other predefined theme, like a green, or a blue theme.
The idea is that I have different app.css, how can I change between one another, I can't find method to do so. Maybe I can do it in my environnement.js?
Any tips is apreciated.
tl;dr: How to set multiple css style in our Ember.JS app?
You can achieve this by generating multiple stylesheets, see: https://ember-cli.com/asset-compilation#configuring-output-paths
I suggest using ember-cli-head to add a specific link element with the additional theme stylesheet. You could set the stylesheet in your head.hbs using the headData service.
Full Example:
ember-cli-build.js
var app = new EmberApp({
outputPaths: {
app: {
css: {
// app/styles/red.css
'red': '/assets/themes/red.css'
}
}
},
// Exclude theme css files from fingerprinting,
// otherwise your file is named `red-somehash.css`
// which we don't (easily) now at runtime.
fingerprint: {
exclude: [ 'red.css' ]
}
})
head.hbs
{{#if theme}}
<link rel="stylesheet" href="/assets/{{theme}}.css">
{{/if}}
some-component.js (or Route or whatever)
export default Ember.Component.extend({
headData: Ember.inject.service(),
actions: {
setTheme(themeName) {
this.set('headData.theme')
}
}
})

Remove animation from WP theme (css)

I'm working on a Wordpress template with an animation on the frontpage. The animation loads the frontpage content (banner and newsletter) when you scroll. I wan't to remove the animation, but I can't find out in which CSS file the animation script is hided. Can anybpody please help me?
Thanks :))
http://funwithfelix.com/
Found inside helper.js
// Initializing waypoints to show/hide flowign panel above header
jQuery(document).ready(function($){
$(window).load(function(){
$('.site-header').waypoint(function(direction) {
if (direction == 'down') {
$('.panel-hidden').fadeIn();
} else {
$('.panel-hidden').fadeOut();
}
}, {
offset: function() {
return -$(this).height();
}
});
});
});

TinyMCE 4.0 , removing buttons on initialization

I have a set of WYSIWYG editors that are all initialized via TinyMCE on demand.
In the previous version of TinyMCE I was able to easily remove buttons by specifying the button theme_advanced_buttons1, theme_advanced_buttons2 etc. But since the newest release of TinyMCE 4.0 , it seems as tho that no longer works.
I am running the modern theme, so maybe the theme_advanced_buttons1 doesn't work with the modern theme? I've tried theme_modern_buttons1 , but that didn't work.
I'm thinking it may have changed with the newest release, as there is a new toolbar with the options for 'File, Edit, Insert...' etc.
Anyone know how I can hide the buttons on initialization? Heres the code I'm trying:
```
// initialize tinyMCE editor on our movie description text area
function initialize_movie_descriptions() {
$('.movie_description_editor').each(function() {
var id = $(this).attr('id');
tinyMCE.init({
mode : "exact",
elements : id,
theme : "modern",
plugins: "wordpress,wplink, paste",
theme_advanced_buttons1: "",
theme_advanced_buttons2 : "",
theme_advanced_buttons3: "",
theme_advanced_resizing : true,
paste_auto_cleanup_on_paste : true,
paste_preprocess : function(pl, o) {
o.content = o.content;
},
paste_postprocess : function(pl, o) {
o.node.innerHTML = o.node.innerHTML;
}
});
});
}
initialize_movie_descriptions();
```
Edit
Apparently changing the line plugins: "wordpress,wplink, paste", to plugins: "", seems to have removed the 'Insert' menu item in the first toolbar. I guess because it's not loading any plugins now??
If you don't want all buttons but keep some of the functionality you have to keep to plugins. Simply just add the buttons you want in toolbar. The Same way with the menu:
tinymce
.init({
...
plugins : [code fullscreen save table contextmenu paste textcolor" ],
//buttons you want to show, else set "toolbar:false"
toolbar : "insertfile undo redo | styleselect",
...
menu : {
...
edit : {
//menu edit
title : 'Edit',
//items of menu edit
items : 'undo redo | cut copy paste pastetext | selectall'
},
...
});
you can find a list of plugins with their configuration in tinyMCE here: http://www.tinymce.com/wiki.php/Plugins
I struggled with the same problem after updating Wordpress to version 4.0. I found the solution on the wiki-advanced-page of TinyMCE. In TinyMCE 4 "theme_advanced_buttons" is replaced by "toolbar". You probably want to hide the "menubar" too, see example below:
tinyMCE.init({
mode: "exact", // not needed
theme: "modern", // default - not needed. Only theme available in WP 4.0
height: height, // e.g. 100
menubar : false, // you probably don't want to show the [file] etc bar
block_formats: "Paragraph=p;Header 1=h1;Header 2=h2;Header 3=h3;Header 4=h4;Header 5=h5;Header 6=h6",
toolbar : "formatselect,bold,italic,underline,removeformat", //choose buttons in bar
});
There's a fast way to remove everything you see: Using CSS. Maybe it's not the best one, but is the faster one:
#mceu_15, #mceu_17, #mceu_18 {
display:none; }
Those #mceu numbers are the icons I want to hide (added by annoying plugins ;)
NOTE: You have to add this css on your_theme/admin.css
If it doesn't work look / add in your theme functions this:
function admin_style() { wp_enqueue_style('admin-styles', get_template_directory_uri().'/admin.css');} add_action('admin_enqueue_scripts', 'admin_style');

Resources