Skip to content
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

FlatDark is not best match for MacOS Dark mode #497

Closed
ijabz opened this issue Mar 8, 2022 · 6 comments
Closed

FlatDark is not best match for MacOS Dark mode #497

ijabz opened this issue Mar 8, 2022 · 6 comments
Milestone

Comments

@ijabz
Copy link

ijabz commented Mar 8, 2022

I naively assumed that FlatDark laf would mimic the dark mode on MacOS, but actually it seems a lot lighter. Im no expert on MacOS but I do know that Mac users are very particular about how applications look and therefore would it not be a good idea to use MacOS dark mode as the basis for the FlatDark laf.

If not I did try out the demo and it seems that maybe GitDark was the best match, why not add a theme called MacOS Dark to give developers such as myself with no expertise in this the confidence to know what is the best laf to use to best match MacOS native apps.

@DevCharly
Copy link
Collaborator

There are plans to provide macOS (and Windows) specific light and dark themes, that are closer to the OS look, in the future...

In the meantime you can use following:

Create a file com/myapp/themes/FlatDarkLaf.properties (used for dark themes) in your application resources:

[mac]@background = #1e1e1e
[mac]@foreground = #e0e0e0
[mac]@accentColor = #107aff
[mac]@accentFocusColor = #176896

[mac]Component.arrowType = chevron

[mac]CheckBox.icon.style = filled
[mac]CheckBox.icon[filled].selectedBorderColor = @accentColor
[mac]CheckBox.icon[filled].selectedBackground = @accentColor
[mac]CheckBox.icon[filled].checkmarkColor = @foreground

[mac]RadioButton.icon.style = filled
[mac]RadioButton.icon[filled].centerDiameter = 6

In your main() method use:

FlatLaf.registerCustomDefaultsSource( "com.myapp.themes" );
FlatDarkLaf.setup();

Then it looks like this on macOS:

image

Default look for comparison:

image

@ijabz
Copy link
Author

ijabz commented Mar 14, 2022

Thanks, that looks great.

However, can I do it i code ?

The reason being introducing config files for different platforms not so easy

@DevCharly
Copy link
Collaborator

The reason being introducing config files for different platforms not so easy

The file FlatDarkLaf.properties needs to be in your application JAR and
works for all platforms because each line is prefixed with [mac] 😉

To do it in code, have a look at FlatLaf.setGlobalExtraDefaults():
https://www.javadoc.io/static/com.formdev/flatlaf/2.0.2/com/formdev/flatlaf/FlatLaf.html#setGlobalExtraDefaults(java.util.Map)

@ijabz
Copy link
Author

ijabz commented Mar 23, 2022

ok, thanks that works for me

This is my code if they select Dark Mode

public static  void install() throws Exception
    {
        Map<String, String> darkModeAdjustments = new HashMap();
        if(Platform.isOSX())
        {
            darkModeAdjustments.put("@background", "#1e1e1e");
            darkModeAdjustments.put("@foreground", "#e0e0e0");
            darkModeAdjustments.put("@accentColor", "#107aff");
            darkModeAdjustments.put("@accentFocusColor", "#176896");
            darkModeAdjustments.put("Component.arrowType", "chevron");
            darkModeAdjustments.put("CheckBox.icon.style", "filled");
            darkModeAdjustments.put("CheckBox.icon[filled].selectedBorderColor", " @accentColor");
            darkModeAdjustments.put("CheckBox.icon[filled].selectedBackground", "@accentColor");
            darkModeAdjustments.put("CheckBox.icon[filled].checkmarkColor", "@foreground");
            darkModeAdjustments.put("RadioButton.icon.style", "filled");
            darkModeAdjustments.put("RadioButton.icon[filled].centerDiameter", "6");
        }
        FlatLaf.setGlobalExtraDefaults(darkModeAdjustments);

        UIManager.setLookAndFeel(FlatDarkLaf.class.getName());

        UIManager.put("Table.alternateRowColor", DarkMode.veryDarkGray);
    }

Also found if they set light mode i need to clear out that global extra mapping i was using in dark by calling again with empty map

public static void install() throws Exception
    {
        Map<String, String> macosLightMode = new HashMap();
        FlatLaf.setGlobalExtraDefaults(macosLightMode);

        UIManager.setLookAndFeel(FlatLightLaf.class.getName());

        UIManager.put("Table.alternateRowColor", aquaBlue);
    }

DevCharly added a commit that referenced this issue May 13, 2022
…the same on Windows or Linux as on macOS (issue #497)
@DevCharly
Copy link
Collaborator

macOS specific themes are coming in FlatLaf 3: see PR #533

DevCharly added a commit that referenced this issue Nov 1, 2022
…the same on Windows or Linux as on macOS (issue #497)
DevCharly added a commit that referenced this issue Nov 1, 2022
@DevCharly
Copy link
Collaborator

PR #533 merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants