Exemplo n.º 1
0
 public override Widget buildTransitions(BuildContext context1, Animation <float> animation, Animation <float> secondaryAnimation, Widget child)
 {
     return(new OrientationBuilder(
                builder: (BuildContext context2, Orientation orientation) => {
         _lastOrientation = orientation;
         if (!animation.isCompleted)
         {
             bool reverse = animation.status == AnimationStatus.reverse;
             Rect rect = reverse
                     ? _rectAnimatableReverse.evaluate(animation)
                     : _rectAnimatable.evaluate(animation);
             Rect sheetRect = reverse
                     ? _sheetRectAnimatableReverse.evaluate(animation)
                     : _sheetRectAnimatable.evaluate(animation);
             float?sheetScale = reverse
                     ? _sheetScaleAnimatableReverse.evaluate(animation)
                     : _sheetScaleAnimatable.evaluate(animation);
             List <Widget> widgets = new List <Widget>();
             widgets.Add(
                 Positioned.fromRect(
                     rect: sheetRect,
                     child: new Opacity(
                         opacity: _sheetOpacity.value,
                         child: Transform.scale(
                             alignment: getSheetAlignment(_contextMenuLocation),
                             scale: sheetScale ?? 1.0f,
                             child: new _ContextMenuSheet(
                                 key: _sheetGlobalKey,
                                 actions: _actions,
                                 contextMenuLocation: _contextMenuLocation,
                                 orientation: orientation
                                 )
                             )
                         )
                     )
                 );
             widgets.Add(
                 Positioned.fromRect(
                     key: _childGlobalKey,
                     rect: rect,
                     child: _builder(context2, animation)
                     ));
             return new Stack(
                 children: widgets
                 );
         }
         return new _ContextMenuRouteStatic(
             actions: _actions,
             child: _builder(context1, animation),
             childGlobalKey: _childGlobalKey,
             contextMenuLocation: _contextMenuLocation,
             onDismiss: _onDismiss,
             orientation: orientation,
             sheetGlobalKey: _sheetGlobalKey
             );
     }
                ));
 }
Exemplo n.º 2
0
 // Build the animation for the _ContextMenuSheet.
 Widget _buildSheetAnimation(BuildContext context, Widget child)
 {
     return(Transform.scale(
                alignment: _ContextMenuRoute.getSheetAlignment(widget.contextMenuLocation),
                scale: _sheetScaleAnimation.value,
                child: new Opacity(
                    opacity: _sheetOpacityAnimation.value,
                    child: child
                    )
                ));
 }
Exemplo n.º 3
0
 // Build the animation for the child.
 Widget _buildChildAnimation(BuildContext context, Widget child)
 {
     _lastScale = _getScale(
         widget.orientation,
         MediaQuery.of(context).size.height,
         _moveAnimation.value.dy
         );
     return(Transform.scale(
                key: widget.childGlobalKey,
                scale: _lastScale,
                child: child
                ));
 }
        public override Widget build(BuildContext context)
        {
            return(new GestureDetector
                   (
                       onLongPressDragUpdate: details =>
            {
//                    Debug.Log("onLongPressDragUpdate");
            },
                       onScaleStart: details =>
            {
                MoveEndVelocity = Offset.zero;
                previousScrollPosition = details.focalPoint;
                previousDragPosition = details.focalPoint;
            },
                       onScaleUpdate: details =>
            {
//                    Debug.Log("onScaleUpdate");
                MoveEndVelocity = Offset.zero;
                float scaleDiff = previousScale * (details.scale - 1);
                if (aimedScale >= widget.MaxScale && scaleDiff > 0)
                {
                    scaleDiff = 0;
                }

                if (aimedScale <= widget.MinScale && scaleDiff < 0)
                {
                    scaleDiff = 0;
                }
                scroll(details.focalPoint, scaleDiff);
                move(details.focalPoint);
//                    postCheck();
            },
                       onScaleEnd: details =>
            {
                MoveEndVelocity = details.velocity.pixelsPerSecond;
            },
                       onVerticalDragStart: details =>
            {
                MoveEndVelocity = Offset.zero;
                previousScrollPosition = details.globalPosition;
                previousDragPosition = details.globalPosition;
            },
                       onVerticalDragUpdate: details =>
            {
//                    Debug.Log("onVerticalDragUpdate");
                if (details.isScroll)
                {
                    float scaleDiff = details.delta.dy / MediaQuery.of(context).size.height;
                    if (aimedScale >= widget.MaxScale && scaleDiff > 0)
                    {
                        scaleDiff = 0;
                    }
                    if (aimedScale <= widget.MinScale && scaleDiff < 0)
                    {
                        scaleDiff = 0;
                    }
                    if (Math.Abs(scaleDiff) > float.Epsilon)
                    {
                        scroll(details.globalPosition, scaleDiff);
                    }
//                        postCheck();
                }
                else
                {
                    move(details.globalPosition);
//                        postCheck();
                }
            },
                       onVerticalDragEnd: details =>
            {
                MoveEndVelocity = details.velocity.pixelsPerSecond;
            },
                       child: new ClipRect
                       (
                           clipBehavior: Clip.hardEdge,
                           child: new Stack
                           (
                               children: new List <Widget>
            {
                new Positioned
                (
                    left: Offset.dx,
                    top: Offset.dy,
                    child: Transform.scale
                    (
                        scale: Scale,
                        child: new Container(
                            key: ContentViewContainerKey,
                            width: widget.ContentSizeWidth,
                            height: widget.ContentSizeHeight,
                            child: widget.child
                            ),
                        alignment: Alignment.topLeft
                    )
                )
            }
                           )
                       )
                   ));
        }
Exemplo n.º 5
0
        Widget _buildContent(BuildContext context)
        {
            var articleIds         = this.widget.viewModel.team.articleIds;
            var articlesHasMore    = this.widget.viewModel.team.articlesHasMore ?? false;
            var teamArticleLoading = this.widget.viewModel.teamArticleLoading && articleIds == null;
            int itemCount;

            if (teamArticleLoading)
            {
                itemCount = 3;
            }
            else
            {
                if (articleIds == null)
                {
                    itemCount = 3;
                }
                else
                {
                    var articleCount = articlesHasMore ? articleIds.Count : articleIds.Count + 1;
                    itemCount = 2 + (articleIds.Count == 0 ? 1 : articleCount);
                }
            }

            return(new Container(
                       color: CColors.Background,
                       child: new CustomScrollbar(
                           new SmartRefresher(
                               controller: this._refreshController,
                               enablePullDown: false,
                               enablePullUp: articlesHasMore,
                               onRefresh: this._onRefresh,
                               onNotification: this._onNotification,
                               child: ListView.builder(
                                   physics: new AlwaysScrollableScrollPhysics(),
                                   itemCount: itemCount,
                                   itemBuilder: (cxt, index) => {
                if (index == 0)
                {
                    return Transform.scale(
                        scale: this._factor,
                        child: this._buildTeamInfo()
                        );
                }

                if (index == 1)
                {
                    return _buildTeamArticleTitle();
                }

                if (teamArticleLoading && index == 2)
                {
                    var height = MediaQuery.of(context: context).size.height - headerHeight - 44;
                    return new Container(
                        height: height,
                        child: new GlobalLoading()
                        );
                }

                if ((articleIds == null || articleIds.Count == 0) && index == 2)
                {
                    var height = MediaQuery.of(context: context).size.height - headerHeight - 44;
                    return new Container(
                        height: height,
                        child: new BlankView(
                            "哎呀,暂无已发布的文章",
                            "image/default-article"
                            )
                        );
                }

                if (index == itemCount - 1 && !articlesHasMore)
                {
                    return new EndView();
                }

                var articleId = articleIds[index - 2];
                if (!this.widget.viewModel.articleDict.ContainsKey(key: articleId))
                {
                    return new Container();
                }

                var article = this.widget.viewModel.articleDict[key: articleId];
                return new ArticleCard(
                    article: article,
                    () => this.widget.actionModel.pushToArticleDetail(obj: article.id),
                    () => this._share(article: article),
                    fullName: this.widget.viewModel.team.name,
                    key: new ObjectKey(value: article.id)
                    );
            }
                                   )
                               )
                           )
                       ));
        }
Exemplo n.º 6
0
        Widget _buildUserContent(BuildContext context)
        {
            var articleIds         = this.widget.viewModel.user.articleIds;
            var articlesHasMore    = this.widget.viewModel.user.articlesHasMore ?? false;
            var userArticleLoading = this.widget.viewModel.userArticleLoading && articleIds == null;
            int itemCount;

            if (userArticleLoading)
            {
                itemCount = 3;
            }
            else
            {
                if (articleIds == null)
                {
                    itemCount = 3;
                }
                else
                {
                    var articleCount = articlesHasMore ? articleIds.Count : articleIds.Count + 1;
                    itemCount = 2 + (articleIds.Count == 0 ? 1 : articleCount);
                }
            }

            return(new Container(
                       color: CColors.Background,
                       child: new CustomScrollbar(
                           new SmartRefresher(
                               controller: this._refreshController,
                               enablePullDown: false,
                               enablePullUp: articlesHasMore,
                               onRefresh: this._onRefresh,
                               onNotification: this._onNotification,
                               child: ListView.builder(
                                   physics: new AlwaysScrollableScrollPhysics(),
                                   itemCount: itemCount,
                                   itemBuilder: (cxt, index) => {
                if (index == 0)
                {
                    return Transform.scale(
                        scale: this._factor,
                        child: this._buildUserInfo()
                        );
                }

                if (index == 1)
                {
                    return _buildUserArticleTitle();
                }

                if (userArticleLoading && index == 2)
                {
                    var height = MediaQuery.of(context: context).size.height - headerHeight - 44;
                    return new Container(
                        height: height,
                        child: new GlobalLoading()
                        );
                }

                if ((articleIds == null || articleIds.Count == 0) && index == 2)
                {
                    var height = MediaQuery.of(context: context).size.height - headerHeight - 44;
                    return new Container(
                        height: height,
                        child: new BlankView(
                            "哎呀,暂无已发布的文章",
                            "image/default-article"
                            )
                        );
                }

                if (index == itemCount - 1 && !articlesHasMore)
                {
                    return new EndView();
                }

                var articleId = articleIds[index - 2];
                if (!this.widget.viewModel.articleDict.ContainsKey(key: articleId))
                {
                    return new Container();
                }

                var article = this.widget.viewModel.articleDict[key: articleId];
                var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id);
                return new ArticleCard(
                    article: article,
                    () => this.widget.actionModel.pushToArticleDetail(obj: article.id),
                    () => ShareManager.showArticleShareView(
                        this.widget.viewModel.currentUserId != article.userId,
                        isLoggedIn: this.widget.viewModel.isLoggedIn,
                        () => {
                    Clipboard.setData(new ClipboardData(text: linkUrl));
                    CustomDialogUtils.showToast("复制链接成功", Icons.check_circle_outline);
                },
                        () => this.widget.actionModel.pushToLogin(),
                        () => this.widget.actionModel.pushToBlock(article.id),
                        () => this.widget.actionModel.pushToReport(article.id, ReportType.article),
                        type => {
                    CustomDialogUtils.showCustomDialog(
                        child: new CustomLoadingDialog()
                        );
                    string imageUrl = CImageUtils.SizeTo200ImageUrl(article.thumbnail.url);
                    this.widget.actionModel.shareToWechat(arg1: type, arg2: article.title,
                                                          arg3: article.subTitle, arg4: linkUrl, arg5: imageUrl)
                    .Then(onResolved: CustomDialogUtils.hiddenCustomDialog)
                    .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
                },
                        () => this.widget.actionModel.mainRouterPop()
                        ),
                    this.widget.viewModel.user.fullName ?? this.widget.viewModel.user.name,
                    key: new ObjectKey(value: article.id)
                    );
            }
                                   )
                               )
                           )
                       ));
        }
Exemplo n.º 7
0
        public override Widget build(int i, float animationValue, Widget widget)
        {
            float s = CustomLayoutUtils._getValue(values: this.values, animationValue: animationValue, index: i);

            return(Transform.scale(scale: s, child: widget));
        }