Ejemplo n.º 1
0
        public override Widget build(BuildContext context)
        {
            ThemeData theme  = Theme.of(context);
            Widget    picker = new Flexible(
                child: new SizedBox(
                    height: DatePickerUtils._kMaxDayPickerHeight,
                    child: this._buildPicker()
                    )
                );
            Widget actions = ButtonTheme.bar(
                child: new ButtonBar(
                    children: new List <Widget> {
                new FlatButton(
                    child: new Text(this.localizations.cancelButtonLabel),
                    onPressed: this._handleCancel
                    ),
                new FlatButton(
                    child: new Text(this.localizations.okButtonLabel),
                    onPressed: this._handleOk
                    )
            }
                    )
                );
            Dialog dialog = new Dialog(
                child: new OrientationBuilder(
                    builder: (BuildContext _context, Orientation orientation) => {
                Widget header = new _DatePickerHeader(
                    selectedDate: this._selectedDate,
                    mode: this._mode,
                    onModeChanged: this._handleModeChanged,
                    orientation: orientation
                    );

                switch (orientation)
                {
                case Orientation.portrait:
                    return(new SizedBox(
                               width: DatePickerUtils._kMonthPickerPortraitWidth,
                               child: new Column(
                                   mainAxisSize: MainAxisSize.min,
                                   crossAxisAlignment: CrossAxisAlignment.stretch,
                                   children: new List <Widget> {
                        header,
                        new Container(
                            color: theme.dialogBackgroundColor,
                            child: new Column(
                                mainAxisSize: MainAxisSize.min,
                                crossAxisAlignment: CrossAxisAlignment.stretch,
                                children: new List <Widget> {
                            picker,
                            actions,
                        }
                                )
                            )
                    }
                                   )
                               ));

                case Orientation.landscape:
                    return(new SizedBox(
                               height: DatePickerUtils._kDatePickerLandscapeHeight,
                               child: new Row(
                                   mainAxisSize: MainAxisSize.min,
                                   crossAxisAlignment: CrossAxisAlignment.stretch,
                                   children: new List <Widget> {
                        header,
                        new Flexible(
                            child: new Container(
                                width: DatePickerUtils._kMonthPickerLandscapeWidth,
                                color: theme.dialogBackgroundColor,
                                child: new Column(
                                    mainAxisSize: MainAxisSize.min,
                                    crossAxisAlignment: CrossAxisAlignment.stretch,
                                    children: new List <Widget> {
                            picker, actions
                        }
                                    )
                                )
                            )
                    }
                                   )
                               ));
                }

                return(null);
            }
                    )
                );

            return(new Theme(
                       data: theme.copyWith(
                           dialogBackgroundColor: Colors.transparent
                           ),
                       child: dialog
                       ));
        }
Ejemplo n.º 2
0
        List <Widget> _buildItems()
        {
            var children    = new List <Widget>();
            var screenWidth = MediaQuery.of(context: this.context).size.width;

            this.widget.items.ForEach(item => {
                Widget buildItem = new Flexible(
                    child: new Stack(
                        fit: StackFit.expand,
                        children: new List <Widget> {
                    new GestureDetector(
                        onTap: () => {
                        if (this._selectedIndex != item.index)
                        {
                            if (this.widget.tapCallBack != null)
                            {
                                if (this.widget.tapCallBack(this._selectedIndex, item.index))
                                {
                                    this.setState(() => {
                                        this._selectedIndex = item.index;
                                        this._pageController.animateToPage(item.index,
                                                                           new TimeSpan(0, 0, 0, 0, 1),
                                                                           Curves.ease);
                                    });
                                }
                            }
                        }
                    },
                        child: new Container(
                            decoration: new BoxDecoration(
                                color: CColors.Transparent
                                ),
                            child: new Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: new List <Widget> {
                        new Padding(
                            padding: EdgeInsets.only(top: 5),
                            child: new Stack(
                                children: new List <Widget> {
                            new Icon(this._selectedIndex == item.index
                                                                ? item.selectedIcon
                                                                : item.normalIcon, size: item.size,
                                     color: this._selectedIndex == item.index
                                                                ? item.activeColor
                                                                : item.inActiveColor),
                        }
                                )
                            ),
                        new Padding(
                            padding: EdgeInsets.only(top: 2.5f),
                            child: new Text(item.title,
                                            style: new TextStyle(fontSize: 10,
                                                                 color: this._selectedIndex == item.index
                                                            ? item.activeColor
                                                            : item.inActiveColor))
                            )
                    }
                                )
                            )
                        ),
                    new Positioned(
                        left: (float)Math.Ceiling(screenWidth / 8) + 2,
                        top: 4,
                        child: new IgnorePointer(
                            child: new NotificationDot(
                                this.widget.notifications[index: item.index],
                                new BorderSide(color: CColors.White, 2)
                                )
                            )
                        )
                }
                        )
                    );
                children.Add(buildItem);
            });

            return(children);
        }
Ejemplo n.º 3
0
        List <Widget> _buildItems()
        {
            var children = new List <Widget>();

            this.widget.items.ForEach(item => {
                Widget buildItem = new Flexible(
                    child: new Stack(
                        fit: StackFit.expand,
                        children: new List <Widget> {
                    new GestureDetector(
                        onTap: () => {
                        if (this._selectedIndex != item.index)
                        {
                            if (this.widget.tapCallBack != null)
                            {
                                if (this.widget.tapCallBack(this._selectedIndex, item.index))
                                {
                                    this.setState(() => {
                                        this._selectedIndex = item.index;
                                        this._pageController.animateToPage(item.index,
                                                                           new TimeSpan(0, 0, 0, 0, 1),
                                                                           Curves.ease);
                                    });
                                }
                            }
                        }
                    },
                        child: new Container(
                            decoration: new BoxDecoration(
                                CColors.Transparent
                                ),
                            child: new Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: new List <Widget> {
                        new Padding(
                            padding: EdgeInsets.only(top: 5),
                            child: new Icon(
                                this._selectedIndex == item.index
                                                        ? item.selectedIcon
                                                        : item.normalIcon, size: item.size,
                                color: this._selectedIndex == item.index
                                                        ? item.activeColor
                                                        : item.inActiveColor)
                            ),
                        new Padding(
                            padding: EdgeInsets.only(top: 2.5f),
                            child: new Text(item.title,
                                            style: new TextStyle(fontSize: 10,
                                                                 color: this._selectedIndex == item.index
                                                            ? item.activeColor
                                                            : item.inActiveColor))
                            )
                    }
                                )
                            )
                        )
                }
                        )
                    );
                children.Add(buildItem);
            });

            return(children);
        }
Ejemplo n.º 4
0
        List <Widget> _buildItems()
        {
            var children    = new List <Widget>();
            var screenWidth = MediaQuery.of(context: this.context).size.width;

            this.widget.items.ForEach(item => {
                Widget buildItem = new Flexible(
                    child: new Stack(
                        fit: StackFit.expand,
                        children: new List <Widget> {
                    new GestureDetector(
                        onTap: () => {
                        if (this._selectedIndex != item.index)
                        {
                            if (this.widget.tapCallBack != null)
                            {
                                if (this.widget.tapCallBack(this._selectedIndex, item.index))
                                {
                                    TabBarItemStatus status;
                                    if (this._tabBarItemStatus == TabBarItemStatus.toRefresh)
                                    {
                                        status = TabBarItemStatus.refreshToLeave;
                                    }
                                    else if (this._tabBarItemStatus == TabBarItemStatus.toHome)
                                    {
                                        status = TabBarItemStatus.normalAnimation;
                                    }
                                    else
                                    {
                                        status = this._tabBarItemStatus;
                                    }

                                    this._pageController.animateToPage(page: item.index,
                                                                       TimeSpan.FromMilliseconds(1),
                                                                       curve: Curves.ease);
                                    this.setState(() => {
                                        this._tabBarItemStatus = status;
                                        this._selectedIndex    = item.index;
                                    });
                                }
                            }
                        }
                        else
                        {
                            if ((this._tabBarItemStatus == TabBarItemStatus.toRefresh ||
                                 this._tabBarItemStatus == TabBarItemStatus.refreshToLeave) &&
                                item.index == 0)
                            {
                                EventBus.publish(sName: EventBusConstant.article_tab,
                                                 new List <object> {
                                    item.index
                                });
                            }
                        }
                    },
                        child: new Container(
                            color: CColors.Transparent,
                            child: new Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: new List <Widget> {
                        new Padding(
                            padding: EdgeInsets.only(top: 5),
                            child: this._buildItemIcon(item: item)
                            ),
                        new Padding(
                            padding: EdgeInsets.only(top: 2.5f),
                            child: new Text(item.title,
                                            style: new TextStyle(fontSize: 10,
                                                                 color: this._selectedIndex == item.index
                                                            ? item.activeColor
                                                            : item.inActiveColor))
                            )
                    }
                                )
                            )
                        ),
                    new Positioned(
                        left: (float)Math.Ceiling(screenWidth / 8) + 1,
                        top: 4,
                        child: new IgnorePointer(
                            child: new NotificationDot(
                                this.widget.notifications[index: item.index],
                                new BorderSide(color: CColors.White, 2)
                                )
                            )
                        )
                }
                        )
                    );
                children.Add(buildItem);
            });

            return(children);
        }