public override Widget build(BuildContext context) { string previousTooltipText = $"{_localizations.previousMonthTooltip} {_localizations.formatMonthYear(_previousMonthDate)}"; string nextTooltipText = $"{_localizations.nextMonthTooltip} {_localizations.formatMonthYear(_nextMonthDate)}"; Color controlColor = Theme.of(context).colorScheme.onSurface.withOpacity(0.60f); return(new Column( children: new List <Widget> { new Container( padding: EdgeInsetsDirectional.only(start: 16, end: 4), height: material_._subHeaderHeight, child: new Row( children: new List <Widget> { new Spacer(), new IconButton( icon: new Icon(Icons.chevron_left), color: controlColor, tooltip: _isDisplayingFirstMonth ? null : previousTooltipText, onPressed: _isDisplayingFirstMonth ? (VoidCallback)null : _handlePreviousMonth ), new IconButton(icon: new Icon(Icons.chevron_right), color: controlColor, tooltip: _isDisplayingLastMonth ? null : nextTooltipText, onPressed: _isDisplayingLastMonth ? (VoidCallback)null : _handleNextMonth ) } ) ), new _DayHeaders(), new Expanded( child: PageView.builder( controller: _pageController, itemBuilder: _buildItems, itemCount: utils.monthDelta(widget.firstDate, widget.lastDate) + 1, scrollDirection: Axis.horizontal, onPageChanged: _handleMonthPageChanged ) ) } )); }
public override Widget build(BuildContext context) { return(new Stack( children: new List <Widget> { new SingleChildScrollView( child: new SizedBox( height: material_._maxDayPickerHeight, child: _buildPicker() ) ), // Put the mode toggle button on top so that it won"t be covered up by the _MonthPicker new _DatePickerModeToggleButton( mode: _mode, title: _localizations.formatMonthYear(_currentDisplayedMonthDate), onTitlePressed: () => { // Toggle the day/year mode. _handleModeChanged(_mode == DatePickerMode.day ? DatePickerMode.year : DatePickerMode.day); } ) } )); }
public override Widget build(BuildContext context) { ThemeData themeData = Theme.of(context); MaterialLocalizations localizations = MaterialLocalizations.of(context); int year = this.displayedMonth.Year; int month = this.displayedMonth.Month; int daysInMonth = getDaysInMonth(year, month); int firstDayOffset = this._computeFirstDayOffset(year, month, localizations); List <Widget> labels = new List <Widget>(); labels.AddRange(this._getDayHeaders(themeData.textTheme.caption, localizations)); for (int i = 0; true; i += 1) { int day = i - firstDayOffset + 1; if (day > daysInMonth) { break; } if (day < 1) { labels.Add(new Container()); } else { DateTime dayToBuild = new DateTime(year, month, day); bool disabled = dayToBuild > this.lastDate || dayToBuild < this.firstDate || (this.selectableDayPredicate != null && !this.selectableDayPredicate(dayToBuild)); BoxDecoration decoration = null; TextStyle itemStyle = themeData.textTheme.body1; bool isSelectedDay = this.selectedDate.Year == year && this.selectedDate.Month == month && this.selectedDate.Day == day; if (isSelectedDay) { itemStyle = themeData.accentTextTheme.body2; decoration = new BoxDecoration( color: themeData.accentColor, shape: BoxShape.circle ); } else if (disabled) { itemStyle = themeData.textTheme.body1.copyWith(color: themeData.disabledColor); } else if (this.currentDate.Year == year && this.currentDate.Month == month && this.currentDate.Day == day) { itemStyle = themeData.textTheme.body2.copyWith(color: themeData.accentColor); } Widget dayWidget = new Container( decoration: decoration, child: new Center( child: new Text(localizations.formatDecimal(day), style: itemStyle) ) ); if (!disabled) { dayWidget = new GestureDetector( behavior: HitTestBehavior.opaque, onTap: () => { this.onChanged(dayToBuild); }, child: dayWidget, dragStartBehavior: this.dragStartBehavior ); } labels.Add(dayWidget); } } return(new Padding( padding: EdgeInsets.symmetric(horizontal: 8.0f), child: new Column( children: new List <Widget> { new Container( height: DatePickerUtils._kDayPickerRowHeight, child: new Center( child: new Text( localizations.formatMonthYear(this.displayedMonth), style: themeData.textTheme.subhead ) ) ), new Flexible( child: GridView.custom( gridDelegate: DatePickerUtils._kDayPickerGridDelegate, childrenDelegate: new SliverChildListDelegate(labels, addRepaintBoundaries: false) ) ) } ) )); }