浏览代码

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

Zgh/cupertino/fix
/siyaoH-1.17-PlatformMessage
GitHub 4 年前
当前提交
a1176b49
共有 8 个文件被更改,包括 181 次插入61 次删除
  1. 10
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_activity_indicator_demo.cs
  2. 71
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_refresh_demo.cs
  3. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/backdrop.cs
  4. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/shopping_cart.cs
  5. 12
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine_demo.cs
  6. 86
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs
  7. 15
      com.unity.uiwidgets/Runtime/cupertino/segmented_control.cs
  8. 32
      com.unity.uiwidgets/Runtime/cupertino/sliding_segmented_control.cs

10
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_activity_indicator_demo.cs


namespace UIWidgetsGallery.gallery {
public class CupertinoProgressIndicatorDemo : StatelessWidget {
public static string routeName = "/cupertino/progress_indicator";
automaticallyImplyLeading: false,
middle: new Text(
"Activity Indicator"
)
),
previousPageTitle: "Cupertino",
middle: new Text("Activity Indicator")
),
child: new Center(
child: new CupertinoActivityIndicator()
)

71
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_refresh_demo.cs


List<List<string>> randomizedContacts;
public override void initState() {
public override void initState()
{
void repopulateList() {
void repopulateList()
{
//List<string> nullStr = new List<string>();//{" "};
randomizedContacts = new List<List<string>>();
for (int index = 0; index < 100; index++ ){
contacts[random.Next()].Add(random.Next()%2 == 0 ? true.ToString() : false.ToString());
randomizedContacts.Add(contacts[random.Next()]);
for (int index = 0; index < 100; index++ )
{
var id = random.Next(contacts.Count);
if (id < contacts.Count)
{
contacts[id].Add(id % 2 == 0 ? true.ToString() : false.ToString());
randomizedContacts.Add(new List<string>());
for (int i = 0; i < 4; i++)
{
randomizedContacts[index].Add(contacts[id][i]);
}
}
_ListItem getListItem(int index)
{
if (index < randomizedContacts.Count && index > 0 )
{
return new _ListItem(
name: randomizedContacts[index][0],
place: randomizedContacts[index][1],
date: randomizedContacts[index][2],
called: randomizedContacts[index][3] == "true"
);
}
else
{
return new _ListItem();
}
}
previousPageTitle: "Cupertino"
//trailing: CupertinoDemoDocumentationButton(CupertinoRefreshControlDemo.routeName),
),

top: false, // Top safe area is consumed by the navigation bar.
sliver: new SliverList(
del: new SliverChildBuilderDelegate(
(BuildContext context1, int index)=> {
return new _ListItem(
name: randomizedContacts[index][0],
place: randomizedContacts[index][1],
date: randomizedContacts[index][2],
called: randomizedContacts[index][3] == "true"
);
(BuildContext context1, int index)=>
{
return getListItem(index);
},
childCount: 20
)

string name = null,
string place = null,
string date = null,
bool? called = null
bool called = false
)
{
this.name = name;

public readonly string name;
public readonly string place;
public readonly string date;
public readonly bool? called;
public readonly bool called;
public override Widget build(BuildContext context) {
return new Container(

children: new List<Widget>{
new Container(
width: 38.0f,
child: (bool)called
child: called
? new Align(
alignment: Alignment.topCenter,
child: new Icon(

)
: null
),
new Expanded(
child: new Container(
new Expanded(
child: new Container(
decoration: new BoxDecoration(
border: new Border(
bottom: new BorderSide(color: new Color(0xFFBCBBC1), width: 0.0f)

mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: new List<Widget>{
new Text(
name,
name ?? "",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: new TextStyle(

),
new Text(
place,
place ?? "",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: new TextStyle(

)
),
new Text(
date,
date ?? "",
style: new TextStyle(
color: CupertinoColors.inactiveGray.resolveFrom(context),
fontSize: 15.0f,

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/backdrop.cs


icon: new Stack(children: new List<Widget>{
new Opacity(
opacity: animation.value,
child: new Container(
width: 44.0f,
height: 44.0f,
child: new Container(
width: 20.0f,
height: 20.0f,
file: "logo.png"
file: "shrine_images/slanted_menu.png"
)
),
shape: BoxShape.circle

begin: Offset.zero,
end: new Offset(1.0f, 0.0f)).evaluate(animation),
child: new Container(
width: 44.0f,
height: 44.0f,
width: 20.0f,
height: 20.0f,
file: "logo.png"
file: "shrine_images/diamond.png"
)
),
shape: BoxShape.circle

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/shopping_cart.cs


public class _ShoppingCartPageState : State<ShoppingCartPage> {
List<Widget> _createShoppingCartRows(AppStateModel model)
{
List<Widget> widgets = null;
List<Widget> widgets = new List<Widget>();
for (int id = 0; id < model.productsInCart.Count; id++)
{
widgets.Add(new ShoppingCartRow(

12
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine_demo.cs


namespace UIWidgetsGallery.demo
{
class ShrineDemo : StatelessWidget {
public ShrineDemo(Key key = null) : base(key: key){}
class ShrineDemo : StatelessWidget
{
public ShrineDemo(Key key = null) : base(key: key){}
public static readonly string routeName = "/shrine"; // Used by the Gallery app.
public static readonly string routeName = "/shrine";
public override Widget build(BuildContext context) => new ShrineApp();
public override Widget build(BuildContext context)
{
return new ShrineApp();
}
}
}

86
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs


public static List<GalleryDemo> _buildGalleryDemos()
{
List<GalleryDemo> cupertinoDemos = new List<GalleryDemo>()
{
new GalleryDemo(
title: "Activity Indicator",
icon: GalleryIcons.cupertino_progress,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoProgressIndicatorDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoActivityIndicator-class.html",
buildRoute: (BuildContext context) => new CupertinoProgressIndicatorDemo()
),
new GalleryDemo(
title: "Alerts",
icon: GalleryIcons.dialogs,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoAlertDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/showCupertinoDialog.html",
buildRoute: (BuildContext context) => new CupertinoAlertDemo()
),
new GalleryDemo(
title: "Buttons",
icon: GalleryIcons.generic_buttons,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoButtonsDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoButton-class.html",
buildRoute: (BuildContext context) => new CupertinoButtonsDemo()
),
new GalleryDemo(
title: "Navigation",
icon: GalleryIcons.bottom_navigation,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoNavigationDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoTabScaffold-class.html",
buildRoute: (BuildContext context) => new CupertinoNavigationDemo()
),
new GalleryDemo(
title: "Pickers",
icon: GalleryIcons.cards,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoPickerDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoPicker-class.html",
buildRoute: (BuildContext context) => new CupertinoPickerDemo()
),
new GalleryDemo(
title: "Pull to refresh",
icon: GalleryIcons.cupertino_pull_to_refresh,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoRefreshControlDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSliverRefreshControl-class.html",
buildRoute: (BuildContext context) => new CupertinoRefreshControlDemo()
),
new GalleryDemo(
title: "Segmented Control",
icon: GalleryIcons.tabs,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoSegmentedControlDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSegmentedControl-class.html",
buildRoute: (BuildContext context) => new CupertinoSegmentedControlDemo()
),
new GalleryDemo(
title: "Sliders",
icon: GalleryIcons.sliders,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoSliderDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSlider-class.html",
buildRoute: (BuildContext context) => new CupertinoSliderDemo()
),
new GalleryDemo(
title: "Switches",
icon: GalleryIcons.cupertino_switch,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoSwitchDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSwitch-class.html",
buildRoute: (BuildContext context) => new CupertinoSwitchDemo()
),
new GalleryDemo(
title: "Text Fields",
icon: GalleryIcons.text_fields_alt,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoTextFieldDemo.routeName,
buildRoute: (BuildContext context) => new CupertinoTextFieldDemo()
)
};
List<GalleryDemo> galleryDemos = new List<GalleryDemo>
{
new GalleryDemo(

),
};
return galleryDemos;
return cupertinoDemos;
}
public static readonly List<GalleryDemo> kAllGalleryDemos = _buildGalleryDemos();

15
com.unity.uiwidgets/Runtime/cupertino/segmented_control.cs


Color selectedColor = null,
Color borderColor = null,
Color pressedColor = null,
EdgeInsetsGeometry Padding = null
EdgeInsetsGeometry padding = null
{
D.assert(children != null);
{ D.assert(children != null);
D.assert(children.Count >= 2);
D.assert(onValueChanged != null);
D.assert(

this.children = children;
this.onValueChanged = onValueChanged;
this.groupValue = groupValue;
this.unselectedColor = unselectedColor;
this.selectedColor = selectedColor;
this.borderColor = borderColor;
this.pressedColor = pressedColor;
this.padding = padding;
}
public readonly Dictionary<T, Widget> children;
public readonly T groupValue;

}
_selectionControllers.Clear();
_childTweens.Clear();
foreach ( T key in widget.children.Keys) {
AnimationController animationController = createAnimationController();
if (widget.groupValue.Equals(key)) {

32
com.unity.uiwidgets/Runtime/cupertino/sliding_segmented_control.cs


{
D.assert(children != null);
D.assert(children.Count >= 2);
D.assert(padding != null);
D.assert(onValueChanged != null);
D.assert(
groupValue == null || children.Keys.Contains(groupValue),()=>

public _RenderSlidingSegmentedControl(
int? selectedIndex = null,
Color thumbColor = null,
_SlidingSegmentedControlState<T> state = null
_SlidingSegmentedControlState<T> state = null
highlightedIndex = selectedIndex;
_thumbColor = thumbColor;
state.drag.onDown = _onDown;
state.drag.onUpdate = _onUpdate;
state.drag.onEnd = _onEnd;
state.drag.onCancel = _onCancel;
state.tap.onTapUp = _onTapUp;
state.longPress.onLongPress = ()=> { };
}
public readonly _SlidingSegmentedControlState<T> state;
Dictionary<RenderBox, _ChildAnimationManifest> _childAnimations = new Dictionary<RenderBox, _ChildAnimationManifest>{};
_highlightedIndex = selectedIndex;
_thumbColor = thumbColor;
this.state = state;
this.state.drag.onDown = _onDown;
this.state.drag.onUpdate = _onUpdate;
this.state.drag.onEnd = _onEnd;
this.state.drag.onCancel = _onCancel;
this.state.tap.onTapUp = _onTapUp;
this.state.longPress.onLongPress = ()=> { };
}
public _SlidingSegmentedControlState<T> state;
Dictionary<RenderBox, _ChildAnimationManifest> _childAnimations = new Dictionary<RenderBox, _ChildAnimationManifest>{};
Rect currentThumbRect;

base.insert(child, after: after);
if (_childAnimations == null)
return;
D.assert(_childAnimations[child] == null);
D.assert(_childAnimations.getOrDefault(child) == null);
_childAnimations[child] = new _ChildAnimationManifest(separatorOpacity: 1);
}

transform: MatrixUtils.forceToPoint(center),
position: center,
hitTest: (BoxHitTestResult result1, Offset position1)=> {
D.assert(position == center);
D.assert(position1 == center);
return child.hitTest(result1, position: center);
}
);

正在加载...
取消
保存