Widget _buildCheckbox( Color color = null, bool isChecked = false, VoidCallback onRowTap = null, ValueChanged <bool?> onCheckboxChanged = null ) { Widget contents = new Padding( padding: EdgeInsetsDirectional.only(start: horizontalMargin, end: horizontalMargin / 2.0f), child: new Center( child: new Checkbox( activeColor: color, value: isChecked, onChanged: onCheckboxChanged ) ) ); if (onRowTap != null) { contents = new TableRowInkWell( onTap: () => onRowTap(), child: contents ); } return(new TableCell( verticalAlignment: TableCellVerticalAlignment.fill, child: contents )); }
public override Widget build(BuildContext context) { var theme = Theme.of(context); return(new Container( height: 56.0f, padding: EdgeInsetsDirectional.only(16.0f), alignment: AlignmentDirectional.centerStart, child: new Row( children: new List <Widget> { new Radio <_ChoiceValue <T> >( value: value, groupValue: groupValue, onChanged: onChanged ), new Expanded( child: new GestureDetector( behavior: HitTestBehavior.opaque, onTap: () => { onChanged(value); }, child: new Text(value.title, style: theme.textTheme.subtitle1 ) ) ) } ) )); }
public override Widget build(BuildContext context) { ColorScheme colorScheme = Theme.of(context).colorScheme; TextTheme textTheme = Theme.of(context).textTheme; Color controlColor = colorScheme.onSurface.withOpacity(0.60f); var rowChildren = new List <Widget> { new Flexible( child: new Container( height: material_._subHeaderHeight, child: new InkWell( onTap: () => widget.onTitlePressed(), child: new Padding( padding: EdgeInsets.symmetric(horizontal: 8), child: new Row( children: new List <Widget> { new Flexible( child: new Text( widget.title, overflow: TextOverflow.ellipsis, style: textTheme.subtitle2?.copyWith( color: controlColor ) ) ), new RotationTransition( turns: _controller, child: new Icon( Icons.arrow_drop_down, color: controlColor ) ), } ) ) ) ) ) }; if (widget.mode == DatePickerMode.day) { // Give space for the prev/next month buttons that are underneath this row rowChildren.Add(new SizedBox(width: material_._monthNavButtonsWidth)); } return(new Container( padding: EdgeInsetsDirectional.only(start: 16, end: 4), height: material_._subHeaderHeight, child: new Row( children: rowChildren ) )); }
public override Widget build(BuildContext context) { var theme = Theme.of(context); return(new Container( height: 48.0f, padding: EdgeInsetsDirectional.only(56.0f), alignment: AlignmentDirectional.centerStart, child: new Text(text, style: theme.textTheme.bodyText2.copyWith( color: theme.primaryColor ) ) )); }
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) { ThemeData theme = Theme.of(context); return(new Material( elevation: 2.0f, borderRadius: BorderRadius.only( topLeft: Radius.circular(16.0f), topRight: Radius.circular(16.0f) ), child: new Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: new List <Widget> { new GestureDetector( behavior: HitTestBehavior.opaque, onVerticalDragUpdate: this.onVerticalDragUpdate, onVerticalDragEnd: this.onVerticalDragEnd, onTap: () => { this.onTap?.Invoke(); }, child: new Container( height: 48.0f, padding: EdgeInsetsDirectional.only(start: 16.0f), alignment: AlignmentDirectional.centerStart, child: new DefaultTextStyle( style: theme.textTheme.subtitle1, child: new Tooltip( message: "Tap to dismiss", child: this.title ) ) ) ), new Divider(height: 1.0f), new Expanded(child: this.child) } ) )); }
public override Widget build(BuildContext context) { DividerThemeData dividerTheme = DividerTheme.of(context); float height = this.height ?? dividerTheme?.space ?? 16.0f; float thickness = this.thickness ?? dividerTheme?.thickness ?? 0.0f; float indent = this.indent ?? dividerTheme?.indent ?? 0.0f; float endIndent = this.endIndent ?? dividerTheme?.endIndent ?? 0.0f; return(new SizedBox( height: height, child: new Center( child: new Container( height: thickness, //TODO: update to EdgeInsetsGeometry margin: EdgeInsetsDirectional.only(start: indent, end: endIndent), decoration: new BoxDecoration( border: new Border( bottom: createBorderSide(context, color: color, width: thickness)) ) ) ) )); }
public override Widget build(BuildContext context) { DividerThemeData dividerTheme = DividerTheme.of(context); float width = this.width ?? dividerTheme.space ?? 16.0f; float thickness = this.thickness ?? dividerTheme.thickness ?? 0.0f; float indent = this.indent ?? dividerTheme.indent ?? 0.0f; float endIndent = this.endIndent ?? dividerTheme.endIndent ?? 0.0f; return(new SizedBox( width: width, child: new Center( child: new Container( width: thickness, margin: EdgeInsetsDirectional.only(top: indent, bottom: endIndent), decoration: new BoxDecoration( border: new Border( left: Divider.createBorderSide(context, color: color, width: thickness) ) ) ) ) )); }
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) { D.assert(!_debugInteractive || material_.debugCheckHasMaterial(context)); ThemeData theme = Theme.of(context); BoxDecoration _kSelectedDecoration = new BoxDecoration( border: new Border(bottom: Divider.createBorderSide(context, width: dividerThickness)), // The backgroundColor has to be transparent so you can see the ink on the material color: (Theme.of(context).brightness == Brightness.light) ? _grey100Opacity : _grey300Opacity ); BoxDecoration _kUnselectedDecoration = new BoxDecoration( border: new Border(bottom: Divider.createBorderSide(context, width: dividerThickness)) ); bool displayCheckboxColumn = showCheckboxColumn && rows.Any((DataRow row) => row.onSelectChanged != null); bool allChecked = displayCheckboxColumn && !rows.Any((DataRow row) => row.onSelectChanged != null && !row.selected); List <TableColumnWidth> tableColumns = new List <TableColumnWidth>(new TableColumnWidth[columns.Count + (displayCheckboxColumn ? 1 : 0)]); List <TableRow> tableRows = LinqUtils <TableRow, int> .SelectList(Enumerable.Range(0, rows.Count + 1), (index) => { return(new TableRow( key: index == 0 ? _headingRowKey : rows[index - 1].key, decoration: index > 0 && rows[index - 1].selected ? _kSelectedDecoration : _kUnselectedDecoration, children: new List <Widget>(new Widget[tableColumns.Count]) )); }); int rowIndex; int displayColumnIndex = 0; if (displayCheckboxColumn) { tableColumns[0] = new FixedColumnWidth(horizontalMargin + Checkbox.width + horizontalMargin / 2.0f); tableRows[0].children[0] = _buildCheckbox( color: theme.accentColor, isChecked: allChecked, onCheckboxChanged: _check => _handleSelectAll(_check ?? false) ); rowIndex = 1; foreach (DataRow row in rows) { tableRows[rowIndex].children[0] = _buildCheckbox( color: theme.accentColor, isChecked: row.selected, onRowTap: () => { if (row.onSelectChanged != null) { row.onSelectChanged(!row.selected); } }, onCheckboxChanged: _select => row.onSelectChanged(_select ?? false) ); rowIndex += 1; } displayColumnIndex += 1; } for (int dataColumnIndex = 0; dataColumnIndex < columns.Count; dataColumnIndex += 1) { DataColumn column = columns[dataColumnIndex]; float paddingStart; if (dataColumnIndex == 0 && displayCheckboxColumn) { paddingStart = horizontalMargin / 2.0f; } else if (dataColumnIndex == 0 && !displayCheckboxColumn) { paddingStart = horizontalMargin; } else { paddingStart = columnSpacing / 2.0f; } float paddingEnd; if (dataColumnIndex == columns.Count - 1) { paddingEnd = horizontalMargin; } else { paddingEnd = columnSpacing / 2.0f; } EdgeInsetsDirectional padding = EdgeInsetsDirectional.only( start: paddingStart, end: paddingEnd ); if (dataColumnIndex == _onlyTextColumn) { tableColumns[displayColumnIndex] = new IntrinsicColumnWidth(flex: 1.0f); } else { tableColumns[displayColumnIndex] = new IntrinsicColumnWidth(); } var currentColumnIndex = dataColumnIndex; tableRows[0].children[displayColumnIndex] = _buildHeadingCell( context: context, padding: padding, label: column.label, tooltip: column.tooltip, numeric: column.numeric, onSort: column.onSort != null ? () => column.onSort(currentColumnIndex, sortColumnIndex != currentColumnIndex || !sortAscending) : (VoidCallback)null, sorted: dataColumnIndex == sortColumnIndex, ascending: sortAscending ); rowIndex = 1; foreach (DataRow row in rows) { DataCell cell = row.cells[dataColumnIndex]; var curRow = row; tableRows[rowIndex].children[displayColumnIndex] = _buildDataCell( context: context, padding: padding, label: cell.child, numeric: column.numeric, placeholder: cell.placeholder, showEditIcon: cell.showEditIcon, onTap: cell.onTap, onSelectChanged: () => { if (curRow.onSelectChanged != null) { curRow.onSelectChanged(!curRow.selected); } }); rowIndex += 1; } displayColumnIndex += 1; } return(new Table( columnWidths: LinqUtils <int, TableColumnWidth> .SelectDictionary(tableColumns, ((TableColumnWidth x) => tableColumns.IndexOf(x))), children: tableRows )); }
public override Widget build(BuildContext context) { BoxDecoration decoration = null; if (backgroundColor != null) { decoration = new BoxDecoration(color: backgroundColor); } EdgeInsetsDirectional padding = EdgeInsetsDirectional.only( start: leading != null ? 8.0f : 16.0f, end: trailing != null ? 8.0f : 16.0f ); ThemeData theme = Theme.of(context); ThemeData darkTheme = new ThemeData( brightness: Brightness.dark, accentColor: theme.accentColor, accentColorBrightness: theme.accentColorBrightness ); var expandChildren = new List <widgets.Widget>(); if (leading != null) { expandChildren.Add(new Padding( padding: EdgeInsetsDirectional.only(end: 8.0f), child: leading)); } if (title != null && subtitle != null) { expandChildren.Add(new Expanded( child: new Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new DefaultTextStyle( style: darkTheme.textTheme.subtitle1, softWrap: false, overflow: TextOverflow.ellipsis, child: title ), new DefaultTextStyle( style: darkTheme.textTheme.caption, softWrap: false, overflow: TextOverflow.ellipsis, child: subtitle ) } ) )); } else if (title != null || subtitle != null) { expandChildren.Add(new Expanded( child: new DefaultTextStyle( style: darkTheme.textTheme.subtitle1, softWrap: false, overflow: TextOverflow.ellipsis, child: title ?? subtitle ) )); } if (trailing != null) { expandChildren.Add(new Padding( padding: EdgeInsetsDirectional.only(start: 8.0f), child: trailing)); } return(new Container( padding: padding, decoration: decoration, height: (title != null && subtitle != null) ? 68.0f : 48.0f, child: new Theme( data: darkTheme, child: IconTheme.merge( data: new IconThemeData(color: Colors.white), child: new Row( crossAxisAlignment: CrossAxisAlignment.center, children: expandChildren ) ) ) )); }
public override Widget build(BuildContext context) { ThemeData theme = Theme.of(context); ColorScheme colorScheme = theme.colorScheme; TextTheme textTheme = theme.textTheme; bool isDark = colorScheme.brightness == Brightness.dark; Color primarySurfaceColor = isDark ? colorScheme.surface : colorScheme.primary; Color onPrimarySurfaceColor = isDark ? colorScheme.onSurface : colorScheme.onPrimary; TextStyle helpStyle = textTheme.overline?.copyWith( color: onPrimarySurfaceColor ); Text help = new Text( helpText, style: helpStyle, maxLines: 1, overflow: TextOverflow.ellipsis ); Text title = new Text( titleText, style: titleStyle, maxLines: (isShort || orientation == Orientation.portrait) ? 1 : 2, overflow: TextOverflow.ellipsis ); IconButton icon = new IconButton( icon: new Icon(this.icon), color: onPrimarySurfaceColor, tooltip: iconTooltip, onPressed: onIconPressed ); switch (orientation) { case Orientation.portrait: return(new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Container( height: DatePickerHeaderUtils._datePickerHeaderPortraitHeight, color: primarySurfaceColor, padding: EdgeInsetsDirectional.only( start: 24f, end: 12f ), child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new SizedBox(height: 16f), new Flexible(child: help), new SizedBox(height: 38), new Row( children: new List <Widget> { new Expanded(child: title), icon, } ), } ) ) } )); case Orientation.landscape: return(new Row( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new Container( width: DatePickerHeaderUtils._datePickerHeaderLandscapeWidth, color: primarySurfaceColor, child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { new SizedBox(height: 16), new Padding( padding: EdgeInsets.symmetric( horizontal: DatePickerHeaderUtils._headerPaddingLandscape ), child: help ), new SizedBox(height: isShort ? 16 : 56), new Padding( padding: EdgeInsets.symmetric( horizontal: DatePickerHeaderUtils._headerPaddingLandscape ), child: title ), new Spacer(), new Padding( padding: EdgeInsets.symmetric( horizontal: 4 ), child: icon ), } ) ), } )); } return(null); }
// Changes the padding between the start edge of the Material and the cart icon // based on the number of products in the cart (padding increases when > 0 // products.) EdgeInsetsDirectional _cartPaddingFor(int numProducts) { return((numProducts == 0) ? EdgeInsetsDirectional.only(start: 20.0f, end: 8.0f) : EdgeInsetsDirectional.only(start: 32.0f, end: 8.0f)); }
public override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterialLocalizations(context)); ThemeData themeData = Theme.of(context); MaterialLocalizations localizations = MaterialLocalizations.of(context); List <Widget> headerWidgets = new List <Widget>(); float startPadding = 24.0f; if (_selectedRowCount == 0) { headerWidgets.Add(new Expanded(child: widget.header)); if (widget.header is ButtonBar) { startPadding = 12.0f; } } else { headerWidgets.Add(new Expanded( child: new Text(localizations.selectedRowCountTitle(_selectedRowCount)) )); } if (widget.actions != null) { headerWidgets.AddRange( LinqUtils <Widget> .SelectList(widget.actions, ((Widget action) => { return(new Padding( padding: EdgeInsetsDirectional.only( start: 24.0f - 8.0f * 2.0f), child: action )); })) ); } TextStyle footerTextStyle = themeData.textTheme.caption; List <Widget> footerWidgets = new List <Widget>(); if (widget.onRowsPerPageChanged != null) { List <Widget> availableRowsPerPage = LinqUtils <Widget, int> .SelectList( LinqUtils <int> .WhereList(widget.availableRowsPerPage, ((int value) => value <= _rowCount || value == widget.rowsPerPage)), (int value) => { return((Widget) new DropdownMenuItem <int>( value: value, child: new Text($"{value}") )); }); footerWidgets.AddRange(new List <Widget>() { new Container(width: 14.0f), // to match trailing padding in case we overflow and end up scrolling new Text(localizations.rowsPerPageTitle), new ConstrainedBox( constraints: new BoxConstraints(minWidth: 64.0f), // 40.0 for the text, 24.0 for the icon child: new Align( alignment: AlignmentDirectional.centerEnd, child: new DropdownButtonHideUnderline( child: new DropdownButton <int>( items: availableRowsPerPage.Cast <DropdownMenuItem <int> >().ToList(), value: widget.rowsPerPage, onChanged: widget.onRowsPerPageChanged, style: footerTextStyle, iconSize: 24.0f ) ) ) ), }); } footerWidgets.AddRange(new List <Widget>() { new Container(width: 32.0f), new Text( localizations.pageRowsInfoTitle( _firstRowIndex + 1, _firstRowIndex + widget.rowsPerPage, _rowCount, _rowCountApproximate ) ), new Container(width: 32.0f), new IconButton( icon: new Icon(Icons.chevron_left), padding: EdgeInsets.zero, tooltip: localizations.previousPageTooltip, onPressed: _firstRowIndex <= 0 ? (VoidCallback)null : _handlePrevious), new Container(width: 24.0f), new IconButton( icon: new Icon(Icons.chevron_right), padding: EdgeInsets.zero, tooltip: localizations.nextPageTooltip, onPressed: (!_rowCountApproximate && (_firstRowIndex + widget.rowsPerPage >= _rowCount)) ? (VoidCallback)null : _handleNext ), new Container(width: 14.0f), }); return(new LayoutBuilder( builder: (BuildContext _context, BoxConstraints constraints) => { return new Card( child: new Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: new List <Widget> { new DefaultTextStyle( style: _selectedRowCount > 0 ? themeData.textTheme.subtitle1.copyWith(color: themeData.accentColor) : themeData.textTheme.headline6.copyWith(fontWeight: FontWeight.w400), child: IconTheme.merge( data: new IconThemeData( opacity: 0.54f ), child: new Ink( height: 64.0f, color: _selectedRowCount > 0 ? themeData.secondaryHeaderColor : null, child: new Padding( padding: EdgeInsetsDirectional.only( start: startPadding, end: 14.0f), child: new Row( mainAxisAlignment: MainAxisAlignment.end, children: headerWidgets ) ) ) ) ), new SingleChildScrollView( scrollDirection: Axis.horizontal, dragStartBehavior: widget.dragStartBehavior, child: new ConstrainedBox( constraints: new BoxConstraints(minWidth: constraints.minWidth), child: new DataTable( key: _tableKey, columns: widget.columns, sortColumnIndex: widget.sortColumnIndex, sortAscending: widget.sortAscending, onSelectAll: widget.onSelectAll, dataRowHeight: widget.dataRowHeight, headingRowHeight: widget.headingRowHeight, horizontalMargin: widget.horizontalMargin, columnSpacing: widget.columnSpacing, rows: _getRows(_firstRowIndex, widget.rowsPerPage) ) ) ), new DefaultTextStyle( style: footerTextStyle, child: IconTheme.merge( data: new IconThemeData( opacity: 0.54f ), child: new Container( height: 56.0f, child: new SingleChildScrollView( dragStartBehavior: widget.dragStartBehavior, scrollDirection: Axis.horizontal, reverse: true, child: new Row( children: footerWidgets ) ) ) ) ) } ) ); } )); }
public override Widget build(BuildContext context) { List <MergeableMaterialItem> items = new List <MergeableMaterialItem>(); for (int i = 0; i < widget.children.Count; i++) { int expandIndex = i; if (_isChildExpanded(expandIndex) && expandIndex != 0 && !_isChildExpanded(expandIndex - 1)) { items.Add(new MaterialGap( key: new _SaltedKey <BuildContext, int>(context, expandIndex * 2 - 1))); } ExpansionPanel child = widget.children[expandIndex]; Widget headerWidget = child.headerBuilder( context, _isChildExpanded(expandIndex) ); Widget expandIconContainer = new Container( margin: EdgeInsetsDirectional.only(end: 8.0f), child: new ExpandIcon( isExpanded: _isChildExpanded(expandIndex), padding: EdgeInsets.all(16.0f), onPressed: !child.canTapOnHeader ? (bool isExpanded) => _handlePressed(isExpanded, expandIndex) : (ValueChanged <bool>)null ) ); Widget header = new Row( children: new List <Widget> { new Expanded( child: new AnimatedContainer( duration: widget.animationDuration, curve: Curves.fastOutSlowIn, margin: _isChildExpanded(expandIndex) ? widget.expandedHeaderPadding : EdgeInsets.zero, child: new ConstrainedBox( constraints: new BoxConstraints( minHeight: material_._kPanelHeaderCollapsedHeight), child: headerWidget ) ) ), expandIconContainer, } ); if (child.canTapOnHeader) { header = new InkWell( onTap: () => _handlePressed(_isChildExpanded(expandIndex), expandIndex), child: header ); } items.Add(new MaterialSlice( key: new _SaltedKey <BuildContext, int>(context, expandIndex * 2), child: new Column( children: new List <Widget> { header, new AnimatedCrossFade( firstChild: new Container(height: 0.0f), secondChild: child.body, firstCurve: new Interval(0.0f, 0.6f, curve: Curves.fastOutSlowIn), secondCurve: new Interval(0.4f, 1.0f, curve: Curves.fastOutSlowIn), sizeCurve: Curves.fastOutSlowIn, crossFadeState: _isChildExpanded(expandIndex) ? CrossFadeState.showSecond : CrossFadeState.showFirst, duration: widget.animationDuration ) } ) ) ); if (_isChildExpanded(expandIndex) && expandIndex != widget.children.Count - 1) { items.Add(new MaterialGap( key: new _SaltedKey <BuildContext, int>(context, expandIndex * 2 + 1))); } } return(new MergeableMaterial( hasDividers: true, children: items)); }