public override void initState() { base.initState(); this._selectedIndex = this.widget.initialTabIndex; this._bottomPadding = 0; this._pageController = new PageController(initialPage: this._selectedIndex); this._articleRefreshSubId = EventBus.subscribe(sName: EventBusConstant.article_refresh, args => { if (args.isNotNullAndEmpty()) { TabBarItemStatus status = (TabBarItemStatus)args[0]; if (this._tabBarItemStatus != status) { this.setState(() => this._tabBarItemStatus = status); } } }); }
void _changeTabBarItemStatus(float pixels, TabBarItemStatus status) { if (pixels > MediaQuery.of(context: this.context).size.height) { if (!this._isRefresh) { this._isRefresh = true; EventBus.publish(sName: EventBusConstant.article_refresh, new List <object> { TabBarItemStatus.toRefresh }); } } else { if (this._isRefresh) { this._isRefresh = false; EventBus.publish(sName: EventBusConstant.article_refresh, new List <object> { status }); } } }
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); }