Ejemplo n.º 1
0
        public override Widget buildPage(BuildContext context, Animation <float> animation,
                                         Animation <float> secondaryAnimation)
        {
            BottomSheetThemeData sheetTheme = theme?.bottomSheetTheme ?? Theme.of(context).bottomSheetTheme;

            Widget bottomSheet = MediaQuery.removePadding(
                context: context,
                removeTop: true,
                child: new _ModalBottomSheet <T>(
                    route: this,
                    backgroundColor: backgroundColor ?? sheetTheme?.modalBackgroundColor ?? sheetTheme?.backgroundColor,
                    elevation: elevation ?? sheetTheme?.modalElevation ?? sheetTheme?.elevation,
                    shape: shape,
                    clipBehavior: clipBehavior,
                    isScrollControlled: isScrollControlled ?? false,
                    enableDrag: enableDrag
                    )
                );

            if (theme != null)
            {
                bottomSheet = new Theme(data: theme, child: bottomSheet);
            }

            return(bottomSheet);
        }
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            ThemeData theme           = Theme.of(context);
            float     statusBarHeight = MediaQuery.of(context).padding.top;

            return(new Container(
                       height: statusBarHeight + DrawerHeaderUtils._kDrawerHeaderHeight,
                       margin: this.margin,
                       decoration: new BoxDecoration(
                           border: new Border(
                               bottom: Divider.createBorderSide(context)
                               )
                           ),
                       child: new AnimatedContainer(
                           padding: this.padding.add(EdgeInsets.only(top: statusBarHeight)),
                           decoration: this.decoration,
                           duration: this.duration,
                           curve: this.curve,
                           child: this.child == null
                        ? null
                        : new DefaultTextStyle(
                               style: theme.textTheme.body2,
                               child: MediaQuery.removePadding(
                                   context: context,
                                   removeTop: true,
                                   child: this.child)
                               )
                           )
                       ));
        }
Ejemplo n.º 3
0
        public override Widget build(BuildContext context)
        {
            D.assert(WidgetsD.debugCheckHasDirectionality(context));
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));

            float additionalBottomPadding =
                Mathf.Max(MediaQuery.of(context).padding.bottom - BottomNavigationBarUtils._kBottomMargin, 0.0f);
            Color backgroundColor = null;

            switch (this.widget.type)
            {
            case BottomNavigationBarType.fix:
                break;

            case BottomNavigationBarType.shifting:
                backgroundColor = this._backgroundColor;
                break;
            }

            return(new Stack(
                       children: new List <Widget>
            {
                Positioned.fill(
                    child: new Material(     // Casts shadow.
                        elevation: 8.0f,
                        color: backgroundColor
                        )
                    ),
                new ConstrainedBox(
                    constraints: new BoxConstraints(
                        minHeight: Constants.kBottomNavigationBarHeight + additionalBottomPadding),
                    child: new Stack(
                        children: new List <Widget>
                {
                    Positioned.fill(
                        child: new CustomPaint(
                            painter: new _RadialPainter(
                                circles: this._circles.ToList()
                                )
                            )
                        ),
                    new Material(             // Splashes.
                        type: MaterialType.transparency,
                        child: new Padding(
                            padding: EdgeInsets.only(bottom: additionalBottomPadding),
                            child: MediaQuery.removePadding(
                                context: context,
                                removeBottom: true,
                                child: this._createContainer(this._createTiles())
                                )
                            )
                        )
                }
                        )
                    )
            }
                       ));
        }
Ejemplo n.º 4
0
        public override Widget buildPage(BuildContext context, Animation <float> animation,
                                         Animation <float> secondaryAnimation)
        {
            int?selectedItemIndex = null;

            if (initialValue != null)
            {
                for (int index = 0; selectedItemIndex == null && index < items.Count; index += 1)
                {
                    if (items[index].represents(initialValue))
                    {
                        selectedItemIndex = index;
                    }
                }
            }

            Widget menu = new _PopupMenu <T>(route: this);

            if (captureInheritedThemes ?? false)
            {
                menu = InheritedTheme.captureAll(showMenuContext, menu);
            }
            else
            {
                if (theme != null)
                {
                    menu = new Theme(data: theme, child: menu);
                }
            }

            return(MediaQuery.removePadding(
                       context: context,
                       removeTop: true,
                       removeBottom: true,
                       removeLeft: true,
                       removeRight: true,
                       child: new Builder(
                           builder: _ => new CustomSingleChildLayout(
                               layoutDelegate: new _PopupMenuRouteLayout(
                                   position,
                                   itemSizes,
                                   selectedItemIndex ?? 0,
                                   Directionality.of(context)
                                   ),
                               child: menu
                               ))
                       ));
        }
Ejemplo n.º 5
0
        public override Widget buildPage(BuildContext context, Animation <float> animation,
                                         Animation <float> secondaryAnimation)
        {
            Widget bottomSheet = MediaQuery.removePadding(
                context: context,
                removeTop: true,
                child: new _ModalBottomSheet <T>(route: this)
                );

            if (this.theme != null)
            {
                bottomSheet = new Theme(data: this.theme, child: bottomSheet);
            }

            return(bottomSheet);
        }
Ejemplo n.º 6
0
        public override Widget build(BuildContext context)
        {
            D.assert(WidgetsD.debugCheckHasDirectionality(context));
            D.assert(material_.debugCheckHasMaterialLocalizations(context));

            float additionalBottomPadding =
                Mathf.Max(MediaQuery.of(context).padding.bottom - widget.selectedFontSize / 2.0f, 0.0f);
            Color backgroundColor = null;

            switch (widget.type)
            {
            case BottomNavigationBarType.fix:
                backgroundColor = widget.backgroundColor;
                break;

            case BottomNavigationBarType.shifting:
                backgroundColor = _backgroundColor;
                break;
            }


            return(new Material(
                       elevation: widget.elevation,
                       color: backgroundColor,
                       child: new ConstrainedBox(
                           constraints: new BoxConstraints(
                               minHeight: material_.kBottomNavigationBarHeight + additionalBottomPadding),
                           child: new CustomPaint(
                               painter: new _RadialPainter(
                                   circles: _circles.ToList()
                                   ),
                               child: new Material( // Splashes.
                                   type: MaterialType.transparency,
                                   child: new Padding(
                                       padding: EdgeInsets.only(bottom: additionalBottomPadding),
                                       child: MediaQuery.removePadding(
                                           context: context,
                                           removeBottom: true,
                                           child: _createContainer(_createTiles())
                                           )
                                       )
                                   )
                               )
                           )
                       ));
        }
Ejemplo n.º 7
0
        public override Widget build(BuildContext context)
        {
            D.assert(WidgetsD.debugCheckHasDirectionality(context));
            if (route.scrollController == null)
            {
                _MenuLimits menuLimits = route.getMenuLimits(buttonRect, constraints.maxHeight, selectedIndex ?? 0);
                route.scrollController = new ScrollController(initialScrollOffset: menuLimits.scrollOffset ?? 0);
            }

            TextDirection textDirection = Directionality.of(context);
            Widget        menu          = new _DropdownMenu <T>(
                route: route,
                padding: padding.resolve(textDirection),
                buttonRect: buttonRect,
                constraints: constraints,
                dropdownColor: dropdownColor
                );

            if (theme != null)
            {
                menu = new Theme(data: theme, child: menu);
            }

            return(MediaQuery.removePadding(
                       context: context,
                       removeTop: true,
                       removeBottom: true,
                       removeLeft: true,
                       removeRight: true,
                       child: new Builder(
                           builder: (BuildContext _context) => {
                return new CustomSingleChildLayout(
                    layoutDelegate: new _DropdownMenuRouteLayout <T>(
                        buttonRect: buttonRect,
                        route: route,
                        textDirection: textDirection
                        ),
                    child: menu
                    );
            }
                           )
                       ));
        }
Ejemplo n.º 8
0
        public override Widget build(BuildContext context)
        {
            D.assert(!widget.primary || WidgetsD.debugCheckHasMediaQuery(context));
            float?topPadding      = widget.primary ? MediaQuery.of(context).padding.top : 0.0f;
            float?collapsedHeight = (widget.pinned && widget.floating && widget.bottom != null)
                ? widget.bottom.preferredSize.height + topPadding
                : null;

            return(MediaQuery.removePadding(
                       context: context,
                       removeBottom: true,
                       child: new SliverPersistentHeader(
                           floating: widget.floating,
                           pinned: widget.pinned,
                           del: new _SliverAppBarDelegate(
                               leading: widget.leading,
                               automaticallyImplyLeading: widget.automaticallyImplyLeading,
                               title: widget.title,
                               actions: widget.actions,
                               flexibleSpace: widget.flexibleSpace,
                               bottom: widget.bottom,
                               elevation: widget.elevation,
                               forceElevated: widget.forceElevated,
                               backgroundColor: widget.backgroundColor,
                               brightness: widget.brightness,
                               iconTheme: widget.iconTheme,
                               actionsIconTheme: widget.actionsIconTheme,
                               textTheme: widget.textTheme,
                               primary: widget.primary,
                               centerTitle: widget.centerTitle,
                               titleSpacing: widget.titleSpacing,
                               expandedHeight: widget.expandedHeight,
                               collapsedHeight: collapsedHeight,
                               topPadding: topPadding,
                               floating: widget.floating,
                               pinned: widget.pinned,
                               shape: widget.shape,
                               snapConfiguration: _snapConfiguration,
                               stretchConfiguration: _stretchConfiguration
                               )
                           )
                       ));
        }
Ejemplo n.º 9
0
        public override Widget buildPage(BuildContext context, Animation <float> animation,
                                         Animation <float> secondaryAnimation)
        {
            float?selectedItemOffset = null;

            if (this.initialValue != null)
            {
                float y = PopupMenuUtils._kMenuVerticalPadding;
                foreach (PopupMenuEntry <T> entry in this.items)
                {
                    if (entry.represents((T)this.initialValue))
                    {
                        selectedItemOffset = y + entry.height / 2.0f;
                        break;
                    }

                    y += entry.height;
                }
            }

            Widget menu = new _PopupMenu <T>(route: this);

            if (this.theme != null)
            {
                menu = new Theme(data: this.theme, child: menu);
            }

            return(MediaQuery.removePadding(
                       context: context,
                       removeTop: true,
                       removeBottom: true,
                       removeLeft: true,
                       removeRight: true,
                       child: new Builder(
                           builder: _ => new CustomSingleChildLayout(
                               layoutDelegate: new _PopupMenuRouteLayout(
                                   this.position,
                                   selectedItemOffset
                                   ),
                               child: menu
                               ))
                       ));
        }
Ejemplo n.º 10
0
 public override Widget build(BuildContext context)
 {
     return(new Scaffold(
                drawerDragStartBehavior: DragStartBehavior.down,
                key: this._scaffoldKey,
                appBar: new AppBar(
                    leading: new IconButton(
                        icon: new Icon(this._backIcon()),
                        alignment: Alignment.centerLeft,
                        tooltip: "Back",
                        onPressed: () => { Navigator.pop <object>(context); }
                        ),
                    title: new Text("Navigation drawer"),
                    actions: new List <Widget> {
         new MaterialDemoDocumentationButton(DrawerDemo.routeName)
     }
                    ),
                drawer: new Drawer(
                    child: new Column(
                        children: new List <Widget>
     {
         new UserAccountsDrawerHeader(
             accountName: new Text("Trevor Widget"),
             accountEmail: new Text("*****@*****.**"),
             currentAccountPicture: new CircleAvatar(
                 backgroundImage: new FileImage(
                     DrawerDemoUtils._kAsset0
                     )
                 ),
             otherAccountsPictures: new List <Widget>
         {
             new GestureDetector(
                 dragStartBehavior: DragStartBehavior.down,
                 onTap: () => { this._onOtherAccountsTap(context); },
                 child: new CircleAvatar(
                     backgroundImage: new FileImage(
                         DrawerDemoUtils._kAsset1
                         )
                     )
                 ),
             new GestureDetector(
                 dragStartBehavior: DragStartBehavior.down,
                 onTap: () => { this._onOtherAccountsTap(context); },
                 child: new CircleAvatar(
                     backgroundImage: new FileImage(
                         DrawerDemoUtils._kAsset2
                         )
                     )
                 )
         },
             margin: EdgeInsets.zero,
             onDetailsPressed: () =>
         {
             this._showDrawerContents = !this._showDrawerContents;
             if (this._showDrawerContents)
             {
                 this._controller.reverse();
             }
             else
             {
                 this._controller.forward();
             }
         }
             ),
         MediaQuery.removePadding(
             context: context,
             // DrawerHeader consumes top MediaQuery padding.
             removeTop: true,
             child: new Expanded(
                 child: new ListView(
                     dragStartBehavior: DragStartBehavior.down,
                     padding: EdgeInsets.only(top: 8.0f),
                     children: new List <Widget>
         {
             new Stack(
                 children: new List <Widget>
             {
                 // The initial contents of the drawer.
                 new FadeTransition(
                     opacity: this._drawerContentsOpacity,
                     child: new Column(
                         mainAxisSize: MainAxisSize.min,
                         crossAxisAlignment: CrossAxisAlignment.stretch,
                         children: _drawerContents.Select <string, Widget>(
                             (string id) =>
                 {
                     return new ListTile(
                         leading: new CircleAvatar(child: new Text(id)),
                         title: new Text($"Drawer item {id}"),
                         onTap: this._showNotImplementedMessage
                         );
                 }).ToList()
                         )
                     ),
                 // The drawer"s "details" view.
                 new SlideTransition(
                     position: this._drawerDetailsPosition,
                     child: new FadeTransition(
                         opacity: new ReverseAnimation(this._drawerContentsOpacity),
                         child: new Column(
                             mainAxisSize: MainAxisSize.min,
                             crossAxisAlignment: CrossAxisAlignment.stretch,
                             children: new List <Widget>
                 {
                     new ListTile(
                         leading: new Icon(Icons.add),
                         title: new Text("Add account"),
                         onTap: this._showNotImplementedMessage
                         ),
                     new ListTile(
                         leading: new Icon(Icons.settings),
                         title: new Text("Manage accounts"),
                         onTap: this._showNotImplementedMessage
                         )
                 }
                             )
                         )
                     )
             }
                 )
         }
                     )
                 )
             )
     }
                        )
                    ),
                body: new Center(
                    child: new InkWell(
                        onTap: () => { this._scaffoldKey.currentState.openDrawer(); },
                        child: new Column(
                            mainAxisSize: MainAxisSize.min,
                            children: new List <Widget>
     {
         new Container(
             width: 100.0f,
             height: 100.0f,
             decoration: new BoxDecoration(
                 shape: BoxShape.circle,
                 image: new DecorationImage(
                     image: new FileImage(
                         DrawerDemoUtils._kAsset0
                         )
                     )
                 )
             ),
         new Padding(
             padding: EdgeInsets.only(top: 8.0f),
             child: new Text("Tap here to open the drawer",
                             style: Theme.of(context).textTheme.subtitle1
                             )
             )
     }
                            )
                        )
                    )
                ));
 }
Ejemplo n.º 11
0
 public override Widget build(BuildContext context)
 {
     return(new Scaffold(
                key: this._scaffoldKey,
                appBar: new AppBar(
                    leading: new IconButton(
                        tooltip: "Navigation menu",
                        icon: new AnimatedIcon(
                            icon: AnimatedIcons.arrow_menu,
                            color: Colors.white,
                            progress: this._delegate.transitionAnimation
                            ),
                        onPressed: () => { this._scaffoldKey.currentState.openDrawer(); }
                        ),
                    title: new Text("Numbers"),
                    actions: new List <Widget> {
         new IconButton(
             tooltip: "Search",
             icon: new Icon(Icons.search),
             onPressed: () => {
             SearchUtils.showSearch(
                 context: context,
                 del: this._delegate
                 ).then_((selected) => {
                 if (selected != null && (int)selected != this._lastIntegerSelected)
                 {
                     this.setState(() => { this._lastIntegerSelected = (int)selected; });
                 }
             });
         }
             ),
         new MaterialDemoDocumentationButton(SearchDemo.routeName),
         new IconButton(
             tooltip: "More (not implemented)",
             icon: new Icon(
                 Theme.of(context).platform == RuntimePlatform.IPhonePlayer
                             ? Icons.more_horiz
                             : Icons.more_vert
                 ),
             onPressed: () => { }
             )
     }
                    ),
                body: new Center(
                    child: new Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: new List <Widget> {
         new Column(
             mainAxisAlignment: MainAxisAlignment.center,
             children: new List <Widget> {
             new Row(
                 mainAxisAlignment: MainAxisAlignment.center,
                 children: new List <Widget> {
                 new Text("Press the "),
                 new Tooltip(
                     message: "search",
                     child: new Icon(
                         Icons.search,
                         size: 18.0f
                         )
                     ),
                 new Text(" icon in the AppBar")
             }
                 ),
             new Text("and search for an integer between 0 and 100,000.")
         }
             ),
         new SizedBox(height: 64.0f),
         new Text(
             this._lastIntegerSelected == null
                             ? $"Last selected integer: {this._lastIntegerSelected}."
                             : $"Last selected integer: NONE."
             ),
     }
                        )
                    ),
                floatingActionButton: FloatingActionButton.extended(
                    tooltip: "Back", // Tests depend on this label to exit the demo.
                    onPressed: () => { Navigator.of(context).pop <object>(); },
                    label:
                    new Text("Close demo"),
                    icon:
                    new Icon(Icons.close)
                    ),
                drawer: new Drawer(
                    child: new Column(
                        children: new List <Widget> {
         new UserAccountsDrawerHeader(
             accountName: new Text("Peter Widget"),
             accountEmail: new Text("*****@*****.**"),
             currentAccountPicture: new CircleAvatar(
                 backgroundImage: new FileImage(
                     "gallery/people/square/peter.png"
                     )
                 ),
             margin: EdgeInsets.zero
             ),
         MediaQuery.removePadding(
             context: context,
             // DrawerHeader consumes top MediaQuery padding.
             removeTop: true,
             child: new ListTile(
                 leading: new Icon(Icons.payment),
                 title: new Text("Placeholder")
                 )
             )
     }
                        )
                    )
                ));
 }
Ejemplo n.º 12
0
        public override Widget buildPage(BuildContext context, Animation <float> animation,
                                         Animation <float> secondaryAnimation)
        {
            D.assert(WidgetsD.debugCheckHasDirectionality(context));
            float screenHeight  = MediaQuery.of(context).size.height;
            float maxMenuHeight = screenHeight - 2.0f * DropdownConstants._kMenuItemHeight;

            float buttonTop    = this.buttonRect.top;
            float buttonBottom = this.buttonRect.bottom;

            float topLimit    = Mathf.Min(DropdownConstants._kMenuItemHeight, buttonTop);
            float bottomLimit = Mathf.Max(screenHeight - DropdownConstants._kMenuItemHeight, buttonBottom);

            float?selectedItemOffset = this.selectedIndex * DropdownConstants._kMenuItemHeight +
                                       Constants.kMaterialListPadding.top;

            float?menuTop = (buttonTop - selectedItemOffset) -
                            (DropdownConstants._kMenuItemHeight - this.buttonRect.height) / 2.0f;
            float preferredMenuHeight = (this.items.Count * DropdownConstants._kMenuItemHeight) +
                                        Constants.kMaterialListPadding.vertical;

            float menuHeight = Mathf.Min(maxMenuHeight, preferredMenuHeight);

            float?menuBottom = menuTop + menuHeight;

            if (menuTop < topLimit)
            {
                menuTop = Mathf.Min(buttonTop, topLimit);
            }

            if (menuBottom > bottomLimit)
            {
                menuBottom = Mathf.Max(buttonBottom, bottomLimit);
                menuTop    = menuBottom - menuHeight;
            }

            if (this.scrollController == null)
            {
                float scrollOffset = preferredMenuHeight > maxMenuHeight
                    ? Mathf.Max(0.0f, selectedItemOffset ?? 0.0f - (buttonTop - (menuTop ?? 0.0f)))
                    : 0.0f;

                this.scrollController = new ScrollController(initialScrollOffset: scrollOffset);
            }

            Widget menu = new _DropdownMenu <T>(
                route: this,
                padding: this.padding
                );

            if (this.theme != null)
            {
                menu = new Theme(data: this.theme, child: menu);
            }

            return(MediaQuery.removePadding(
                       context: context,
                       removeTop: true,
                       removeBottom: true,
                       removeLeft: true,
                       removeRight: true,
                       child: new Builder(
                           builder: (BuildContext _context) => {
                return new CustomSingleChildLayout(
                    layoutDelegate: new _DropdownMenuRouteLayout <T>(
                        buttonRect: this.buttonRect,
                        menuTop: menuTop ?? 0.0f,
                        menuHeight: menuHeight
                        ),
                    child: menu
                    );
            }
                           )
                       ));
        }