Exemplo n.º 1
0
 public MaterialApp(
     Key key = null,
     GlobalKey <NavigatorState> navigatorKey = null,
     Widget home = null,
     Dictionary <string, WidgetBuilder> routes = null,
     string initialRoute          = null,
     RouteFactory onGenerateRoute = null,
     RouteFactory onUnknownRoute  = null,
     List <NavigatorObserver> navigatorObservers = null,
     TransitionBuilder builder = null,
     string title                = "",
     Color color                 = null,
     ThemeData theme             = null,
     bool showPerformanceOverlay = false,
     Window window               = null) : base(key: key)
 {
     D.assert(window != null);
     this.window                 = window;
     this.navigatorKey           = navigatorKey;
     this.home                   = home;
     this.routes                 = routes ?? new Dictionary <string, WidgetBuilder>();
     this.initialRoute           = initialRoute;
     this.onGenerateRoute        = onGenerateRoute;
     this.onUnknownRoute         = onUnknownRoute;
     this.navigatorObservers     = navigatorObservers ?? new List <NavigatorObserver>();
     this.builder                = builder;
     this.title                  = title;
     this.color                  = color;
     this.theme                  = theme;
     this.showPerformanceOverlay = showPerformanceOverlay;
 }
Exemplo n.º 2
0
 public MaterialApp(
     Key key = null,
     GlobalKey <NavigatorState> navigatorKey = null,
     Widget home = null,
     Dictionary <string, WidgetBuilder> routes = null,
     string initialRoute          = null,
     RouteFactory onGenerateRoute = null,
     InitialRouteListFactory onGenerateInitialRoutes = null,
     RouteFactory onUnknownRoute = null,
     List <NavigatorObserver> navigatorObservers = null,
     TransitionBuilder builder = null,
     string title = "",
     GenerateAppTitle onGenerateTitle = null,
     Color color         = null,
     ThemeData theme     = null,
     ThemeData darkTheme = null,
     ThemeMode themeMode = ThemeMode.system,
     Locale locale       = null,
     List <LocalizationsDelegate> localizationsDelegates       = null,
     LocaleListResolutionCallback localeListResolutionCallback = null,
     LocaleResolutionCallback localeResolutionCallback         = null,
     List <Locale> supportedLocales               = null,
     bool showPerformanceOverlay                  = false,
     bool checkerboardRasterCacheImages           = false,
     bool checkerboardOffscreenLayers             = false,
     bool debugShowCheckedModeBanner              = true,
     Dictionary <LogicalKeySet, Intent> shortcuts = null,
     Dictionary <LocalKey, ActionFactory> actions = null
     ) : base(key: key)
 {
     supportedLocales = supportedLocales ?? new List <Locale> {
         new Locale("en", "US")
     };
     this.navigatorKey                  = navigatorKey;
     this.home                          = home;
     this.routes                        = routes ?? new Dictionary <string, WidgetBuilder>();
     this.onGenerateInitialRoutes       = onGenerateInitialRoutes;
     this.initialRoute                  = initialRoute;
     this.onGenerateRoute               = onGenerateRoute;
     this.onUnknownRoute                = onUnknownRoute;
     this.navigatorObservers            = navigatorObservers ?? new List <NavigatorObserver>();
     this.builder                       = builder;
     this.title                         = title;
     this.onGenerateTitle               = onGenerateTitle;
     this.color                         = color;
     this.theme                         = theme;
     this.darkTheme                     = darkTheme;
     this.themeMode                     = themeMode;
     this.locale                        = locale;
     this.localizationsDelegates        = localizationsDelegates;
     this.localeListResolutionCallback  = localeListResolutionCallback;
     this.localeResolutionCallback      = localeResolutionCallback;
     this.supportedLocales              = supportedLocales;
     this.showPerformanceOverlay        = showPerformanceOverlay;
     this.checkerboardRasterCacheImages = checkerboardRasterCacheImages;
     this.checkerboardOffscreenLayers   = checkerboardOffscreenLayers;
     this.debugShowCheckedModeBanner    = debugShowCheckedModeBanner;
     this.shortcuts                     = shortcuts;
     this.actions                       = actions;
 }
Exemplo n.º 3
0
        public WidgetsApp(
            Key key = null,
            GlobalKey <NavigatorState> navigatorKey     = null,
            RouteFactory onGenerateRoute                = null,
            RouteFactory onUnknownRoute                 = null,
            PageRouteFactory pageRouteBuilder           = null,
            List <NavigatorObserver> navigatorObservers = null,
            string initialRoute = null,
            Dictionary <string, WidgetBuilder> routes = null,
            TransitionBuilder builder = null,
            Window window             = null,
            TextStyle textStyle       = null,
            Widget home = null
            ) : base(key)
        {
            D.assert(window != null);
            routes                  = routes ?? new Dictionary <string, WidgetBuilder>();
            this.window             = window;
            this.home               = home;
            this.navigatorKey       = navigatorKey;
            this.onGenerateRoute    = onGenerateRoute;
            this.onUnknownRoute     = onUnknownRoute;
            this.pageRouteBuilder   = pageRouteBuilder;
            this.routes             = routes;
            this.navigatorObservers = navigatorObservers ?? new List <NavigatorObserver>();
            this.initialRoute       = initialRoute;
            this.builder            = builder;
            this.textStyle          = textStyle;

            D.assert(
                home == null ||
                !this.routes.ContainsKey(Navigator.defaultRouteName),
                "If the home property is specified, the routes table " +
                "cannot include an entry for \" / \", since it would be redundant."
                );

            D.assert(
                builder != null ||
                home != null ||
                this.routes.ContainsKey(Navigator.defaultRouteName) ||
                onGenerateRoute != null ||
                onUnknownRoute != null,
                "Either the home property must be specified, " +
                "or the routes table must include an entry for \"/\", " +
                "or there must be on onGenerateRoute callback specified, " +
                "or there must be an onUnknownRoute callback specified, " +
                "or the builder property must be specified, " +
                "because otherwise there is nothing to fall back on if the " +
                "app is started with an intent that specifies an unknown route."
                );

            D.assert(
                builder != null ||
                onGenerateRoute != null ||
                pageRouteBuilder != null,
                "If neither builder nor onGenerateRoute are provided, the " +
                "pageRouteBuilder must be specified so that the default handler " +
                "will know what kind of PageRoute transition to build."
                );
        }
Exemplo n.º 4
0
 public AnimatedBuilder(Key key      = null, Listenable animation = null, TransitionBuilder builder = null,
                        Widget child = null) :
     base(key, animation)
 {
     D.assert(builder != null);
     this.builder = builder;
     this.child   = child;
 }
Exemplo n.º 5
0
        public CupertinoApp(
            Key key = null,
            GlobalKey <NavigatorState> navigatorKey = null,
            Widget home = null,
            CupertinoThemeData theme = null,
            Dictionary <string, WidgetBuilder> routes = null,
            string initialRoute          = null,
            RouteFactory onGenerateRoute = null,
            RouteFactory onUnknownRoute  = null,
            List <NavigatorObserver> navigatorObservers = null,
            TransitionBuilder builder = null,
            string title = "",
            GenerateAppTitle onGenerateTitle = null,
            Color color   = null,
            Locale locale = null,
            List <LocalizationsDelegate <CupertinoLocalizations> > localizationsDelegates = null,
            LocaleListResolutionCallback localeListResolutionCallback = null,
            LocaleResolutionCallback localeResolutionCallback         = null,
            List <Locale> supportedLocales = null,
            bool showPerformanceOverlay    = false
            ) : base(key: key)
        {
            D.assert(title != null);

            supportedLocales = supportedLocales ?? new List <Locale> {
                new Locale("en", "US")
            };
            this.navigatorKey                 = navigatorKey;
            this.home                         = home;
            this.theme                        = theme;
            this.routes                       = routes ?? new Dictionary <string, WidgetBuilder>();
            this.initialRoute                 = initialRoute;
            this.onGenerateRoute              = onGenerateRoute;
            this.onUnknownRoute               = onUnknownRoute;
            this.navigatorObservers           = navigatorObservers ?? new List <NavigatorObserver>();
            this.builder                      = builder;
            this.title                        = title;
            this.onGenerateTitle              = onGenerateTitle;
            this.color                        = color;
            this.locale                       = locale;
            this.localizationsDelegates       = localizationsDelegates;
            this.localeListResolutionCallback = localeListResolutionCallback;
            this.localeResolutionCallback     = localeResolutionCallback;
            this.supportedLocales             = supportedLocales;
            this.showPerformanceOverlay       = showPerformanceOverlay;
        }
Exemplo n.º 6
0
        /// <summary>
        /// 创建跳转节点(强制拉取跳转方式,后续节点状态可以强制拉取前置节点到当前节点[后续节点])
        /// </summary>
        /// <param name="fromActivity">要拉取的节点</param>
        /// <param name="toActivity">拉取到节点</param>
        /// <returns></returns>
        internal static NextActivityComponent CreateNextActivityComponent(ActivityEntity fromActivity,
                                                                          ActivityEntity toActivity)
        {
            NextActivityComponent component = null;

            if (XPDLHelper.IsSimpleComponentNode(fromActivity.ActivityType) == true)       //可流转简单类型节点
            {
                string name       = "单一节点";
                var    transition = TransitionBuilder.CreateJumpforwardEmptyTransition(fromActivity, toActivity);

                component = new NextActivityItem(name, transition, fromActivity);     //强制拉取跳转类型的transition 为空类型
            }
            else
            {
                throw new ApplicationException(string.Format("不能跳转到其它非任务类型的节点!当前节点:{0}",
                                                             fromActivity.ActivityType));
            }
            return(component);
        }
Exemplo n.º 7
0
        public static IPromise <object> showDatePicker(
            BuildContext context,
            DateTime initialDate,
            DateTime firstDate,
            DateTime lastDate,
            SelectableDayPredicate selectableDayPredicate = null,
            DatePickerMode initialDatePickerMode          = DatePickerMode.day,
            Locale locale             = null,
            TransitionBuilder builder = null
            )
        {
            D.assert(initialDate >= firstDate, () => "initialDate must be on or after firstDate");
            D.assert(initialDate <= lastDate, () => "initialDate must be on or before lastDate");
            D.assert(firstDate <= lastDate, () => "lastDate must be on or after firstDate");
            D.assert(
                selectableDayPredicate == null || selectableDayPredicate(initialDate),
                () => "Provided initialDate must satisfy provided selectableDayPredicate"
                );
            D.assert(context != null);
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));

            Widget child = new _DatePickerDialog(
                initialDate: initialDate,
                firstDate: firstDate,
                lastDate: lastDate,
                selectableDayPredicate: selectableDayPredicate,
                initialDatePickerMode: initialDatePickerMode
                );

            if (locale != null)
            {
                child = Localizations.overrides(
                    context: context,
                    locale: locale,
                    child: child
                    );
            }

            return(DialogUtils.showDialog(
                       context: context,
                       builder: (BuildContext _context) => { return builder == null ? child : builder(_context, child); }
                       ));
        }
Exemplo n.º 8
0
 public Hero(
     Key key    = null,
     object tag = null,
     CreateRectTween createRectTween = null,
     HeroFlightShuttleBuilder flightShuttleBuilder = null,
     TransitionBuilder placeholderBuilder          = null,
     bool transitionOnUserGestures = false,
     Widget child = null
     ) : base(key: key)
 {
     D.assert(tag != null);
     D.assert(child != null);
     this.tag                      = tag;
     this.createRectTween          = createRectTween;
     this.child                    = child;
     this.flightShuttleBuilder     = flightShuttleBuilder;
     this.placeholderBuilder       = placeholderBuilder;
     this.transitionOnUserGestures = transitionOnUserGestures;
 }
Exemplo n.º 9
0
        public WidgetsApp(
            Key key = null,
            GlobalKey <NavigatorState> navigatorKey         = null,
            RouteFactory onGenerateRoute                    = null,
            InitialRouteListFactory onGenerateInitialRoutes = null,
            RouteFactory onUnknownRoute = null,
            List <NavigatorObserver> navigatorObservers = null,
            string initialRoute = null,
            PageRouteFactory pageRouteBuilder = null,
            Widget home = null,
            Dictionary <string, WidgetBuilder> routes = null,
            TransitionBuilder builder = null,
            string title = "",
            GenerateAppTitle onGenerateTitle = null,
            TextStyle textStyle = null,
            Color color         = null,
            Locale locale       = null,
            List <LocalizationsDelegate> localizationsDelegates       = null,
            LocaleListResolutionCallback localeListResolutionCallback = null,
            LocaleResolutionCallback localeResolutionCallback         = null,
            List <Locale> supportedLocales     = null,
            bool showPerformanceOverlay        = false,
            bool checkerboardRasterCacheImages = false,
            bool checkerboardOffscreenLayers   = false,
            bool showSemanticsDebugger         = false,
            bool debugShowWidgetInspector      = false,
            bool debugShowCheckedModeBanner    = true,
            InspectorSelectButtonBuilder inspectorSelectButtonBuilder = null,
            Dictionary <LogicalKeySet, Intent> shortcuts = null,
            Dictionary <LocalKey, ActionFactory> actions = null
            ) : base(key: key)
        {
            routes           = routes ?? new Dictionary <string, WidgetBuilder>();
            supportedLocales = supportedLocales ?? new List <Locale> {
                new Locale("en", "US")
            };
            window = Window.instance;
            D.assert(routes != null);
            D.assert(color != null);
            D.assert(supportedLocales != null && supportedLocales.isNotEmpty());
            this.home                          = home;
            this.navigatorKey                  = navigatorKey;
            this.onGenerateRoute               = onGenerateRoute;
            this.onGenerateInitialRoutes       = onGenerateInitialRoutes;
            this.onUnknownRoute                = onUnknownRoute;
            this.pageRouteBuilder              = pageRouteBuilder;
            this.routes                        = routes;
            this.navigatorObservers            = navigatorObservers ?? new List <NavigatorObserver>();
            this.initialRoute                  = initialRoute;
            this.builder                       = builder;
            this.textStyle                     = textStyle;
            this.locale                        = locale;
            this.localizationsDelegates        = localizationsDelegates;
            this.localeListResolutionCallback  = localeListResolutionCallback;
            this.localeResolutionCallback      = localeResolutionCallback;
            this.supportedLocales              = supportedLocales;
            this.showPerformanceOverlay        = showPerformanceOverlay;
            this.checkerboardOffscreenLayers   = checkerboardOffscreenLayers;
            this.checkerboardRasterCacheImages = checkerboardRasterCacheImages;
            this.showSemanticsDebugger         = showSemanticsDebugger;
            this.debugShowWidgetInspector      = debugShowWidgetInspector;
            this.debugShowCheckedModeBanner    = debugShowCheckedModeBanner;
            this.onGenerateTitle               = onGenerateTitle;
            this.title                         = title;
            this.color                         = color;
            this.inspectorSelectButtonBuilder  = inspectorSelectButtonBuilder;
            this.shortcuts                     = shortcuts;
            this.actions                       = actions;

            D.assert(
                home == null ||
                onGenerateInitialRoutes == null,
                () => "If onGenerateInitialRoutes is specifiied, the home argument will be redundant."
                );
            D.assert(
                home == null ||
                !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."
                );

            D.assert(
                builder != null ||
                home != null ||
                this.routes.ContainsKey(key: Navigator.defaultRouteName) ||
                onGenerateRoute != null ||
                onUnknownRoute != null,
                () => "Either the home property must be specified, " +
                "or the routes table must include an entry for \"/\", " +
                "or there must be on onGenerateRoute callback specified, " +
                "or there must be an onUnknownRoute callback specified, " +
                "or the builder property must be specified, " +
                "because otherwise there is nothing to fall back on if the " +
                "app is started with an intent that specifies an unknown route."
                );
            D.assert(
                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).");

            D.assert(
                builder != null ||
                onGenerateRoute != null ||
                pageRouteBuilder != null,
                () => "If neither builder nor onGenerateRoute are provided, the " +
                "pageRouteBuilder must be specified so that the default handler " +
                "will know what kind of PageRoute transition to build."
                );
        }
Exemplo n.º 10
0
        public WidgetsApp(
            Key key = null,
            GlobalKey <NavigatorState> navigatorKey     = null,
            RouteFactory onGenerateRoute                = null,
            RouteFactory onUnknownRoute                 = null,
            PageRouteFactory pageRouteBuilder           = null,
            List <NavigatorObserver> navigatorObservers = null,
            string initialRoute = null,
            Dictionary <string, WidgetBuilder> routes = null,
            TransitionBuilder builder = null,
            TextStyle textStyle       = null,
            Widget home   = null,
            Locale locale = null,
            List <LocalizationsDelegate> localizationsDelegates       = null,
            LocaleListResolutionCallback localeListResolutionCallback = null,
            LocaleResolutionCallback localeResolutionCallback         = null,
            List <Locale> supportedLocales   = null,
            bool showPerformanceOverlay      = false,
            GenerateAppTitle onGenerateTitle = null,
            string title = "",
            Color color  = null,
            InspectorSelectButtonBuilder inspectorSelectButtonBuilder = null
            ) : base(key)
        {
            routes           = routes ?? new Dictionary <string, WidgetBuilder>();
            supportedLocales = supportedLocales ?? new List <Locale> {
                new Locale("en", "US")
            };
            this.window                       = Window.instance;
            this.home                         = home;
            this.navigatorKey                 = navigatorKey;
            this.onGenerateRoute              = onGenerateRoute;
            this.onUnknownRoute               = onUnknownRoute;
            this.pageRouteBuilder             = pageRouteBuilder;
            this.routes                       = routes;
            this.navigatorObservers           = navigatorObservers ?? new List <NavigatorObserver>();
            this.initialRoute                 = initialRoute;
            this.builder                      = builder;
            this.textStyle                    = textStyle;
            this.locale                       = locale;
            this.localizationsDelegates       = localizationsDelegates;
            this.localeListResolutionCallback = localeListResolutionCallback;
            this.localeResolutionCallback     = localeResolutionCallback;
            this.supportedLocales             = supportedLocales;
            this.showPerformanceOverlay       = showPerformanceOverlay;

            this.onGenerateTitle = onGenerateTitle;
            this.title           = title;
            this.color           = color;
            this.inspectorSelectButtonBuilder = inspectorSelectButtonBuilder;

            D.assert(
                home == null ||
                !this.routes.ContainsKey(Navigator.defaultRouteName),
                () => "If the home property is specified, the routes table " +
                "cannot include an entry for \" / \", since it would be redundant."
                );

            D.assert(
                builder != null ||
                home != null ||
                this.routes.ContainsKey(Navigator.defaultRouteName) ||
                onGenerateRoute != null ||
                onUnknownRoute != null,
                () => "Either the home property must be specified, " +
                "or the routes table must include an entry for \"/\", " +
                "or there must be on onGenerateRoute callback specified, " +
                "or there must be an onUnknownRoute callback specified, " +
                "or the builder property must be specified, " +
                "because otherwise there is nothing to fall back on if the " +
                "app is started with an intent that specifies an unknown route."
                );

            D.assert(
                builder != null ||
                onGenerateRoute != null ||
                pageRouteBuilder != null,
                () => "If neither builder nor onGenerateRoute are provided, the " +
                "pageRouteBuilder must be specified so that the default handler " +
                "will know what kind of PageRoute transition to build."
                );
        }
        public static Future <DateTime> showDatePicker(
            BuildContext context,
            DateTime initialDate,
            DateTime firstDate,
            DateTime lastDate,
            DatePickerEntryMode initialEntryMode = DatePickerEntryMode.calendar,
            material_.SelectableDayPredicate selectableDayPredicate = null,
            string helpText                      = null,
            string cancelText                    = null,
            string confirmText                   = null,
            Locale locale                        = null,
            bool useRootNavigator                = true,
            RouteSettings routeSettings          = null,
            TextDirection?textDirection          = null,
            TransitionBuilder builder            = null,
            DatePickerMode initialDatePickerMode = DatePickerMode.day,
            string errorFormatText               = null,
            string errorInvalidText              = null,
            string fieldHintText                 = null,
            string fieldLabelText                = null
            )
        {
            D.assert(context != null);
            initialDate = utils.dateOnly(initialDate);
            firstDate   = utils.dateOnly(firstDate);
            lastDate    = utils.dateOnly(lastDate);

            D.assert(
                !lastDate.isBefore(firstDate),
                () => $"lastDate {lastDate} must be on or after firstDate {firstDate}."
                );
            D.assert(
                !initialDate.isBefore(firstDate),
                () => $"initialDate {initialDate} must be on or after firstDate {firstDate}."
                );
            D.assert(
                !initialDate.isAfter(lastDate),
                () => $"initialDate {initialDate} must be on or before lastDate {lastDate}."
                );
            D.assert(
                selectableDayPredicate == null || selectableDayPredicate(initialDate),
                () => $"Provided initialDate {initialDate} must satisfy provided selectableDayPredicate."
                );

            D.assert(initialEntryMode != null);
            D.assert(initialDatePickerMode != null);
            D.assert(material_.debugCheckHasMaterialLocalizations(context));

            Widget dialog = new _DatePickerDialog(
                initialDate: initialDate,
                firstDate: firstDate,
                lastDate: lastDate,
                initialEntryMode: initialEntryMode,
                selectableDayPredicate: selectableDayPredicate,
                helpText: helpText,
                cancelText: cancelText,
                confirmText: confirmText,
                initialCalendarMode: initialDatePickerMode,
                errorFormatText: errorFormatText,
                errorInvalidText: errorInvalidText,
                fieldHintText: fieldHintText,
                fieldLabelText: fieldLabelText
                );

            if (textDirection != null)
            {
                dialog = new Directionality(
                    textDirection: textDirection.Value,
                    child: dialog
                    );
            }

            if (locale != null)
            {
                dialog = Localizations.overrides(
                    context: context,
                    locale: locale,
                    child: dialog
                    );
            }

            return(material_.showDialog <DateTime>(
                       context: context,
                       useRootNavigator: useRootNavigator,
                       routeSettings: routeSettings,
                       builder: (BuildContext subContext) => { return builder == null ? dialog : builder(subContext, dialog); }
                       ));
        }