Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 95dc2c1

Browse files
committed
[Cupertino] Update Cupertino gallery
1 parent 823e088 commit 95dc2c1

14 files changed

+734
-40
lines changed

Runtime/cupertino/switch.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313

1414
namespace Unity.UIWidgets.cupertino {
1515
class CupertinoSwitchUtils {
16-
public static float _kTrackWidth = 51.0f;
17-
public static float _kTrackHeight = 31.0f;
18-
public static float _kTrackRadius = _kTrackHeight / 2.0f;
19-
public static float _kTrackInnerStart = _kTrackHeight / 2.0f;
20-
public static float _kTrackInnerEnd = _kTrackWidth - _kTrackInnerStart;
21-
public static float _kTrackInnerLength = _kTrackInnerEnd - _kTrackInnerStart;
22-
public static float _kSwitchWidth = 59.0f;
23-
public static float _kSwitchHeight = 39.0f;
24-
public static float _kCupertinoSwitchDisabledOpacity = 0.5f;
16+
public const float _kTrackWidth = 51.0f;
17+
public const float _kTrackHeight = 31.0f;
18+
public const float _kTrackRadius = _kTrackHeight / 2.0f;
19+
public const float _kTrackInnerStart = _kTrackHeight / 2.0f;
20+
public const float _kTrackInnerEnd = _kTrackWidth - _kTrackInnerStart;
21+
public const float _kTrackInnerLength = _kTrackInnerEnd - _kTrackInnerStart;
22+
public const float _kSwitchWidth = 59.0f;
23+
public const float _kSwitchHeight = 39.0f;
24+
public const float _kCupertinoSwitchDisabledOpacity = 0.5f;
2525
public static Color _kTrackColor = CupertinoColors.lightBackgroundGray;
2626
public static TimeSpan _kReactionDuration = new TimeSpan(0, 0, 0, 0, 300);
2727
public static TimeSpan _kToggleDuration = new TimeSpan(0, 0, 0, 0, 200);
@@ -100,8 +100,7 @@ public _CupertinoSwitchRenderObjectWidget(
100100
public readonly ValueChanged<bool> onChanged;
101101
public readonly TickerProvider vsync;
102102
public readonly DragStartBehavior dragStartBehavior;
103-
104-
103+
105104
public override RenderObject createRenderObject(BuildContext context) {
106105
return new _RenderCupertinoSwitch(
107106
value: this.value,
@@ -294,8 +293,8 @@ public bool isInteractive {
294293
TapGestureRecognizer _tap;
295294
HorizontalDragGestureRecognizer _drag;
296295

297-
public override void attach(object owne) {
298-
base.attach(this.owner);
296+
public override void attach(object _owner) {
297+
base.attach(_owner);
299298
if (this.value) {
300299
this._positionController.forward();
301300
}
@@ -372,9 +371,9 @@ void _handleDragUpdate(DragUpdateDetails details) {
372371
this._position.curve = null;
373372
this._position.reverseCurve = null;
374373
float delta = details.primaryDelta / CupertinoSwitchUtils._kTrackInnerLength ?? 0f;
375-
374+
376375
this._positionController.setValue(this._positionController.value + delta);
377-
376+
378377
// switch (this.textDirection) {
379378
// case TextDirection.rtl:
380379
// this._positionController.setValue(this._positionController.value - delta);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Unity.UIWidgets.cupertino;
2+
using Unity.UIWidgets.widgets;
3+
4+
namespace UIWidgetsGallery.gallery {
5+
/*
6+
class CupertinoProgressIndicatorDemo : StatelessWidget {
7+
public static string routeName = "/cupertino/progress_indicator";
8+
9+
public override
10+
Widget build(BuildContext context) {
11+
return new CupertinoPageScaffold(
12+
navigationBar: new CupertinoNavigationBar(
13+
previousPageTitle: "Cupertino",
14+
middle: new Text("Activity Indicator"),
15+
trailing: new CupertinoDemoDocumentationButton(routeName)
16+
),
17+
child: new Center(
18+
child: new CupertinoActivityIndicator()
19+
)
20+
);
21+
}
22+
}
23+
*/
24+
}

Samples/UIWidgetsGallery/demo/cupertino/cupertino_activity_indicator_demo.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
using System.Collections.Generic;
2+
using Unity.UIWidgets.cupertino;
3+
using Unity.UIWidgets.foundation;
4+
using Unity.UIWidgets.painting;
5+
using Unity.UIWidgets.widgets;
6+
7+
namespace UIWidgetsGallery.gallery {
8+
/*
9+
class CupertinoAlertDemo : StatefulWidget {
10+
public static string routeName = "/cupertino/alert";
11+
public override State createState() => new _CupertinoAlertDemoState();
12+
}
13+
14+
class _CupertinoAlertDemoState : State<CupertinoAlertDemo> {
15+
string lastSelectedValue;
16+
17+
void showDemoDialog(
18+
BuildContext context = null,
19+
Widget child = null
20+
) {
21+
CupertinoRouteUtils.showCupertinoDialog<string>(
22+
context: context,
23+
builder: (BuildContext _context) => child
24+
).Then((string value) => {
25+
if (value != null) {
26+
this.setState(() => { this.lastSelectedValue = value; });
27+
}
28+
});
29+
}
30+
31+
void showDemoActionSheet(
32+
BuildContext context = null,
33+
Widget child = null
34+
) {
35+
CupertinoRouteUtils.showCupertinoModalPopup<string>(
36+
context: context,
37+
builder: (BuildContext _context) => child
38+
).Then((string value) => {
39+
if (value != null) {
40+
this.setState(() => { this.lastSelectedValue = value; });
41+
}
42+
});
43+
}
44+
45+
public override Widget build(BuildContext context) {
46+
return new CupertinoPageScaffold(
47+
navigationBar: new CupertinoNavigationBar(
48+
middle: new Text("Alerts"),
49+
previousPageTitle: "Cupertino",
50+
trailing: new CupertinoDemoDocumentationButton(CupertinoAlertDemo.routeName)
51+
),
52+
child:
53+
new DefaultTextStyle(
54+
style: CupertinoTheme.of(context).textTheme.textStyle,
55+
child: new Builder(
56+
builder: (BuildContext _context) => {
57+
List<Widget> stackChildren = new List<Widget> {
58+
new ListView(
59+
padding: EdgeInsets.symmetric(vertical: 24.0f, horizontal: 72.0f)
60+
+ MediaQuery.of(_context).padding,
61+
children: new List<Widget> {
62+
CupertinoButton.filled(
63+
child: new Text("Alert"),
64+
onPressed: () => {
65+
this.showDemoDialog(
66+
context: _context,
67+
child: new CupertinoAlertDialog(
68+
title: new Text("Discard draft?"),
69+
actions: new List<Widget> {
70+
new CupertinoDialogAction(
71+
child: new Text("Discard"),
72+
isDestructiveAction: true,
73+
onPressed: () => { Navigator.pop(_context, "Discard"); }
74+
),
75+
new CupertinoDialogAction(
76+
child: new Text("Cancel"),
77+
isDefaultAction: true,
78+
onPressed: () => { Navigator.pop(_context, "Cancel"); }
79+
),
80+
}
81+
)
82+
);
83+
}
84+
),
85+
new Padding(padding: EdgeInsets.all(8.0f)),
86+
CupertinoButton.filled(
87+
child: new Text("Alert with Title"),
88+
padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
89+
onPressed: () => {
90+
this.showDemoDialog(
91+
context: _context,
92+
child: new CupertinoAlertDialog(
93+
title: new Text(
94+
"Allow \"Maps\" to access your location while you are using the app?")
95+
,
96+
content: new Text(
97+
"Your current location will be displayed on the map and used \n" +
98+
"for directions, nearby search results, and estimated travel times.")
99+
,
100+
actions: new List<Widget> {
101+
new CupertinoDialogAction(
102+
child: new Text("Don\"t Allow"),
103+
onPressed: () => {
104+
Navigator.pop(_context, "Disallow");
105+
}
106+
),
107+
new CupertinoDialogAction(
108+
child: new Text("Allow"),
109+
onPressed: () => { Navigator.pop(_context, "Allow"); }
110+
),
111+
}
112+
)
113+
);
114+
}
115+
),
116+
new Padding(padding: EdgeInsets.all(8.0f)),
117+
CupertinoButton.filled(
118+
child: new Text("Alert with Buttons"),
119+
padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
120+
onPressed: () => {
121+
this.showDemoDialog(
122+
context: _context,
123+
child: new CupertinoDessertDialog(
124+
title: new Text("Select Favorite Dessert"),
125+
content: new Text(
126+
"Please select your favorite type of dessert from the \n" +
127+
"list below. Your selection will be used to customize the suggested \n" +
128+
"list of eateries in your area.")
129+
)
130+
);
131+
}
132+
),
133+
new Padding(padding: EdgeInsets.all(8.0f)),
134+
CupertinoButton.filled(
135+
child: new Text("Alert Buttons Only"),
136+
padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
137+
onPressed: () => {
138+
this.showDemoDialog(
139+
context: _context,
140+
child: new CupertinoDessertDialog()
141+
);
142+
}
143+
),
144+
new Padding(padding: EdgeInsets.all(8.0f)),
145+
CupertinoButton.filled(
146+
child: new Text("Action Sheet"),
147+
padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
148+
onPressed: () => {
149+
this.showDemoActionSheet(
150+
context: _context,
151+
child: new CupertinoActionSheet(
152+
title: new Text("Favorite Dessert"),
153+
message:
154+
new Text(
155+
"Please select the best dessert from the options below."),
156+
actions:
157+
new List<Widget> {
158+
new CupertinoActionSheetAction(
159+
child: new Text("Profiteroles"),
160+
onPressed: () => {
161+
Navigator.pop(_context, "Profiteroles");
162+
}
163+
),
164+
new CupertinoActionSheetAction(
165+
child: new Text("Cannolis"),
166+
onPressed: () => {
167+
Navigator.pop(_context, "Cannolis");
168+
}
169+
),
170+
new CupertinoActionSheetAction(
171+
child: new Text("Trifle"),
172+
onPressed: () => { Navigator.pop(_context, "Trifle"); }
173+
),
174+
},
175+
cancelButton: new CupertinoActionSheetAction(
176+
child: new Text("Cancel"),
177+
isDefaultAction:
178+
true,
179+
onPressed:
180+
() => { Navigator.pop(_context, "Cancel"); }
181+
)
182+
)
183+
);
184+
}
185+
)
186+
}
187+
)
188+
};
189+
190+
if (this.lastSelectedValue != null) {
191+
stackChildren.Add(
192+
new Positioned(
193+
bottom: 32.0f,
194+
child: new Text("You selected: $lastSelectedValue")
195+
)
196+
);
197+
}
198+
199+
return new Stack(
200+
alignment: Alignment.center,
201+
children: stackChildren
202+
);
203+
}
204+
)
205+
)
206+
);
207+
}
208+
}
209+
210+
class CupertinoDessertDialog : StatelessWidget {
211+
public CupertinoDessertDialog(
212+
Key key = null,
213+
Widget title = null,
214+
Widget content = null
215+
) : base(key: key) {
216+
this.title = title;
217+
this.content = content;
218+
}
219+
220+
public readonly Widget title;
221+
public readonly Widget content;
222+
223+
public override Widget build(BuildContext context) {
224+
return new CupertinoAlertDialog(
225+
title: title,
226+
content: content,
227+
actions: new List<Widget> {
228+
new CupertinoDialogAction(
229+
child: new Text("Cheesecake"),
230+
onPressed: () => { Navigator.pop(context, "Cheesecake"); }
231+
),
232+
new CupertinoDialogAction(
233+
child: new Text("Tiramisu"),
234+
onPressed: () => { Navigator.pop(context, "Tiramisu"); }
235+
),
236+
new CupertinoDialogAction(
237+
child: new Text("Apple Pie"),
238+
onPressed:
239+
() => { Navigator.pop(context, "Apple Pie"); }
240+
),
241+
new CupertinoDialogAction(
242+
child: new Text("Devil\"s food cake"),
243+
onPressed:
244+
() => { Navigator.pop(context, "Devil\"s food cake"); }
245+
),
246+
new CupertinoDialogAction(
247+
child: new Text("Banana Split"),
248+
onPressed:
249+
() => { Navigator.pop(context, "Banana Split"); }
250+
),
251+
new CupertinoDialogAction(
252+
child: new Text("Oatmeal Cookie"),
253+
onPressed:
254+
() => { Navigator.pop(context, "Oatmeal Cookies"); }
255+
),
256+
new CupertinoDialogAction(
257+
child: new Text("Chocolate Brownie"),
258+
onPressed:
259+
() => { Navigator.pop(context, "Chocolate Brownies"); }
260+
),
261+
new CupertinoDialogAction(
262+
child: new Text("Cancel"),
263+
isDestructiveAction:
264+
true,
265+
onPressed:
266+
() => { Navigator.pop(context, "Cancel"); }
267+
),
268+
}
269+
);
270+
}
271+
}
272+
*/
273+
}

Samples/UIWidgetsGallery/demo/cupertino/cupertino_alert_demo.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)