public override Widget build(BuildContext context) { D.assert(actions.isNotEmpty); ThemeData theme = Theme.of(context); MaterialBannerThemeData bannerTheme = MaterialBannerTheme.of(context); bool isSingleRow = actions.Count == 1 && !forceActionsBelow; EdgeInsetsGeometry padding = this.padding ?? bannerTheme?.padding ?? (isSingleRow ? EdgeInsetsDirectional.only(start: 16.0f, top: 2.0f) : EdgeInsetsDirectional.only(start: 16.0f, top: 24.0f, end: 16.0f, bottom: 4.0f)); EdgeInsetsGeometry leadingPadding = this.leadingPadding ?? bannerTheme?.padding ?? EdgeInsetsDirectional.only(end: 16.0f); Widget buttonBar = new ButtonBar( layoutBehavior: ButtonBarLayoutBehavior.constrained, children: actions ); Color backgroundColor = this.backgroundColor ?? bannerTheme?.backgroundColor ?? theme.colorScheme.surface; TextStyle textStyle = contentTextStyle ?? bannerTheme?.contentTextStyle ?? theme.textTheme.bodyText2; var rowList = new List <Widget>(); if (leading != null) { rowList.Add(new Padding( padding: leadingPadding, child: leading )); } rowList.Add(new Expanded( child: new DefaultTextStyle( style: textStyle, child: content ) )); if (isSingleRow) { rowList.Add(buttonBar); } var columnList = new List <Widget>(); columnList.Add(new Padding( padding: padding, child: new Row( children: rowList ) )); if (!isSingleRow) { columnList.Add(buttonBar); } columnList.Add(new Divider(height: 0)); return(new Container( color: backgroundColor, child: new Column( children: columnList ) )); }
public override Widget build(BuildContext context) { ThemeData theme = Theme.of(context); ColorScheme colorScheme = theme.colorScheme; MaterialLocalizations localizations = MaterialLocalizations.of(context); Orientation? orientation = MediaQuery.of(context).orientation; TextTheme textTheme = theme.textTheme; float textScaleFactor = Mathf.Min(MediaQuery.of(context).textScaleFactor, 1.3f); string dateText = _selectedDate != null ? localizations.formatMediumDate(_selectedDate) : "Date"; Color dateColor = colorScheme.brightness == Brightness.light ? colorScheme.onPrimary : colorScheme.onSurface; TextStyle dateStyle = orientation == Orientation.landscape ? textTheme.headline5?.copyWith(color: dateColor) : textTheme.headline4?.copyWith(color: dateColor); Widget actions = new ButtonBar( buttonTextTheme: ButtonTextTheme.primary, layoutBehavior: ButtonBarLayoutBehavior.constrained, children: new List <Widget> { new FlatButton( child: new Text(widget.cancelText ?? localizations.cancelButtonLabel), onPressed: _handleCancel ), new FlatButton( child: new Text(widget.confirmText ?? localizations.okButtonLabel), onPressed: _handleOk ), } ); Widget picker = null; IconData entryModeIcon = null; string entryModeTooltip = null; switch (_entryMode) { case DatePickerEntryMode.calendar: picker = new CalendarDatePicker( key: _calendarPickerKey, initialDate: _selectedDate, firstDate: widget.firstDate, lastDate: widget.lastDate, onDateChanged: _handleDateChanged, selectableDayPredicate: widget.selectableDayPredicate, initialCalendarMode: widget.initialCalendarMode ); entryModeIcon = Icons.edit; entryModeTooltip = "Switch to input"; break; case DatePickerEntryMode.input: picker = new Form( key: _formKey, autovalidate: _autoValidate, child: new InputDatePickerFormField( initialDate: _selectedDate, firstDate: widget.firstDate, lastDate: widget.lastDate, onDateSubmitted: _handleDateChanged, onDateSaved: _handleDateChanged, selectableDayPredicate: widget.selectableDayPredicate, errorFormatText: widget.errorFormatText, errorInvalidText: widget.errorInvalidText, fieldHintText: widget.fieldHintText, fieldLabelText: widget.fieldLabelText, autofocus: true ) ); entryModeIcon = Icons.calendar_today; entryModeTooltip = "Switch to calendar"; break; } Widget header = new DatePickerHeader( helpText: widget.helpText ?? "SELECT DATE", titleText: dateText, titleStyle: dateStyle, orientation: orientation, isShort: orientation == Orientation.landscape, icon: entryModeIcon, iconTooltip: entryModeTooltip, onIconPressed: _handelEntryModeToggle ); Size dialogSize = _dialogSize(context) * textScaleFactor; DialogTheme dialogTheme = Theme.of(context).dialogTheme; return(new Dialog( child: new AnimatedContainer( width: dialogSize.width, height: dialogSize.height, duration: material_._dialogSizeAnimationDuration, curve: Curves.easeIn, child: new MediaQuery( data: MediaQuery.of(context).copyWith( textScaleFactor: textScaleFactor ), child: new Builder(builder: (BuildContext subContext) => { switch (orientation) { case Orientation.portrait: return new Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: new List <Widget> { header, new Expanded(child: picker), actions, } ); case Orientation.landscape: return new Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: new List <Widget> { header, new Flexible( child: new Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: new List <Widget> { new Expanded(child: picker), actions, } ) ), } ); } return null; }) ) ), insetPadding: EdgeInsets.symmetric(horizontal: 16.0f, vertical: 24.0f), shape: dialogTheme.shape ?? new RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(4.0f)) ), clipBehavior: Clip.antiAlias )); }