Ejemplo n.º 1
0
        public override Widget build(BuildContext context)
        {
            TextStyle style = CupertinoActionSheetUtils._kActionSheetActionStyle.copyWith(
                color: isDestructiveAction
                    ? CupertinoDynamicColor.resolve(CupertinoColors.systemRed, context)
                    : CupertinoTheme.of(context).primaryColor);

            if (isDefaultAction)
            {
                style = style.copyWith(fontWeight: FontWeight.w600);
            }

            return(new GestureDetector(
                       onTap: () => onPressed(),
                       behavior: HitTestBehavior.opaque,
                       child: new ConstrainedBox(
                           constraints: new BoxConstraints(
                               minHeight: CupertinoActionSheetUtils._kButtonHeight
                               ),
                           child: new Container(
                               alignment: Alignment.center,
                               padding: EdgeInsets.symmetric(
                                   vertical: 16.0f,
                                   horizontal: 10.0f
                                   ),
                               child: new DefaultTextStyle(
                                   style: style,
                                   child: child,
                                   textAlign: TextAlign.center
                                   )
                               )
                           )
                       ));
        }
Ejemplo n.º 2
0
        public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight)
        {
            Size   desiredSize = getHandleSize(textLineHeight);
            Widget handle      = SizedBox.fromSize(
                size: desiredSize,
                child: new CustomPaint(
                    painter: new _TextSelectionHandlePainter(CupertinoTheme.of(context).primaryColor)
                    )
                );
            var result = Matrix4.identity();

            result.translate(desiredSize.width / 2, desiredSize.height / 2);
            result.rotateZ(Mathf.PI);
            result.translate(-desiredSize.width / 2, -desiredSize.height / 2);
            switch (type)
            {
            case TextSelectionHandleType.left:
                return(handle);

            case TextSelectionHandleType.right:
                return(new Transform(
                           transform: result,
                           child: handle
                           ));

            case TextSelectionHandleType.collapsed:
                return(new SizedBox());
            }
            D.assert(type != null);
            return(null);
        }
        public bool opaque(BuildContext context)
        {
            Color backgroundColor =
                this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor;

            return(backgroundColor.alpha == 0xFF);
        }
Ejemplo n.º 4
0
        public override Widget build(BuildContext context)
        {
            CupertinoThemeData effectiveThemeData = widget.theme ?? new CupertinoThemeData();

            return(new ScrollConfiguration(
                       behavior: new _AlwaysCupertinoScrollBehavior(),
                       child: new CupertinoUserInterfaceLevel(
                           data: CupertinoUserInterfaceLevelData.baselayer,
                           child: new CupertinoTheme(
                               data: effectiveThemeData,
                               child: new Builder(
                                   builder: (BuildContext context1) => {
                return new WidgetsApp(
                    key: new GlobalObjectKey <State <StatefulWidget> >(value: this),
                    navigatorKey: widget.navigatorKey,
                    navigatorObservers: _navigatorObservers,
                    pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
                    new CupertinoPageRoute(settings: settings, builder: builder),
                    home: widget.home,
                    routes: widget.routes,
                    initialRoute: widget.initialRoute,
                    onGenerateRoute: widget.onGenerateRoute,
                    onGenerateInitialRoutes: widget.onGenerateInitialRoutes,
                    onUnknownRoute: widget.onUnknownRoute,
                    builder: widget.builder,
                    title: widget.title,
                    onGenerateTitle: widget.onGenerateTitle,
                    textStyle: CupertinoTheme.of(context1).textTheme.textStyle,
                    color: CupertinoDynamicColor.resolve(widget.color ?? effectiveThemeData.primaryColor, context1),
                    locale: widget.locale,
                    localizationsDelegates: _localizationsDelegates,
                    localeResolutionCallback: widget.localeResolutionCallback,
                    localeListResolutionCallback: widget.localeListResolutionCallback,
                    supportedLocales: widget.supportedLocales,
                    showPerformanceOverlay: widget.showPerformanceOverlay,
                    checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages,
                    checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers,
                    showSemanticsDebugger: widget.showSemanticsDebugger,
                    debugShowCheckedModeBanner: widget.debugShowCheckedModeBanner,
                    inspectorSelectButtonBuilder: (BuildContext context3, VoidCallback onPressed) => {
                    return CupertinoButton.filled(
                        child: new Icon(
                            CupertinoIcons.search,
                            size: 28.0f,
                            color: CupertinoColors.white
                            ),
                        padding: EdgeInsets.zero,
                        onPressed: onPressed
                        );
                },
                    shortcuts: widget.shortcuts,
                    actions: widget.actions
                    );
            }
                                   )
                               )
                           )
                       ));
        }
Ejemplo n.º 5
0
 public _InheritedCupertinoTheme(
     Key key = null,
     CupertinoTheme theme = null,
     Widget child         = null
     ) : base(key: key, child: child)
 {
     D.assert(theme != null);
     this.theme = theme;
 }
Ejemplo n.º 6
0
 public override Widget build(BuildContext context)
 {
     return(new _CupertinoSliderRenderObjectWidget(
                value: (this.widget.value - this.widget.min) / (this.widget.max - this.widget.min),
                divisions: this.widget.divisions,
                activeColor: this.widget.activeColor ?? CupertinoTheme.of(context).primaryColor,
                onChanged: this.widget.onChanged != null ? (ValueChanged <float>) this._handleChanged : null,
                onChangeStart: this.widget.onChangeStart != null ? (ValueChanged <float>) this._handleDragStart : null,
                onChangeEnd: this.widget.onChangeEnd != null ? (ValueChanged <float>) this._handleDragEnd : null,
                vsync: this
                ));
 }
Ejemplo n.º 7
0
 public override Widget build(BuildContext context)
 {
     return(new _CupertinoSliderRenderObjectWidget(
                value: (widget.value - widget.min) / (widget.max - widget.min),
                divisions: widget.divisions,
                activeColor: CupertinoDynamicColor.resolve(
                    widget.activeColor ?? CupertinoTheme.of(context).primaryColor,
                    context
                    ),
                thumbColor: widget.thumbColor,
                onChanged: widget.onChanged != null ? (ValueChanged <float>)_handleChanged : null,
                onChangeStart: widget.onChangeStart != null ? (ValueChanged <float>)_handleDragStart : null,
                onChangeEnd: widget.onChangeEnd != null ? (ValueChanged <float>)_handleDragEnd : null,
                vsync: this
                ));
 }
Ejemplo n.º 8
0
        bool _updateColors()
        {
            D.assert(mounted, () => "This should only be called after didUpdateDependencies");
            bool  changed       = false;
            Color selectedColor = widget.selectedColor ?? CupertinoTheme.of(context).primaryColor;

            if (_selectedColor != selectedColor)
            {
                changed        = true;
                _selectedColor = selectedColor;
            }
            Color unselectedColor = widget.unselectedColor ?? CupertinoTheme.of(context).primaryContrastingColor;

            if (_unselectedColor != unselectedColor)
            {
                changed          = true;
                _unselectedColor = unselectedColor;
            }
            Color borderColor = widget.borderColor ?? CupertinoTheme.of(context).primaryColor;

            if (_borderColor != borderColor)
            {
                changed      = true;
                _borderColor = borderColor;
            }
            Color pressedColor = widget.pressedColor ?? CupertinoTheme.of(context).primaryColor.withOpacity(0.2f);

            if (_pressedColor != pressedColor)
            {
                changed       = true;
                _pressedColor = pressedColor;
            }

            _forwardBackgroundColorTween = new ColorTween(
                begin: _pressedColor,
                end: _selectedColor
                );
            _reverseBackgroundColorTween = new ColorTween(
                begin: _unselectedColor,
                end: _selectedColor
                );
            _textColorTween = new ColorTween(
                begin: _selectedColor,
                end: _unselectedColor
                );
            return(changed);
        }
        Widget _wrapActiveItem(BuildContext context, Widget item, bool active)
        {
            if (!active)
            {
                return(item);
            }

            Color activeColor = this.activeColor ?? CupertinoTheme.of(context).primaryColor;

            return(IconTheme.merge(
                       data: new IconThemeData(color: activeColor),
                       child: DefaultTextStyle.merge(
                           style: new TextStyle(color: activeColor),
                           child: item
                           )
                       ));
        }
        public override Widget build(BuildContext context)
        {
            float bottomPadding = MediaQuery.of(context).padding.bottom;

            Widget result = new DecoratedBox(
                decoration: new BoxDecoration(
                    border: this.border,
                    color: this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor
                    ),
                child: new SizedBox(
                    height: BottomAppBarUtils._kTabBarHeight + bottomPadding,
                    child: IconTheme.merge( // Default with the inactive state.
                        data: new IconThemeData(
                            color: this.inactiveColor,
                            size: this.iconSize
                            ),
                        child: new DefaultTextStyle( // Default with the inactive state.
                            style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle
                            .copyWith(color: this.inactiveColor),
                            child: new Padding(
                                padding: EdgeInsets.only(bottom: bottomPadding),
                                child: new Row(
                                    crossAxisAlignment: CrossAxisAlignment.end,
                                    children: this._buildTabItems(context)
                                    )
                                )
                            )
                        )
                    )
                );

            if (!this.opaque(context))
            {
                result = new ClipRect(
                    child: new BackdropFilter(
                        filter: ImageFilter.blur(sigmaX: 10.0f, sigmaY: 10.0f),
                        child: result
                        )
                    );
            }

            return(result);
        }
Ejemplo n.º 11
0
        public override Widget build(BuildContext context)
        {
            Color resolvedBackgroundColor = CupertinoDynamicColor.resolve(widget.backgroundColor, context);

            Widget result = new DefaultTextStyle(
                style: CupertinoTheme.of(context).textTheme.pickerTextStyle,
                child: new Stack(
                    children: new List <Widget> {
                Positioned.fill(
                    child: new _CupertinoPickerSemantics(
                        scrollController: widget.scrollController ?? _controller,
                        child: new ListWheelScrollView(
                            controller: widget.scrollController ?? _controller,
                            physics: new FixedExtentScrollPhysics(),
                            diameterRatio: widget.diameterRatio ?? RenderListWheelViewport.defaultDiameterRatio,
                            perspective: CupertinoPickerUtils._kDefaultPerspective,
                            offAxisFraction: widget.offAxisFraction,
                            useMagnifier: widget.useMagnifier,
                            magnification: widget.magnification,
                            overAndUnderCenterOpacity: CupertinoPickerUtils._kOverAndUnderCenterOpacity,
                            itemExtent: widget.itemExtent,
                            squeeze: widget.squeeze ?? CupertinoPickerUtils._kSqueeze,
                            onSelectedItemChanged: _handleSelectedItemChanged,
                            childDelegate: widget.childDelegate
                            )
                        )
                    ),
                _buildMagnifierScreen(),
            }
                    )
                );

            return(new DecoratedBox(
                       decoration: new BoxDecoration(color: resolvedBackgroundColor),
                       child: result
                       ));
        }
Ejemplo n.º 12
0
        public CupertinoDynamicColor resolveFrom(BuildContext context, bool nullOk = true)
        {
            Brightness brightness = _isPlatformBrightnessDependent
                ? CupertinoTheme.brightnessOf(context, nullOk: nullOk) ?? Brightness.light
                : Brightness.light;

            bool isHighContrastEnabled = _isHighContrastDependent &&
                                         (MediaQuery.of(context, nullOk: nullOk)?.highContrast ?? false);

            CupertinoUserInterfaceLevelData level = _isInterfaceElevationDependent
                ? CupertinoUserInterfaceLevel.of(context, nullOk: nullOk) ?? CupertinoUserInterfaceLevelData.baselayer
                : CupertinoUserInterfaceLevelData.baselayer;

            Color resolved = null;

            switch (brightness)
            {
            case Brightness.light:
                switch (level)
                {
                case CupertinoUserInterfaceLevelData.baselayer:
                    resolved = isHighContrastEnabled ? highContrastColor : color;
                    break;

                case CupertinoUserInterfaceLevelData.elevatedlayer:
                    resolved = isHighContrastEnabled ? highContrastElevatedColor : elevatedColor;
                    break;
                }

                break;

            case Brightness.dark:
                switch (level)
                {
                case CupertinoUserInterfaceLevelData.baselayer:
                    resolved = isHighContrastEnabled ? darkHighContrastColor : darkColor;
                    break;

                case CupertinoUserInterfaceLevelData.elevatedlayer:
                    resolved = isHighContrastEnabled ? darkHighContrastElevatedColor : darkElevatedColor;
                    break;
                }

                break;
            }

            Element _debugContext = null;

            D.assert(() => {
                _debugContext = context as Element;
                return(true);
            }
                     );

            return(new CupertinoDynamicColor(
                       debugLabel: _debugLabel,
                       effectiveColor: resolved,
                       color: color,
                       darkColor: darkColor,
                       highContrastColor: highContrastColor,
                       darkHighContrastColor: darkHighContrastColor,
                       elevatedColor: color,
                       darkElevatedColor: darkColor,
                       highContrastElevatedColor: highContrastColor,
                       darkHighContrastElevatedColor: darkHighContrastColor,
                       debugResolveContext: null
                       ));
        }
Ejemplo n.º 13
0
        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
                                                   )
                                               )
                                           )
                                       )
                                   )
                               )
                           )
                       ));
        }
Ejemplo n.º 14
0
        public override Widget build(BuildContext context)
        {
            List <Widget> stacked = new List <Widget> {
            };

            MediaQueryData existingMediaQuery = MediaQuery.of(context);
            MediaQueryData newMediaQuery      = MediaQuery.of(context);

            Widget content = new _TabSwitchingView(
                currentTabIndex: _controller.index,
                tabNumber: widget.tabBar.items.Count,
                tabBuilder: widget.tabBuilder
                );
            EdgeInsets contentPadding = EdgeInsets.zero;

            if (widget.resizeToAvoidBottomInset)
            {
                newMediaQuery  = newMediaQuery.removeViewInsets(removeBottom: true);
                contentPadding = EdgeInsets.only(bottom: existingMediaQuery.viewInsets.bottom);
            }

            if (widget.tabBar != null &&
                (!widget.resizeToAvoidBottomInset ||
                 widget.tabBar.preferredSize.height > existingMediaQuery.viewInsets.bottom))
            {
                float bottomPadding = widget.tabBar.preferredSize.height + existingMediaQuery.padding.bottom;

                if (widget.tabBar.opaque(context))
                {
                    contentPadding = EdgeInsets.only(bottom: bottomPadding);
                    newMediaQuery  = newMediaQuery.removePadding(removeBottom: true);
                }
                else
                {
                    newMediaQuery = newMediaQuery.copyWith(
                        padding: newMediaQuery.padding.copyWith(
                            bottom: bottomPadding
                            )
                        );
                }
            }

            content = new MediaQuery(
                data: newMediaQuery,
                child: new Padding(
                    padding: contentPadding,
                    child: content
                    )
                );
            stacked.Add(content);
            stacked.Add(
                new MediaQuery(
                    data: existingMediaQuery.copyWith(textScaleFactor: 1),
                    child: new Align(
                        alignment: Alignment.bottomCenter,
                        child: widget.tabBar.copyWith(
                            currentIndex: _controller.index,
                            onTap: (int newIndex) => {
                _controller.index = newIndex;
                if (widget.tabBar.onTap != null)
                {
                    widget.tabBar.onTap(newIndex);
                }
            }
                            )
                        )
                    )
                );

            return(new DecoratedBox(
                       decoration: new BoxDecoration(
                           color: CupertinoDynamicColor.resolve(widget.backgroundColor, context)
                           ?? CupertinoTheme.of(context).scaffoldBackgroundColor
                           ),
                       child: new Stack(
                           children: stacked
                           )
                       ));
        }
Ejemplo n.º 15
0
        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)
                                   )
                               )
                           )

                       ));
        }
Ejemplo n.º 16
0
        public override Widget build(BuildContext context)
        {
            Widget paddedContent = widget.child;

            MediaQueryData existingMediaQuery = MediaQuery.of(context);

            if (widget.navigationBar != null)
            {
                float topPadding = widget.navigationBar.preferredSize.height + existingMediaQuery.padding.top;

                float bottomPadding = widget.resizeToAvoidBottomInset
                    ? existingMediaQuery.viewInsets.bottom
                    : 0.0f;

                EdgeInsets newViewInsets = widget.resizeToAvoidBottomInset
                    ? existingMediaQuery.viewInsets.copyWith(bottom: 0.0f)
                    : existingMediaQuery.viewInsets;

                bool fullObstruction = widget.navigationBar.shouldFullyObstruct(context);

                if (fullObstruction == true)
                {
                    paddedContent = new MediaQuery(
                        data: existingMediaQuery
                        .removePadding(removeTop: true)
                        .copyWith(
                            viewInsets: newViewInsets
                            ),
                        child: new Padding(
                            padding: EdgeInsets.only(top: topPadding, bottom: bottomPadding),
                            child: paddedContent
                            )
                        );
                }
                else
                {
                    paddedContent = new MediaQuery(
                        data: existingMediaQuery.copyWith(
                            padding: existingMediaQuery.padding.copyWith(
                                top: topPadding
                                ),
                            viewInsets: newViewInsets
                            ),
                        child: new Padding(
                            padding: EdgeInsets.only(bottom: bottomPadding),
                            child: paddedContent
                            )
                        );
                }
            }
            else
            {
                float bottomPadding = widget.resizeToAvoidBottomInset
                    ? existingMediaQuery.viewInsets.bottom
                    : 0.0f;
                paddedContent = new Padding(
                    padding: EdgeInsets.only(bottom: bottomPadding),
                    child: paddedContent
                    );
            }
            List <Widget> childrenWigets = new List <Widget>();

            childrenWigets.Add(new PrimaryScrollController(
                                   controller: _primaryScrollController,
                                   child: paddedContent
                                   ));
            if (widget.navigationBar != null)
            {
                childrenWigets.Add(new Positioned(
                                       top: 0.0f,
                                       left: 0.0f,
                                       right: 0.0f,
                                       child: new MediaQuery(
                                           data: existingMediaQuery.copyWith(textScaleFactor: 1),
                                           child: widget.navigationBar
                                           )
                                       ));
            }
            childrenWigets.Add(new Positioned(
                                   top: 0.0f,
                                   left: 0.0f,
                                   right: 0.0f,
                                   height: existingMediaQuery.padding.top,
                                   child: new GestureDetector(
                                       onTap: _handleStatusBarTap
                                       )

                                   ));

            return(new DecoratedBox(
                       decoration: new BoxDecoration(
                           color: CupertinoDynamicColor.resolve(widget.backgroundColor, context)
                           ?? CupertinoTheme.of(context).scaffoldBackgroundColor
                           ),
                       child: new Stack(
                           children: childrenWigets)));
        }
Ejemplo n.º 17
0
        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
                                                   )
                                               )
                                           )
                                       )
                                   )
                               )
                           )
                       ));
        }
Ejemplo n.º 18
0
        public override Widget build(BuildContext context)
        {
            float bottomPadding   = MediaQuery.of(context).padding.bottom;
            Color backgroundColor = CupertinoDynamicColor.resolve(
                this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor,
                context
                );

            BorderSide resolveBorderSide(BorderSide side)
            {
                return(side == BorderSide.none
                    ? side
                    : side.copyWith(color: CupertinoDynamicColor.resolve(side.color, context)));
            }

            Border resolvedBorder = border == null || border.GetType() != typeof(Border)
                ? border
                : new Border(
                top: resolveBorderSide(border.top),
                left: resolveBorderSide(border.left),
                bottom: resolveBorderSide(border.bottom),
                right: resolveBorderSide(border.right)
                );

            Color  inactive = CupertinoDynamicColor.resolve(inactiveColor, context);
            Widget result   = new DecoratedBox(
                decoration: new BoxDecoration(
                    border: resolvedBorder,
                    color: backgroundColor
                    ),
                child: new SizedBox(
                    height: BottomAppBarUtils._kTabBarHeight + bottomPadding,
                    child: IconTheme.merge( // Default with the inactive state.
                        data: new IconThemeData(
                            color: inactiveColor,
                            size: iconSize
                            ),
                        child: new DefaultTextStyle( // Default with the inactive state.
                            style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(color: inactive),
                            child: new Padding(
                                padding: EdgeInsets.only(bottom: bottomPadding),
                                child: new Row(
                                    crossAxisAlignment: CrossAxisAlignment.end,
                                    children: _buildTabItems(context)
                                    )
                                )
                            )
                        )
                    )
                );

            if (!opaque(context))
            {
                result = new ClipRect(
                    child: new BackdropFilter(
                        filter: ImageFilter.blur(sigmaX: 10.0f, sigmaY: 10.0f),
                        child: result
                        )
                    );
            }

            return(result);
        }
Ejemplo n.º 19
0
        public override Widget build(BuildContext context)
        {
            List <Widget> stacked = new List <Widget>();

            Widget paddedContent = this.widget.child;

            MediaQueryData existingMediaQuery = MediaQuery.of(context);

            if (this.widget.navigationBar != null)
            {
                float topPadding = this.widget.navigationBar.preferredSize.height + existingMediaQuery.padding.top;

                float bottomPadding = this.widget.resizeToAvoidBottomInset
                    ? existingMediaQuery.viewInsets.bottom
                    : 0.0f;

                EdgeInsets newViewInsets = this.widget.resizeToAvoidBottomInset
                    ? existingMediaQuery.viewInsets.copyWith(bottom: 0.0f)
                    : existingMediaQuery.viewInsets;

                bool?fullObstruction =
                    this.widget.navigationBar.fullObstruction == false
                        ? CupertinoTheme.of(context).barBackgroundColor.alpha == 0xFF
                        : this.widget.navigationBar.fullObstruction;

                if (fullObstruction == true)
                {
                    paddedContent = new MediaQuery(
                        data: existingMediaQuery
                        .removePadding(removeTop: true)
                        .copyWith(
                            viewInsets: newViewInsets
                            ),
                        child: new Padding(
                            padding: EdgeInsets.only(top: topPadding, bottom: bottomPadding),
                            child: paddedContent
                            )
                        );
                }
                else
                {
                    paddedContent = new MediaQuery(
                        data: existingMediaQuery.copyWith(
                            padding: existingMediaQuery.padding.copyWith(
                                top: topPadding
                                ),
                            viewInsets: newViewInsets
                            ),
                        child: new Padding(
                            padding: EdgeInsets.only(bottom: bottomPadding),
                            child: paddedContent
                            )
                        );
                }
            }

            stacked.Add(new PrimaryScrollController(
                            controller: this._primaryScrollController,
                            child: paddedContent
                            ));

            if (this.widget.navigationBar != null)
            {
                stacked.Add(new Positioned(
                                top: 0.0f,
                                left: 0.0f,
                                right: 0.0f,
                                child: this.widget.navigationBar
                                ));
            }

            stacked.Add(new Positioned(
                            top: 0.0f,
                            left: 0.0f,
                            right: 0.0f,
                            height: existingMediaQuery.padding.top,
                            child: new GestureDetector(
                                onTap: this._handleStatusBarTap
                                )
                            )
                        );

            return(new DecoratedBox(
                       decoration: new BoxDecoration(
                           color: this.widget.backgroundColor ?? CupertinoTheme.of(context).scaffoldBackgroundColor
                           ),
                       child: new Stack(
                           children: stacked
                           )
                       ));
        }
Ejemplo n.º 20
0
        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)
                                   )
                               )
                           )
                       ));
        }