|
|
|
|
|
|
using System.Linq; |
|
|
|
using Unity.UIWidgets.async2; |
|
|
|
using Unity.UIWidgets.foundation; |
|
|
|
using Unity.UIWidgets.rendering; |
|
|
|
using Unity.UIWidgets.ui; |
|
|
|
|
|
|
|
namespace Unity.UIWidgets.widgets { |
|
|
|
|
|
|
public static Locale localeOf(BuildContext context, bool nullOk = false) { |
|
|
|
D.assert(context != null); |
|
|
|
_LocalizationsScope scope = |
|
|
|
(_LocalizationsScope) context.inheritFromWidgetOfExactType(typeof(_LocalizationsScope)); |
|
|
|
(_LocalizationsScope) context.dependOnInheritedWidgetOfExactType<_LocalizationsScope>(); |
|
|
|
if (nullOk && scope == null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
public static List<LocalizationsDelegate> _delegatesOf(BuildContext context) { |
|
|
|
D.assert(context != null); |
|
|
|
_LocalizationsScope scope = |
|
|
|
(_LocalizationsScope) context.inheritFromWidgetOfExactType(typeof(_LocalizationsScope)); |
|
|
|
(_LocalizationsScope) context.dependOnInheritedWidgetOfExactType<_LocalizationsScope>(); |
|
|
|
D.assert(scope != null, () => "a Localizations ancestor was not found"); |
|
|
|
return new List<LocalizationsDelegate>(scope.localizationsState.widget.delegates); |
|
|
|
} |
|
|
|
|
|
|
D.assert(type != null); |
|
|
|
_LocalizationsScope scope = |
|
|
|
(_LocalizationsScope) context.inheritFromWidgetOfExactType(typeof(_LocalizationsScope)); |
|
|
|
(_LocalizationsScope) context.dependOnInheritedWidgetOfExactType<_LocalizationsScope>(); |
|
|
|
if (scope != null && scope.localizationsState != null) { |
|
|
|
return scope.localizationsState.resourcesFor<T>(type); |
|
|
|
} |
|
|
|
|
|
|
_locale = locale; |
|
|
|
} |
|
|
|
else { |
|
|
|
// WidgetsBinding.instance.deferFirstFrameReport();
|
|
|
|
// WidgetsBinding.instance.allowFirstFrameReport();
|
|
|
|
return; |
|
|
|
setState(() => { |
|
|
|
_typeToResources = (Dictionary<Type, object>) value; |
|
|
|
_locale = locale; |
|
|
|
}); |
|
|
|
|
|
|
|
setState(() => { |
|
|
|
_typeToResources = (Dictionary<Type, object>)value; |
|
|
|
_locale = locale; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|