コード例 #1
0
ファイル: dialog.cs プロジェクト: ragdollKB/2dFighter
        public override Widget build(BuildContext context)
        {
            DialogTheme dialogTheme = DialogTheme.of(context);

            return(new AnimatedPadding(
                       padding: MediaQuery.of(context).viewInsets + EdgeInsets.symmetric(horizontal: 40.0f, vertical: 24.0f),
                       duration: this.insetAnimationDuration,
                       curve: this.insetAnimationCurve,
                       child: MediaQuery.removeViewInsets(
                           removeLeft: true,
                           removeTop: true,
                           removeRight: true,
                           removeBottom: true,
                           context: context,
                           child: new Center(
                               child: new ConstrainedBox(
                                   constraints: new BoxConstraints(minWidth: 280.0f),
                                   child: new Material(
                                       color: this.backgroundColor ?? dialogTheme.backgroundColor ??
                                       Theme.of(context).dialogBackgroundColor,
                                       elevation: this.elevation ?? dialogTheme.elevation ?? _defaultElevation,
                                       shape: this.shape ?? dialogTheme.shape ?? _defaultDialogShape,
                                       type: MaterialType.card,
                                       child: this.child
                                       )
                                   )
                               )
                           )
                       ));
        }
コード例 #2
0
        public override Widget build(BuildContext context)
        {
            DialogTheme dialogTheme      = DialogTheme.of(context);
            EdgeInsets  effectivePadding = MediaQuery.of(context).viewInsets + (insetPadding ?? EdgeInsets.all(0.0f));

            return(new AnimatedPadding(
                       padding: effectivePadding,
                       duration: insetAnimationDuration,
                       curve: insetAnimationCurve,
                       child: MediaQuery.removeViewInsets(
                           removeLeft: true,
                           removeTop: true,
                           removeRight: true,
                           removeBottom: true,
                           context: context,
                           child: new Center(
                               child: new ConstrainedBox(
                                   constraints: new BoxConstraints(minWidth: 280.0f),
                                   child: new Material(
                                       color: backgroundColor ?? dialogTheme.backgroundColor ??
                                       Theme.of(context).dialogBackgroundColor,
                                       elevation: elevation ?? dialogTheme.elevation ?? _defaultElevation,
                                       shape: shape ?? dialogTheme.shape ?? _defaultDialogShape,
                                       type: MaterialType.card,
                                       clipBehavior: clipBehavior,
                                       child: child
                                       )
                                   )
                               )
                           )
                       ));
        }
コード例 #3
0
ファイル: dialog.cs プロジェクト: ragdollKB/2dFighter
        public override Widget build(BuildContext context)
        {
            // D.assert(debugCheckHasMaterialLocalizations(context));

            ThemeData   theme       = Theme.of(context);
            DialogTheme dialogTheme = DialogTheme.of(context);

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

            if (this.title != null)
            {
                children.Add(new Padding(
                                 padding: this.titlePadding ??
                                 EdgeInsets.fromLTRB(24.0f, 24.0f, 24.0f, this.content == null ? 20.0f : 0.0f),
                                 child: new DefaultTextStyle(
                                     style: this.titleTextStyle ?? dialogTheme.titleTextStyle ?? theme.textTheme.title,
                                     child: this.title
                                     )
                                 ));
            }

            if (this.content != null)
            {
                children.Add(new Flexible(
                                 child: new Padding(
                                     padding: this.contentPadding,
                                     child: new DefaultTextStyle(
                                         style: this.contentTextStyle ?? dialogTheme.contentTextStyle ?? theme.textTheme.subhead,
                                         child: this.content
                                         )
                                     )
                                 ));
            }

            if (this.actions != null)
            {
                children.Add(ButtonTheme.bar(
                                 child: new ButtonBar(
                                     children: this.actions
                                     )
                                 ));
            }

            Widget dialogChild = new IntrinsicWidth(
                child: new Column(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: children
                    )
                );

            return(new Dialog(
                       backgroundColor: this.backgroundColor,
                       elevation: this.elevation,
                       shape: this.shape,
                       child: dialogChild
                       ));
        }
コード例 #4
0
        public override Widget build(BuildContext context)
        {
            D.assert(material_.debugCheckHasMaterialLocalizations(context));

            ThemeData   theme       = Theme.of(context);
            DialogTheme dialogTheme = DialogTheme.of(context);

            Widget titleWidget   = null;
            Widget contentWidget = null;
            Widget actionsWidget = null;

            if (title != null)
            {
                titleWidget = new Padding(
                    padding: titlePadding ?? EdgeInsets.fromLTRB(24.0f, 24.0f, 24.0f, content == null ? 20.0f : 0.0f),
                    child: new DefaultTextStyle(
                        style: titleTextStyle ?? dialogTheme.titleTextStyle ?? theme.textTheme.headline6,
                        child: title
                        )
                    );
            }

            if (content != null)
            {
                contentWidget = new Padding(
                    padding: contentPadding,
                    child: new DefaultTextStyle(
                        style: contentTextStyle ?? dialogTheme.contentTextStyle ?? theme.textTheme.subtitle1,
                        child: content
                        )
                    );
            }

            if (actions != null)
            {
                actionsWidget = new Padding(
                    padding: actionsPadding,
                    child: new ButtonBar(
                        buttonPadding: buttonPadding,
                        overflowDirection: actionsOverflowDirection,
                        overflowButtonSpacing: actionsOverflowButtonSpacing,
                        children: actions
                        )
                    );
            }

            List <Widget> columnChildren;

            if (scrollable)
            {
                var titleList = new List <Widget>();

                if (title != null)
                {
                    titleList.Add(titleWidget);
                }

                if (content != null)
                {
                    titleList.Add(contentWidget);
                }

                columnChildren = new List <Widget>();

                if (title != null || content != null)
                {
                    columnChildren.Add(new Flexible(
                                           child: new SingleChildScrollView(
                                               child: new Column(
                                                   mainAxisSize: MainAxisSize.min,
                                                   crossAxisAlignment: CrossAxisAlignment.stretch,
                                                   children: titleList
                                                   )
                                               )
                                           ));
                }

                if (actions != null)
                {
                    columnChildren.Add(actionsWidget);
                }
            }
            else
            {
                columnChildren = new List <Widget>();
                if (title != null)
                {
                    columnChildren.Add(titleWidget);
                }

                if (content != null)
                {
                    columnChildren.Add(new Flexible(child: contentWidget));
                }

                if (actions != null)
                {
                    columnChildren.Add(actionsWidget);
                }
            }

            Widget dialogChild = new IntrinsicWidth(
                child: new Column(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: columnChildren
                    )
                );

            return(new Dialog(
                       backgroundColor: backgroundColor,
                       elevation: elevation,
                       insetPadding: insetPadding,
                       clipBehavior: clipBehavior,
                       shape: shape,
                       child: dialogChild
                       ));
        }
コード例 #5
0
        public override Widget build(BuildContext context)
        {
            ThemeData             theme         = Theme.of(context);
            ColorScheme           colorScheme   = theme.colorScheme;
            MaterialLocalizations localizations = MaterialLocalizations.of(context);
            Orientation?          orientation   = MediaQuery.of(context).orientation;
            TextTheme             textTheme     = theme.textTheme;

            float textScaleFactor = Mathf.Min(MediaQuery.of(context).textScaleFactor, 1.3f);

            string dateText = _selectedDate != null
                ? localizations.formatMediumDate(_selectedDate)
                : "Date";

            Color dateColor = colorScheme.brightness == Brightness.light
                ? colorScheme.onPrimary
                : colorScheme.onSurface;
            TextStyle dateStyle = orientation == Orientation.landscape
                ? textTheme.headline5?.copyWith(color: dateColor)
                : textTheme.headline4?.copyWith(color: dateColor);

            Widget actions = new ButtonBar(
                buttonTextTheme: ButtonTextTheme.primary,
                layoutBehavior: ButtonBarLayoutBehavior.constrained,
                children: new List <Widget> {
                new FlatButton(
                    child: new Text(widget.cancelText ?? localizations.cancelButtonLabel),
                    onPressed: _handleCancel
                    ),
                new FlatButton(
                    child: new Text(widget.confirmText ?? localizations.okButtonLabel),
                    onPressed: _handleOk
                    ),
            }
                );

            Widget   picker           = null;
            IconData entryModeIcon    = null;
            string   entryModeTooltip = null;

            switch (_entryMode)
            {
            case DatePickerEntryMode.calendar:
                picker = new CalendarDatePicker(
                    key: _calendarPickerKey,
                    initialDate: _selectedDate,
                    firstDate: widget.firstDate,
                    lastDate: widget.lastDate,
                    onDateChanged: _handleDateChanged,
                    selectableDayPredicate: widget.selectableDayPredicate,
                    initialCalendarMode: widget.initialCalendarMode
                    );
                entryModeIcon    = Icons.edit;
                entryModeTooltip = "Switch to input";
                break;

            case DatePickerEntryMode.input:
                picker = new Form(
                    key: _formKey,
                    autovalidate: _autoValidate,
                    child: new InputDatePickerFormField(
                        initialDate: _selectedDate,
                        firstDate: widget.firstDate,
                        lastDate: widget.lastDate,
                        onDateSubmitted: _handleDateChanged,
                        onDateSaved: _handleDateChanged,
                        selectableDayPredicate: widget.selectableDayPredicate,
                        errorFormatText: widget.errorFormatText,
                        errorInvalidText: widget.errorInvalidText,
                        fieldHintText: widget.fieldHintText,
                        fieldLabelText: widget.fieldLabelText,
                        autofocus: true
                        )
                    );
                entryModeIcon    = Icons.calendar_today;
                entryModeTooltip = "Switch to calendar";
                break;
            }

            Widget header = new DatePickerHeader(
                helpText: widget.helpText ?? "SELECT DATE",
                titleText: dateText,
                titleStyle: dateStyle,
                orientation: orientation,
                isShort: orientation == Orientation.landscape,
                icon: entryModeIcon,
                iconTooltip: entryModeTooltip,
                onIconPressed: _handelEntryModeToggle
                );

            Size        dialogSize  = _dialogSize(context) * textScaleFactor;
            DialogTheme dialogTheme = Theme.of(context).dialogTheme;

            return(new Dialog(
                       child: new AnimatedContainer(
                           width: dialogSize.width,
                           height: dialogSize.height,
                           duration: material_._dialogSizeAnimationDuration,
                           curve: Curves.easeIn,
                           child: new MediaQuery(
                               data: MediaQuery.of(context).copyWith(
                                   textScaleFactor: textScaleFactor
                                   ),
                               child: new Builder(builder: (BuildContext subContext) => {
                switch (orientation)
                {
                case Orientation.portrait:
                    return new Column(
                        mainAxisSize: MainAxisSize.min,
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        children: new List <Widget> {
                        header,
                        new Expanded(child: picker),
                        actions,
                    }
                        );

                case Orientation.landscape:
                    return new Row(
                        mainAxisSize: MainAxisSize.min,
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        children: new List <Widget> {
                        header,
                        new Flexible(
                            child: new Column(
                                mainAxisSize: MainAxisSize.min,
                                crossAxisAlignment: CrossAxisAlignment.stretch,
                                children: new List <Widget> {
                            new Expanded(child: picker),
                            actions,
                        }
                                )
                            ),
                    }
                        );
                }

                return null;
            })
                               )
                           ),
                       insetPadding: EdgeInsets.symmetric(horizontal: 16.0f, vertical: 24.0f),
                       shape: dialogTheme.shape ?? new RoundedRectangleBorder(
                           borderRadius: BorderRadius.all(Radius.circular(4.0f))
                           ),
                       clipBehavior: Clip.antiAlias
                       ));
        }