コード例 #1
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
                       ));
        }
コード例 #2
0
        public override Widget build(BuildContext context)
        {
            D.assert(material_.debugCheckHasMaterialLocalizations(context));
            ThemeData theme = Theme.of(context);

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

            if (title != null)
            {
                body.Add(new Padding(
                             padding: titlePadding,
                             child: new DefaultTextStyle(
                                 style: theme.textTheme.headline6,
                                 child: title
                                 )
                             ));
            }

            if (children != null)
            {
                body.Add(new Flexible(
                             child: new SingleChildScrollView(
                                 padding: contentPadding,
                                 child: new ListBody(children: 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: backgroundColor,
                       elevation: elevation,
                       shape: shape,
                       child: dialogChild
                       ));
        }
コード例 #3
0
ファイル: CustomDialog.cs プロジェクト: soulhez/ConnectAppCN
        public override Widget build(BuildContext context)
        {
            var children = new List <Widget>();

            if (this.title.isNotEmpty())
            {
                children.Add(
                    new Container(
                        padding: EdgeInsets.only(16, 24, 16, this.message == null ? 24 : 8),
                        alignment: Alignment.center,
                        child: new Text(
                            data: this.title,
                            style: CTextStyle.PLargeMedium,
                            textAlign: TextAlign.center
                            )
                        ));
            }

            if (this.message.isNotEmpty())
            {
                var mediaQuery        = MediaQuery.of(context: context);
                var horizontalPadding = mediaQuery.viewInsets.left + mediaQuery.viewInsets.right + 40 + 40;
                var width             = mediaQuery.size.width - horizontalPadding - 32;
                var maxHeight         = CTextUtils.CalculateTextHeight(
                    text: this.message, textStyle: this._messageStyle, textWidth: width, 7);
                var totalHeight = CTextUtils.CalculateTextHeight(
                    text: this.message, textStyle: this._messageStyle, textWidth: width);
                if (maxHeight < totalHeight)
                {
                    maxHeight += 16;
                }
                else
                {
                    maxHeight += 32;
                }

                children.Add(new Container(
                                 height: maxHeight,
                                 alignment: Alignment.center,
                                 child: new CustomScrollbar(
                                     new SingleChildScrollView(
                                         child: new Padding(
                                             padding: EdgeInsets.only(16, 8, 16, 16),
                                             child: new Text(
                                                 data: this.message,
                                                 style: this._messageStyle
                                                 )
                                             )
                                         )
                                     )
                                 ));
            }

            if (this.actions != null)
            {
                children.Add(new CustomDivider(
                                 height: 1
                                 ));

                var _children = new List <Widget>();
                foreach (var _child in this.actions)
                {
                    _children.Add(new Expanded(
                                      child: new Stack(
                                          fit: StackFit.expand,
                                          children: new List <Widget> {
                        _child
                    }
                                          )
                                      ));
                    var index = this.actions.IndexOf(_child);
                    if (index < this.actions.Count - 1)
                    {
                        _children.Add(new Container(
                                          width: 1,
                                          color: CColors.Separator
                                          ));
                    }
                }

                Widget child = new Container(
                    height: 48,
                    child: new Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: _children
                        )
                    );
                children.Add(item: child);
            }

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

            return(new CustomDialog(
                       backgroundColor: CColors.White,
                       radius: 5,
                       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)
        {
            var children = new List <Widget>();

            if (this.title.isNotEmpty())
            {
                children.Add(new Container(
                                 padding: EdgeInsets.fromLTRB(16, 24, 16, this.message == null ? 24 : 0),
                                 alignment: Alignment.center,
                                 child: new Text(this.title,
                                                 style: CTextStyle.H5
                                                 )
                                 ));
            }

            if (this.message.isNotEmpty())
            {
                children.Add(new Container(
                                 padding: EdgeInsets.all(16),
                                 alignment: Alignment.center,
                                 child: new Text(this.message,
                                                 style: CTextStyle.PLargeBody
                                                 )
                                 ));
            }

            if (this.actions != null)
            {
                children.Add(new CustomDivider(
                                 height: 1
                                 ));

                var _children = new List <Widget>();
                foreach (var _child in this.actions)
                {
                    _children.Add(new Expanded(
                                      child: new Stack(
                                          fit: StackFit.expand,
                                          children: new List <Widget> {
                        _child
                    }
                                          )
                                      ));
                    var index = this.actions.IndexOf(_child);
                    if (index < this.actions.Count - 1)
                    {
                        _children.Add(new Container(
                                          width: 1,
                                          color: CColors.Separator
                                          ));
                    }
                }

                Widget child = new Container(
                    height: 48,
                    child: new Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: _children
                        )
                    );
                children.Add(child);
            }

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

            return(new CustomDialog(
                       backgroundColor: CColors.White,
                       radius: 5,
                       child: dialogChild
                       ));
        }