浏览代码

Merge pull request #93 from Unity-Technologies/zgh/cupertino/fix

Zgh/cupertino/fix
/siyaoH-1.17-PlatformMessage
GitHub 4 年前
当前提交
8aa8ba9f
共有 17 个文件被更改,包括 315 次插入284 次删除
  1. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_alert_demo.cs
  2. 344
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_picker_demo.cs
  3. 7
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/expanding_bottom_sheet.cs
  4. 4
      com.unity.uiwidgets/Runtime/animation/animation_controller.cs
  5. 88
      com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
  6. 14
      com.unity.uiwidgets/Runtime/cupertino/picker.cs
  7. 12
      com.unity.uiwidgets/Runtime/cupertino/route.cs
  8. 4
      com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
  9. 2
      com.unity.uiwidgets/Runtime/material/app_bar.cs
  10. 2
      com.unity.uiwidgets/Runtime/material/app_bar_theme.cs
  11. 2
      com.unity.uiwidgets/Runtime/painting/image_provider.cs
  12. 2
      com.unity.uiwidgets/Runtime/painting/matrix_utils.cs
  13. 15
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  14. 19
      com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs
  15. 2
      com.unity.uiwidgets/Runtime/ui2/Matrix4.cs
  16. 64
      com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs
  17. 16
      com.unity.uiwidgets/Runtime/widgets/scrollable.cs

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_alert_demo.cs


navigationBar: new CupertinoNavigationBar(
middle: new Text("Alerts"),
previousPageTitle: "Cupertino"
//trailing: CupertinoDemoDocumentationButton(CupertinoAlertDemo.routeName)
//,trailing: CupertinoDemoDocumentationButton(CupertinoAlertDemo.routeName)
),
child: new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,

344
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_picker_demo.cs


using System;
using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;

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
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))
);
}
}
)
},
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))
)
}
)
);
}
Widget _buildCountdownTimerPicker(BuildContext context) {
return new GestureDetector(
onTap: () =>{
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>{
return new _BottomPicker(
child: new CupertinoTimerPicker(
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
initialTimerDuration: timer,
onTimerDurationChanged: (newTimer) =>{
setState(() => timer = newTimer);
}
)
}
Widget _buildCountdownTimerPicker(BuildContext context) {
return new GestureDetector(
onTap: () =>{
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>{
return new _BottomPicker(
child: new CupertinoTimerPicker(
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
initialTimerDuration: timer,
onTimerDurationChanged: (newTimer) =>{
setState(() => timer = newTimer);
}
)
);
}
}
},
child: new _Menu(
children: new List<Widget>{
new Text("Countdown Timer"),
new Text(
$"{timer.Hours}:" +
$"{(timer.Minutes % 60).ToString("00")}:" +
$"{(timer.Seconds % 60).ToString("00")}",
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
),
}
)
},
child: new _Menu(
children: new List<Widget>{
new Text("Countdown Timer"),
new Text(
$"{timer.Hours}:" +
$"{(timer.Minutes % 60).ToString("00")}:" +
$"{(timer.Seconds % 60).ToString("00")}",
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
),
}
)
);
}
}
Widget _buildDatePicker(BuildContext context)
{
return new GestureDetector(
onTap: () =>
Widget _buildDatePicker(BuildContext context)
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>
return new GestureDetector(
onTap: () =>
return new _BottomPicker(
child: new CupertinoDatePicker(
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
mode: CupertinoDatePickerMode.date,
initialDateTime: date,
onDateTimeChanged: (newDateTime) => { setState(() => date = newDateTime); }
)
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>
{
return new _BottomPicker(
child: new CupertinoDatePicker(
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
mode: CupertinoDatePickerMode.date,
initialDateTime: date,
onDateTimeChanged: (DateTime newDateTime) =>{
setState(() => date = newDateTime);
}
)
);
}
}
},
child: new _Menu(
children: new List<Widget>{
new Text("Date"),
new Text(
date.ToString("MMMM dd, yyyy"),
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
),
}
)
},
child: new _Menu(
children: new List<Widget>{
new Text("Date"),
new Text(
date.ToString("MMMM dd, yyyy"),
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
),
}
)
);
}
}
Widget _buildTimePicker(BuildContext context) {
return new GestureDetector(
onTap: () =>{
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>{
return new _BottomPicker(
child: new CupertinoDatePicker(
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
mode: CupertinoDatePickerMode.time,
initialDateTime: time,
onDateTimeChanged: (newDateTime) => {
setState(() => time = newDateTime);
}
)
Widget _buildTimePicker(BuildContext context) {
return new GestureDetector(
onTap: () =>{
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>{
return new _BottomPicker(
child: new CupertinoDatePicker(
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
mode: CupertinoDatePickerMode.time,
initialDateTime: time,
onDateTimeChanged: (newDateTime) => {
setState(() => time = newDateTime);
}
)
);
}
}
},
child:new _Menu(
children: new List<Widget>{
new Text("Time"),
new Text(
time.ToString("h:mm tt"),
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
),
}
)
},
child:new _Menu(
children: new List<Widget>{
new Text("Time"),
new Text(
time.ToString("h:mm tt"),
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
),
}
)
);
}
}
Widget _buildDateAndTimePicker(BuildContext context) {
return new GestureDetector(
onTap: ()=> {
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>{
return new _BottomPicker(
child: new CupertinoDatePicker(
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
mode: CupertinoDatePickerMode.dateAndTime,
initialDateTime: dateTime,
onDateTimeChanged: (newDateTime) => {
setState(() => dateTime = newDateTime);
}
)
Widget _buildDateAndTimePicker(BuildContext context) {
return new GestureDetector(
onTap: ()=> {
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>{
return new _BottomPicker(
child: new CupertinoDatePicker(
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
mode: CupertinoDatePickerMode.dateAndTime,
initialDateTime: dateTime,
onDateTimeChanged: (newDateTime) => {
setState(() => dateTime = newDateTime);
}
)
);
}
}
},
child: new _Menu(
children:new List<Widget>{
new Text("Date and Time"),
new Text(
dateTime.ToString("MMMM dd, yyyy") + " " + dateTime.ToString("HH:mm tt"),
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
),
}
)
},
child: new _Menu(
children:new List<Widget>{
new Text("Date and Time"),
new Text(
dateTime.ToString("MMMM dd, yyyy h:mm tt"),
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
),
}
)
);
}
}
public override Widget build(BuildContext context) {
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: new Text("Picker"),
// We're specifying a back label here because the previous page is a
// Material page. CupertinoPageRoutes could auto-populate these back
// labels.
previousPageTitle: "Cupertino"
//trailing: CupertinoDemoDocumentationButton(CupertinoPickerDemo.routeName)
),
child: new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: new ListView(
children: new List<Widget>{
new Padding(padding: EdgeInsets.only(top: 32.0f)),
_buildColorPicker(context),
//_buildCountdownTimerPicker(context),
//_buildDatePicker(context),
//_buildTimePicker(context),
//_buildDateAndTimePicker(context),
}
)
)
);
public override Widget build(BuildContext context) {
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: new Text("Picker"),
// We're specifying a back label here because the previous page is a
// Material page. CupertinoPageRoutes could auto-populate these back
// labels.
previousPageTitle: "Cupertino"
//trailing: CupertinoDemoDocumentationButton(CupertinoPickerDemo.routeName)
),
child: new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: new ListView(
children: new List<Widget>{
new Padding(padding: EdgeInsets.only(top: 32.0f)),
_buildColorPicker(context),
_buildCountdownTimerPicker(context),
_buildDatePicker(context),
_buildTimePicker(context),
_buildDateAndTimePicker(context),
}
)
)
);
}
}
}
}

7
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/expanding_bottom_sheet.cs


new Row(
children: new List<Widget>
{
/* new AnimatedPadding(
new AnimatedPadding(
),*/
),
new Container(
// Accounts for the overflow number
width: numProducts > 3 ? _width - 94.0f : _width - 64.0f,

)//, new ExtraProductsNumber(),
),
new ExtraProductsNumber(),
}
),
}

4
com.unity.uiwidgets/Runtime/animation/animation_controller.cs


void _internalSetValue(float newValue) {
_value = newValue.clamp(lowerBound, upperBound);
if (_value == lowerBound) {
if (foundation_.FloatEqual(_value, lowerBound)) {
else if (_value == upperBound) {
else if (foundation_.FloatEqual(_value, upperBound)) {
_status = AnimationStatus.completed;
}
else {

88
com.unity.uiwidgets/Runtime/cupertino/date_picker.cs


letterSpacing: -0.83f
);
public const float _kTimerPickerHalfColumnPadding = 2f;
public const float _kTimerPickerLabelPadSize = 4.5f;
public const float _kTimerPickerLabelFontSize = 17.0f;
public const float _kTimerPickerColumnIntrinsicWidth = 106f;

_onSelectedItemChange(index);
},
itemBuilder: (BuildContext context, int index) => {
rangeStart.AddDays(index);
rangeStart = rangeStart.AddDays(index);
var rangeEnd = rangeStart.AddDays(1);

return null;
if (widget.maximumDate?.CompareTo(rangeStart) > 0)
if (widget.maximumDate?.CompareTo(rangeStart) < 0)
return null;
string dateText = rangeStart == new DateTime(now.Year, now.Month, now.Day)

DateTime _lastDayInMonth(int year, int month) {
//new DateTime(year, month + 1, 0);
var date = new DateTime(year,month,1);
date.AddMonths(1);
date.Subtract(new TimeSpan(1, 0, 0, 0));
date = date.AddMonths(1);
date = date.Subtract(new TimeSpan(1, 0, 0, 0));
return date;
}

context,
new Text(
localizations.datePickerYear(year),
style: CupertinoDatePickerUtils._themeTextStyle(context, isValid: isValidYear))
style: CupertinoDatePickerUtils._themeTextStyle(_context, isValid: isValidYear))
);
}

// The current date selection represents a range [minSelectedData, maxSelectDate].
get {
DateTime minSelectedDate = new DateTime(selectedYear, selectedMonth, selectedDay);
DateTime maxSelectedDate = new DateTime(selectedYear, selectedMonth, selectedDay + 1);
DateTime maxSelectedDate = new DateTime(selectedYear, selectedMonth, selectedDay);
maxSelectedDate = maxSelectedDate.AddDays(1);
bool minCheck = widget.minimumDate?.CompareTo(maxSelectedDate) < 0;
bool maxCheck = widget.maximumDate?.CompareTo(minSelectedDate) > 0;
bool minCheck = widget.minimumDate == null ? true : widget.minimumDate?.CompareTo(maxSelectedDate) < 0;
bool maxCheck = widget.maximumDate == null ? false : widget.maximumDate?.CompareTo(minSelectedDate) > 0;
return minCheck && !maxCheck && minSelectedDate.Day == selectedDay;
}

DateTime minSelectDate = new DateTime(selectedYear, selectedMonth, selectedDay);
DateTime maxSelectDate = new DateTime(selectedYear, selectedMonth, selectedDay + 1);
bool minCheck = widget.minimumDate?.CompareTo(maxSelectDate) < 0;
bool maxCheck = widget.maximumDate?.CompareTo(minSelectDate) > 0;
bool minCheck = widget.minimumDate == null ? true : widget.minimumDate?.CompareTo(maxSelectDate) < 0 ;
bool maxCheck = widget.maximumDate == null ? false :widget.maximumDate?.CompareTo(minSelectDate) > 0;
DateTime targetDate = minCheck ? (DateTime) widget.maximumDate : (DateTime) widget.minimumDate;
_scrollToDate(targetDate);
return;

List<Widget> pickers = new List<Widget>();
for (int i = 0; i < columnWidths.Count; i++) {
float offAxisFraction = (i - 1) * 0.3f * textDirectionFactor;
int index = i;
float offAxisFraction = (index - 1) * 0.3f * textDirectionFactor;
Widget transitionBuilder(BuildContext _context, Widget child) {
var columnWidth = columnWidths.Count == 0 ? 0 : columnWidths[index];
var result = new Container(
alignment: index == (columnWidths.Count - 1)
? alignCenterLeft
: alignCenterRight,
padding: index == 0 ? null : padding,
child: new Container(
alignment: index == 0 ? alignCenterLeft : alignCenterRight,
width: columnWidth + CupertinoDatePickerUtils._kDatePickerPadSize,
child: child
)
);
return result;
}
TransitionBuilder builder = transitionBuilder;
Widget childWidget = pickerBuilders[index](
offAxisFraction: offAxisFraction,
itemPositioningBuilder : builder
);
id: i,
child: pickerBuilders[i](
offAxisFraction,
(BuildContext _context, Widget child) => {
return new Container(
alignment: i == columnWidths.Count - 1
? alignCenterLeft
: alignCenterRight,
padding: i == 0 ? null : padding,
child: new Container(
alignment: i == 0 ? alignCenterLeft : alignCenterRight,
width: columnWidths[i] + CupertinoDatePickerUtils._kDatePickerPadSize,
child: child
)
);
}
id: index,
child: childWidget
));
);
}
return new MediaQuery(

Color backgroundColor = null,
ValueChanged<TimeSpan> onTimerDurationChanged = null
):base(key : key) {
alignment = alignment ?? Alignment.center ;
alignment = alignment ?? Alignment.center;
//D.assert(((TimeSpan)initialTimerDuration)/TimeSpan. % minuteInterval == 0);
//D.assert(((TimeSpan)initialTimerDuration).% secondInterval == 0);
this.mode = mode;
this.initialTimerDuration = initialTimerDuration ?? TimeSpan.Zero;
this.minuteInterval = minuteInterval;

this.onTimerDurationChanged = onTimerDurationChanged;
public readonly CupertinoTimerPickerMode mode;
public readonly TimeSpan initialTimerDuration;
public readonly int minuteInterval;

return new IgnorePointer(
child: new Container(
//alignment: AlignmentDirectional.centerStart.resolve(textDirection),
alignment: AlignmentDirectional.centerStart.resolve(textDirection),
padding: padding.resolve(textDirection),
child: new SizedBox(
height: numberLabelHeight,

return new Container(
width: CupertinoDatePickerUtils._kTimerPickerColumnIntrinsicWidth + padding.horizontal,
padding: padding.resolve(textDirection),
//alignment: AlignmentDirectional.centerStart.resolve(textDirection),
alignment: AlignmentDirectional.centerStart.resolve(textDirection),
// alignment: AlignmentDirectional.centerEnd.resolve(textDirection),
alignment: AlignmentDirectional.centerEnd.resolve(textDirection),
child: new Text(text, softWrap: false, maxLines: 1, overflow: TextOverflow.visible)
)
);

14
com.unity.uiwidgets/Runtime/cupertino/picker.cs


public class CupertinoPicker : StatefulWidget {
public CupertinoPicker(
List<Widget> children,
float itemExtent,
Key key = null,
float? diameterRatio = null,
Color backgroundColor = null,

FixedExtentScrollController scrollController = null,
float? squeeze = null,
float? itemExtent = null,
ValueChanged<int> onSelectedItemChanged = null,
bool looping = false
) : base(key: key) {

D.assert(diameterRatio > 0.0f, ()=>RenderListWheelViewport.diameterRatioZeroMessage);
D.assert(magnification > 0);
D.assert(itemExtent != null);
D.assert(itemExtent > 0);
D.assert(squeeze > 0);
this.diameterRatio = diameterRatio;

}
public CupertinoPicker(
float itemExtent,
Key key = null,
float? diameterRatio = null,
Color backgroundColor = null,

FixedExtentScrollController scrollController = null,
float? squeeze = null,
float? itemExtent = null,
ValueChanged<int> onSelectedItemChanged = null,
IndexedWidgetBuilder itemBuilder = null,
int? childCount = null

D.assert(itemBuilder != null);
D.assert(diameterRatio > 0.0f,()=> RenderListWheelViewport.diameterRatioZeroMessage);
D.assert(magnification > 0);
D.assert(itemExtent != null);
D.assert(itemExtent > 0);
D.assert(squeeze > 0);
this.diameterRatio = diameterRatio;

public readonly bool useMagnifier;
public readonly float magnification;
public readonly FixedExtentScrollController scrollController;
public readonly float? itemExtent;
public readonly float itemExtent;
public readonly ValueChanged<int> onSelectedItemChanged;
public ListWheelChildDelegate childDelegate;
public readonly float? squeeze;

}
public override void didUpdateWidget(StatefulWidget oldWidget) {
oldWidget = (CupertinoPicker) oldWidget;
if (widget.scrollController != null && ((CupertinoPicker) oldWidget).scrollController == null) {
_controller = null;
}

child: new ListWheelScrollView(
controller: widget.scrollController ?? _controller,
physics: new FixedExtentScrollPhysics(),
diameterRatio: widget.diameterRatio ?? CupertinoPickerUtils._kDefaultDiameterRatio,
diameterRatio: widget.diameterRatio ?? RenderListWheelViewport.defaultDiameterRatio ,
itemExtent: widget.itemExtent ?? 1f,
itemExtent: widget.itemExtent ,
squeeze: widget.squeeze ?? CupertinoPickerUtils._kSqueeze,
onSelectedItemChanged: _handleSelectedItemChanged,
childDelegate: widget.childDelegate

12
com.unity.uiwidgets/Runtime/cupertino/route.cs


using System;
using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;

public readonly WidgetBuilder builder;
public readonly string title;
ValueNotifier<string> _previousTitle;
public ValueListenable<string> previousTitle {

public override Widget buildPage(BuildContext context, Animation<float> animation, Animation<float> secondaryAnimation) {
Widget result = builder(context);
D.assert(() =>{
if (result == null) {

}
public new string debugLabel {
get { return $"{base.debugLabel}(${settings.name})"; }
get { return $"{base.debugLabel}({settings.name})"; }
}
}

this.barrierColor = barrierColor;
this.builder = builder;
this.barrierLabel = barrierLabel;
public readonly string barrierLabel;
public readonly Color barrierColor;
public override Color barrierColor { get; }
public override string barrierLabel { get; }
public override bool barrierDismissible {
get { return true; }

4
com.unity.uiwidgets/Runtime/foundation/diagnostics.cs


public static bool _isSingleLine(DiagnosticsTreeStyle? style) {
return style == DiagnosticsTreeStyle.singleLine;
}
public static bool FloatEqual(float left, float right) {
return Mathf.Abs(left - right) < precisionErrorTolerance;
}
}

2
com.unity.uiwidgets/Runtime/material/app_bar.cs


child: appBar
)
),
widget.bottomOpacity == 1.0f
foundation_.FloatEqual(widget.bottomOpacity, 1.0f)
? (Widget) widget.bottom
: new Opacity(
opacity: new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(widget

2
com.unity.uiwidgets/Runtime/material/app_bar_theme.cs


public bool Equals(AppBarTheme other) {
return other.brightness == brightness
&& other.color == color
&& other.elevation == elevation
&& Equals(other.elevation, elevation)
&& other.iconTheme == iconTheme
&& other.actionsIconTheme == actionsIconTheme
&& other.textTheme == textTheme;

2
com.unity.uiwidgets/Runtime/painting/image_provider.cs


public readonly float scale;
public override Future<FileImage> obtainKey(ImageConfiguration configuration) {
return Future.value(FutureOr.value(this)).to<FileImage>();
return new SynchronousFuture<FileImage>(this);
}
public override ImageStreamCompleter load(FileImage key, DecoderCallback decode) {

2
com.unity.uiwidgets/Runtime/painting/matrix_utils.cs


return (e > f) ? e : f;
}
static Matrix4 createCylindricalProjectionTransform(
public static Matrix4 createCylindricalProjectionTransform(
float radius,
float angle,
float perspective = 0.001f,

15
com.unity.uiwidgets/Runtime/rendering/layer.cs


var totalOffset = offset + layerOffset;
if (totalOffset != Offset.zero) {
_lastEffectiveTransform = Matrix4.translationValues(totalOffset.dx, totalOffset.dy, 0);
_lastEffectiveTransform = Matrix4.translationValues(totalOffset.dx, totalOffset.dy, 0.0f);
_lastEffectiveTransform.multiply(transform);
}

_lastOffset = offset + layerOffset;
if (_lastOffset != Offset.zero) {
engineLayer = builder.pushTransform(
Matrix4.translationValues(_lastOffset.dx, _lastOffset.dy,0)
._m4storage,
Matrix4.translationValues(_lastOffset.dx, _lastOffset.dy,0.0f).storage,
oldLayer: engineLayer as TransformEngineLayer);
}

return null;
}
Matrix4 result = Matrix4.translationValues(-_lastOffset.dx, -_lastOffset.dy,0 );
Matrix4 result = Matrix4.translationValues(-_lastOffset.dx, -_lastOffset.dy,0.0f );
result.multiply(_lastTransform);
return result;
}

_establishTransform();
if (_lastTransform != null) {
engineLayer = builder.pushTransform(
_lastTransform._m4storage,
_lastTransform.storage,
oldLayer: engineLayer as TransformEngineLayer);
addChildrenToScene(builder);
builder.pop();

_lastOffset = null;
var matrix = Matrix4.translationValues(unlinkedOffset.dx, unlinkedOffset.dy, 0);
var matrix = Matrix4.translationValues(unlinkedOffset.dx, unlinkedOffset.dy, 0.0f);
matrix._m4storage,
matrix.storage,
oldLayer: engineLayer as TransformEngineLayer);
addChildrenToScene(builder);
builder.pop();

transform.multiply(_lastTransform);
}
else {
transform.multiply(Matrix4.translationValues(unlinkedOffset.dx, unlinkedOffset.dy, 0));
transform.multiply(Matrix4.translationValues(unlinkedOffset.dx, unlinkedOffset.dy, 0.0f));
}
}

19
com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs


var radius = size.height * _diameterRatio / 2.0f;
var deltaY = radius * Mathf.Sin(angle);
Matrix4 transform = Matrix4.identity();
// Matrix4x4 transform2 = MatrixUtils.createCylindricalProjectionTransform(
// radius: this.size.height * this._diameterRatio / 2.0f,
// angle: angle,
// perspective: this._perspective
// );
Matrix4 transform = MatrixUtils.createCylindricalProjectionTransform(
radius: size.height * _diameterRatio / 2.0f,
angle: angle,
perspective: _perspective
);
// Offset offsetToCenter = new Offset(untransformedPaintingCoordinates.dx, -this._topScrollMarginExtent);
// Offset that helps painting everything in the center (e.g. angle = 0).
Offset offsetToCenter = new Offset(
untransformedPaintingCoordinates.dx,
-_topScrollMarginExtent
);
Offset offsetToCenter =
new Offset(untransformedPaintingCoordinates.dx, -deltaY - _topScrollMarginExtent);
bool shouldApplyOffCenterDim = overAndUnderCenterOpacity < 1;
if (useMagnifier || shouldApplyOffCenterDim) {

2
com.unity.uiwidgets/Runtime/ui2/Matrix4.cs


static float TOLERANCE = 0.000001f;
public float[] storage {
get => _m4storage;
get { return _m4storage; }
}
public static void solve2(Matrix4 A, Vector2 x, Vector2 b) {

64
com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs


if (children.isEmpty()) {
return null;
}
return new Container(child: children[Mathf.Abs(index % children.Count)]);
return new IndexedSemantics(child: children[Mathf.Abs(index % children.Count)]);
}
public bool shouldRebuild(ListWheelChildDelegate oldDelegate) {

public Widget build(BuildContext context, int index) {
if (childCount == null) {
Widget child = builder(context, index);
return child == null ? null : new Container(child: child);
return child == null ? null : new IndexedSemantics(child: child);
}
if (index < 0 || index >= childCount) {

return new Container(child: builder(context, index));
return new IndexedSemantics(child: builder(context, index));
}
public int trueIndexOf(int index) {

class ListWheelScrollViewUtils {
public static int _getItemFromOffset(
float? offset = null,
float? itemExtent = null,
float? minScrollExtent = null,
float? maxScrollExtent = null
float offset ,
float itemExtent ,
float minScrollExtent ,
float maxScrollExtent
var _itemExtent = itemExtent ?? 1.0f;
return (_clipOffsetToScrollableRange(offset ?? 0.0f , minScrollExtent ?? 0.0f, maxScrollExtent ?? 0.0f) / _itemExtent).round();
return (_clipOffsetToScrollableRange(offset, minScrollExtent, maxScrollExtent) / itemExtent).round();
}
public static float _clipOffsetToScrollableRange(
float offset,

() =>
"The selectedItem property cannot be read when multiple scroll views are attached to the same FixedExtentScrollController."
);
_FixedExtentScrollPosition position = (_FixedExtentScrollPosition) this.position;
_FixedExtentScrollPosition position = (_FixedExtentScrollPosition) this.position;
return position.itemIndex;
}
}

TimeSpan? duration = null,
Curve curve = null
TimeSpan duration,
Curve curve
duration: duration ?? new TimeSpan(0,0,0,0,0),
duration: duration,
return Future.wait<object>(futures);
}

}
public class FixedExtentMetrics : FixedScrollMetrics, IFixedExtentMetrics {
public FixedExtentMetrics(
/*public FixedExtentMetrics(
float? minScrollExtent = null,
float? maxScrollExtent = null,
float? pixels = null,

axisDirection: axisDirection
) {
this.itemIndex = itemIndex ?? 0;
}*/
public FixedExtentMetrics(
float minScrollExtent ,
float maxScrollExtent,
float pixels ,
float viewportDimension ,
AxisDirection axisDirection ,
int itemIndex
) : base(
minScrollExtent: minScrollExtent ,
maxScrollExtent: maxScrollExtent ,
pixels: pixels ,
viewportDimension: viewportDimension ,
axisDirection: axisDirection
) {
this.itemIndex = itemIndex;
}
public int itemIndex { get; set; }

) : base(
physics: physics,
context: context,
initialPixels: _getItemExtentFromScrollContext(context) * initialItem,
initialPixels: _getItemExtentFromScrollContext(context) * (initialItem ?? 0.0f),
keepScrollOffset: keepScrollOffset,
oldPosition: oldPosition,
debugLabel: debugLabel

static float _getItemExtentFromScrollContext(ScrollContext context) {
_FixedExtentScrollableState scrollable = (_FixedExtentScrollableState) context;
return scrollable.itemExtent ?? 0.0f;
return scrollable.itemExtent;
}
public float itemExtent {

class _FixedExtentScrollable : Scrollable {
public _FixedExtentScrollable(
float itemExtent,
ScrollPhysics physics = null,
float? itemExtent = null,
ScrollPhysics physics = null,
) : base(
key: key,
axisDirection: axisDirection,

this.itemExtent = itemExtent;
}
public readonly float? itemExtent;
public readonly float itemExtent;
public override State createState() {
return new _FixedExtentScrollableState();

class _FixedExtentScrollableState : ScrollableState {
public float? itemExtent {
public float itemExtent {
get {
_FixedExtentScrollable actualWidget = (_FixedExtentScrollable) widget;
return actualWidget.itemExtent;

public class ListWheelScrollView : StatefulWidget {
public ListWheelScrollView(
List<Widget> children,
float itemExtent,
Key key = null,
ScrollController controller = null,
ScrollPhysics physics = null,

bool useMagnifier = false,
float magnification = 1.0f,
float overAndUnderCenterOpacity = 1.0f,
float? itemExtent = null,
float squeeze = 1.0f,
ValueChanged<int> onSelectedItemChanged = null,
bool clipToSize = true,

}
public ListWheelScrollView (
float itemExtent,
Key key = null,
ScrollController controller = null,
ScrollPhysics physics = null,

bool useMagnifier = false,
float magnification = 1.0f,
float? itemExtent = null,
float squeeze = 1.0f,
ValueChanged<int> onSelectedItemChanged = null,
float overAndUnderCenterOpacity = 1.0f,

public readonly float offAxisFraction;
public readonly bool useMagnifier;
public readonly float magnification;
public readonly float? itemExtent;
public readonly float itemExtent;
public readonly float overAndUnderCenterOpacity;
public readonly float squeeze;
public readonly ValueChanged<int> onSelectedItemChanged;

16
com.unity.uiwidgets/Runtime/widgets/scrollable.cs


if (widget.physics != null) {
_physics = widget.physics.applyTo(_physics);
}
ScrollController controller = widget.controller;
ScrollPosition oldPosition = position;
if (oldPosition != null) {

});
}
_position = controller == null
? null
: controller.createScrollPosition(_physics, this, oldPosition);
_position = _position
?? new ScrollPositionWithSingleContext(physics: _physics, context: this,
oldPosition: oldPosition);
if (controller == null) {
_position = new ScrollPositionWithSingleContext(physics: _physics, context: this, oldPosition: oldPosition);
}
else {
_position = controller?.createScrollPosition(_physics, this, oldPosition)
?? new ScrollPositionWithSingleContext(physics: _physics, context: this, oldPosition: oldPosition);
}
D.assert(position != null);
if (controller != null) {
controller.attach(position);

正在加载...
取消
保存