public TextField(Key key = null, TextEditingController controller = null, FocusNode focusNode = null, InputDecoration decoration = null, bool noDecoration = false, TextInputType keyboardType = null, TextInputAction?textInputAction = null, TextCapitalization textCapitalization = TextCapitalization.none, TextStyle style = null, StrutStyle strutStyle = null, TextAlign textAlign = TextAlign.left, TextAlignVertical textAlignVertical = null, TextDirection textDirection = TextDirection.ltr, bool readOnly = false, ToolbarOptions toolbarOptions = null, bool?showCursor = null, bool autofocus = false, bool obscureText = false, bool autocorrect = false, SmartDashesType?smartDashesType = null, SmartQuotesType?smartQuotesType = null, bool enableSuggestions = true, int?maxLines = 1, int?minLines = null, bool expands = false, int?maxLength = null, bool maxLengthEnforced = true, ValueChanged <string> onChanged = null, VoidCallback onEditingComplete = null, ValueChanged <string> onSubmitted = null, List <TextInputFormatter> inputFormatters = null, bool?enabled = null, float?cursorWidth = 2.0f, Radius cursorRadius = null, Color cursorColor = null, BoxHeightStyle selectionHeightStyle = BoxHeightStyle.tight, BoxWidthStyle selectionWidthStyle = BoxWidthStyle.tight, Brightness?keyboardAppearance = null, EdgeInsets scrollPadding = null, DragStartBehavior dragStartBehavior = DragStartBehavior.start, bool enableInteractiveSelection = true, GestureTapCallback onTap = null, InputCounterWidgetBuilder buildCounter = null, ScrollController scrollController = null, ScrollPhysics scrollPhysics = null ) : base(key: key) { D.assert(maxLines == null || maxLines > 0); D.assert(minLines == null || minLines > 0); D.assert((maxLines == null) || (minLines == null) || (maxLines >= minLines), () => "minLines can't be greater than maxLines"); D.assert(!expands || (maxLines == null && minLines == null), () => "minLines and maxLines must be null when expands is true."); D.assert(maxLength == null || maxLength == noMaxLength || maxLength > 0); D.assert(!obscureText || maxLines == 1, () => "Obscured fields cannot be multiline."); this.smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled); this.smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled); this.controller = controller; this.focusNode = focusNode; this.decoration = noDecoration ? null : (decoration ?? new InputDecoration()); this.textInputAction = textInputAction; this.textCapitalization = textCapitalization; this.style = style; this.strutStyle = strutStyle; this.textAlign = textAlign; this.textAlignVertical = textAlignVertical; this.textDirection = textDirection; this.readOnly = readOnly; this.showCursor = showCursor; this.autofocus = autofocus; this.obscureText = obscureText; this.autocorrect = autocorrect; this.enableSuggestions = enableSuggestions; this.maxLines = maxLines; this.minLines = minLines; this.expands = expands; this.maxLength = maxLength; this.maxLengthEnforced = maxLengthEnforced; this.onChanged = onChanged; this.onEditingComplete = onEditingComplete; this.onSubmitted = onSubmitted; this.inputFormatters = inputFormatters; this.enabled = enabled; this.cursorWidth = cursorWidth; this.cursorColor = cursorColor; this.selectionHeightStyle = selectionHeightStyle; this.selectionWidthStyle = selectionWidthStyle; this.cursorRadius = cursorRadius; this.onSubmitted = onSubmitted; this.keyboardAppearance = keyboardAppearance; this.enableInteractiveSelection = enableInteractiveSelection; this.onTap = onTap; this.keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline); this.toolbarOptions = toolbarOptions ?? (obscureText ? new ToolbarOptions( selectAll: true, paste: true ) : new ToolbarOptions( copy: true, cut: true, selectAll: true, paste: true )); this.scrollPadding = scrollPadding ?? EdgeInsets.all(20.0f); this.dragStartBehavior = dragStartBehavior; this.enableInteractiveSelection = enableInteractiveSelection; this.buildCounter = buildCounter; this.scrollPhysics = scrollPhysics; this.scrollController = scrollController; }
public RawMaterialButton( Key key = null, VoidCallback onPressed = null, GestureLongPressCallback onLongPress = null, ValueChanged <bool> onHighlightChanged = null, TextStyle textStyle = null, Color fillColor = null, Color focusColor = null, Color hoverColor = null, Color highlightColor = null, Color splashColor = null, float elevation = 2.0f, float focusElevation = 4.0f, float hoverElevation = 4.0f, float highlightElevation = 8.0f, float disabledElevation = 0.0f, EdgeInsetsGeometry padding = null, VisualDensity visualDensity = null, BoxConstraints constraints = null, ShapeBorder shape = null, TimeSpan?animationDuration = null, Clip clipBehavior = Clip.none, FocusNode focusNode = null, bool autofocus = false, MaterialTapTargetSize?materialTapTargetSize = null, Widget child = null, bool enableFeedback = true) : base(key: key) { D.assert(elevation >= 0.0f); D.assert(focusElevation >= 0.0f); D.assert(focusElevation >= 0.0f); D.assert(highlightElevation >= 0.0f); D.assert(disabledElevation >= 0.0f); MaterialTapTargetSize _materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded; shape = shape ?? new RoundedRectangleBorder(); visualDensity = visualDensity ?? new VisualDensity(); padding = padding ?? EdgeInsets.zero; constraints = constraints ?? new BoxConstraints(minWidth: 88.0f, minHeight: 36.0f); TimeSpan _animationDuration = animationDuration ?? material_.kThemeChangeDuration; this.onPressed = onPressed; this.onLongPress = onLongPress; this.onHighlightChanged = onHighlightChanged; this.textStyle = textStyle; this.fillColor = fillColor; this.focusColor = focusColor; this.hoverColor = hoverColor; this.highlightColor = highlightColor; this.splashColor = splashColor; this.elevation = elevation; this.focusElevation = focusElevation; this.hoverElevation = hoverElevation; this.highlightElevation = highlightElevation; this.disabledElevation = disabledElevation; this.padding = padding; this.visualDensity = visualDensity; this.constraints = constraints; this.shape = shape; this.animationDuration = _animationDuration; this.clipBehavior = clipBehavior; this.focusNode = focusNode; this.autofocus = autofocus; this.enableFeedback = enableFeedback; this.materialTapTargetSize = _materialTapTargetSize; this.child = child; }
public SliderThemeData( float?trackHeight = null, Color activeTrackColor = null, Color inactiveTrackColor = null, Color disabledActiveTrackColor = null, Color disabledInactiveTrackColor = null, Color activeTickMarkColor = null, Color inactiveTickMarkColor = null, Color disabledActiveTickMarkColor = null, Color disabledInactiveTickMarkColor = null, Color thumbColor = null, Color disabledThumbColor = null, Color overlayColor = null, Color valueIndicatorColor = null, SliderTrackShape trackShape = null, SliderTickMarkShape tickMarkShape = null, SliderComponentShape thumbShape = null, SliderComponentShape overlayShape = null, SliderComponentShape valueIndicatorShape = null, ShowValueIndicator?showValueIndicator = null, TextStyle valueIndicatorTextStyle = null ) { D.assert(trackHeight != null); D.assert(activeTrackColor != null); D.assert(inactiveTrackColor != null); D.assert(disabledActiveTrackColor != null); D.assert(disabledInactiveTrackColor != null); D.assert(activeTickMarkColor != null); D.assert(inactiveTickMarkColor != null); D.assert(disabledActiveTickMarkColor != null); D.assert(disabledInactiveTickMarkColor != null); D.assert(thumbColor != null); D.assert(disabledThumbColor != null); D.assert(overlayColor != null); D.assert(valueIndicatorColor != null); D.assert(trackShape != null); D.assert(tickMarkShape != null); D.assert(thumbShape != null); D.assert(overlayShape != null); D.assert(valueIndicatorShape != null); D.assert(valueIndicatorTextStyle != null); D.assert(showValueIndicator != null); this.trackHeight = trackHeight.Value; this.activeTrackColor = activeTrackColor; this.inactiveTrackColor = inactiveTrackColor; this.disabledActiveTrackColor = disabledActiveTrackColor; this.disabledInactiveTrackColor = disabledInactiveTrackColor; this.activeTickMarkColor = activeTickMarkColor; this.inactiveTickMarkColor = inactiveTickMarkColor; this.disabledActiveTickMarkColor = disabledActiveTickMarkColor; this.disabledInactiveTickMarkColor = disabledInactiveTickMarkColor; this.thumbColor = thumbColor; this.disabledThumbColor = disabledThumbColor; this.overlayColor = overlayColor; this.valueIndicatorColor = valueIndicatorColor; this.trackShape = trackShape; this.tickMarkShape = tickMarkShape; this.thumbShape = thumbShape; this.overlayShape = overlayShape; this.valueIndicatorShape = valueIndicatorShape; this.showValueIndicator = showValueIndicator.Value; this.valueIndicatorTextStyle = valueIndicatorTextStyle; }
public TextField(Key key = null, TextEditingController controller = null, FocusNode focusNode = null, InputDecoration decoration = null, bool noDecoration = false, TextInputType keyboardType = null, TextInputAction?textInputAction = null, TextCapitalization textCapitalization = TextCapitalization.none, TextStyle style = null, TextAlign textAlign = TextAlign.left, TextDirection textDirection = TextDirection.ltr, bool autofocus = false, bool obscureText = false, bool autocorrect = false, int?maxLines = 1, int?maxLength = null, bool maxLengthEnforced = true, ValueChanged <string> onChanged = null, VoidCallback onEditingComplete = null, ValueChanged <string> onSubmitted = null, List <TextInputFormatter> inputFormatters = null, bool?enabled = null, float?cursorWidth = 2.0f, Radius cursorRadius = null, Color cursorColor = null, Brightness?keyboardAppearance = null, EdgeInsets scrollPadding = null, DragStartBehavior dragStartBehavior = DragStartBehavior.down, bool?enableInteractiveSelection = null, GestureTapCallback onTap = null, InputCounterWidgetBuilder buildCounter = null ) : base(key: key) { D.assert(maxLines == null || maxLines > 0); D.assert(maxLength == null || maxLength == TextField.noMaxLength || maxLength > 0); this.controller = controller; this.focusNode = focusNode; this.decoration = noDecoration ? null : (decoration ?? new InputDecoration()); this.textInputAction = textInputAction; this.textCapitalization = textCapitalization; this.style = style; this.textAlign = textAlign; this.textDirection = textDirection; this.autofocus = autofocus; this.obscureText = obscureText; this.autocorrect = autocorrect; this.maxLines = maxLines; this.maxLength = maxLength; this.maxLengthEnforced = maxLengthEnforced; this.onChanged = onChanged; this.onEditingComplete = onEditingComplete; this.onSubmitted = onSubmitted; this.inputFormatters = inputFormatters; this.enabled = enabled; this.cursorWidth = cursorWidth; this.cursorColor = cursorColor; this.cursorRadius = cursorRadius; this.onSubmitted = onSubmitted; this.keyboardAppearance = keyboardAppearance; this.enableInteractiveSelection = enableInteractiveSelection; this.onTap = onTap; this.keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline); this.scrollPadding = scrollPadding ?? EdgeInsets.all(20.0f); this.dragStartBehavior = dragStartBehavior; this.buildCounter = buildCounter; }
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) { FlexibleSpaceBarSettings settings = (FlexibleSpaceBarSettings)context.inheritFromWidgetOfExactType(typeof(FlexibleSpaceBarSettings)); D.assert(settings != null, "A FlexibleSpaceBar must be wrapped in the widget returned by FlexibleSpaceBar.createSettings()."); List <Widget> children = new List <Widget>(); float deltaExtent = settings.maxExtent.Value - settings.minExtent.Value; float t = (1.0f - (settings.currentExtent.Value - settings.minExtent.Value) / deltaExtent) .clamp(0.0f, 1.0f); if (this.widget.background != null) { float fadeStart = Mathf.Max(0.0f, 1.0f - Constants.kToolbarHeight / deltaExtent); float fadeEnd = 1.0f; D.assert(fadeStart <= fadeEnd); float opacity = 1.0f - new Interval(fadeStart, fadeEnd).transform(t); if (opacity > 0.0f) { children.Add(new Positioned( top: this._getCollapsePadding(t, settings), left: 0.0f, right: 0.0f, height: settings.maxExtent, child: new Opacity( opacity: opacity, child: this.widget.background) ) ); } } Widget title = null; if (this.widget.title != null) { switch (Application.platform) { case RuntimePlatform.IPhonePlayer: title = this.widget.title; break; default: title = this.widget.title; break; } } ThemeData theme = Theme.of(context); float toolbarOpacity = settings.toolbarOpacity.Value; if (toolbarOpacity > 0.0f) { TextStyle titleStyle = theme.primaryTextTheme.title; titleStyle = titleStyle.copyWith( color: titleStyle.color.withOpacity(toolbarOpacity)); bool effectiveCenterTitle = this._getEffectiveCenterTitle(theme).Value; float scaleValue = new FloatTween(begin: 1.5f, end: 1.0f).lerp(t); Matrix3 scaleTransform = Matrix3.makeScale(scaleValue, scaleValue); Alignment titleAlignment = this._getTitleAlignment(effectiveCenterTitle); children.Add(new Container( padding: EdgeInsets.fromLTRB( effectiveCenterTitle ? 0.0f : 72.0f, 0f, 0f, 16.0f), child: new Transform( alignment: titleAlignment, transform: scaleTransform, child: new Align( alignment: titleAlignment, child: new DefaultTextStyle( style: titleStyle, child: title) ) ) ) ); } return(new ClipRect( child: new Stack( children: children) )); }
Widget build(BuildContext context) { base.build(context); D.assert(() => { return(_controller._textSpan.visitChildren((InlineSpan span) => span is TextSpan)); }, () => "SelectableText only supports TextSpan; Other type of InlineSpan is not allowed"); D.assert(WidgetsD.debugCheckHasMediaQuery(context)); D.assert(WidgetsD.debugCheckHasDirectionality(context)); D.assert( !(widget.style != null && widget.style.inherit == false && (widget.style.fontSize == null || widget.style.textBaseline == null)), () => "inherit false style must supply fontSize and textBaseline" ); ThemeData themeData = Theme.of(context); FocusNode focusNode = _effectiveFocusNode; TextSelectionControls textSelectionControls; bool paintCursorAboveText; bool cursorOpacityAnimates; Offset cursorOffset = Offset.zero; Color cursorColor = widget.cursorColor; Radius cursorRadius = widget.cursorRadius; switch (themeData.platform) { case RuntimePlatform.IPhonePlayer: case RuntimePlatform.OSXEditor: case RuntimePlatform.OSXPlayer: forcePressEnabled = true; textSelectionControls = CupertinoTextFieldUtils.cupertinoTextSelectionControls; paintCursorAboveText = true; cursorOpacityAnimates = true; cursorColor = cursorColor ?? CupertinoTheme.of(context).primaryColor; cursorRadius = cursorRadius ?? Radius.circular(2.0f); cursorOffset = new Offset(SelectableTextUtils.iOSHorizontalOffset / MediaQuery.of(context).devicePixelRatio, 0); break; default: forcePressEnabled = false; textSelectionControls = _MaterialTextSelectionControls.materialTextSelectionControls; paintCursorAboveText = false; cursorOpacityAnimates = false; cursorColor = cursorColor ?? themeData.cursorColor; break; } DefaultTextStyle defaultTextStyle = DefaultTextStyle.of(context); TextStyle effectiveTextStyle = widget.style; if (widget.style == null || widget.style.inherit) { effectiveTextStyle = defaultTextStyle.style.merge(widget.style); } if (MediaQuery.boldTextOverride(context)) { effectiveTextStyle = effectiveTextStyle.merge(new TextStyle(fontWeight: FontWeight.bold)); } Widget child = new RepaintBoundary( child: new EditableText( key: editableTextKey, style: effectiveTextStyle, readOnly: true, textWidthBasis: widget.textWidthBasis ?? defaultTextStyle.textWidthBasis, showSelectionHandles: _showSelectionHandles, showCursor: widget.showCursor, controller: _controller, focusNode: focusNode, strutStyle: widget.strutStyle ?? new StrutStyle(), textAlign: widget.textAlign ?? defaultTextStyle.textAlign ?? TextAlign.start, textDirection: widget.textDirection, textScaleFactor: widget.textScaleFactor, autofocus: widget.autofocus, forceLine: false, toolbarOptions: widget.toolbarOptions, minLines: widget.minLines, maxLines: widget.maxLines ?? defaultTextStyle.maxLines, selectionColor: themeData.textSelectionColor, selectionControls: widget.selectionEnabled ? textSelectionControls : null, onSelectionChanged: _handleSelectionChanged, onSelectionHandleTapped: _handleSelectionHandleTapped, rendererIgnoresPointer: true, cursorWidth: widget.cursorWidth, cursorRadius: cursorRadius, cursorColor: cursorColor, cursorOpacityAnimates: cursorOpacityAnimates, cursorOffset: cursorOffset, paintCursorAboveText: paintCursorAboveText, backgroundCursorColor: CupertinoColors.inactiveGray, enableInteractiveSelection: widget.enableInteractiveSelection, dragStartBehavior: widget.dragStartBehavior, scrollPhysics: widget.scrollPhysics ) ); return(_selectionGestureDetectorBuilder.buildGestureDetector( behavior: HitTestBehavior.translucent, child: child )); }
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) ) ) } ) )); }
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 EditableText(TextEditingController controller, FocusNode focusNode, TextStyle style, Color cursorColor, bool obscureText = false, bool autocorrect = false, TextAlign textAlign = TextAlign.left, TextDirection?textDirection = null, float?textScaleFactor = null, int?maxLines = 1, bool autofocus = false, Color selectionColor = null, TextSelectionControls selectionControls = null, TextInputType keyboardType = null, TextInputAction?textInputAction = null, TextCapitalization textCapitalization = TextCapitalization.none, ValueChanged <string> onChanged = null, VoidCallback onEditingComplete = null, ValueChanged <string> onSubmitted = null, SelectionChangedCallback onSelectionChanged = null, List <TextInputFormatter> inputFormatters = null, bool rendererIgnoresPointer = false, EdgeInsets scrollPadding = null, bool unityTouchKeyboard = false, Key key = null, float?cursorWidth = 2.0f, Radius cursorRadius = null, Brightness?keyboardAppearance = Brightness.light, bool enableInteractiveSelection = true ) : base(key) { D.assert(controller != null); D.assert(focusNode != null); D.assert(style != null); D.assert(cursorColor != null); D.assert(maxLines == null || maxLines > 0); this.keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline); this.scrollPadding = scrollPadding ?? EdgeInsets.all(20.0f); this.controller = controller; this.focusNode = focusNode; this.obscureText = obscureText; this.autocorrect = autocorrect; this.style = style; this.textAlign = textAlign; this.textDirection = textDirection; this.textScaleFactor = textScaleFactor; this.textInputAction = textInputAction; this.textCapitalization = textCapitalization; this.cursorColor = cursorColor; this.maxLines = maxLines; this.autofocus = autofocus; this.selectionColor = selectionColor; this.onChanged = onChanged; this.onSubmitted = onSubmitted; this.onSelectionChanged = onSelectionChanged; this.onEditingComplete = onEditingComplete; this.rendererIgnoresPointer = rendererIgnoresPointer; this.selectionControls = selectionControls; this.unityTouchKeyboard = unityTouchKeyboard; if (maxLines == 1) { this.inputFormatters = new List <TextInputFormatter>(); this.inputFormatters.Add(BlacklistingTextInputFormatter.singleLineFormatter); if (inputFormatters != null) { this.inputFormatters.AddRange(inputFormatters); } } else { this.inputFormatters = inputFormatters; } this.cursorWidth = cursorWidth; this.cursorRadius = cursorRadius; this.keyboardAppearance = keyboardAppearance; this.enableInteractiveSelection = enableInteractiveSelection; }
public TextFormField( Key key = null, TextEditingController controller = null, string initialValue = null, FocusNode focusNode = null, InputDecoration decoration = null, TextInputType keyboardType = null, TextCapitalization textCapitalization = TextCapitalization.none, TextInputAction?textInputAction = null, TextStyle style = null, StrutStyle strutStyle = null, TextDirection?textDirection = null, TextAlign textAlign = TextAlign.left, bool autofocus = false, bool obscureText = false, bool autocorrect = true, bool autovalidate = false, bool maxLengthEnforced = true, int?maxLines = 1, int?minLines = null, bool expands = false, int?maxLength = null, VoidCallback onEditingComplete = null, ValueChanged <string> onFieldSubmitted = null, FormFieldSetter <string> onSaved = null, FormFieldValidator <string> validator = null, List <TextInputFormatter> inputFormatters = null, bool enabled = true, float cursorWidth = 2.0f, Radius cursorRadius = null, Color cursorColor = null, Brightness?keyboardAppearance = null, EdgeInsets scrollPadding = null, bool enableInteractiveSelection = true, InputCounterWidgetBuilder buildCounter = null ) : base( key: key, initialValue: controller != null ? controller.text : (initialValue ?? ""), onSaved: onSaved, validator: validator, autovalidate: autovalidate, enabled: enabled, builder: (FormFieldState <string> field) => { _TextFormFieldState state = (_TextFormFieldState)field; InputDecoration effectiveDecoration = (decoration ?? new InputDecoration()) .applyDefaults(Theme.of(field.context).inputDecorationTheme); return(new TextField( controller: state._effectiveController, focusNode: focusNode, decoration: effectiveDecoration.copyWith(errorText: field.errorText), keyboardType: keyboardType, textInputAction: textInputAction, style: style, strutStyle: strutStyle, textAlign: textAlign, textDirection: textDirection ?? TextDirection.ltr, textCapitalization: textCapitalization, autofocus: autofocus, obscureText: obscureText, autocorrect: autocorrect, maxLengthEnforced: maxLengthEnforced, maxLines: maxLines, minLines: minLines, expands: expands, maxLength: maxLength, onChanged: field.didChange, onEditingComplete: onEditingComplete, onSubmitted: onFieldSubmitted, inputFormatters: inputFormatters, enabled: enabled, cursorWidth: cursorWidth, cursorRadius: cursorRadius, cursorColor: cursorColor, scrollPadding: scrollPadding ?? EdgeInsets.all(20.0f), keyboardAppearance: keyboardAppearance, enableInteractiveSelection: enableInteractiveSelection, buildCounter: buildCounter )); } ) { D.assert(initialValue == null || controller == null); D.assert(maxLines > 0); D.assert(maxLines == null || maxLines > 0); D.assert(minLines == null || minLines > 0); D.assert((maxLines == null) || (minLines == null) || (maxLines >= minLines), () => "minLines can't be greater than maxLines"); D.assert(!expands || (maxLines == null && minLines == null), () => "minLines and maxLines must be null when expands is true."); D.assert(maxLength == null || maxLength > 0); this.controller = controller; }
public override Widget build(BuildContext context) { base.build(context); TextEditingController controller = this._effectiveController; List <TextInputFormatter> formatters = this.widget.inputFormatters ?? new List <TextInputFormatter>(); bool enabled = this.widget.enabled ?? true; Offset cursorOffset = new Offset( CupertinoTextFieldUtils._iOSHorizontalCursorOffsetPixels / MediaQuery.of(context).devicePixelRatio, 0); if (this.widget.maxLength != null && this.widget.maxLengthEnforced) { formatters.Add(new LengthLimitingTextInputFormatter(this.widget.maxLength)); } CupertinoThemeData themeData = CupertinoTheme.of(context); TextStyle textStyle = themeData.textTheme.textStyle.merge(this.widget.style); TextStyle placeholderStyle = textStyle.merge(this.widget.placeholderStyle); Brightness keyboardAppearance = this.widget.keyboardAppearance ?? themeData.brightness; Color cursorColor = this.widget.cursorColor ?? themeData.primaryColor; Widget paddedEditable = new Padding( padding: this.widget.padding, child: new RepaintBoundary( child: new EditableText( key: this._editableTextKey, controller: controller, focusNode: this._effectiveFocusNode, keyboardType: this.widget.keyboardType, textInputAction: this.widget.textInputAction, textCapitalization: this.widget.textCapitalization, style: textStyle, strutStyle: this.widget.strutStyle, textAlign: this.widget.textAlign, autofocus: this.widget.autofocus, obscureText: this.widget.obscureText, autocorrect: this.widget.autocorrect, maxLines: this.widget.maxLines, minLines: this.widget.minLines, expands: this.widget.expands, selectionColor: CupertinoTextFieldUtils._kSelectionHighlightColor, selectionControls: CupertinoTextSelectionUtils.cupertinoTextSelectionControls, onChanged: this.widget.onChanged, onSelectionChanged: this._handleSelectionChanged, onEditingComplete: this.widget.onEditingComplete, onSubmitted: this.widget.onSubmitted, inputFormatters: formatters, rendererIgnoresPointer: true, cursorWidth: this.widget.cursorWidth, cursorRadius: this.widget.cursorRadius, cursorColor: cursorColor, cursorOpacityAnimates: true, cursorOffset: cursorOffset, paintCursorAboveText: true, backgroundCursorColor: CupertinoColors.inactiveGray, scrollPadding: this.widget.scrollPadding, keyboardAppearance: keyboardAppearance, dragStartBehavior: this.widget.dragStartBehavior, scrollPhysics: this.widget.scrollPhysics ) ) ); return(new IgnorePointer( ignoring: !enabled, child: new Container( decoration: this.widget.decoration, child: new Container( color: enabled ? null : CupertinoTheme.of(context).brightness == Brightness.light ? CupertinoTextFieldUtils._kDisabledBackground : CupertinoColors.darkBackgroundGray, child: new TextSelectionGestureDetector( onTapDown: this._handleTapDown, onSingleTapUp: this._handleSingleTapUp, onSingleLongTapStart: this._handleSingleLongTapStart, onSingleLongTapMoveUpdate: this._handleSingleLongTapMoveUpdate, onSingleLongTapEnd: this._handleSingleLongTapEnd, onDoubleTapDown: this._handleDoubleTapDown, onDragSelectionStart: this._handleMouseDragSelectionStart, onDragSelectionUpdate: this._handleMouseDragSelectionUpdate, onDragSelectionEnd: this._handleMouseDragSelectionEnd, behavior: HitTestBehavior.translucent, child: this._addTextDependentAttachments(paddedEditable, textStyle, placeholderStyle) ) ) ) )); }
public CupertinoTextField( Key key = null, TextEditingController controller = null, FocusNode focusNode = null, BoxDecoration decoration = null, EdgeInsets padding = null, string placeholder = null, TextStyle placeholderStyle = null, Widget prefix = null, OverlayVisibilityMode prefixMode = OverlayVisibilityMode.always, Widget suffix = null, OverlayVisibilityMode suffixMode = OverlayVisibilityMode.always, OverlayVisibilityMode clearButtonMode = OverlayVisibilityMode.never, TextInputType keyboardType = null, TextInputAction?textInputAction = null, TextCapitalization textCapitalization = TextCapitalization.none, TextStyle style = null, StrutStyle strutStyle = null, TextAlign textAlign = TextAlign.left, bool autofocus = false, bool obscureText = false, bool autocorrect = true, int?maxLines = 1, int?minLines = null, bool expands = false, int?maxLength = null, bool maxLengthEnforced = true, ValueChanged <string> onChanged = null, VoidCallback onEditingComplete = null, ValueChanged <string> onSubmitted = null, List <TextInputFormatter> inputFormatters = null, bool?enabled = null, float cursorWidth = 2.0f, Radius cursorRadius = null, Color cursorColor = null, Brightness?keyboardAppearance = null, EdgeInsets scrollPadding = null, DragStartBehavior dragStartBehavior = DragStartBehavior.start, ScrollPhysics scrollPhysics = null) : base(key: key) { D.assert(maxLines == null || maxLines > 0); D.assert(minLines == null || minLines > 0); D.assert(maxLines == null || minLines == null || maxLines >= minLines, () => "minLines can't be greater than maxLines"); D.assert(!expands || (maxLines == null && minLines == null), () => "minLines and maxLines must be null when expands is true."); D.assert(maxLength == null || maxLength > 0); this.controller = controller; this.focusNode = focusNode; this.decoration = decoration ?? CupertinoTextFieldUtils._kDefaultRoundedBorderDecoration; this.padding = padding ?? EdgeInsets.all(6.0f); this.placeholder = placeholder; this.placeholderStyle = placeholderStyle ?? new TextStyle( fontWeight: FontWeight.w300, color: CupertinoTextFieldUtils._kInactiveTextColor ); this.prefix = prefix; this.prefixMode = prefixMode; this.suffix = suffix; this.suffixMode = suffixMode; this.clearButtonMode = clearButtonMode; this.textInputAction = textInputAction; this.textCapitalization = textCapitalization; this.style = style; this.strutStyle = strutStyle; this.textAlign = textAlign; this.autofocus = autofocus; this.obscureText = obscureText; this.autocorrect = autocorrect; this.maxLines = maxLines; this.minLines = minLines; this.expands = expands; this.maxLength = maxLength; this.maxLengthEnforced = maxLengthEnforced; this.onChanged = onChanged; this.onEditingComplete = onEditingComplete; this.onSubmitted = onSubmitted; this.inputFormatters = inputFormatters; this.enabled = enabled; this.cursorWidth = cursorWidth; this.cursorRadius = cursorRadius ?? Radius.circular(2.0f); this.cursorColor = cursorColor; this.keyboardAppearance = keyboardAppearance; this.scrollPadding = scrollPadding ?? EdgeInsets.all(20.0f); this.dragStartBehavior = dragStartBehavior; this.scrollPhysics = scrollPhysics; this.keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline); }
Widget _addTextDependentAttachments(Widget editableText, TextStyle textStyle, TextStyle placeholderStyle) { D.assert(editableText != null); D.assert(textStyle != null); D.assert(placeholderStyle != null); if (widget.placeholder == null && widget.clearButtonMode == OverlayVisibilityMode.never && widget.prefix == null && widget.suffix == null) { return(editableText); } return(new ValueListenableBuilder <TextEditingValue>( valueListenable: _effectiveController, child: editableText, builder: (BuildContext context, TextEditingValue text, Widget child) => { List <Widget> rowChildren = new List <Widget>(); if (_showPrefixWidget(text)) { rowChildren.Add(widget.prefix); } List <Widget> stackChildren = new List <Widget>(); if (widget.placeholder != null && text.text.isEmpty()) { stackChildren.Add( new SizedBox( width: float.PositiveInfinity, child: new Padding( padding: widget.padding, child: new Text( widget.placeholder, maxLines: widget.maxLines, overflow: TextOverflow.ellipsis, style: placeholderStyle, textAlign: widget.textAlign ) ) ) ); } stackChildren.Add(child); rowChildren.Add( new Expanded (child: new Stack (children: stackChildren))); if (_showSuffixWidget(text)) { rowChildren.Add(widget.suffix); } else if (_showClearButton(text)) { rowChildren.Add( new GestureDetector( onTap: widget.enabled ?? true ? () => { bool textChanged = _effectiveController.text.isNotEmpty(); _effectiveController.clear(); if (widget.onChanged != null && textChanged) { widget.onChanged(_effectiveController.text); } } : (GestureTapCallback)null, child: new Padding( padding: EdgeInsets.symmetric(horizontal: 6.0f), child: new Icon( CupertinoIcons.clear_thick_circled, size: 18.0f, color: CupertinoDynamicColor.resolve(CupertinoTextFieldUtils._kClearButtonColor, context) ) ) ) ); } return new Row(children: rowChildren); } )); }
public override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterialLocalizations(context)); ThemeData theme = Theme.of(context); AppBarTheme appBarTheme = AppBarTheme.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 overallIconTheme = widget.iconTheme ?? appBarTheme.iconTheme ?? theme.primaryIconTheme; IconThemeData actionsIconTheme = widget.actionsIconTheme ?? appBarTheme.actionsIconTheme ?? overallIconTheme; TextStyle centerStyle = widget.textTheme?.headline6 ?? appBarTheme.textTheme?.headline6 ?? theme.primaryTextTheme.headline6; TextStyle sideStyle = widget.textTheme?.bodyText2 ?? appBarTheme.textTheme?.bodyText2 ?? theme.primaryTextTheme.bodyText2; if (widget.toolbarOpacity != 1.0f) { float opacity = new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(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)); } overallIconTheme = overallIconTheme.copyWith( opacity: opacity * (overallIconTheme.opacity ?? 1.0f) ); actionsIconTheme = actionsIconTheme.copyWith( opacity: opacity * (actionsIconTheme.opacity ?? 1.0f) ); } Widget leading = widget.leading; if (leading == null && widget.automaticallyImplyLeading) { if (hasDrawer) { leading = new IconButton( icon: new Icon(Icons.menu), onPressed: _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 = widget.title; if (title != null) { switch (theme.platform) { case RuntimePlatform.Android: case RuntimePlatform.LinuxEditor: case RuntimePlatform.LinuxPlayer: case RuntimePlatform.WindowsEditor: case RuntimePlatform.WindowsPlayer: break; case RuntimePlatform.IPhonePlayer: case RuntimePlatform.OSXEditor: case RuntimePlatform.OSXPlayer: break; } title = new _AppBarTitleBox(child: title); title = new DefaultTextStyle( style: centerStyle, softWrap: false, overflow: TextOverflow.ellipsis, child: title ); } Widget actions = null; if (widget.actions != null && widget.actions.isNotEmpty()) { actions = new Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: widget.actions); } else if (hasEndDrawer) { actions = new IconButton( icon: new Icon(Icons.menu), onPressed: _handleDrawerButtonEnd, tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip); } if (actions != null) { actions = IconTheme.merge( data: actionsIconTheme, child: actions ); } Widget toolbar = new NavigationToolbar( leading: leading, middle: title, trailing: actions, centerMiddle: widget._getEffectiveCenterTitle(theme).Value, middleSpacing: widget.titleSpacing); Widget appBar = new ClipRect( child: new CustomSingleChildLayout( layoutDelegate: new _ToolbarContainerLayout(), child: IconTheme.merge( data: overallIconTheme, child: new DefaultTextStyle( style: sideStyle, child: toolbar) ) ) ); if (widget.bottom != null) { appBar = new Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { new Flexible( child: new ConstrainedBox( constraints: new BoxConstraints(maxHeight: material_.kToolbarHeight), child: appBar ) ), foundation_.FloatEqual(widget.bottomOpacity, 1.0f) ? (Widget)widget.bottom : new Opacity( opacity: new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(widget .bottomOpacity), child: widget.bottom ) } ); } if (widget.primary) { appBar = new SafeArea( bottom: false, top: true, child: appBar); } appBar = new Align( alignment: Alignment.topCenter, child: appBar); if (widget.flexibleSpace != null) { appBar = new Stack( fit: StackFit.passthrough, children: new List <Widget> { widget.flexibleSpace, appBar } ); } Brightness brightness = widget.brightness ?? appBarTheme.brightness ?? theme.primaryColorBrightness; SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark; return(new AnnotatedRegion <SystemUiOverlayStyle>( value: overlayStyle, child: new Material( color: widget.backgroundColor ?? appBarTheme.color ?? theme.primaryColor, elevation: widget.elevation ?? appBarTheme.elevation ?? _defaultElevation, shape: widget.shape, child: appBar ))); }
public override Widget build(BuildContext context) { base.build(context); D.assert(WidgetsD.debugCheckHasDirectionality(context)); TextEditingController controller = _effectiveController; List <TextInputFormatter> formatters = widget.inputFormatters ?? new List <TextInputFormatter>(); bool enabled = widget.enabled ?? true; Offset cursorOffset = new Offset( CupertinoTextFieldUtils._iOSHorizontalCursorOffsetPixels / MediaQuery.of(context).devicePixelRatio, 0); if (widget.maxLength != null && widget.maxLengthEnforced) { formatters.Add(new LengthLimitingTextInputFormatter(widget.maxLength)); } CupertinoThemeData themeData = CupertinoTheme.of(context); TextStyle resolvedStyle = widget.style?.copyWith( color: CupertinoDynamicColor.resolve(widget.style?.color, context), backgroundColor: CupertinoDynamicColor.resolve(widget.style?.backgroundColor, context) ); TextStyle textStyle = themeData.textTheme.textStyle.merge(resolvedStyle); TextStyle resolvedPlaceholderStyle = widget.placeholderStyle?.copyWith( color: CupertinoDynamicColor.resolve(widget.placeholderStyle?.color, context), backgroundColor: CupertinoDynamicColor.resolve(widget.placeholderStyle?.backgroundColor, context) ); TextStyle placeholderStyle = textStyle.merge(resolvedPlaceholderStyle); Brightness?keyboardAppearance = widget.keyboardAppearance ?? CupertinoTheme.brightnessOf(context); Color cursorColor = CupertinoDynamicColor.resolve(widget.cursorColor, context) ?? themeData.primaryColor; Color disabledColor = CupertinoDynamicColor.resolve(CupertinoTextFieldUtils._kDisabledBackground, context); Color decorationColor = CupertinoDynamicColor.resolve(widget.decoration?.color, context); BoxBorder border = widget.decoration?.border; Border resolvedBorder = border as Border; if (border is Border) { BorderSide resolveBorderSide(BorderSide side) { return(side == BorderSide.none ? side : side.copyWith(color: CupertinoDynamicColor.resolve(side.color, context))); } resolvedBorder = (Border)(border == null || border.GetType() != typeof(Border) ? border : new Border( top: resolveBorderSide(((Border)border).top), left: resolveBorderSide(((Border)border).left), bottom: resolveBorderSide(((Border)border).bottom), right: resolveBorderSide(((Border)border).right) )); } BoxDecoration effectiveDecoration = widget.decoration?.copyWith( border: resolvedBorder, color: enabled ? decorationColor : (decorationColor == null ? disabledColor : decorationColor) ); Widget paddedEditable = new Padding( padding: widget.padding, child: new RepaintBoundary( child: new EditableText( key: editableTextKey, controller: controller, readOnly: widget.readOnly, toolbarOptions: widget.toolbarOptions, showCursor: widget.showCursor, showSelectionHandles: _showSelectionHandles, focusNode: _effectiveFocusNode, keyboardType: widget.keyboardType, textInputAction: widget.textInputAction, textCapitalization: widget.textCapitalization, style: textStyle, strutStyle: widget.strutStyle, textAlign: widget.textAlign, autofocus: widget.autofocus, obscureText: widget.obscureText, autocorrect: widget.autocorrect, smartDashesType: widget.smartDashesType, smartQuotesType: widget.smartQuotesType, enableSuggestions: widget.enableSuggestions, maxLines: widget.maxLines, minLines: widget.minLines, expands: widget.expands, selectionColor: CupertinoTheme.of(context).primaryColor.withOpacity(0.2f), selectionControls: widget.selectionEnabled ? CupertinoTextFieldUtils.cupertinoTextSelectionControls : null, onChanged: widget.onChanged, onSelectionChanged: _handleSelectionChanged, onEditingComplete: widget.onEditingComplete, onSubmitted: widget.onSubmitted, inputFormatters: formatters, rendererIgnoresPointer: true, cursorWidth: widget.cursorWidth, cursorRadius: widget.cursorRadius, cursorColor: cursorColor, cursorOpacityAnimates: true, cursorOffset: cursorOffset, paintCursorAboveText: true, backgroundCursorColor: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context), selectionHeightStyle: widget.selectionHeightStyle, selectionWidthStyle: widget.selectionWidthStyle, scrollPadding: widget.scrollPadding, keyboardAppearance: keyboardAppearance, dragStartBehavior: widget.dragStartBehavior, scrollController: widget.scrollController, scrollPhysics: widget.scrollPhysics, enableInteractiveSelection: widget.enableInteractiveSelection ) ) ); return(new IgnorePointer( ignoring: !enabled, child: new Container( decoration: effectiveDecoration, child: _selectionGestureDetectorBuilder.buildGestureDetector( behavior: HitTestBehavior.translucent, child: new Align( alignment: new Alignment(-1.0f, _textAlignVertical.y), widthFactor: 1.0f, heightFactor: 1.0f, child: _addTextDependentAttachments(paddedEditable, textStyle, placeholderStyle) ) ) ) )); }
public TextSpan(string text = "", TextStyle style = null, List <TextSpan> children = null) { this.text = text; this.style = style; this.children = children; }
public override Widget build(BuildContext context) { ThemeData theme = Theme.of(context); TextStyle dialogTextStyle = theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color); var children = new List <Widget> { new RaisedButton( child: new Text("ALERT"), onPressed: () => { showDemoDialog <DialogDemoAction>( context: context, child: new AlertDialog( content: new Text( GalleryDialogDemoUtils._alertWithoutTitleText, style: dialogTextStyle ), actions: new List <Widget> { new FlatButton( child: new Text("CANCEL"), onPressed: () => { Navigator.pop(context, DialogDemoAction.cancel); } ), new FlatButton( child: new Text("DISCARD"), onPressed: () => { Navigator.pop(context, DialogDemoAction.discard); } ) } ) ); } ), new RaisedButton( child: new Text("ALERT WITH TITLE"), onPressed: () => { showDemoDialog <DialogDemoAction>( context: context, child: new AlertDialog( title: new Text("Use location service?"), content: new Text( GalleryDialogDemoUtils._alertWithTitleText, style: dialogTextStyle ), actions: new List <Widget> { new FlatButton( child: new Text("DISAGREE"), onPressed: () => { Navigator.pop(context, DialogDemoAction.disagree); } ), new FlatButton( child: new Text("AGREE"), onPressed: () => { Navigator.pop(context, DialogDemoAction.agree); } ) } ) ); } ), new RaisedButton( child: new Text("SIMPLE"), onPressed: () => { showDemoDialog <String>( context: context, child: new SimpleDialog( title: new Text("Set backup account"), children: new List <Widget> { new DialogDemoItem( icon: Icons.account_circle, color: theme.primaryColor, text: "*****@*****.**", onPressed: () => { Navigator.pop(context, "*****@*****.**"); } ), new DialogDemoItem( icon: Icons.account_circle, color: theme.primaryColor, text: "*****@*****.**", onPressed: () => { Navigator.pop(context, "*****@*****.**"); } ), new DialogDemoItem( icon: Icons.add_circle, text: "add account", color: theme.disabledColor ) } ) ); } ), new RaisedButton( child: new Text("CONFIRMATION"), onPressed: () => { TimePickerUtils.showTimePicker( context: context, initialTime: _selectedTime ) .then((object value) => { var time = (TimeOfDay)value; if (time != null && time != _selectedTime) { _selectedTime = time; _scaffoldKey.currentState.showSnackBar(new SnackBar( content: new Text($"You selected: {time.format(context)}") )); } }); } ), new RaisedButton( child: new Text("FULLSCREEN"), onPressed: () => { /*Navigator.push(context, new MaterialPageRoute<DismissDialogAction>( * builder: (BuildContext subContext) => new FullScreenDialogDemo(), * fullscreenDialog: true * ));*/ D.assert(false, () => "TO DO >>>"); } ) }; return(new Scaffold( key: _scaffoldKey, appBar: new AppBar( title: new Text("Dialogs"), actions: new List <Widget> { new MaterialDemoDocumentationButton(DialogDemo.routeName) } ), body: new ListView( padding: EdgeInsets.symmetric(vertical: 24.0f, horizontal: 72.0f), children: children.Select <Widget, Widget>((Widget button) => { return new Container( padding: EdgeInsets.symmetric(vertical: 8.0f), child: button ); }) .ToList() ) )); }
public override Widget build(BuildContext context) { ThemeData theme = Theme.of(context); FloatingActionButtonThemeData floatingActionButtonTheme = theme.floatingActionButtonTheme; Color backgroundColor = this.backgroundColor ?? floatingActionButtonTheme.backgroundColor ?? theme.colorScheme.secondary; Color foregroundColor = this.foregroundColor ?? floatingActionButtonTheme.foregroundColor ?? theme.accentIconTheme.color ?? theme.colorScheme.onSecondary; float elevation = this.elevation ?? floatingActionButtonTheme.elevation ?? _defaultElevation; float disabledElevation = this.disabledElevation ?? floatingActionButtonTheme.disabledElevation ?? elevation; float highlightElevation = this.highlightElevation ?? floatingActionButtonTheme.highlightElevation ?? _defaultHighlightElevation; MaterialTapTargetSize materialTapTargetSize = this.materialTapTargetSize ?? theme.materialTapTargetSize; TextStyle textStyle = theme.accentTextTheme.button.copyWith( color: foregroundColor, letterSpacing: 1.2f ); ShapeBorder shape = this.shape ?? floatingActionButtonTheme.shape ?? (this.isExtended ? this._defaultExtendedShape : this._defaultShape); Widget result = null; if (this.child != null) { result = IconTheme.merge( data: new IconThemeData( color: foregroundColor), child: this.child ); } result = new RawMaterialButton( onPressed: this.onPressed, elevation: elevation, highlightElevation: highlightElevation, disabledElevation: disabledElevation, constraints: this._sizeConstraints, materialTapTargetSize: materialTapTargetSize, fillColor: backgroundColor, textStyle: textStyle, shape: shape, clipBehavior: this.clipBehavior, child: result); if (this.tooltip != null) { result = new Tooltip( message: this.tooltip, child: result); } if (this.heroTag != null) { result = new Hero( tag: this.heroTag, child: result); } return(result); }
public override Widget build(BuildContext context) { D.assert(WidgetsD.debugCheckHasMediaQuery(context)); ThemeData theme = Theme.of(context); TextStyle textStyle = theme.primaryTextTheme.subtitle1.copyWith(color: foregroundColor); Color effectiveBackgroundColor = backgroundColor; if (effectiveBackgroundColor == null) { switch (ThemeData.estimateBrightnessForColor(textStyle.color)) { case Brightness.dark: effectiveBackgroundColor = theme.primaryColorLight; break; case Brightness.light: effectiveBackgroundColor = theme.primaryColorDark; break; } } else if (foregroundColor == null) { switch (ThemeData.estimateBrightnessForColor(backgroundColor)) { case Brightness.dark: textStyle = textStyle.copyWith(color: theme.primaryColorLight); break; case Brightness.light: textStyle = textStyle.copyWith(color: theme.primaryColorDark); break; } } float minDiameter = _minDiameter; float maxDiameter = _maxDiameter; return(new AnimatedContainer( constraints: new BoxConstraints( minHeight: minDiameter, minWidth: minDiameter, maxWidth: maxDiameter, maxHeight: maxDiameter ), duration: material_.kThemeChangeDuration, decoration: new BoxDecoration( color: effectiveBackgroundColor, image: backgroundImage != null ? new DecorationImage( image: backgroundImage, onError: onBackgroundImageError, fit: BoxFit.cover ) : null, shape: BoxShape.circle ), child: child == null ? null : new Center( child: new MediaQuery( data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0f), child: new IconTheme( data: theme.iconTheme.copyWith(color: textStyle.color), child: new DefaultTextStyle( style: textStyle, child: child ) ) ) ) )); }
public override Widget build(BuildContext context) { bool enabled = widget.enabled; CupertinoThemeData themeData = CupertinoTheme.of(context); Color primaryColor = themeData.primaryColor; Color backgroundColor = (widget.color == null) ? (widget._filled ? primaryColor : null) : CupertinoDynamicColor.resolve(widget.color, context); Color foregroundColor = backgroundColor != null ? themeData.primaryContrastingColor : enabled ? primaryColor : CupertinoDynamicColor.resolve(CupertinoColors.placeholderText, context); TextStyle textStyle = themeData.textTheme.textStyle.copyWith(color: foregroundColor); return(new GestureDetector( behavior: HitTestBehavior.opaque, onTapDown: enabled ? _handleTapDown : (GestureTapDownCallback)null, onTapUp: enabled ? _handleTapUp : (GestureTapUpCallback)null, onTapCancel: enabled ? _handleTapCancel : (GestureTapCancelCallback)null, onTap: widget.onPressed == null ? (GestureTapCallback)null : () => { if (widget.onPressed != null) { widget.onPressed(); } }, child: new ConstrainedBox( constraints: widget.minSize == null ? new BoxConstraints() : new BoxConstraints( minWidth: widget.minSize.Value, minHeight: widget.minSize.Value ), child: new FadeTransition( opacity: _opacityAnimation, child: new DecoratedBox( decoration: new BoxDecoration( borderRadius: widget.borderRadius, color: backgroundColor != null && !enabled ? CupertinoDynamicColor.resolve(widget.disabledColor, context) : backgroundColor ), child: new Padding( padding: widget.padding ?? (backgroundColor != null ? CupertinoButtonUtils._kBackgroundButtonPadding : CupertinoButtonUtils._kButtonPadding), child: new Center( widthFactor: 1.0f, heightFactor: 1.0f, child: new DefaultTextStyle( style: textStyle, child: new IconTheme( data: new IconThemeData(color: foregroundColor), child: widget.child ) ) ) ) ) ) ) )); }
public override Widget build(BuildContext context) { base.build(context); // See AutomaticKeepAliveClientMixin. D.assert(MaterialD.debugCheckHasMaterial(context)); D.assert(WidgetsD.debugCheckHasDirectionality(context)); D.assert( !(this.widget.style != null && this.widget.style.inherit == false && (this.widget.style.fontSize == null || this.widget.style.textBaseline == null)), () => "inherit false style must supply fontSize and textBaseline" ); ThemeData themeData = Theme.of(context); TextStyle style = themeData.textTheme.subhead.merge(this.widget.style); Brightness keyboardAppearance = this.widget.keyboardAppearance ?? themeData.primaryColorBrightness; TextEditingController controller = this._effectiveController; FocusNode focusNode = this._effectiveFocusNode; List <TextInputFormatter> formatters = this.widget.inputFormatters ?? new List <TextInputFormatter>(); if (this.widget.maxLength != null && this.widget.maxLengthEnforced) { formatters.Add(new LengthLimitingTextInputFormatter(this.widget.maxLength)); } // bool forcePressEnabled = false; // TODO: wait for force press is ready TextSelectionControls textSelectionControls = MaterialUtils.materialTextSelectionControls;; bool paintCursorAboveText = false; bool cursorOpacityAnimates = false; Offset cursorOffset = null; Color cursorColor = this.widget.cursorColor ?? themeData.cursorColor; Radius cursorRadius = this.widget.cursorRadius; Widget child = new RepaintBoundary( child: new EditableText( key: this._editableTextKey, controller: controller, focusNode: focusNode, keyboardType: this.widget.keyboardType, textInputAction: this.widget.textInputAction, textCapitalization: this.widget.textCapitalization, style: style, textAlign: this.widget.textAlign, textDirection: this.widget.textDirection, autofocus: this.widget.autofocus, obscureText: this.widget.obscureText, autocorrect: this.widget.autocorrect, maxLines: this.widget.maxLines, selectionColor: themeData.textSelectionColor, selectionControls: this.widget.selectionEnabled ? textSelectionControls : null, onChanged: this.widget.onChanged, onSelectionChanged: this._handleSelectionChanged, onEditingComplete: this.widget.onEditingComplete, onSubmitted: this.widget.onSubmitted, inputFormatters: formatters, rendererIgnoresPointer: true, cursorWidth: this.widget.cursorWidth, cursorRadius: cursorRadius, cursorColor: cursorColor, cursorOpacityAnimates: cursorOpacityAnimates, cursorOffset: cursorOffset, paintCursorAboveText: paintCursorAboveText, backgroundCursorColor: new Color(0xFF8E8E93),// TODO: CupertinoColors.inactiveGray, scrollPadding: this.widget.scrollPadding, keyboardAppearance: keyboardAppearance, enableInteractiveSelection: this.widget.enableInteractiveSelection == true, dragStartBehavior: this.widget.dragStartBehavior ) ); if (this.widget.decoration != null) { child = new AnimatedBuilder( animation: ListenableUtils.merge(new List <Listenable> { focusNode, controller }), builder: (_context, _child) => { return(new InputDecorator( decoration: this._getEffectiveDecoration(), baseStyle: this.widget.style, textAlign: this.widget.textAlign, isFocused: focusNode.hasFocus, isEmpty: controller.value.text.isEmpty(), child: _child )); }, child: child ); } return(new IgnorePointer( ignoring: !(this.widget.enabled ?? this.widget.decoration?.enabled ?? true), child: new TextSelectionGestureDetector( onTapDown: this._handleTapDown, // onForcePressStart: forcePressEnabled ? this._handleForcePressStarted : null, // TODO: Remove this when force press is added onSingleTapUp: this._handleSingleTapUp, onSingleTapCancel: this._handleSingleTapCancel, onSingleLongTapStart: this._handleLongPress, onDragSelectionStart: this._handleDragSelectionStart, onDragSelectionUpdate: this._handleDragSelectionUpdate, behavior: HitTestBehavior.translucent, child: child ) )); }
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) { 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); }
public override Widget build(BuildContext context) { D.assert(MaterialD.debugCheckHasMaterial(context)); ThemeData theme = Theme.of(context); ListTileTheme tileTheme = ListTileTheme.of(context); IconThemeData iconThemeData = null; if (this.leading != null || this.trailing != null) { iconThemeData = new IconThemeData(color: this._iconColor(theme, tileTheme)); } Widget leadingIcon = null; if (this.leading != null) { leadingIcon = IconTheme.merge( data: iconThemeData, child: this.leading); } TextStyle titleStyle = this._titleTextStyle(theme, tileTheme); Widget titleText = new AnimatedDefaultTextStyle( style: titleStyle, duration: Constants.kThemeChangeDuration, child: this.title ?? new SizedBox() ); Widget subtitleText = null; TextStyle subtitleStyle = null; if (this.subtitle != null) { subtitleStyle = this._subtitleTextStyle(theme, tileTheme); subtitleText = new AnimatedDefaultTextStyle( style: subtitleStyle, duration: Constants.kThemeChangeDuration, child: this.subtitle); } Widget trailingIcon = null; if (this.trailing != null) { trailingIcon = IconTheme.merge( data: iconThemeData, child: this.trailing); } EdgeInsets _defaultContentPadding = EdgeInsets.symmetric(horizontal: 16.0f); EdgeInsets resolvedContentPadding = this.contentPadding ?? tileTheme?.contentPadding ?? _defaultContentPadding; return(new InkWell( onTap: this.enabled ? this.onTap : null, onLongPress: this.enabled ? this.onLongPress : null, child: new SafeArea( top: false, bottom: false, mininum: resolvedContentPadding, child: new _ListTile( leading: leadingIcon, title: titleText, subtitle: subtitleText, trailing: trailingIcon, isDense: this._isDenseLayout(tileTheme), isThreeLine: this.isThreeLine, titleBaselineType: titleStyle.textBaseline, subtitleBaselineType: subtitleStyle?.textBaseline ) ) )); }
public override Widget build(BuildContext context) { bool enabled = this.widget.enabled; Color primaryColor = CupertinoTheme.of(context).primaryColor; Color backgroundColor = this.widget.color ?? (this.widget._filled ? primaryColor : null); Color foregroundColor = backgroundColor != null ? CupertinoTheme.of(context).primaryContrastingColor : enabled ? primaryColor : CupertinoButtonUtils._kDisabledForeground; TextStyle textStyle = CupertinoTheme.of(context).textTheme.textStyle.copyWith(color: foregroundColor); return(new GestureDetector( behavior: HitTestBehavior.opaque, onTapDown: enabled ? this._handleTapDown : (GestureTapDownCallback)null, onTapUp: enabled ? this._handleTapUp : (GestureTapUpCallback)null, onTapCancel: enabled ? this._handleTapCancel : (GestureTapCancelCallback)null, onTap: this.widget.onPressed == null ? (GestureTapCallback)null : () => { if (this.widget.onPressed != null) { this.widget.onPressed(); } }, child: new ConstrainedBox( constraints: new BoxConstraints( minWidth: this.widget.minSize, minHeight: this.widget.minSize ), child: new FadeTransition( opacity: this._opacityAnimation, child: new DecoratedBox( decoration: new BoxDecoration( borderRadius: this.widget.borderRadius, color: backgroundColor != null && !enabled ? this.widget.disabledColor ?? CupertinoButtonUtils._kDisabledBackground : backgroundColor ), child: new Padding( padding: this.widget.padding ?? (backgroundColor != null ? CupertinoButtonUtils._kBackgroundButtonPadding : CupertinoButtonUtils._kButtonPadding), child: new Center( widthFactor: 1.0f, heightFactor: 1.0f, child: new DefaultTextStyle( style: textStyle, child: new IconTheme( data: new IconThemeData(color: foregroundColor), child: this.widget.child ) ) ) ) ) ) ) )); }
public CupertinoTextField( Key key = null, TextEditingController controller = null, FocusNode focusNode = null, BoxDecoration decoration = null, EdgeInsets padding = null, string placeholder = null, TextStyle placeholderStyle = null, Widget prefix = null, OverlayVisibilityMode prefixMode = OverlayVisibilityMode.always, Widget suffix = null, OverlayVisibilityMode suffixMode = OverlayVisibilityMode.always, OverlayVisibilityMode clearButtonMode = OverlayVisibilityMode.never, TextInputType keyboardType = null, TextInputAction?textInputAction = null, TextCapitalization textCapitalization = TextCapitalization.none, TextStyle style = null, StrutStyle strutStyle = null, TextAlign textAlign = TextAlign.left, TextAlignVertical textAlignVertical = null, bool readOnly = false, ToolbarOptions toolbarOptions = null, bool?showCursor = null, bool autofocus = false, bool obscureText = false, bool autocorrect = true, SmartDashesType?smartDashesType = null, SmartQuotesType?smartQuotesType = null, bool enableSuggestions = true, int?maxLines = 1, int?minLines = null, bool expands = false, int?maxLength = null, bool maxLengthEnforced = true, ValueChanged <string> onChanged = null, VoidCallback onEditingComplete = null, ValueChanged <string> onSubmitted = null, List <TextInputFormatter> inputFormatters = null, bool?enabled = null, float cursorWidth = 2.0f, Radius cursorRadius = null, Color cursorColor = null, ui.BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight, ui.BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight, Brightness?keyboardAppearance = null, EdgeInsets scrollPadding = null, DragStartBehavior dragStartBehavior = DragStartBehavior.start, bool enableInteractiveSelection = true, GestureTapCallback onTap = null, ScrollController scrollController = null, ScrollPhysics scrollPhysics = null ) : base(key: key) { this.smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled); this.smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled); D.assert(maxLines == null || maxLines > 0); D.assert(minLines == null || minLines > 0); D.assert(maxLines == null || minLines == null || maxLines >= minLines, () => "minLines can't be greater than maxLines"); D.assert(!expands || (maxLines == null && minLines == null), () => "minLines and maxLines must be null when expands is true."); D.assert(maxLength == null || maxLength > 0); this.controller = controller; this.focusNode = focusNode; this.decoration = decoration ?? CupertinoTextFieldUtils._kDefaultRoundedBorderDecoration; this.padding = padding ?? EdgeInsets.all(6.0f); this.placeholder = placeholder; this.placeholderStyle = placeholderStyle ?? new TextStyle( fontWeight: FontWeight.w400, color: CupertinoColors.placeholderText ); this.prefix = prefix; this.prefixMode = prefixMode; this.suffix = suffix; this.suffixMode = suffixMode; this.clearButtonMode = clearButtonMode; this.textInputAction = textInputAction; this.textCapitalization = textCapitalization; this.style = style; this.strutStyle = strutStyle; this.textAlign = textAlign; this.textAlignVertical = textAlignVertical; this.readOnly = readOnly; this.showCursor = showCursor; this.autofocus = autofocus; this.obscureText = obscureText; this.autocorrect = autocorrect; this.enableSuggestions = enableSuggestions; this.maxLines = maxLines; this.minLines = minLines; this.expands = expands; this.maxLength = maxLength; this.maxLengthEnforced = maxLengthEnforced; this.onChanged = onChanged; this.onEditingComplete = onEditingComplete; this.onSubmitted = onSubmitted; this.inputFormatters = inputFormatters; this.enabled = enabled; this.cursorWidth = cursorWidth; this.cursorRadius = cursorRadius ?? Radius.circular(2.0f); this.cursorColor = cursorColor; this.selectionHeightStyle = selectionHeightStyle; this.selectionWidthStyle = selectionWidthStyle; this.keyboardAppearance = keyboardAppearance; this.scrollPadding = scrollPadding ?? EdgeInsets.all(20.0f); this.dragStartBehavior = dragStartBehavior; this.enableInteractiveSelection = enableInteractiveSelection; this.scrollPhysics = scrollPhysics; this.onTap = onTap; this.scrollController = scrollController; this.keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline); this.toolbarOptions = toolbarOptions ?? (obscureText ? new ToolbarOptions( selectAll: true, paste: true ) : new ToolbarOptions( copy: true, cut: true, selectAll: true, paste: true )); }
public InlineSpan( TextStyle style = null ) { this.style = style; }
public override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterial(context)); D.assert(WidgetsD.debugCheckHasDirectionality(context)); D.assert( !(widget.style != null && widget.style.inherit == false && (widget.style.fontSize == null || widget.style.textBaseline == null)), () => "inherit false style must supply fontSize and textBaseline" ); ThemeData themeData = Theme.of(context); TextStyle style = themeData.textTheme.subtitle1.merge(widget.style); Brightness keyboardAppearance = widget.keyboardAppearance ?? themeData.primaryColorBrightness; TextEditingController controller = _effectiveController; FocusNode focusNode = _effectiveFocusNode; List <TextInputFormatter> formatters = widget.inputFormatters ?? new List <TextInputFormatter>(); if (widget.maxLength != null && widget.maxLengthEnforced) { formatters.Add(new LengthLimitingTextInputFormatter(widget.maxLength)); } TextSelectionControls textSelectionControls = MaterialUtils.materialTextSelectionControls; ; bool paintCursorAboveText = false; bool cursorOpacityAnimates = false; Offset cursorOffset = null; Color cursorColor = widget.cursorColor ?? themeData.cursorColor; Radius cursorRadius = widget.cursorRadius; _forcePressEnabled = false; textSelectionControls = _MaterialTextSelectionControls.materialTextSelectionControls; paintCursorAboveText = false; cursorOpacityAnimates = false; cursorColor = cursorColor ?? themeData.cursorColor; Widget child = new RepaintBoundary( child: new EditableText( key: editableTextKey, readOnly: widget.readOnly, toolbarOptions: widget.toolbarOptions, showCursor: widget.showCursor, showSelectionHandles: _showSelectionHandles, controller: controller, focusNode: focusNode, keyboardType: widget.keyboardType, textInputAction: widget.textInputAction, textCapitalization: widget.textCapitalization, style: style, strutStyle: widget.strutStyle, textAlign: widget.textAlign, textDirection: widget.textDirection, autofocus: widget.autofocus, obscureText: widget.obscureText, autocorrect: widget.autocorrect, smartDashesType: widget.smartDashesType, smartQuotesType: widget.smartQuotesType, enableSuggestions: widget.enableSuggestions, maxLines: widget.maxLines, minLines: widget.minLines, expands: widget.expands, selectionColor: themeData.textSelectionColor, selectionControls: widget.selectionEnabled ? textSelectionControls : null, onChanged: widget.onChanged, onSelectionChanged: _handleSelectionChanged, onEditingComplete: widget.onEditingComplete, onSubmitted: widget.onSubmitted, onSelectionHandleTapped: _handleSelectionHandleTapped, inputFormatters: formatters, rendererIgnoresPointer: true, cursorWidth: widget.cursorWidth.Value, cursorRadius: cursorRadius, cursorColor: cursorColor, selectionHeightStyle: widget.selectionHeightStyle, selectionWidthStyle: widget.selectionWidthStyle, cursorOpacityAnimates: cursorOpacityAnimates, cursorOffset: cursorOffset, paintCursorAboveText: paintCursorAboveText, backgroundCursorColor: CupertinoColors.inactiveGray, scrollPadding: widget.scrollPadding, keyboardAppearance: keyboardAppearance, enableInteractiveSelection: widget.enableInteractiveSelection == true, dragStartBehavior: widget.dragStartBehavior, scrollController: widget.scrollController, scrollPhysics: widget.scrollPhysics ) ); if (widget.decoration != null) { child = new AnimatedBuilder( animation: ListenableUtils.merge(new List <Listenable> { focusNode, controller }), builder: (_context, _child) => { return(new InputDecorator( decoration: _getEffectiveDecoration(), baseStyle: widget.style, textAlign: widget.textAlign, textAlignVertical: widget.textAlignVertical, isHovering: _isHovering, isFocused: focusNode.hasFocus, isEmpty: controller.value.text.isEmpty(), expands: widget.expands, child: _child )); }, child: child ); } void onEnter(PointerEnterEvent pEvent) { _handleHover(true); } void onExit(PointerExitEvent pEvent) { _handleHover(false); } return(new IgnorePointer( ignoring: !_isEnabled, child: new MouseRegion( onEnter: onEnter, onExit: onExit, child: new AnimatedBuilder( animation: controller, builder: (BuildContext buildContext, Widget buildChild) => { return buildChild; }, child: _selectionGestureDetectorBuilder.buildGestureDetector( behavior: HitTestBehavior.translucent, child: child ) ) ) )); }