How to detect dark mode in Delphi macOS apps

Viewed 341

How to detect dark mode in Delphi FireMonkey macOS (e.g. Big Sur) apps?

1 Answers

You can use FireMonkey platform services to get that information:

uses
  FMX.Platform;

function GetSystemTheme: TSystemThemeKind;
var
  LService: IFMXSystemAppearanceService;
begin
  Result := TSystemThemeKind.Unspecified;
  if TPlatformServices.Current.SupportsPlatformService(IFMXSystemAppearanceService, LService) then
    Result := LService.GetSystemThemeKind;
end;

Where TSystemThemeKind is declared as

TSystemThemeKind = (Unspecified, Light, Dark); 

IFMXSystemAppearanceService is currently supported on Android, iOS and macOS.

Related