Esempio n. 1
0
 protected override Widget buildStackActions(BuildContext context, CustomDismissibleDelegateContext ctx)
 {
     return(Positioned.fill(
                new LayoutBuilder(builder: (_context, constraints) => {
         var totalExtent =
             ctx.getMaxExtent(constraints) * ctx.state.totalActionsExtent;
         var animation = new FloatTween(-totalExtent, 0).animate(ctx.state.actionsMoveAnimation);
         return new AnimatedBuilder(
             animation: ctx.state.actionsMoveAnimation,
             builder: (cxt, child) => {
             var widgets = new List <Widget>();
             ctx.buildActions(cxt).ForEach(item => {
                 var widget = new Expanded(child: item);
                 widgets.Add(widget);
             });
             return new Stack(
                 children: new List <Widget> {
                 ctx.createPositioned(
                     position: animation.value,
                     extent: totalExtent,
                     child: new Flex(
                         ctx.state.widget.direction,
                         children: widgets
                         )
                     )
             }
                 );
         }
             );
     })
                ));
 }
Esempio n. 2
0
 protected override Widget buildStackActions(BuildContext context, CustomDismissibleDelegateContext ctx)
 {
     return(Positioned.fill(
                new LayoutBuilder(builder: (_context, constraints) => {
         var widgets = new List <Widget>();
         ctx.buildActions(_context).ForEach(item => {
             var widget = new Expanded(child: item);
             widgets.Add(widget);
         });
         return new Stack(
             children: new List <Widget> {
             ctx.createPositioned(
                 position: 0,
                 extent:
                 ctx.getMaxExtent(constraints) * ctx.state.totalActionsExtent,
                 child: new Flex(
                     ctx.state.widget.direction,
                     children: widgets
                     )
                 )
         }
             );
     })
                ));
 }
Esempio n. 3
0
        public override Widget build(BuildContext context)
        {
            if (this.header == null && this.footer == null)
            {
                return(this.child);
            }

            List <Widget> children = new List <Widget> {
                Positioned.fill(
                    child: this.child)
            };

            if (this.header != null)
            {
                children.Add(new Positioned(
                                 top: 0.0,
                                 left: 0.0,
                                 right: 0.0,
                                 child: this.header));
            }

            if (this.footer != null)
            {
                children.Add(new Positioned(
                                 left: 0.0,
                                 bottom: 0.0,
                                 right: 0.0,
                                 child: this.footer));
            }

            return(new Stack(
                       children: children));
        }
Esempio n. 4
0
        public override Widget buildTransitions(BuildContext context, Animation <float> animation,
                                                Animation <float> secondaryAnimation, Widget child)
        {
            Widget result = new Align(
                alignment: Alignment.bottomCenter,
                child: new FractionalTranslation(
                    translation: this._offsetTween.evaluate(animation: this._animation),
                    child: child
                    )
                );

            if (this.overlayBuilder != null)
            {
                result = new Stack(
                    children: new List <Widget> {
                    Positioned.fill(
                        child: new Opacity(
                            opacity: this._opacityTween.evaluate(animation: this._animation),
                            child: this.overlayBuilder(context)
                            )
                        ),
                    result
                });
            }

            return(result);
        }
Esempio n. 5
0
 public override Widget build(BuildContext context)
 {
     return(Positioned.fill(
                child: new IgnorePointer(
                    child: new CustomSingleChildLayout(
                        layoutDelegate: new _TooltipPositionDelegate(
                            target: target,
                            verticalOffset: verticalOffset,
                            preferBelow: preferBelow),
                        child: new FadeTransition(
                            opacity: animation,
                            child: new ConstrainedBox(
                                constraints: new BoxConstraints(minHeight: height.Value),
                                child: new DefaultTextStyle(
                                    style: Theme.of(context).textTheme.bodyText2,
                                    child: new Container(
                                        decoration: decoration,
                                        padding: padding,
                                        margin: margin,
                                        child: new Center(
                                            widthFactor: 1.0f,
                                            heightFactor: 1.0f,
                                            child: new Text(message, style: textStyle)
                                            )
                                        ))
                                )
                            )
                        )
                    )
                ));
 }
 Widget _buildMoreBlogger(List <string> bloggerIds)
 {
     return(new GestureDetector(
                onTap: () => this.onPressMore?.Invoke(),
                child: new Container(
                    width: 160,
                    margin: EdgeInsets.only(right: 16),
                    decoration: new BoxDecoration(
                        color: CColors.White,
                        borderRadius: BorderRadius.all(6)
                        ),
                    child: new ClipRRect(
                        borderRadius: BorderRadius.all(6),
                        child: new Stack(
                            fit: StackFit.expand,
                            children: new List <Widget> {
         Image.asset(
             "image/blogger-more-pattern",
             fit: BoxFit.fill
             ),
         Positioned.fill(
             new Column(
                 mainAxisAlignment: MainAxisAlignment.center,
                 children: this._buildAvatars(bloggerIds)
                 )
             )
     }
                            )
                        )
                    )
                ));
 }
Esempio n. 7
0
        Widget _buildGradientScreen()
        {
            if (this.widget.backgroundColor != null && this.widget.backgroundColor.alpha < 255)
            {
                return(new Container());
            }

            Color widgetBackgroundColor = this.widget.backgroundColor ?? new Color(0xFFFFFFFF);

            return(Positioned.fill(
                       child: new IgnorePointer(
                           child: new Container(
                               decoration: new BoxDecoration(
                                   gradient: new LinearGradient(
                                       colors: new List <Color> {
                widgetBackgroundColor,
                widgetBackgroundColor.withAlpha(0xF2),
                widgetBackgroundColor.withAlpha(0xDD),
                widgetBackgroundColor.withAlpha(0),
                widgetBackgroundColor.withAlpha(0),
                widgetBackgroundColor.withAlpha(0xDD),
                widgetBackgroundColor.withAlpha(0xF2),
                widgetBackgroundColor,
            },
                                       stops: new List <float> {
                0.0f, 0.05f, 0.09f, 0.22f, 0.78f, 0.91f, 0.95f, 1.0f
            },
                                       begin: Alignment.topCenter,
                                       end: Alignment.bottomCenter
                                       )
                                   )
                               )
                           )
                       ));
        }
Esempio n. 8
0
        void _createTipMenu(BuildContext context, ArrowDirection arrowDirection, Offset position, Size size)
        {
            dismiss();
            float triangleY = arrowDirection == ArrowDirection.up
                ? position.dy
                : position.dy - CustomTextSelectionControlsUtils._kToolbarTriangleSize.height
                              - this._getTipMenuHeight(context: context);

            _overlayState = Overlay.of(context: context);
            _overlayEntry = new OverlayEntry(
                _context => Positioned.fill(
                    new GestureDetector(
                        onTap: dismiss,
                        child: new Container(
                            color: CColors.Transparent,
                            child: new Stack(
                                children: new List <Widget> {
                new Positioned(
                    top: triangleY,
                    left: size.width / 2.0f + position.dx - 25 * this.tipMenuItems.Count,
                    child: new _TipMenuContent(
                        tipMenuItems: this.tipMenuItems,
                        arrowDirection: arrowDirection
                        )
                    )
            }
                                )
                            )
                        )
                    )
                );
            _isVisible = true;
            _overlayState.insert(entry: _overlayEntry);
        }
Esempio n. 9
0
 Widget _buildOfflineHeaderView()
 {
     return(this._buildHeadImage(
                Positioned.fill(
                    new Container()
                    )
                ));
 }
Esempio n. 10
0
        public override Widget build(BuildContext context)
        {
            D.assert(WidgetsD.debugCheckHasDirectionality(context));
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));

            float additionalBottomPadding =
                Mathf.Max(MediaQuery.of(context).padding.bottom - BottomNavigationBarUtils._kBottomMargin, 0.0f);
            Color backgroundColor = null;

            switch (this.widget.type)
            {
            case BottomNavigationBarType.fix:
                break;

            case BottomNavigationBarType.shifting:
                backgroundColor = this._backgroundColor;
                break;
            }

            return(new Stack(
                       children: new List <Widget>
            {
                Positioned.fill(
                    child: new Material(     // Casts shadow.
                        elevation: 8.0f,
                        color: backgroundColor
                        )
                    ),
                new ConstrainedBox(
                    constraints: new BoxConstraints(
                        minHeight: Constants.kBottomNavigationBarHeight + additionalBottomPadding),
                    child: new Stack(
                        children: new List <Widget>
                {
                    Positioned.fill(
                        child: new CustomPaint(
                            painter: new _RadialPainter(
                                circles: this._circles.ToList()
                                )
                            )
                        ),
                    new Material(             // Splashes.
                        type: MaterialType.transparency,
                        child: new Padding(
                            padding: EdgeInsets.only(bottom: additionalBottomPadding),
                            child: MediaQuery.removePadding(
                                context: context,
                                removeBottom: true,
                                child: this._createContainer(this._createTiles())
                                )
                            )
                        )
                }
                        )
                    )
            }
                       ));
        }
Esempio n. 11
0
        public override Widget build(BuildContext context)
        {
            List <Color> colors;

            if (this._selectedIndex == 2)
            {
                colors = new List <Color> {
                    new Color(0xFFFFB84F),
                    new Color(0xFFFF8024)
                };
            }
            else
            {
                colors = new List <Color> {
                    new Color(0xFF6EC6FF),
                    CColors.PrimaryBlue,
                    CColors.MessageReactionCount
                };
            }

            return(new Container(
                       color: CColors.White,
                       child: new CustomSafeArea(
                           top: false,
                           bottom: false,
                           child: new Container(
                               decoration: new BoxDecoration(
                                   gradient: new LinearGradient(
                                       colors: colors,
                                       begin: Alignment.topLeft,
                                       end: Alignment.bottomRight
                                       )
                                   ),
                               child: new Stack(
                                   alignment: Alignment.topLeft,
                                   fit: StackFit.expand,
                                   children: new List <Widget> {
                Image.asset("image/leaderboard-pattern-curves", fit: BoxFit.fill),
                Positioned.fill(
                    new Column(
                        children: new List <Widget> {
                    this._buildNavigationBar(context: context),
                    new Flexible(child: this._buildContent())
                }
                        )
                    )
            }
                                   )
                               )
                           )
                       ));
        }
Esempio n. 12
0
        protected override Widget buildStackActions(BuildContext context, CustomDismissibleDelegateContext ctx)
        {
            return(Positioned.fill(
                       new LayoutBuilder(builder: (_context, constraints) => {
                var state = ctx.state;
                var count = state.actionCount;
                var showActions = ctx.showActions;
                var actionsMoveAnimation = state.actionsMoveAnimation;
                var actionExtent = ctx.getMaxExtent(constraints) * state.widget.actionExtentRatio;
                var actionDelegate = state.actionDelegate;

                var animations = new List <Animation <float> >();
                for (var index = 0; index < count; index++)
                {
                    var animation = new FloatTween(
                        -(float)actionExtent,
                        (count - index - 1) * (float)actionExtent
                        ).animate(actionsMoveAnimation);
                    animations.Add(animation);
                }

                return new AnimatedBuilder(
                    animation: actionsMoveAnimation,
                    builder: (cxt, child) => {
                    var widgets = new List <Widget>();
                    for (var index = 0; index < count; index++)
                    {
                        var displayIndex = showActions ? count - index - 1 : index;
                        var widget = ctx.createPositioned(
                            position: animations[index].value,
                            extent: (float)actionExtent,
                            child: actionDelegate.build(
                                context,
                                displayIndex,
                                actionsMoveAnimation,
                                CustomDismissibleMode.slide
                                )
                            );
                        widgets.Add(widget);
                    }

                    return new Stack(
                        children: widgets
                        );
                }
                    );
            })
                       ));
        }
Esempio n. 13
0
        Widget _buildLeaderBoardItem(BuildContext context, int index)
        {
            var collectionId = this.data[index : index];
            var rankData     = this.rankDict.ContainsKey(key: collectionId)
                ? this.rankDict[key : collectionId]
                               : new RankData();
            var favoriteTag = this.favoriteTagDict.ContainsKey(key: rankData.itemId)
                ? this.favoriteTagDict[key : rankData.itemId]
                              : new FavoriteTag();

            return(new GestureDetector(
                       onTap: () => this.onPressItem?.Invoke(text: rankData.id),
                       child: new Container(
                           width: 160,
                           height: 80,
                           margin: EdgeInsets.only(index == 0 ? 16 : 0, right: 16),
                           decoration: new BoxDecoration(
                               borderRadius: BorderRadius.all(4)
                               ),
                           child: new ClipRRect(
                               borderRadius: BorderRadius.all(4),
                               child: new Stack(
                                   children: new List <Widget> {
                Positioned.fill(
                    new Container(color: CColorUtils.GetCardColorFromId(id: collectionId))
                    ),
                Image.asset(
                    CImageUtils.GetSpecificPatternImageNameFromId(id: collectionId),
                    width: 160,
                    height: 80,
                    fit: BoxFit.fill
                    ),
                Positioned.fill(
                    new Padding(
                        padding: EdgeInsets.all(16),
                        child: new Text(
                            rankData.resetTitle.isNotEmpty() ? rankData.resetTitle : favoriteTag.name,
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: CTextStyle.PLargeMediumWhite
                            )
                        )
                    )
            }
                                   )
                               )
                           )
                       ));
        }
Esempio n. 14
0
 Widget _buildQrScanWidget(bool isLoggedIn)
 {
     return(new Container(
                height: 44,
                child: new Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: new List <Widget> {
         isLoggedIn
                     ? (Widget) new CustomButton(
             padding: EdgeInsets.symmetric(8, 16),
             onPressed: () => this.widget.actionModel.pushToNotifications(),
             child: new Container(
                 width: 28,
                 height: 28,
                 child: new Stack(
                     children: new List <Widget> {
             new Icon(
                 icon: Icons.outline_notifications,
                 color: CColors.LightBlueGrey,
                 size: 28
                 ),
             Positioned.fill(
                 new Align(
                     alignment: Alignment.topRight,
                     child: new NotificationDot(
                         this.widget.viewModel.hasUnreadNotifications ? "" : null,
                         new BorderSide(color: CColors.White, 2)
                         )
                     )
                 )
         }
                     )
                 )
             )
                     : new Container(),
         new CustomButton(
             padding: EdgeInsets.symmetric(8, 16),
             onPressed: QRScanPlugin.PushToQRScan,
             child: new Icon(
                 icon: Icons.outline_scan,
                 size: 28,
                 color: CColors.LightBlueGrey
                 )
             )
     }
                    )
                ));
 }
Esempio n. 15
0
 public static void createBasicObjectWithTitle(
     this MovieClipSnapshot snapshot,
     string id,
     string title,
     Widget child,
     float titleDistance       = 25,
     Alignment alignment       = null,
     TextStyle style           = null,
     AppearAnimation animation = AppearAnimation.none,
     int layer        = 0,
     Offset position  = null,
     Offset pivot     = null,
     Size scale       = null,
     float rotation   = 0,
     float opacity    = 1,
     float delay      = 0,
     float appearTime = MovieClipSnapshot.kDefaultAppearTime)
 {
     snapshot.createBasicObject(
         id: id,
         child: new Stack(children: new List <Widget> {
         new Padding(
             child: child,
             padding: EdgeInsets.all(titleDistance)
             ),
         Positioned.fill(
             new Align(
                 child: new Text(title, style: style ?? new TextStyle(fontWeight: FontWeight.bold)),
                 alignment: alignment ?? Alignment.topCenter
                 )
             )
     }),
         animation: animation,
         layer: layer,
         position: position,
         pivot: pivot,
         scale: scale,
         rotation: rotation,
         opacity: opacity,
         delay: delay,
         appearTime: appearTime
         );
 }
Esempio n. 16
0
        public override Widget build(BuildContext context)
        {
            Widget coverImageWidget;
            Color  coverImageColor;
            var    coverImageWidth = MediaQuery.of(context).size.width;

            if (this.coverImage.isNotEmpty())
            {
                coverImageWidget = new PlaceholderImage(
                    imageUrl: this.coverImage,
                    height: this.height,
                    width: coverImageWidth,
                    fit: BoxFit.cover
                    );
                coverImageColor = Color.fromRGBO(0, 0, 0, 0.4f);
            }
            else
            {
                coverImageWidget = new Container(
                    color: CColors.Black,
                    child: Image.asset(
                        "image/default-background-cover",
                        height: this.height,
                        width: coverImageWidth,
                        fit: BoxFit.cover
                        )
                    );
                coverImageColor = CColors.Transparent;
            }

            return(new Stack(
                       children: new List <Widget> {
                coverImageWidget,
                Positioned.fill(
                    new Container(
                        color: coverImageColor,
                        child: this.child
                        )
                    )
            }
                       ));
        }
Esempio n. 17
0
        public override Widget build(BuildContext context)
        {
            ThemeData theme     = Theme.of(context);
            ThemeData darkTheme = new ThemeData(
                brightness: Brightness.dark,
                textTheme: theme.brightness == Brightness.dark ? theme.textTheme : theme.primaryTextTheme
                );

            return(Positioned.fill(
                       child: new IgnorePointer(
                           child: new CustomSingleChildLayout(
                               layoutDelegate: new _TooltipPositionDelegate(
                                   target: this.target,
                                   verticalOffset: this.verticalOffset,
                                   preferBelow: this.preferBelow),
                               child: new FadeTransition(
                                   opacity: this.animation,
                                   child: new Opacity(
                                       opacity: 0.9,
                                       child: new ConstrainedBox(
                                           constraints: new BoxConstraints(minHeight: this.height ?? 0.0),
                                           child: new Container(
                                               decoration: new BoxDecoration(
                                                   color: darkTheme.backgroundColor,
                                                   borderRadius: BorderRadius.circular(2.0)),
                                               padding: this.padding,
                                               child: new Center(
                                                   widthFactor: 1.0,
                                                   heightFactor: 1.0,
                                                   child: new Text(this.message, style: darkTheme.textTheme.body1)
                                                   )
                                               )
                                           )
                                       )
                                   )
                               )
                           )
                       ));
        }
Esempio n. 18
0
        public override Widget build(BuildContext context)
        {
            Widget result = new Stack(
                children: new List <Widget> {
                Positioned.fill(
                    child: ListWheelScrollView.useDelegate(
                        controller: this.widget.scrollController ?? this._controller,
                        physics: new FixedExtentScrollPhysics(),
                        diameterRatio: this.widget.diameterRatio,
                        perspective: CupertinoPickerUtils._kDefaultPerspective,
                        offAxisFraction: this.widget.offAxisFraction,
                        useMagnifier: this.widget.useMagnifier,
                        magnification: this.widget.magnification,
                        itemExtent: this.widget.itemExtent,
                        onSelectedItemChanged: this._handleSelectedItemChanged,
                        childDelegate: this.widget.childDelegate
                        )
                    ),
                this._buildGradientScreen(),
                this._buildMagnifierScreen()
            }
                );

            if (this.widget.backgroundColor != null && this.widget.backgroundColor.alpha < 255)
            {
                result = new Stack(
                    children: new List <Widget> {
                    this._buildUnderMagnifierScreen(), this._addBackgroundToChild(result),
                }
                    );
            }
            else
            {
                result = this._addBackgroundToChild(result);
            }

            return(result);
        }
Esempio n. 19
0
        public override Widget build(BuildContext context)
        {
            Color resolvedBackgroundColor = CupertinoDynamicColor.resolve(widget.backgroundColor, context);

            Widget result = new DefaultTextStyle(
                style: CupertinoTheme.of(context).textTheme.pickerTextStyle,
                child: new Stack(
                    children: new List <Widget> {
                Positioned.fill(
                    child: new _CupertinoPickerSemantics(
                        scrollController: widget.scrollController ?? _controller,
                        child: new ListWheelScrollView(
                            controller: widget.scrollController ?? _controller,
                            physics: new FixedExtentScrollPhysics(),
                            diameterRatio: widget.diameterRatio ?? RenderListWheelViewport.defaultDiameterRatio,
                            perspective: CupertinoPickerUtils._kDefaultPerspective,
                            offAxisFraction: widget.offAxisFraction,
                            useMagnifier: widget.useMagnifier,
                            magnification: widget.magnification,
                            overAndUnderCenterOpacity: CupertinoPickerUtils._kOverAndUnderCenterOpacity,
                            itemExtent: widget.itemExtent,
                            squeeze: widget.squeeze ?? CupertinoPickerUtils._kSqueeze,
                            onSelectedItemChanged: _handleSelectedItemChanged,
                            childDelegate: widget.childDelegate
                            )
                        )
                    ),
                _buildMagnifierScreen(),
            }
                    )
                );

            return(new DecoratedBox(
                       decoration: new BoxDecoration(color: resolvedBackgroundColor),
                       child: result
                       ));
        }
Esempio n. 20
0
        public override Widget build(BuildContext context)
        {
            if (this.data.isNullOrEmpty() || this.favoriteTagDict.isNullOrEmpty())
            {
                return(new Container());
            }

            var collectionId = this.data[0];
            var rankData     = this.rankDict.ContainsKey(key: collectionId)
                ? this.rankDict[key : collectionId]
                               : new RankData();
            var favoriteTagArticle = this.favoriteTagArticleDict.ContainsKey(key: rankData.itemId)
                ? this.favoriteTagArticleDict[key : rankData.itemId]
                                     : new FavoriteTagArticle();
            var favoriteTag = this.favoriteTagDict.ContainsKey(key: rankData.itemId)
                ? this.favoriteTagDict[key : rankData.itemId]
                              : new FavoriteTag();
            var title  = rankData.resetTitle.isNotEmpty() ? rankData.resetTitle : favoriteTag.name;
            var images = new List <string>();

            favoriteTagArticle.list.ForEach(article => { images.Add(item: article.thumbnail.url); });
            return(new Container(
                       color: CColors.White,
                       height: 184,
                       child: new Stack(
                           fit: StackFit.expand,
                           children: new List <Widget> {
                Image.asset(
                    "image/recommend-blogger-bg",
                    fit: BoxFit.fill
                    ),
                new Column(
                    children: new List <Widget> {
                    new MoreListTile(
                        "image/leader-board",
                        "推荐榜单",
                        EdgeInsets.only(16, 16),
                        onPress: this.onPressMore
                        ),
                    new GestureDetector(
                        onTap: () => this.onPressItem?.Invoke(text: rankData.id),
                        child: new Container(
                            color: CColors.Transparent,
                            padding: EdgeInsets.all(16),
                            child: new Stack(
                                children: new List <Widget> {
                        new Column(
                            children: new List <Widget> {
                            new Container(height: 8),
                            new Container(
                                height: 104,
                                decoration: new BoxDecoration(
                                    new Color(0xFF3B516A),
                                    borderRadius: BorderRadius.all(6)
                                    )
                                )
                        }
                            ),
                        new Positioned(
                            right: 16,
                            bottom: 8,
                            child: new Text(
                                "UNITY",
                                style: new TextStyle(
                                    fontSize: 40,
                                    fontFamily: "Roboto-Bold",
                                    color: new Color(0xFF4F6378)
                                    )
                                )
                            ),
                        Positioned.fill(
                            new Row(
                                children: new List <Widget> {
                            new Padding(
                                padding: EdgeInsets.only(16, right: 16, bottom: 16),
                                child: new CoverImages(
                                    images: images,
                                    80,
                                    0,
                                    8,
                                    8
                                    )
                                ),
                            new Expanded(
                                child: new Column(
                                    crossAxisAlignment: CrossAxisAlignment.start,
                                    children: new List <Widget> {
                                new Container(height: 20),
                                new Text(
                                    data: title,
                                    maxLines: 2,
                                    overflow: TextOverflow.ellipsis,
                                    style: new TextStyle(
                                        height: 1.27f,
                                        fontSize: 20,
                                        fontFamily: "Roboto-Medium",
                                        color: CColors.White
                                        )
                                    ),
                                new Container(height: 4),
                                new Text(
                                    $"文章 {favoriteTag.stasitics.count}",
                                    style: new TextStyle(
                                        height: 1.53f,
                                        fontSize: 12,
                                        fontFamily: "Roboto-Regular",
                                        color: new Color(0xFFCCCCCC)
                                        )
                                    )
                            }
                                    )
                                ),
                            new SizedBox(width: 16)
                        }
                                )
                            )
                    }
                                )
                            )
                        )
                }
                    )
            }
                           )
                       ));
        }
Esempio n. 21
0
        Widget _buildBlogger(User user, string resetTitle)
        {
            UserType userType = UserType.unFollow;

            if (!this.isLoggedIn)
            {
                userType = UserType.unFollow;
            }
            else
            {
                if (UserInfoManager.getUserInfo().userId == user.id)
                {
                    userType = UserType.me;
                }
                else if (user.followUserLoading ?? false)
                {
                    userType = UserType.loading;
                }
                else if (this.followMap.ContainsKey(key: user.id))
                {
                    userType = UserType.follow;
                }
            }

            return(new GestureDetector(
                       onTap: () => this.onPressItem?.Invoke(text: user.id),
                       child: new Container(
                           width: 160,
                           margin: EdgeInsets.only(right: 16),
                           decoration: new BoxDecoration(
                               color: CColors.White,
                               borderRadius: BorderRadius.all(6)
                               ),
                           child: new ClipRRect(
                               borderRadius: BorderRadius.all(6),
                               child: new Column(
                                   children: new List <Widget> {
                new Container(
                    height: 88,
                    color: CColorUtils.GetSpecificDarkColorFromId(id: user.id),
                    child: new Stack(
                        fit: StackFit.expand,
                        children: new List <Widget> {
                    Image.asset(
                        "image/blogger-avatar-pattern",
                        fit: BoxFit.fill
                        ),
                    Positioned.fill(
                        new Center(
                            child: Avatar.User(user: user, 64, true)
                            )
                        )
                }
                        )
                    ),
                new Padding(
                    padding: EdgeInsets.only(16, 16, 16, 4),
                    child: new Text(data: user.fullName, style: CTextStyle.PXLargeMedium, maxLines: 1)
                    ),
                new Text(
                    $"粉丝{user.followCount ?? 0} • 文章{user.articleCount ?? 0}",
                    style: CTextStyle.PSmallBody4
                    ),
                new Text(resetTitle ?? "", style: CTextStyle.PSmallBody4),
                new Padding(
                    padding: EdgeInsets.only(top: 12),
                    child: new FollowButton(
                        userType: userType,
                        () => this._onFollow(userType: userType, userId: user.id)
                        )
                    )
            }
                                   )
                               )
                           )
                       ));
        }
Esempio n. 22
0
        Widget _buildKingKongItem(string title, string imageName, GestureTapCallback onPressItem)
        {
            Widget newDot;

            if (title == "榜单" && this.widget.leaderBoardUpdatedTime.HasValue &&
                LocalDataManager.needNoticeNewLeaderBoard(dateTime: this.widget.leaderBoardUpdatedTime.Value))
            {
                newDot = new Positioned(
                    top: 0,
                    right: 0,
                    child: new Container(
                        width: 18,
                        height: 18,
                        decoration: new BoxDecoration(
                            color: CColors.Error,
                            borderRadius: BorderRadius.only(9, 9, 9)
                            ),
                        alignment: Alignment.center,
                        child: new Text(
                            "新",
                            style: new TextStyle(
                                fontSize: 10,
                                fontFamily: "Roboto-Bold",
                                color: CColors.White
                                )
                            )
                        )
                    );
            }
            else
            {
                newDot = Positioned.fill(new Container());
            }

            return(new Expanded(
                       child: new GestureDetector(
                           onTap: onPressItem,
                           child: new Container(
                               color: CColors.Transparent,
                               padding: EdgeInsets.only(top: 16, bottom: 16),
                               child: new Column(
                                   children: new List <Widget> {
                new Container(
                    margin: EdgeInsets.only(bottom: 8),
                    child: new Stack(
                        children: new List <Widget> {
                    new Padding(
                        padding: EdgeInsets.symmetric(horizontal: 9),
                        child: Image.asset(
                            "image/kingkong-bg",
                            width: 48,
                            height: 48
                            )
                        ),
                    newDot,
                    Positioned.fill(
                        new Container(
                            padding: EdgeInsets.all(6),
                            child: Image.asset($"image/{imageName}")
                            )
                        )
                }
                        )
                    ),
                new Text(data: title, style: CTextStyle.PSmallBody4)
            }
                                   )
                               )
                           )
                       ));
        }
Esempio n. 23
0
        public override Widget build(BuildContext context)
        {
            base.build(context); // See AutomaticKeepAliveClientMixin.

            D.assert(!this._directionIsXAxis || WidgetsD.debugCheckHasDirectionality(context));

            Widget background = this.widget.background;

            if (this.widget.secondaryBackground != null)
            {
                DismissDirection?direction = this._dismissDirection;
                if (direction == DismissDirection.endToStart || direction == DismissDirection.up)
                {
                    background = this.widget.secondaryBackground;
                }
            }

            if (this._resizeAnimation != null)
            {
                // we've been dragged aside, and are now resizing.
                D.assert(() => {
                    if (this._resizeAnimation.status != AnimationStatus.forward)
                    {
                        D.assert(this._resizeAnimation.status == AnimationStatus.completed);
                        throw new UIWidgetsError(
                            "A dismissed Dismissible widget is still part of the tree.\n" +
                            "Make sure to implement the onDismissed handler and to immediately remove the Dismissible\n" +
                            "widget from the application once that handler has fired."
                            );
                    }

                    return(true);
                });

                return(new SizeTransition(
                           sizeFactor: this._resizeAnimation,
                           axis: this._directionIsXAxis ? Axis.vertical : Axis.horizontal,
                           child: new SizedBox(
                               width: this._sizePriorToCollapse.width,
                               height: this._sizePriorToCollapse.height,
                               child: background
                               )
                           ));
            }

            Widget content = new SlideTransition(
                position: this._moveAnimation,
                child: this.widget.child
                );

            if (background != null)
            {
                List <Widget> children = new List <Widget> {
                };

                if (!this._moveAnimation.isDismissed)
                {
                    children.Add(Positioned.fill(
                                     child: new ClipRect(
                                         clipper: new _DismissibleClipper(
                                             axis: this._directionIsXAxis ? Axis.horizontal : Axis.vertical,
                                             moveAnimation: this._moveAnimation
                                             ),
                                         child: background
                                         )
                                     ));
                }

                children.Add(content);
                content = new Stack(children: children);
            }

            return(new GestureDetector(
                       onHorizontalDragStart: this._directionIsXAxis ? (GestureDragStartCallback)this._handleDragStart : null,
                       onHorizontalDragUpdate: this._directionIsXAxis
                    ? (GestureDragUpdateCallback)this._handleDragUpdate
                    : null,
                       onHorizontalDragEnd: this._directionIsXAxis ? (GestureDragEndCallback)this._handleDragEnd : null,
                       onVerticalDragStart: this._directionIsXAxis ? null : (GestureDragStartCallback)this._handleDragStart,
                       onVerticalDragUpdate: this._directionIsXAxis
                    ? null
                    : (GestureDragUpdateCallback)this._handleDragUpdate,
                       onVerticalDragEnd: this._directionIsXAxis ? null : (GestureDragEndCallback)this._handleDragEnd,
                       behavior: HitTestBehavior.opaque,
                       child: content,
                       dragStartBehavior: this.widget.dragStartBehavior
                       ));
        }
Esempio n. 24
0
        static Widget _Atomic(BuildContext context, string type, string contentType, string title,
                              _OriginalImage originalImage,
                              string url, string downloadUrl, Action <string> openUrl, Action <string> playVideo,
                              Action browserImage = null)
        {
            if (type == "ATTACHMENT" && contentType != "video/mp4")
            {
                return(new Container());
            }

            var playButton = Positioned.fill(
                new Container()
                );

            if (type == "VIDEO" || type == "ATTACHMENT")
            {
                playButton = Positioned.fill(
                    new Center(
                        child: new CustomButton(
                            onPressed: () => {
                    if (type == "ATTACHMENT")
                    {
                        playVideo($"{downloadUrl}?noLoginRequired=true");
                    }
                    else
                    {
                        if (url == null || url.Length <= 0)
                        {
                            return;
                        }

                        openUrl(url);
                    }
                },
                            child: new Container(
                                width: 60,
                                height: 60,
                                decoration: new BoxDecoration(
                                    CColors.H5White,
                                    borderRadius: BorderRadius.all(30)
                                    ),
                                child: new Icon(
                                    Icons.play_arrow,
                                    size: 45,
                                    color: CColors.Icon
                                    )
                                )
                            )
                        )
                    );
            }

            var attachWidth  = MediaQuery.of(context).size.width - 32;
            var attachHeight = attachWidth * 9 / 16;

            if (type == "ATTACHMENT")
            {
                return(new Container(
                           color: CColors.White,
                           padding: EdgeInsets.only(bottom: 32),
                           alignment: Alignment.center,
                           child: new Container(
                               padding: EdgeInsets.only(16, right: 16),
                               child: new Column(
                                   children: new List <Widget> {
                    new Stack(
                        children: new List <Widget> {
                        new Container(
                            width: attachWidth,
                            height: attachHeight,
                            color: CColors.Black
                            ),
                        playButton
                    }
                        )
                }
                                   )
                               )
                           ));
            }

            var width = originalImage.width < MediaQuery.of(context).size.width - 32
                ? originalImage.width
                : MediaQuery.of(context).size.width - 32;
            var height   = width * originalImage.height / originalImage.width;
            var imageUrl = originalImage.url;

            if (imageUrl.isNotEmpty())
            {
                imageUrl = imageUrl.EndsWith(".gif") || imageUrl.EndsWith(".png")
                    ? imageUrl
                    : CImageUtils.SuitableSizeImageUrl(MediaQuery.of(context).size.width, imageUrl);
            }

            var nodes = new List <Widget> {
                new Stack(
                    children: new List <Widget> {
                    new GestureDetector(
                        child: new PlaceholderImage(
                            imageUrl,
                            width,
                            height,
                            fit: BoxFit.cover
                            ), onTap: () => {
                        if (browserImage != null)
                        {
                            browserImage();
                        }
                    }),

                    playButton
                }
                    )
            };

            if (title != null)
            {
                var imageTitle = new Container(
                    decoration: new BoxDecoration(
                        border: new Border(
                            bottom: new BorderSide(
                                CColors.Separator,
                                2
                                )
                            )
                        ),
                    child: new Container(
                        margin: EdgeInsets.only(4, 8, 4, 4),
                        child: new Text(
                            title,
                            style: CTextStyle.PRegularBody4
                            )
                        )
                    );
                nodes.Add(imageTitle);
            }

            return(new Container(
                       color: CColors.White,
                       padding: EdgeInsets.only(bottom: 32),
                       alignment: Alignment.center,
                       child: new Container(
                           padding: EdgeInsets.only(16, right: 16),
                           child: new Column(
                               children: nodes
                               )
                           )
                       ));
        }
Esempio n. 25
0
        public override Widget build(BuildContext context)
        {
            if (this.channel == null)
            {
                return(new Container());
            }

            Widget image = Positioned.fill(
                CachedNetworkImageProvider.cachedNetworkImage(
                    this.channel?.thumbnail ?? "",
                    fit: BoxFit.cover
                    )
                );
            Widget gradient = Positioned.fill(
                new Container(
                    decoration: new BoxDecoration(
                        gradient: new LinearGradient(
                            begin: Alignment.topCenter,
                            end: Alignment.bottomCenter,
                            new List <Color> {
                Color.fromARGB(20, 0, 0, 0),
                Color.fromARGB(80, 0, 0, 0)
            }
                            )
                        )
                    )
                );

            Widget title = new Container(
                height: 72,
                padding: EdgeInsets.symmetric(0, 8),
                child: new Align(
                    alignment: Alignment.bottomLeft,
                    child: new Text(
                        data: this.channel.name,
                        style: CTextStyle.PLargeMediumWhite
                        )
                    )
                );

            Widget count = new Container(
                padding: EdgeInsets.only(top: 4, left: 8),
                child: new Row(
                    children: new List <Widget> {
                new Container(
                    width: 8,
                    height: 8,
                    decoration: new BoxDecoration(
                        color: CColors.AquaMarine,
                        borderRadius: BorderRadius.all(4)
                        )
                    ),
                new Container(width: 4),
                new Text($"{this.channel.memberCount}人",
                         style: CTextStyle.PSmallWhite)
            }
                    )
                );

            Widget content = Positioned.fill(
                new Column(
                    children: new List <Widget> {
                title, count
            }
                    )
                );

            return(new GestureDetector(
                       onTap: this.onTap,
                       child: new Container(
                           width: 120,
                           height: 120,
                           margin: EdgeInsets.only(right: 16),
                           child: new ClipRRect(
                               borderRadius: BorderRadius.all(8),
                               child: new Container(
                                   child: new Stack(
                                       children: new List <Widget> {
                image, gradient, content
            }
                                       )
                                   )
                               )
                           )
                       ));
        }
Esempio n. 26
0
        Widget _buildLoginInNavigationBar()
        {
            var    user = this.widget.viewModel.userDict[key : this.widget.viewModel.user.userId];
            Widget titleWidget;

            if (user.title != null && user.title.isNotEmpty())
            {
                titleWidget = new Text(
                    data: user.title,
                    style: new TextStyle(
                        fontSize: 14,
                        fontFamily: "Roboto-Regular",
                        color: CColors.BgGrey
                        ),
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis
                    );
            }
            else
            {
                titleWidget = new Container();
            }

            var content = new Container(
                height: 184 + CCommonUtils.getSafeAreaTopPadding(context: this.context),
                padding: EdgeInsets.only(16, CCommonUtils.getSafeAreaTopPadding(context: this.context), bottom: 16),
                child: new Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: new List <Widget> {
                _buildQrScanWidget(),
                new Row(
                    children: new List <Widget> {
                    new Container(
                        margin: EdgeInsets.only(right: 12),
                        child: Avatar.User(
                            user: user,
                            64,
                            true
                            )
                        ),
                    new Expanded(
                        child: new Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: new List <Widget> {
                        new Row(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: new List <Widget> {
                            new Flexible(
                                child: new Text(
                                    user.fullName ?? user.name,
                                    style: CTextStyle.H4White.merge(new TextStyle(height: 1)),
                                    maxLines: 1,
                                    overflow: TextOverflow.ellipsis
                                    )
                                ),
                            CImageUtils.GenBadgeImage(
                                badges: user.badges,
                                CCommonUtils.GetUserLicense(
                                    userId: user.id,
                                    userLicenseMap: this.widget.viewModel.userLicenseDict
                                    ),
                                EdgeInsets.only(4, 6)
                                )
                        }
                            ),
                        titleWidget
                    }
                            )
                        ),
                    new Container(
                        padding: EdgeInsets.only(12, right: 16),
                        child: new Icon(
                            icon: Icons.chevron_right,
                            size: 24,
                            color: CColors.LightBlueGrey
                            )
                        )
                }
                    )
            }
                    )
                );

            return(new GestureDetector(
                       onTap: () => this.widget.actionModel.pushToUserDetail(obj: user.id),
                       child: new Stack(
                           children: new List <Widget> {
                Positioned.fill(new Stack(
                                    children: new List <Widget> {
                    new Stack(
                        children: new List <Widget> {
                        new Container(color: new Color(0xFF212121)),
                        new Positioned(
                            top: 30,
                            right: 30,
                            child: new Icon(Icons.UnityLogo, size: 210, color: new Color(0xFF2b2b2b)))
                    })
                })),
                content
            })
                       ));
        }
Esempio n. 27
0
        static Widget _Atomic(BuildContext context, string type, string contentType, string title, string dataUrl,
                              _OriginalImage originalImage, string videoStatus, string videoPoster,
                              string url, string downloadUrl, string attachmentId, Action <string> openUrl,
                              Action <string, bool, int> playVideo, Action loginAction, bool needUpdate, int limitSeconds,
                              Action <string> browserImage = null)
        {
            if (type == "ATTACHMENT" && contentType != "video/mp4")
            {
                return(new Container());
            }

            var playButton = Positioned.fill(
                new Container()
                );

            if (type == "VIDEO" || type == "ATTACHMENT")
            {
                playButton = Positioned.fill(
                    new Center(
                        child: videoStatus == "completed"
                            ? UserInfoManager.isLogin()
                                ? new CustomButton(
                            onPressed: () => {
                    if (type == "ATTACHMENT")
                    {
                        if (url.isEmpty())
                        {
                            playVideo(downloadUrl, false, 0);
                        }
                        else
                        {
                            playVideo($"{Config.apiAddress}/playlist/{attachmentId}", needUpdate,
                                      limitSeconds);
                        }
                    }
                    else
                    {
                        if (url == null || url.Length <= 0)
                        {
                            return;
                        }

                        openUrl(url);
                    }
                },
                            child: new Container(
                                width: 60,
                                height: 60,
                                decoration: new BoxDecoration(
                                    CColors.H5White,
                                    borderRadius: BorderRadius.all(30)
                                    ),
                                child: new Icon(
                                    Icons.play_arrow,
                                    size: 45,
                                    color: CColors.Icon
                                    )
                                )
                            )
                                : (Widget) new GestureDetector(
                            onTap: () => { loginAction(); },
                            child: new Container(
                                color: CColors.Black.withOpacity(0.5f),
                                alignment: Alignment.center,
                                child: new Text("Login to view this video",
                                                style: CTextStyle.PXLargeWhite.merge(
                                                    new TextStyle(decoration: TextDecoration.underline)))
                                ))
                            : new Container(
                            color: CColors.Black.withOpacity(0.5f),
                            alignment: Alignment.center,
                            child: new Text("Video is processing, try it later", style: CTextStyle.PXLargeWhite)
                            )
                        )
                    );
            }

            var attachWidth  = MediaQuery.of(context).size.width - 32;
            var attachHeight = attachWidth * 9 / 16;

            if (type == "ATTACHMENT")
            {
                return(new Container(
                           color: CColors.White,
                           padding: EdgeInsets.only(bottom: 32),
                           alignment: Alignment.center,
                           child: new Container(
                               padding: EdgeInsets.only(16, right: 16),
                               child: new Column(
                                   children: new List <Widget> {
                    new Stack(
                        children: new List <Widget> {
                        new Container(
                            width: attachWidth,
                            height: attachHeight,
                            color: CColors.Black,
                            child: Image.network(
                                videoPoster,
                                fit: BoxFit.cover
                                )
                            ),
                        playButton
                    }
                        )
                }
                                   )
                               )
                           ));
            }

            var width = originalImage.width < MediaQuery.of(context).size.width - 32
                ? originalImage.width
                : MediaQuery.of(context).size.width - 32;
            var height   = width * originalImage.height / originalImage.width;
            var imageUrl = originalImage.url;

            if (imageUrl.isNotEmpty())
            {
                imageUrl = imageUrl.EndsWith(".gif") || imageUrl.EndsWith(".png")
                    ? imageUrl
                    : CImageUtils.SuitableSizeImageUrl(MediaQuery.of(context).size.width, imageUrl);
                imageUrls.Add(imageUrl);
            }

            var nodes = new List <Widget> {
                new Stack(
                    children: new List <Widget> {
                    new GestureDetector(
                        child: new Hero(
                            tag: imageUrl,
                            child: new PlaceholderImage(
                                imageUrl: imageUrl,
                                width: width,
                                height: height,
                                fit: BoxFit.cover,
                                useCachedNetworkImage: true
                                )
                            ), onTap: () => {
                        if (dataUrl.isNotEmpty())
                        {
                            openUrl(obj: dataUrl);
                        }
                        else
                        {
                            browserImage?.Invoke(imageUrl);
                        }
                    }
                        ),
                    playButton
                }
                    )
            };

            if (title != null)
            {
                var imageTitle = new Container(
                    decoration: new BoxDecoration(
                        border: new Border(
                            bottom: new BorderSide(
                                CColors.Separator,
                                2
                                )
                            )
                        ),
                    child: new Container(
                        margin: EdgeInsets.only(4, 8, 4, 4),
                        child: new Text(
                            title,
                            style: CTextStyle.PRegularBody4
                            )
                        )
                    );
                nodes.Add(imageTitle);
            }

            return(new Container(
                       color: CColors.White,
                       padding: EdgeInsets.only(bottom: 32),
                       alignment: Alignment.center,
                       child: new Container(
                           padding: EdgeInsets.only(16, right: 16),
                           child: new Column(
                               children: nodes
                               )
                           )
                       ));
        }
Esempio n. 28
0
        public override Widget build(BuildContext context)
        {
            ThemeData theme            = Theme.of(context);
            TextStyle titleStyle       = theme.textTheme.headline.copyWith(color: Colors.white);
            TextStyle descriptionStyle = theme.textTheme.subhead;

            return(new SafeArea(
                       top: false,
                       bottom: false,
                       child: new Container(
                           padding: EdgeInsets.all(8.0f),
                           height: height,
                           child: new Card(
                               shape: this.shape,
                               child: new Column(
                                   crossAxisAlignment: CrossAxisAlignment.start,
                                   children: new List <Widget> {
                new SizedBox(
                    height: 184.0f,
                    child: new Stack(
                        children: new List <Widget> {
                    Positioned.fill(
                        child: Image.asset(this.destination.assetName,
                                           fit: BoxFit.cover
                                           )
                        ),
                    new Positioned(
                        bottom: 16.0f,
                        left: 16.0f,
                        right: 16.0f,
                        child: new FittedBox(
                            fit: BoxFit.scaleDown,
                            alignment: Alignment.centerLeft,
                            child: new Text(this.destination.title,
                                            style: titleStyle
                                            )
                            )
                        )
                }
                        )
                    ),
                new Expanded(
                    child: new Padding(
                        padding: EdgeInsets.fromLTRB(16.0f, 16.0f, 16.0f, 0.0f),
                        child: new DefaultTextStyle(
                            softWrap: false,
                            overflow: TextOverflow.ellipsis,
                            style: descriptionStyle,
                            child: new Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: new List <Widget> {
                    new Padding(
                        padding: EdgeInsets.only(bottom: 8.0f),
                        child: new Text(this.destination.description[0],
                                        style: descriptionStyle.copyWith(color: Colors.black54)
                                        )
                        ),
                    new Text(this.destination.description[1]),
                    new Text(this.destination.description[2])
                }
                                )
                            )
                        )
                    ),
                ButtonTheme.bar(
                    child: new ButtonBar(
                        alignment: MainAxisAlignment.start,
                        children: new List <Widget> {
                    new FlatButton(
                        child: new Text("SHARE"),
                        textColor: Colors.amber.shade500,
                        onPressed: () => {
                        /* do nothing */
                    }
                        ),
                    new FlatButton(
                        child: new Text("EXPLORE"),
                        textColor: Colors.amber.shade500,
                        onPressed: () => {
                        /* do nothing */
                    }
                        )
                }
                        )
                    ),
            }
                                   )
                               )
                           )
                       ));
        }
Esempio n. 29
0
        public override Widget build(BuildContext context)
        {
            return(new LayoutBuilder(
                       builder: (BuildContext _context, BoxConstraints constraints) => {
                FlexibleSpaceBarSettings settings =
                    _context.dependOnInheritedWidgetOfExactType <FlexibleSpaceBarSettings>();
                D.assert(settings != null,
                         () =>
                         "A FlexibleSpaceBar must be wrapped in the widget returned by FlexibleSpaceBar.createSettings().");

                List <Widget> children = new List <Widget>();
                float deltaExtent = settings.maxExtent.Value - settings.minExtent.Value;

                float t = (1.0f - (settings.currentExtent.Value - settings.minExtent.Value) / deltaExtent)
                          .clamp(0.0f, 1.0f);

                if (widget.background != null)
                {
                    float fadeStart = Mathf.Max(0.0f, 1.0f - material_.kToolbarHeight / deltaExtent);
                    float fadeEnd = 1.0f;
                    D.assert(fadeStart <= fadeEnd);

                    float opacity = 1.0f - new Interval(fadeStart, fadeEnd).transform(t);
                    if (opacity > 0.0f)
                    {
                        float height = settings.maxExtent ?? 0;

                        if (widget.stretchModes.Contains(StretchMode.zoomBackground) &&
                            constraints.maxHeight > height)
                        {
                            height = constraints.maxHeight;
                        }

                        children.Add(new Positioned(
                                         top: _getCollapsePadding(t, settings),
                                         left: 0.0f,
                                         right: 0.0f,
                                         height: height,
                                         child: new Opacity(
                                             opacity: opacity,
                                             child: widget.background)
                                         )
                                     );

                        if (widget.stretchModes.Contains(StretchMode.blurBackground) &&
                            constraints.maxHeight > settings.maxExtent)
                        {
                            float blurAmount = (constraints.maxHeight - settings.maxExtent) / 10 ?? 0;
                            children.Add(Positioned.fill(
                                             child: new BackdropFilter(
                                                 child: new Container(
                                                     color: Colors.transparent
                                                     ),
                                                 filter: ui.ImageFilter.blur(
                                                     sigmaX: blurAmount,
                                                     sigmaY: blurAmount
                                                     )
                                                 )
                                             ));
                        }
                    }
                }

                Widget title = null;
                if (widget.title != null)
                {
                    switch (Application.platform)
                    {
                    case RuntimePlatform.IPhonePlayer:
                        title = widget.title;
                        break;

                    default:
                        title = widget.title;
                        break;
                    }
                }

                if (widget.stretchModes.Contains(StretchMode.fadeTitle) &&
                    constraints.maxHeight > settings.maxExtent)
                {
                    float stretchOpacity =
                        1 - (((constraints.maxHeight - settings.maxExtent) / 100)?.clamp(0.0f, 1.0f) ?? 0);
                    title = new Opacity(
                        opacity: stretchOpacity,
                        child: title
                        );
                }

                ThemeData theme = Theme.of(_context);
                float toolbarOpacity = settings.toolbarOpacity.Value;
                if (toolbarOpacity > 0.0f)
                {
                    TextStyle titleStyle = theme.primaryTextTheme.title;
                    titleStyle = titleStyle.copyWith(
                        color: titleStyle.color.withOpacity(toolbarOpacity));

                    bool effectiveCenterTitle = _getEffectiveCenterTitle(theme).Value;
                    EdgeInsetsGeometry padding = widget.titlePadding ??
                                                 EdgeInsets.only(
                        left: effectiveCenterTitle ? 0.0f : 72.0f,
                        bottom: 16.0f
                        );
                    float scaleValue = new FloatTween(begin: 1.5f, end: 1.0f).lerp(t);
                    Matrix4 scaleTransform = Matrix4.diagonal3Values(scaleValue, scaleValue, 1);
                    Alignment titleAlignment = _getTitleAlignment(effectiveCenterTitle);

                    children.Add(new Container(
                                     padding: padding,
                                     child: new Transform(
                                         alignment: titleAlignment,
                                         transform: scaleTransform,
                                         child: new Align(
                                             alignment: titleAlignment,
                                             child: new DefaultTextStyle(
                                                 style: titleStyle,
                                                 child: new LayoutBuilder(
                                                     builder: (BuildContext __context, BoxConstraints _constraints) => {
                        return new Container(
                            width: _constraints.maxWidth / scaleValue,
                            alignment: titleAlignment,
                            child: title
                            );
                    }
                                                     )
                                                 )
                                             )
                                         )
                                     )
                                 );
                }

                return new ClipRect(
                    child: new Stack(
                        children: children)
                    );
            }
                       ));
        }
Esempio n. 30
0
        protected override Widget buildActionsWhileDismissing(BuildContext context,
                                                              CustomDismissibleDelegateContext ctx)
        {
            var animation = new OffsetTween(
                Offset.zero,
                ctx.createOffset(ctx.state.dragSign)
                ).animate(ctx.state.overallMoveAnimation);

            return(new Container(
                       child: new Stack(
                           children: new List <Widget> {
                Positioned.fill(
                    new LayoutBuilder(builder: (_context, constraints) => {
                    var count = ctx.state.actionCount;
                    var actionExtent =
                        ctx.getMaxExtent(constraints) * ctx.state.widget.actionExtentRatio;
                    var totalExtent = ctx.getMaxExtent(constraints);

                    var extentAnimations = new List <Animation <float> >();
                    for (var index = 0; index < count; index++)
                    {
                        var extentAnimation = new FloatTween(
                            (float)actionExtent,
                            totalExtent - (float)actionExtent * (ctx.state.actionCount - index - 1)
                            ).animate(
                            new CurvedAnimation(
                                ctx.state.overallMoveAnimation,
                                new Interval(ctx.state.totalActionsExtent, 1)
                                )
                            );
                        extentAnimations.Add(extentAnimation);
                    }

                    return new AnimatedBuilder(
                        animation: ctx.state.overallMoveAnimation,
                        builder: (cxt, child) => {
                        var widgets = new List <Widget>();
                        for (var index = 0; index < ctx.state.actionCount; index++)
                        {
                            var displayIndex = ctx.showActions
                                                    ? ctx.state.actionCount - index - 1
                                                    : index;
                            var widget = ctx.createPositioned(
                                position: (float)actionExtent *
                                (ctx.state.actionCount - index - 1),
                                extent: extentAnimations[index].value,
                                child: ctx.state.actionDelegate.build(
                                    context,
                                    displayIndex,
                                    ctx.state.overallMoveAnimation,
                                    ctx.state.renderingMode
                                    )
                                );
                            widgets.Add(widget);
                        }

                        return new Stack(
                            children: widgets
                            );
                    }
                        );
                }
                                      )
                    ),
                new SlideTransition(
                    position: animation,
                    child: ctx.state.widget.child
                    )
            }
                           )));
        }