Пример #1
0
        public static Widget buildSimpleRefreshIndicator(
            BuildContext context,
            RefreshIndicatorMode refreshState,
            float pulledExtent,
            float refreshTriggerPullDistance,
            float refreshIndicatorExtent
            )
        {
            Curve opacityCurve = new Interval(0.4f, 0.8f, curve: Curves.easeInOut);

            return(new Align(
                       alignment: Alignment.bottomCenter,
                       child: new Padding(
                           padding: EdgeInsets.only(bottom: 16.0f),
                           child: refreshState == RefreshIndicatorMode.drag
                    ? new Opacity(
                               opacity: opacityCurve.transform(Mathf.Min(pulledExtent / refreshTriggerPullDistance, 1.0f)
                                                               ),
                               child: new Icon(
                                   CupertinoIcons.down_arrow,
                                   color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context),
                                   size: 36.0f
                                   )
                               )
                    : new Opacity(
                               opacity: opacityCurve.transform(
                                   Mathf.Min(pulledExtent / refreshIndicatorExtent, 1.0f)
                                   ),
                               child: new CupertinoActivityIndicator(radius: 14.0f)
                               )
                           )
                       ));
        }
Пример #2
0
        public bool opaque(BuildContext context)
        {
            Color backgroundColor =
                this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor;

            return(CupertinoDynamicColor.resolve(backgroundColor, context).alpha == 0xFF);
        }
Пример #3
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
                                   )
                               )
                           )
                       ));
        }
Пример #4
0
 public _CupertinoTextThemeDefaults resolveFrom(BuildContext context, bool nullOk = false)
 {
     return(new _CupertinoTextThemeDefaults(
                CupertinoDynamicColor.resolve(labelColor, context, nullOk: nullOk),
                CupertinoDynamicColor.resolve(inactiveGray, context, nullOk: nullOk)
                ));
 }
Пример #5
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
                    );
            }
                                   )
                               )
                           )
                       ));
        }
Пример #6
0
 public static TextStyle _resolveTextStyle(TextStyle style, BuildContext context, bool nullOk)
 {
     return(style?.copyWith(
                color: CupertinoDynamicColor.resolve(style?.color, context, nullOk: nullOk),
                backgroundColor: CupertinoDynamicColor.resolve(style?.backgroundColor, context, nullOk: nullOk),
                decorationColor: CupertinoDynamicColor.resolve(style?.decorationColor, context, nullOk: nullOk)
                ));
 }
Пример #7
0
 public override RenderObject createRenderObject(BuildContext context)
 {
     return(new _RenderCupertinoAlert(
                dividerThickness: CupertinoActionSheetUtils._kDividerThickness /
                MediaQuery.of(context).devicePixelRatio,
                dividerColor: CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kButtonDividerColor, context)
                ));
 }
Пример #8
0
        public _TextThemeDefaultsBuilder resolveFrom(BuildContext context, bool nullOk)
        {
            Color resolvedLabelColor   = CupertinoDynamicColor.resolve(labelColor, context, nullOk: nullOk);
            Color resolvedInactiveGray = CupertinoDynamicColor.resolve(inactiveGrayColor, context, nullOk: nullOk);

            return(resolvedLabelColor == labelColor && resolvedInactiveGray == CupertinoColors.inactiveGray
                ? this
                : new _TextThemeDefaultsBuilder(resolvedLabelColor, resolvedInactiveGray));
        }
Пример #9
0
 public override void updateRenderObject(BuildContext context, RenderObject renderObject)
 {
     ((_RenderCupertinoAlertActions)renderObject).dividerThickness = _dividerThickness;
     ((_RenderCupertinoAlertActions)renderObject).dividerColor     =
         CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kButtonDividerColor, context);
     ((_RenderCupertinoAlertActions)renderObject).hasCancelButton = _hasCancelButton;
     ((_RenderCupertinoAlertActions)renderObject).backgroundColor =
         CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kBackgroundColor, context);
     ((_RenderCupertinoAlertActions)renderObject).pressedColor = CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kPressedColor, context);
 }
Пример #10
0
 public override RenderObject createRenderObject(BuildContext context)
 {
     return(new _RenderCupertinoAlertActions(
                dividerThickness: _dividerThickness,
                dividerColor: CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kButtonDividerColor, context),
                hasCancelButton: _hasCancelButton,
                backgroundColor: CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kBackgroundColor, context),
                pressedColor: CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kPressedColor, context)
                ));
 }
Пример #11
0
        public new _NoDefaultCupertinoThemeData resolveFrom(BuildContext context, bool nullOk = false)
        {
            Color convertColor(Color color) => CupertinoDynamicColor.resolve(color, context, nullOk: nullOk);

            return(new _NoDefaultCupertinoThemeData(
                       brightness,
                       convertColor(primaryColor),
                       convertColor(primaryContrastingColor),
                       textTheme?.resolveFrom(context, nullOk: nullOk),
                       convertColor(barBackgroundColor),
                       convertColor(scaffoldBackgroundColor)
                       ));
        }
Пример #12
0
        public _CupertinoThemeDefaults resolveFrom(BuildContext context, bool resolveTextTheme, bool nullOk = false)
        {
            Color convertColor(Color color) => CupertinoDynamicColor.resolve(color, context, nullOk: nullOk);

            return(new _CupertinoThemeDefaults(
                       brightness: brightness,
                       primaryColor: convertColor(primaryColor),
                       primaryContrastingColor: convertColor(primaryContrastingColor),
                       barBackgroundColor: convertColor(barBackgroundColor),
                       scaffoldBackgroundColor: convertColor(scaffoldBackgroundColor),
                       textThemeDefaults: resolveTextTheme ? textThemeDefaults?.resolveFrom(context, nullOk: nullOk) : textThemeDefaults
                       ));
        }
Пример #13
0
        public CupertinoThemeData resolveFrom(BuildContext context, bool nullOk = false)
        {
            Color convertColor(Color color) => CupertinoDynamicColor.resolve(color, context, nullOk: nullOk);

            return(new CupertinoThemeData(
                       brightness: brightness,
                       primaryColor: convertColor(_primaryColor),
                       primaryContrastingColor: convertColor(_primaryContrastingColor),
                       textTheme: _textTheme?.resolveFrom(context, nullOk: nullOk),
                       barBackgroundColor: convertColor(_barBackgroundColor),
                       scaffoldBackgroundColor: convertColor(_scaffoldBackgroundColor),
                       defaults: _defaults.resolveFrom(context, _textTheme == null, nullOk: nullOk)
                       ));
        }
Пример #14
0
        public override void updateRenderObject(BuildContext context, RenderObject _renderObject)
        {
            _RenderCupertinoSlider renderObject = _renderObject as _RenderCupertinoSlider;

            renderObject.value         = value ?? 0.0f;
            renderObject.divisions     = divisions;
            renderObject.activeColor   = activeColor;
            renderObject.thumbColor    = CupertinoDynamicColor.resolve(thumbColor, context);
            renderObject.trackColor    = CupertinoDynamicColor.resolve(CupertinoColors.systemFill, context);
            renderObject.onChanged     = onChanged;
            renderObject.onChangeStart = onChangeStart;
            renderObject.onChangeEnd   = onChangeEnd;
            renderObject.textDirection = Directionality.of(context);
        }
Пример #15
0
 public override Widget build(BuildContext context)
 {
     return(new SizedBox(
                height: widget.radius * 2,
                width: widget.radius * 2,
                child: new CustomPaint(
                    painter: new _CupertinoActivityIndicatorPainter(
                        position: _controller,
                        activeColor: CupertinoDynamicColor.resolve(CupertinoActivityIndicatorUtils._kActiveTickColor, context),
                        radius: widget.radius
                        )
                    )
                ));
 }
Пример #16
0
 public ScrollbarPainter _buildCupertinoScrollbarPainter(BuildContext context)
 {
     return(new ScrollbarPainter(
                color: CupertinoDynamicColor.resolve(CupertinoScrollbarUtils._kScrollbarColor, context),
                textDirection: Directionality.of(context),
                thickness: _thickness,
                fadeoutOpacityAnimation: _fadeoutOpacityAnimation,
                mainAxisMargin: CupertinoScrollbarUtils._kScrollbarMainAxisMargin,
                crossAxisMargin: CupertinoScrollbarUtils._kScrollbarCrossAxisMargin,
                radius: _radius,
                padding: MediaQuery.of(context).padding,
                minLength: CupertinoScrollbarUtils._kScrollbarMinLength,
                minOverscrollLength: CupertinoScrollbarUtils._kScrollbarMinOverscrollLength
                ));
 }
Пример #17
0
 public CupertinoTextThemeData resolveFrom(BuildContext context, bool nullOk = false)
 {
     return(new CupertinoTextThemeData(
                _defaults?.resolveFrom(context, nullOk),
                CupertinoDynamicColor.resolve(_primaryColor, context, nullOk: nullOk),
                CupertinoTextThemeDataUtils._resolveTextStyle(_textStyle, context, nullOk),
                CupertinoTextThemeDataUtils._resolveTextStyle(_actionTextStyle, context, nullOk),
                CupertinoTextThemeDataUtils._resolveTextStyle(_tabLabelTextStyle, context, nullOk),
                CupertinoTextThemeDataUtils._resolveTextStyle(_navTitleTextStyle, context, nullOk),
                CupertinoTextThemeDataUtils._resolveTextStyle(_navLargeTitleTextStyle, context, nullOk),
                CupertinoTextThemeDataUtils._resolveTextStyle(_navActionTextStyle, context, nullOk),
                CupertinoTextThemeDataUtils._resolveTextStyle(_pickerTextStyle, context, nullOk),
                CupertinoTextThemeDataUtils._resolveTextStyle(_dateTimePickerTextStyle, context, nullOk)
                ));
 }
Пример #18
0
 public override RenderObject createRenderObject(BuildContext context)
 {
     return(new _RenderCupertinoSlider(
                value: value ?? 0.0f,
                divisions: divisions,
                activeColor: activeColor,
                thumbColor: CupertinoDynamicColor.resolve(thumbColor, context),
                trackColor: CupertinoDynamicColor.resolve(CupertinoColors.systemFill, context),
                onChanged: onChanged,
                onChangeStart: onChangeStart,
                onChangeEnd: onChangeEnd,
                vsync: vsync,
                textDirection: Directionality.of(context)
                ));
 }
Пример #19
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
                ));
 }
Пример #20
0
 public static Future <T> showCupertinoModalPopup <T>(
     BuildContext context  = null,
     WidgetBuilder builder = null,
     ImageFilter filter    = null,
     bool?useRootNavigator = true
     )
 {
     D.assert(useRootNavigator != null);
     return(Navigator.of(context, rootNavigator: useRootNavigator.Value).push(
                new _CupertinoModalPopupRoute(
                    barrierColor: CupertinoDynamicColor.resolve(_kModalBarrierColor, context),
                    barrierLabel: "Dismiss",
                    builder: builder,
                    filter: filter
                    )
                ).to <T>());
 }
Пример #21
0
 public static Future showCupertinoModalPopup(
     BuildContext context      = null,
     WidgetBuilder builder     = null,
     ImageFilter filter        = null,
     bool useRootNavigator     = true,
     bool?semanticsDismissible = null
     )
 {
     return(Navigator.of(context, rootNavigator: useRootNavigator).push(
                new _CupertinoModalPopupRoute(
                    barrierColor: CupertinoDynamicColor.resolve(_kModalBarrierColor, context),
                    barrierLabel: "Dismiss",
                    builder: builder,
                    filter: filter
                    )
                ));
 }
Пример #22
0
        Widget _wrapActiveItem(BuildContext context, Widget item, bool active)
        {
            if (!active)
            {
                return(item);
            }
            Color activeColor = CupertinoDynamicColor.resolve(
                this.activeColor ?? CupertinoTheme.of(context).primaryColor,
                context
                );

            return(IconTheme.merge(
                       data: new IconThemeData(color: activeColor),
                       child: DefaultTextStyle.merge(
                           style: new TextStyle(color: activeColor),
                           child: item
                           )
                       ));
        }
Пример #23
0
        public override Widget build(BuildContext context)
        {
            Color backgroundColor = isBeingPressed
                ? CupertinoActionSheetUtils._kCancelPressedColor
                : CupertinoColors.secondarySystemGroupedBackground;

            return(new GestureDetector(
                       onTapDown: _onTapDown,
                       onTapUp: _onTapUp,
                       onTapCancel: _onTapCancel,
                       child: new Container(
                           decoration: new BoxDecoration(
                               color: CupertinoDynamicColor.resolve(backgroundColor, context),
                               borderRadius: BorderRadius.circular(CupertinoActionSheetUtils._kCornerRadius)
                               ),
                           child: widget.child
                           )
                       ));
        }
Пример #24
0
        Widget _buildMagnifierScreen()
        {
            Color resolvedBorderColor = CupertinoDynamicColor.resolve(CupertinoPickerUtils._kHighlighterBorder, context);

            return(new IgnorePointer(
                       child: new Center(
                           child: new Container(
                               decoration: new BoxDecoration(
                                   border: new Border(
                                       top: new BorderSide(width: 0.0f, color: resolvedBorderColor),
                                       bottom: new BorderSide(width: 0.0f, color: resolvedBorderColor)
                                       )
                                   ),
                               constraints: BoxConstraints.expand(
                                   height: widget.itemExtent * widget.magnification
                                   )
                               )
                           )
                       ));
        }
Пример #25
0
 public override Widget build(BuildContext context)
 {
     if (needsPositionAnimation)
     {
         _resumePositionAnimation();
     }
     return(new Opacity(
                opacity: widget.onChanged == null ? CupertinoSwitchUtils._kCupertinoSwitchDisabledOpacity : 1.0f,
                child: new _CupertinoSwitchRenderObjectWidget(
                    value: widget.value,
                    activeColor: CupertinoDynamicColor.resolve(
                        widget.activeColor ?? CupertinoColors.systemGreen,
                        context
                        ),
                    trackColor: CupertinoDynamicColor.resolve(widget.trackColor ?? CupertinoColors.secondarySystemFill, context),
                    onChanged: widget.onChanged,
                    textDirection: Directionality.of(context),
                    state: this
                    )
                ));
 }
Пример #26
0
 public override void didChangeDependencies()
 {
     base.didChangeDependencies();
     if (_painter == null)
     {
         _painter = _buildCupertinoScrollbarPainter(context);
     }
     else
     {
         _painter.textDirection = Directionality.of(context);
         _painter.color         = CupertinoDynamicColor.resolve(CupertinoScrollbarUtils._kScrollbarColor, context);
         _painter.padding       = MediaQuery.of(context).padding;
     }
     WidgetsBinding.instance.addPostFrameCallback((TimeSpan duration) => {
         if (widget.isAlwaysShown)
         {
             D.assert(widget.controller != null);
             widget.controller.position.didUpdateScrollPositionBy(0);
         }
     });
 }
Пример #27
0
        public static Future showCupertinoDialog(
            BuildContext context        = null,
            WidgetBuilder builder       = null,
            bool useRootNavigator       = true,
            RouteSettings routeSettings = null
            )
        {
            D.assert(builder != null);

            return(DialogUtils.showGeneralDialog <object>(
                       context: context,
                       barrierDismissible: false,
                       barrierColor: CupertinoDynamicColor.resolve(_kModalBarrierColor, context),
                       transitionDuration: TimeSpan.FromMilliseconds(250),
                       pageBuilder: (BuildContext context1, Animation <float> animation, Animation <float> secondaryAnimation) => {
                return builder(context1);
            },
                       transitionBuilder: _buildCupertinoDialogTransitions,
                       useRootNavigator: useRootNavigator,
                       routeSettings: routeSettings
                       ));
        }
Пример #28
0
        Widget _buildContent(BuildContext context)
        {
            List <Widget> content = new List <Widget>();

            if (title != null || message != null)
            {
                Widget titleSection = new _CupertinoAlertContentSection(
                    title: title,
                    message: message,
                    scrollController: messageScrollController
                    );
                content.Add(new Flexible(child: titleSection));
            }

            return(new Container(
                       color:  CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kBackgroundColor, context),
                       child: new Column(
                           mainAxisSize: MainAxisSize.min,
                           crossAxisAlignment: CrossAxisAlignment.stretch,
                           children: content
                           )
                       ));
        }
Пример #29
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
                       ));
        }
Пример #30
0
 public override void updateRenderObject(BuildContext context, RenderObject renderObject)
 {
     renderObject = (_RenderCupertinoAlert)renderObject;
     base.updateRenderObject(context, renderObject);
     ((_RenderCupertinoAlert)renderObject).dividerColor = CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kButtonDividerColor, context);
 }