Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.

GH-1121 If VC is null use TraitCollection #1144

Merged
merged 1 commit into from
Mar 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Xamarin.Essentials/AppInfo/AppInfo.ios.tvos.watchos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ static AppTheme PlatformRequestedTheme()
if (!Platform.HasOSVersion(13, 0))
return AppTheme.Unspecified;

return Platform.GetCurrentViewController().TraitCollection.UserInterfaceStyle switch
var uiStyle = Platform.GetCurrentUIViewController()?.TraitCollection?.UserInterfaceStyle ??
UITraitCollection.CurrentTraitCollection.UserInterfaceStyle;

return uiStyle switch
{
UIUserInterfaceStyle.Light => AppTheme.Light,
UIUserInterfaceStyle.Dark => AppTheme.Dark,
Expand Down