|
|
|
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using Unity.UIWidgets.async2; |
|
|
|
using Unity.UIWidgets.engine; |
|
|
|
using Unity.UIWidgets.widgets; |
|
|
|
using UnityEngine; |
|
|
|
using Color = Unity.UIWidgets.ui.Color; |
|
|
|
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|
|
|
|
|
|
public delegate string GenerateAppTitle(BuildContext context); |
|
|
|
|
|
|
|
public delegate PageRoute PageRouteFactory(RouteSettings settings, WidgetBuilder builder); |
|
|
|
|
|
|
|
public static bool showPerformanceOverlayOverride = false; |
|
|
|
public static bool debugShowWidgetInspectorOverride = false; |
|
|
|
public static bool debugAllowBannerOverride = true; |
|
|
|
|
|
|
|
public static readonly Dictionary<LogicalKeySet, Intent> _defaultShortcuts = |
|
|
|
new Dictionary<LogicalKeySet, Intent> { |
|
|
|
// Activation
|
|
|
|
{new LogicalKeySet(key1: LogicalKeyboardKey.enter), new Intent(key: ActivateAction.key)}, |
|
|
|
{new LogicalKeySet(key1: LogicalKeyboardKey.space), new Intent(key: ActivateAction.key)}, |
|
|
|
{new LogicalKeySet(key1: LogicalKeyboardKey.gameButtonA), new Intent(key: ActivateAction.key)}, |
|
|
|
|
|
|
|
// Keyboard traversal.
|
|
|
|
{new LogicalKeySet(key1: LogicalKeyboardKey.tab), new Intent(key: NextFocusAction.key)}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.shift, key2: LogicalKeyboardKey.tab), |
|
|
|
new Intent(key: PreviousFocusAction.key) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.arrowLeft), |
|
|
|
new DirectionalFocusIntent(direction: TraversalDirection.left) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.arrowRight), |
|
|
|
new DirectionalFocusIntent(direction: TraversalDirection.right) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.arrowDown), |
|
|
|
new DirectionalFocusIntent(direction: TraversalDirection.down) |
|
|
|
}, |
|
|
|
{new LogicalKeySet(key1: LogicalKeyboardKey.arrowUp), new DirectionalFocusIntent()}, |
|
|
|
|
|
|
|
// Scrolling
|
|
|
|
{ |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.control, key2: LogicalKeyboardKey.arrowUp), |
|
|
|
new ScrollIntent(direction: AxisDirection.up) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.control, key2: LogicalKeyboardKey.arrowDown), |
|
|
|
new ScrollIntent(direction: AxisDirection.down) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.control, key2: LogicalKeyboardKey.arrowLeft), |
|
|
|
new ScrollIntent(direction: AxisDirection.left) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.control, key2: LogicalKeyboardKey.arrowRight), |
|
|
|
new ScrollIntent(direction: AxisDirection.right) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.pageUp), |
|
|
|
new ScrollIntent(direction: AxisDirection.up, type: ScrollIncrementType.page) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.pageDown), |
|
|
|
new ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page) |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// Default shortcuts for the web platform.
|
|
|
|
public static readonly Dictionary<LogicalKeySet, Intent> _defaultWebShortcuts = |
|
|
|
new Dictionary<LogicalKeySet, Intent> { |
|
|
|
// Activation
|
|
|
|
{new LogicalKeySet(key1: LogicalKeyboardKey.space), new Intent(key: ActivateAction.key)}, |
|
|
|
|
|
|
|
// Keyboard traversal.
|
|
|
|
{new LogicalKeySet(key1: LogicalKeyboardKey.tab), new Intent(key: NextFocusAction.key)}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.shift, key2: LogicalKeyboardKey.tab), |
|
|
|
new Intent(key: PreviousFocusAction.key) |
|
|
|
}, |
|
|
|
|
|
|
|
// Scrolling
|
|
|
|
{new LogicalKeySet(key1: LogicalKeyboardKey.arrowUp), new ScrollIntent(direction: AxisDirection.up)}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.arrowDown), |
|
|
|
new ScrollIntent(direction: AxisDirection.down) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.arrowLeft), |
|
|
|
new ScrollIntent(direction: AxisDirection.left) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.arrowRight), |
|
|
|
new ScrollIntent(direction: AxisDirection.right) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.pageUp), |
|
|
|
new ScrollIntent(direction: AxisDirection.up, type: ScrollIncrementType.page) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.pageDown), |
|
|
|
new ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page) |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// Default shortcuts for the macOS platform.
|
|
|
|
public static readonly Dictionary<LogicalKeySet, Intent> _defaultMacOsShortcuts = |
|
|
|
new Dictionary<LogicalKeySet, Intent> { |
|
|
|
// Activation
|
|
|
|
{new LogicalKeySet(key1: LogicalKeyboardKey.enter), new Intent(key: ActivateAction.key)}, |
|
|
|
{new LogicalKeySet(key1: LogicalKeyboardKey.space), new Intent(key: ActivateAction.key)}, |
|
|
|
|
|
|
|
// Keyboard traversal
|
|
|
|
{new LogicalKeySet(key1: LogicalKeyboardKey.tab), new Intent(key: NextFocusAction.key)}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.shift, key2: LogicalKeyboardKey.tab), |
|
|
|
new Intent(key: PreviousFocusAction.key) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.arrowLeft), |
|
|
|
new DirectionalFocusIntent(direction: TraversalDirection.left) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.arrowRight), |
|
|
|
new DirectionalFocusIntent(direction: TraversalDirection.right) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.arrowDown), |
|
|
|
new DirectionalFocusIntent(direction: TraversalDirection.down) |
|
|
|
}, |
|
|
|
{new LogicalKeySet(key1: LogicalKeyboardKey.arrowUp), new DirectionalFocusIntent()}, |
|
|
|
|
|
|
|
// Scrolling
|
|
|
|
{ |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.meta, key2: LogicalKeyboardKey.arrowUp), |
|
|
|
new ScrollIntent(direction: AxisDirection.up) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.meta, key2: LogicalKeyboardKey.arrowDown), |
|
|
|
new ScrollIntent(direction: AxisDirection.down) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.meta, key2: LogicalKeyboardKey.arrowLeft), |
|
|
|
new ScrollIntent(direction: AxisDirection.left) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.meta, key2: LogicalKeyboardKey.arrowRight), |
|
|
|
new ScrollIntent(direction: AxisDirection.right) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.pageUp), |
|
|
|
new ScrollIntent(direction: AxisDirection.up, type: ScrollIncrementType.page) |
|
|
|
}, { |
|
|
|
new LogicalKeySet(key1: LogicalKeyboardKey.pageDown), |
|
|
|
new ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page) |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
/// The default value of [WidgetsApp.actions].
|
|
|
|
public static readonly Dictionary<LocalKey, ActionFactory> defaultActions = |
|
|
|
new Dictionary<LocalKey, ActionFactory> { |
|
|
|
{DoNothingAction.key, () => new DoNothingAction()}, |
|
|
|
{RequestFocusAction.key, () => new RequestFocusAction()}, |
|
|
|
{NextFocusAction.key, () => new NextFocusAction()}, |
|
|
|
{PreviousFocusAction.key, () => new PreviousFocusAction()}, |
|
|
|
{DirectionalFocusAction.key, () => new DirectionalFocusAction()}, |
|
|
|
{ScrollAction.key, () => new ScrollAction()} |
|
|
|
}; |
|
|
|
|
|
|
|
public readonly Dictionary<LocalKey, ActionFactory> actions; |
|
|
|
public readonly bool checkerboardOffscreenLayers; |
|
|
|
public readonly bool checkerboardRasterCacheImages; |
|
|
|
public readonly Color color; |
|
|
|
public readonly bool debugShowCheckedModeBanner; |
|
|
|
public readonly bool debugShowWidgetInspector; |
|
|
|
public readonly InspectorSelectButtonBuilder inspectorSelectButtonBuilder; |
|
|
|
public readonly Locale locale; |
|
|
|
public readonly LocaleListResolutionCallback localeListResolutionCallback; |
|
|
|
public readonly LocaleResolutionCallback localeResolutionCallback; |
|
|
|
public readonly List<LocalizationsDelegate> localizationsDelegates; |
|
|
|
public readonly InitialRouteListFactory onGenerateInitialRoutes; |
|
|
|
public readonly InitialRouteListFactory onGenerateInitialRoutes; |
|
|
|
public readonly GenerateAppTitle onGenerateTitle; |
|
|
|
public readonly TextStyle textStyle; |
|
|
|
public readonly Window window; |
|
|
|
public readonly Dictionary<LogicalKeySet, Intent> shortcuts; |
|
|
|
public readonly Locale locale; |
|
|
|
public readonly List<LocalizationsDelegate> localizationsDelegates; |
|
|
|
public readonly LocaleListResolutionCallback localeListResolutionCallback; |
|
|
|
public readonly LocaleResolutionCallback localeResolutionCallback; |
|
|
|
public readonly bool showSemanticsDebugger; |
|
|
|
public readonly TextStyle textStyle; |
|
|
|
public readonly GenerateAppTitle onGenerateTitle; |
|
|
|
public readonly Color color; |
|
|
|
public readonly InspectorSelectButtonBuilder inspectorSelectButtonBuilder; |
|
|
|
|
|
|
|
public static bool showPerformanceOverlayOverride = false; |
|
|
|
public static bool debugShowWidgetInspectorOverride = false; |
|
|
|
public static bool debugAllowBannerOverride = true; |
|
|
|
public readonly bool debugShowCheckedModeBanner; |
|
|
|
public readonly bool checkerboardRasterCacheImages; |
|
|
|
public readonly bool checkerboardOffscreenLayers; |
|
|
|
public readonly bool showSemanticsDebugger; |
|
|
|
public readonly bool debugShowWidgetInspector; |
|
|
|
public readonly Dictionary<LogicalKeySet, Intent> shortcuts; |
|
|
|
public readonly Dictionary<LocalKey, ActionFactory> actions; |
|
|
|
|
|
|
|
public readonly Window window; |
|
|
|
|
|
|
|
public WidgetsApp( |
|
|
|
Key key = null, |
|
|
|
GlobalKey<NavigatorState> navigatorKey = null, |
|
|
|
|
|
|
InspectorSelectButtonBuilder inspectorSelectButtonBuilder = null, |
|
|
|
Dictionary<LogicalKeySet, Intent> shortcuts = null, |
|
|
|
Dictionary<LocalKey, ActionFactory> actions = null |
|
|
|
) : base(key) { |
|
|
|
|
|
|
|
) : base(key: key) { |
|
|
|
routes = routes ?? new Dictionary<string, WidgetBuilder>(); |
|
|
|
supportedLocales = supportedLocales ?? new List<Locale> {new Locale("en", "US")}; |
|
|
|
window = Window.instance; |
|
|
|
|
|
|
this.inspectorSelectButtonBuilder = inspectorSelectButtonBuilder; |
|
|
|
this.shortcuts = shortcuts; |
|
|
|
this.actions = actions; |
|
|
|
|
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
!this.routes.ContainsKey(Navigator.defaultRouteName), |
|
|
|
!this.routes.ContainsKey(key: Navigator.defaultRouteName), |
|
|
|
() => "If the home property is specified, the routes table " + |
|
|
|
"cannot include an entry for \" / \", since it would be redundant." |
|
|
|
); |
|
|
|
|
|
|
home != null || |
|
|
|
this.routes.ContainsKey(Navigator.defaultRouteName) || |
|
|
|
this.routes.ContainsKey(key: Navigator.defaultRouteName) || |
|
|
|
onGenerateRoute != null || |
|
|
|
onUnknownRoute != null, |
|
|
|
() => "Either the home property must be specified, " + |
|
|
|
|
|
|
"app is started with an intent that specifies an unknown route." |
|
|
|
); |
|
|
|
D.assert( |
|
|
|
(home != null || |
|
|
|
routes.isNotEmpty() || |
|
|
|
onGenerateRoute != null || |
|
|
|
onUnknownRoute != null) |
|
|
|
home != null || |
|
|
|
routes.isNotEmpty() || |
|
|
|
onGenerateRoute != null || |
|
|
|
onUnknownRoute != null |
|
|
|
(builder != null && |
|
|
|
navigatorKey == null && |
|
|
|
initialRoute == null && |
|
|
|
navigatorObservers.isEmpty()),()=> |
|
|
|
"If no route is provided using " + |
|
|
|
"home, routes, onGenerateRoute, or onUnknownRoute, " + |
|
|
|
"a non-null callback for the builder property must be provided, " + |
|
|
|
"and the other navigator-related properties, " + |
|
|
|
"navigatorKey, initialRoute, and navigatorObservers, " + |
|
|
|
"must have their initial values " + |
|
|
|
"(null, null, and the empty list, respectively)."); |
|
|
|
builder != null && |
|
|
|
navigatorKey == null && |
|
|
|
initialRoute == null && |
|
|
|
navigatorObservers.isEmpty(), () => |
|
|
|
"If no route is provided using " + |
|
|
|
"home, routes, onGenerateRoute, or onUnknownRoute, " + |
|
|
|
"a non-null callback for the builder property must be provided, " + |
|
|
|
"and the other navigator-related properties, " + |
|
|
|
"navigatorKey, initialRoute, and navigatorObservers, " + |
|
|
|
"must have their initial values " + |
|
|
|
"(null, null, and the empty list, respectively)."); |
|
|
|
|
|
|
|
D.assert( |
|
|
|
builder != null || |
|
|
|
|
|
|
"pageRouteBuilder must be specified so that the default handler " + |
|
|
|
"will know what kind of PageRoute transition to build." |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
public static readonly Dictionary<LogicalKeySet, Intent> _defaultShortcuts = new Dictionary<LogicalKeySet, Intent>(){ |
|
|
|
// Activation
|
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.enter), new Intent(ActivateAction.key)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.space), new Intent(ActivateAction.key)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.gameButtonA), new Intent(ActivateAction.key)}, |
|
|
|
|
|
|
|
// Keyboard traversal.
|
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.tab), new Intent(NextFocusAction.key)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.shift, LogicalKeyboardKey.tab), new Intent(PreviousFocusAction.key)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowLeft), new DirectionalFocusIntent(TraversalDirection.left)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowRight), new DirectionalFocusIntent(TraversalDirection.right)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowDown), new DirectionalFocusIntent(TraversalDirection.down)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowUp), new DirectionalFocusIntent(TraversalDirection.up)}, |
|
|
|
|
|
|
|
// Scrolling
|
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.arrowUp), new ScrollIntent(direction: AxisDirection.up)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.arrowDown), new ScrollIntent(direction: AxisDirection.down)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.arrowLeft), new ScrollIntent(direction: AxisDirection.left)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.arrowRight), new ScrollIntent(direction: AxisDirection.right)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.pageUp), new ScrollIntent(direction: AxisDirection.up, type: ScrollIncrementType.page)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.pageDown), new ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page)}, |
|
|
|
}; |
|
|
|
|
|
|
|
// Default shortcuts for the web platform.
|
|
|
|
public static readonly Dictionary<LogicalKeySet, Intent> _defaultWebShortcuts = new Dictionary<LogicalKeySet, Intent>(){ |
|
|
|
// Activation
|
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.space), new Intent(ActivateAction.key)}, |
|
|
|
} |
|
|
|
// Keyboard traversal.
|
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.tab), new Intent(NextFocusAction.key)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.shift, LogicalKeyboardKey.tab),new Intent(PreviousFocusAction.key)}, |
|
|
|
// Scrolling
|
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowUp), new ScrollIntent(direction: AxisDirection.up)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowDown), new ScrollIntent(direction: AxisDirection.down)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowLeft), new ScrollIntent(direction: AxisDirection.left)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.arrowRight), new ScrollIntent(direction: AxisDirection.right)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.pageUp), new ScrollIntent(direction: AxisDirection.up, type: ScrollIncrementType.page)}, |
|
|
|
{new widgets.LogicalKeySet(LogicalKeyboardKey.pageDown), new ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page)}, |
|
|
|
}; |
|
|
|
|
|
|
|
// Default shortcuts for the macOS platform.
|
|
|
|
public static readonly Dictionary<LogicalKeySet, Intent> _defaultMacOsShortcuts = new Dictionary<LogicalKeySet, Intent>(){ |
|
|
|
// Activation
|
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.enter), new Intent(ActivateAction.key)}, |
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.space), new Intent(ActivateAction.key)}, |
|
|
|
|
|
|
|
// Keyboard traversal
|
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.tab), new Intent(NextFocusAction.key)}, |
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.shift, LogicalKeyboardKey.tab), new Intent(PreviousFocusAction.key)}, |
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.arrowLeft), new DirectionalFocusIntent(TraversalDirection.left)}, |
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.arrowRight), new DirectionalFocusIntent(TraversalDirection.right)}, |
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.arrowDown), new DirectionalFocusIntent(TraversalDirection.down)}, |
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.arrowUp), new DirectionalFocusIntent(TraversalDirection.up)}, |
|
|
|
|
|
|
|
// Scrolling
|
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.arrowUp), new ScrollIntent(direction: AxisDirection.up)}, |
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.arrowDown), new ScrollIntent(direction: AxisDirection.down)}, |
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.arrowLeft), new ScrollIntent(direction: AxisDirection.left)}, |
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.arrowRight), new ScrollIntent(direction: AxisDirection.right)}, |
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.pageUp), new ScrollIntent(direction: AxisDirection.up, type: ScrollIncrementType.page)}, |
|
|
|
{new LogicalKeySet(LogicalKeyboardKey.pageDown), new ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page)}, |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (Application.platform) { |
|
|
|
case RuntimePlatform.Android: |
|
|
|
//case TargetPlatform.fuchsia:
|
|
|
|
|
|
|
// No keyboard support on iOS yet.
|
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
/// The default value of [WidgetsApp.actions].
|
|
|
|
public static readonly Dictionary<LocalKey, ActionFactory> defaultActions = new Dictionary<LocalKey, ActionFactory>(){ |
|
|
|
{DoNothingAction.key, () => new DoNothingAction()}, |
|
|
|
{RequestFocusAction.key, () => new RequestFocusAction()}, |
|
|
|
{NextFocusAction.key, () => new NextFocusAction()}, |
|
|
|
{PreviousFocusAction.key, () => new PreviousFocusAction()}, |
|
|
|
{DirectionalFocusAction.key, () => new DirectionalFocusAction()}, |
|
|
|
{ScrollAction.key, () => new ScrollAction()}, |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Locale _locale; |
|
|
|
|
|
|
|
GlobalKey<NavigatorState> _navigator; |
|
|
|
|
|
|
|
List<LocalizationsDelegate> _localizationsDelegates { |
|
|
|
get { |
|
|
|
var _delegates = new List<LocalizationsDelegate>(); |
|
|
|
if (widget.localizationsDelegates != null) { |
|
|
|
_delegates.AddRange(collection: widget.localizationsDelegates); |
|
|
|
} |
|
|
|
|
|
|
|
_delegates.Add(item: DefaultWidgetsLocalizations.del); |
|
|
|
return _delegates; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void didChangeMetrics() { |
|
|
|
setState(); |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void didChangeLocales(List<Locale> locale) { |
|
|
|
Locale newLocale = _resolveLocales(locale, widget.supportedLocales); |
|
|
|
var newLocale = _resolveLocales(preferredLocales: locale, supportedLocales: widget.supportedLocales); |
|
|
|
List<LocalizationsDelegate> _localizationsDelegates { |
|
|
|
get { |
|
|
|
List<LocalizationsDelegate> _delegates = new List<LocalizationsDelegate>(); |
|
|
|
if (widget.localizationsDelegates != null) { |
|
|
|
_delegates.AddRange(widget.localizationsDelegates); |
|
|
|
} |
|
|
|
public Future<bool> didPopRoute() { |
|
|
|
///async
|
|
|
|
D.assert(result: mounted); |
|
|
|
var navigator = _navigator?.currentState; |
|
|
|
if (navigator == null) { |
|
|
|
return Future.value(false).to<bool>(); |
|
|
|
} |
|
|
|
|
|
|
|
return navigator.maybePop<bool>(); |
|
|
|
} |
|
|
|
_delegates.Add(DefaultWidgetsLocalizations.del); |
|
|
|
return _delegates; |
|
|
|
public Future<bool> didPushRoute(string route) { |
|
|
|
D.assert(result: mounted); |
|
|
|
var navigator = _navigator?.currentState; |
|
|
|
if (navigator == null) { |
|
|
|
return Future.value(false).to<bool>(); |
|
|
|
|
|
|
|
navigator.pushNamed<bool>(routeName: route); |
|
|
|
return Future.value(true).to<bool>(); |
|
|
|
} |
|
|
|
|
|
|
|
public void didChangeAccessibilityFeatures() { |
|
|
|
} |
|
|
|
|
|
|
|
public override void initState() { |
|
|
|
|
|
|
_resolveLocales(new List<Locale> {new Locale("en", "US")}, widget.supportedLocales); |
|
|
|
_resolveLocales(new List<Locale> {new Locale("en", "US")}, supportedLocales: widget.supportedLocales); |
|
|
|
base.didUpdateWidget(oldWidget); |
|
|
|
base.didUpdateWidget(oldWidget: oldWidget); |
|
|
|
if (widget.navigatorKey != ((WidgetsApp) oldWidget).navigatorKey) { |
|
|
|
_updateNavigator(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
base.dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
GlobalKey<NavigatorState> _navigator; |
|
|
|
|
|
|
|
void _updateNavigator() { |
|
|
|
_navigator = widget.navigatorKey ?? new GlobalObjectKey<NavigatorState>(this); |
|
|
|
|
|
|
var name = settings.name; |
|
|
|
var pageContentBuilder = name == Navigator.defaultRouteName && widget.home != null |
|
|
|
? context => widget.home |
|
|
|
: widget.routes.getOrDefault(name); |
|
|
|
: widget.routes.getOrDefault(key: name); |
|
|
|
|
|
|
|
if (pageContentBuilder != null) { |
|
|
|
D.assert(widget.pageRouteBuilder != null, |
|
|
|
|
|
|
settings, |
|
|
|
pageContentBuilder |
|
|
|
settings: settings, |
|
|
|
builder: pageContentBuilder |
|
|
|
); |
|
|
|
D.assert(route != null, |
|
|
|
() => "The pageRouteBuilder for WidgetsApp must return a valid non-null Route."); |
|
|
|
|
|
|
if (widget.onGenerateRoute != null) { |
|
|
|
return widget.onGenerateRoute(settings); |
|
|
|
return widget.onGenerateRoute(settings: settings); |
|
|
|
public Future<bool> didPopRoute() { |
|
|
|
///async
|
|
|
|
D.assert(mounted); |
|
|
|
var navigator = _navigator?.currentState; |
|
|
|
if (navigator == null) { |
|
|
|
return Future.value(false).to<bool>(); |
|
|
|
} |
|
|
|
|
|
|
|
return navigator.maybePop<bool>(); |
|
|
|
} |
|
|
|
|
|
|
|
public Future<bool> didPushRoute(string route) { |
|
|
|
D.assert(mounted); |
|
|
|
var navigator = _navigator?.currentState; |
|
|
|
if (navigator == null) { |
|
|
|
return Future.value(false).to<bool>(); |
|
|
|
} |
|
|
|
|
|
|
|
navigator.pushNamed<bool>(route); |
|
|
|
return Future.value(true).to<bool>(); |
|
|
|
} |
|
|
|
|
|
|
|
public void didChangeAccessibilityFeatures() {} |
|
|
|
|
|
|
|
$"Generators for routes are searched for in the following order:\n" + |
|
|
|
"Generators for routes are searched for in the following order:\n" + |
|
|
|
" 1. For the \"/\" route, the \"home\" property, if non-null, is used.\n" + |
|
|
|
" 2. Otherwise, the \"routes\" table is used, if it has an entry for " + |
|
|
|
"the route.\n" + |
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
}); |
|
|
|
var result = widget.onUnknownRoute(settings) as Route<object>; |
|
|
|
var result = widget.onUnknownRoute(settings: settings) as Route<object>; |
|
|
|
D.assert(() => { |
|
|
|
if (result == null) { |
|
|
|
throw new UIWidgetsError( |
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
Locale _locale; |
|
|
|
|
|
|
|
Locale locale = |
|
|
|
widget.localeListResolutionCallback(preferredLocales, widget.supportedLocales); |
|
|
|
var locale = |
|
|
|
widget.localeListResolutionCallback(locales: preferredLocales, |
|
|
|
supportedLocales: widget.supportedLocales); |
|
|
|
if (locale != null) { |
|
|
|
return locale; |
|
|
|
} |
|
|
|
|
|
|
Locale locale = widget.localeResolutionCallback( |
|
|
|
var locale = widget.localeResolutionCallback( |
|
|
|
widget.supportedLocales |
|
|
|
supportedLocales: widget.supportedLocales |
|
|
|
); |
|
|
|
if (locale != null) { |
|
|
|
return locale; |
|
|
|
|
|
|
return basicLocaleListResolution(preferredLocales, supportedLocales); |
|
|
|
return basicLocaleListResolution(preferredLocales: preferredLocales, supportedLocales: supportedLocales); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Dictionary<string, Locale> allSupportedLocales = new Dictionary<string, Locale>(); |
|
|
|
Dictionary<string, Locale> languageAndCountryLocales = new Dictionary<string, Locale>(); |
|
|
|
Dictionary<string, Locale> languageAndScriptLocales = new Dictionary<string, Locale>(); |
|
|
|
Dictionary<string, Locale> languageLocales = new Dictionary<string, Locale>(); |
|
|
|
Dictionary<string, Locale> countryLocales = new Dictionary<string, Locale>(); |
|
|
|
foreach (Locale locale in supportedLocales) { |
|
|
|
var allSupportedLocales = new Dictionary<string, Locale>(); |
|
|
|
var languageAndCountryLocales = new Dictionary<string, Locale>(); |
|
|
|
var languageAndScriptLocales = new Dictionary<string, Locale>(); |
|
|
|
var languageLocales = new Dictionary<string, Locale>(); |
|
|
|
var countryLocales = new Dictionary<string, Locale>(); |
|
|
|
foreach (var locale in supportedLocales) { |
|
|
|
languageLocales.putIfAbsent(locale.languageCode, () => locale); |
|
|
|
countryLocales.putIfAbsent(locale.countryCode, () => locale); |
|
|
|
languageLocales.putIfAbsent(key: locale.languageCode, () => locale); |
|
|
|
countryLocales.putIfAbsent(key: locale.countryCode, () => locale); |
|
|
|
|
|
|
|
for (int localeIndex = 0; localeIndex < preferredLocales.Count; localeIndex++) { |
|
|
|
Locale userLocale = preferredLocales[localeIndex]; |
|
|
|
for (var localeIndex = 0; localeIndex < preferredLocales.Count; localeIndex++) { |
|
|
|
var userLocale = preferredLocales[index: localeIndex]; |
|
|
|
if (allSupportedLocales.ContainsKey(userLocale.languageCode + "_" + userLocale.scriptCode + "_" + |
|
|
|
userLocale.countryCode)) { |
|
|
|
return userLocale; |
|
|
|
|
|
|
Locale match = null; |
|
|
|
if (languageAndScriptLocales.TryGetValue(userLocale.languageCode + "_" + userLocale.scriptCode, |
|
|
|
out match)) { |
|
|
|
value: out match)) { |
|
|
|
if (match != null) { |
|
|
|
return match; |
|
|
|
} |
|
|
|
|
|
|
//Locale match = languageAndCountryLocales['${userLocale.languageCode}_${userLocale.countryCode}'];
|
|
|
|
Locale match = null; |
|
|
|
if (languageAndCountryLocales.TryGetValue(userLocale.languageCode + "_" + userLocale.countryCode, |
|
|
|
out match)) { |
|
|
|
value: out match)) { |
|
|
|
if (match != null) { |
|
|
|
return match; |
|
|
|
} |
|
|
|
|
|
|
return matchesLanguageCode; |
|
|
|
} |
|
|
|
|
|
|
|
if (languageLocales.ContainsKey(userLocale.languageCode)) { |
|
|
|
matchesLanguageCode = languageLocales[userLocale.languageCode]; |
|
|
|
if (languageLocales.ContainsKey(key: userLocale.languageCode)) { |
|
|
|
matchesLanguageCode = languageLocales[key: userLocale.languageCode]; |
|
|
|
|
|
|
|
if (localeIndex == 0 && |
|
|
|
!(localeIndex + 1 < preferredLocales.Count && preferredLocales[localeIndex + 1].languageCode == |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (matchesCountryCode == null && userLocale.countryCode != null) { |
|
|
|
if (countryLocales.ContainsKey(userLocale.countryCode)) { |
|
|
|
matchesCountryCode = countryLocales[userLocale.countryCode]; |
|
|
|
if (countryLocales.ContainsKey(key: userLocale.countryCode)) { |
|
|
|
matchesCountryCode = countryLocales[key: userLocale.countryCode]; |
|
|
|
Locale resolvedLocale = matchesLanguageCode ?? matchesCountryCode ?? supportedLocales.first(); |
|
|
|
var resolvedLocale = matchesLanguageCode ?? matchesCountryCode ?? supportedLocales.first(); |
|
|
|
return resolvedLocale; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HashSet<Type> unsupportedTypes = new HashSet<Type>(); |
|
|
|
var unsupportedTypes = new HashSet<Type>(); |
|
|
|
unsupportedTypes.Add(_delegate.type); |
|
|
|
unsupportedTypes.Add(item: _delegate.type); |
|
|
|
foreach ( LocalizationsDelegate _delegate in _localizationsDelegates) { |
|
|
|
if (!unsupportedTypes.Contains(_delegate.type)) |
|
|
|
|
|
|
|
foreach (var _delegate in _localizationsDelegates) { |
|
|
|
if (!unsupportedTypes.Contains(item: _delegate.type)) { |
|
|
|
if (_delegate.isSupported(appLocale)) |
|
|
|
unsupportedTypes.Remove(_delegate.type); |
|
|
|
} |
|
|
|
|
|
|
|
if (_delegate.isSupported(locale: appLocale)) { |
|
|
|
unsupportedTypes.Remove(item: _delegate.type); |
|
|
|
} |
|
|
|
if (unsupportedTypes.isEmpty()) |
|
|
|
|
|
|
|
if (unsupportedTypes.isEmpty()) { |
|
|
|
List<string> list = new List<string> {"CupertinoLocalizations"}; |
|
|
|
List<string> unsupportedTypesList = new List<string>(); |
|
|
|
} |
|
|
|
|
|
|
|
var list = new List<string> {"CupertinoLocalizations"}; |
|
|
|
var unsupportedTypesList = new List<string>(); |
|
|
|
if (unsupportedTypesList.SequenceEqual(list)) |
|
|
|
|
|
|
|
if (unsupportedTypesList.SequenceEqual(second: list)) { |
|
|
|
} |
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
var message = new StringBuilder(); |
|
|
|
"localization delegates." |
|
|
|
); |
|
|
|
foreach ( Type unsupportedType in unsupportedTypes) { |
|
|
|
|
|
|
|
if (unsupportedType.ToString() == "CupertinoLocalizations") |
|
|
|
"localization delegates." |
|
|
|
); |
|
|
|
foreach (var unsupportedType in unsupportedTypes) { |
|
|
|
if (unsupportedType.ToString() == "CupertinoLocalizations") { |
|
|
|
} |
|
|
|
|
|
|
|
"> A "+ unsupportedType + " delegate that supports the " + appLocale + "locale was not found." |
|
|
|
"> A " + unsupportedType + " delegate that supports the " + appLocale + "locale was not found." |
|
|
|
|
|
|
|
"information about configuring an app's locale, supportedLocales,\n" + |
|
|
|
"and localizationsDelegates parameters." |
|
|
|
); |
|
|
|
"information about configuring an app's locale, supportedLocales,\n" + |
|
|
|
"and localizationsDelegates parameters." |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
}); |
|
|
|
return true; |
|
|
|
|
|
|
Widget navigator = null; |
|
|
|
if (_navigator != null) { |
|
|
|
RouteListFactory routeListFactory = (state, route) => {return widget.onGenerateInitialRoutes(route); }; |
|
|
|
RouteListFactory routeListFactory = (state, route) => { |
|
|
|
return widget.onGenerateInitialRoutes(initialRoute: route); |
|
|
|
}; |
|
|
|
initialRoute: |
|
|
|
WidgetsBinding.instance.window.defaultRouteName != Navigator.defaultRouteName |
|
|
|
initialRoute: WidgetsBinding.instance.window.defaultRouteName != Navigator.defaultRouteName |
|
|
|
? WidgetsBinding.instance.window.defaultRouteName |
|
|
|
: widget.initialRoute ?? WidgetsBinding.instance.window.defaultRouteName, |
|
|
|
onGenerateRoute: _onGenerateRoute, |
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
builder: _context => { return widget.builder(_context, navigator); } |
|
|
|
); |
|
|
|
builder: context1 => { return widget.builder(context: context, child: navigator); }); |
|
|
|
} |
|
|
|
else { |
|
|
|
D.assert(navigator != null); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PerformanceOverlay performanceOverlay = null; |
|
|
|
|
|
|
|
|
|
|
|
} else if (widget.checkerboardRasterCacheImages || widget.checkerboardOffscreenLayers) { |
|
|
|
} |
|
|
|
else if (widget.checkerboardRasterCacheImages || widget.checkerboardOffscreenLayers) { |
|
|
|
performanceOverlay = new PerformanceOverlay( |
|
|
|
checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages, |
|
|
|
checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers |
|
|
|
|
|
|
|
|
|
|
new Positioned(top: 0.0f, |
|
|
|
left: 0.0f, |
|
|
|
right: 0.0f, |
|
|
|
child: performanceOverlay) |
|
|
|
}); |
|
|
|
new Positioned(top: 0.0f, left: 0.0f, right: 0.0f, child: performanceOverlay) |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
D.assert(() => { |
|
|
|
if (widget.debugShowWidgetInspector || WidgetsApp.debugShowWidgetInspectorOverride) { |
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
builder: (BuildContext context1)=> { |
|
|
|
string title1 = widget.onGenerateTitle(context1); |
|
|
|
D.assert(title1 != null,()=> "onGenerateTitle must return a non-null String"); |
|
|
|
return new Title( |
|
|
|
title: title1, |
|
|
|
color: widget.color, |
|
|
|
child: result |
|
|
|
); |
|
|
|
} |
|
|
|
builder: context2 => { |
|
|
|
var _title = widget.onGenerateTitle(context: context2); |
|
|
|
D.assert(_title != null, () => "onGenerateTitle must return a non-null String"); |
|
|
|
return new Title( |
|
|
|
title: _title, |
|
|
|
color: widget.color, |
|
|
|
child: result |
|
|
|
); |
|
|
|
} |
|
|
|
} else { |
|
|
|
} |
|
|
|
else { |
|
|
|
title = new Title( |
|
|
|
title: widget.title, |
|
|
|
color: widget.color, |
|
|
|
|
|
|
|
|
|
|
Locale appLocale = widget.locale != null |
|
|
|
? _resolveLocales(new List<Locale> {widget.locale}, widget.supportedLocales) |
|
|
|
var appLocale = widget.locale != null |
|
|
|
? _resolveLocales(new List<Locale> {widget.locale}, supportedLocales: widget.supportedLocales) |
|
|
|
D.assert(_debugCheckLocalizations(appLocale)); |
|
|
|
|
|
|
|
result = new Shortcuts( |
|
|
|
|
|
|
|
D.assert(_debugCheckLocalizations(appLocale: appLocale)); |
|
|
|
|
|
|
|
return new Shortcuts( |
|
|
|
shortcuts: widget.shortcuts ?? WidgetsApp.defaultShortcuts, |
|
|
|
debugLabel: "<Default WidgetsApp Shortcuts>", |
|
|
|
child: new Actions( |
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
return result; |
|
|
|
return new _InspectorSelectButton(onPressed); |
|
|
|
return new _InspectorSelectButton(onPressed: onPressed); |
|
|
|
public readonly Widget child; |
|
|
|
|
|
|
|
public readonly Widget child; |
|
|
|
|
|
|
|
class _MediaQueryFromWindowsState : State<_MediaQueryFromWindow>,WidgetsBindingObserver { |
|
|
|
public override void initState() { |
|
|
|
base.initState(); |
|
|
|
WidgetsBinding.instance.addObserver(this); |
|
|
|
class _MediaQueryFromWindowsState : State<_MediaQueryFromWindow>, WidgetsBindingObserver { |
|
|
|
public void didChangeAccessibilityFeatures() { |
|
|
|
setState(() => { }); |
|
|
|
public void didChangeAccessibilityFeatures() { |
|
|
|
setState(()=> { |
|
|
|
}); |
|
|
|
|
|
|
|
public void didChangeMetrics() { |
|
|
|
setState(() => { }); |
|
|
|
public void didChangeMetrics() { |
|
|
|
setState(()=>{ |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
public void didChangeTextScaleFactor() { |
|
|
|
setState(() => { }); |
|
|
|
public void didChangeTextScaleFactor() { |
|
|
|
setState(()=> { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
setState(()=> { |
|
|
|
}); |
|
|
|
setState(() => { }); |
|
|
|
} |
|
|
|
|
|
|
|
public void didChangeLocales(List<Locale> locale) { |
|
|
|
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
|
|
|
|
public override void initState() { |
|
|
|
base.initState(); |
|
|
|
WidgetsBinding.instance.addObserver(this); |
|
|
|
} |
|
|
|
|
|
|
|
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window), |
|
|
|
data: MediaQueryData.fromWindow(window: WidgetsBinding.instance.window), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _InspectorSelectButton : StatelessWidget { |
|
|
|
public readonly GestureTapCallback onPressed; |
|
|
|
|
|
|
|
|
|
|
) : base(key) { |
|
|
|
) : base(key: key) { |
|
|
|
this.onPressed = () => onPressed(); |
|
|
|
} |
|
|
|
|
|
|
|