コード例 #1
0
        public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight)
        {
            Widget handle = new SizedBox(
                width: MaterialUtils._kHandleSize,
                height: MaterialUtils._kHandleSize,
                child: new CustomPaint(
                    painter: new _TextSelectionHandlePainter(
                        color: Theme.of(context).textSelectionHandleColor
                        )
                    )
                );

            switch (type)
            {
            case TextSelectionHandleType.left:     // points up-right
                return(new Transform(
                           transform: Matrix4.rotationZ(Mathf.PI / 2),
                           child: handle
                           ));

            case TextSelectionHandleType.right:     // points up-left
                return(handle);

            case TextSelectionHandleType.collapsed:     // points up
                return(new Transform(
                           transform: Matrix4.rotationZ(Mathf.PI / 4),
                           child: handle
                           ));
            }

            return(null);
        }
コード例 #2
0
 public override Widget build(BuildContext context)
 {
     return(new Expanded(
                flex: flex,
                child: SizedBox.shrink()
                ));
 }
コード例 #3
0
ファイル: TipMenu.cs プロジェクト: zuoyanshun/ConnectAppCN
        public override Widget build(BuildContext context)
        {
            List <Widget> items = new List <Widget>();
            Widget        onePhysicalPixelVerticalDivider =
                new SizedBox(width: 1.0f / MediaQuery.of(context: context).devicePixelRatio);

            this.widget.tipMenuItems.ForEach(tipMenuItem => {
                items.Add(_buildToolbarButton(text: tipMenuItem.title, onPressed: tipMenuItem.onTap));
                var index = this.widget.tipMenuItems.IndexOf(item: tipMenuItem);
                if (this.widget.tipMenuItems.Count > 1 && index < this.widget.tipMenuItems.Count)
                {
                    items.Add(item: onePhysicalPixelVerticalDivider);
                }
            });

            Widget toolbar = new ClipRRect(
                borderRadius: CustomTextSelectionControlsUtils._kToolbarBorderRadius,
                child: new DecoratedBox(
                    decoration: new BoxDecoration(
                        color: CustomTextSelectionControlsUtils._kToolbarDividerColor,
                        borderRadius: CustomTextSelectionControlsUtils._kToolbarBorderRadius,
                        border: Border.all(color: CustomTextSelectionControlsUtils._kToolbarBackgroundColor, 0)
                        ),
                    child: new Row(mainAxisSize: MainAxisSize.min, children: items)
                    )
                );

            return(new AnimatedBuilder(
                       animation: this._animationController,
                       builder: (cxt, child) => new Opacity(
                           opacity: this._animationOpacity.value,
                           child: toolbar
                           )
                       ));
        }
コード例 #4
0
        public override Widget build(BuildContext context)
        {
            Widget child = new SizedBox(
                width: widget.count * widget.size + (widget.count - 1) * widget.space,
                height: widget.size,
                child: new CustomPaint(
                    painter: _createPainer()
                    )


                );

            if (widget.layout == PageIndicatorLayout.SCALE ||
                widget.layout == PageIndicatorLayout.COLOR)
            {
                child = new ClipRect(
                    child: child


                    );
            }

            return(new IgnorePointer(
                       child: child


                       ));
        }
コード例 #5
0
ファイル: visibility.cs プロジェクト: JC-ut0/CubeGame
 public Visibility(
     Key key                    = null,
     Widget child               = null,
     Widget replacement         = null,
     bool visible               = true,
     bool maintainState         = false,
     bool maintainAnimation     = false,
     bool maintainSize          = false,
     bool maintainInteractivity = false
     ) : base(key: key)
 {
     D.assert(child != null);
     D.assert(maintainState == true || maintainAnimation == false,
              () => "Cannot maintain animations if the state is not also maintained.");
     D.assert(maintainAnimation == true || maintainSize == false,
              () => "Cannot maintain size if animations are not maintained.");
     D.assert(maintainSize == true || maintainInteractivity == false,
              () => "Cannot maintain interactivity if size is not maintained.");
     this.replacement           = replacement ?? SizedBox.shrink();
     this.child                 = child;
     this.visible               = visible;
     this.maintainState         = maintainState;
     this.maintainAnimation     = maintainAnimation;
     this.maintainSize          = maintainSize;
     this.maintainInteractivity = maintainInteractivity;
 }
コード例 #6
0
        public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight)
        {
            Size   desiredSize = getHandleSize(textLineHeight);
            Widget handle      = SizedBox.fromSize(
                size: desiredSize,
                child: new CustomPaint(
                    painter: new _TextSelectionHandlePainter(CupertinoTheme.of(context).primaryColor)
                    )
                );
            var result = Matrix4.identity();

            result.translate(desiredSize.width / 2, desiredSize.height / 2);
            result.rotateZ(Mathf.PI);
            result.translate(-desiredSize.width / 2, -desiredSize.height / 2);
            switch (type)
            {
            case TextSelectionHandleType.left:
                return(handle);

            case TextSelectionHandleType.right:
                return(new Transform(
                           transform: result,
                           child: handle
                           ));

            case TextSelectionHandleType.collapsed:
                return(new SizedBox());
            }
            D.assert(type != null);
            return(null);
        }
コード例 #7
0
            private Widget _buildImage(string src)
            {
                string[] parts = src.Split('#');
                if (parts.isEmpty())
                {
                    return(SizedBox.expand());
                }

                string path = parts.first();
                float  width = 0, height = 0;

                if (parts.Length == 2)
                {
                    var dimensions = parts.last().Split('x');
                    if (dimensions.Length == 2)
                    {
                        width  = float.Parse(dimensions[0]);
                        height = float.Parse(dimensions[1]);
                    }
                }

                Uri    uri = new Uri(path);
                Widget child;

                if (uri.Scheme == "http" || uri.Scheme == "https")
                {
                    child = Image.network(uri.ToString(), null, 1);
                }
                else if (uri.Scheme == "data")
                {
                    child = _handleDataSchemeUri(uri, width, height);
                }
                else if (uri.Scheme == "resource")
                {
                    //TODO:
                    child = Image.asset(path.Substring(9), null, null, width, height);
                }
                else
                {
                    string filePath = imageDirectory == null
                        ? uri.ToString()
                        : System.IO.Path.Combine(imageDirectory, uri.ToString());

                    child = Image.file(filePath, null, 1, width, height);
                }

                if (_linkHandlers.isNotEmpty())
                {
                    TapGestureRecognizer recognizer = _linkHandlers.last() as TapGestureRecognizer;
                    return(new GestureDetector(null, child, null, null, recognizer.onTap));
                }
                else
                {
                    return(child);
                }
            }
コード例 #8
0
 public override Widget build(BuildContext context)
 {
     return(new CustomPaint(
                foregroundPainter: new _MaterialPainter(
                    SrcOffset, SrcSize, GameMaterial.GetMaterial(context)
                    ),
                child:
                SizedBox.fromSize(size: Size)
                ));
 }
コード例 #9
0
 static Widget _buildTriangle()
 {
     return(SizedBox.fromSize(
                size: triangleSize,
                child: new CustomPaint(
                    painter: new TrianglePainter(
                        arrowDirection: ArrowDirection.up,
                        color: CColors.PrimaryBlue
                        )
                    )
                ));
 }
コード例 #10
0
        public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight)
        {
            Size desiredSize = new Size(
                2.0f * CustomTextSelectionControlsUtils._kHandlesPadding,
                textLineHeight + 2.0f * CustomTextSelectionControlsUtils._kHandlesPadding
                );

            Widget handle = SizedBox.fromSize(
                size: desiredSize,
                child: new CustomPaint(
                    painter: new _TextSelectionHandlePainter(
                        new Offset(
                            CustomTextSelectionControlsUtils._kHandlesPadding,
                            textLineHeight + CustomTextSelectionControlsUtils._kHandlesPadding
                            )
                        )
                    )
                );

            switch (type)
            {
            case TextSelectionHandleType.left: {
                Matrix3 matrix3 = Matrix3.makeRotate(Mathf.PI);
                matrix3.preConcat(
                    Matrix3.makeTrans(
                        -CustomTextSelectionControlsUtils._kHandlesPadding,
                        -CustomTextSelectionControlsUtils._kHandlesPadding
                        )
                    );
                return(new Transform(
                           transform: matrix3,
                           child: handle
                           ));
            }

            case TextSelectionHandleType.right: {
                return(new Transform(
                           transform: Matrix3.makeTrans(
                               -CustomTextSelectionControlsUtils._kHandlesPadding,
                               -(textLineHeight + CustomTextSelectionControlsUtils._kHandlesPadding)
                               ),
                           child: handle
                           ));
            }

            case TextSelectionHandleType.collapsed:
                return(new Container());

            default:
                return(null);
            }
        }
コード例 #11
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
            return(new LayoutBuilder(builder: (BuildContext _, BoxConstraints constraints) => {
                List <Widget> wrappedChildren = new List <Widget> {
                };
                if (this.widget.header != null)
                {
                    wrappedChildren.Add(this.widget.header);
                }

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

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

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

                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
                    );
            }));
        }
コード例 #12
0
 public override Widget build(BuildContext context)
 {
     return(new LayoutBuilder(
                builder: (BuildContext subContext, BoxConstraints subConstraints) => {
         _extent.availablePixels = widget.maxChildSize * subConstraints.biggest.height;
         Widget sheet = new FractionallySizedBox(
             heightFactor: _extent.currentExtent,
             child: widget.builder(subContext, _scrollController),
             alignment: Alignment.bottomCenter
             );
         return widget.expand ? SizedBox.expand(child: sheet) : sheet;
     }
                ));
 }
コード例 #13
0
        public override Widget build(BuildContext context)
        {
            List <Widget> items = new List <Widget>();
            Widget        onePhysicalPixelVerticalDivider =
                new SizedBox(width: 1.0f / MediaQuery.of(context: context).devicePixelRatio);

            this.tipMenuItems.ForEach(tipMenuItem => {
                items.Add(_buildToolbarButton(text: tipMenuItem.title, onPressed: tipMenuItem.onTap));
                var index = this.tipMenuItems.IndexOf(item: tipMenuItem);
                if (this.tipMenuItems.Count > 1 && index < this.tipMenuItems.Count)
                {
                    items.Add(item: onePhysicalPixelVerticalDivider);
                }
            });

            Widget triangle = SizedBox.fromSize(
                size: CustomTextSelectionControlsUtils._kToolbarTriangleSize,
                child: new CustomPaint(
                    painter: new TrianglePainter(
                        arrowDirection: this.arrowDirection
                        )
                    )
                );

            Widget toolbar = new ClipRRect(
                borderRadius: CustomTextSelectionControlsUtils._kToolbarBorderRadius,
                child: new DecoratedBox(
                    decoration: new BoxDecoration(
                        color: CustomTextSelectionControlsUtils._kToolbarDividerColor,
                        borderRadius: CustomTextSelectionControlsUtils._kToolbarBorderRadius,
                        border: Border.all(color: CustomTextSelectionControlsUtils._kToolbarBackgroundColor, 0)
                        ),
                    child: new Row(mainAxisSize: MainAxisSize.min, children: items)
                    )
                );

            List <Widget> menus = this.arrowDirection == ArrowDirection.down
                ? new List <Widget> {
                toolbar, triangle
            }
                : new List <Widget> {
                triangle, toolbar
            };

            return(new Column(
                       mainAxisSize: MainAxisSize.min,
                       children: menus
                       ));
        }
コード例 #14
0
 public override Widget build(BuildContext context)
 {
     return(SizedBox.fromSize(size: AppConstants.DIRECTION_BUTTON_SIZE * 2.8f,
                              child: Transform.rotate(
                                  origin: new Offset(90, 90),
                                  degree: Mathf.PI / 4,
                                  child: new Column(
                                      mainAxisSize: MainAxisSize.min,
                                      children: new List <Widget>()
     {
         new SizedBox(height: AppConstants.DIRECTION_BUTTON_SPACE),
         new Row(
             children: new List <Widget>()
         {
             new SizedBox(width: AppConstants.DIRECTION_BUTTON_SPACE),
             new GBButton(
                 size: AppConstants.DIRECTION_BUTTON_SIZE,
                 () => { Game.of(context).Drop(); }
                 ),
             new SizedBox(width: AppConstants.DIRECTION_BUTTON_SPACE),
             new GBButton(
                 size: AppConstants.DIRECTION_BUTTON_SIZE,
                 () => { Game.of(context).Right(); }
                 )
         }
             ),
         new SizedBox(height: AppConstants.DIRECTION_BUTTON_SPACE),
         new Row(
             children: new List <Widget>()
         {
             new SizedBox(width: AppConstants.DIRECTION_BUTTON_SPACE),
             new GBButton(
                 size: AppConstants.DIRECTION_BUTTON_SIZE,
                 () => { Game.of(context).Left(); }
                 ),
             new SizedBox(width: AppConstants.DIRECTION_BUTTON_SPACE),
             new GBButton(
                 size: AppConstants.DIRECTION_BUTTON_SIZE,
                 () => { Game.of(context).Down(); }
                 )
         }
             ),
         new SizedBox(height: AppConstants.DIRECTION_BUTTON_SPACE)
     }
                                      )
                                  )
                              ));
 }
コード例 #15
0
ファイル: ink_decoration.cs プロジェクト: JC-ut0/CubeGame
        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);
        }
コード例 #16
0
    public override Widget _buildItem(int index, int realIndex, float animationValue)
    {
        List <Build> builders = widget.option.builders;

        Widget child = new SizedBox(
            width: widget.itemWidth,
            height: widget.itemHeight,
            child: widget.itemBuilder(context, realIndex));

        for (int i = builders.Count - 1; i >= 0; --i)
        {
            Build builder = builders[i];
            child = builder.build(index, animationValue, child);
        }

        return(child);
    }
コード例 #17
0
        protected override Widget _buildItem(int index, int realIndex, float animationValue)
        {
            List <TransformBuilder> builders = this.widget.option.builders;

            Widget child = new SizedBox(
                width: this.widget.itemWidth ?? float.PositiveInfinity,
                height: this.widget.itemHeight ?? float.PositiveInfinity,
                child: this.widget.itemBuilder(context: this.context, index: realIndex));

            for (int i = builders.Count - 1; i >= 0; --i)
            {
                TransformBuilder builder = builders[i];
                child = builder.build(i: index, animationValue: animationValue, widget: child);
            }

            return(child);
        }
コード例 #18
0
        public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight)
        {
            Size desiredSize = new Size(
                2.0f * CupertinoTextSelectionUtils._kHandlesPadding,
                textLineHeight + 2.0f * CupertinoTextSelectionUtils._kHandlesPadding
                );

            Widget handle = SizedBox.fromSize(
                size: desiredSize,
                child: new CustomPaint(
                    painter: new _TextSelectionHandlePainter(
                        origin: new Offset(CupertinoTextSelectionUtils._kHandlesPadding,
                                           textLineHeight + CupertinoTextSelectionUtils._kHandlesPadding)
                        )
                    )
                );

            switch (type)
            {
            case TextSelectionHandleType.left:
                Matrix4 matrix = new Matrix4().rotationZ(Mathf.PI);
                matrix.translate(-CupertinoTextSelectionUtils._kHandlesPadding,
                                 -CupertinoTextSelectionUtils._kHandlesPadding);

                return(new Transform(
                           transform: matrix,
                           child: handle
                           ));

            case TextSelectionHandleType.right:
                return(new Transform(
                           transform: new Matrix4().translationValues(
                               -CupertinoTextSelectionUtils._kHandlesPadding,
                               -(textLineHeight + CupertinoTextSelectionUtils._kHandlesPadding),
                               0
                               ),
                           child: handle
                           ));

            case TextSelectionHandleType.collapsed:
                return(new Container());
            }

            return(null);
        }
コード例 #19
0
ファイル: TipMenu.cs プロジェクト: zuoyanshun/ConnectAppCN
        public override Widget build(BuildContext context)
        {
            Widget triangle = SizedBox.fromSize(
                size: CustomTextSelectionControlsUtils._kToolbarTriangleSize,
                child: new CustomPaint(
                    painter: new TrianglePainter(
                        arrowDirection: this.widget.arrowDirection
                        )
                    )
                );

            return(new AnimatedBuilder(
                       animation: this._animationController,
                       builder: (cxt, child) => new Opacity(
                           opacity: this._animationOpacity.value,
                           child: triangle
                           )
                       ));
        }
コード例 #20
0
        public readonly BannerTapCallback onBannerTap; // User taps on the photo's header or footer.

        private void showPhoto(BuildContext context)
        {
            Navigator.push <object>(context, new MaterialPageRoute(
                                        builder: (BuildContext subContext) =>
            {
                return(new Scaffold(
                           appBar: new AppBar(
                               title: new Text(photo.title)
                               ),
                           body: SizedBox.expand(
                               child: new Hero(
                                   tag: photo.tag,
                                   child: new GridPhotoViewer(photo: photo)
                                   )
                               )
                           ));
            }
                                        ));
        }
コード例 #21
0
        public override Widget build(BuildContext context)
        {
            var size = MediaQuery.of(context).size;

            var screenWidth = size.width * 0.8f;

            return(new Game(
                       child: new KeyboardController(
                           child: SizedBox.expand(
                               child: new Container(
                                   color: AppConstants.APP_BACKGROUND_COLOR,
                                   child: new Padding(
                                       padding: MediaQuery.of(context).padding,
                                       child: new Column(
                                           children: new List <Widget>
            {
                new Row(
                    children: new List <Widget>()
                {
                    new Spacer(),
                    new FlatButton(
                        onPressed: () =>
                    {
                        DialogUtils.showDialog(context,
                                               builder: ctx => new DonationDialog());
                    },
                        child: new Text(L.of(context).Reward)
                        )
                }
                    ),
                new Spacer(),
                new ScreenDecoration(child: new GBScreen(width: screenWidth)),
                new Spacer(flex: 2),
                new GBJoyStick()
            }
                                           )
                                       )
                                   )
                               )
                           )
                       ));
        }
コード例 #22
0
        public override Widget build(BuildContext context)
        {
            Widget child = new SizedBox(
                width: this.widget.count * this.widget.size + (this.widget.count - 1) * this.widget.space,
                height: this.widget.size,
                child: new CustomPaint(
                    painter: this._createPainter()
                    )
                );

            if (this.widget.layout == PageIndicatorLayout.scale || this.widget.layout == PageIndicatorLayout.color)
            {
                child = new ClipRect(
                    child: child
                    );
            }

            return(new IgnorePointer(
                       child: child
                       ));
        }
コード例 #23
0
        public override Widget build(BuildContext context)
        {
            var width = BrickSize.of(context).Size.width;

            return(SizedBox.fromSize(
                       size: new Size(width, width),
                       child: new Container(
                           margin: EdgeInsets.all(width * 0.05f),
                           padding: EdgeInsets.all(width * 0.1f),
                           decoration: new BoxDecoration(
                               border: Border.all(
                                   color: mColor,
                                   width: width * 0.1f
                                   )
                               ),
                           child: new Container(
                               color: mColor
                               )
                           )
                       ));
        }
コード例 #24
0
        public override Widget build(BuildContext context)
        {
            List <Widget> items = new List <Widget>();
            Widget        onePhysicalPixelVerticalDivider =
                new SizedBox(width: 1.0f / MediaQuery.of(context).devicePixelRatio);
            CupertinoLocalizations localizations = CupertinoLocalizations.of(context);

            if (this.handleCut != null)
            {
                items.Add(this._buildToolbarButton(localizations.cutButtonLabel, this.handleCut));
            }

            if (this.handleCopy != null)
            {
                if (items.isNotEmpty())
                {
                    items.Add(onePhysicalPixelVerticalDivider);
                }

                items.Add(this._buildToolbarButton(localizations.copyButtonLabel, this.handleCopy));
            }

            if (this.handlePaste != null)
            {
                if (items.isNotEmpty())
                {
                    items.Add(onePhysicalPixelVerticalDivider);
                }

                items.Add(this._buildToolbarButton(localizations.pasteButtonLabel, this.handlePaste));
            }

            if (this.handleSelectAll != null)
            {
                if (items.isNotEmpty())
                {
                    items.Add(onePhysicalPixelVerticalDivider);
                }

                items.Add(this._buildToolbarButton(localizations.selectAllButtonLabel, this.handleSelectAll));
            }

            Widget triangle = SizedBox.fromSize(
                size: CupertinoTextSelectionUtils._kToolbarTriangleSize,
                child: new CustomPaint(
                    painter: new _TextSelectionToolbarNotchPainter()
                    )
                );

            return(new Column(
                       mainAxisSize: MainAxisSize.min,
                       children: new List <Widget> {
                new ClipRRect(
                    borderRadius: CupertinoTextSelectionUtils._kToolbarBorderRadius,
                    child: new DecoratedBox(
                        decoration: new BoxDecoration(
                            color: CupertinoTextSelectionUtils._kToolbarDividerColor,
                            borderRadius: CupertinoTextSelectionUtils._kToolbarBorderRadius,
                            border: Border.all(color: CupertinoTextSelectionUtils._kToolbarBackgroundColor,
                                               width: 0)
                            ),
                        child: new Row(mainAxisSize: MainAxisSize.min, children: items)
                        )
                    ),
                triangle,
                new Padding(padding: EdgeInsets.only(bottom: 10.0f))
            }
                       ));
        }
コード例 #25
0
        Widget _buildBody(BuildContext context)
        {
            MediaQueryData mediaQueryData  = MediaQuery.of(context);
            float          statusBarHeight = mediaQueryData.padding.top;
            float          screenHeight    = mediaQueryData.size.height;
            float          appBarMaxHeight = screenHeight - statusBarHeight;

            float appBarMidScrollOffset = statusBarHeight + appBarMaxHeight - AnimationHomeUtils._kAppBarMidHeight;

            return(SizedBox.expand(
                       child: new Stack(
                           children: new List <Widget> {
                new NotificationListener <ScrollNotification>(
                    onNotification: (ScrollNotification notification) => {
                    return this._handleScrollNotification(notification, appBarMidScrollOffset);
                },
                    child: new CustomScrollView(
                        controller: this._scrollController,
                        physics: new _SnappingScrollPhysics(midScrollOffset: appBarMidScrollOffset),
                        slivers: new List <Widget> {
                    new _StatusBarPaddingSliver(
                        maxHeight: statusBarHeight,
                        scrollFactor: 7.0f
                        ),
                    new SliverPersistentHeader(
                        pinned: true,
                        del: new _SliverAppBarDelegate(
                            minHeight: AnimationHomeUtils._kAppBarMinHeight,
                            maxHeight: appBarMaxHeight,
                            child: new NotificationListener <ScrollNotification>(
                                onNotification: (ScrollNotification notification) => {
                        return this._handlePageNotification(notification,
                                                            this._headingPageController, this._detailsPageController);
                    },
                                child: new PageView(
                                    physics: this._headingScrollPhysics,
                                    controller: this._headingPageController,
                                    children: this._allHeadingItems(appBarMaxHeight,
                                                                    appBarMidScrollOffset)
                                    )
                                )
                            )
                        ),
                    new SliverToBoxAdapter(
                        child: new SizedBox(
                            height: 610.0f,
                            child: new NotificationListener <ScrollNotification>(
                                onNotification: (ScrollNotification notification) => {
                        return this._handlePageNotification(notification,
                                                            this._detailsPageController, this._headingPageController);
                    },
                                child: new PageView(
                                    controller: this._detailsPageController,
                                    children: AnimationSectionsUtils.allSections
                                    .Select <Section, Widget>((Section section) => {
                        return new Column(
                            crossAxisAlignment: CrossAxisAlignment.stretch,
                            children: this._detailItemsFor(section).ToList()
                            );
                    }).ToList()
                                    )
                                )
                            )
                        )
                }
                        )
                    ),
                new Positioned(
                    top: statusBarHeight,
                    left: 0.0f,
                    child: new IconTheme(
                        data: new IconThemeData(color: Colors.white),
                        child: new SafeArea(
                            top: false,
                            bottom: false,
                            child: new IconButton(
                                icon: new BackButtonIcon(),
                                tooltip: "Back",
                                onPressed: () => { this._handleBackButton(appBarMidScrollOffset); }
                                )
                            )
                        )
                    )
            }
                           )
                       ));
        }
コード例 #26
0
 public override Widget build(BuildContext context, float shrinkOffset, bool overlapsContent)
 {
     return(SizedBox.expand(child: this.child));
 }
コード例 #27
0
            public override void visitElementAfter(markdown.Element element)
            {
                string tag = element.tag;
                if (_isBlockTag(tag))
                {
                    _addAnonymousBLockIfNeeded(styleSheet.styles(tag));

                    _BlockElement current = _blocks.removeLast();
                    Widget child;

                    if (current.children.isNotEmpty())
                    {
                        child = new Column(null, null, null, MainAxisAlignment.start, MainAxisSize.max,
                            CrossAxisAlignment.stretch, VerticalDirection.down, current.children);
                    }
                    else
                    {
                        child = new SizedBox();
                    }

                    if (_isListTag(tag))
                    {
                        Debug.Assert(_listIndents.isNotEmpty(), "_listIndents.isNotEmpty()");
                        _listIndents.removeLast();
                    }
                    else if (tag == "li")
                    {
                        if (_listIndents.isNotEmpty())
                        {
                            child = new Row(
                                null,
                                null,
                                null,
                                MainAxisAlignment.start,
                                MainAxisSize.max,
                                CrossAxisAlignment.start,
                                VerticalDirection.down,
                                new List<Widget>()
                                {
                                    new SizedBox(null, styleSheet.listIndent, null, _buildBullet(_listIndents.last())),
                                    new Expanded(null, 1, child)
                                });
                        }
                    }
                    else if (tag == "blockquote")
                    {
                        child = new DecoratedBox(
                            null,
                            styleSheet.blockquoteDecoration,
                            DecorationPosition.background,
                            new Padding(
                                null,
                                EdgeInsets.all(styleSheet.blockquotePadding),
                                child));
                    }
                    else if (tag == "pre")
                    {
                        child = new DecoratedBox(
                            null,
                            styleSheet.codeblockDecoration,
                            DecorationPosition.background,
                            new Padding(
                                null,
                                EdgeInsets.all(styleSheet.codeblockPadding),
                                child));
                    }
                    else if (tag == "hr")
                    {
                        child = new DecoratedBox(
                            null,
                            styleSheet.horizontalRuleDecoration,
                            DecorationPosition.background,
                            child);
                    }

                    _addBlockChild(child);
                }
                else
                {
                    _InlineElement current = _inlines.removeLast();
                    _InlineElement parent = _inlines.last();

                    if (tag == "img")
                    {
                        current.children.Add(_buildImage(element.attributes["src"]));
                    }
                    else if (tag == "a")
                    {
                        _linkHandlers.removeLast();
                    }

                    if (current.children.isNotEmpty())
                    {
                        parent.children.AddRange(current.children);
                    }
                }
            }
コード例 #28
0
        public override Widget build(BuildContext context)
        {
            List <Widget> items = new List <Widget>();
            Widget        onePhysicalPixelVerticalDivider =
                new SizedBox(width: 1.0f / MediaQuery.of(context).devicePixelRatio);

            if (this.handleCut != null)
            {
                items.Add(_buildToolbarButton("剪切", this.handleCut));
            }

            if (this.handleCopy != null)
            {
                if (items.isNotEmpty())
                {
                    items.Add(onePhysicalPixelVerticalDivider);
                }

                items.Add(_buildToolbarButton("拷贝", this.handleCopy));
            }

            if (this.handlePaste != null)
            {
                if (items.isNotEmpty())
                {
                    items.Add(onePhysicalPixelVerticalDivider);
                }

                items.Add(_buildToolbarButton("粘贴", this.handlePaste));
            }

            if (this.handleSelectAll != null)
            {
                if (items.isNotEmpty())
                {
                    items.Add(onePhysicalPixelVerticalDivider);
                }

                items.Add(_buildToolbarButton("全选", this.handleSelectAll));
            }

            Widget padding = new Padding(padding: EdgeInsets.only(bottom: 10.0f));

            Widget triangle = SizedBox.fromSize(
                size: CustomTextSelectionControlsUtils._kToolbarTriangleSize,
                child: new CustomPaint(
                    painter: new _TextSelectionToolbarNotchPainter((_ArrowDirection)this.arrowDirection)
                    )
                );

            Widget toolbar = new ClipRRect(
                borderRadius: CustomTextSelectionControlsUtils._kToolbarBorderRadius,
                child: new DecoratedBox(
                    decoration: new BoxDecoration(
                        color: CustomTextSelectionControlsUtils._kToolbarDividerColor,
                        borderRadius: CustomTextSelectionControlsUtils._kToolbarBorderRadius,
                        border: Border.all(color: CustomTextSelectionControlsUtils._kToolbarBackgroundColor, 0)
                        ),
                    child: new Row(mainAxisSize: MainAxisSize.min, children: items)
                    )
                );

            List <Widget> menus = this.arrowDirection == _ArrowDirection.down
                ? new List <Widget> {
                toolbar, triangle, padding
            }
                : new List <Widget> {
                padding, triangle, toolbar
            };

            return(new Column(
                       mainAxisSize: MainAxisSize.min,
                       children: menus
                       ));
        }
コード例 #29
0
            Widget _buildImage(string src)
            {
                string[] parts = src.Split('#');
                if (parts.isEmpty()) return SizedBox.expand();

                string path = parts.first();
                float? width = null, height = null;
                if (parts.Length == 2)
                {
                    var dimensions = parts.last().Split('x');
                    if (dimensions.Length == 2)
                    {
                        width = float.Parse(dimensions[0]);
                        height = float.Parse(dimensions[1]);
                    }
                }

                Uri uri;
                Widget child = null;
                if (Uri.TryCreate(src, UriKind.RelativeOrAbsolute, out uri) && uri.IsAbsoluteUri)
                {
                    if (uri.Scheme == "http" || uri.Scheme == "https")
                    {
                        child = Image.network(src: uri.ToString(), scale: 1, width: width, height: height);
                    }
                    else if (uri.Scheme == "data")
                    {
                        child = _handleDataSchemeUri(uri, width, height);
                    }
                    else if (uri.Scheme == "resource")
                    {
                        child = Image.asset(path.Substring(9), scale: 1, width: width, height: height);
                    }
                    else if (uri.Scheme == "file")
                    {
                        child = Image.file(file: uri.ToString(), scale: 1, width: width, height: height);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(imageDirectory))
                    {
                        if (imageDirectory.StartsWith("http"))
                        {
                            uri = new Uri(new Uri(imageDirectory), uri);
                            child = Image.network(src: uri.ToString(), scale: 1, width: width, height: height);
                        }
                        else
                        {
                            child = Image.file(file: System.IO.Path.Combine(imageDirectory, uri.ToString()), scale: 1, width: width, height: height);
                        }
                    }
                    else
                    {
                        child = Image.file(file: uri.ToString(), scale: 1, width: width, height: height);
                    }
                }

                if (_linkHandlers.isNotEmpty())
                {
                    TapGestureRecognizer recognizer = _linkHandlers.last() as TapGestureRecognizer;
                    return new GestureDetector(null, child, null, null, recognizer.onTap);
                }
                else
                {
                    return child;
                }
            }
コード例 #30
0
 Widget _handleDataSchemeUri(Uri uri, float? width, float? height)
 {
     //TODO:
     return SizedBox.expand();
 }