public override Widget build(BuildContext context) { D.assert(MaterialD.debugCheckHasMaterial(context)); D.assert(WidgetsD.debugCheckHasMediaQuery(context)); SliderThemeData sliderTheme = SliderTheme.of(context); if (this.widget.activeColor != null || this.widget.inactiveColor != null) { sliderTheme = sliderTheme.copyWith( activeTrackColor: this.widget.activeColor, inactiveTrackColor: this.widget.inactiveColor, activeTickMarkColor: this.widget.inactiveColor, inactiveTickMarkColor: this.widget.activeColor, thumbColor: this.widget.activeColor, valueIndicatorColor: this.widget.activeColor, overlayColor: this.widget.activeColor?.withAlpha(0x29) ); } return(new _SliderRenderObjectWidget( value: this._unlerp(this.widget.value), divisions: this.widget.divisions, label: this.widget.label, sliderTheme: sliderTheme, mediaQueryData: MediaQuery.of(context), onChanged: (this.widget.onChanged != null) && (this.widget.max > this.widget.min) ? this._handleChanged : (ValueChanged <float>)null, onChangeStart: this.widget.onChangeStart != null ? this._handleDragStart : (ValueChanged <float>)null, onChangeEnd: this.widget.onChangeEnd != null ? this._handleDragEnd : (ValueChanged <float>)null, state: this )); }
public override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterial(context)); D.assert(WidgetsD.debugCheckHasMediaQuery(context)); ThemeData theme = Theme.of(context); SliderThemeData sliderTheme = SliderTheme.of(context); sliderTheme = sliderTheme.copyWith( trackHeight: sliderTheme.trackHeight ?? _defaultTrackHeight, activeTrackColor: widget.activeColor ?? sliderTheme.activeTrackColor ?? theme.colorScheme.primary, inactiveTrackColor: widget.inactiveColor ?? sliderTheme.inactiveTrackColor ?? theme.colorScheme.primary.withOpacity(0.24f), disabledActiveTrackColor: sliderTheme.disabledActiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.32f), disabledInactiveTrackColor: sliderTheme.disabledInactiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.12f), activeTickMarkColor: widget.inactiveColor ?? sliderTheme.activeTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.54f), inactiveTickMarkColor: widget.activeColor ?? sliderTheme.inactiveTickMarkColor ?? theme.colorScheme.primary.withOpacity(0.54f), disabledActiveTickMarkColor: sliderTheme.disabledActiveTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.12f), disabledInactiveTickMarkColor: sliderTheme.disabledInactiveTickMarkColor ?? theme.colorScheme.onSurface.withOpacity(0.12f), thumbColor: widget.activeColor ?? sliderTheme.thumbColor ?? theme.colorScheme.primary, overlappingShapeStrokeColor: sliderTheme.overlappingShapeStrokeColor ?? theme.colorScheme.surface, disabledThumbColor: sliderTheme.disabledThumbColor ?? theme.colorScheme.onSurface.withOpacity(0.38f), overlayColor: widget.activeColor?.withOpacity(0.12f) ?? sliderTheme.overlayColor ?? theme.colorScheme.primary.withOpacity(0.12f), valueIndicatorColor: widget.activeColor ?? sliderTheme.valueIndicatorColor ?? theme.colorScheme.primary, rangeTrackShape: sliderTheme.rangeTrackShape ?? _defaultTrackShape, rangeTickMarkShape: sliderTheme.rangeTickMarkShape ?? _defaultTickMarkShape, rangeThumbShape: sliderTheme.rangeThumbShape ?? _defaultThumbShape, overlayShape: sliderTheme.overlayShape ?? _defaultOverlayShape, rangeValueIndicatorShape: sliderTheme.rangeValueIndicatorShape ?? _defaultValueIndicatorShape, showValueIndicator: sliderTheme.showValueIndicator ?? _defaultShowValueIndicator, valueIndicatorTextStyle: sliderTheme.valueIndicatorTextStyle ?? theme.textTheme.bodyText1.copyWith( color: theme.colorScheme.onPrimary ), minThumbSeparation: sliderTheme.minThumbSeparation ?? _defaultMinThumbSeparation, thumbSelector: sliderTheme.thumbSelector ?? _defaultRangeThumbSelector ); return(new _RangeSliderRenderObjectWidget( values: _unlerpRangeValues(widget.values), divisions: widget.divisions, labels: widget.labels, sliderTheme: sliderTheme, textScaleFactor: MediaQuery.of(context).textScaleFactor, onChanged: (widget.onChanged != null) && (widget.max > widget.min) ? _handleChanged : (ValueChanged <RangeValues>)null, onChangeStart: widget.onChangeStart != null ? _handleDragStart : (ValueChanged <RangeValues>)null, onChangeEnd: widget.onChangeEnd != null ? _handleDragEnd : (ValueChanged <RangeValues>)null, state: this )); }
public override Widget buildToolbar(BuildContext context, Rect globalEditableRegion, float textLineHeight, Offset selectionMidpoint, List <TextSelectionPoint> endpoints, TextSelectionDelegate selectionDelegate) { D.assert(WidgetsD.debugCheckHasMediaQuery(context)); D.assert(material_.debugCheckHasMaterialLocalizations(context)); TextSelectionPoint startTextSelectionPoint = endpoints[0]; TextSelectionPoint endTextSelectionPoint = endpoints.Count > 1 ? endpoints[1] : endpoints[0]; const float closedToolbarHeightNeeded = MaterialUtils._kToolbarScreenPadding + MaterialUtils._kToolbarHeight + MaterialUtils._kToolbarContentDistance; float paddingTop = MediaQuery.of(context).padding.top; float availableHeight = globalEditableRegion.top + startTextSelectionPoint.point.dy - textLineHeight - paddingTop; bool fitsAbove = closedToolbarHeightNeeded <= availableHeight; Offset anchor = new Offset( globalEditableRegion.left + selectionMidpoint.dx, fitsAbove ? globalEditableRegion.top + startTextSelectionPoint.point.dy - textLineHeight - MaterialUtils._kToolbarContentDistance : globalEditableRegion.top + endTextSelectionPoint.point.dy + MaterialUtils._kToolbarContentDistanceBelow ); return(new Stack( children: new List <Widget>() { new CustomSingleChildLayout( layoutDelegate: new _TextSelectionToolbarLayout( anchor, MaterialUtils._kToolbarScreenPadding + paddingTop, fitsAbove ), child: new _TextSelectionToolbar( handleCut: canCut(selectionDelegate) ? () => handleCut(selectionDelegate) : (VoidCallback)null, handleCopy: canCopy(selectionDelegate) ? () => handleCopy(selectionDelegate) : (VoidCallback)null, handlePaste: canPaste(selectionDelegate) ? () => handlePaste(selectionDelegate) : (VoidCallback)null, handleSelectAll: canSelectAll(selectionDelegate) ? () => handleSelectAll(selectionDelegate) : (VoidCallback)null, isAbove: fitsAbove ) ), } )); }
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 override Widget build(BuildContext context) { D.assert(material_.debugCheckHasMaterial(context)); D.assert(WidgetsD.debugCheckHasMediaQuery(context)); switch (widget._sliderType) { case _SliderType.material: return(_buildMaterialSlider(context)); case _SliderType.adaptive: { ThemeData theme = Theme.of(context); return(_buildMaterialSlider(context)); } } D.assert(false); return(null); }
public override Widget build(BuildContext context) { D.assert(!widget.primary || WidgetsD.debugCheckHasMediaQuery(context)); float?topPadding = widget.primary ? MediaQuery.of(context).padding.top : 0.0f; float?collapsedHeight = (widget.pinned && widget.floating && widget.bottom != null) ? widget.bottom.preferredSize.height + topPadding : null; return(MediaQuery.removePadding( context: context, removeBottom: true, child: new SliverPersistentHeader( floating: widget.floating, pinned: widget.pinned, del: new _SliverAppBarDelegate( leading: widget.leading, automaticallyImplyLeading: widget.automaticallyImplyLeading, title: widget.title, actions: widget.actions, flexibleSpace: widget.flexibleSpace, bottom: widget.bottom, elevation: widget.elevation, forceElevated: widget.forceElevated, backgroundColor: widget.backgroundColor, brightness: widget.brightness, iconTheme: widget.iconTheme, actionsIconTheme: widget.actionsIconTheme, textTheme: widget.textTheme, primary: widget.primary, centerTitle: widget.centerTitle, titleSpacing: widget.titleSpacing, expandedHeight: widget.expandedHeight, collapsedHeight: collapsedHeight, topPadding: topPadding, floating: widget.floating, pinned: widget.pinned, shape: widget.shape, snapConfiguration: _snapConfiguration, stretchConfiguration: _stretchConfiguration ) ) )); }
public override Widget buildToolbar(BuildContext context, Rect globalEditableRegion, Offset position, TextSelectionDelegate del) { D.assert(WidgetsD.debugCheckHasMediaQuery(context)); return(new ConstrainedBox( constraints: BoxConstraints.tight(globalEditableRegion.size), child: new CustomSingleChildLayout( layoutDelegate: new _TextSelectionToolbarLayout( MediaQuery.of(context).size, globalEditableRegion, position ), child: new _TextSelectionToolbar( handleCut: this.canCut(del) ? () => this.handleCut(del) : (VoidCallback)null, handleCopy: this.canCopy(del) ? () => this.handleCopy(del) : (VoidCallback)null, handlePaste: this.canPaste(del) ? () => this.handlePaste(del) : (VoidCallback)null, handleSelectAll: this.canSelectAll(del) ? () => this.handleSelectAll(del) : (VoidCallback)null ) ) )); }
public override Widget build(BuildContext context) { D.assert(WidgetsD.debugCheckHasMediaQuery(context)); D.assert(material_.debugCheckHasMaterialLocalizations(context)); MediaQueryData mediaQuery = MediaQuery.of(context); MaterialLocalizations localizations = MaterialLocalizations.of(context); string routeLabel = _getRouteLabel(localizations); return(new AnimatedBuilder( animation: widget.route.animation, builder: (BuildContext _context, Widget child) => { float animationValue = animationCurve.transform( mediaQuery.accessibleNavigation ? 1.0f : widget.route.animation.value ); return new ClipRect( child: new CustomSingleChildLayout( layoutDelegate: new _ModalBottomSheetLayout(animationValue, widget.isScrollControlled), child: new BottomSheet( animationController: widget.route._animationController, onClosing: () => { if (widget.route.isCurrent) { Navigator.pop <object>(_context); } }, builder: widget.route.builder, backgroundColor: widget.backgroundColor, elevation: widget.elevation, shape: widget.shape, clipBehavior: widget.clipBehavior, enableDrag: widget.enableDrag, onDragStart: handleDragStart, onDragEnd: handleDragEnd ) ) ); } )); }
public override 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 buildToolbar( BuildContext context, Rect globalEditableRegion, float textLineHeight, Offset position, List <TextSelectionPoint> endpoints, TextSelectionDelegate _delegate ) { D.assert(WidgetsD.debugCheckHasMediaQuery(context)); MediaQueryData mediaQuery = MediaQuery.of(context); float toolbarHeightNeeded = mediaQuery.padding.top + CupertinoTextSelectionUtils._kToolbarScreenPadding + CupertinoTextSelectionUtils._kToolbarHeight + CupertinoTextSelectionUtils._kToolbarContentDistance; float availableHeight = globalEditableRegion.top + endpoints.first().point.dy - textLineHeight; bool isArrowPointingDown = toolbarHeightNeeded <= availableHeight; float arrowTipX = (position.dx + globalEditableRegion.left).clamp( CupertinoTextSelectionUtils._kArrowScreenPadding + mediaQuery.padding.left, mediaQuery.size.width - mediaQuery.padding.right - CupertinoTextSelectionUtils._kArrowScreenPadding ); float localBarTopY = isArrowPointingDown ? endpoints.first().point.dy - textLineHeight - CupertinoTextSelectionUtils._kToolbarContentDistance - CupertinoTextSelectionUtils._kToolbarHeight : endpoints.last().point.dy + CupertinoTextSelectionUtils._kToolbarContentDistance; List <Widget> items = new List <Widget> { }; Widget onePhysicalPixelVerticalDivider = new SizedBox(width: 1.0f / MediaQuery.of(context).devicePixelRatio); CupertinoLocalizations localizations = CupertinoLocalizations.of(context); EdgeInsets arrowPadding = isArrowPointingDown ? EdgeInsets.only(bottom: CupertinoTextSelectionUtils._kToolbarArrowSize.height) : EdgeInsets.only(top: CupertinoTextSelectionUtils._kToolbarArrowSize.height); void addToolbarButtonIfNeeded( string text, Predicate predicate, OnPressed onPressed) { if (!predicate(_delegate)) { return; } if (items.isNotEmpty()) { items.Add(onePhysicalPixelVerticalDivider); } items.Add(new CupertinoButton( child: new Text(text, style: CupertinoTextSelectionUtils._kToolbarButtonFontStyle), color: CupertinoTextSelectionUtils._kToolbarBackgroundColor, minSize: CupertinoTextSelectionUtils._kToolbarHeight, padding: CupertinoTextSelectionUtils._kToolbarButtonPadding.add(arrowPadding), borderRadius: null, pressedOpacity: 0.7f, onPressed: () => onPressed(_delegate) )); } addToolbarButtonIfNeeded(localizations.cutButtonLabel, canCut, handleCut); addToolbarButtonIfNeeded(localizations.copyButtonLabel, canCopy, handleCopy); addToolbarButtonIfNeeded(localizations.pasteButtonLabel, canPaste, handlePaste); addToolbarButtonIfNeeded(localizations.selectAllButtonLabel, canSelectAll, handleSelectAll); return(new CupertinoTextSelectionToolbar( barTopY: localBarTopY + globalEditableRegion.top, arrowTipX: arrowTipX, isArrowPointingDown: isArrowPointingDown, child: items.isEmpty() ? null : new DecoratedBox( decoration: new BoxDecoration(color: CupertinoTextSelectionUtils._kToolbarDividerColor), child: new Row(mainAxisSize: MainAxisSize.min, children: items) ) )); }
public override Widget build(BuildContext context) { D.assert(WidgetsD.debugCheckHasMediaQuery(context)); ThemeData theme = Theme.of(context); TextStyle textStyle = theme.primaryTextTheme.subhead.copyWith(color: this.foregroundColor); Color effectiveBackgroundColor = this.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 (this.foregroundColor == null) { switch (ThemeData.estimateBrightnessForColor(this.backgroundColor)) { case Brightness.dark: textStyle = textStyle.copyWith(color: theme.primaryColorLight); break; case Brightness.light: textStyle = textStyle.copyWith(color: theme.primaryColorDark); break; } } float minDiameter = this._minDiameter; float maxDiameter = this._maxDiameter; return(new AnimatedContainer( constraints: new BoxConstraints( minHeight: minDiameter, minWidth: minDiameter, maxWidth: maxDiameter, maxHeight: maxDiameter ), duration: Constants.kThemeChangeDuration, decoration: new BoxDecoration( color: effectiveBackgroundColor, image: this.backgroundImage != null ? new DecorationImage(image: this.backgroundImage, fit: BoxFit.cover) : null, shape: BoxShape.circle ), child: this.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: this.child ) ) ) ) )); }