Example #1
0
 public override Widget build(BuildContext context)
 {
     return(new Stack(
                fit: StackFit.expand,
                children: new List <Widget>
     {
         new Container(
             child: Image.asset("splashscreen", fit: BoxFit.cover)
             ),
         new Container(
             margin: EdgeInsets.only(bottom: 35),
             child: new Row(
                 mainAxisAlignment: MainAxisAlignment.spaceAround,
                 crossAxisAlignment: CrossAxisAlignment.end,
                 children: new List <Widget>
         {
             new StoreConnector <AppState, object>(
                 converter: state => null,
                 builder: ((ctx, _, dispatcher) =>
                           new SizedBox(width: MediaQuery.of(context).size.width * .4f,
                                        child: new FlatButton(color: Colors.white,
                                                              child: new Text("登录",
                                                                              style: CustomTheme.CustomTheme.DefaultTextThemen.display3),
                                                              onPressed: () =>
             {
                 dispatcher.dispatch(new LoginState()
                 {
                     userOpCode = UserOpCodeEnum.GoToLoginPage,
                     Context = context
                 });
             }
                                                              )
                                        )
                           ),
                 pure: true
                 ),
             new StoreConnector <AppState, AppState>(
                 converter: state => state,
                 builder: ((ctx, model, dispatcher) =>
                           new SizedBox(width: MediaQuery.of(context).size.width * .4f,
                                        child: new FlatButton(color: Colors.green, child: new Text("注册",
                                                                                                   style: CustomTheme.CustomTheme.DefaultTextThemen.display2),
                                                              onPressed: () =>
             {
                 dispatcher.dispatch(new RegisterState()
                 {
                     userOpCode = UserOpCodeEnum.GoToRegisterPage,
                     RequestOpCode = model.RequestOpCode,
                     Context = context
                 });
             }
                                                              )
                                        )
                           ),
                 pure: true
                 ),
         }
                 )
             ),
     }
                ));
 }
        public override Widget build(BuildContext context)
        {
            var children = new List <Widget>();

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

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

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

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

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

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

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

            return(new CustomDialog(
                       backgroundColor: CColors.White,
                       radius: 8,
                       child: dialogChild,
                       header: this.header
                       ));
        }
            public override Widget build(BuildContext buildContext)
            {
                if (_loading)
                {
                    return(new Container(
                               child: new Center(
                                   child: new Loading(
                                       size: 48f
                                       )
                                   )
                               ));
                }

                var markdownBuildCtx = new BuilderContext(_imageMetas, buildContext);

                _spanRecognizers?.ForEach(recognizer => recognizer.dispose());

                var widgets = new List <Widget>();

                widgets.AddRange(_tokens
                                 .Where(token => Mappings.ContainsKey(token.type))
                                 .Select(token => Mappings[token.type].Invoke(token, markdownBuildCtx))
                                 .Where(w => !(w is null))
                                 .Select(w => new RepaintBoundary(child: w)));
                _spanRecognizers = markdownBuildCtx.SpanRecognizers;

                widgets.Insert(0,
                               new Container(
                                   height: 64f,
                                   padding: EdgeInsets.only(bottom: 8f),
                                   decoration: new BoxDecoration(
                                       border: new Border(
                                           bottom: new BorderSide(
                                               color: new Color(0xffd8d8d8),
                                               width: 1f
                                               )
                                           )
                                       ),
                                   child: new Align(
                                       alignment: Alignment.bottomLeft,
                                       child: new Breadcrumbs(
                                           _breadcrumbs,
                                           normalBreadcrumbStyle: new TextStyle(
                                               fontSize: 16f,
                                               color: new Color(0xff979797)
                                               ),
                                           hoverBreadCrumbStyle: new TextStyle(
                                               fontSize: 16f,
                                               color: new Color(0xff979797),
                                               decoration: TextDecoration.underline
                                               ),
                                           splitterStyle: new TextStyle(
                                               fontSize: 16f,
                                               color: new Color(0xff979797)
                                               )
                                           )
                                       )
                                   )
                               );

                var linkButtons = new List <Widget>();

                if (_prevLink != null)
                {
                    linkButtons.Add(
                        new Button(
                            text: _prevLink.content ?? "",
                            onTap: () =>
                    {
                        if (!string.IsNullOrEmpty(_prevLink?.link))
                        {
                            LocationUtil.Go(
                                $"/Manual/{_prevLink?.link}");
                        }
                    },
                            prefix: Icons.MaterialArrowBack
                            )
                        );
                }
                else
                {
                    linkButtons.Add(new Container()); // placeholder to use spaceBetween
                }

                if (_nextLink != null)
                {
                    linkButtons.Add(
                        new Button(
                            text: _nextLink.content ?? "",
                            onTap: () =>
                    {
                        if (!string.IsNullOrEmpty(_nextLink.link))
                        {
                            LocationUtil.Go(
                                $"/Manual/{_nextLink.link}");
                        }
                    },
                            suffix: Icons.MaterialArrowForward
                            )
                        );
                }

                widgets.Add(
                    new Container(
                        margin: EdgeInsets.only(top: 32, bottom: 64),
                        child: new Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: linkButtons
                            )
                        )
                    );

                var version = DocApp.of(buildContext).version;

                return(new Row(
                           crossAxisAlignment: CrossAxisAlignment.start,
                           children: new List <Widget>
                {
                    new Expanded(
                        child: new Stack(
                            children: new List <Widget>
                    {
                        new Scroller(
                            child: new SingleChildScrollView(
                                controller: _scrollController,
                                child: new ScrollableOverlay(
                                    child: new Column(
                                        children: new List <Widget>
                        {
                            new Container(
                                constraints: new BoxConstraints(
                                    minHeight: MediaQuery.of(buildContext).size.height -
                                    Header.Height -
                                    SearchBar.Height -
                                    Footer.Height
                                    ),
                                child: new Column(
                                    mainAxisAlignment: MainAxisAlignment.start,
                                    crossAxisAlignment: CrossAxisAlignment.start,
                                    children: widgets)
                                ),
                            new Footer(style: Footer.Light, showSocials: false)
                        }
                                        )
                                    )
                                )
                            ),
                        new ToTop(_scrollController, displayThreshold: 128f)
                    }
                            )
                        ),
                    new MetaFields(
                        markdownBuildCtx.PositionRecords,
                        _scrollController,
                        $"https://github.com/UnityTech/documentation-cn/blob/{version.unityVersion}/Manual/md/{widget._title}.md"
                        )
                }
                           ));
            }
        public override Widget build(BuildContext context)
        {
            List <Widget> items = new List <Widget>();
            Widget        onePhysicalPixelVerticalDivider =
                new SizedBox(width: 1.0f / MediaQuery.of(context).devicePixelRatio);
            CupertinoLocalizations localizations = CupertinoLocalizations.of(context);

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

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

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

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

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

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

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

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

            return(new Column(
                       mainAxisSize: MainAxisSize.min,
                       children: new List <Widget> {
                new ClipRRect(
                    borderRadius: CupertinoTextSelectionUtils._kToolbarBorderRadius,
                    child: new DecoratedBox(
                        decoration: new BoxDecoration(
                            color: CupertinoTextSelectionUtils._kToolbarDividerColor,
                            borderRadius: CupertinoTextSelectionUtils._kToolbarBorderRadius,
                            border: Border.all(color: CupertinoTextSelectionUtils._kToolbarBackgroundColor,
                                               width: 0)
                            ),
                        child: new Row(mainAxisSize: MainAxisSize.min, children: items)
                        )
                    ),
                triangle,
                new Padding(padding: EdgeInsets.only(bottom: 10.0f))
            }
                       ));
        }
Example #5
0
        public override void initState()
        {
            base.initState();
            m_HasMoreOld          = true;
            m_EmptyFocusNode      = new FocusNode();
            m_SenderFocusNode     = new FocusNode();
            m_ScrollController    = new ScrollController();
            m_AnimationController = new AnimationController(
                vsync: this,
                duration: new TimeSpan(0, 0, 0, 0, milliseconds: 240)
                );
            m_AnimationController.addListener(() => setState());
            m_AnimationController.addStatusListener(AnimationStatusListener);

            SchedulerBinding.instance.addPostFrameCallback(value =>
            {
                if (MediaQuery.of(context).size.width < 750)
                {
                    m_AnimationController.forward();
                }
            });

            m_ScrollController.addListener(() =>
            {
                if (m_ScrollController.offset < 50f && Window.NewMessages.isNotEmpty())
                {
                    var message = Window.NewMessages[0];
                    Window.NewMessages.RemoveAt(0);
                    var showTime = true;
                    if (!widget.messages[message.channelId].isEmpty())
                    {
                        var preMsg  = widget.messages[message.channelId].first();
                        var preTime = ExtractTimeFromSnowflakeId(preMsg.id ?? preMsg.nonce);
                        var curTime = ExtractTimeFromSnowflakeId(message.id ?? message.nonce);
                        showTime    = curTime - preTime > TimeSpan.FromMinutes(5);
                    }

                    var height = CalculateMessageHeight(
                        message,
                        showTime,
                        MediaQuery.of(context).size.width * 0.7f - 286.5f);
                    Window.Messages[message.channelId].Insert(0, message);
                    m_ScrollController.jumpTo(m_ScrollController.offset + height);
                    HomePage.currentState.setState();
                }
            });
            if (!widget.messages.ContainsKey(widget.channel.id) || widget.messages[widget.channel.id].isEmpty())
            {
                m_Initialized = false;
                widget.messages[widget.channel.id] = new List <Models.Message>();
                if (widget.pullFlags.ContainsKey(widget.channel.id) && widget.pullFlags[widget.channel.id])
                {
                    widget.pullFlags[widget.channel.id] = false;
                }

                SchedulerBinding.instance.addPostFrameCallback(value =>
                {
                    Promise.All(new List <IPromise>
                    {
                        Get <GetMembersResponse>(
                            $"/api/connectapp/v1/channels/{widget.channel.id}/members"
                            ).Then(response =>
                        {
                            if (!widget.members.ContainsKey(widget.channel.id))
                            {
                                widget.members[widget.channel.id] = new List <ChannelMember>();
                            }

                            response.list.ForEach(member =>
                            {
                                if (!widget.users.ContainsKey(member.user.id))
                                {
                                    widget.users.Add(member.user.id, member.user);
                                }

                                if (widget.members[widget.channel.id].All(m => m.user.id != member.user.id))
                                {
                                    widget.members[widget.channel.id].Add(member);
                                }
                            });
                            widget.hasMoreMembers[widget.channel.id] =
                                response.total > widget.members[widget.channel.id].Count;
                        }).Catch(exception => { }),
                        Utils.Get <GetMessagesResponse>(
                            $"/api/connectapp/v1/channels/{widget.channel.id}/messages"
                            ).Then(getMessagesResponse =>
                        {
                            if (mounted)
                            {
                                m_HasMoreOld  = getMessagesResponse.hasMore;
                                m_Initialized = true;
                            }

                            widget.messages[widget.channel.id] = getMessagesResponse.items;
                            m_HasMoreUnreads = true;
                            if (m_PreviousLastMsgId == null)
                            {
                                m_HasMoreUnreads = false;
                            }
                            else
                            {
                                foreach (var m in widget.messages[widget.channel.id])
                                {
                                    if (string.Compare(m.id, m_PreviousLastMsgId) > 0)
                                    {
                                        ++m_MsgsUnreads;
                                    }
                                    else
                                    {
                                        m_HasMoreUnreads = false;
                                        break;
                                    }
                                }
                            }
                        }).Catch(exception => { }),
                    }).Then(() =>
                    {
                        if (mounted)
                        {
                            using (WindowProvider.of(context).getScope())
                            {
                                setState();
                                FocusScope.of(context).requestFocus(m_SenderFocusNode);
                            }
                        }
                    });
                });
            }
            else
            {
                PullIfNeeded();
                m_Initialized    = true;
                m_HasMoreUnreads = true;
                if (m_PreviousLastMsgId == null)
                {
                    m_HasMoreUnreads = false;
                }
                else
                {
                    foreach (var m in widget.messages[widget.channel.id])
                    {
                        if (string.Compare(m.id, m_PreviousLastMsgId) > 0)
                        {
                            ++m_MsgsUnreads;
                        }
                        else
                        {
                            m_HasMoreUnreads = false;
                            break;
                        }
                    }
                }

                SchedulerBinding.instance.addPostFrameCallback(value =>
                {
                    using (WindowProvider.of(context).getScope())
                    {
                        FocusScope.of(context).requestFocus(m_SenderFocusNode);
                    }
                });
            }

            SchedulerBinding.instance.addPostFrameCallback(value =>
            {
                var rootState = HomePage.of(context);
                rootState.Ack(widget.channel.id);
            });
        }
Example #6
0
 public override Widget build(BuildContext context)
 {
     if (MediaQuery.of(context).orientation == Orientation.portrait || widget.portraitOnly)
     {
         return(new Column(
                    children: new List <Widget>
         {
             new SizedBox(
                 width: widget.colorPickerWidth,
                 height: widget.colorPickerWidth * widget.pickerAreaHeightPercent,
                 child: colorPickerArea()
                 ),//SizedBox
             new Padding(
                 padding: EdgeInsets.fromLTRB(15f, 5f, 10f, 5f),
                 child: new Row(
                     mainAxisAlignment: MainAxisAlignment.center,
                     children: new List <Widget>
             {
                 new ColorIndicator(currentHsvColor),
                 new Expanded(
                     child: new Column(
                         children: new List <Widget> {
                     new SizedBox(
                         height: 40f,
                         width: widget.colorPickerWidth - 75,
                         child: colorPickerSlider(TrackType.hue)
                         ),
                     new Visibility(
                         visible: widget.enableAlpha,
                         child: new SizedBox(
                             height: 40f,
                             width: widget.colorPickerWidth - 75,
                             child: colorPickerSlider(TrackType.alpha)
                             ) //SizedBox
                         )     //Visibility
                 }
                         )     //Column
                     )         //Expanded
             }
                     )         //Row
                 ),            //Padding
             new Visibility(
                 visible: widget.showLabel,
                 child: new ColorPickerLabel(
                     currentHsvColor,
                     enableAlpha: widget.enableAlpha,
                     textStyle: widget.labelTextStyle
                     )
                 ),
             new SizedBox(height: 20f)
         }              //List
                    )); //Column
     }
     else
     {
         return(new Row(
                    children: new List <Widget>
         {
             new Expanded(
                 child: new SizedBox(
                     width: 300f,
                     height: 200f,
                     child: colorPickerArea()
                     ) //SizedBox
                 ),    //Expanded
             new Column(
                 children: new List <Widget>
             {
                 new Row(
                     children: new List <Widget> {
                     new SizedBox(width: 20f),
                     new ColorIndicator(currentHsvColor),
                     new Column(
                         children: new List <Widget> {
                         new SizedBox(
                             height: 40f,
                             width: 260f,
                             child: colorPickerSlider(TrackType.hue)
                             ),
                         new Visibility(
                             visible: widget.enableAlpha,
                             child: new SizedBox(
                                 height: 40f,
                                 width: 260f,
                                 child: colorPickerSlider(TrackType.alpha)
                                 )
                             )
                     }
                         ),        //Column
                     new SizedBox(width: 10f)
                 }
                     ),    //Row
                 new SizedBox(width: 10f),
                 new Visibility(
                     visible: widget.showLabel,
                     child: new ColorPickerLabel(
                         currentHsvColor,
                         enableAlpha: widget.enableAlpha,
                         textStyle: widget.labelTextStyle
                         ) //ColorPickerLabel
                     )     //Visibility
             }
                 )         //Column
         }
                    ));    //Row
     }
 }
Example #7
0
            public override Widget build(BuildContext context)
            {
                if (_loading)
                {
                    return(new Container(
                               child: new Center(
                                   child: new Loading(
                                       size: 48f
                                       )
                                   )
                               ));
                }

                var children = new List <Widget>
                {
                    new Container(
                        margin: EdgeInsets.only(top: 24, bottom: 8f),
                        child: new Row(
                            children: new List <Widget>
                    {
                        new Expanded(
                            child: new SelectableText(
                                widget._title.Split('.').Last().Replace("-", "."),
                                style: new TextStyle(
                                    fontSize: 36f,
                                    fontWeight: FontWeight.w500
                                    )
                                )
                            ),
                        new HyperLink(
                            text: "在Github上编辑本文",
                            style: new TextStyle(
                                fontSize: 16,
                                decoration: TextDecoration.underline,
                                color: new Color(0xff2196f3)
                                ),
                            link:
                            $"https://github.com/UnityTech/documentation-cn/blob/2018.1/ScriptingAPI/xml/{widget._title}.xml"
                            )
                    }
                            )
                        ),
                };

                if (!string.IsNullOrEmpty(_scripting.model.@namespace))
                {
                    children.Add(new Container(
                                     child: new SelectableText(
                                         $"class in {_scripting.model.@namespace}",
                                         style: NamespaceStyle
                                         ),
                                     margin: EdgeInsets.only(bottom: 24)
                                     )
                                 );
                }

                foreach (var sections in _scripting.model.section)
                {
                    foreach (var section in sections)
                    {
                        switch (section)
                        {
                        case Summary summary:
                            children.Add(BuildTextUsingMixedContent(context, summary.value));
                            break;

                        case Description description:
                            children.Add(BuildTextUsingMixedContent(context, description.value));
                            break;

                        case Example example:
                            children.Add(
                                new Container(
                                    decoration: new BoxDecoration(
                                        border: Border.all(
                                            width: 1f,
                                            color: new Color(0xffe0e0e0)
                                            )
                                        ),
                                    padding: EdgeInsets.all(24f),
                                    margin: EdgeInsets.only(top: 16, bottom: 24),
                                    child: new Row(
                                        crossAxisAlignment: CrossAxisAlignment.start,
                                        children: new List <Widget>
                            {
                                new Expanded(
                                    child: BuildTextUsingMixedContent(context, example.cSharp)
                                    ),
                                new CopyIcon(string.Join(string.Empty,
                                                         example.cSharp.Select(c => c.ToString())))
                            }
                                        )
                                    )
                                );
                            break;
                        }
                    }
                }

                BuildSegment(context, children, "Static Properties", _scripting.model.staticVars);
                BuildSegment(context, children, "Properties", _scripting.model.vars);
                BuildSegment(context, children, "Constructors", _scripting.model.constructors);
                BuildSegment(context, children, "Public Methods", _scripting.model.memberFunctions);
                BuildSegment(context, children, "Protected Methods", _scripting.model.protectedFunctions);
                BuildSegment(context, children, "Static Methods", _scripting.model.staticFunctions);
                BuildSegment(context, children, "Operators", _scripting.model.operators);
                BuildSegment(context, children, "Messages", _scripting.model.messages);
                BuildSegment(context, children, "Events", _scripting.model.events);
                BuildSegment(context, children, "Delegates", _scripting.model.delegates);
                if (_scripting.model.baseType != null)
                {
                    children.Add(
                        new Container(
                            margin: TitleMargin,
                            child: new Text(
                                "Inherited Members",
                                style: TitleStyle
                                )
                            )
                        );
                    BuildSegment(context, children, "Static Properties", _scripting.model.baseType.staticVars, false);
                    BuildSegment(context, children, "Properties", _scripting.model.baseType.vars, false);
                    BuildSegment(context, children, "Constructors", _scripting.model.baseType.constructors, false);
                    BuildSegment(context, children, "Public Methods", _scripting.model.baseType.memberFunctions, false);
                    BuildSegment(context, children, "Protected Methods", _scripting.model.baseType.protectedFunctions,
                                 false);
                    BuildSegment(context, children, "Static Methods", _scripting.model.baseType.staticFunctions, false);
                    BuildSegment(context, children, "Operators", _scripting.model.baseType.operators, false);
                    BuildSegment(context, children, "Messages", _scripting.model.baseType.messages, false);
                    BuildSegment(context, children, "Events", _scripting.model.baseType.events, false);
                    BuildSegment(context, children, "Delegates", _scripting.model.baseType.delegates, false);
                }

                var padding = new Container(height: 48f);

                children.Add(padding);
                return(new Stack(
                           children: new List <Widget>
                {
                    new Scroller(
                        child: new SingleChildScrollView(
                            controller: _scrollController,
                            child: new ScrollableOverlay(
                                child: new Container(
                                    padding: EdgeInsets.only(right: 48f),
                                    child: new Column(
                                        crossAxisAlignment: CrossAxisAlignment.stretch,
                                        children: new List <Widget>
                    {
                        new Container(
                            constraints: new BoxConstraints(
                                minHeight: MediaQuery.of(context).size.height - Header.Height -
                                SearchBar.Height - Footer.Height
                                ),
                            child: new Column(
                                mainAxisAlignment: MainAxisAlignment.start,
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: children)
                            ),
                        new Footer(style: Footer.Light, showSocials: false)
                    }
                                        )
                                    )
                                )
                            )
                        ),
                    new ToTop(_scrollController, 128f)
                }
                           ));
            }
        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);
                }
            }

            var headerHeight = imageBaseHeight + 44 + CCommonUtils.getSafeAreaTopPadding(context: context);

            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(context: context)
                        );
                }

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

                if (teamArticleLoading && index == 2)
                {
                    var height = MediaQuery.of(context: context).size.height - headerHeight;
                    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;
                    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)
                    );
            }
                                   )
                               )
                           )
                       ));
        }
Example #9
0
        public override Widget build(BuildContext context)
        {
            this.widget.viewModel.articleDict.TryGetValue(key: this.widget.viewModel.articleId,
                                                          value: out this._article);
            if (this.widget.viewModel.articleDetailLoading && (this._article == null || !this._article.isNotFirst))
            {
                return(new Container(
                           color: CColors.White,
                           child: new CustomSafeArea(
                               child: new Column(
                                   children: new List <Widget> {
                    this._buildNavigationBar(false),
                    new ArticleDetailLoading()
                }
                                   )
                               )
                           ));
            }

            if (this._article == null || this._article.channelId == null)
            {
                return(new Container(
                           color: CColors.White,
                           child: new CustomSafeArea(
                               child: new Column(
                                   children: new List <Widget> {
                    this._buildNavigationBar(false),
                    new Flexible(
                        child: new BlankView("帖子不存在", "image/default-history")
                        )
                }
                                   )
                               )
                           ));;
            }

            if (this._article.ownerType == "user")
            {
                if (this._article.userId != null &&
                    this.widget.viewModel.userDict.TryGetValue(this._article.userId, out this._user))
                {
                    this._user = this.widget.viewModel.userDict[key : this._article.userId];
                }
            }

            if (this._article.ownerType == "team")
            {
                if (this._article.teamId != null &&
                    this.widget.viewModel.teamDict.TryGetValue(this._article.teamId, out this._team))
                {
                    this._team = this.widget.viewModel.teamDict[key : this._article.teamId];
                }
            }

            if (this._titleHeight == 0f && this._article.title.isNotEmpty())
            {
                this._titleHeight = CTextUtils.CalculateTextHeight(
                    text: this._article.title,
                    textStyle: CTextStyle.H3,
                    MediaQuery.of(context).size.width - 16 * 2, // 16 is horizontal padding
                    null
                    ) + 16;                                     // 16 is top padding
                this.setState(() => { });
            }

            var commentIndex = 0;
            var originItems  = this._article == null ? new List <Widget>() : this._buildItems(context, out commentIndex);

            commentIndex    = this._jumpState == _ArticleJumpToCommentState.active ? commentIndex : 0;
            this._jumpState = _ArticleJumpToCommentState.Inactive;

            Widget contentWidget;

            //happens at the next frame after user presses the "Comment" button
            //we rebuild a CenteredRefresher so that we can calculate out the comment section's position
            if (this._needRebuildWithCachedCommentPosition == false && commentIndex != 0)
            {
                contentWidget = new CenteredRefresher(
                    controller: this._refreshController,
                    enablePullDown: false,
                    enablePullUp: this._article.hasMore,
                    onRefresh: this._onRefresh,
                    onNotification: this._onNotification,
                    children: originItems,
                    centerIndex: commentIndex
                    );
            }
            else
            {
                //happens when the page is updated or (when _needRebuildWithCachedCommentPosition is true) at the next frame after
                //a CenteredRefresher is created and the comment section's position is estimated
                //we use 0 or this estimated position to initiate the SmartRefresher's init scroll offset, respectively
                D.assert(!this._needRebuildWithCachedCommentPosition || this._cachedCommentPosition != null);
                contentWidget = new SmartRefresher(
                    initialOffset: this._needRebuildWithCachedCommentPosition ? this._cachedCommentPosition.Value : 0f,
                    controller: this._refreshController,
                    enablePullDown: false,
                    enablePullUp: this._article.hasMore,
                    onRefresh: this._onRefresh,
                    onNotification: this._onNotification,
                    child: ListView.builder(
                        physics: new AlwaysScrollableScrollPhysics(),
                        itemCount: originItems.Count,
                        itemBuilder: (cxt, index) => originItems[index]
                        ));
                if (this._needRebuildWithCachedCommentPosition)
                {
                    this._needRebuildWithCachedCommentPosition = false;
                    //assume that when we jump to the comment, the title should always be shown as the header
                    //this assumption will fail when an article is shorter than 16 pixels in height (as referred to in _onNotification
                    this._controller.forward();
                    this._isHaveTitle = true;
                }
            }

            var child = new Container(
                color: CColors.Background,
                child: new Column(
                    children: new List <Widget> {
                this._buildNavigationBar(),
                new Expanded(
                    child: new CustomScrollbar(
                        child: contentWidget
                        )
                    ),
                this._buildArticleTabBar()
            }
                    )
                );

            return(new Container(
                       color: CColors.White,
                       child: new CustomSafeArea(
                           child: child
                           )
                       ));
        }
Example #10
0
 public override Widget build(BuildContext context)
 {
     if (width == null)
     {
         width = MediaQuery.of(context).size.width;
     }
     return
         (new Container(
              child: new Center(
                  child: new Card(
                      shape: new RoundedRectangleBorder(
                          borderRadius: BorderRadius.all(5.0f)
                          ),
                      child:
                      new InkWell(
                          onTap: () => {
         Navigator.of(context).push(new MaterialPageRoute((buildcontext) => new OAPanel(offcialAccount)));
     }
                          , child: new Container(
                              width: width * 0.95f
                              , child: new Padding(
                                  padding: EdgeInsets.only(8, 8, 8, 8)
                                  , child:
                                  new Row(
                                      children: new List <Widget>()
     {
         new ClipOval(
             child: string.IsNullOrWhiteSpace(offcialAccount.open_id)?
             Image.asset(
                 offcialAccount.headimage ?? "products/backpack",
                 fit: BoxFit.cover,
                 width: 80,
                 height: 80
                 ) :
             Image.network(
                 offcialAccount.headimage ?? "products/backpack",
                 fit: BoxFit.cover,
                 width: 80,
                 height: 80
                 )
             )
         ,
         new Expanded(
             child:
             new Column(
                 children: new List <Widget>()
         {
             new Container(
                 alignment: Alignment.topLeft
                 , padding: EdgeInsets.only(8, 4, 8, 4)
                 , child: new Text(data: offcialAccount.wechat_name ?? "这是名字", style: Theme.of(context).textTheme.headline)
                 )
             , new Container(
                 height: 42
                 , padding: EdgeInsets.only(8, 4, 8, 4)
                 , alignment: Alignment.topLeft
                 , child: new Text(data: offcialAccount.introduction ?? "这是一个帅气的简介这是一个帅气这是一个帅气这是一个帅气这是一个帅气这是一个帅气这是一个帅气"
                                   , style: Theme.of(context).textTheme.body1.copyWith(color: Colors.black54)
                                   , overflow: Unity.UIWidgets.rendering.TextOverflow.ellipsis
                                   , maxLines: 2)
                 )
         }
                 )
             )
     }
                                      )
                                  )
                              )
                          )
                      )
                  )
              ));
 }
Example #11
0
        public static Brightness?brightnessOf(BuildContext context, bool nullOk = false)
        {
            _InheritedCupertinoTheme inheritedTheme = context.dependOnInheritedWidgetOfExactType <_InheritedCupertinoTheme>();

            return((inheritedTheme?.theme?.data?.brightness) ?? MediaQuery.of(context, nullOk: nullOk)?.platformBrightness);
        }
Example #12
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
                               )
                           )
                       ));
        }
Example #13
0
        Widget _buildUserContent(BuildContext context)
        {
            var articleIds  = this.widget.viewModel.user.articleIds;
            var favoriteIds = this.widget.viewModel.favoriteTagIdDict.ContainsKey(key: this.widget.viewModel.user.id)
                ? this.widget.viewModel.favoriteTagIdDict[key : this.widget.viewModel.user.id]
                              : null;
            var articlesHasMore     = this.widget.viewModel.user.articlesHasMore ?? false;
            var userFavoriteHasMore = this.widget.viewModel.userFavoriteHasMore;
            var userArticleLoading  = this.widget.viewModel.userArticleLoading && articleIds == null;
            var userFavoriteLoading = this.widget.viewModel.userFavoriteLoading && favoriteIds == null;
            int itemCount;

            if (userArticleLoading && this._selectedIndex == 0)
            {
                itemCount = 3;
            }
            else if (userFavoriteLoading && this._selectedIndex == 1)
            {
                itemCount = 3;
            }
            else
            {
                if (articleIds == null && this._selectedIndex == 0)
                {
                    itemCount = 3;
                }
                else if (favoriteIds == null && this._selectedIndex == 1)
                {
                    itemCount = 3;
                }
                else
                {
                    if (this._selectedIndex == 0)
                    {
                        var articleCount = articlesHasMore ? articleIds.Count : articleIds.Count + 1;
                        itemCount = 2 + (articleIds.Count == 0 ? 1 : articleCount);
                    }
                    else
                    {
                        var favoriteCount = userFavoriteHasMore ? favoriteIds.Count : favoriteIds.Count + 1;
                        itemCount = 2 + (favoriteIds.Count == 0 ? 1 : favoriteCount);
                    }
                }
            }

            var headerHeight = imageBaseHeight + 44 + CCommonUtils.getSafeAreaTopPadding(context: context);

            return(new Container(
                       color: CColors.Background,
                       child: new CustomScrollbar(
                           new SmartRefresher(
                               controller: this._refreshController,
                               enablePullDown: false,
                               enablePullUp: this._selectedIndex == 0 ? articlesHasMore : userFavoriteHasMore,
                               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(context)
                        );
                }

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

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

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

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

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

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

                if (index == itemCount - 1 && !userFavoriteHasMore && this._selectedIndex == 1)
                {
                    return new EndView();
                }

                if (this._selectedIndex == 1)
                {
                    var favoriteId = favoriteIds[index - 2];
                    return this._buildFavoriteCard(favoriteId: favoriteId);
                }

                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);
                var fullName = "";
                if (article.ownerType == OwnerType.user.ToString())
                {
                    if (this.widget.viewModel.userDict.ContainsKey(key: article.userId))
                    {
                        fullName = this.widget.viewModel.userDict[key: article.userId].fullName
                                   ?? this.widget.viewModel.userDict[key: article.userId].name;
                    }
                }

                if (article.ownerType == OwnerType.team.ToString())
                {
                    if (this.widget.viewModel.teamDict.ContainsKey(key: article.teamId))
                    {
                        fullName = this.widget.viewModel.teamDict[key: article.teamId].name;
                    }
                }

                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()
                        ),
                    fullName,
                    key: new ObjectKey(value: article.id)
                    );
            }
                                   )
                               )
                           )
                       ));
        }
        Widget _buildAlbumCard(BuildContext context, int index)
        {
            if (index == 0)
            {
                if (this.widget.viewModel.loading)
                {
                    return(new Container(
                               height: MediaQuery.of(context).size.height - 202 - MediaQuery.of(context).padding.top,
                               child: new Center(
                                   child: new GlobalLoading(color: CColors.White)
                                   )
                               ));
                }

                if (this.widget.viewModel.articleList.isEmpty())
                {
                    return(new Container(
                               height: MediaQuery.of(context).size.height - 202 - MediaQuery.of(context).padding.top,
                               child: new BlankView(
                                   "暂无文章",
                                   "image/default-article",
                                   true,
                                   () => {
                        this.widget.actionModel.startFetchDetailList();
                        this.widget.actionModel.fetchDetailList(this._pageNumber);
                    },
                                   new BoxDecoration(
                                       color: CColors.White,
                                       borderRadius: BorderRadius.only(12, 12)
                                       ))
                               ));
                }

                return(new Container(
                           height: 16,
                           decoration: new BoxDecoration(color: CColors.White, borderRadius: BorderRadius.only(12, 12))
                           ));
            }

            var article = this.widget.viewModel.articleDict[this.widget.viewModel.articleList[index - 1]];

            if (!this.widget.viewModel.articleDict.ContainsKey(key: article.id))
            {
                return(new Container());
            }

            var fullName = "";
            var userId   = "";

            if (article.ownerType == OwnerType.user.ToString())
            {
                userId = article.userId;
                if (this.widget.viewModel.userDict.ContainsKey(key: article.userId))
                {
                    fullName = this.widget.viewModel.userDict[key : article.userId].fullName
                               ?? this.widget.viewModel.userDict[key : article.userId].name;
                }
            }

            if (article.ownerType == OwnerType.team.ToString())
            {
                userId = article.teamId;
                if (this.widget.viewModel.teamDict.ContainsKey(key: article.teamId))
                {
                    fullName = this.widget.viewModel.teamDict[key : article.teamId].name;
                }
            }

            var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id);

            return(new ArticleCard(
                       article: article,
                       () => {
                this.widget.actionModel.pushToArticleDetail(obj: article.id);
                AnalyticsManager.ClickEnterArticleDetail("Home_Article", articleId: article.id,
                                                         articleTitle: article.title);
            },
                       () => ShareManager.showArticleShareView(
                           false,
                           isLoggedIn: this.widget.viewModel.isLoggedIn,
                           () => {
                Clipboard.setData(new ClipboardData(text: linkUrl));
                CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline);
            },
                           () => this.widget.actionModel.pushToLogin(),
                           () => this.widget.actionModel.pushToBlock(obj: article.id),
                           () => this.widget.actionModel.pushToReport(arg1: article.id,
                                                                      arg2: ReportType.article),
                           type => {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog()
                    );
                string imageUrl = CImageUtils.SizeTo200ImageUrl(imageUrl: 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());
            }
                           ),
                       fullName: fullName,
                       new ObjectKey(value: article.id)
                       ));
        }
Example #15
0
        public override Widget build(BuildContext context)
        {
            ThemeData      theme      = Theme.of(context);
            bool           isDark     = theme.brightness == Brightness.dark;
            MediaQueryData media      = MediaQuery.of(context);
            bool           centerHome = media.orientation == Orientation.portrait && media.size.height < 800.0;

            Curve switchOutCurve = new Interval(0.4f, 1.0f, curve: Curves.fastOutSlowIn);
            Curve switchInCurve  = new Interval(0.4f, 1.0f, curve: Curves.fastOutSlowIn);

            Widget home = new Scaffold(
                key: this._scaffoldKey,
                backgroundColor: isDark ? HomeUtils._kUIWidgetsBlue : theme.primaryColor,
                body: new SafeArea(
                    bottom: false,
                    child: new WillPopScope(
                        onWillPop: () => {
                if (this._category != null)
                {
                    this.setState(() => this._category = null);
                    return(Promise <bool> .Resolved(false));
                }

                return(Promise <bool> .Resolved(true));
            },
                        child: new Backdrop(
                            backTitle: new Text("Options"),
                            backLayer: this.widget.optionsPage,
                            frontAction: new AnimatedSwitcher(
                                duration: HomeUtils._kFrontLayerSwitchDuration,
                                switchOutCurve: switchOutCurve,
                                switchInCurve: switchInCurve,
                                child: this._category == null
                                    ? (Widget) new _UIWidgetsLogo(isDark: this.widget.options?.theme == GalleryTheme.kDarkGalleryTheme)
                                    : new IconButton(
                                    icon: new BackButtonIcon(),
                                    tooltip: "Back",
                                    onPressed: () => this.setState(() => this._category = null)
                                    )
                                ),
                            frontTitle: new AnimatedSwitcher(
                                duration: HomeUtils._kFrontLayerSwitchDuration,
                                child: this._category == null
                                    ? new Text("UIWidgets gallery")
                                    : new Text(this._category.name)
                                ),
                            frontHeading: this.widget.testMode ? null : new Container(height: 24.0f),
                            frontLayer: new AnimatedSwitcher(
                                duration: HomeUtils._kFrontLayerSwitchDuration,
                                switchOutCurve: switchOutCurve,
                                switchInCurve: switchInCurve,
                                layoutBuilder: centerHome ? _centerHomeLayout : _topHomeLayout,
                                child: this._category != null
                                    ? (Widget) new _DemosPage(this._category)
                                    : new _CategoriesPage(
                                    categories: DemoUtils.kAllGalleryDemoCategories,
                                    onCategoryTap: (GalleryDemoCategory category) => {
                this.setState(() => this._category = category);
            }
                                    )
                                )
                            )
                        )
                    )
                );

            D.assert(() => {
                GalleryHome.showPreviewBanner = false;
                return(true);
            });

            if (GalleryHome.showPreviewBanner)
            {
                home = new Stack(
                    fit: StackFit.expand,
                    children: new List <Widget> {
                    home,
                    new FadeTransition(
                        opacity: new CurvedAnimation(parent: this._controller, curve: Curves.easeInOut),
                        child: new Banner(
                            message: "PREVIEW",
                            location: BannerLocation.topEnd
                            )
                        )
                }
                    );
            }

            home = new AnnotatedRegion <SystemUiOverlayStyle>(
                child: home,
                value: SystemUiOverlayStyle.light
                );

            return(home);
        }
Example #16
0
        IEnumerable <Widget> _buildComments(BuildContext context)
        {
            List <string> channelComments = new List <string>();

            if (this.widget.viewModel.channelMessageList.ContainsKey(key: this._article.channelId))
            {
                channelComments = this.widget.viewModel.channelMessageList[key : this._article.channelId];
            }

            var mediaQuery = MediaQuery.of(context);
            var comments   = new List <Widget> {
                new Container(
                    color: CColors.White,
                    width: mediaQuery.size.width,
                    padding: EdgeInsets.only(16, 16, 16),
                    child: new Text(
                        "评论",
                        style: CTextStyle.H5,
                        textAlign: TextAlign.left
                        )
                    )
            };

            var titleHeight = CTextUtils.CalculateTextHeight(
                "评论",
                CTextStyle.H5,
                mediaQuery.size.width - 16 * 2, // 16 is horizontal padding
                null
                ) + 16;                         // 16 is top padding

            float safeAreaPadding = 0;

            if (Application.platform != RuntimePlatform.Android)
            {
                safeAreaPadding = mediaQuery.padding.vertical;
            }

            var height = mediaQuery.size.height - navBarHeight - 44 - safeAreaPadding;

            if (channelComments.Count == 0)
            {
                var blankView = new Container(
                    height: height - titleHeight,
                    child: new BlankView(
                        "快来写下第一条评论吧",
                        "image/default-comment"
                        )
                    );
                comments.Add(item: blankView);
                return(comments);
            }

            var   messageDict    = this.widget.viewModel.channelMessageDict[key : this._article.channelId];
            float contentHeights = 0;

            foreach (var commentId in channelComments)
            {
                if (!messageDict.ContainsKey(key: commentId))
                {
                    break;
                }

                var  message        = messageDict[key : commentId];
                bool isPraised      = _isPraised(message: message, loginUserId: this.widget.viewModel.loginUserId);
                var  parentName     = "";
                var  parentAuthorId = "";
                if (message.upperMessageId.isNotEmpty())
                {
                    if (messageDict.ContainsKey(key: message.upperMessageId))
                    {
                        var parentMessage = messageDict[key : message.upperMessageId];
                        parentName     = parentMessage.author.fullName;
                        parentAuthorId = parentMessage.author.id;
                    }
                }
                else if (message.parentMessageId.isNotEmpty())
                {
                    if (messageDict.ContainsKey(key: message.parentMessageId))
                    {
                        var parentMessage = messageDict[key : message.parentMessageId];
                        parentName     = parentMessage.author.fullName;
                        parentAuthorId = parentMessage.author.id;
                    }
                }

                var content = MessageUtils.AnalyzeMessage(message.content, message.mentions,
                                                          message.mentionEveryone) + (parentName.isEmpty() ? "" : $"回复@{parentName}");
                var contentHeight = CTextUtils.CalculateTextHeight(
                    content,
                    CTextStyle.PLargeBody,
                    // 16 is horizontal padding, 24 is avatar size, 8 is content left margin to avatar
                    mediaQuery.size.width - 16 * 2 - 24 - 8,
                    null
                    ) + 16 + 24 + 3 + 5 + 22 + 12;
                // 16 is top padding, 24 is avatar size, 3 is content top margin to avatar, 5 is content bottom margin to commentTime
                // 22 is commentTime height, 12 is commentTime bottom margin
                contentHeights += contentHeight;
                var card = new CommentCard(
                    message: message,
                    isPraised: isPraised,
                    parentName: parentName,
                    parentAuthorId: parentAuthorId,
                    () => ReportManager.showReportView(
                        isLoggedIn: this.widget.viewModel.isLoggedIn,
                        reportType: ReportType.comment,
                        () => this.widget.actionModel.pushToLogin(),
                        () => this.widget.actionModel.pushToReport(arg1: commentId, arg2: ReportType.comment)
                        ),
                    replyCallBack: () => this._sendComment(
                        "Article_Comment",
                        message.parentMessageId.isNotEmpty() ? message.parentMessageId : commentId,
                        message.parentMessageId.isNotEmpty() ? commentId : "",
                        message.author.fullName.isEmpty() ? "" : message.author.fullName
                        ),
                    praiseCallBack: () => {
                    if (!this.widget.viewModel.isLoggedIn)
                    {
                        this.widget.actionModel.pushToLogin();
                    }
                    else
                    {
                        if (isPraised)
                        {
                            this.widget.actionModel.removeLikeComment(arg: message);
                        }
                        else
                        {
                            this.widget.actionModel.likeComment(arg: message);
                        }
                    }
                },
                    pushToUserDetail: this.widget.actionModel.pushToUserDetail
                    );
                comments.Add(item: card);
            }

            float endHeight = 0;

            if (!this._article.hasMore)
            {
                comments.Add(new EndView());
                endHeight = 52;
            }

            if (titleHeight + contentHeights + endHeight < height)
            {
                return(new List <Widget> {
                    new Container(
                        height: height,
                        child: new Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: comments
                            )
                        )
                });
            }

            return(comments);
        }
Example #17
0
        public override void initState()
        {
            base.initState();
            StatusBarManager.statusBarStyle(false);
            this._showNavBarShadow = true;
            this._isHaveTitle      = false;
            this._controller       = new AnimationController(
                duration: new TimeSpan(0, 0, 0, 0, 300),
                vsync: this
                );
            this._titleAnimationController = new AnimationController(
                duration: TimeSpan.FromMilliseconds(100),
                vsync: this
                );
            RelativeRectTween rectTween = new RelativeRectTween(
                RelativeRect.fromLTRB(0, 44, 0, 0),
                RelativeRect.fromLTRB(0, 13, 0, 0)
                );

            this._titleAnimation = rectTween.animate(this._titleAnimationController);
            SchedulerBinding.instance.addPostFrameCallback(_ => {
                AVPlayerPlugin.initVideoPlayer("", "",
                                               0, (int)MediaQuery.of(this.context).padding.top, MediaQuery.of(this.context).size.width,
                                               MediaQuery.of(this.context).size.width * 9 / 16, true);
                AVPlayerPlugin.hiddenPlayer();
                this.widget.actionModel.showChatWindow(false);
                this.widget.actionModel.startFetchEventDetail();
                this.widget.actionModel.fetchEventDetail(this.widget.viewModel.eventId, EventType.online);
            });
            this._loginSubId = EventBus.subscribe(EventBusConstant.login_success, args => {
                this.widget.actionModel.startFetchEventDetail();
                this.widget.actionModel.fetchEventDetail(this.widget.viewModel.eventId, EventType.online);
            });
            this._shareActionSubId = EventBus.subscribe(EventBusConstant.shareAction, args => {
                if (this.widget.viewModel.eventsDict.ContainsKey(this.widget.viewModel.eventId))
                {
                    this._showShareView(this.widget.viewModel.eventsDict[this.widget.viewModel.eventId]);
                }
            });
        }
        public override Widget build(BuildContext context)
        {
            Orientation?orientation = MediaQuery.of(context).orientation;

            return(new Scaffold(
                       appBar: new AppBar(
                           title: new Text("Grid list"),
                           actions: new List <Widget>
            {
                new MaterialDemoDocumentationButton(GridListDemo.routeName),
                new PopupMenuButton <GridDemoTileStyle>(
                    onSelected: changeTileStyle,
                    itemBuilder: (BuildContext subContext) => new List <PopupMenuEntry <GridDemoTileStyle> >
                {
                    new PopupMenuItem <GridDemoTileStyle>(
                        value: GridDemoTileStyle.imageOnly,
                        child: new Text("Image only")
                        ),
                    new PopupMenuItem <GridDemoTileStyle>(
                        value: GridDemoTileStyle.oneLine,
                        child: new Text("One line")
                        ),
                    new PopupMenuItem <GridDemoTileStyle>(
                        value: GridDemoTileStyle.twoLine,
                        child: new Text("Two line")
                        )
                }
                    )
            }
                           ),
                       body: new Column(
                           children: new List <Widget>
            {
                new Expanded(
                    child: new SafeArea(
                        top: false,
                        bottom: false,
                        child: GridView.count(
                            crossAxisCount: (orientation == Orientation.portrait) ? 2 : 3,
                            mainAxisSpacing: 4.0f,
                            crossAxisSpacing: 4.0f,
                            padding: EdgeInsets.all(4.0f),
                            childAspectRatio: (orientation == Orientation.portrait) ? 1.0f : 1.3f,
                            children: photos.Select <Photo, Widget>((Photo photo) =>
                {
                    return new GridDemoPhotoItem(
                        photo: photo,
                        tileStyle: _tileStyle,
                        onBannerTap: (Photo curPhoto) =>
                    {
                        setState(() => { curPhoto.isFavorite = !curPhoto.isFavorite; });
                    }
                        );
                }).ToList()
                            )
                        )
                    )
            }
                           )
                       ));
        }
Example #19
0
        Widget _buildBody(BuildContext context)
        {
            MediaQueryData mediaQueryData  = MediaQuery.of(context);
            float          statusBarHeight = mediaQueryData.padding.top;
            float          screenHeight    = mediaQueryData.size.height;
            float          appBarMaxHeight = screenHeight - statusBarHeight;

            float appBarMidScrollOffset = statusBarHeight + appBarMaxHeight - AnimationHomeUtils._kAppBarMidHeight;

            return(SizedBox.expand(
                       child: new Stack(
                           children: new List <Widget> {
                new NotificationListener <ScrollNotification>(
                    onNotification: (ScrollNotification notification) => {
                    return this._handleScrollNotification(notification, appBarMidScrollOffset);
                },
                    child: new CustomScrollView(
                        controller: this._scrollController,
                        physics: new _SnappingScrollPhysics(midScrollOffset: appBarMidScrollOffset),
                        slivers: new List <Widget> {
                    new _StatusBarPaddingSliver(
                        maxHeight: statusBarHeight,
                        scrollFactor: 7.0f
                        ),
                    new SliverPersistentHeader(
                        pinned: true,
                        del: new _SliverAppBarDelegate(
                            minHeight: AnimationHomeUtils._kAppBarMinHeight,
                            maxHeight: appBarMaxHeight,
                            child: new NotificationListener <ScrollNotification>(
                                onNotification: (ScrollNotification notification) => {
                        return this._handlePageNotification(notification,
                                                            this._headingPageController, this._detailsPageController);
                    },
                                child: new PageView(
                                    physics: this._headingScrollPhysics,
                                    controller: this._headingPageController,
                                    children: this._allHeadingItems(appBarMaxHeight,
                                                                    appBarMidScrollOffset)
                                    )
                                )
                            )
                        ),
                    new SliverToBoxAdapter(
                        child: new SizedBox(
                            height: 610.0f,
                            child: new NotificationListener <ScrollNotification>(
                                onNotification: (ScrollNotification notification) => {
                        return this._handlePageNotification(notification,
                                                            this._detailsPageController, this._headingPageController);
                    },
                                child: new PageView(
                                    controller: this._detailsPageController,
                                    children: AnimationSectionsUtils.allSections
                                    .Select <Section, Widget>((Section section) => {
                        return new Column(
                            crossAxisAlignment: CrossAxisAlignment.stretch,
                            children: this._detailItemsFor(section).ToList()
                            );
                    }).ToList()
                                    )
                                )
                            )
                        )
                }
                        )
                    ),
                new Positioned(
                    top: statusBarHeight,
                    left: 0.0f,
                    child: new IconTheme(
                        data: new IconThemeData(color: Colors.white),
                        child: new SafeArea(
                            top: false,
                            bottom: false,
                            child: new IconButton(
                                icon: new BackButtonIcon(),
                                tooltip: "Back",
                                onPressed: () => { this._handleBackButton(appBarMidScrollOffset); }
                                )
                            )
                        )
                    )
            }
                           )
                       ));
        }
Example #20
0
        public override Widget build(BuildContext context)
        {
            var channel = widget.channels[widget.selectedChannelId];

            Widget members;

            var screenSize     = MediaQuery.of(context).size;
            var screenWidth    = screenSize.width;
            var screenHeight   = screenSize.height;
            var containerWidth = screenWidth - 48;

            if (screenWidth >= 750)
            {
                containerWidth -= 375;
            }

            var countPerRow = (containerWidth / 240).floor();
            var rowCount    = ((widget.members.ContainsKey(channel.id) ? widget.members[channel.id].Count : 0) /
                               (float)countPerRow).ceil();

            if (!widget.hasMoreMembers.ContainsKey(widget.selectedChannelId))
            {
                widget.hasMoreMembers[widget.selectedChannelId] = true;
            }
            if (widget.hasMoreMembers[widget.selectedChannelId])
            {
                rowCount += 1;
            }

            members = new SliverList(
                del: new SliverChildBuilderDelegate(
                    builder: (buildContext, index) =>
            {
                if (widget.hasMoreMembers[widget.selectedChannelId] && index == rowCount - 1)
                {
                    return(new Container(
                               height: 78,
                               alignment: Alignment.center,
                               child: new LoadTrigger(
                                   onLoad: () =>
                    {
                        var offset = widget.members.ContainsKey(channel.id)
                                            ? widget.members[channel.id].Count
                                            : 0;
                        Utils.Get <GetMembersResponse>(
                            $"/api/connectapp/channels/{channel.id}/members?offset={offset}"
                            ).Then(response =>
                        {
                            response.list.ForEach(member =>
                            {
                                if (widget.members[channel.id].All(m => m.user.id != member.user.id))
                                {
                                    widget.members[channel.id].Add(member);
                                }

                                widget.users.putIfAbsent(member.user.id, () => member.user);
                            });

                            m_AmIOwner = widget.members[channel.id].Any(member =>
                                                                        member.user.id == Window.currentUserId && member.role == "owner");
                            widget.hasMoreMembers[widget.selectedChannelId] = response.total > widget.members[channel.id].Count;
                            if (mounted)
                            {
                                using (WindowProvider.of(context).getScope())
                                {
                                    setState(() => { });
                                }
                            }
                        });
                    }
                                   )
                               ));
                }

                var children = new List <Widget> {
                };
                for (var i = 0; i < countPerRow; ++i)
                {
                    if (index * countPerRow + i < widget.members[channel.id].Count)
                    {
                        var member = widget.members[channel.id][index * countPerRow + i];
                        children.Add(
                            new Expanded(
                                child: new Container(
                                    height: 78,
                                    width: 240,
                                    alignment: Alignment.center,
                                    child: new Container(
                                        height: 50,
                                        padding: EdgeInsets.only(
                                            top: 6,
                                            bottom: 4
                                            ),
                                        child: new Row(
                                            children: new List <Widget>
                        {
                            new Container(
                                margin: EdgeInsets.only(right: 8),
                                child: new Avatar(member.user)
                                ),
                            new Expanded(
                                child: new Column(
                                    crossAxisAlignment: CrossAxisAlignment.start,
                                    children: new List <Widget>
                            {
                                new Text(
                                    member.user.fullName,
                                    style: new TextStyle(
                                        fontSize: 14,
                                        fontWeight: FontWeight.w500,
                                        fontFamily: "PingFang"
                                        ),
                                    overflow: TextOverflow.ellipsis
                                    ),
                                new Text(
                                    member.user.title ?? string.Empty,
                                    style: new TextStyle(
                                        color: new Color(0xff5a5a5b),
                                        fontSize: 14,
                                        fontFamily: "PingFang"
                                        ),
                                    overflow: TextOverflow.ellipsis
                                    )
                            }
                                    )
                                )
                        }
                                            )
                                        )
                                    )
                                )
                            );
                    }
                    else
                    {
                        children.Add(
                            new Expanded(
                                child: new Container(
                                    height: 78,
                                    width: 240
                                    )
                                )
                            );
                    }
                }

                return(new Container(
                           margin: EdgeInsets.symmetric(horizontal: 24),
                           decoration: new BoxDecoration(
                               border: new Border(
                                   top: new BorderSide(
                                       color: new Color(0xfff0f0f0)
                                       )
                                   )
                               ),
                           child: new Row(
                               mainAxisAlignment: MainAxisAlignment.start,
                               children: children
                               )
                           ));
            },
                    childCount: rowCount
                    )
                );

            var headerChildren = new List <Widget>
            {
                new Expanded(
                    child: new Text(
                        $"{channel.name}",
                        style: new TextStyle(
                            fontSize: 16,
                            fontWeight: FontWeight.w500,
                            color: new Color(0xff212121),
                            fontFamily: "PingFang"
                            )
                        )
                    ),
            };

            headerChildren.Add(
                new GestureDetector(
                    onTap: () =>
            {
                if (screenWidth < 750)
                {
                    m_AnimationController.reverse();
                }
                else
                {
                    HomePage.of(this.context).HideChannelInfo();
                }
            },
                    child: new Icon(
                        IconFont.IconFontClose,
                        color: new Color(0xff979a9e),
                        size: 28
                        )
                    )
                );

            Widget all = new Container(
                color: new Color(0xffffffff),
                child: new Scroller(
                    child: new CustomScrollView(
                        slivers: new List <Widget>
            {
                new SliverToBoxAdapter(
                    child: new Container(
                        height: 64,
                        decoration: new BoxDecoration(
                            border: new Border(
                                bottom: new BorderSide(
                                    color: new Color(0xffd8d8d8)
                                    )
                                )
                            ),
                        padding: EdgeInsets.symmetric(horizontal: 24),
                        alignment: Alignment.center,
                        child: new Row(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: headerChildren
                            )
                        )
                    ),
                MediaQuery.of(context).size.width < 750 ? BuildNarrowInfo() : BuildWideInfo(),
                new SliverToBoxAdapter(
                    child: new Container(
                        decoration: new BoxDecoration(
                            border: new Border(
                                top: new BorderSide(
                                    color: new Color(0xffd8d8d8)
                                    ),
                                bottom: new BorderSide(
                                    color: new Color(0xffd8d8d8)
                                    )
                                )
                            ),
                        padding: EdgeInsets.symmetric(vertical: 18),
                        margin: EdgeInsets.symmetric(horizontal: 24),
                        height: 78,
                        child: new Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: new List <Widget>
                {
                    new Column(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: new List <Widget>
                    {
                        new Text(
                            "消息免打扰",
                            style: new TextStyle(
                                fontSize: 14,
                                color: new Color(0xff212121),
                                fontFamily: "PingFang"
                                )
                            ),
                        new Text(
                            "打开后,将不会收到消息提醒",
                            style: new TextStyle(
                                fontSize: 14,
                                color: new Color(0xff797979),
                                fontFamily: "PingFang"
                                )
                            ),
                    }
                        ),
                    new Switch(
                        m_MuteController
                        )
                }
                            )
                        )
                    ),
                new SliverToBoxAdapter(
                    child: new Container(
                        decoration: new BoxDecoration(
                            border: new Border(
                                bottom: new BorderSide(
                                    color: new Color(0xffd8d8d8)
                                    )
                                )
                            ),
                        padding: EdgeInsets.symmetric(vertical: 18),
                        margin: EdgeInsets.symmetric(horizontal: 24),
                        height: 78,
                        child: new Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: new List <Widget>
                {
                    new Column(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: new List <Widget>
                    {
                        new Text(
                            "设为置顶",
                            style: new TextStyle(
                                fontSize: 14,
                                color: new Color(0xff212121),
                                fontFamily: "PingFang"
                                )
                            ),
                        new Text(
                            "打开后,当前群聊将会被置顶在群聊列表",
                            style: new TextStyle(
                                fontSize: 14,
                                color: new Color(0xff797979),
                                fontFamily: "PingFang"
                                )
                            )
                    }
                        ),
                    new Switch(
                        m_PinController
                        )
                }
                            )
                        )
                    ),
                new SliverToBoxAdapter(
                    child: new Container(
                        margin: EdgeInsets.only(top: 24, left: 24, right: 24),
                        padding: EdgeInsets.only(bottom: 8),
                        child: new Text(
                            $"群聊成员({channel.memberCount})",
                            style: new TextStyle(
                                fontSize: 18,
                                fontWeight: FontWeight.w500,
                                fontFamily: "PingFang"
                                )
                            )
                        )
                    ),
                members,
                new SliverToBoxAdapter(
                    child: new Container(
                        height: 56
                        )
                    )
            }
                        )
                    )
                );

            var stacked = new List <Widget> {
                all
            };

            if (!m_AmIOwner)
            {
                var quitButtonChildren = new List <Widget>();
                if (m_Quiting)
                {
                    quitButtonChildren.Add(
                        new Text(
                            "退出群聊",
                            style: new TextStyle(
                                fontSize: 18,
                                color: new Color(0x00000000),
                                fontFamily: "PingFang"
                                )
                            )
                        );
                    quitButtonChildren.Add(
                        new Loading(
                            size: 24
                            )
                        );
                }
                else
                {
                    quitButtonChildren.Add(new Text(
                                               "退出群聊",
                                               style: new TextStyle(
                                                   fontSize: 18,
                                                   color: new Color(0xfff44336),
                                                   fontFamily: "PingFang"
                                                   )
                                               )
                                           );
                }

                stacked.Add(
                    new Positioned(
                        bottom: 0,
                        left: 0,
                        right: 0,
                        child: new GestureDetector(
                            onTap: () =>
                {
                    if (m_Quiting)
                    {
                        return;
                    }
                    setState(() => m_Quiting = true);
                    var requestUrl           = string.IsNullOrEmpty(channel.groupId)
                                    ? $"/api/connectapp/v1/channels/{channel.id}/leave"
                                    : $"/api/connectapp/v1/groups/{channel.groupId}/leave";
                    var state = HomePage.of(context);
                    Utils.Post <Models.Channel>(
                        requestUrl,
                        "{}"
                        ).Then(c =>
                    {
                        state.Select(string.Empty);
                        state.RemoveChannel(channel);
                    });
                },
                            child: new Container(
                                height: 56,
                                decoration: new BoxDecoration(
                                    color: new Color(0xffffffff),
                                    border: new Border(
                                        top: new BorderSide(
                                            color: new Color(0xffd8d8d8)
                                            )
                                        )
                                    ),
                                alignment: Alignment.center,
                                child: new Stack(
                                    children: quitButtonChildren
                                    )
                                )
                            )
                        )
                    );
            }

            all = new Stack(
                children: stacked
                );

            if (screenWidth < 750)
            {
                all = Transform.translate(
                    offset: new Offset(0, (1 - m_AnimationController.value) * screenHeight),
                    child: all
                    );
            }

            return(all);
        }
Example #21
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
                               )
                           )
                       ));
        }
Example #22
0
        public override void initState()
        {
            base.initState();
            var channel = widget.channels[widget.selectedChannelId];

            m_MuteController = new SwitchController(channel.isMute);
            m_PinController  = new SwitchController(!string.IsNullOrEmpty(channel.stickTime));
            m_Quiting        = false;
            m_AmIOwner       = widget.members.ContainsKey(channel.id) &&
                               widget.members[channel.id].Any(member =>
                                                              member.user.id == Window.currentUserId && member.role == "owner");
            m_MuteController.addListener(MuteControllerListener);
            m_PinController.addListener(PinControllerListener);
            m_AnimationController = new AnimationController(
                vsync: this,
                duration: new TimeSpan(0, 0, 0, 0, milliseconds: 240)
                );
            m_AnimationController.addListener(() => setState());
            m_AnimationController.addStatusListener(AnimationStatusListener);
            _showCopiedTip = false;

            SchedulerBinding.instance.addPostFrameCallback(value =>
            {
                if (MediaQuery.of(context).size.width < 750)
                {
                    m_AnimationController.forward();
                }

                _copiedTipEntry = new OverlayEntry(buildContext =>
                {
                    var left = 0.0f;
                    if (MediaQuery.of(buildContext).size.width >= 750)
                    {
                        left = 375;
                    }

                    return(new Positioned(
                               top: 64 + 40,
                               left: left,
                               right: 0,
                               child: new IgnorePointer(
                                   child: new Container(
                                       height: 40,
                                       alignment: Alignment.center,
                                       child: new Row(
                                           mainAxisSize: MainAxisSize.min,
                                           children: new List <Widget>
                    {
                        new AnimatedOpacity(
                            opacity: _showCopiedTip ? 1 : 0,
                            duration: new TimeSpan(0, 0, 0, 0, 240),
                            curve: Curves.fastOutSlowIn,
                            child: new Container(
                                decoration: new BoxDecoration(
                                    borderRadius: BorderRadius.circular(20),
                                    color: new Color(0x99000000)
                                    ),
                                padding: EdgeInsets.symmetric(horizontal: 24),
                                alignment: Alignment.center,
                                child: new Text(
                                    "已复制群聊链接,请前往粘贴分享",
                                    style: new TextStyle(
                                        fontSize: 16,
                                        color: new Color(0xffffffff),
                                        fontFamily: "PingFang"
                                        )
                                    )
                                )
                            ),
                    }
                                           )
                                       )
                                   )
                               ));
                });
                Overlay.of(context).insert(_copiedTipEntry);
            });
        }
Example #23
0
        Widget _buildEditableText(BuildContext context)
        {
            Widget clearButton = new Container();

            if (this.widget.clearButtonMode == InputFieldClearButtonMode.always)
            {
                clearButton = this._buildClearButton(context);
            }
            else if (this.widget.clearButtonMode == InputFieldClearButtonMode.hasText)
            {
                if (this._isHintTextHidden)
                {
                    clearButton = this._buildClearButton(context);
                }
            }
            else if (this.widget.clearButtonMode == InputFieldClearButtonMode.whileEditing)
            {
                if (this._isHintTextHidden && this._isFocus)
                {
                    clearButton = this._buildClearButton(context);
                }
            }

            return(new GestureDetector(
                       onTap: () => {
                if (!this._textEditingController.selection.isValid)
                {
                    this._textEditingController.selection = TextSelection.collapsed(offset: this._textEditingController.text.Length);
                }

                this._requestKeyboard();
                var focusNode = this.widget.focusNode ?? this._focusNode;
                FocusScope.of(context).requestFocus(focusNode);
            },
                       child: new Container(
                           height: this.widget.height,
                           alignment: Alignment.center,
                           color: CColors.Transparent,
                           child: new Row(
                               children: new List <Widget> {
                new Expanded(
                    child: new TextSelectionGestureDetector(
                        onTapDown: this._handleTapDown,
                        onSingleTapUp: this._handleSingleTapUp,
                        onDoubleTapDown: this._handleDoubleTapDown,
                        onDragSelectionStart: this._handleMouseDragSelectionStart,
                        onDragSelectionUpdate: this._handleMouseDragSelectionUpdate,
                        onDragSelectionEnd: this._handleMouseDragSelectionEnd,
                        behavior: HitTestBehavior.translucent,
                        child: new RepaintBoundary(
                            child: new EditableText(
                                key: this._editableTextKey,
                                maxLines: this.widget.maxLines,
                                controller: this._textEditingController,
                                focusNode: this._focusNode,
                                autofocus: this.widget.autofocus,
                                obscureText: this.widget.obscureText,
                                style: this.widget.style,
                                cursorWidth: this.widget.cursorWidth,
                                cursorColor: this.widget.cursorColor,
                                cursorRadius: this.widget.cursorRadius,
                                cursorOffset: new Offset(-2 / MediaQuery.of(context).devicePixelRatio, 0),
                                autocorrect: this.widget.autocorrect,
                                textInputAction: this.widget.textInputAction,
                                keyboardType: this.widget.keyboardType,
                                textAlign: this.widget.textAlign,
                                scrollPadding: this.widget.scrollPadding,
                                selectionControls: this.widget.enableInteractiveSelection
                                                ? new CustomTextSelectionControls()
                                                : null,
                                enableInteractiveSelection: this.widget.enableInteractiveSelection,
                                selectionColor: this.widget.selectionColor,
                                onSelectionChanged: this._handleSelectionChanged,
                                paintCursorAboveText: true,
                                cursorOpacityAnimates: true,
                                backgroundCursorColor: new Color(0xFF8E8E93),
                                onChanged: text => {
                    var isTextEmpty = text.Length > 0;
                    if (this._isHintTextHidden != isTextEmpty)
                    {
                        this.setState(() => { this._isHintTextHidden = isTextEmpty; });
                    }

                    if (this.widget.onChanged != null)
                    {
                        this.widget.onChanged(text);
                    }
                },
                                onSubmitted: this.widget.onSubmitted
                                )
                            )
                        )
                    ),
                clearButton
            }
                               )
                           )
                       ));
        }
Example #24
0
        public override Widget build(BuildContext context)
        {
            if (this.images.isNullOrEmpty())
            {
                return(new Container());
            }

            Widget firstImage;

            if (this.images.Count > 0)
            {
                firstImage = new PlaceholderImage(
                    CImageUtils.SuitableSizeImageUrl(
                        imageWidth: MediaQuery.of(context: context).size.width,
                        this.images[0]
                        ),
                    this.size + this.ratioGap * 2,
                    this.size + this.ratioGap * 2,
                    6,
                    fit: BoxFit.cover,
                    true,
                    CColorUtils.GetSpecificDarkColorFromId(this.images[0])
                    );
            }
            else
            {
                firstImage = new Container();
            }

            Widget secondImage;

            if (this.images.Count > 1)
            {
                secondImage = this.onlyShowFirst
                    ? (Widget) new Container(
                    width: this.size + this.ratioGap * 2,
                    height: this.size + this.ratioGap * 2,
                    decoration: new BoxDecoration(borderRadius: BorderRadius.all(6),
                                                  color: Color.fromRGBO(207, 213, 219, 1))
                    )
                    : new PlaceholderImage(
                    CImageUtils.SuitableSizeImageUrl(
                        imageWidth: MediaQuery.of(context: context).size.width,
                        this.images[1]
                        ),
                    this.size + this.ratioGap,
                    this.size + this.ratioGap,
                    6,
                    fit: BoxFit.cover,
                    true,
                    CColorUtils.GetSpecificDarkColorFromId(this.images[1])
                    );
            }
            else
            {
                secondImage = new Container();
            }

            Widget thirdImage;

            if (this.images.Count > 2)
            {
                thirdImage = this.onlyShowFirst
                    ? (Widget) new Container(
                    width: this.size + this.ratioGap * 2,
                    height: this.size + this.ratioGap * 2,
                    decoration: new BoxDecoration(borderRadius: BorderRadius.all(6),
                                                  color: Color.fromRGBO(137, 150, 165, 1))
                    )
                    : new PlaceholderImage(
                    CImageUtils.SuitableSizeImageUrl(
                        imageWidth: MediaQuery.of(context: context).size.width,
                        this.images[2]
                        ),
                    width: this.size,
                    height: this.size,
                    6,
                    fit: BoxFit.cover,
                    true,
                    CColorUtils.GetSpecificDarkColorFromId(this.images[2])
                    );
            }
            else
            {
                thirdImage = new Container();
            }

            return(new Container(
                       width: this.size + this.ratioGap * 2 + this.horizontalGap * (this.images.Count - 1),
                       height: this.size + this.ratioGap * 2 + this.verticalGap * (this.images.Count - 1),
                       child: new Stack(
                           children: new List <Widget> {
                new Positioned(
                    right: 0,
                    bottom: 0,
                    child: thirdImage
                    ),
                new Positioned(
                    right: this.horizontalGap,
                    bottom: this.verticalGap,
                    child: secondImage
                    ),
                new Positioned(
                    left: 0,
                    top: 0,
                    child: firstImage
                    )
            }
                           )
                       ));
        }
Example #25
0
        public override Widget build(BuildContext context)
        {
            var screenWidth    = MediaQuery.of(context).size.width;
            var windowChildren = new List <Widget>
            {
                new Scroller(
                    child: ListView.builder(
                        controller: m_ScrollController,
                        reverse: true,
                        itemCount: m_HasMoreOld
                            ? widget.messages[widget.channel.id].Count + 1
                            : widget.messages[widget.channel.id].Count,
                        itemBuilder: (ctx, index) =>
                {
                    if (!m_Initialized)
                    {
                        return(new Container());
                    }

                    if (index == widget.messages[widget.channel.id].Count)
                    {
                        return(new LoadTrigger(
                                   () =>
                        {
                            var lastMessageId =
                                widget.messages[widget.channel.id].last().id;
                            Get(
                                $"/api/connectapp/v1/channels/{widget.channel.id}/messages?before={lastMessageId}",
                                (GetMessagesResponse getMessagesResponse) =>
                            {
                                if (mounted)
                                {
                                    using (WindowProvider.of(context)
                                           .getScope())
                                    {
                                        setState(() =>
                                        {
                                            widget.messages[widget.channel.id]
                                            .AddRange(
                                                getMessagesResponse.items
                                                .Where(
                                                    item =>
                                                    item.id !=
                                                    lastMessageId
                                                    )
                                                );
                                            m_MsgsUnreads = 0;
                                            m_HasMoreUnreads = true;
                                            if (m_PreviousLastMsgId == null)
                                            {
                                                m_HasMoreUnreads = false;
                                            }
                                            else
                                            {
                                                foreach (var m in widget.messages[widget.channel.id])
                                                {
                                                    if (string.Compare(m.id, m_PreviousLastMsgId) > 0)
                                                    {
                                                        ++m_MsgsUnreads;
                                                    }
                                                    else
                                                    {
                                                        m_HasMoreUnreads = false;
                                                        break;
                                                    }
                                                }
                                            }

                                            m_HasMoreOld =
                                                getMessagesResponse.hasMore;
                                        });
                                    }
                                }
                            });
                        }
                                   ));
                    }

                    var currentMessage = widget.messages[widget.channel.id][index];
                    var msgTime        =
                        ExtractTimeFromSnowflakeId(currentMessage.id.IsNullOrEmpty()
                                    ? currentMessage.nonce
                                    : currentMessage.id);
                    bool showTime;
                    var isNew = false;
                    if (index == widget.messages[widget.channel.id].Count - 1)
                    {
                        showTime = true;
                    }
                    else
                    {
                        var nextMessage = widget.messages[widget.channel.id][index + 1];
                        showTime        = msgTime - ExtractTimeFromSnowflakeId(
                            nextMessage.id.IsNullOrEmpty()
                                                   ? nextMessage.nonce
                                                   : nextMessage.id) >
                                          TimeSpan.FromMinutes(5);
                        if (nextMessage.id != null && nextMessage.id == m_PreviousLastMsgId)
                        {
                            isNew = true;
                        }
                    }

                    Action onBuild = null;
                    if (currentMessage.id == m_PreviousLastMsgId)
                    {
                        onBuild = () =>
                        {
                            SchedulerBinding.instance.addPostFrameCallback(value =>
                            {
                                setState(() =>
                                {
                                    m_MsgsUnreads    = 0;
                                    m_HasMoreUnreads = false;
                                });
                            });
                        };
                    }

                    return(new Message(
                               widget.messages[widget.channel.id][index],
                               widget.users,
                               showTime,
                               m_PreviousLastMsgId != widget.channel.lastMessage.id && isNew,
                               msgTime,
                               onBuild
                               ));
                }
                        )
                    ),
            };

            if (Window.reconnecting)
            {
                windowChildren.Add(
                    new Positioned(
                        left: 0,
                        top: 0,
                        right: 0,
                        child: new Container(
                            color: new Color(0xfffde1df),
                            height: 48,
                            alignment: Alignment.center,
                            child: new Text(
                                "网络未连接,正在连接中",
                                style: new TextStyle(
                                    fontSize: 16,
                                    color: new Color(0xfff44336),
                                    fontFamily: "PingFang"
                                    )
                                )
                            )
                        )
                    );
            }

            var newMsgsCount = Window.NewMessages.Count(msg => msg.author.id != Window.currentUserId);

            if (newMsgsCount != 0)
            {
                windowChildren.Add(
                    new Positioned(
                        bottom: 24,
                        child: new GestureDetector(
                            onTap: () =>
                {
                    Window.NewMessages.ForEach(msg => { Window.Messages[msg.channelId].Insert(0, msg); });
                    Window.NewMessages.Clear();
                    setState();
                    m_ScrollController.animateTo(
                        0,
                        new TimeSpan(0, 0, 0, 0, 480),
                        Curves.easeInOut
                        );
                },
                            child: new Container(
                                height: 40,
                                padding: EdgeInsets.symmetric(horizontal: 16),
                                decoration: new BoxDecoration(
                                    borderRadius: BorderRadius.all(20),
                                    boxShadow: new List <BoxShadow>
                {
                    new BoxShadow(
                        offset: new Offset(0, 1),
                        blurRadius: 6,
                        color: new Color(0x19000000)
                        ),
                },
                                    color: new Color(0xffffffff)
                                    ),
                                child: new Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: new List <Widget>
                {
                    new Text(
                        $"{newMsgsCount}条新消息未读",
                        style: new TextStyle(
                            color: new Color(0xff2196f3),
                            fontSize: 14,
                            fontFamily: "PingFang"
                            )
                        ),
                }
                                    )
                                )
                            )
                        )
                    );
            }

            if (m_MsgsUnreads > 0)
            {
                var text = $"{m_MsgsUnreads}";
                if (m_HasMoreUnreads)
                {
                    text += "+";
                }

                text += "条新消息";
                windowChildren.Add(
                    new Positioned(
                        top: 24,
                        child: new GestureDetector(
                            onTap: () =>
                {
                    var totalHeight = 0.0f;
                    for (var index = 0; index < widget.messages[widget.channel.id].Count; ++index)
                    {
                        var message = widget.messages[widget.channel.id][index];
                        if (string.Compare(message.id, m_PreviousLastMsgId) > 0)
                        {
                            var showTime = true;
                            var msgTime  =
                                ExtractTimeFromSnowflakeId(message.id.IsNullOrEmpty()
                                                ? message.nonce
                                                : message.id);
                            if (index != widget.messages[widget.channel.id].Count - 1)
                            {
                                var nextMessage = widget.messages[widget.channel.id][index + 1];
                                showTime        = msgTime - ExtractTimeFromSnowflakeId(
                                    nextMessage.id.IsNullOrEmpty()
                                                               ? nextMessage.nonce
                                                               : nextMessage.id) >
                                                  TimeSpan.FromMinutes(5);
                            }

                            var layoutWidth = screenWidth * 0.7f;
                            if (screenWidth >= 750)
                            {
                                layoutWidth -= 286.5f;
                            }
                            else
                            {
                                layoutWidth -= 24f;
                            }

                            totalHeight += CalculateMessageHeight(
                                message,
                                showTime,
                                layoutWidth
                                );
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (m_HasMoreUnreads)
                    {
                        totalHeight += 40;
                    }
                    else
                    {
                        totalHeight += 36;
                    }

                    m_ScrollController.animateTo(
                        totalHeight - MediaQuery.of(context).size.height + 184,
                        new TimeSpan(0, 0, 0, 0, 480),
                        Curves.easeInOut
                        );
                    if (!m_HasMoreUnreads)
                    {
                        setState(() =>
                        {
                            m_MsgsUnreads    = 0;
                            m_HasMoreUnreads = false;
                        });
                    }
                },
                            child: new Container(
                                height: 40,
                                padding: EdgeInsets.symmetric(horizontal: 16),
                                decoration: new BoxDecoration(
                                    borderRadius: BorderRadius.all(20),
                                    boxShadow: new List <BoxShadow>
                {
                    new BoxShadow(
                        offset: new Offset(0, 1),
                        blurRadius: 6,
                        color: new Color(0x19000000)
                        ),
                },
                                    color: new Color(0xffffffff)
                                    ),
                                child: new Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: new List <Widget>
                {
                    new Text(
                        text,
                        style: new TextStyle(
                            color: new Color(0xff2196f3),
                            fontSize: 14,
                            fontFamily: "PingFang"
                            )
                        ),
                    new Container(
                        margin: EdgeInsets.only(left: 4),
                        child: Transform.rotate(
                            child: new Icon(
                                IconFont.IconFontArrowUp,
                                size: 24,
                                color: new Color(0xff2196f3)
                                )
                            )
                        )
                }
                                    )
                                )
                            )
                        )
                    );
            }

            var rootState = HomePage.of(context);

            var children = new List <Widget>
            {
                new Container(
                    color: new Color(0xffffffff),
                    child: new Column(
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        children: new List <Widget>
                {
                    new ChattingWindowHeader(
                        widget.channel, () =>
                    {
                        if (screenWidth < 750)
                        {
                            m_AnimationController.reverse();
                        }
                        else
                        {
                            HomePage.of(context).Select(string.Empty);
                        }
                    }),
                    new Expanded(
                        child: new Stack(
                            alignment: Alignment.center,
                            children: windowChildren
                            )
                        ),
                    new Sender(
                        m_SenderFocusNode,
                        widget.users),
                }
                        )
                    ),
            };

            if (!m_Initialized)
            {
                children.Add(
                    new Container(
                        alignment: Alignment.center,
                        child: new Loading(size: 56)
                        )
                    );
            }

            Widget all = new GestureDetector(
                onTap: () => { FocusScope.of(context).requestFocus(m_EmptyFocusNode); },
                child: new Stack(
                    children: children
                    )
                );

            if (screenWidth < 750)
            {
                all = Transform.translate(
                    offset: new Offset((1 - m_AnimationController.value) * screenWidth, 0),
                    child: all
                    );
            }

            return(all);
        }
Example #26
0
        public override Widget build(BuildContext context)
        {
            this._context = context;
            if (!this._isShow)
            {
                return(new MainScreen());
            }

            var topPadding = Application.platform != RuntimePlatform.Android
                ? MediaQuery.of(context: context).padding.top
                : 0f;

            var    isShowLogo = SplashManager.getSplash()?.isShowLogo ?? false;
            Widget logoWidget;

            if (isShowLogo)
            {
                logoWidget = new Positioned(
                    top: topPadding + 24,
                    left: 16,
                    child: new Icon(
                        icon: Icons.LogoWithUnity,
                        size: 35,
                        color: new Color(value: this.hexColor)
                        )
                    );
            }
            else
            {
                logoWidget = new Container();
            }

            return(new Container(
                       color: CColors.White,
                       child: new CustomSafeArea(
                           top: false,
                           child: new Stack(
                               children: new List <Widget> {
                new Column(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: new List <Widget> {
                    new GestureDetector(
                        child: new Container(
                            width: MediaQuery.of(context).size.width,
                            height: MediaQuery.of(context).size.height - 116 -
                            CCommonUtils.getSafeAreaBottomPadding(context: context),
                            child: Image.memory(SplashManager.readImage(), fit: BoxFit.cover)
                            ),
                        onTap: this.pushPage
                        ),
                    new Container(
                        width: 182,
                        height: 32,
                        margin: EdgeInsets.only(top: 36),
                        child: Image.asset("image/iOS/unityConnectBlack.imageset/unityConnectBlack")
                        ),
                    new Container(
                        width: 101,
                        height: 22,
                        margin: EdgeInsets.only(top: 6, bottom: 20),
                        child: Image.asset("image/iOS/madeWithUnity.imageset/madeWithUnity")
                        )
                }
                    ),
                new Positioned(
                    top: topPadding + 24,
                    right: 16,
                    child: new GestureDetector(
                        child: new Container(
                            decoration: new BoxDecoration(
                                Color.fromRGBO(0, 0, 0, 0.5f),
                                borderRadius: BorderRadius.all(16)
                                ),
                            width: 65,
                            height: 32,
                            alignment: Alignment.center,
                            child: new Text($"跳过 {this._lastSecond}", style: new TextStyle(
                                                fontSize: 14,
                                                fontFamily: "Roboto-Regular",
                                                color: CColors.White
                                                ))
                            ),
                        onTap: this.pushCallback
                        )
                    ),
                logoWidget
            }
                               ))
                       ));
        }
Example #27
0
        public override Widget build(BuildContext context)
        {
            var reply = new Container();

            if (!this.widget.replyUserName.isEmpty())
            {
                reply = new Container(
                    height: 40,
                    width: MediaQuery.of(context).size.width,
                    padding: EdgeInsets.only(16, right: 16),
                    alignment: Alignment.centerLeft,
                    decoration: new BoxDecoration(
                        CColors.White,
                        border: new Border(
                            bottom: new BorderSide(CColors.Separator)
                            )
                        ),
                    child: new RichText(
                        text: new TextSpan(
                            "回复 ",
                            CTextStyle.PRegularBody3,
                            new List <TextSpan> {
                    new TextSpan(this.widget.replyUserName,
                                 CTextStyle.PMediumBody3
                                 )
                }
                            )
                        )
                    );
            }

            return(new Container(
                       child: new Column(
                           mainAxisAlignment: MainAxisAlignment.end,
                           children: new List <Widget> {
                new Container(
                    color: Color.fromRGBO(0, 0, 0, 0.4f),
                    child: new Container(
                        color: CColors.White,
                        child: new Column(
                            children: new List <Widget> {
                    reply,
                    new Row(
                        children: new List <Widget> {
                        new Expanded(
                            child: new Container(
                                margin: EdgeInsets.only(10, 6.5f, 8, 6.5f),
                                decoration: new BoxDecoration(
                                    CColors.Separator2,
                                    borderRadius: BorderRadius.circular(
                                        (this._inputFieldHeight + 13) / 2)
                                    ),
                                child: new Container(
                                    padding: this._inputFieldPadding,
                                    child: new InputField(this._inputFieldKey,
                                                          height: this._inputFieldHeight,
                                                          controller: this._controller,
                                                          style: this._inputFieldStyle,
                                                          maxLines: 2,
                                                          autofocus: true,
                                                          hintText: "友好的评论是交流的起点…",
                                                          hintStyle: CTextStyle.PLargeBody4,
                                                          cursorColor: CColors.PrimaryBlue,
                                                          textInputAction: TextInputAction.send,
                                                          onChanged: text => {
                            var isTextEmpty = text.Length > 0;
                            if (this._isPublish != isTextEmpty)
                            {
                                this.setState(() => {
                                    this._isPublish = isTextEmpty;
                                });
                            }

                            this._inputText = text;
                        },
                                                          onSubmitted: this._onSubmitted
                                                          )
                                    )
                                )
                            ),
                        new CustomButton(
                            onPressed: () => {
                            if (!this._isPublish)
                            {
                                return;
                            }

                            this._onSubmitted(this._inputText);
                        },
                            child: new Text(
                                "发布",
                                style: this._isPublish
                                                            ? CTextStyle.PLargeBlue
                                                            : CTextStyle.PLargeDisabled
                                )
                            ),
                        new Container(width: 8)
                    }
                        )
                }
                            ),
                        margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom)
                        )
                    )
            }
                           )
                       ));
        }
Example #28
0
        public static string SizeToScreenImageUrl(string imageUrl)
        {
            var data = MediaQuery.of(GlobalContext.context);

            return($"{imageUrl}.{(int) (data.size.width * data.devicePixelRatio)}x0x1.jpg");
        }
        public override Widget build(BuildContext context)
        {
            var iconData = Icons.pause;

            switch (this._playState)
            {
            case PlayState.stop:
                iconData = Icons.replay;
                break;

            case PlayState.pause:
                iconData = Icons.play_arrow;
                break;
            }

            var content = new Container(
                child: new Stack(children: new List <Widget> {
                new GestureDetector(
                    onTap: () => {
                    if (this._isFailure && this._isHiddenBar == false)
                    {
                        return;
                    }

                    this._isHiddenBar      = !this._isHiddenBar;
                    this._isReadyHiddenBar = false;
                    this.setState();
                    this.cancelTimer();
                },
                    child: new Container(color: CColors.Black, child: new Texture(texture: this._texture))
                    ),
                this._isLoaded
                        ? new Align()
                        : new Align(
                    alignment: Alignment.center,
                    child: new CustomActivityIndicator(loadingColor: LoadingColor.white)
                    ),
                this._isHiddenBar
                        ? new Positioned(new Container())
                        : new Positioned(top: 0, left: 0, right: 0, child: this._isFullScreen
                            ? new Row(
                                             mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                             children: new List <Widget> {
                    new GestureDetector(
                        onTap: this._setScreenOrientation,
                        child: new Container(
                            margin: EdgeInsets.only(8,
                                                    Application.platform == RuntimePlatform.IPhonePlayer ? 20 : 8),
                            child: new Icon(
                                Icons.arrow_back,
                                size: 28,
                                color: CColors.White
                                )
                            )
                        )
                }
                                             )
                            : this.widget.topWidget),
                this._isHiddenBar
                        ? new Positioned(new Container())
                        : new Positioned(
                    bottom: 0,
                    left: 0,
                    right: 0,
                    child: this._isFailure
                                ? new Container(
                        height: _toolBarHeight,
                        padding: EdgeInsets.only(top: 0, left: 8),
                        color: Color.fromRGBO(0, 0, 0, 0.2f),
                        child: new Row(children: new List <Widget> {
                    new GestureDetector(
                        child: new Container(
                            height: _toolBarHeight,
                            width: _toolBarHeight,
                            color: CColors.Transparent,
                            child: new Icon(Icons.replay, size: 24, color: CColors.White)
                            ),
                        onTap: this._reloadVideo
                        ),
                    new Text("视频播放失败", style: new TextStyle(
                                 fontSize: 15,
                                 fontFamily: "Roboto-Bold",
                                 color: CColors.White
                                 ))
                }))
                                : new Container(
                        height: _toolBarHeight,
                        decoration: new BoxDecoration(gradient: new LinearGradient(
                                                          colors: new List <Color> {
                    Color.fromRGBO(0, 0, 0, 0),
                    Color.fromRGBO(0, 0, 0, 0.5f)
                },
                                                          begin: Alignment.topCenter,
                                                          end: Alignment.bottomCenter
                                                          )),
                        child: new Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: new List <Widget> {
                    new GestureDetector(
                        child: new Container(
                            height: _toolBarHeight,
                            width: _toolBarHeight,
                            color: CColors.Transparent,
                            child: new Icon(iconData, size: 24, color: CColors.White)
                            ),
                        onTap: this._playOrPause
                        ),
                    new Container(margin: EdgeInsets.only(right: 8), child:
                                  new Text($"{DateConvert.formatTime((float) this._player.time)}",
                                           style: CTextStyle.CaptionWhite)),
                    new Expanded(
                        child: new ProgressBar(this._relative,
                                               changeCallback: relative => {
                        this._relative = relative;
                        if (this.widget.recordDuration > 0)
                        {
                            this._player.time = relative * this.widget.recordDuration;
                        }
                        else
                        {
                            this._player.time =
                                relative * this._player.frameCount /
                                this._player.frameRate;
                        }

                        this.cancelTimer();
                        this._isLoaded = false;
                        this._player.Pause();
                        this.setState(() => { });
                    }, onDragStart: () => {
                        this.cancelTimer();
                        this._isLoaded = false;
                        this._player.Pause();
                        this.setState(() => { });
                    })),
                    new Container(margin: EdgeInsets.only(left: 8, right: 8), child:
                                  new Text(
                                      $"{DateConvert.formatTime(this.widget.recordDuration > 0 ? this.widget.recordDuration : this._player.frameCount / this._player.frameRate)}",
                                      style: CTextStyle.CaptionWhite)),
                    new GestureDetector(
                        child: new Container(
                            height: _toolBarHeight,
                            width: _toolBarHeight,
                            color: CColors.Transparent,
                            child: new Icon(
                                this._isFullScreen ? Icons.fullscreen_exit : Icons.fullscreen,
                                size: 24,
                                color: CColors.White)
                            ),
                        onTap: this._setScreenOrientation
                        )
                })
                        )
                    )
            })
                );

            return(new Container(
                       width: this._isFullScreen
                    ? MediaQuery.of(context).size.height * 16 / 9
                    : MediaQuery.of(context).size.width,
                       height: this._isFullScreen
                    ? MediaQuery.of(context).size.height
                    : MediaQuery.of(context).size.width * 9 / 16,
                       child: content
                       ));
        }
Example #30
0
 Widget _buildBottomView(BuildContext context)
 {
     return(new Container(
                padding: EdgeInsets.symmetric(horizontal: 16),
                child: new Column(
                    children: new List <Widget> {
         this._buildWeChatButton(context: context),
         new Container(height: 16),
         new CustomButton(
             onPressed: () => this.widget.actionModel.loginRouterPushToBindUnity(),
             padding: EdgeInsets.zero,
             child: new Container(
                 height: 48,
                 decoration: new BoxDecoration(
                     color: CColors.White,
                     border: Border.all(color: CColors.PrimaryBlue),
                     borderRadius: BorderRadius.all(24)
                     ),
                 child: new Row(
                     mainAxisAlignment: MainAxisAlignment.center,
                     children: new List <Widget> {
             new Text(
                 "使用 Unity ID 登录",
                 maxLines: 1,
                 style: CTextStyle.PLargeBlue
                 )
         }
                     )
                 )
             ),
         new Container(
             margin: EdgeInsets.only(top: 16),
             child: new RichText(
                 text: new TextSpan(
                     children: new List <TextSpan> {
             new TextSpan(
                 "登录代表您已经同意 ",
                 style: CTextStyle.PSmallBody4
                 ),
             new TextSpan(
                 "用户协议",
                 CTextStyle.PSmallBody4.copyWith(decoration: TextDecoration.underline),
                 recognizer: new TapGestureRecognizer {
                 onTap = () => this.widget.actionModel.openUrl(Config.termsOfService)
             }
                 ),
             new TextSpan(
                 " 和 ",
                 style: CTextStyle.PSmallBody4
                 ),
             new TextSpan(
                 "隐私政策",
                 CTextStyle.PSmallBody4.copyWith(decoration: TextDecoration.underline),
                 recognizer: new TapGestureRecognizer {
                 onTap = () => this.widget.actionModel.openUrl(Config.privacyPolicy)
             }
                 )
         }
                     )
                 )
             ),
         new Container(
             height: 16 + MediaQuery.of(context: context).padding.bottom
             )
     }
                    )
                ));
 }