public override Widget build(BuildContext context) { List <Widget> stacked = new List <Widget> { }; MediaQueryData existingMediaQuery = MediaQuery.of(context); MediaQueryData newMediaQuery = MediaQuery.of(context); Widget content = new _TabSwitchingView( currentTabIndex: _controller.index, tabNumber: widget.tabBar.items.Count, tabBuilder: widget.tabBuilder ); EdgeInsets contentPadding = EdgeInsets.zero; if (widget.resizeToAvoidBottomInset) { newMediaQuery = newMediaQuery.removeViewInsets(removeBottom: true); contentPadding = EdgeInsets.only(bottom: existingMediaQuery.viewInsets.bottom); } if (widget.tabBar != null && (!widget.resizeToAvoidBottomInset || widget.tabBar.preferredSize.height > existingMediaQuery.viewInsets.bottom)) { float bottomPadding = widget.tabBar.preferredSize.height + existingMediaQuery.padding.bottom; if (widget.tabBar.opaque(context)) { contentPadding = EdgeInsets.only(bottom: bottomPadding); newMediaQuery = newMediaQuery.removePadding(removeBottom: true); } else { newMediaQuery = newMediaQuery.copyWith( padding: newMediaQuery.padding.copyWith( bottom: bottomPadding ) ); } } content = new MediaQuery( data: newMediaQuery, child: new Padding( padding: contentPadding, child: content ) ); stacked.Add(content); stacked.Add( new MediaQuery( data: existingMediaQuery.copyWith(textScaleFactor: 1), child: new Align( alignment: Alignment.bottomCenter, child: widget.tabBar.copyWith( currentIndex: _controller.index, onTap: (int newIndex) => { _controller.index = newIndex; if (widget.tabBar.onTap != null) { widget.tabBar.onTap(newIndex); } } ) ) ) ); return(new DecoratedBox( decoration: new BoxDecoration( color: CupertinoDynamicColor.resolve(widget.backgroundColor, context) ?? CupertinoTheme.of(context).scaffoldBackgroundColor ), child: new Stack( children: stacked ) )); }
public override Widget build(BuildContext context) { List <Widget> stacked = new List <Widget>(); Widget paddedContent = this.widget.child; MediaQueryData existingMediaQuery = MediaQuery.of(context); if (this.widget.navigationBar != null) { float topPadding = this.widget.navigationBar.preferredSize.height + existingMediaQuery.padding.top; float bottomPadding = this.widget.resizeToAvoidBottomInset ? existingMediaQuery.viewInsets.bottom : 0.0f; EdgeInsets newViewInsets = this.widget.resizeToAvoidBottomInset ? existingMediaQuery.viewInsets.copyWith(bottom: 0.0f) : existingMediaQuery.viewInsets; bool?fullObstruction = this.widget.navigationBar.fullObstruction == false ? CupertinoTheme.of(context).barBackgroundColor.alpha == 0xFF : this.widget.navigationBar.fullObstruction; if (fullObstruction == true) { paddedContent = new MediaQuery( data: existingMediaQuery .removePadding(removeTop: true) .copyWith( viewInsets: newViewInsets ), child: new Padding( padding: EdgeInsets.only(top: topPadding, bottom: bottomPadding), child: paddedContent ) ); } else { paddedContent = new MediaQuery( data: existingMediaQuery.copyWith( padding: existingMediaQuery.padding.copyWith( top: topPadding ), viewInsets: newViewInsets ), child: new Padding( padding: EdgeInsets.only(bottom: bottomPadding), child: paddedContent ) ); } } stacked.Add(new PrimaryScrollController( controller: this._primaryScrollController, child: paddedContent )); if (this.widget.navigationBar != null) { stacked.Add(new Positioned( top: 0.0f, left: 0.0f, right: 0.0f, child: this.widget.navigationBar )); } stacked.Add(new Positioned( top: 0.0f, left: 0.0f, right: 0.0f, height: existingMediaQuery.padding.top, child: new GestureDetector( onTap: this._handleStatusBarTap ) ) ); return(new DecoratedBox( decoration: new BoxDecoration( color: this.widget.backgroundColor ?? CupertinoTheme.of(context).scaffoldBackgroundColor ), child: new Stack( children: stacked ) )); }
public override Widget build(BuildContext context) { Widget paddedContent = widget.child; MediaQueryData existingMediaQuery = MediaQuery.of(context); if (widget.navigationBar != null) { float topPadding = widget.navigationBar.preferredSize.height + existingMediaQuery.padding.top; float bottomPadding = widget.resizeToAvoidBottomInset ? existingMediaQuery.viewInsets.bottom : 0.0f; EdgeInsets newViewInsets = widget.resizeToAvoidBottomInset ? existingMediaQuery.viewInsets.copyWith(bottom: 0.0f) : existingMediaQuery.viewInsets; bool fullObstruction = widget.navigationBar.shouldFullyObstruct(context); if (fullObstruction == true) { paddedContent = new MediaQuery( data: existingMediaQuery .removePadding(removeTop: true) .copyWith( viewInsets: newViewInsets ), child: new Padding( padding: EdgeInsets.only(top: topPadding, bottom: bottomPadding), child: paddedContent ) ); } else { paddedContent = new MediaQuery( data: existingMediaQuery.copyWith( padding: existingMediaQuery.padding.copyWith( top: topPadding ), viewInsets: newViewInsets ), child: new Padding( padding: EdgeInsets.only(bottom: bottomPadding), child: paddedContent ) ); } } else { float bottomPadding = widget.resizeToAvoidBottomInset ? existingMediaQuery.viewInsets.bottom : 0.0f; paddedContent = new Padding( padding: EdgeInsets.only(bottom: bottomPadding), child: paddedContent ); } List <Widget> childrenWigets = new List <Widget>(); childrenWigets.Add(new PrimaryScrollController( controller: _primaryScrollController, child: paddedContent )); if (widget.navigationBar != null) { childrenWigets.Add(new Positioned( top: 0.0f, left: 0.0f, right: 0.0f, child: new MediaQuery( data: existingMediaQuery.copyWith(textScaleFactor: 1), child: widget.navigationBar ) )); } childrenWigets.Add(new Positioned( top: 0.0f, left: 0.0f, right: 0.0f, height: existingMediaQuery.padding.top, child: new GestureDetector( onTap: _handleStatusBarTap ) )); return(new DecoratedBox( decoration: new BoxDecoration( color: CupertinoDynamicColor.resolve(widget.backgroundColor, context) ?? CupertinoTheme.of(context).scaffoldBackgroundColor ), child: new Stack( children: childrenWigets))); }