public override Widget build(BuildContext context) { MaterialLocalizations localizations = MaterialLocalizations.of(context); List <Widget> items = new List <Widget>(); if (widget.handleCut != null) { items.Add(_getItem(widget.handleCut, localizations.cutButtonLabel)); } if (widget.handleCopy != null) { items.Add(_getItem(widget.handleCopy, localizations.copyButtonLabel)); } if (widget.handlePaste != null) { items.Add(_getItem(widget.handlePaste, localizations.pasteButtonLabel)); } if (widget.handleSelectAll != null) { items.Add(_getItem(widget.handleSelectAll, localizations.selectAllButtonLabel)); } if (items.isEmpty()) { return(new Container(width: 0.0f, height: 0.0f)); } items.Insert(0, new IconButton( icon: new Icon(_overflowOpen ? Icons.arrow_back : Icons.more_vert), onPressed: () => { setState(() => { _overflowOpen = !_overflowOpen; }); }, tooltip: _overflowOpen ? localizations.backButtonTooltip : localizations.moreButtonTooltip ) ); return(new _TextSelectionToolbarContainer( key: _containerKey, overflowOpen: _overflowOpen, child: new AnimatedSize( vsync: this, duration: new TimeSpan(0, 0, 0, 0, 140), child: new Material( elevation: 1.0f, child: new _TextSelectionToolbarItems( isAbove: widget.isAbove, overflowOpen: _overflowOpen, children: items) ) ) )); }
public string format(BuildContext context) { D.assert(WidgetsD.debugCheckHasMediaQuery(context)); D.assert(MaterialD.debugCheckHasMaterialLocalizations(context)); MaterialLocalizations localizations = MaterialLocalizations.of(context); return(localizations.formatTimeOfDay( this, alwaysUse24HourFormat: MediaQuery.of(context).alwaysUse24HourFormat )); }
public static IPromise <object> showModalBottomSheet <T>( BuildContext context, WidgetBuilder builder ) { D.assert(context != null); D.assert(builder != null); D.assert(MaterialD.debugCheckHasMaterialLocalizations(context)); return(Navigator.push(context, new _ModalBottomSheetRoute <T>( builder: builder, theme: Theme.of(context, shadowThemeOnly: true), barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel ))); }
public override void didChangeDependencies() { base.didChangeDependencies(); _localizations = MaterialLocalizations.of(context); _textDirection = Directionality.of(context); if (!_announcedInitialDate) { _announcedInitialDate = true; // SemanticsService.announce( // _localizations.formatFullDate(_selectedDate), // _textDirection, // ); } }
public override Widget build(BuildContext context) { D.assert(MaterialD.debugCheckHasMaterialLocalizations(context)); return(this.widget.child != null ? (Widget) new InkWell( onTap: this.showButtonMenu, child: this.widget.child ) : new IconButton( icon: this.widget.icon ?? this._getIcon(Theme.of(context).platform), padding: this.widget.padding, tooltip: this.widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip, onPressed: this.showButtonMenu )); }
public override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterialLocalizations(context)); MaterialLocalizations localizations = MaterialLocalizations.of(context); _DropdownRoute <T> route = widget.route; List <Widget> children = new List <Widget>(); for (int itemIndex = 0; itemIndex < route.items.Count; ++itemIndex) { children.Add(new _DropdownMenuItemButton <T>( route: widget.route, padding: widget.padding, buttonRect: widget.buttonRect, constraints: widget.constraints, itemIndex: itemIndex )); } return(new FadeTransition( opacity: _fadeOpacity, child: new CustomPaint( painter: new _DropdownMenuPainter( color: widget.dropdownColor ?? Theme.of(context).canvasColor, elevation: route.elevation, selectedIndex: route.selectedIndex, resize: _resize, getSelectedItemOffset: () => route.getItemOffset(route.selectedIndex ?? 0) ), child: new Material( type: MaterialType.transparency, textStyle: route.style, child: new ScrollConfiguration( behavior: new _DropdownScrollBehavior(), child: new Scrollbar( child: new ListView( controller: widget.route.scrollController, padding: material_.kMaterialListPadding, shrinkWrap: true, children: children ) ) ) ) ) )); }
public override Widget build(BuildContext context) { return(new IconButton( icon: new BackButtonIcon(), color: color, tooltip: MaterialLocalizations.of(context).backButtonTooltip, onPressed: () => { if (onPressed != null) { onPressed(); } else { Navigator.maybePop(context); } })); }
public override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterialLocalizations(context)); return(new IconButton( icon: new Icon(Icons.close), color: color, tooltip: MaterialLocalizations.of(context).closeButtonTooltip, onPressed: () => { if (onPressed != null) { onPressed(); } else { Navigator.maybePop(context); } })); }
public static ThemeData of(BuildContext context, bool shadowThemeOnly = false) { _InheritedTheme inheritedTheme = context.dependOnInheritedWidgetOfExactType <_InheritedTheme>(); if (shadowThemeOnly) { if (inheritedTheme == null || inheritedTheme.theme.isMaterialAppTheme) { return(null); } return(inheritedTheme.theme.data); } MaterialLocalizations localizations = MaterialLocalizations.of(context); ScriptCategory category = ScriptCategory.englishLike; ThemeData theme = inheritedTheme?.theme?.data ?? _kFallbackTheme; return(ThemeData.localize(theme, theme.typography.geometryThemeFor(category))); }
public override void didChangeDependencies() { base.didChangeDependencies(); if (_selectedDate != null) { MaterialLocalizations localizations = MaterialLocalizations.of(context); _inputText = localizations.formatCompactDate(_selectedDate.Value); TextEditingValue textEditingValue = _controller.value.copyWith(text: _inputText); if (widget.autofocus && !_autoSelected) { textEditingValue = textEditingValue.copyWith(selection: new TextSelection( baseOffset: 0, extentOffset: _inputText.Length )); _autoSelected = true; } _controller.value = textEditingValue; } }
InputDecoration _getEffectiveDecoration() { MaterialLocalizations localizations = MaterialLocalizations.of(this.context); InputDecoration effectiveDecoration = (this.widget.decoration ?? new InputDecoration()) .applyDefaults(Theme.of(this.context).inputDecorationTheme) .copyWith( enabled: this.widget.enabled ); if (!this.needsCounter) { return(effectiveDecoration); } int currentLength = this._effectiveController.value.text.Length; string counterText = $"{currentLength}"; if (this.widget.maxLength != TextField.noMaxLength) { counterText += $"/{this.widget.maxLength}"; } // Handle length exceeds maxLength if (this._effectiveController.value.text.Length > this.widget.maxLength) { ThemeData themeData = Theme.of(this.context); return(effectiveDecoration.copyWith( errorText: effectiveDecoration.errorText ?? "", counterStyle: effectiveDecoration.errorStyle ?? themeData.textTheme.caption.copyWith(color: themeData.errorColor), counterText: counterText )); } return(effectiveDecoration.copyWith( counterText: counterText )); }
public override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterial(context)); D.assert(material_.debugCheckHasMaterialLocalizations(context)); return(new ListTile( leading: icon, title: child ?? new Text(MaterialLocalizations.of(context).aboutListTileTitle( applicationName ?? material_._defaultApplicationName(context) )), dense: dense, onTap: () => { material_.showAboutDialog( context: context, applicationName: applicationName, applicationVersion: applicationVersion, applicationIcon: applicationIcon, applicationLegalese: applicationLegalese, children: aboutBoxChildren ); } )); }
public override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterialLocalizations(context)); if (widget.child != null) { return(new Tooltip( message: widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip, child: new InkWell( onTap: widget.enabled ? showButtonMenu : (GestureTapCallback)null, canRequestFocus: widget.enabled, child: widget.child ) )); } return(new IconButton( icon: widget.icon ?? _getIcon(Theme.of(context).platform), padding: widget.padding, tooltip: widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip, onPressed: widget.enabled ? showButtonMenu : (VoidCallback)null )); }
public override Widget build(BuildContext context) { ThemeData theme = Theme.of(context); ColorScheme colorScheme = theme.colorScheme; TextStyle dayHeaderStyle = theme.textTheme.caption?.apply( color: colorScheme.onSurface.withOpacity(0.60f) ); MaterialLocalizations localizations = MaterialLocalizations.of(context); List <Widget> labels = _getDayHeaders(dayHeaderStyle, localizations); return(new Padding( padding: EdgeInsets.symmetric(horizontal: material_._monthPickerHorizontalPadding), child: GridView.custom( shrinkWrap: true, gridDelegate: material_._dayPickerGridDelegate, childrenDelegate: new SliverChildListDelegate( labels, addRepaintBoundaries: false ) ) )); }
public override Widget build(BuildContext context) { ThemeData theme = Theme.of(context); NavigationRailThemeData navigationRailTheme = NavigationRailTheme.of(context); MaterialLocalizations localizations = MaterialLocalizations.of(context); Color backgroundColor = widget.backgroundColor ?? navigationRailTheme.backgroundColor ?? theme.colorScheme.surface; float elevation = widget.elevation ?? navigationRailTheme.elevation ?? 0; float minWidth = widget.minWidth ?? material_._minRailWidth; float minExtendedWidth = widget.minExtendedWidth ?? material_._minExtendedRailWidth; Color baseSelectedColor = theme.colorScheme.primary; Color baseColor = theme.colorScheme.onSurface.withOpacity(0.64f); IconThemeData defaultUnselectedIconTheme = widget.unselectedIconTheme ?? navigationRailTheme.unselectedIconTheme; IconThemeData unselectedIconTheme = new IconThemeData( size: defaultUnselectedIconTheme?.size ?? 24.0f, color: defaultUnselectedIconTheme?.color ?? theme.colorScheme.onSurface, opacity: defaultUnselectedIconTheme?.opacity ?? 1.0f ); IconThemeData defaultSelectedIconTheme = widget.selectedIconTheme ?? navigationRailTheme.selectedIconTheme; IconThemeData selectedIconTheme = new IconThemeData( size: defaultSelectedIconTheme?.size ?? 24.0f, color: defaultSelectedIconTheme?.color ?? theme.colorScheme.primary, opacity: defaultSelectedIconTheme?.opacity ?? 0.64f ); TextStyle unselectedLabelTextStyle = theme.textTheme.bodyText1.copyWith(color: baseColor) .merge(widget.unselectedLabelTextStyle ?? navigationRailTheme.unselectedLabelTextStyle); TextStyle selectedLabelTextStyle = theme.textTheme.bodyText1.copyWith(color: baseSelectedColor) .merge(widget.selectedLabelTextStyle ?? navigationRailTheme.selectedLabelTextStyle); float groupAlignment = widget.groupAlignment ?? navigationRailTheme.groupAlignment ?? -1.0f; NavigationRailLabelType labelType = widget.labelType ?? navigationRailTheme.labelType ?? NavigationRailLabelType.none; var materialChildren = new List <Widget>(); materialChildren.Add(material_._verticalSpacer); if (widget.leading != null) { materialChildren.AddRange(new List <Widget>() { new ConstrainedBox( constraints: new BoxConstraints( minWidth: MathUtils.lerpNullableFloat(minWidth, minExtendedWidth, _extendedAnimation.value) ), child: widget.leading ), material_._verticalSpacer, }); } var alignChildren = new List <Widget>(); for (int i = 0; i < widget.destinations.Count; i += 1) { alignChildren.Add(new _RailDestination( minWidth: minWidth, minExtendedWidth: minExtendedWidth, extendedTransitionAnimation: _extendedAnimation, selected: widget.selectedIndex == i, icon: widget.selectedIndex == i ? widget.destinations[i].selectedIcon : widget.destinations[i].icon, label: widget.destinations[i].label, destinationAnimation: _destinationAnimations[i], labelType: labelType, iconTheme: widget.selectedIndex == i ? selectedIconTheme : unselectedIconTheme, labelTextStyle: widget.selectedIndex == i ? selectedLabelTextStyle : unselectedLabelTextStyle, onTap: () => { widget.onDestinationSelected(i); }, indexLabel: localizations.tabLabel( tabIndex: i + 1, tabCount: widget.destinations.Count ) )); } if (widget.trailing != null) { alignChildren.Add(new ConstrainedBox( constraints: new BoxConstraints( minWidth: MathUtils.lerpNullableFloat(minWidth, minExtendedWidth, _extendedAnimation.value) ), child: widget.trailing )); } materialChildren.Add(new Expanded( child: new Align( alignment: new Alignment(0, groupAlignment), child: new Column( mainAxisSize: MainAxisSize.min, children: alignChildren ) ) )); return(new _ExtendedNavigationRailAnimation( animation: _extendedAnimation, child: new Material( elevation: elevation, color: backgroundColor, child: new Column( children: materialChildren ) ) )); }
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 )); }
public override Widget build(BuildContext context) { D.assert(MaterialD.debugCheckHasMaterialLocalizations(context)); MaterialLocalizations localizations = MaterialLocalizations.of(context); _DropdownRoute <T> route = this.widget.route; float unit = 0.5f / (route.items.Count + 1.5f); List <Widget> children = new List <Widget>(); for (int itemIndex = 0; itemIndex < route.items.Count; ++itemIndex) { CurvedAnimation opacity; if (itemIndex == route.selectedIndex) { opacity = new CurvedAnimation(parent: route.animation, curve: new Threshold(0.0f)); } else { float start = (0.5f + (itemIndex + 1) * unit).clamp(0.0f, 1.0f); float end = (start + 1.5f * unit).clamp(0.0f, 1.0f); opacity = new CurvedAnimation(parent: route.animation, curve: new Interval(start, end)); } var index = itemIndex; children.Add(new FadeTransition( opacity: opacity, child: new InkWell( child: new Container( padding: this.widget.padding, child: route.items[itemIndex] ), onTap: () => Navigator.pop( context, new _DropdownRouteResult <T>(route.items[index].value) ) ) )); } return(new FadeTransition( opacity: this._fadeOpacity, child: new CustomPaint( painter: new _DropdownMenuPainter( color: Theme.of(context).canvasColor, elevation: route.elevation, selectedIndex: route.selectedIndex, resize: this._resize ), child: new Material( type: MaterialType.transparency, textStyle: route.style, child: new ScrollConfiguration( behavior: new _DropdownScrollBehavior(), child: new Scrollbar( child: new ListView( controller: this.widget.route.scrollController, padding: Constants.kMaterialListPadding, itemExtent: DropdownConstants._kMenuItemHeight, shrinkWrap: true, children: children ) ) ) ) ) )); }
public override void didChangeDependencies() { base.didChangeDependencies(); this.localizations = MaterialLocalizations.of(this.context); }
List <Widget> _createTiles() { MaterialLocalizations localizations = MaterialLocalizations.of(this.context); D.assert(localizations != null); ThemeData themeData = Theme.of(this.context); Color themeColor; switch (themeData.brightness) { case Brightness.light: themeColor = themeData.primaryColor; break; case Brightness.dark: themeColor = themeData.accentColor; break; default: throw new Exception("Unknown brightness: " + themeData.brightness); } ColorTween colorTween; switch (this.widget.type) { case BottomNavigationBarType.fix: colorTween = new ColorTween( begin: this.widget.unselectedItemColor ?? themeData.textTheme.caption.color, end: this.widget.selectedItemColor ?? this.widget.fixedColor ?? themeColor ); break; case BottomNavigationBarType.shifting: colorTween = new ColorTween( begin: this.widget.unselectedItemColor ?? Colors.white, end: this.widget.selectedItemColor ?? Colors.white ); break; default: throw new UIWidgetsError($"Unknown bottom navigation bar type: {this.widget.type}"); } List <Widget> tiles = new List <Widget>(); for (int i = 0; i < this.widget.items.Count; i++) { int index = i; tiles.Add(new _BottomNavigationTile( this.widget.type, this.widget.items[i], this._animations[i], this.widget.iconSize, selectedFontSize: this.widget.selectedFontSize, unselectedFontSize: this.widget.unselectedFontSize, onTap: () => { if (this.widget.onTap != null) { this.widget.onTap(index); } }, colorTween: colorTween, flex: this._evaluateFlex(this._animations[i]), selected: i == this.widget.currentIndex, showSelectedLabels: this.widget.showSelectedLabels, showUnselectedLabels: this.widget.showUnselectedLabels, indexLabel: localizations.tabLabel(tabIndex: i + 1, tabCount: this.widget.items.Count) )); } return(tiles); }
public override Widget build(BuildContext context) { MaterialLocalizations localizations = MaterialLocalizations.of(context); ThemeData themeData = Theme.of(context); TextTheme headerTextTheme = themeData.primaryTextTheme; Color dayColor = null; Color yearColor = null; switch (themeData.primaryColorBrightness) { case Brightness.light: dayColor = this.mode == DatePickerMode.day ? Colors.black87 : Colors.black54; yearColor = this.mode == DatePickerMode.year ? Colors.black87 : Colors.black54; break; case Brightness.dark: dayColor = this.mode == DatePickerMode.day ? Colors.white : Colors.white70; yearColor = this.mode == DatePickerMode.year ? Colors.white : Colors.white70; break; } TextStyle dayStyle = headerTextTheme.display1.copyWith(color: dayColor, height: 1.4f); TextStyle yearStyle = headerTextTheme.subhead.copyWith(color: yearColor, height: 1.4f); Color backgroundColor = null; switch (themeData.brightness) { case Brightness.light: backgroundColor = themeData.primaryColor; break; case Brightness.dark: backgroundColor = themeData.backgroundColor; break; } float width = 0f; float height = 0f; EdgeInsets padding = null; MainAxisAlignment mainAxisAlignment = MainAxisAlignment.center; switch (this.orientation) { case Orientation.portrait: height = DatePickerUtils._kDatePickerHeaderPortraitHeight; padding = EdgeInsets.symmetric(horizontal: 16.0f); mainAxisAlignment = MainAxisAlignment.center; break; case Orientation.landscape: width = DatePickerUtils._kDatePickerHeaderLandscapeWidth; padding = EdgeInsets.all(8.0f); mainAxisAlignment = MainAxisAlignment.start; break; } Widget yearButton = new IgnorePointer( ignoring: this.mode != DatePickerMode.day, child: new _DateHeaderButton( color: backgroundColor, onTap: Feedback.wrapForTap(() => this._handleChangeMode(DatePickerMode.year), context), child: new Text(localizations.formatYear(this.selectedDate), style: yearStyle) ) ); Widget dayButton = new IgnorePointer( ignoring: this.mode == DatePickerMode.day, child: new _DateHeaderButton( color: backgroundColor, onTap: Feedback.wrapForTap(() => this._handleChangeMode(DatePickerMode.day), context), child: new Text(localizations.formatMediumDate(this.selectedDate), style: dayStyle) ) ); return(new Container( width: width, height: height, padding: padding, color: backgroundColor, child: new Column( mainAxisAlignment: mainAxisAlignment, crossAxisAlignment: CrossAxisAlignment.start, children: new List <Widget> { yearButton, dayButton } ) )); }
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) ) ) } ) )); }
DateTime?_parseDate(string text) { MaterialLocalizations localizations = MaterialLocalizations.of(context); return(localizations.parseCompactDate(text)); }
public override Widget build(BuildContext context) { D.assert(MaterialD.debugCheckHasMaterialLocalizations(context)); ThemeData themeData = Theme.of(context); ScaffoldState scaffold = Scaffold.of(context, nullOk: true); ModalRoute parentRoute = ModalRoute.of(context); bool hasDrawer = scaffold?.hasDrawer ?? false; bool hasEndDrawer = scaffold?.hasEndDrawer ?? false; bool canPop = parentRoute?.canPop ?? false; bool useCloseButton = parentRoute is PageRoute && ((PageRoute)parentRoute).fullscreenDialog; IconThemeData appBarIconTheme = this.widget.iconTheme ?? themeData.primaryIconTheme; TextStyle centerStyle = this.widget.textTheme?.title ?? themeData.primaryTextTheme.title; TextStyle sideStyle = this.widget.textTheme?.body1 ?? themeData.primaryTextTheme.body1; if (this.widget.toolbarOpacity != 1.0f) { float opacity = new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget.toolbarOpacity); if (centerStyle?.color != null) { centerStyle = centerStyle.copyWith(color: centerStyle.color.withOpacity(opacity)); } if (sideStyle?.color != null) { sideStyle = sideStyle.copyWith(color: sideStyle.color.withOpacity(opacity)); } appBarIconTheme = appBarIconTheme.copyWith( opacity: opacity * (appBarIconTheme.opacity ?? 1.0f) ); } Widget leading = this.widget.leading; if (leading == null && this.widget.automaticallyImplyLeading) { if (hasDrawer) { leading = new IconButton( icon: new Icon(Icons.menu), onPressed: this._handleDrawerButton, tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip); } else { if (canPop) { leading = useCloseButton ? (Widget) new CloseButton() : new BackButton(); } } } if (leading != null) { leading = new ConstrainedBox( constraints: BoxConstraints.tightFor(width: AppBarUtils._kLeadingWidth), child: leading); } Widget title = this.widget.title; if (title != null) { title = new DefaultTextStyle( style: centerStyle, softWrap: false, overflow: TextOverflow.ellipsis, child: title); } Widget actions = null; if (this.widget.actions != null && this.widget.actions.isNotEmpty()) { actions = new Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: this.widget.actions); } else if (hasEndDrawer) { actions = new IconButton( icon: new Icon(Icons.menu), onPressed: this._handleDrawerButtonEnd, tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip); } Widget toolbar = new NavigationToolbar( leading: leading, middle: title, trailing: actions, centerMiddle: this.widget._getEffectiveCenterTitle(themeData).Value, middleSpacing: this.widget.titleSpacing); Widget appBar = new ClipRect( child: new CustomSingleChildLayout( layoutDelegate: new _ToolbarContainerLayout(), child: IconTheme.merge( data: appBarIconTheme, child: new DefaultTextStyle( style: sideStyle, child: toolbar) ) ) ); if (this.widget.bottom != null) { appBar = new Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { new Flexible( child: new ConstrainedBox( constraints: new BoxConstraints(maxHeight: Constants.kToolbarHeight), child: appBar ) ), this.widget.bottomOpacity == 1.0f ? (Widget)this.widget.bottom : new Opacity( opacity: new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget .bottomOpacity), child: this.widget.bottom ) } ); } if (this.widget.primary) { appBar = new SafeArea( top: true, child: appBar); } appBar = new Align( alignment: Alignment.topCenter, child: appBar); if (this.widget.flexibleSpace != null) { appBar = new Stack( fit: StackFit.passthrough, children: new List <Widget> { this.widget.flexibleSpace, appBar } ); } Brightness brightness = this.widget.brightness ?? themeData.primaryColorBrightness; SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark; return(new AnnotatedRegion <SystemUiOverlayStyle>( value: overlayStyle, child: new Material( color: this.widget.backgroundColor ?? themeData.primaryColor, elevation: this.widget.elevation, child: appBar ))); }
InputDecoration _getEffectiveDecoration() { MaterialLocalizations localizations = MaterialLocalizations.of(this.context); ThemeData themeData = Theme.of(this.context); InputDecoration effectiveDecoration = (this.widget.decoration ?? new InputDecoration()) .applyDefaults(themeData.inputDecorationTheme) .copyWith( enabled: this.widget.enabled, hintMaxLines: this.widget.decoration?.hintMaxLines ?? this.widget.maxLines ); if (effectiveDecoration.counter != null || effectiveDecoration.counterText != null) { return(effectiveDecoration); } Widget counter; int currentLength = this._effectiveController.value.text.Length; if (effectiveDecoration.counter == null && effectiveDecoration.counterText == null && this.widget.buildCounter != null) { bool isFocused = this._effectiveFocusNode.hasFocus; counter = this.widget.buildCounter( this.context, currentLength: currentLength, maxLength: this.widget.maxLength, isFocused: isFocused ); return(effectiveDecoration.copyWith(counter: counter)); } if (this.widget.maxLength == null) { return(effectiveDecoration); } string counterText = $"{currentLength}"; if (this.widget.maxLength > 0) { counterText += $"/{this.widget.maxLength}"; if (this._effectiveController.value.text.Length > this.widget.maxLength) { return(effectiveDecoration.copyWith( errorText: effectiveDecoration.errorText ?? "", counterStyle: effectiveDecoration.errorStyle ?? themeData.textTheme.caption.copyWith(color: themeData.errorColor), counterText: counterText )); } } // Handle length exceeds maxLength return(effectiveDecoration.copyWith( counterText: counterText )); }
List <Widget> _createTiles() { MaterialLocalizations localizations = MaterialLocalizations.of(this.context); D.assert(localizations != null); List <Widget> children = new List <Widget> { }; switch (this.widget.type) { case BottomNavigationBarType.fix: ThemeData themeData = Theme.of(this.context); TextTheme textTheme = themeData.textTheme; Color themeColor; switch (themeData.brightness) { case Brightness.light: themeColor = themeData.primaryColor; break; case Brightness.dark: themeColor = themeData.accentColor; break; default: throw new Exception("Unknown brightness: " + themeData.brightness); } ColorTween colorTween = new ColorTween( begin: textTheme.caption.color, end: this.widget.fixedColor ?? themeColor ); for (int i = 0; i < this.widget.items.Count; i += 1) { int index = i; children.Add( new _BottomNavigationTile(this.widget.type, this.widget.items[i], this._animations[i], this.widget.iconSize, onTap: () => { if (this.widget.onTap != null) { this.widget.onTap(index); } }, colorTween: colorTween, selected: i == this.widget.currentIndex, indexLabel: localizations.tabLabel(tabIndex: i + 1, tabCount: this.widget.items.Count) ) ); } break; case BottomNavigationBarType.shifting: for (int i = 0; i < this.widget.items.Count; i += 1) { int index = i; children.Add( new _BottomNavigationTile(this.widget.type, this.widget.items[i], this._animations[i], this.widget.iconSize, onTap: () => { if (this.widget.onTap != null) { this.widget.onTap(index); } }, flex: this._evaluateFlex(this._animations[i]), selected: i == this.widget.currentIndex, indexLabel: localizations.tabLabel(tabIndex: i + 1, tabCount: this.widget.items.Count) ) ); } break; } return(children); }
public override Widget build(BuildContext context) { D.assert(WidgetsD.debugCheckHasDirectionality(context)); D.assert(MaterialD.debugCheckHasMaterialLocalizations(context)); D.assert(MaterialD.debugCheckHasMaterialLocalizations(context)); ThemeData theme = Theme.of(context); List <Widget> children = new List <Widget> { }; if (this.widget.accountName != null) { Widget accountNameLine = new LayoutId( id: _AccountDetailsLayout.accountName, child: new Padding( padding: EdgeInsets.symmetric(vertical: 2.0f), child: new DefaultTextStyle( style: theme.primaryTextTheme.body2, overflow: TextOverflow.ellipsis, child: this.widget.accountName ) ) ); children.Add(accountNameLine); } if (this.widget.accountEmail != null) { Widget accountEmailLine = new LayoutId( id: _AccountDetailsLayout.accountEmail, child: new Padding( padding: EdgeInsets.symmetric(vertical: 2.0f), child: new DefaultTextStyle( style: theme.primaryTextTheme.body1, overflow: TextOverflow.ellipsis, child: this.widget.accountEmail ) ) ); children.Add(accountEmailLine); } if (this.widget.onTap != null) { MaterialLocalizations localizations = MaterialLocalizations.of(context); Widget dropDownIcon = new LayoutId( id: _AccountDetailsLayout.dropdownIcon, child: new SizedBox( height: UserAccountsDrawerHeaderUtils._kAccountDetailsHeight, width: UserAccountsDrawerHeaderUtils._kAccountDetailsHeight, child: new Center( child: Transform.rotate( degree: this._animation.value * Mathf.PI, child: new Icon( Icons.arrow_drop_down, color: Colors.white ) ) ) ) ); children.Add(dropDownIcon); } Widget accountDetails = new CustomMultiChildLayout( layoutDelegate: new _AccountDetailsLayout(), children: children ); if (this.widget.onTap != null) { accountDetails = new InkWell( onTap: this.widget.onTap == null ? (GestureTapCallback)null : () => { this.widget.onTap(); }, child: accountDetails ); } return(new SizedBox( height: UserAccountsDrawerHeaderUtils._kAccountDetailsHeight, child: accountDetails )); }
public override Widget build(BuildContext context) { ColorScheme colorScheme = Theme.of(context).colorScheme; MaterialLocalizations localizations = MaterialLocalizations.of(context); TextTheme textTheme = Theme.of(context).textTheme; TextStyle dayStyle = textTheme.caption; Color enabledDayColor = colorScheme.onSurface.withOpacity(0.87f); Color disabledDayColor = colorScheme.onSurface.withOpacity(0.38f); Color selectedDayColor = colorScheme.onPrimary; Color selectedDayBackground = colorScheme.primary; Color todayColor = colorScheme.primary; int year = displayedMonth.Year; int month = displayedMonth.Month; int daysInMonth = utils.getDaysInMonth(year, month); int dayOffset = utils.firstDayOffset(year, month, localizations); List <Widget> dayItems = new List <Widget>(); // 1-based day of month, e.g. 1-31 for January, and 1-29 for February on // a leap year. int day = -dayOffset; while (day < daysInMonth) { day++; if (day < 1) { dayItems.Add(new Container()); } else { DateTime dayToBuild = new DateTime(year, month, day); bool isDisabled = dayToBuild > lastDate || dayToBuild < firstDate || (selectableDayPredicate != null && !selectableDayPredicate(dayToBuild)); BoxDecoration decoration = null; Color dayColor = enabledDayColor; bool isSelectedDay = utils.isSameDay(selectedDate, dayToBuild); if (isSelectedDay) { // The selected day gets a circle background highlight, and a // contrasting text color. dayColor = selectedDayColor; decoration = new BoxDecoration( color: selectedDayBackground, shape: BoxShape.circle ); } else if (isDisabled) { dayColor = disabledDayColor; } else if (utils.isSameDay(currentDate, dayToBuild)) { // The current day gets a different text color and a circle stroke // border. dayColor = todayColor; decoration = new BoxDecoration( border: Border.all(color: todayColor, width: 1), shape: BoxShape.circle ); } Widget dayWidget = new Container( decoration: decoration, child: new Center( child: new Text(localizations.formatDecimal(day), style: dayStyle.apply(color: dayColor)) ) ); if (!isDisabled) { dayWidget = new GestureDetector( behavior: HitTestBehavior.opaque, onTap: () => onChanged(dayToBuild), child: dayWidget ); } dayItems.Add(dayWidget); } } return(new Padding( padding: EdgeInsets.symmetric( horizontal: material_._monthPickerHorizontalPadding ), child: GridView.custom( physics: new ClampingScrollPhysics(), gridDelegate: material_._dayPickerGridDelegate, childrenDelegate: new SliverChildListDelegate( dayItems, addRepaintBoundaries: false ) ) )); }
public override void didChangeDependencies() { base.didChangeDependencies(); _localizations = MaterialLocalizations.of(context); _textDirection = Directionality.of(context); }
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) { material_.debugCheckHasMaterialLocalizations(context); ThemeData theme = widget.del.appBarTheme(context); string searchFieldLabel = widget.del.searchFieldLabel ?? MaterialLocalizations.of(context).searchFieldLabel; Widget body = null; switch (widget.del._currentBody) { case _SearchBody.suggestions: body = new KeyedSubtree( key: new ValueKey <_SearchBody>(_SearchBody.suggestions), child: widget.del.buildSuggestions(context) ); break; case _SearchBody.results: body = new KeyedSubtree( key: new ValueKey <_SearchBody>(_SearchBody.results), child: widget.del.buildResults(context) ); break; } string routeName; switch (Theme.of(this.context).platform) { case RuntimePlatform.IPhonePlayer: case RuntimePlatform.OSXEditor: case RuntimePlatform.OSXPlayer: routeName = ""; break; case RuntimePlatform.Android: routeName = searchFieldLabel; break; } return(new Scaffold( appBar: new AppBar( backgroundColor: theme.primaryColor, iconTheme: theme.primaryIconTheme, textTheme: theme.primaryTextTheme, brightness: theme.primaryColorBrightness, leading: widget.del.buildLeading(context), title: new TextField( controller: widget.del._queryTextController, focusNode: focusNode, style: theme.textTheme.headline6, textInputAction: widget.del.textInputAction, keyboardType: widget.del.keyboardType, onSubmitted: (string _) => { widget.del.showResults(context); }, decoration: new InputDecoration( border: InputBorder.none, hintText: searchFieldLabel, hintStyle: theme.inputDecorationTheme.hintStyle ) ), actions: widget.del.buildActions(context) ), body: new AnimatedSwitcher( duration: new TimeSpan(0, 0, 0, 0, 300), child: body ) )); }