Exemple #1
0
 public CupertinoPicker(
     List <Widget> children,
     float itemExtent,
     Key key               = null,
     float?diameterRatio   = null,
     Color backgroundColor = null,
     float offAxisFraction = 0.0f,
     bool useMagnifier     = false,
     float magnification   = 1.0f,
     FixedExtentScrollController scrollController = null,
     float?squeeze = null,
     ValueChanged <int> onSelectedItemChanged = null,
     bool looping = false
     ) : base(key: key)
 {
     diameterRatio = diameterRatio == null ? CupertinoPickerUtils._kDefaultDiameterRatio : diameterRatio;
     squeeze       = squeeze == null ? CupertinoPickerUtils._kSqueeze : squeeze;
     // D.assert(children != null);
     D.assert(diameterRatio > 0.0f, () => RenderListWheelViewport.diameterRatioZeroMessage);
     D.assert(magnification > 0);
     D.assert(itemExtent > 0);
     D.assert(squeeze > 0);
     this.diameterRatio         = diameterRatio;
     this.backgroundColor       = backgroundColor;
     this.offAxisFraction       = offAxisFraction;
     this.useMagnifier          = useMagnifier;
     this.magnification         = magnification;
     this.scrollController      = scrollController;
     this.squeeze               = squeeze;
     this.itemExtent            = itemExtent;
     this.onSelectedItemChanged = onSelectedItemChanged;
     childDelegate              = looping
         ? (ListWheelChildDelegate) new ListWheelChildLoopingListDelegate(children: children)
         : new ListWheelChildListDelegate(children: children);
 }
Exemple #2
0
        public CupertinoPicker(
            float itemExtent,
            Key key               = null,
            float?diameterRatio   = null,
            Color backgroundColor = null,
            float offAxisFraction = 0.0f,
            bool useMagnifier     = false,
            float magnification   = 1.0f,
            FixedExtentScrollController scrollController = null,
            float?squeeze = null,

            ValueChanged <int> onSelectedItemChanged = null,
            IndexedWidgetBuilder itemBuilder         = null,
            int?childCount = null
            )
        {
            diameterRatio = diameterRatio == null ? CupertinoPickerUtils._kDefaultDiameterRatio : diameterRatio;
            squeeze       = squeeze == null ?  CupertinoPickerUtils._kSqueeze : squeeze;
            D.assert(itemBuilder != null);
            D.assert(diameterRatio > 0.0f, () => RenderListWheelViewport.diameterRatioZeroMessage);
            D.assert(magnification > 0);
            D.assert(itemExtent > 0);
            D.assert(squeeze > 0);
            this.diameterRatio         = diameterRatio;
            this.backgroundColor       = backgroundColor;
            this.offAxisFraction       = offAxisFraction;
            this.useMagnifier          = useMagnifier;
            this.magnification         = magnification;
            this.scrollController      = scrollController;
            this.squeeze               = squeeze;
            this.itemExtent            = itemExtent;
            this.onSelectedItemChanged = onSelectedItemChanged;
            childDelegate              = new ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount);
        }
Exemple #3
0
        public static CupertinoPicker builder(
            float itemExtent,
            ValueChanged <int> onSelectedItemChanged,
            IndexedWidgetBuilder itemBuilder,
            Key key               = null,
            float diameterRatio   = CupertinoPickerUtils._kDefaultDiameterRatio,
            Color backgroundColor = null,
            float offAxisFraction = 0.0f,
            bool useMagnifier     = false,
            float magnification   = 1.0f,
            FixedExtentScrollController scrollController = null,
            int?childCount = null
            )
        {
            D.assert(itemBuilder != null);
            D.assert(diameterRatio > 0.0f, () => RenderListWheelViewport.diameterRatioZeroMessage);
            D.assert(magnification > 0);
            D.assert(itemExtent > 0);

            return(new CupertinoPicker(
                       itemExtent: itemExtent,
                       onSelectedItemChanged: onSelectedItemChanged,
                       key: key,
                       diameterRatio: diameterRatio,
                       backgroundColor: backgroundColor,
                       offAxisFraction: offAxisFraction,
                       useMagnifier: useMagnifier,
                       magnification: magnification,
                       scrollController: scrollController,
                       childDelegate: new ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount)
                       ));
        }
Exemple #4
0
        public CupertinoPicker(
            float itemExtent,
            ValueChanged <int> onSelectedItemChanged,
            List <Widget> children = null,
            Key key               = null,
            float diameterRatio   = CupertinoPickerUtils._kDefaultDiameterRatio,
            Color backgroundColor = null,
            float offAxisFraction = 0.0f,
            bool useMagnifier     = false,
            float magnification   = 1.0f,
            FixedExtentScrollController scrollController = null,
            bool looping = false,
            ListWheelChildDelegate childDelegate = null
            ) : base(key: key)
        {
            D.assert(children != null || childDelegate != null);
            D.assert(diameterRatio > 0.0, () => RenderListWheelViewport.diameterRatioZeroMessage);
            D.assert(magnification > 0);
            D.assert(itemExtent > 0);

            this.childDelegate = childDelegate ?? (looping
                                     ? (ListWheelChildDelegate) new ListWheelChildLoopingListDelegate(
                                                       children: children)
                                     : (ListWheelChildDelegate) new ListWheelChildListDelegate(children: children));

            this.itemExtent            = itemExtent;
            this.onSelectedItemChanged = onSelectedItemChanged;
            this.diameterRatio         = diameterRatio;
            this.backgroundColor       = backgroundColor ?? CupertinoPickerUtils._kDefaultBackground;
            this.offAxisFraction       = offAxisFraction;
            this.useMagnifier          = useMagnifier;
            this.magnification         = magnification;
            this.scrollController      = scrollController;
        }
Exemple #5
0
 public _CupertinoPickerSemantics(
     Key key      = null,
     Widget child = null,
     FixedExtentScrollController scrollController = null
     ) : base(key: key, child: child)
 {
     this.scrollController = scrollController;
 }
Exemple #6
0
 public override void initState()
 {
     base.initState();
     if (widget.scrollController == null)
     {
         _controller = new FixedExtentScrollController();
     }
 }
Exemple #7
0
        Widget _buildColorPicker(BuildContext context)
        {
            FixedExtentScrollController scrollController =
                new FixedExtentScrollController(initialItem: this._selectedColorIndex);

            List <Widget> generateList()
            {
                var list = new List <Widget>();

                foreach (var item in CupertinoNavigationDemoUtils.coolColorNames)
                {
                    list.Add(new Center(child:
                                        new Text(item)
                                        ));
                }

                return(list);
            }

            return(new GestureDetector(
                       onTap: () => {
                CupertinoRouteUtils.showCupertinoModalPopup(
                    context: context,
                    builder: (BuildContext _context) => {
                    return this._buildBottomPicker(
                        new CupertinoPicker(
                            scrollController: scrollController,
                            itemExtent: CupertinoPickerDemoUtils._kPickerItemHeight,
                            backgroundColor: CupertinoColors.white,
                            onSelectedItemChanged: (int index) => {
                        this.setState(() => this._selectedColorIndex = index);
                    },
                            children: generateList()
                            )
                        );
                }
                    );
            },
                       child: this._buildMenu(new List <Widget> {
                new Text("Favorite Color"),
                new Text(
                    CupertinoNavigationDemoUtils.coolColorNames[this._selectedColorIndex],
                    style: new TextStyle(
                        color: CupertinoColors.inactiveGray
                        )
                    )
            }
                                              )
                       ));
        }
Exemple #8
0
        public override void didUpdateWidget(StatefulWidget oldWidget)
        {
            if (this.widget.scrollController != null && ((CupertinoPicker)oldWidget).scrollController == null)
            {
                this._controller = null;
            }
            else if (this.widget.scrollController == null && ((CupertinoPicker)oldWidget).scrollController != null)
            {
                D.assert(this._controller == null);
                this._controller = new FixedExtentScrollController();
            }

            base.didUpdateWidget(oldWidget);
        }
Exemple #9
0
        Widget _buildColorPicker(BuildContext context)
        {
            FixedExtentScrollController scrollController = new FixedExtentScrollController(initialItem: _selectedColorIndex);

            List <Widget> widgets = new List <Widget>();

            for (int i = 0; i < CupertinoPickerDemoUtils.coolColorNames.Count; i++)
            {
                widgets.Add(new Center(
                                child: new Text(CupertinoPickerDemoUtils.coolColorNames[i])
                                ));
            }

            return(new GestureDetector(
                       onTap: () => {
                CupertinoRouteUtils.showCupertinoModalPopup(
                    context: context,
                    semanticsDismissible: true,
                    builder: (BuildContext context1) => {
                    return new _BottomPicker(
                        child: new CupertinoPicker(
                            scrollController: scrollController,
                            itemExtent: CupertinoPickerDemoUtils._kPickerItemHeight,
                            backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
                            onSelectedItemChanged: (int index) => {
                        setState(() => _selectedColorIndex = index);
                    },
                            children: widgets
                            )
                        );
                }
                    );
            },
                       child: new _Menu(
                           children: new List <Widget> {
                new Text("Favorite Color"),
                new Text(
                    CupertinoPickerDemoUtils.coolColorNames[_selectedColorIndex],
                    style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
                    )
            }
                           )
                       ));
        }
Exemple #10
0
 public _RenderCupertinoPickerSemantics(FixedExtentScrollController controller, TextDirection textDirection)
 {
     this.controller = controller;
     _textDirection  = textDirection;
 }