Ejemplo n.º 1
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
            ThemeData     themeData   = Theme.of(context);
            AppBarTheme   appBarTheme = AppBarTheme.of(context);
            ScaffoldState scaffold    = Scaffold.of(context, nullOk: true);
            ModalRoute    parentRoute = ModalRoute.of(context);

            bool hasDrawer      = scaffold?.hasDrawer ?? false;
            bool hasEndDrawer   = scaffold?.hasEndDrawer ?? false;
            bool canPop         = parentRoute?.canPop ?? false;
            bool useCloseButton = parentRoute is PageRoute && ((PageRoute)parentRoute).fullscreenDialog;

            IconThemeData appBarIconTheme = this.widget.iconTheme
                                            ?? appBarTheme.iconTheme
                                            ?? themeData.primaryIconTheme;
            TextStyle centerStyle = this.widget.textTheme?.title
                                    ?? appBarTheme.textTheme?.title
                                    ?? themeData.primaryTextTheme.title;
            TextStyle sideStyle = this.widget.textTheme?.body1
                                  ?? appBarTheme.textTheme?.body1
                                  ?? themeData.primaryTextTheme.body1;

            if (this.widget.toolbarOpacity != 1.0f)
            {
                float opacity =
                    new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget.toolbarOpacity);
                if (centerStyle?.color != null)
                {
                    centerStyle = centerStyle.copyWith(color: centerStyle.color.withOpacity(opacity));
                }

                if (sideStyle?.color != null)
                {
                    sideStyle = sideStyle.copyWith(color: sideStyle.color.withOpacity(opacity));
                }

                appBarIconTheme = appBarIconTheme.copyWith(
                    opacity: opacity * (appBarIconTheme.opacity ?? 1.0f)
                    );
            }

            Widget leading = this.widget.leading;

            if (leading == null && this.widget.automaticallyImplyLeading)
            {
                if (hasDrawer)
                {
                    leading = new IconButton(
                        icon: new Icon(Icons.menu),
                        onPressed: this._handleDrawerButton,
                        tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip);
                }
                else
                {
                    if (canPop)
                    {
                        leading = useCloseButton ? (Widget) new CloseButton() : new BackButton();
                    }
                }
            }

            if (leading != null)
            {
                leading = new ConstrainedBox(
                    constraints: BoxConstraints.tightFor(width: AppBarUtils._kLeadingWidth),
                    child: leading);
            }

            Widget title = this.widget.title;

            if (title != null)
            {
                title = new DefaultTextStyle(
                    style: centerStyle,
                    softWrap: false,
                    overflow: TextOverflow.ellipsis,
                    child: title);
            }

            Widget actions = null;

            if (this.widget.actions != null && this.widget.actions.isNotEmpty())
            {
                actions = new Row(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: this.widget.actions);
            }
            else if (hasEndDrawer)
            {
                actions = new IconButton(
                    icon: new Icon(Icons.menu),
                    onPressed: this._handleDrawerButtonEnd,
                    tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip);
            }

            Widget toolbar = new NavigationToolbar(
                leading: leading,
                middle: title,
                trailing: actions,
                centerMiddle: this.widget._getEffectiveCenterTitle(themeData).Value,
                middleSpacing: this.widget.titleSpacing);

            Widget appBar = new ClipRect(
                child: new CustomSingleChildLayout(
                    layoutDelegate: new _ToolbarContainerLayout(),
                    child: IconTheme.merge(
                        data: appBarIconTheme,
                        child: new DefaultTextStyle(
                            style: sideStyle,
                            child: toolbar)
                        )
                    )
                );

            if (this.widget.bottom != null)
            {
                appBar = new Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: new List <Widget> {
                    new Flexible(
                        child: new ConstrainedBox(
                            constraints: new BoxConstraints(maxHeight: Constants.kToolbarHeight),
                            child: appBar
                            )
                        ),
                    this.widget.bottomOpacity == 1.0f
                            ? (Widget)this.widget.bottom
                            : new Opacity(
                        opacity: new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget
                                                                                                  .bottomOpacity),
                        child: this.widget.bottom
                        )
                }
                    );
            }

            if (this.widget.primary)
            {
                appBar = new SafeArea(
                    top: true,
                    child: appBar);
            }

            appBar = new Align(
                alignment: Alignment.topCenter,
                child: appBar);

            if (this.widget.flexibleSpace != null)
            {
                appBar = new Stack(
                    fit: StackFit.passthrough,
                    children: new List <Widget> {
                    this.widget.flexibleSpace,
                    appBar
                }
                    );
            }

            Brightness brightness = this.widget.brightness
                                    ?? appBarTheme.brightness
                                    ?? themeData.primaryColorBrightness;
            SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark
                ? SystemUiOverlayStyle.light
                : SystemUiOverlayStyle.dark;

            return(new AnnotatedRegion <SystemUiOverlayStyle>(
                       value: overlayStyle,
                       child: new Material(
                           color: this.widget.backgroundColor
                           ?? appBarTheme.color
                           ?? themeData.primaryColor,
                           elevation: this.widget.elevation
                           ?? appBarTheme.elevation
                           ?? _defaultElevation,
                           child: appBar
                           )));
        }
Ejemplo n.º 2
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
            Widget child = new NotificationListener <ScrollNotification>(
                key: this._key,
                onNotification: this._handleScrollNotification,
                child: new NotificationListener <OverscrollIndicatorNotification>(
                    onNotification: this._handleGlowNotification,
                    child: this.widget.child
                    )
                );

            if (this._mode == null)
            {
                D.assert(this._dragOffset == null);
                D.assert(this._isIndicatorAtTop == null);
                return(child);
            }

            D.assert(this._dragOffset != null);
            D.assert(this._isIndicatorAtTop != null);

            bool showIndeterminateIndicator =
                this._mode == _RefreshIndicatorMode.refresh || this._mode == _RefreshIndicatorMode.done;

            return(new Stack(
                       children: new List <Widget> {
                child,
                new Positioned(
                    top: this._isIndicatorAtTop == true ? 0.0f : (float?)null,
                    bottom: this._isIndicatorAtTop != true ? 0.0f : (float?)null,
                    left: 0.0f,
                    right: 0.0f,
                    child: new SizeTransition(
                        axisAlignment: this._isIndicatorAtTop == true ? 1.0f : -1.0f,
                        sizeFactor: this._positionFactor,     // this is what brings it down
                        child: new Container(
                            padding: this._isIndicatorAtTop == true
                                    ? EdgeInsets.only(top: this.widget.displacement)
                                    : EdgeInsets.only(bottom: this.widget.displacement),
                            alignment: this._isIndicatorAtTop == true
                                    ? Alignment.topCenter
                                    : Alignment.bottomCenter,
                            child: new ScaleTransition(
                                scale: this._scaleFactor,
                                child: new AnimatedBuilder(
                                    animation: this._positionController,
                                    builder: (BuildContext _context, Widget _child) => {
                    return new RefreshProgressIndicator(
                        value: showIndeterminateIndicator ? (float?)null : this._value.value,
                        valueColor: this._valueColor,
                        backgroundColor: this.widget.backgroundColor
                        );
                }
                                    )
                                )
                            )
                        )
                    )
            }
                       ));
        }
Ejemplo n.º 3
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
            return(new LayoutBuilder(builder: (BuildContext _, BoxConstraints constraints) => {
                List <Widget> wrappedChildren = new List <Widget> {
                };
                if (this.widget.header != null)
                {
                    wrappedChildren.Add(this.widget.header);
                }

                for (int i = 0; i < this.widget.children.Count; i += 1)
                {
                    wrappedChildren.Add(this._wrap(this.widget.children[i], i, constraints));
                }

                Key endWidgetKey = Key.key("DraggableList - End Widget");
                Widget finalDropArea;
                switch (this.widget.scrollDirection)
                {
                case Axis.horizontal:
                    finalDropArea = new SizedBox(
                        key: endWidgetKey,
                        width: _defaultDropAreaExtent,
                        height: constraints.maxHeight
                        );
                    break;

                case Axis.vertical:
                default:
                    finalDropArea = new SizedBox(
                        key: endWidgetKey,
                        height: _defaultDropAreaExtent,
                        width: constraints.maxWidth
                        );
                    break;
                }

                if (this.widget.reverse == true)
                {
                    wrappedChildren.Insert(0, this._wrap(
                                               finalDropArea,
                                               this.widget.children.Count,
                                               constraints)
                                           );
                }
                else
                {
                    wrappedChildren.Add(this._wrap(
                                            finalDropArea, this.widget.children.Count,
                                            constraints)
                                        );
                }

                return new SingleChildScrollView(
                    scrollDirection: this.widget.scrollDirection,
                    child: this._buildContainerForScrollDirection(children: wrappedChildren),
                    padding: this.widget.padding,
                    controller: this._scrollController,
                    reverse: this.widget.reverse == true
                    );
            }));
        }
        public override Widget build(BuildContext context)
        {
            D.assert(WidgetsD.debugCheckHasDirectionality(context));
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));

            ThemeData     theme    = Theme.of(context);
            List <Widget> children = new List <Widget> {
            };

            if (this.widget.accountName != null)
            {
                Widget accountNameLine = new LayoutId(
                    id: _AccountDetailsLayout.accountName,
                    child: new Padding(
                        padding: EdgeInsets.symmetric(vertical: 2.0f),
                        child: new DefaultTextStyle(
                            style: theme.primaryTextTheme.body2,
                            overflow: TextOverflow.ellipsis,
                            child: this.widget.accountName
                            )
                        )
                    );
                children.Add(accountNameLine);
            }

            if (this.widget.accountEmail != null)
            {
                Widget accountEmailLine = new LayoutId(
                    id: _AccountDetailsLayout.accountEmail,
                    child: new Padding(
                        padding: EdgeInsets.symmetric(vertical: 2.0f),
                        child: new DefaultTextStyle(
                            style: theme.primaryTextTheme.body1,
                            overflow: TextOverflow.ellipsis,
                            child: this.widget.accountEmail
                            )
                        )
                    );
                children.Add(accountEmailLine);
            }

            if (this.widget.onTap != null)
            {
                MaterialLocalizations localizations = MaterialLocalizations.of(context);
                Widget dropDownIcon = new LayoutId(
                    id: _AccountDetailsLayout.dropdownIcon,
                    child: new SizedBox(
                        height: UserAccountsDrawerHeaderUtils._kAccountDetailsHeight,
                        width: UserAccountsDrawerHeaderUtils._kAccountDetailsHeight,
                        child: new Center(
                            child: Transform.rotate(
                                degree: this._animation.value * Mathf.PI,
                                child: new Icon(
                                    Icons.arrow_drop_down,
                                    color: Colors.white
                                    )
                                )
                            )
                        )
                    );
                children.Add(dropDownIcon);
            }

            Widget accountDetails = new CustomMultiChildLayout(
                layoutDelegate: new _AccountDetailsLayout(),
                children: children
                );

            if (this.widget.onTap != null)
            {
                accountDetails = new InkWell(
                    onTap: this.widget.onTap == null ? (GestureTapCallback)null : () => { this.widget.onTap(); },
                    child: accountDetails
                    );
            }

            return(new SizedBox(
                       height: UserAccountsDrawerHeaderUtils._kAccountDetailsHeight,
                       child: accountDetails
                       ));
        }