Same theme but different colors to choose from - qooxdoo

Finally my app is almost done, and instead switching to others themes I would like to stick to Modern and change only combinations of colors.
My possible option are:
a) Make a copy of Theme to ModernA, ModernB, etc and change Color.js
b) Apply States to colors to select them according to some condition
c) Change them at runtime (if possible)
Which could be my easy and best approach to do it? and a snippet would be really appreciate.

The best way to do this is to create a new theme and reuse the modern theme; for example:
source/class/myapp/MyModern.js:
qx.Theme.define("myapp.MyModern", {
title : "My Modern",
meta : {
color : myapp.MyColor,
decoration : qx.theme.modern.Decoration,
font : qx.theme.modern.Font,
appearance : qx.theme.modern.Appearance,
icon : qx.theme.icon.Tango
}
});
and source/class/myapp/MyColor.js:
qx.Theme.define("myapp.MyColor", {
extend : qx.theme.modern.Color,
colors : {
// Add your custom colour overrides here
}
});
By using the extend keyword in the MyColor class, you will start with the normal Modern colours and can then choose to override colours as you need

Option C is possible by creating an edited Color theme at runtime:
// First, get the current Color theme
var currentcolor = qx.theme.manager.Color.getInstance().getTheme();
// Change any or all color entries. This can be as dynamic as you want. Get a user defined color from a color picker control. Create Shades based off of a primary color, etc.
currentcolor.colors.themePrimary = "#00ffd4"; // Or a value from the ColorPicker widget
// Now define a new Color theme with the updated colors
qx.Theme.define("NewColor",
{
colors : currentcolor.colors
});
// Set the new Color theme (button used below as an example)
button.addListener("execute", function(e) {
qx.theme.manager.Color.getInstance().setTheme(qx.Theme.getByName("NewColor"));
});

Related

How to change the icon or color of the icon for each file using material-ui-dropzone

I am using material-ui-dropzone to upload multiple files.
Is there any way to change the icon or color of the icon for each file?
Please give me suggestion to solve this problem.
Current situation -
Code example - Link
First if you see the example in the documentation https://react-dropzone.js.org/#section-previews
instead of using thumbnail use an icon from material UI and update the color programmatically.
Create a color pallet or a function that returns you the RGB programmatically. Then assign the color to each icon when you mount an icon component based on the number of file.
for simple one just create an array with color values:
const colorPallet = ['red', 'yello', 'green', ... ]
and assign the color in style <FileClipIcon style={{ color: colorPallet[index] }} />
otherwise write a function which returns you random RGB values between 0 to 255 and use that.

How does using dynamic colors in viewDidLoad automatically switch the colors for Dark mode?

Per my understanding of the WWDC 2019 video "Implementing Dark Mode in iOS", dynamic colors are resolved using UITraitCollection.current. The updated trait collection is ready only in certain methods such as draw, viewWillLayoutSubviews etc.
So, if I use dynamic colors inside viewDidLoad, for example, the colors should not update automatically upon mode switch. However, they are being updated
Below is my code:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
view.backgroundColor = .systemBackground
let label = UILabel(frame: CGRect(x: 100, y: 100, width: 100, height: 20))
label.textColor = UIColor.label
label.text = "Label text"
view.addSubview(label)
}
}
The way I switched the mode in the simulator was Settings -> Developer -> Dark appearance. Then I brought my app to the foreground.
How did the color get auto-updated?
Note: I did not test in my device.
The colors you are using, systemBackground and label, are actually dynamic colors that adopt automatically when the trait collection changes. (Ok, under the hood it's more likely that the views that apply the colors react to trait environment changes and re-evaluate the colors.) That's why you don't need to do anything manually when using the system colors.
If you want the same behavior for your own colors, you have two options:
You can create a color set in an asset catalog. In color sets, you can define different colors for different appearances (light & dark mode and high-contrast accessibility colors). You can them get the color by the name of your color set in code (UIColor(named:)) or use them in interface builder.
Alternatively, you can use a dynamic provider block when creating the color in code, where you can determine the actual color based on the trait collection:
let color = UIColor { traitCollection -> UIColor in
switch traitCollection.userInterfaceStyle {
case .light, .unspecified: return .white
case .dark: return .black
}
}

Change CodenameOne Accordion Icon UIID

How do you change the UIID for the openIcon and closeIcon on a CodenameOne Accordion? It does not appear that there is any method available to do this.
What I am ultimately trying to do is to change the color of the material icon being used for the openIcon/closeIcon in one instance of an Accordion component. I have tried to do this a dozen different ways with no luck. I have been able to change the UIID of the accordion container itself, the header, and the content, but not the > icon.
I realize that I could create a > icon of the desired color and then use setCloseIcon/setOpenIcon to assign it. However, I would prefer to use the material icon, and those get their color from the UIID.
I see in the CN1 source that arrow.setUIID("AccordionArrow"); appears to be used in the AccordionContent class. However defining an AccordionArrow UIID in the theme builder does not appear to make a difference either.
You can customize the material icons programmatically. Create below method and reuse it where necessary.
public static FontImage materialIcon(char charCode, float size, int color) {
Font fnt = Font.createTrueTypeFont("native:MainLight", "native:MainLight").derive(CN.convertToPixels(size), Font.STYLE_PLAIN);
Style s = new Style(color, 0, fnt, (byte) 0);
FontImage fm = FontImage.createMaterial(charCode, s);
return fm;
}
//Change material icon, size and color as appropriate
accordion.setOpenIcon(materialIcon(FontImage.MATERIAL_ARROW_DROP_DOWN, 4, 0x4D5052));
accordion.setCloseIcon(materialIcon(FontImage.MATERIAL_ARROW_DROP_UP, 4, 0x4D5052));

How to define contrast colors in extending a palette in Angular Material theme

Angular Material Documentation for theming states the following to extend an existing palette for custom theming-
var neonRedMap = $mdThemingProvider.extendPalette('red', {
'500': '#ff0000',
'contrastDefaultColor': 'dark'
});
In this, if i want to specify which color i want as the contrast using
'contrastLightColors': ['800']
is it possible? Doesn't seem to be working at all. Just defaults to black on giving contrastDefaultColor.
Is defining a whole new custom palette for this the only option?
I can't exactly use color css property since there are icons also that need to take that color. All those icons are web components (Angular 1.5x) so i want a centralised control over the colors.
What should i do?

Change the background color of my Watson Virtual Agent

I've created a bot using Watson Virtual Agent, and I embedded it in my website. Can I change the background color of the chat window so that it matches the other colors on my site?
You can certainly change the colors of the chat widget to match your brand.
In fact, every color that is used in the chat widget is configurable.
To choose your own colors, you can supply your own colors as part of your config object you pass to the IBMChat.init function.
The example below includes the default colors, but replace the hex codes as you see fit.
var config = {};
//set your other config params
config.styles = {
background: '#3d3d3d',
//the main background color
accentBackground: '#AF6EE8',
/*the background for "accent" elements.
These are the attention grabbing elements like a selected button,
or a loading spinner*/
accentText: '#ffffff',
//the text color for the accentBackground
text: '#ffffff',
//default text color
link: '#ffffff',
/*default link color... this should be a color that works both
with the "background" color and the "secondaryBackground" color.*/
secondaryBackground: '#464646',
/*this is the background for elements that get some emphasis,
but not as much as "accent" elements. e.g. An unselected button
or a container box for a widget.*/
secondaryText: '#f7f7f7',
inputBackground: '#464646',
//background color for your form elements, including the main chat input
inputText: '#f7f7f7'
}
IBMChat.init(config);

Resources