Esempio n. 1
0
 public override void didChangeDependencies()
 {
     base.didChangeDependencies();
     D.assert(MaterialD.debugCheckHasMaterial(this.context));
     this._updateTabController();
     this._initIndicatorPainter();
 }
Esempio n. 2
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            D.assert(WidgetsD.debugCheckHasMediaQuery(context));

            SliderThemeData sliderTheme = SliderTheme.of(context);

            if (this.widget.activeColor != null || this.widget.inactiveColor != null)
            {
                sliderTheme = sliderTheme.copyWith(
                    activeTrackColor: this.widget.activeColor,
                    inactiveTrackColor: this.widget.inactiveColor,
                    activeTickMarkColor: this.widget.inactiveColor,
                    inactiveTickMarkColor: this.widget.activeColor,
                    thumbColor: this.widget.activeColor,
                    valueIndicatorColor: this.widget.activeColor,
                    overlayColor: this.widget.activeColor?.withAlpha(0x29)
                    );
            }

            return(new _SliderRenderObjectWidget(
                       value: this._unlerp(this.widget.value),
                       divisions: this.widget.divisions,
                       label: this.widget.label,
                       sliderTheme: sliderTheme,
                       mediaQueryData: MediaQuery.of(context),
                       onChanged: (this.widget.onChanged != null) && (this.widget.max > this.widget.min)
                    ? this._handleChanged
                    : (ValueChanged <float>)null,
                       onChangeStart: this.widget.onChangeStart != null ? this._handleDragStart : (ValueChanged <float>)null,
                       onChangeEnd: this.widget.onChangeEnd != null ? this._handleDragEnd : (ValueChanged <float>)null,
                       state: this
                       ));
        }
        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)
                               )
                           )
                       ));
        }
Esempio n. 4
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
            D.assert(() => {
                if (context.ancestorWidgetOfExactType(typeof(Stepper)) != null)
                {
                    throw new UIWidgetsError(
                        "Steppers must not be nested. The material specification advises that one should avoid embedding steppers within steppers. "
                        );
                }

                return(true);
            });

            switch (this.widget.type)
            {
            case StepperType.vertical:
                return(this._buildVertical());

            case StepperType.horizontal:
                return(this._buildHorizontal());
            }

            return(null);
        }
Esempio n. 5
0
        public static IPromise <object> showDialog(
            BuildContext context    = null,
            bool barrierDismissible = true,
            WidgetBuilder builder   = null
            )
        {
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));

            return(widgets.DialogUtils.showGeneralDialog(
                       context: context,
                       pageBuilder: (buildContext, animation, secondaryAnimation) => {
                ThemeData theme = Theme.of(context, shadowThemeOnly: true);
                Widget pageChild = new Builder(builder: builder);
                return new SafeArea(
                    child: new Builder(
                        builder: (_) => theme != null
                                ? new Theme(data: theme, child: pageChild)
                                : pageChild)
                    );
            },
                       barrierDismissible: barrierDismissible,
                       barrierColor: Colors.black54,
                       transitionDuration: new TimeSpan(0, 0, 0, 0, 150),
                       transitionBuilder: _buildMaterialDialogTransitions
                       ));
        }
Esempio n. 6
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            ThemeData themeData = Theme.of(context);
            TextStyle style     = themeData.textTheme.body1;

            return(ListView.builder(
                       dragStartBehavior: this.widget.dragStartBehavior,
                       controller: this.scrollController,
                       itemExtent: _itemExtent,
                       itemCount: this.widget.lastDate.Year - this.widget.firstDate.Year + 1,
                       itemBuilder: (BuildContext _context, int index) => {
                int year = this.widget.firstDate.Year + index;
                bool isSelected = year == this.widget.selectedDate.Year;
                TextStyle itemStyle = isSelected
                        ? themeData.textTheme.headline.copyWith(color: themeData.accentColor)
                        : style;
                return new InkWell(
                    key: new ValueKey <int>(year),
                    onTap: () => {
                    this.widget.onChanged(new DateTime(year, this.widget.selectedDate.Month,
                                                       this.widget.selectedDate.Day));
                },
                    child: new Center(
                        child: new Text(year.ToString(), style: itemStyle)
                        )
                    );
            }
                       ));
        }
Esempio n. 7
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            ThemeData themeData = Theme.of(context);
            Size      size;

            switch (this.widget.materialTapTargetSize ?? themeData.materialTapTargetSize)
            {
            case MaterialTapTargetSize.padded:
                size = new Size(2 * Constants.kRadialReactionRadius + 8.0f,
                                2 * Constants.kRadialReactionRadius + 8.0f);
                break;

            case MaterialTapTargetSize.shrinkWrap:
                size = new Size(2 * Constants.kRadialReactionRadius, 2 * Constants.kRadialReactionRadius);
                break;

            default:
                throw new Exception("Unknown material tap target size");
            }

            BoxConstraints additionalConstraints = BoxConstraints.tight(size);

            return(new _RadioRenderObjectWidget(
                       selected: this.widget.value == this.widget.groupValue,
                       activeColor: this.widget.activeColor ?? themeData.toggleableActiveColor,
                       inactiveColor: this._getInactiveColor(themeData),
                       onChanged: this._enabled ? this._handleChanged : (ValueChanged <bool?>)null,
                       additionalConstraints: additionalConstraints,
                       vsync: this
                       ));
        }
Esempio n. 8
0
 public override Widget build(BuildContext context)
 {
     D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
     return(new IconButton(
                icon: new Icon(Icons.close),
                tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
                onPressed: () => { Navigator.maybePop(context); }));
 }
Esempio n. 9
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())
                                )
                            )
                        )
                }
                        )
                    )
            }
                       ));
        }
Esempio n. 10
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            Color currentColor;

            if (this.onPressed != null)
            {
                currentColor = this.color;
            }
            else
            {
                currentColor = this.disabledColor ?? Theme.of(context).disabledColor;
            }

            Widget result = new ConstrainedBox(
                constraints: new BoxConstraints(minWidth: IconButtonUtils._kMinButtonSize,
                                                minHeight: IconButtonUtils._kMinButtonSize),
                child: new Padding(
                    padding: this.padding,
                    child: new SizedBox(
                        height: this.iconSize,
                        width: this.iconSize,
                        child: new Align(
                            alignment: this.alignment,
                            child: IconTheme.merge(
                                data: new IconThemeData(
                                    size: this.iconSize,
                                    color: currentColor),
                                child: this.icon)
                            )
                        )
                    )
                );

            if (this.tooltip != null)
            {
                result = new Tooltip(
                    message: this.tooltip,
                    child: result);
            }

            return(new InkResponse(
                       onTap: () => {
                if (this.onPressed != null)
                {
                    this.onPressed();
                }
            },
                       child: result,
                       highlightColor: this.highlightColor ?? Theme.of(context).highlightColor,
                       splashColor: this.splashColor ?? Theme.of(context).splashColor,
                       radius: Mathf.Max(
                           Material.defaultSplashRadius,
                           (this.iconSize + Mathf.Min(this.padding.horizontal, this.padding.vertical)) * 0.7f)
                       ));
        }
Esempio n. 11
0
        public string format(BuildContext context)
        {
            D.assert(WidgetsD.debugCheckHasMediaQuery(context));
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
            MaterialLocalizations localizations = MaterialLocalizations.of(context);

            return(localizations.formatTimeOfDay(
                       this,
                       alwaysUse24HourFormat: MediaQuery.of(context).alwaysUse24HourFormat
                       ));
        }
Esempio n. 12
0
 public static IPromise <object> showModalBottomSheet <T>(
     BuildContext context,
     WidgetBuilder builder
     )
 {
     D.assert(context != null);
     D.assert(builder != null);
     D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
     return(Navigator.push(context, new _ModalBottomSheetRoute <T>(
                               builder: builder,
                               theme: Theme.of(context, shadowThemeOnly: true),
                               barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel
                               )));
 }
        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;
                }

                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
                    );
            }));
        }
Esempio n. 14
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            ThemeData theme = Theme.of(context);

            return(new IconButton(
                       padding: this.widget.padding,
                       color: theme.brightness == Brightness.dark ? Colors.white54 : Colors.black54,
                       onPressed: this.widget.onPressed == null ? (VoidCallback)null : this._handlePressed,
                       icon: new RotationTransition(
                           turns: this._iconTurns,
                           child: new Icon(Icons.expand_more))
                       ));
        }
Esempio n. 15
0
 public override Widget build(BuildContext context)
 {
     D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
     return(this.widget.child != null
         ? (Widget) new InkWell(
                onTap: this.showButtonMenu,
                child: this.widget.child
                )
         : new IconButton(
                icon: this.widget.icon ?? this._getIcon(Theme.of(context).platform),
                padding: this.widget.padding,
                tooltip: this.widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip,
                onPressed: this.showButtonMenu
                ));
 }
Esempio n. 16
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            Widget result = new LayoutBuilder(
                builder: this._build
                );

            if (this.widget.width != null || this.widget.height != null)
            {
                result = new SizedBox(
                    width: this.widget.width,
                    height: this.widget.height,
                    child: result);
            }

            return(result);
        }
Esempio n. 17
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));

            List <Widget> body = new List <Widget>();

            if (this.title != null)
            {
                body.Add(new Padding(
                             padding: this.titlePadding,
                             child: new DefaultTextStyle(
                                 style: Theme.of(context).textTheme.title,
                                 child: this.title
                                 )
                             ));
            }

            if (this.children != null)
            {
                body.Add(new Flexible(
                             child: new SingleChildScrollView(
                                 padding: this.contentPadding,
                                 child: new ListBody(children: this.children)
                                 )
                             ));
            }

            Widget dialogChild = new IntrinsicWidth(
                stepWidth: 56.0f,
                child: new ConstrainedBox(
                    constraints: new BoxConstraints(minWidth: 280.0f),
                    child: new Column(
                        mainAxisSize: MainAxisSize.min,
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        children: body
                        )
                    )
                );

            return(new Dialog(
                       backgroundColor: this.backgroundColor,
                       elevation: this.elevation,
                       shape: this.shape,
                       child: dialogChild
                       ));
        }
Esempio n. 18
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); }
                       ));
        }
Esempio n. 19
0
        Widget buildMaterialSwitch(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            ThemeData theme  = Theme.of(context);
            bool      isDark = theme.brightness == Brightness.dark;

            Color activeThumbColor = this.widget.activeColor ?? theme.toggleableActiveColor;
            Color activeTrackColor = this.widget.activeTrackColor ?? activeThumbColor.withAlpha(0x80);

            Color inactiveThumbColor;
            Color inactiveTrackColor;

            if (this.widget.onChanged != null)
            {
                Color black32 = new Color(0x52000000); // Black with 32% opacity
                inactiveThumbColor = this.widget.inactiveThumbColor ??
                                     (isDark ? Colors.grey.shade400 : Colors.grey.shade50);
                inactiveTrackColor = this.widget.inactiveTrackColor ?? (isDark ? Colors.white30 : black32);
            }
            else
            {
                inactiveThumbColor = this.widget.inactiveThumbColor ??
                                     (isDark ? Colors.grey.shade800 : Colors.grey.shade400);
                inactiveTrackColor = this.widget.inactiveTrackColor ?? (isDark ? Colors.white10 : Colors.black12);
            }

            return(new _SwitchRenderObjectWidget(
                       dragStartBehavior: this.widget.dragStartBehavior,
                       value: this.widget.value,
                       activeColor: activeThumbColor,
                       inactiveColor: inactiveThumbColor,
                       activeThumbImage: this.widget.activeThumbImage,
                       inactiveThumbImage: this.widget.inactiveThumbImage,
                       activeTrackColor: activeTrackColor,
                       inactiveTrackColor: inactiveTrackColor,
                       configuration: ImageUtils.createLocalImageConfiguration(context),
                       onChanged: this.widget.onChanged,
                       additionalConstraints: BoxConstraints.tight(this.getSwitchSize(theme)),
                       vsync: this
                       ));
        }
Esempio n. 20
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));

            float  height = 0f;
            Widget label  = null;

            if (this.icon == null)
            {
                height = TabsUtils._kTabHeight;
                label  = this._buildLabelText();
            }
            else if (this.text == null)
            {
                height = TabsUtils._kTabHeight;
                label  = this.icon;
            }
            else
            {
                height = TabsUtils._kTextAndIconTabHeight;
                label  = new Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: new List <Widget> {
                    new Container(
                        child: this.icon,
                        margin: EdgeInsets.only(bottom: 10.0f)
                        ),
                    this._buildLabelText()
                }
                    );
            }

            return(new SizedBox(
                       height: height,
                       child: new Center(
                           child: label,
                           widthFactor: 1.0f)
                       ));
        }
Esempio n. 21
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            ThemeData themeData = Theme.of(context);
            Size      size;

            switch (this.widget.materialTapTargetSize ?? themeData.materialTapTargetSize)
            {
            case MaterialTapTargetSize.padded:
                size = new Size(2 * Constants.kRadialReactionRadius + 8.0f,
                                2 * Constants.kRadialReactionRadius + 8.0f);
                break;

            case MaterialTapTargetSize.shrinkWrap:
                size = new Size(2 * Constants.kRadialReactionRadius, 2 * Constants.kRadialReactionRadius);
                break;

            default:
                throw new Exception("Unknown target size: " + this.widget.materialTapTargetSize);
            }

            BoxConstraints additionalConstraints = BoxConstraints.tight(size);

            return(new _CheckboxRenderObjectWidget(
                       value: this.widget.value,
                       tristate: this.widget.tristate,
                       activeColor: this.widget.activeColor ?? themeData.toggleableActiveColor,
                       checkColor: this.widget.checkColor ?? new Color(0xFFFFFFFF),
                       inactiveColor: this.widget.onChanged != null
                    ? themeData.unselectedWidgetColor
                    : themeData.disabledColor,
                       onChanged: this.widget.onChanged,
                       additionalConstraints: additionalConstraints,
                       vsync: this
                       ));
        }
Esempio n. 22
0
 public override Widget build(BuildContext context)
 {
     D.assert(MaterialD.debugCheckHasMaterial(context));
     D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
     return(new DrawerHeader(
                decoration: this.widget.decoration ?? new BoxDecoration(
                    color: Theme.of(context).primaryColor
                    ),
                margin: this.widget.margin,
                padding: EdgeInsets.only(top: 16.0f, left: 16.0f),
                child: new SafeArea(
                    bottom: false,
                    child: new Column(
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        children: new List <Widget> {
         new Expanded(
             child: new Padding(
                 padding: EdgeInsets.only(right: 16.0f),
                 child: new _AccountPictures(
                     currentAccountPicture: this.widget.currentAccountPicture,
                     otherAccountsPictures: this.widget.otherAccountsPictures
                     )
                 )
             ),
         new _AccountDetails(
             accountName: this.widget.accountName,
             accountEmail: this.widget.accountEmail,
             isOpen: this._isOpen,
             onTap: this.widget.onDetailsPressed == null
                             ? (VoidCallback)null
                             : () => { this._handleDetailsPressed(); })
     }
                        )
                    )
                ));
 }
Esempio n. 23
0
        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
                       ));
        }
Esempio n. 24
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            ThemeData     theme     = Theme.of(context);
            ListTileTheme tileTheme = ListTileTheme.of(context);

            IconThemeData iconThemeData = null;

            if (this.leading != null || this.trailing != null)
            {
                iconThemeData = new IconThemeData(color: this._iconColor(theme, tileTheme));
            }

            Widget leadingIcon = null;

            if (this.leading != null)
            {
                leadingIcon = IconTheme.merge(
                    data: iconThemeData,
                    child: this.leading);
            }

            TextStyle titleStyle = this._titleTextStyle(theme, tileTheme);
            Widget    titleText  = new AnimatedDefaultTextStyle(
                style: titleStyle,
                duration: Constants.kThemeChangeDuration,
                child: this.title ?? new SizedBox()
                );

            Widget    subtitleText  = null;
            TextStyle subtitleStyle = null;

            if (this.subtitle != null)
            {
                subtitleStyle = this._subtitleTextStyle(theme, tileTheme);
                subtitleText  = new AnimatedDefaultTextStyle(
                    style: subtitleStyle,
                    duration: Constants.kThemeChangeDuration,
                    child: this.subtitle);
            }

            Widget trailingIcon = null;

            if (this.trailing != null)
            {
                trailingIcon = IconTheme.merge(
                    data: iconThemeData,
                    child: this.trailing);
            }

            EdgeInsets _defaultContentPadding = EdgeInsets.symmetric(horizontal: 16.0f);
            EdgeInsets resolvedContentPadding =
                this.contentPadding ?? tileTheme?.contentPadding ?? _defaultContentPadding;

            return(new InkWell(
                       onTap: this.enabled ? this.onTap : null,
                       onLongPress: this.enabled ? this.onLongPress : null,
                       child: new SafeArea(
                           top: false,
                           bottom: false,
                           mininum: resolvedContentPadding,
                           child: new _ListTile(
                               leading: leadingIcon,
                               title: titleText,
                               subtitle: subtitleText,
                               trailing: trailingIcon,
                               isDense: this._isDenseLayout(tileTheme),
                               isThreeLine: this.isThreeLine,
                               titleBaselineType: titleStyle.textBaseline,
                               subtitleBaselineType: subtitleStyle?.textBaseline
                               )
                           )
                       ));
        }
Esempio n. 25
0
        public override Widget build(BuildContext context)
        {
            base.build(context); // See AutomaticKeepAliveClientMixin.
            D.assert(MaterialD.debugCheckHasMaterial(context));
            D.assert(WidgetsD.debugCheckHasDirectionality(context));
            ThemeData                 themeData          = Theme.of(context);
            TextStyle                 style              = this.widget.style ?? themeData.textTheme.subhead;
            Brightness                keyboardAppearance = this.widget.keyboardAppearance ?? themeData.primaryColorBrightness;
            TextEditingController     controller         = this._effectiveController;
            FocusNode                 focusNode          = this._effectiveFocusNode;
            List <TextInputFormatter> formatters         = this.widget.inputFormatters ?? new List <TextInputFormatter>();

            if (this.widget.maxLength != null && this.widget.maxLengthEnforced)
            {
                formatters.Add(new LengthLimitingTextInputFormatter(this.widget.maxLength));
            }


            Widget child = new RepaintBoundary(
                child: new EditableText(
                    key: this._editableTextKey,
                    controller: controller,
                    focusNode: focusNode,
                    keyboardType: this.widget.keyboardType,
                    textInputAction: this.widget.textInputAction,
                    textCapitalization: this.widget.textCapitalization,
                    style: style,
                    textAlign: this.widget.textAlign,
                    textDirection: this.widget.textDirection,
                    autofocus: this.widget.autofocus,
                    obscureText: this.widget.obscureText,
                    autocorrect: this.widget.autocorrect,
                    maxLines: this.widget.maxLines,
                    selectionColor: themeData.textSelectionColor,
                    selectionControls: this.widget.enableInteractiveSelection
                        ? MaterialUtils.materialTextSelectionControls
                        : null,
                    onChanged: this.widget.onChanged,
                    onEditingComplete: this.widget.onEditingComplete,
                    onSubmitted: this.widget.onSubmitted,
                    onSelectionChanged: this._handleSelectionChanged,
                    inputFormatters: formatters,
                    rendererIgnoresPointer: true,
                    cursorWidth: this.widget.cursorWidth,
                    cursorRadius: this.widget.cursorRadius,
                    cursorColor: this.widget.cursorColor ?? Theme.of(context).cursorColor,
                    scrollPadding: this.widget.scrollPadding,
                    keyboardAppearance: keyboardAppearance,
                    enableInteractiveSelection: this.widget.enableInteractiveSelection
                    )
                );

            if (this.widget.decoration != null)
            {
                child = new AnimatedBuilder(
                    animation: ListenableUtils.merge(new List <Listenable> {
                    focusNode, controller
                }),
                    builder:
                    (_context, _child) => {
                    return(new InputDecorator(
                               decoration: this._getEffectiveDecoration(),
                               baseStyle: this.widget.style,
                               textAlign: this.widget.textAlign,
                               isFocused: focusNode.hasFocus,
                               isEmpty: controller.value.text.isEmpty(),
                               child: _child
                               ));
                },
                    child: child
                    );
            }

            return(new IgnorePointer(
                       ignoring: !(this.widget.enabled ?? this.widget.decoration?.enabled ?? true),
                       child: new GestureDetector(
                           behavior: HitTestBehavior.translucent,
                           onTapDown: this._handleTapDown,
                           onTap: this._handleTap,
                           onTapCancel: this._handleTapCancel,
                           onLongPress: this._handleLongPress,
                           child: child
                           )
                       ));
        }
Esempio n. 26
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
            MaterialLocalizations localizations = MaterialLocalizations.of(context);
            _DropdownRoute <T>    route         = this.widget.route;
            float         unit     = 0.5f / (route.items.Count + 1.5f);
            List <Widget> children = new List <Widget>();

            for (int itemIndex = 0; itemIndex < route.items.Count; ++itemIndex)
            {
                CurvedAnimation opacity;
                if (itemIndex == route.selectedIndex)
                {
                    opacity = new CurvedAnimation(parent: route.animation, curve: new Threshold(0.0f));
                }
                else
                {
                    float start = (0.5f + (itemIndex + 1) * unit).clamp(0.0f, 1.0f);
                    float end   = (start + 1.5f * unit).clamp(0.0f, 1.0f);
                    opacity = new CurvedAnimation(parent: route.animation, curve: new Interval(start, end));
                }

                var index = itemIndex;
                children.Add(new FadeTransition(
                                 opacity: opacity,
                                 child: new InkWell(
                                     child: new Container(
                                         padding: this.widget.padding,
                                         child: route.items[itemIndex]
                                         ),
                                     onTap: () => Navigator.pop(
                                         context,
                                         new _DropdownRouteResult <T>(route.items[index].value)
                                         )
                                     )
                                 ));
            }

            return(new FadeTransition(
                       opacity: this._fadeOpacity,
                       child: new CustomPaint(
                           painter: new _DropdownMenuPainter(
                               color: Theme.of(context).canvasColor,
                               elevation: route.elevation,
                               selectedIndex: route.selectedIndex,
                               resize: this._resize
                               ),
                           child: new Material(
                               type: MaterialType.transparency,
                               textStyle: route.style,
                               child: new ScrollConfiguration(
                                   behavior: new _DropdownScrollBehavior(),
                                   child: new Scrollbar(
                                       child: new ListView(
                                           controller: this.widget.route.scrollController,
                                           padding: Constants.kMaterialListPadding,
                                           itemExtent: DropdownConstants._kMenuItemHeight,
                                           shrinkWrap: true,
                                           children: children
                                           )
                                       )
                                   )
                               )
                           )
                       ));
        }
Esempio n. 27
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));

            List <Widget> items     = this._enabled ? new List <Widget>(this.widget.items) : new List <Widget>();
            int           hintIndex = 0;

            if (this.widget.hint != null || (!this._enabled && this.widget.disabledHint != null))
            {
                Widget emplacedHint =
                    this._enabled
                        ? this.widget.hint
                        : new DropdownMenuItem <Widget>(child: this.widget.disabledHint ?? this.widget.hint);
                hintIndex = items.Count;
                items.Add(new DefaultTextStyle(
                              style: this._textStyle.copyWith(color: Theme.of(context).hintColor),
                              child: new IgnorePointer(
                                  child: emplacedHint
                                  )
                              ));
            }

            EdgeInsets padding = ButtonTheme.of(context).alignedDropdown
                ? DropdownConstants._kAlignedButtonPadding
                : DropdownConstants._kUnalignedButtonPadding;

            IndexedStack innerItemsWidget = new IndexedStack(
                index: this._enabled ? (this._selectedIndex ?? hintIndex) : hintIndex,
                alignment: Alignment.centerLeft,
                children: items
                );

            Widget result = new DefaultTextStyle(
                style: this._textStyle,
                child: new Container(
                    padding: padding,
                    height: this.widget.isDense ? this._denseButtonHeight : null,
                    child: new Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        mainAxisSize: MainAxisSize.min,
                        children: new List <Widget> {
                this.widget.isExpanded ? new Expanded(child: innerItemsWidget) : (Widget)innerItemsWidget,
                new Icon(Icons.arrow_drop_down,
                         size: this.widget.iconSize,
                         color: this._downArrowColor
                         )
            }
                        )
                    )
                );

            if (!DropdownButtonHideUnderline.at(context))
            {
                float bottom = this.widget.isDense ? 0.0f : 8.0f;
                result = new Stack(
                    children: new List <Widget> {
                    result,
                    new Positioned(
                        left: 0.0f,
                        right: 0.0f,
                        bottom: bottom,
                        child: new Container(
                            height: 1.0f,
                            decoration: new BoxDecoration(
                                border: new Border(
                                    bottom: new BorderSide(color: new Color(0xFFBDBDBD), width: 0.0f))
                                )
                            )
                        )
                }
                    );
            }

            return(new GestureDetector(
                       onTap: this._enabled ? (GestureTapCallback)this._handleTap : null,
                       behavior: HitTestBehavior.opaque,
                       child: result
                       ));
        }
Esempio n. 28
0
        public override Widget build(BuildContext context)
        {
            base.build(context); // See AutomaticKeepAliveClientMixin.
            D.assert(MaterialD.debugCheckHasMaterial(context));
            D.assert(WidgetsD.debugCheckHasDirectionality(context));
            D.assert(
                !(this.widget.style != null && this.widget.style.inherit == false &&
                  (this.widget.style.fontSize == null || this.widget.style.textBaseline == null)),
                "inherit false style must supply fontSize and textBaseline"
                );
            ThemeData                 themeData          = Theme.of(context);
            TextStyle                 style              = themeData.textTheme.subhead.merge(this.widget.style);
            Brightness                keyboardAppearance = this.widget.keyboardAppearance ?? themeData.primaryColorBrightness;
            TextEditingController     controller         = this._effectiveController;
            FocusNode                 focusNode          = this._effectiveFocusNode;
            List <TextInputFormatter> formatters         = this.widget.inputFormatters ?? new List <TextInputFormatter>();

            if (this.widget.maxLength != null && this.widget.maxLengthEnforced)
            {
                formatters.Add(new LengthLimitingTextInputFormatter(this.widget.maxLength));
            }

            bool forcePressEnabled = false;
            TextSelectionControls textSelectionControls = MaterialUtils.materialTextSelectionControls;;
            bool   paintCursorAboveText  = false;
            bool   cursorOpacityAnimates = false;
            Offset cursorOffset          = null;
            Color  cursorColor           = this.widget.cursorColor ?? themeData.cursorColor;
            Radius cursorRadius          = this.widget.cursorRadius;

            Widget child = new RepaintBoundary(
                child: new EditableText(
                    key: this._editableTextKey,
                    controller: controller,
                    focusNode: focusNode,
                    keyboardType: this.widget.keyboardType,
                    textInputAction: this.widget.textInputAction,
                    textCapitalization: this.widget.textCapitalization,
                    style: style,
                    textAlign: this.widget.textAlign,
                    textDirection: this.widget.textDirection,
                    autofocus: this.widget.autofocus,
                    obscureText: this.widget.obscureText,
                    autocorrect: this.widget.autocorrect,
                    maxLines: this.widget.maxLines,
                    selectionColor: themeData.textSelectionColor,
                    selectionControls: this.widget.selectionEnabled ? textSelectionControls : null,
                    onChanged: this.widget.onChanged,
                    onSelectionChanged: this._handleSelectionChanged,
                    onEditingComplete: this.widget.onEditingComplete,
                    onSubmitted: this.widget.onSubmitted,
                    inputFormatters: formatters,
                    rendererIgnoresPointer: true,
                    cursorWidth: this.widget.cursorWidth,
                    cursorRadius: cursorRadius,
                    cursorColor: cursorColor,
                    cursorOpacityAnimates: cursorOpacityAnimates,
                    cursorOffset: cursorOffset,
                    paintCursorAboveText: paintCursorAboveText,
                    backgroundCursorColor: new Color(0xFF8E8E93),// TODO: CupertinoColors.inactiveGray,
                    scrollPadding: this.widget.scrollPadding,
                    keyboardAppearance: keyboardAppearance,
                    enableInteractiveSelection: this.widget.enableInteractiveSelection == true,
                    dragStartBehavior: this.widget.dragStartBehavior
                    )
                );

            if (this.widget.decoration != null)
            {
                child = new AnimatedBuilder(
                    animation: ListenableUtils.merge(new List <Listenable> {
                    focusNode, controller
                }),
                    builder:
                    (_context, _child) => {
                    return(new InputDecorator(
                               decoration: this._getEffectiveDecoration(),
                               baseStyle: this.widget.style,
                               textAlign: this.widget.textAlign,
                               isFocused: focusNode.hasFocus,
                               isEmpty: controller.value.text.isEmpty(),
                               child: _child
                               ));
                },
                    child: child
                    );
            }

            return(new IgnorePointer(
                       ignoring: !(this.widget.enabled ?? this.widget.decoration?.enabled ?? true),
                       child: new TextSelectionGestureDetector(
                           onTapDown: this._handleTapDown,
                           // onForcePressStart: forcePressEnabled ? this._handleForcePressStarted : null, // TODO: Remove this when force press is added
                           onSingleTapUp: this._handleSingleTapUp,
                           onSingleTapCancel: this._handleSingleTapCancel,
                           onSingleLongTapStart: this._handleLongPress,
                           onDragSelectionStart: this._handleDragSelectionStart,
                           onDragSelectionUpdate: this._handleDragSelectionUpdate,
                           behavior: HitTestBehavior.translucent,
                           child: child
                           )
                       ));
        }
Esempio n. 29
0
        public override Widget build(BuildContext context)
        {
            MaterialD.debugCheckHasMaterialLocalizations(context);

            ThemeData theme            = this.widget.del.appBarTheme(context);
            string    searchFieldLabel = MaterialLocalizations.of(context).searchFieldLabel;
            Widget    body             = null;

            switch (this.widget.del._currentBody)
            {
            case _SearchBody.suggestions:
                body = new KeyedSubtree(
                    key: new ValueKey <_SearchBody>(_SearchBody.suggestions),
                    child: this.widget.del.buildSuggestions(context)
                    );
                break;

            case _SearchBody.results:
                body = new KeyedSubtree(
                    key: new ValueKey <_SearchBody>(_SearchBody.results),
                    child: this.widget.del.buildResults(context)
                    );
                break;
            }

            string routeName;

            switch (Theme.of(this.context).platform)
            {
            case RuntimePlatform.IPhonePlayer:
                routeName = "";
                break;

            case RuntimePlatform.Android:
                routeName = searchFieldLabel;
                break;
            }

            return(new Scaffold(
                       appBar: new AppBar(
                           backgroundColor: theme.primaryColor,
                           iconTheme: theme.primaryIconTheme,
                           textTheme: theme.primaryTextTheme,
                           brightness: theme.primaryColorBrightness,
                           leading: this.widget.del.buildLeading(context),
                           title: new TextField(
                               controller: this.queryTextController,
                               focusNode: this.widget.del._focusNode,
                               style: theme.textTheme.title,
                               textInputAction: TextInputAction.search,
                               onSubmitted: (string _) => { this.widget.del.showResults(context); },
                               decoration: new InputDecoration(
                                   border: InputBorder.none,
                                   hintText: searchFieldLabel
                                   )
                               ),
                           actions: this.widget.del.buildActions(context)
                           ),
                       body: new AnimatedSwitcher(
                           duration: new TimeSpan(0, 0, 0, 0, 300),
                           child: body
                           )
                       ));
        }
Esempio n. 30
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
            ThemeData     themeData   = Theme.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 ?? themeData.primaryIconTheme;
            TextStyle     centerStyle     = this.widget.textTheme?.title ?? themeData.primaryTextTheme.title;
            TextStyle     sideStyle       = this.widget.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 ?? themeData.primaryColorBrightness;
            SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark
                ? SystemUiOverlayStyle.light
                : SystemUiOverlayStyle.dark;

            return(new AnnotatedRegion <SystemUiOverlayStyle>(
                       value: overlayStyle,
                       child: new Material(
                           color: this.widget.backgroundColor ?? themeData.primaryColor,
                           elevation: this.widget.elevation,
                           child: appBar
                           )));
        }