Exemplo n.º 1
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);
            });
        }
Exemplo n.º 2
0
 public Switch(SwitchController controller)
 {
     this.controller = controller;
 }