diff --git a/Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/indexLayout.xml b/Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/indexLayout.xml
index e0b8c34a..9f8a466b 100644
--- a/Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/indexLayout.xml
+++ b/Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/indexLayout.xml
@@ -8,6 +8,7 @@
Library/PackageCache/com.unity.ide.rider@1.1.4
Library/PackageCache/com.unity.ide.vscode@1.2.1
Library/PackageCache/com.unity.test-framework@1.1.14
+ Library/PackageCache/com.unity.test-framework@1.1.16
Library/PackageCache/com.unity.textmeshpro@2.0.1
Library/PackageCache/com.unity.timeline@1.2.15
Packages
@@ -18,6 +19,7 @@
.idea
.vs
Library
+ Logs
Temp
obj
diff --git a/Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/workspace.xml b/Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/workspace.xml
index ab9175f8..df644621 100644
--- a/Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/workspace.xml
+++ b/Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/workspace.xml
@@ -1,5 +1,215 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -20,4 +230,199 @@
+
+
+
+
+ 1606295678220
+
+
+ 1606295678220
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/../../com.unity.uiwidgets/Runtime/async2/schedule_microtask.cs
+ 137
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/../../com.unity.uiwidgets/Runtime/rendering/editable.cs
+ 1058
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/../../com.unity.uiwidgets/Runtime/rendering/editable.cs
+ 1100
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/../../com.unity.uiwidgets/Runtime/rendering/editable.cs
+ 1120
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/../../com.unity.uiwidgets/Runtime/rendering/editable.cs
+ 1111
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/../../com.unity.uiwidgets/Runtime/async2/timer.cs
+ 117
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs b/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs
index 175b60e7..5ee83b73 100644
--- a/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs
+++ b/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs
@@ -11,7 +11,12 @@ using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.rendering;
//using UIWidgetsGallery.gallery;
using Unity.UIWidgets.service;
-
+using Brightness = Unity.UIWidgets.ui.Brightness;
+using UnityEngine;
+using System;
+using UIWidgetsGallery.gallery;
+using Color = Unity.UIWidgets.ui.Color;
+using Random = UnityEngine.Random;
namespace UIWidgetsSample
{
@@ -28,401 +33,222 @@ namespace UIWidgetsSample
}
class MyApp : StatelessWidget
- {
- public override Widget build(BuildContext context)
- {
- return new CupertinoApp(
- home: new HomeScreen()
- );
- /*return new WidgetsApp(
- home: new HomeScreen(),
-
- pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
- new PageRouteBuilder(
- settings: settings,
- pageBuilder: (BuildContext Buildcontext, Animation animation,
- Animation secondaryAnimation) => builder(context)
- )
- );*/
-
- }
- }
+ {
+ public override Widget build(BuildContext context)
+ {
+ return new CupertinoApp(
+ home: new HomeScreen()
+ );
-
-
- class HomeScreen : StatelessWidget
- {
- public override Widget build(BuildContext context)
- {
- /*return new CupertinoPageScaffold(
- child: new Center(
- child: new Text("hello world!",
- style: CupertinoTheme.of(context).textTheme.navTitleTextStyle)
- ),
- backgroundColor: Colors.brown
- );*/
-
- List items = new List();
- items.Add( new BottomNavigationBarItem(
- icon: new Icon(CupertinoIcons.bell),
- title: new Text("views")
- ));
- items.Add(new BottomNavigationBarItem(
- icon: new Icon(CupertinoIcons.eye_solid),
- title: new Text("articles")
- ));
- return new CupertinoTabScaffold(
- tabBar: new CupertinoTabBar(
- items: items
- ),
- tabBuilder: ((contex, index) =>
- {
- //return new Center(child: new Text("hello"));
- return new CupertinoTabView(
- builder:(contex1) =>
- {
- return new CupertinoPageScaffold(
- navigationBar: new CupertinoNavigationBar(
- middle:(index==0)? new Text("views") : new Text("articles")
- ),
- child: new Center(
- /*child: new Text(
- "THIS IS TAB #" + index,
- style: CupertinoTheme.of(contex1)
- .textTheme
- .navTitleTextStyle
- //.copyWith(fontSize:32)
- )*/
- child: new CupertinoButton(
- child: new Text(
- "THIS IS TAB #",
- style: CupertinoTheme.of(contex1)
- .textTheme
- .navTitleTextStyle
- //.copyWith(fontSize:32)
- ),
-
- onPressed: () =>
- {
- Navigator.of(contex1).push(
- new CupertinoPageRoute(builder: (contex3) =>
- {
- return
- new DetailScreen1(index==0? "views" : "articles" );
- })
- );
- }
- )
- )
- );
- }
- );
- })
-
- );
-
-
- }
- }
-
- public class DetailScreen1 : StatelessWidget
- {
- public DetailScreen1(string topic)
- {
- this.topic = topic;
-
- }
-
- public string topic;
- public override Widget build(BuildContext context)
- {
- return new CupertinoPageScaffold(
- navigationBar: new CupertinoNavigationBar(
- //middle: new Text("Details")
- ),
- child: new Center(
- child: new Text("hello world")
- )
- );
- }
- }
- public class DetailScreen : StatefulWidget
- {
- public DetailScreen(string topic)
- {
- this.topic = topic;
- }
- public string topic;
-
-
- public override State createState()
- {
- return new DetailScreenState();
- }
- }
-
- public class DetailScreenState : State
- {
- public bool switchValue = false;
- public override Widget build(BuildContext context)
- {
- var widgets = new List();
- widgets.Add( new Expanded(child : new Text("a switch")));
- widgets.Add(new CupertinoSwitch(
- value: switchValue,
- onChanged: value =>
- {
- setState(() => switchValue = value);
- }
- ));
- var rowWidgtes = new List();
- var row = new Row(children:widgets);
- //rowWidgtes.Add(row);
-
- var cupBtn = new CupertinoButton(
- child: new Text("launch action sheet"),
- onPressed: () =>
- {
- CupertinoRouteUtils.showCupertinoModalPopup(
- context: context,
- builder: (context1) =>
- {
- return new CupertinoActionSheet(
- title: new Text("some choices"),
- actions: new List(){
- new CupertinoActionSheetAction(
- child: new Text("one"),
- onPressed: () =>
- {
- Navigator.pop(context1, 1);
- },
- isDefaultAction: true
- ),
- new CupertinoActionSheetAction(
- child: new Text("two"),
- onPressed: () =>
- {
- Navigator.pop(context1, 2);
- }
- ),
- new CupertinoActionSheetAction(
- child: new Text("three"),
- onPressed: () =>
- {
- Navigator.pop(context1, 3);
- }
- )
- }
- );
- }
- );
- }
- );
- rowWidgtes.Add(cupBtn);
-
- return new CupertinoPageScaffold(
- child: new Center(
- child: new Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.center,
- children:rowWidgtes
- )
- )
- /*,
- navigationBar: new CupertinoNavigationBar(
- middle: new Text("hello world")
- )*/
-
-
-
-
- );
- }
- }
-
- class CupertinoTextFieldDemo : StatefulWidget {
- public const string routeName = "/cupertino/text_fields";
-
- public override State createState() {
- return new _CupertinoTextFieldDemoState();
- }
- }
-
- class _CupertinoTextFieldDemoState : State {
- TextEditingController _chatTextController;
- TextEditingController _locationTextController;
-
- public override void initState() {
- base.initState();
- this._chatTextController = new TextEditingController();
- this._locationTextController = new TextEditingController(text: "Montreal, Canada");
+ }
}
- Widget _buildChatTextField() {
- return new CupertinoTextField(
- controller: this._chatTextController,
- textCapitalization: TextCapitalization.sentences,
- placeholder: "Text Message",
- decoration: new BoxDecoration(
- border: Border.all(
- width: 0.0f,
- color: CupertinoColors.inactiveGray
- ),
- borderRadius: BorderRadius.circular(15.0f)
- ),
- maxLines: null,
- keyboardType: TextInputType.multiline,
- prefix: new Padding(padding: EdgeInsets.symmetric(horizontal: 4.0f)),
- suffix:
- new Padding(
- padding: EdgeInsets.symmetric(horizontal: 4.0f),
- child: new CupertinoButton(
- color: CupertinoColors.activeGreen,
- minSize: 0.0f,
- child: new Icon(
- CupertinoIcons.up_arrow,
- size: 21.0f,
- color: CupertinoColors.white
- ),
- padding: EdgeInsets.all(2.0f),
- borderRadius:
- BorderRadius.circular(15.0f),
- onPressed: () => this.setState(() => this._chatTextController.clear())
+
+
+ class HomeScreen : StatelessWidget
+ {
+ public override Widget build(BuildContext context)
+ {
+ return new CupertinoPageScaffold(
+ child: new Center(
+ child: new CupertinoButton(
+ child: new Text(
+ "THIS IS TAB #"
+ ),
+ onPressed: () =>
+ {
+ Navigator.of(context).push(
+ new CupertinoPageRoute(builder: (contex3) =>
+ {
+ return
+ new CupertinoTextFieldDemo();
+ })
+ );
+ }
+ )
+ //new Text("hello world!", style: CupertinoTheme.of(context).textTheme.navTitleTextStyle)
)
- ),
- autofocus: true,
- suffixMode: OverlayVisibilityMode.editing,
- onSubmitted: (string text) => this.setState(() => this._chatTextController.clear())
- );
- }
+ //backgroundColor: Colors.brown
+ );
- Widget _buildNameField() {
- return new CupertinoTextField(
- prefix: new Icon(
- CupertinoIcons.person_solid,
- color: CupertinoColors.lightBackgroundGray,
- size: 28.0f
- ),
- padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
- clearButtonMode: OverlayVisibilityMode.editing,
- textCapitalization: TextCapitalization.words,
- autocorrect: false,
- decoration: new BoxDecoration(
- border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
- ),
- placeholder: "Name"
- );
- }
+ List items = new List();
+ items.Add(new BottomNavigationBarItem(
+ icon: new Icon(CupertinoIcons.bell),
+ title: new Text("views")
+ ));
+ items.Add(new BottomNavigationBarItem(
+ icon: new Icon(CupertinoIcons.eye_solid),
+ title: new Text("articles")
+ ));
+ return new CupertinoTabScaffold(
+ tabBar: new CupertinoTabBar(
+ items: items
+ ),
+ tabBuilder: ((contex, index) =>
+ {
+ //return new Center(child: new Text("hello"));
+ return new CupertinoTabView(
+ builder: (contex1) =>
+ {
+ return new CupertinoPageScaffold(
+ navigationBar: new CupertinoNavigationBar(
+ middle: (index == 0) ? new Text("views") : new Text("articles")
+ ),
+ child: new Center(
+ /*child: new Text(
+ "THIS IS TAB #" + index,
+ style: CupertinoTheme.of(contex1)
+ .textTheme
+ .navTitleTextStyle
+ //.copyWith(fontSize:32)
+ )*/
+ child: new CupertinoButton(
+ child: new Text(
+ "THIS IS TAB #",
+ style: CupertinoTheme.of(contex1)
+ .textTheme
+ .navTitleTextStyle
+ //.copyWith(fontSize:32)
+ ),
- Widget _buildEmailField() {
- return new CupertinoTextField(
- prefix: new Icon(
- CupertinoIcons.mail_solid,
- color: CupertinoColors.lightBackgroundGray,
- size: 28.0f
- ),
- padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
- clearButtonMode: OverlayVisibilityMode.editing,
- keyboardType: TextInputType.emailAddress,
- autocorrect: false,
- decoration: new BoxDecoration(
- border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
- ),
- placeholder: "Email"
- );
- }
-
- Widget _buildLocationField() {
- return new CupertinoTextField(
- controller: this._locationTextController,
- prefix: new Icon(
- CupertinoIcons.location_solid,
- color: CupertinoColors.lightBackgroundGray,
- size: 28.0f
- ),
- padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
- clearButtonMode: OverlayVisibilityMode.editing,
- textCapitalization: TextCapitalization.words,
- decoration: new BoxDecoration(
- border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
- ),
- placeholder: "Location"
- );
- }
-
- Widget _buildPinField() {
- return new CupertinoTextField(
- prefix: new Icon(
- CupertinoIcons.padlock_solid,
- color: CupertinoColors.lightBackgroundGray,
- size: 28.0f
- ),
- padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
- clearButtonMode: OverlayVisibilityMode.editing,
- keyboardType: TextInputType.number,
- autocorrect: false,
- obscureText: true,
- decoration: new BoxDecoration(
- border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
- ),
- placeholder: "Create a PIN"
- );
- }
-
- Widget _buildTagsField() {
- return new CupertinoTextField(
- controller: new TextEditingController(text: "colleague, reading club"),
- prefix: new Icon(
- CupertinoIcons.tags_solid,
- color: CupertinoColors.lightBackgroundGray,
- size: 28.0f
- ),
- enabled: false,
- padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
- decoration: new BoxDecoration(
- border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
- )
- );
- }
-
- public override Widget build(BuildContext context) {
- return new DefaultTextStyle(
- style: new TextStyle(
- fontFamily: ".SF Pro Text", // ".SF UI Text",
- inherit: false,
- fontSize: 17.0f,
- color: CupertinoColors.black
- ),
- child: new CupertinoPageScaffold(
-
- child: new SafeArea(
- child: new ListView(
- children: new List
- {
- /*new Padding(
- padding: EdgeInsets.symmetric(vertical: 32.0f, horizontal: 16.0f),
- child: new Column(
- children: new List {
- this._buildNameField(),
- this._buildEmailField(),
- this._buildLocationField(),
- this._buildPinField(),
- this._buildTagsField(),
+ onPressed: () =>
+ {
+ Navigator.of(contex1).push(
+ new CupertinoPageRoute(builder: (contex3) =>
+ {
+ return
+ new DetailScreen1(index == 0 ? "views" : "articles");
+ })
+ );
}
)
- ),*/
- new Padding(
- padding: EdgeInsets.symmetric(vertical: 32.0f, horizontal: 16.0f)//,
- //child: this._buildChatTextField()
- ),
- }
- )
-
+ )
+ );
+ }
+ );
+ })
+
+ );
+
+
+ }
+ }
+
+
+
+ public class DetailScreen1 : StatelessWidget
+ {
+ public DetailScreen1(string topic)
+ {
+ this.topic = topic;
+
+ }
+
+ public string topic;
+
+ public override Widget build(BuildContext context)
+ {
+ return new CupertinoPageScaffold(
+ navigationBar: new CupertinoNavigationBar(
+ //middle: new Text("Details")
+ ),
+ child: new Center(
+ child: new Text("hello world")
+ )
+ );
+ }
+ }
+
+ public class DetailScreen : StatefulWidget
+ {
+ public DetailScreen(string topic)
+ {
+ this.topic = topic;
+ }
+
+ public string topic;
+
+
+ public override State createState()
+ {
+ return new DetailScreenState();
+ }
+ }
+
+ public class DetailScreenState : State
+ {
+ public bool switchValue = false;
+
+ public override Widget build(BuildContext context)
+ {
+ var widgets = new List();
+ widgets.Add(new Expanded(child: new Text("a switch")));
+ widgets.Add(new CupertinoSwitch(
+ value: switchValue,
+ onChanged: value => { setState(() => switchValue = value); }
+ ));
+ var rowWidgtes = new List();
+ var row = new Row(children: widgets);
+ //rowWidgtes.Add(row);
+
+ var cupBtn = new CupertinoButton(
+ child: new Text("launch action sheet"),
+ onPressed: () =>
+ {
+ CupertinoRouteUtils.showCupertinoModalPopup(
+ context: context,
+ builder: (context1) =>
+ {
+ return new CupertinoActionSheet(
+ title: new Text("some choices"),
+ actions: new List()
+ {
+ new CupertinoActionSheetAction(
+ child: new Text("one"),
+ onPressed: () => { Navigator.pop(context1, 1); },
+ isDefaultAction: true
+ ),
+ new CupertinoActionSheetAction(
+ child: new Text("two"),
+ onPressed: () => { Navigator.pop(context1, 2); }
+ ),
+ new CupertinoActionSheetAction(
+ child: new Text("three"),
+ onPressed: () => { Navigator.pop(context1, 3); }
+ )
+ }
+ );
+ }
+ );
+ }
+ );
+ rowWidgtes.Add(cupBtn);
+
+ return new CupertinoPageScaffold(
+ child: new Center(
+ child: new Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: rowWidgtes
)
)
-
- );
+ /*,
+ navigationBar: new CupertinoNavigationBar(
+ middle: new Text("hello world")
+ )*/
+
+
+
+
+ );
+ }
}
+
+
+
+
+
}
- }
+
+
}
\ No newline at end of file
diff --git a/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs b/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs
index d7797f5c..b41922f3 100644
--- a/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs
+++ b/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs
@@ -1,17 +1,17 @@
using UIWidgetsGallery.gallery;
-using Unity.UIWidgets.engine;
+using Unity.UIWidgets.engine2;
using Unity.UIWidgets.material;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
namespace UIWidgetsGallery {
- /*public class GalleryMain : UIWidgetsPanel {
- protected override Widget createWidget() {
+ public class GalleryMain : UIWidgetsPanel {
+ /*protected override Widget createWidget() {
return new GalleryApp();
- }
+ }*/
- protected override void OnEnable() {
+ /*protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load("fonts/MaterialIcons-Regular"), "Material Icons");
FontManager.instance.addFont(Resources.Load("fonts/GalleryIcons"), "GalleryIcons");
@@ -21,6 +21,6 @@ namespace UIWidgetsGallery {
FontManager.instance.addFont(Resources.Load(path: "fonts/SF-Pro-Text-Bold"), ".SF Pro Text", FontWeight.w700);
base.OnEnable();
- }
- }*/
+ }*/
+ }
}
diff --git a/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_text_field_demo.cs b/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_text_field_demo.cs
index 63de00f6..181d683f 100644
--- a/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_text_field_demo.cs
+++ b/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_text_field_demo.cs
@@ -146,7 +146,8 @@ namespace UIWidgetsGallery.gallery {
padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
- )
+ ),
+ placeholder:"test"
);
}
@@ -159,29 +160,37 @@ namespace UIWidgetsGallery.gallery {
color: CupertinoColors.black
),
child: new CupertinoPageScaffold(
- navigationBar: new CupertinoNavigationBar(
+ /*navigationBar: new CupertinoNavigationBar(
previousPageTitle: "Cupertino",
middle: new Text("Text Fields")
- ),
- child: new SafeArea(
- child: new ListView(
+ ),*/
+ child:
+ /*new Padding(
+ padding: EdgeInsets.symmetric(vertical: 32.0f, horizontal: 16.0f),
+ child: this._buildTagsField()//_buildChatTextField()
+ )*/
+ new SafeArea(
+ child:
+
+
+ new ListView(
children: new List {
new Padding(
padding: EdgeInsets.symmetric(vertical: 32.0f, horizontal: 16.0f),
child: new Column(
children: new List {
- this._buildNameField(),
- this._buildEmailField(),
- this._buildLocationField(),
- this._buildPinField(),
- this._buildTagsField(),
+ //this._buildNameField(),
+ //this._buildEmailField(),// !点击crash!
+ this._buildLocationField()//, // !点击crash!
+ //this._buildPinField(),// !点击crash!
+ //this._buildTagsField()
}
)
),
new Padding(
- padding: EdgeInsets.symmetric(vertical: 32.0f, horizontal: 16.0f),
- child: this._buildChatTextField()
- ),
+ padding: EdgeInsets.symmetric(vertical: 32.0f, horizontal: 16.0f)//,
+ //child: this._buildChatTextField()
+ )
}
)
)
diff --git a/com.unity.uiwidgets/Runtime/cupertino/action_Sheet.cs b/com.unity.uiwidgets/Runtime/cupertino/action_Sheet.cs
index b675fbd1..070cbf91 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/action_Sheet.cs
+++ b/com.unity.uiwidgets/Runtime/cupertino/action_Sheet.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
@@ -10,35 +11,37 @@ using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.cupertino {
class CupertinoActionSheetUtils {
public static readonly TextStyle _kActionSheetActionStyle = new TextStyle(
- // fontFamily: ".SF UI Text",
- fontFamily: ".SF Pro Text",
+ fontFamily: ".SF UI Text",
inherit: false,
fontSize: 20.0f,
fontWeight: FontWeight.w400,
- color: CupertinoColors.activeBlue,
textBaseline: TextBaseline.alphabetic
);
public static readonly TextStyle _kActionSheetContentStyle = new TextStyle(
- // fontFamily: ".SF UI Text",
- fontFamily: ".SF Pro Text",
+ fontFamily: ".SF UI Text",
inherit: false,
fontSize: 13.0f,
fontWeight: FontWeight.w400,
color: _kContentTextColor,
textBaseline: TextBaseline.alphabetic
);
-
- public static readonly BoxDecoration _kAlertBlurOverlayDecoration = new BoxDecoration(
- color: CupertinoColors.white,
- backgroundBlendMode: BlendMode.overlay
+ public static readonly Color _kBackgroundColor = CupertinoDynamicColor.withBrightness(
+ color: new Color(0xC7F9F9F9),
+ darkColor: new Color(0xC7252525)
+ );
+ public static readonly Color _kPressedColor = CupertinoDynamicColor.withBrightness(
+ color: new Color(0xFFE1E1E1),
+ darkColor: new Color(0xFF2E2E2E)
);
- public static readonly Color _kBackgroundColor = new Color(0xD1F8F8F8);
- public static readonly Color _kPressedColor = new Color(0xA6E5E5EA);
- public static readonly Color _kButtonDividerColor = new Color(0x403F3F3F);
+ public static readonly Color _kCancelPressedColor = CupertinoDynamicColor.withBrightness(
+ color: new Color(0xFFECECEC),
+ darkColor: new Color(0xFF49494B)
+ );
+
public static readonly Color _kContentTextColor = new Color(0xFF8F8F8F);
- public static readonly Color _kCancelButtonPressedColor = new Color(0xFFEAEAEA);
+ public static readonly Color _kButtonDividerColor = _kContentTextColor;
public const float _kBlurAmount = 20.0f;
public const float _kEdgeHorizontalPadding = 8.0f;
@@ -79,7 +82,7 @@ namespace Unity.UIWidgets.cupertino {
public readonly ScrollController actionScrollController;
public readonly Widget cancelButton;
- Widget _buildContent() {
+ Widget _buildContent( BuildContext context ) {
List content = new List();
if (title != null || message != null) {
Widget titleSection = new _CupertinoAlertContentSection(
@@ -91,7 +94,7 @@ namespace Unity.UIWidgets.cupertino {
}
return new Container(
- color: CupertinoActionSheetUtils._kBackgroundColor,
+ color: CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kBackgroundColor, context),//CupertinoActionSheetUtils._kBackgroundColor,
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -131,15 +134,20 @@ namespace Unity.UIWidgets.cupertino {
new Flexible(child: new ClipRRect(
borderRadius: BorderRadius.circular(12.0f),
child: new BackdropFilter(
- filter: ImageFilter.blur(sigmaX: CupertinoActionSheetUtils._kBlurAmount,
+ filter: ImageFilter.blur(
+ sigmaX: CupertinoActionSheetUtils._kBlurAmount,
sigmaY: CupertinoActionSheetUtils._kBlurAmount),
- child: new Container(
+ child: new _CupertinoAlertRenderWidget(
+ contentSection: new Builder(builder: _buildContent),
+ actionsSection: _buildActions()
+ )
+ /*new Container(
decoration: CupertinoActionSheetUtils._kAlertBlurOverlayDecoration,
child: new _CupertinoAlertRenderWidget(
contentSection: _buildContent(),
actionsSection: _buildActions()
)
- )
+ )*/
)
)
),
@@ -161,7 +169,30 @@ namespace Unity.UIWidgets.cupertino {
actionSheetWidth = MediaQuery.of(context).size.height -
(CupertinoActionSheetUtils._kEdgeHorizontalPadding * 2);
}
-
+/// tbc semantics
+ /*return new SafeArea(
+ child: new Semantics(
+ namesRoute: true,
+ scopesRoute: true,
+ explicitChildNodes: true,
+ label: "Alert",
+ child: new CupertinoUserInterfaceLevel(
+ data: CupertinoUserInterfaceLevelData.elevated,
+ child: new Container(
+ width: actionSheetWidth,
+ margin: EdgeInsets.symmetric(
+ horizontal: CupertinoActionSheetUtils._kEdgeHorizontalPadding,
+ vertical: CupertinoActionSheetUtils._kEdgeVerticalPadding
+ ),
+ child: new Column(
+ children: children,
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch
+ )
+ )
+ )
+ )
+ );*/
return new SafeArea(
child: new Container(
width: actionSheetWidth,
@@ -182,11 +213,13 @@ namespace Unity.UIWidgets.cupertino {
public class CupertinoActionSheetAction : StatelessWidget {
public CupertinoActionSheetAction(
- Widget child,
- VoidCallback onPressed,
+ Key key = null,
+ VoidCallback onPressed = null,
bool isDefaultAction = false,
- bool isDestructiveAction = false
- ) {
+ bool isDestructiveAction = false,
+ Widget child = null
+ ):base(key:key)
+ {
D.assert(child != null);
D.assert(onPressed != null);
this.child = child;
@@ -201,16 +234,16 @@ namespace Unity.UIWidgets.cupertino {
public readonly Widget child;
public override Widget build(BuildContext context) {
- TextStyle style = CupertinoActionSheetUtils._kActionSheetActionStyle;
+ TextStyle style =CupertinoActionSheetUtils. _kActionSheetActionStyle.copyWith(
+ color: isDestructiveAction
+ ? CupertinoDynamicColor.resolve(CupertinoColors.systemRed, context)
+ : CupertinoTheme.of(context).primaryColor);
+ //CupertinoActionSheetUtils._kActionSheetActionStyle;
if (isDefaultAction) {
style = style.copyWith(fontWeight: FontWeight.w600);
}
- if (isDestructiveAction) {
- style = style.copyWith(color: CupertinoColors.destructiveRed);
- }
-
return new GestureDetector(
onTap: () => onPressed(),
behavior: HitTestBehavior.opaque,
@@ -218,6 +251,7 @@ namespace Unity.UIWidgets.cupertino {
constraints: new BoxConstraints(
minHeight: CupertinoActionSheetUtils._kButtonHeight
),
+ ////tbc semantics
child: new Container(
alignment: Alignment.center,
padding: EdgeInsets.symmetric(
@@ -251,33 +285,30 @@ namespace Unity.UIWidgets.cupertino {
}
class _CupertinoActionSheetCancelButtonState : State<_CupertinoActionSheetCancelButton> {
- Color _backgroundColor;
-
- public override void initState() {
- _backgroundColor = CupertinoColors.white;
- base.initState();
- }
-
+ bool isBeingPressed = false;
void _onTapDown(TapDownDetails evt) {
- setState(() => { _backgroundColor = CupertinoActionSheetUtils._kCancelButtonPressedColor; });
+ setState(() => { isBeingPressed = true; });
}
void _onTapUp(TapUpDetails evt) {
- setState(() => { _backgroundColor = CupertinoColors.white; });
+ setState(() => { isBeingPressed = false; });
}
void _onTapCancel() {
- setState(() => { _backgroundColor = CupertinoColors.white; });
+ setState(() => { isBeingPressed = false; });
}
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: _backgroundColor,
+ color: CupertinoDynamicColor.resolve(backgroundColor, context),
borderRadius: BorderRadius.circular(CupertinoActionSheetUtils._kCornerRadius)
),
child: widget.child
@@ -288,9 +319,10 @@ namespace Unity.UIWidgets.cupertino {
class _CupertinoAlertRenderWidget : RenderObjectWidget {
public _CupertinoAlertRenderWidget(
- Widget contentSection,
- Widget actionsSection,
- Key key = null
+ Key key = null,
+ Widget contentSection = null,
+ Widget actionsSection = null
+
) : base(key: key) {
this.contentSection = contentSection;
this.actionsSection = actionsSection;
@@ -302,13 +334,20 @@ namespace Unity.UIWidgets.cupertino {
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderCupertinoAlert(
dividerThickness: CupertinoActionSheetUtils._kDividerThickness /
- MediaQuery.of(context).devicePixelRatio
+ MediaQuery.of(context).devicePixelRatio,
+ dividerColor: CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kButtonDividerColor, context)
);
}
+ public override void updateRenderObject(BuildContext context, _RenderCupertinoAlert renderObject) {
+ base.updateRenderObject(context, renderObject);
+ renderObject.dividerColor = CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kButtonDividerColor, context);
+ }
+
public override Element createElement() {
return new _CupertinoAlertRenderElement(this);
}
+
}
class _CupertinoAlertRenderElement : RenderObjectElement {
@@ -318,11 +357,11 @@ namespace Unity.UIWidgets.cupertino {
Element _contentElement;
Element _actionsElement;
- public new _CupertinoAlertRenderWidget widget {
+ public override _CupertinoAlertRenderWidget widget {
get { return base.widget as _CupertinoAlertRenderWidget; }
}
- public new _RenderCupertinoAlert renderObject {
+ public override _RenderCupertinoAlert renderObject {
get { return base.renderObject as _RenderCupertinoAlert; }
}
@@ -360,7 +399,7 @@ namespace Unity.UIWidgets.cupertino {
_AlertSections.actionsSection);
}
- protected override void forgetChild(Element child) {
+ public override void forgetChild(Element child) {
D.assert(child == _contentElement || child == _actionsElement);
if (_contentElement == child) {
_contentElement = null;
@@ -368,6 +407,7 @@ namespace Unity.UIWidgets.cupertino {
else if (_actionsElement == child) {
_actionsElement = null;
}
+ base.forgetChild(child);
}
protected override void removeChildRenderObject(RenderObject child) {
@@ -381,6 +421,7 @@ namespace Unity.UIWidgets.cupertino {
}
void _placeChildInSlot(RenderObject child, object slot) {
+ D.assert(slot != null);
switch ((_AlertSections) slot) {
case _AlertSections.contentSection:
renderObject.contentSection = child as RenderBox;
@@ -398,11 +439,16 @@ namespace Unity.UIWidgets.cupertino {
public _RenderCupertinoAlert(
RenderBox contentSection = null,
RenderBox actionsSection = null,
- float dividerThickness = 0.0f
+ float dividerThickness = 0.0f,
+ Color dividerColor = null
) {
+ D.assert(dividerColor != null);
_contentSection = contentSection;
_actionsSection = actionsSection;
_dividerThickness = dividerThickness;
+ _dividerPaint = new Paint();
+ _dividerPaint.color = CupertinoActionSheetUtils._kButtonDividerColor;
+ _dividerPaint.style = PaintingStyle.fill;
}
public RenderBox contentSection {
@@ -422,8 +468,6 @@ namespace Unity.UIWidgets.cupertino {
}
RenderBox _contentSection;
-
-
public RenderBox actionsSection {
get { return _actionsSection; }
set {
@@ -442,12 +486,19 @@ namespace Unity.UIWidgets.cupertino {
RenderBox _actionsSection;
- readonly float _dividerThickness;
+ public Color dividerColor {
+ get { return _dividerPaint.color; }
+ set {
+ if (value == _dividerPaint.color) {
+ return;
+ }
+ _dividerPaint.color = value;
+ markNeedsPaint();
+ }
+ }
- readonly Paint _dividerPaint = new Paint() {
- color = CupertinoActionSheetUtils._kButtonDividerColor,
- style = PaintingStyle.fill
- };
+ public readonly float _dividerThickness;
+ public readonly Paint _dividerPaint;
public override void attach(object owner) {
base.attach(owner);
@@ -535,7 +586,7 @@ namespace Unity.UIWidgets.cupertino {
return 0.0f;
}
- protected internal override float computeMaxIntrinsicHeight(float width) {
+ protected override float computeMaxIntrinsicHeight(float width) {
float contentHeight = contentSection.getMaxIntrinsicHeight(width);
float actionsHeight = actionsSection.getMaxIntrinsicHeight(width);
bool hasDivider = contentHeight > 0.0f && actionsHeight > 0.0f;
@@ -552,7 +603,7 @@ namespace Unity.UIWidgets.cupertino {
return 0.0f;
}
- protected override void performLayout() {
+ public override void performLayout() {
bool hasDivider = contentSection.getMaxIntrinsicHeight(constraints.maxWidth) > 0.0f
&& actionsSection.getMaxIntrinsicHeight(constraints.maxWidth) > 0.0f;
float dividerThickness = hasDivider ? _dividerThickness : 0.0f;
@@ -573,7 +624,6 @@ namespace Unity.UIWidgets.cupertino {
);
Size actionsSize = actionsSection.size;
-
float actionSheetHeight = contentSize.height + dividerThickness + actionsSize.height;
@@ -598,16 +648,18 @@ namespace Unity.UIWidgets.cupertino {
actionsSection.paint(context, offset + actionsParentData.offset);
}
- void _paintDividerBetweenContentAndActions(Canvas canvas, Offset offset) {
+ public void _paintDividerBetweenContentAndActions(Canvas canvas, Offset offset) {
canvas.drawRect(
Rect.fromLTWH(
offset.dx,
- offset.dy + contentSection.size.height, size.width, _dividerThickness
+ offset.dy + contentSection.size.height,
+ size.width,
+ _dividerThickness
), _dividerPaint
);
}
- protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
+ public override bool hitTestChildren(BoxHitTestResult result, Offset position = null) {
MultiChildLayoutParentData contentSectionParentData =
contentSection.parentData as MultiChildLayoutParentData;
MultiChildLayoutParentData actionsSectionParentData =
@@ -725,8 +777,8 @@ namespace Unity.UIWidgets.cupertino {
class _CupertinoAlertActionSection : StatefulWidget {
public _CupertinoAlertActionSection(
- List children,
Key key = null,
+ List children = null,
ScrollController scrollController = null,
bool hasCancelButton = false
) : base(key: key) {
@@ -788,7 +840,7 @@ namespace Unity.UIWidgets.cupertino {
bool _isPressed = false;
public override Widget build(BuildContext context) {
- return new _ActionSheetActionButtonParentDataWidget(
+ return new _ActionButtonParentDataWidget(
isPressed: _isPressed,
child: new GestureDetector(
behavior: HitTestBehavior.opaque,
@@ -801,8 +853,8 @@ namespace Unity.UIWidgets.cupertino {
}
}
- class _ActionSheetActionButtonParentDataWidget : ParentDataWidget<_CupertinoAlertActionsRenderWidget> {
- public _ActionSheetActionButtonParentDataWidget(
+ class _ActionButtonParentDataWidget : ParentDataWidget<_ActionButtonParentData> {
+ public _ActionButtonParentDataWidget(
Widget child,
bool isPressed = false,
Key key = null
@@ -813,21 +865,29 @@ namespace Unity.UIWidgets.cupertino {
public readonly bool isPressed;
public override void applyParentData(RenderObject renderObject) {
- D.assert(renderObject.parentData is _ActionSheetActionButtonParentData);
- _ActionSheetActionButtonParentData parentData =
- renderObject.parentData as _ActionSheetActionButtonParentData;
+ D.assert(renderObject.parentData is _ActionButtonParentData);
+ _ActionButtonParentData parentData =
+ renderObject.parentData as _ActionButtonParentData;
if (parentData.isPressed != isPressed) {
parentData.isPressed = isPressed;
AbstractNodeMixinDiagnosticableTree targetParent = renderObject.parent;
+ // AbstractNode targetParent = renderObject.parent;
+ // tbc
if (targetParent is RenderObject) {
((RenderObject) targetParent).markNeedsPaint();
}
}
}
+
+ public new Type debugTypicalAncestorWidgetClass {
+ get {
+ return typeof(_CupertinoAlertActionsRenderWidget);
+ }
+ }
}
- class _ActionSheetActionButtonParentData : MultiChildLayoutParentData {
- public _ActionSheetActionButtonParentData(
+ public class _ActionButtonParentData : MultiChildLayoutParentData {
+ public _ActionButtonParentData(
bool isPressed = false
) {
this.isPressed = isPressed;
@@ -835,11 +895,11 @@ namespace Unity.UIWidgets.cupertino {
public bool isPressed;
}
-
+
class _CupertinoAlertActionsRenderWidget : MultiChildRenderObjectWidget {
public _CupertinoAlertActionsRenderWidget(
- List actionButtons,
Key key = null,
+ List actionButtons = null,
float dividerThickness = 0.0f,
bool hasCancelButton = false
) : base(key: key, children: actionButtons) {
@@ -853,13 +913,21 @@ namespace Unity.UIWidgets.cupertino {
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderCupertinoAlertActions(
dividerThickness: _dividerThickness,
- hasCancelButton: _hasCancelButton
+ dividerColor: CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kButtonDividerColor, context),
+ hasCancelButton: _hasCancelButton,
+ backgroundColor: CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kBackgroundColor, context),
+ pressedColor: CupertinoDynamicColor.resolve(CupertinoActionSheetUtils._kPressedColor, context)
);
}
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);
}
}
@@ -868,13 +936,32 @@ namespace Unity.UIWidgets.cupertino {
public _RenderCupertinoAlertActions(
List children = null,
float dividerThickness = 0.0f,
- bool hasCancelButton = false
+ Color dividerColor = null,
+ bool hasCancelButton = false,
+ Color backgroundColor = null,
+ Color pressedColor = null
) {
_dividerThickness = dividerThickness;
_hasCancelButton = hasCancelButton;
- addAll(children ?? new List());
+
+ _buttonBackgroundPaint = new Paint() {
+ color = CupertinoActionSheetUtils._kBackgroundColor,
+ style = PaintingStyle.fill
+ };
+
+ _pressedButtonBackgroundPaint = new Paint() {
+ color = CupertinoActionSheetUtils._kPressedColor,
+ style = PaintingStyle.fill
+ };
+
+ _dividerPaint = new Paint() {
+ color = CupertinoActionSheetUtils._kButtonDividerColor,
+ style = PaintingStyle.fill
+ };
+ addAll(children);
}
+ float _dividerThickness;
public float dividerThickness {
get { return _dividerThickness; }
set {
@@ -887,10 +974,40 @@ namespace Unity.UIWidgets.cupertino {
}
}
- float _dividerThickness;
+ public Color backgroundColor {
+ get { return _buttonBackgroundPaint.color; }
+ set {
+ if (value == _buttonBackgroundPaint.color) {
+ return;
+ }
+ _buttonBackgroundPaint.color = value;
+ markNeedsPaint();
+ }
+ }
+
+ public Color dividerColor {
+ get { return _dividerPaint.color; }
+ set {
+ if (value == _dividerPaint.color) {
+ return;
+ }
+ _dividerPaint.color = value;
+ markNeedsPaint();
+ }
+ }
+
+ public Color pressedColor {
+ get { return _pressedButtonBackgroundPaint.color; }
+ set {
+ if (value == _pressedButtonBackgroundPaint.color) {
+ return;
+ }
+ _pressedButtonBackgroundPaint.color = value;
+ markNeedsPaint();
+ }
+ }
bool _hasCancelButton;
-
public bool hasCancelButton {
get { return _hasCancelButton; }
set {
@@ -903,25 +1020,13 @@ namespace Unity.UIWidgets.cupertino {
}
}
-
- readonly Paint _buttonBackgroundPaint = new Paint() {
- color = CupertinoActionSheetUtils._kBackgroundColor,
- style = PaintingStyle.fill
- };
-
- readonly Paint _pressedButtonBackgroundPaint = new Paint() {
- color = CupertinoActionSheetUtils._kPressedColor,
- style = PaintingStyle.fill
- };
-
- readonly Paint _dividerPaint = new Paint() {
- color = CupertinoActionSheetUtils._kButtonDividerColor,
- style = PaintingStyle.fill
- };
+ public readonly Paint _buttonBackgroundPaint;
+ public readonly Paint _pressedButtonBackgroundPaint;
+ public readonly Paint _dividerPaint;
public override void setupParentData(RenderObject child) {
- if (!(child.parentData is _ActionSheetActionButtonParentData)) {
- child.parentData = new _ActionSheetActionButtonParentData();
+ if (!(child.parentData is _ActionButtonParentData)) {
+ child.parentData = new _ActionButtonParentData();
}
}
@@ -970,7 +1075,7 @@ namespace Unity.UIWidgets.cupertino {
+ (0.5f * childAfter(firstChild).getMinIntrinsicHeight(width));
}
- protected internal override float computeMaxIntrinsicHeight(float width) {
+ protected override float computeMaxIntrinsicHeight(float width) {
if (childCount == 0) {
return 0.0f;
}
@@ -1034,7 +1139,7 @@ namespace Unity.UIWidgets.cupertino {
void _drawButtonBackgroundsAndDividersStacked(Canvas canvas, Offset offset) {
Offset dividerOffset = new Offset(0.0f, dividerThickness);
Path backgroundFillPath = new Path();
- // fillType = PathFillType.evenOdd
+ backgroundFillPath.fillType = PathFillType.evenOdd;
backgroundFillPath.addRect(Rect.fromLTWH(0.0f, 0.0f, size.width, size.height));
Path pressedBackgroundFillPath = new Path();
@@ -1042,16 +1147,19 @@ namespace Unity.UIWidgets.cupertino {
Offset accumulatingOffset = offset;
RenderBox child = firstChild;
RenderBox prevChild = null;
+
while (child != null) {
- D.assert(child.parentData is _ActionSheetActionButtonParentData);
- _ActionSheetActionButtonParentData currentButtonParentData =
- child.parentData as _ActionSheetActionButtonParentData;
+ D.assert(child.parentData is _ActionButtonParentData);
+ _ActionButtonParentData currentButtonParentData =
+ child.parentData as _ActionButtonParentData;
bool isButtonPressed = currentButtonParentData.isPressed;
+
bool isPrevButtonPressed = false;
+
if (prevChild != null) {
- D.assert(prevChild.parentData is _ActionSheetActionButtonParentData);
- _ActionSheetActionButtonParentData previousButtonParentData =
- prevChild.parentData as _ActionSheetActionButtonParentData;
+ D.assert(prevChild.parentData is _ActionButtonParentData);
+ _ActionButtonParentData previousButtonParentData =
+ prevChild.parentData as _ActionButtonParentData;
isPrevButtonPressed = previousButtonParentData.isPressed;
}
@@ -1059,12 +1167,15 @@ namespace Unity.UIWidgets.cupertino {
bool isDividerPainted = isDividerPresent && !(isButtonPressed || isPrevButtonPressed);
Rect dividerRect = Rect.fromLTWH(
accumulatingOffset.dx,
- accumulatingOffset.dy, size.width, _dividerThickness
+ accumulatingOffset.dy,
+ size.width,
+ _dividerThickness
);
Rect buttonBackgroundRect = Rect.fromLTWH(
accumulatingOffset.dx,
- accumulatingOffset.dy + (isDividerPresent ? dividerThickness : 0.0f), size.width,
- child.size.height
+ accumulatingOffset.dy + (isDividerPresent ? dividerThickness : 0.0f),
+ size.width,
+ child.size.height
);
if (isButtonPressed) {
backgroundFillPath.addRect(buttonBackgroundRect);
diff --git a/com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs b/com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs
index 2690ce63..a1a130c7 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs
+++ b/com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs
@@ -1,5 +1,7 @@
using System;
+using System.Collections.Generic;
using Unity.UIWidgets.animation;
+using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
@@ -10,11 +12,20 @@ using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.cupertino {
static class CupertinoActivityIndicatorUtils {
public const float _kDefaultIndicatorRadius = 10.0f;
+ public const Color _kActiveTickColor = CupertinoDynamicColor.withBrightness(
+ color: Color(0xFF3C3C44),
+ darkColor: Color(0xFFEBEBF5)
+ );
+
public const float _kTwoPI = Mathf.PI * 2.0f;
public const int _kTickCount = 12;
+ // list
+ public static int[] _alphaValues = {
+ 147, 131, 114, 97, 81, 64, 47, 47, 47, 47, 47, 47
+ };
public const int _kHalfTickCount = _kTickCount / 2;
public static readonly Color _kTickColor = CupertinoColors.lightBackgroundGray;
- public static readonly Color _kActiveTickColor = new Color(0xFF9D9D9D);
+
}
public class CupertinoActivityIndicator : StatefulWidget {
@@ -23,6 +34,8 @@ namespace Unity.UIWidgets.cupertino {
bool animating = true,
float radius = CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius
) : base(key: key) {
+ D.assert(animating != null);
+ D.assert(radius != null);
D.assert(radius > 0);
this.animating = animating;
this.radius = radius;
@@ -77,6 +90,7 @@ namespace Unity.UIWidgets.cupertino {
child: new CustomPaint(
painter: new _CupertinoActivityIndicatorPainter(
position: _controller,
+ activeColor: CupertinoDynamicColor.resolve(CupertinoActivityIndicatorUtils._kActiveTickColor, context),
radius: widget.radius
)
)
@@ -84,24 +98,29 @@ namespace Unity.UIWidgets.cupertino {
}
}
- class _CupertinoActivityIndicatorPainter : AbstractCustomPainter {
+ class _CupertinoActivityIndicatorPainter : CustomPainter {
+ //AbstractCustomPainter {
public _CupertinoActivityIndicatorPainter(
- Animation position,
- float radius
+ Animation position = null,
+ Color activeColor = null,
+ float radius =0f
) : base(repaint: position) {
+
tickFundamentalRRect = RRect.fromLTRBXY(
left: -radius,
top: 1.0f * radius / CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius,
right: -radius / 2.0f,
bottom: -1.0f * radius / CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius,
- radiusX: 1.0f,
- radiusY: 1.0f
+ radiusX: 1.0f * radius / CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius,
+ radiusY: 1.0f * radius / CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius
);
this.position = position;
+ this.activeColor = activeColor;
}
-
- readonly Animation position;
- readonly RRect tickFundamentalRRect;
+
+ public readonly Animation position;
+ public readonly RRect tickFundamentalRRect;
+ public readonly Color activeColor;
public override void paint(Canvas canvas, Size size) {
Paint paint = new Paint();
@@ -112,10 +131,8 @@ namespace Unity.UIWidgets.cupertino {
int activeTick = (CupertinoActivityIndicatorUtils._kTickCount * position.value).floor();
for (int i = 0; i < CupertinoActivityIndicatorUtils._kTickCount; ++i) {
- float t = (((i + activeTick) % CupertinoActivityIndicatorUtils._kTickCount) /
- CupertinoActivityIndicatorUtils._kHalfTickCount).clamp(0, 1);
- paint.color = Color.lerp(a: CupertinoActivityIndicatorUtils._kActiveTickColor,
- b: CupertinoActivityIndicatorUtils._kTickColor, t: t);
+ int t = ((i + activeTick) % CupertinoActivityIndicatorUtils._kTickCount);
+ paint.color = activeColor.withAlpha(CupertinoActivityIndicatorUtils._alphaValues[t]);
canvas.drawRRect(tickFundamentalRRect,paint);
canvas.rotate(-CupertinoActivityIndicatorUtils._kTwoPI / CupertinoActivityIndicatorUtils._kTickCount);
}
@@ -124,7 +141,8 @@ namespace Unity.UIWidgets.cupertino {
}
public override bool shouldRepaint(CustomPainter oldPainter) {
- return (oldPainter as _CupertinoActivityIndicatorPainter).position != position;
+ return ((oldPainter as _CupertinoActivityIndicatorPainter).position != position) ||
+ ((oldPainter as _CupertinoActivityIndicatorPainter).activeColor != activeColor);
}
}
}
\ No newline at end of file
diff --git a/com.unity.uiwidgets/Runtime/cupertino/app.cs b/com.unity.uiwidgets/Runtime/cupertino/app.cs
index 608d3cf3..e927762e 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/app.cs
+++ b/com.unity.uiwidgets/Runtime/cupertino/app.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
-using Unity.UIWidgets.material;
+//using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
@@ -26,9 +26,23 @@ namespace Unity.UIWidgets.cupertino {
LocaleListResolutionCallback localeListResolutionCallback = null,
LocaleResolutionCallback localeResolutionCallback = null,
List supportedLocales = null,
- bool showPerformanceOverlay = false
+ bool showPerformanceOverlay = false,
+ bool checkerboardRasterCacheImages = false,
+ bool checkerboardOffscreenLayers = false,
+ bool showSemanticsDebugger = false,
+ bool debugShowCheckedModeBanner = true
+ // tbc????
+ //Dictionary shortcuts = null,
+ //Dictionary actions = null
) : base(key: key) {
+ D.assert(routes != null);
+ D.assert(navigatorObservers != null);
D.assert(title != null);
+ D.assert(showPerformanceOverlay != null);
+ D.assert(checkerboardRasterCacheImages != null);
+ D.assert(checkerboardOffscreenLayers != null);
+ D.assert(showSemanticsDebugger != null);
+ D.assert(debugShowCheckedModeBanner != null);
supportedLocales = supportedLocales ?? new List {new Locale("en", "US")};
this.navigatorKey = navigatorKey;
@@ -57,6 +71,7 @@ namespace Unity.UIWidgets.cupertino {
public readonly Dictionary routes;
public readonly string initialRoute;
public readonly RouteFactory onGenerateRoute;
+ public readonly InitialRouteListFactory onGenerateInitialRoutes;
public readonly RouteFactory onUnknownRoute;
public readonly List navigatorObservers;
public readonly TransitionBuilder builder;
@@ -69,6 +84,14 @@ namespace Unity.UIWidgets.cupertino {
public readonly LocaleResolutionCallback localeResolutionCallback;
public readonly List supportedLocales;
public readonly bool showPerformanceOverlay;
+ public readonly bool checkerboardRasterCacheImages;
+ public readonly bool checkerboardOffscreenLayers;
+ public readonly bool showSemanticsDebugger;
+ public readonly bool debugShowWidgetInspector;
+ public readonly bool debugShowCheckedModeBanner;
+ //TBC ????
+ //public readonly Dictionary shortcuts;
+ //public readonly Dictionary actions;
public override State createState() {
return new _CupertinoAppState();
@@ -111,7 +134,9 @@ namespace Unity.UIWidgets.cupertino {
List _navigatorObservers;
void _updateNavigator() {
- if (widget.home != null || widget.routes.isNotEmpty() || widget.onGenerateRoute != null ||
+ if (widget.home != null ||
+ widget.routes.isNotEmpty() ||
+ widget.onGenerateRoute != null ||
widget.onUnknownRoute != null) {
_navigatorObservers = new List();
foreach (var item in widget.navigatorObservers) {
@@ -131,51 +156,68 @@ namespace Unity.UIWidgets.cupertino {
}
_delegates.Add(DefaultCupertinoLocalizations.del);
- //_delegates.Add(DefaultMaterialLocalizations.del);
return new List(_delegates);
+
}
}
public override Widget build(BuildContext context) {
CupertinoThemeData effectiveThemeData = widget.theme ?? new CupertinoThemeData();
-
return new ScrollConfiguration(
behavior: new _AlwaysCupertinoScrollBehavior(),
- child: new CupertinoTheme(
- data: effectiveThemeData,
- child: new WidgetsApp(
- pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
- new CupertinoPageRoute(settings: settings, builder: builder),
- home: widget.home,
- routes: widget.routes,
- initialRoute: widget.initialRoute,
- onGenerateRoute: widget.onGenerateRoute,
- onUnknownRoute: widget.onUnknownRoute,
- builder: widget.builder,
- title: widget.title,
- onGenerateTitle: widget.onGenerateTitle,
- textStyle: effectiveThemeData.textTheme.textStyle,
- color: widget.color ?? CupertinoColors.activeBlue,
- locale: widget.locale,
- localizationsDelegates: _localizationsDelegates,
- localeResolutionCallback: widget.localeResolutionCallback,
- localeListResolutionCallback: widget.localeListResolutionCallback,
- supportedLocales: widget.supportedLocales,
- showPerformanceOverlay: widget.showPerformanceOverlay,
- inspectorSelectButtonBuilder: (BuildContext _context, VoidCallback onPressed) => {
- return CupertinoButton.filled(
- child: new Icon(
- CupertinoIcons.search,
- size: 28.0f,
- color: CupertinoColors.white
- ),
- padding: EdgeInsets.zero,
- onPressed: onPressed
- );
- }
+ child: new CupertinoUserInterfaceLevel(
+ data: CupertinoUserInterfaceLevelData.baselayer,
+ child: new CupertinoTheme(
+ data: effectiveThemeData,
+ child: new Builder(
+ builder: (BuildContext context1)=> {
+ return new WidgetsApp(
+ key: new GlobalObjectKey>(value: this),
+ navigatorKey: widget.navigatorKey,
+ onGenerateRoute: widget.onGenerateRoute,
+ onGenerateInitialRoutes: widget.onGenerateInitialRoutes,
+ onUnknownRoute: widget.onUnknownRoute,
+ navigatorObservers: _navigatorObservers,
+ initialRoute: widget.initialRoute,
+ pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
+ new CupertinoPageRoute(settings: settings, builder: builder),
+ home: widget.home,
+ routes: widget.routes,
+ builder: widget.builder,
+ title: widget.title,
+ onGenerateTitle: widget.onGenerateTitle,
+ textStyle: CupertinoTheme.of(context).textTheme.textStyle,
+ color: CupertinoDynamicColor.resolve(widget.color ?? effectiveThemeData.primaryColor, context),
+ 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 context2, VoidCallback onPressed)=>{
+ return CupertinoButton.filled(
+ child: new Icon(
+ CupertinoIcons.search,
+ size: 28.0f,
+ color: CupertinoColors.white
+ ),
+ padding: EdgeInsets.zero,
+ onPressed: onPressed
+ );
+ }
+ ///TBC????
+ //shortcuts: widget.shortcuts,
+ //actions: widget.actions
+ );
+ }
+ )
)
)
);
- }
+ }
}
}
\ No newline at end of file
diff --git a/com.unity.uiwidgets/Runtime/cupertino/bottom_app_bar.cs b/com.unity.uiwidgets/Runtime/cupertino/bottom_tab_bar.cs
similarity index 77%
rename from com.unity.uiwidgets/Runtime/cupertino/bottom_app_bar.cs
rename to com.unity.uiwidgets/Runtime/cupertino/bottom_tab_bar.cs
index ffc764a7..5cd8b46d 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/bottom_app_bar.cs
+++ b/com.unity.uiwidgets/Runtime/cupertino/bottom_tab_bar.cs
@@ -10,11 +10,18 @@ using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.cupertino {
class BottomAppBarUtils {
public const float _kTabBarHeight = 50.0f;
- public static readonly Color _kDefaultTabBarBorderColor = new Color(0x4C000000);
+
+ public static readonly Color _kDefaultTabBarBorderColor =
+ CupertinoDynamicColor.withBrightness(
+ color: new Color(0x4C000000),
+ darkColor: new Color(0x29000000)
+ );
+ public static readonly Color _kDefaultTabBarInactiveColor = CupertinoColors.inactiveGray;
}
- public class CupertinoTabBar : StatelessWidget {
+ public class CupertinoTabBar : StatelessWidget{
+
public CupertinoTabBar(
Key key = null,
List items = null,
@@ -26,20 +33,19 @@ namespace Unity.UIWidgets.cupertino {
float iconSize = 30.0f,
Border border = null
) : base(key: key) {
+
D.assert(items != null);
D.assert(items.Count >= 2,
() => "Tabs need at least 2 items to conform to Apple's HIG"
);
D.assert(0 <= currentIndex && currentIndex < items.Count);
-
this.items = items;
this.onTap = onTap;
this.currentIndex = currentIndex;
-
this.backgroundColor = backgroundColor;
this.activeColor = activeColor;
- this.inactiveColor = inactiveColor ?? CupertinoColors.inactiveGray;
+ this.inactiveColor = inactiveColor ?? BottomAppBarUtils._kDefaultTabBarInactiveColor;
this.iconSize = iconSize;
this.border = border ?? new Border(
top: new BorderSide(
@@ -73,16 +79,34 @@ namespace Unity.UIWidgets.cupertino {
public bool opaque(BuildContext context) {
Color backgroundColor =
this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor;
- return backgroundColor.alpha == 0xFF;
+ return CupertinoDynamicColor.resolve(backgroundColor, context).alpha == 0xFF;
}
public override Widget build(BuildContext context) {
float bottomPadding = MediaQuery.of(context).padding.bottom;
+ Color backgroundColor = CupertinoDynamicColor.resolve(
+ this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor,
+ context
+ );
+ BorderSide resolveBorderSide(BorderSide side) {
+ return side == BorderSide.none
+ ? side
+ : side.copyWith(color: CupertinoDynamicColor.resolve(side.color, context));
+ }
+ Border resolvedBorder = border == null || border.GetType() != typeof(Border)
+ ? border
+ : new Border(
+ top: resolveBorderSide(border.top),
+ left: resolveBorderSide(border.left),
+ bottom: resolveBorderSide(border.bottom),
+ right: resolveBorderSide(border.right)
+ );
+ Color inactive = CupertinoDynamicColor.resolve(inactiveColor, context);
Widget result = new DecoratedBox(
decoration: new BoxDecoration(
- border: border,
- color: backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor
+ border: resolvedBorder,//border,
+ color: backgroundColor //?? CupertinoTheme.of(context).barBackgroundColor
),
child: new SizedBox(
height: BottomAppBarUtils._kTabBarHeight + bottomPadding,
@@ -92,8 +116,8 @@ namespace Unity.UIWidgets.cupertino {
size: iconSize
),
child: new DefaultTextStyle( // Default with the inactive state.
- style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle
- .copyWith(color: inactiveColor),
+ style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(color: inactive),
+ //CupertinoTheme.of(context).textTheme.tabLabelTextStyle
child: new Padding(
padding: EdgeInsets.only(bottom: bottomPadding),
child: new Row(
@@ -128,6 +152,7 @@ namespace Unity.UIWidgets.cupertino {
_wrapActiveItem(
context,
new Expanded(
+ //// ??? semantics tbc ???
child: new GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap == null ? null : (GestureTapCallback) (() => { onTap(tabIndex); }),
@@ -167,7 +192,11 @@ namespace Unity.UIWidgets.cupertino {
return item;
}
- Color activeColor = this.activeColor ?? CupertinoTheme.of(context).primaryColor;
+ //Color activeColor = this.activeColor ?? CupertinoTheme.of(context).primaryColor;
+ Color activeColor = CupertinoDynamicColor.resolve(
+ this.activeColor ?? CupertinoTheme.of(context).primaryColor,
+ context
+ );
return IconTheme.merge(
data: new IconThemeData(color: activeColor),
child: DefaultTextStyle.merge(
diff --git a/com.unity.uiwidgets/Runtime/cupertino/bottom_app_bar.cs.meta b/com.unity.uiwidgets/Runtime/cupertino/bottom_tab_bar.cs.meta
similarity index 83%
rename from com.unity.uiwidgets/Runtime/cupertino/bottom_app_bar.cs.meta
rename to com.unity.uiwidgets/Runtime/cupertino/bottom_tab_bar.cs.meta
index 893c4f4d..2aa58485 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/bottom_app_bar.cs.meta
+++ b/com.unity.uiwidgets/Runtime/cupertino/bottom_tab_bar.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: aae818985ea0fb942b943da7205b523c
+guid: 85a418ac598e2534d8eaa6b8deff74af
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/com.unity.uiwidgets/Runtime/cupertino/button.cs b/com.unity.uiwidgets/Runtime/cupertino/button.cs
index 6d4b07fe..8ae72d0e 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/button.cs
+++ b/com.unity.uiwidgets/Runtime/cupertino/button.cs
@@ -4,7 +4,6 @@ using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
-using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
@@ -12,60 +11,64 @@ using TickerFuture = Unity.UIWidgets.scheduler2.TickerFuture;
namespace Unity.UIWidgets.cupertino {
public class CupertinoButtonUtils {
- public static readonly Color _kDisabledBackground = new Color(0xFFA9A9A9);
- public static readonly Color _kDisabledForeground = new Color(0xFFD1D1D1);
public static readonly EdgeInsets _kButtonPadding = EdgeInsets.all(16.0f);
- public static readonly EdgeInsets _kBackgroundButtonPadding = EdgeInsets.symmetric(vertical: 14.0f, horizontal: 64.0f);
+ public static readonly EdgeInsets _kBackgroundButtonPadding = EdgeInsets.symmetric(
+ vertical: 14.0f,
+ horizontal: 64.0f);
+ public static readonly float kMinInteractiveDimensionCupertino = 44.0f;
}
public class CupertinoButton : StatefulWidget {
public CupertinoButton(
- Widget child,
- VoidCallback onPressed,
Key key = null,
+ Widget child = null,
EdgeInsets padding = null,
Color color = null,
Color disabledColor = null,
- float minSize = 44.0f,
- float pressedOpacity = 0.1f,
+ float minSize = CupertinoButtonUtils.kMinInteractiveDimensionCupertino,
+ float pressedOpacity = 0.4f,
BorderRadius borderRadius = null,
- bool filled = false
+ VoidCallback onPressed = null
) : base(key: key) {
- D.assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0);
- _filled = filled;
+ D.assert((pressedOpacity >= 0.0 && pressedOpacity <= 1.0) || pressedOpacity == null );
+ D.assert(disabledColor != null);
+ _filled = false;
this.child = child;
this.onPressed = onPressed;
this.padding = padding;
this.color = color;
- this.disabledColor = disabledColor;
+ this.disabledColor = disabledColor ?? CupertinoColors.quaternarySystemFill;
this.minSize = minSize;
this.pressedOpacity = pressedOpacity;
this.borderRadius = borderRadius ?? BorderRadius.all(Radius.circular(8.0f));
}
public static CupertinoButton filled(
- Widget child,
- VoidCallback onPressed,
Key key = null,
+ Widget child = null,
EdgeInsets padding = null,
Color disabledColor = null,
- float minSize = 44.0f,
- float pressedOpacity = 0.1f,
- BorderRadius borderRadius = null
+ float minSize = CupertinoButtonUtils.kMinInteractiveDimensionCupertino,
+ float pressedOpacity = 0.4f,
+ BorderRadius borderRadius = null,
+ VoidCallback onPressed = null
) {
D.assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0);
- return new CupertinoButton(
+ D.assert(disabledColor != null);
+
+ var btn = new CupertinoButton(
key: key,
color: null,
child: child,
- onPressed: onPressed,
padding: padding,
disabledColor: disabledColor,
minSize: minSize,
pressedOpacity: pressedOpacity,
borderRadius: borderRadius,
- filled: true
+ onPressed: onPressed
);
+ btn._filled = true;
+ return btn;
}
public readonly Widget child;
@@ -80,10 +83,10 @@ namespace Unity.UIWidgets.cupertino {
public readonly float minSize;
- public readonly float? pressedOpacity;
+ public readonly float pressedOpacity;
public readonly BorderRadius borderRadius;
- public readonly bool _filled;
+ public bool _filled;
public bool enabled {
get { return onPressed != null; }
@@ -102,7 +105,7 @@ namespace Unity.UIWidgets.cupertino {
class _CupertinoButtonState : SingleTickerProviderStateMixin {
static readonly TimeSpan kFadeOutDuration = new TimeSpan(0, 0, 0, 0, 10);
static readonly TimeSpan kFadeInDuration = new TimeSpan(0, 0, 0, 0, 100);
- public readonly FloatTween _opacityTween = new FloatTween(begin: 1.0f, end: 0.0f);
+ public readonly Tween _opacityTween = new Tween(begin: 1.0f, end: 0.0f);
AnimationController _animationController;
Animation _opacityAnimation;
@@ -112,6 +115,7 @@ namespace Unity.UIWidgets.cupertino {
duration: new TimeSpan(0, 0, 0, 0, 200),
value: 0.0f,
vsync: this);
+
_opacityAnimation = _animationController
.drive(new CurveTween(curve: Curves.decelerate))
.drive(_opacityTween);
@@ -183,17 +187,21 @@ namespace Unity.UIWidgets.cupertino {
public override Widget build(BuildContext context) {
bool enabled = widget.enabled;
- Color primaryColor = CupertinoTheme.of(context).primaryColor;
- Color backgroundColor = widget.color ?? (widget._filled ? primaryColor : null);
+ CupertinoThemeData themeData = CupertinoTheme.of(context);
+ Color primaryColor = themeData.primaryColor;
+ Color backgroundColor = (widget.color == null)
+ ? (widget._filled ? primaryColor : null)
+ : CupertinoDynamicColor.resolve(widget.color, context);
Color foregroundColor = backgroundColor != null
- ? CupertinoTheme.of(context).primaryContrastingColor
+ ? themeData.primaryContrastingColor
: enabled
? primaryColor
- : CupertinoButtonUtils._kDisabledForeground;
+ : CupertinoDynamicColor.resolve(CupertinoColors.placeholderText, context);
TextStyle textStyle =
- CupertinoTheme.of(context).textTheme.textStyle.copyWith(color: foregroundColor);
+ themeData.textTheme.textStyle.copyWith(color: foregroundColor);
+
return new GestureDetector(
behavior: HitTestBehavior.opaque,
onTapDown: enabled ? _handleTapDown : (GestureTapDownCallback) null,
@@ -206,8 +214,11 @@ namespace Unity.UIWidgets.cupertino {
widget.onPressed();
}
},
+ ////tbc semantics
child: new ConstrainedBox(
- constraints: new BoxConstraints(
+ constraints: widget.minSize == null
+ ? new BoxConstraints() :
+ new BoxConstraints(
minWidth: widget.minSize,
minHeight: widget.minSize
),
@@ -217,7 +228,7 @@ namespace Unity.UIWidgets.cupertino {
decoration: new BoxDecoration(
borderRadius: widget.borderRadius,
color: backgroundColor != null && !enabled
- ? widget.disabledColor ?? CupertinoButtonUtils._kDisabledBackground
+ ? CupertinoDynamicColor.resolve(widget.disabledColor, context)
: backgroundColor
),
child: new Padding(
diff --git a/com.unity.uiwidgets/Runtime/cupertino/color.cs b/com.unity.uiwidgets/Runtime/cupertino/color.cs
deleted file mode 100644
index 53174181..00000000
--- a/com.unity.uiwidgets/Runtime/cupertino/color.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using Unity.UIWidgets.ui;
-
-namespace Unity.UIWidgets.cupertino {
- public class CupertinoColors {
- public static readonly Color activeBlue = new Color(0xFF007AFF);
-
- public static readonly Color activeGreen = new Color(0xFF4CD964);
-
- public static readonly Color activeOrange = new Color(0xFFFF9500);
-
- public static readonly Color white = new Color(0xFFFFFFFF);
-
- public static readonly Color black = new Color(0xFF000000);
-
- public static readonly Color lightBackgroundGray = new Color(0xFFE5E5EA);
-
- public static readonly Color extraLightBackgroundGray = new Color(0xFFEFEFF4);
-
- public static readonly Color darkBackgroundGray = new Color(0xFF171717);
-
- public static readonly Color inactiveGray = new Color(0xFF8E8E93);
-
- public static readonly Color destructiveRed = new Color(0xFFFF3B30);
- }
-}
\ No newline at end of file
diff --git a/com.unity.uiwidgets/Runtime/cupertino/colors.cs b/com.unity.uiwidgets/Runtime/cupertino/colors.cs
new file mode 100644
index 00000000..b0ee53d7
--- /dev/null
+++ b/com.unity.uiwidgets/Runtime/cupertino/colors.cs
@@ -0,0 +1,763 @@
+using System.Collections.Generic;
+using System.Linq;
+using Unity.UIWidgets.ui;
+using Unity.UIWidgets.foundation;
+using Unity.UIWidgets.widgets;
+using Unity.UIWidgets.painting;
+namespace Unity.UIWidgets.cupertino {
+ public class CupertinoColors {
+ public static CupertinoDynamicColor activeBlue = systemBlue;
+ public static CupertinoDynamicColor activeGreen = systemGreen;
+ public static CupertinoDynamicColor activeOrange = systemOrange;
+
+ public static Color white = new Color(0xFFFFFFFF);
+ public static Color black = new Color(0xFF000000);
+ public static Color lightBackgroundGray = new Color(0xFFE5E5EA);
+ public static Color extraLightBackgroundGray = new Color(0xFFEFEFF4);
+ public static Color darkBackgroundGray = new Color(0xFF171717);
+
+ public static CupertinoDynamicColor inactiveGray = CupertinoDynamicColor.withBrightness(
+ debugLabel: "inactiveGray",
+ color: new Color(0xFF999999),
+ darkColor: new Color(0xFF757575)
+ );
+
+ public static CupertinoDynamicColor destructiveRed = systemRed;
+
+ public static CupertinoDynamicColor systemBlue = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemBlue",
+ color: Color.fromARGB(255, 0, 122, 255),
+ darkColor: Color.fromARGB(255, 10, 132, 255),
+ highContrastColor: Color.fromARGB(255, 0, 64, 221),
+ darkHighContrastColor: Color.fromARGB(255, 64, 156, 255)
+ );
+
+ public static CupertinoDynamicColor systemGreen = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemGreen",
+ color: Color.fromARGB(255, 52, 199, 89),
+ darkColor: Color.fromARGB(255, 48, 209, 88),
+ highContrastColor: Color.fromARGB(255, 36, 138, 61),
+ darkHighContrastColor: Color.fromARGB(255, 48, 219, 91)
+ );
+
+ public static CupertinoDynamicColor systemIndigo = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemIndigo",
+ color: Color.fromARGB(255, 88, 86, 214),
+ darkColor: Color.fromARGB(255, 94, 92, 230),
+ highContrastColor: Color.fromARGB(255, 54, 52, 163),
+ darkHighContrastColor: Color.fromARGB(255, 125, 122, 255)
+ );
+
+ public static CupertinoDynamicColor systemOrange = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemOrange",
+ color: Color.fromARGB(255, 255, 149, 0),
+ darkColor: Color.fromARGB(255, 255, 159, 10),
+ highContrastColor: Color.fromARGB(255, 201, 52, 0),
+ darkHighContrastColor: Color.fromARGB(255, 255, 179, 64)
+ );
+
+ public static CupertinoDynamicColor systemPink = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemPink",
+ color: Color.fromARGB(255, 255, 45, 85),
+ darkColor: Color.fromARGB(255, 255, 55, 95),
+ highContrastColor: Color.fromARGB(255, 211, 15, 69),
+ darkHighContrastColor: Color.fromARGB(255, 255, 100, 130)
+ );
+
+ public static CupertinoDynamicColor systemPurple = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemPurple",
+ color: Color.fromARGB(255, 175, 82, 222),
+ darkColor: Color.fromARGB(255, 191, 90, 242),
+ highContrastColor: Color.fromARGB(255, 137, 68, 171),
+ darkHighContrastColor: Color.fromARGB(255, 218, 143, 255)
+ );
+
+ public static CupertinoDynamicColor systemRed = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemRed",
+ color: Color.fromARGB(255, 255, 59, 48),
+ darkColor: Color.fromARGB(255, 255, 69, 58),
+ highContrastColor: Color.fromARGB(255, 215, 0, 21),
+ darkHighContrastColor: Color.fromARGB(255, 255, 105, 97)
+ );
+
+ public static CupertinoDynamicColor systemTeal = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemTeal",
+ color: Color.fromARGB(255, 90, 200, 250),
+ darkColor: Color.fromARGB(255, 100, 210, 255),
+ highContrastColor: Color.fromARGB(255, 0, 113, 164),
+ darkHighContrastColor: Color.fromARGB(255, 112, 215, 255)
+ );
+
+ public static CupertinoDynamicColor systemYellow = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemYellow",
+ color: Color.fromARGB(255, 255, 204, 0),
+ darkColor: Color.fromARGB(255, 255, 214, 10),
+ highContrastColor: Color.fromARGB(255, 160, 90, 0),
+ darkHighContrastColor: Color.fromARGB(255, 255, 212, 38)
+ );
+
+ public static CupertinoDynamicColor systemGrey = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemGrey",
+ color: Color.fromARGB(255, 142, 142, 147),
+ darkColor: Color.fromARGB(255, 142, 142, 147),
+ highContrastColor: Color.fromARGB(255, 108, 108, 112),
+ darkHighContrastColor: Color.fromARGB(255, 174, 174, 178)
+ );
+
+ public static CupertinoDynamicColor systemGrey2 = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemGrey2",
+ color: Color.fromARGB(255, 174, 174, 178),
+ darkColor: Color.fromARGB(255, 99, 99, 102),
+ highContrastColor: Color.fromARGB(255, 142, 142, 147),
+ darkHighContrastColor: Color.fromARGB(255, 124, 124, 128)
+ );
+
+ public static CupertinoDynamicColor systemGrey3 = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemGrey3",
+ color: Color.fromARGB(255, 199, 199, 204),
+ darkColor: Color.fromARGB(255, 72, 72, 74),
+ highContrastColor: Color.fromARGB(255, 174, 174, 178),
+ darkHighContrastColor: Color.fromARGB(255, 84, 84, 86)
+ );
+
+ public static CupertinoDynamicColor systemGrey4 = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemGrey4",
+ color: Color.fromARGB(255, 209, 209, 214),
+ darkColor: Color.fromARGB(255, 58, 58, 60),
+ highContrastColor: Color.fromARGB(255, 188, 188, 192),
+ darkHighContrastColor: Color.fromARGB(255, 68, 68, 70)
+ );
+
+ public static CupertinoDynamicColor systemGrey5 = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemGrey5",
+ color: Color.fromARGB(255, 229, 229, 234),
+ darkColor: Color.fromARGB(255, 44, 44, 46),
+ highContrastColor: Color.fromARGB(255, 216, 216, 220),
+ darkHighContrastColor: Color.fromARGB(255, 54, 54, 56)
+ );
+
+ public static CupertinoDynamicColor systemGrey6 = CupertinoDynamicColor.withBrightnessAndContrast(
+ debugLabel: "systemGrey6",
+ color: Color.fromARGB(255, 242, 242, 247),
+ darkColor: Color.fromARGB(255, 28, 28, 30),
+ highContrastColor: Color.fromARGB(255, 235, 235, 240),
+ darkHighContrastColor: Color.fromARGB(255, 36, 36, 38)
+ );
+
+ public static CupertinoDynamicColor label = new CupertinoDynamicColor(
+ debugLabel: "label",
+ color: Color.fromARGB(255, 0, 0, 0),
+ darkColor: Color.fromARGB(255, 255, 255, 255),
+ highContrastColor: Color.fromARGB(255, 0, 0, 0),
+ darkHighContrastColor: Color.fromARGB(255, 255, 255, 255),
+ elevatedColor: Color.fromARGB(255, 0, 0, 0),
+ darkElevatedColor: Color.fromARGB(255, 255, 255, 255),
+ highContrastElevatedColor: Color.fromARGB(255, 0, 0, 0),
+ darkHighContrastElevatedColor: Color.fromARGB(255, 255, 255, 255)
+ );
+
+ public static CupertinoDynamicColor secondaryLabel = new CupertinoDynamicColor(
+ debugLabel: "secondaryLabel",
+ color: Color.fromARGB(153, 60, 60, 67),
+ darkColor: Color.fromARGB(153, 235, 235, 245),
+ highContrastColor: Color.fromARGB(173, 60, 60, 67),
+ darkHighContrastColor: Color.fromARGB(173, 235, 235, 245),
+ elevatedColor: Color.fromARGB(153, 60, 60, 67),
+ darkElevatedColor: Color.fromARGB(153, 235, 235, 245),
+ highContrastElevatedColor: Color.fromARGB(173, 60, 60, 67),
+ darkHighContrastElevatedColor: Color.fromARGB(173, 235, 235, 245)
+ );
+
+ /// The color for text labels containing tertiary content, equivalent to
+ /// [UIColor.tertiaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173153-tertiarylabel).
+ public static CupertinoDynamicColor tertiaryLabel = new CupertinoDynamicColor(
+ debugLabel: "tertiaryLabel",
+ color: Color.fromARGB(76, 60, 60, 67),
+ darkColor: Color.fromARGB(76, 235, 235, 245),
+ highContrastColor: Color.fromARGB(96, 60, 60, 67),
+ darkHighContrastColor: Color.fromARGB(96, 235, 235, 245),
+ elevatedColor: Color.fromARGB(76, 60, 60, 67),
+ darkElevatedColor: Color.fromARGB(76, 235, 235, 245),
+ highContrastElevatedColor: Color.fromARGB(96, 60, 60, 67),
+ darkHighContrastElevatedColor: Color.fromARGB(96, 235, 235, 245)
+ );
+
+ public static CupertinoDynamicColor quaternaryLabel = new CupertinoDynamicColor(
+ debugLabel: "quaternaryLabel",
+ color: Color.fromARGB(45, 60, 60, 67),
+ darkColor: Color.fromARGB(40, 235, 235, 245),
+ highContrastColor: Color.fromARGB(66, 60, 60, 67),
+ darkHighContrastColor: Color.fromARGB(61, 235, 235, 245),
+ elevatedColor: Color.fromARGB(45, 60, 60, 67),
+ darkElevatedColor: Color.fromARGB(40, 235, 235, 245),
+ highContrastElevatedColor: Color.fromARGB(66, 60, 60, 67),
+ darkHighContrastElevatedColor: Color.fromARGB(61, 235, 235, 245)
+ );
+
+ public static CupertinoDynamicColor systemFill = new CupertinoDynamicColor(
+ debugLabel: "systemFill",
+ color: Color.fromARGB(51, 120, 120, 128),
+ darkColor: Color.fromARGB(91, 120, 120, 128),
+ highContrastColor: Color.fromARGB(71, 120, 120, 128),
+ darkHighContrastColor: Color.fromARGB(112, 120, 120, 128),
+ elevatedColor: Color.fromARGB(51, 120, 120, 128),
+ darkElevatedColor: Color.fromARGB(91, 120, 120, 128),
+ highContrastElevatedColor: Color.fromARGB(71, 120, 120, 128),
+ darkHighContrastElevatedColor: Color.fromARGB(112, 120, 120, 128)
+ );
+
+ public static CupertinoDynamicColor secondarySystemFill = new CupertinoDynamicColor(
+ debugLabel: "secondarySystemFill",
+ color: Color.fromARGB(40, 120, 120, 128),
+ darkColor: Color.fromARGB(81, 120, 120, 128),
+ highContrastColor: Color.fromARGB(61, 120, 120, 128),
+ darkHighContrastColor: Color.fromARGB(102, 120, 120, 128),
+ elevatedColor: Color.fromARGB(40, 120, 120, 128),
+ darkElevatedColor: Color.fromARGB(81, 120, 120, 128),
+ highContrastElevatedColor: Color.fromARGB(61, 120, 120, 128),
+ darkHighContrastElevatedColor: Color.fromARGB(102, 120, 120, 128)
+ );
+
+ public static CupertinoDynamicColor tertiarySystemFill = new CupertinoDynamicColor(
+ debugLabel: "tertiarySystemFill",
+ color: Color.fromARGB(30, 118, 118, 128),
+ darkColor: Color.fromARGB(61, 118, 118, 128),
+ highContrastColor: Color.fromARGB(51, 118, 118, 128),
+ darkHighContrastColor: Color.fromARGB(81, 118, 118, 128),
+ elevatedColor: Color.fromARGB(30, 118, 118, 128),
+ darkElevatedColor: Color.fromARGB(61, 118, 118, 128),
+ highContrastElevatedColor: Color.fromARGB(51, 118, 118, 128),
+ darkHighContrastElevatedColor: Color.fromARGB(81, 118, 118, 128)
+ );
+
+ public static CupertinoDynamicColor quaternarySystemFill = new CupertinoDynamicColor(
+ debugLabel: "quaternarySystemFill",
+ color: Color.fromARGB(20, 116, 116, 128),
+ darkColor: Color.fromARGB(45, 118, 118, 128),
+ highContrastColor: Color.fromARGB(40, 116, 116, 128),
+ darkHighContrastColor: Color.fromARGB(66, 118, 118, 128),
+ elevatedColor: Color.fromARGB(20, 116, 116, 128),
+ darkElevatedColor: Color.fromARGB(45, 118, 118, 128),
+ highContrastElevatedColor: Color.fromARGB(40, 116, 116, 128),
+ darkHighContrastElevatedColor: Color.fromARGB(66, 118, 118, 128)
+ );
+
+ /// The color for placeholder text in controls or text views, equivalent to
+ /// [UIColor.placeholderText](https://developer.apple.com/documentation/uikit/uicolor/3173134-placeholdertext).
+ public static CupertinoDynamicColor placeholderText = new CupertinoDynamicColor(
+ debugLabel: "placeholderText",
+ color: Color.fromARGB(76, 60, 60, 67),
+ darkColor: Color.fromARGB(76, 235, 235, 245),
+ highContrastColor: Color.fromARGB(96, 60, 60, 67),
+ darkHighContrastColor: Color.fromARGB(96, 235, 235, 245),
+ elevatedColor: Color.fromARGB(76, 60, 60, 67),
+ darkElevatedColor: Color.fromARGB(76, 235, 235, 245),
+ highContrastElevatedColor: Color.fromARGB(96, 60, 60, 67),
+ darkHighContrastElevatedColor: Color.fromARGB(96, 235, 235, 245)
+ );
+
+ public static CupertinoDynamicColor systemBackground = new CupertinoDynamicColor(
+ debugLabel: "systemBackground",
+ color: Color.fromARGB(255, 255, 255, 255),
+ darkColor: Color.fromARGB(255, 0, 0, 0),
+ highContrastColor: Color.fromARGB(255, 255, 255, 255),
+ darkHighContrastColor: Color.fromARGB(255, 0, 0, 0),
+ elevatedColor: Color.fromARGB(255, 255, 255, 255),
+ darkElevatedColor: Color.fromARGB(255, 28, 28, 30),
+ highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255),
+ darkHighContrastElevatedColor: Color.fromARGB(255, 36, 36, 38)
+ );
+
+ public static CupertinoDynamicColor secondarySystemBackground = new CupertinoDynamicColor(
+ debugLabel: "secondarySystemBackground",
+ color: Color.fromARGB(255, 242, 242, 247),
+ darkColor: Color.fromARGB(255, 28, 28, 30),
+ highContrastColor: Color.fromARGB(255, 235, 235, 240),
+ darkHighContrastColor: Color.fromARGB(255, 36, 36, 38),
+ elevatedColor: Color.fromARGB(255, 242, 242, 247),
+ darkElevatedColor: Color.fromARGB(255, 44, 44, 46),
+ highContrastElevatedColor: Color.fromARGB(255, 235, 235, 240),
+ darkHighContrastElevatedColor: Color.fromARGB(255, 54, 54, 56)
+ );
+
+ public static CupertinoDynamicColor tertiarySystemBackground = new CupertinoDynamicColor(
+ debugLabel: "tertiarySystemBackground",
+ color: Color.fromARGB(255, 255, 255, 255),
+ darkColor: Color.fromARGB(255, 44, 44, 46),
+ highContrastColor: Color.fromARGB(255, 255, 255, 255),
+ darkHighContrastColor: Color.fromARGB(255, 54, 54, 56),
+ elevatedColor: Color.fromARGB(255, 255, 255, 255),
+ darkElevatedColor: Color.fromARGB(255, 58, 58, 60),
+ highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255),
+ darkHighContrastElevatedColor: Color.fromARGB(255, 68, 68, 70)
+ );
+
+ public static CupertinoDynamicColor systemGroupedBackground = new CupertinoDynamicColor(
+ debugLabel: "systemGroupedBackground",
+ color: Color.fromARGB(255, 242, 242, 247),
+ darkColor: Color.fromARGB(255, 0, 0, 0),
+ highContrastColor: Color.fromARGB(255, 235, 235, 240),
+ darkHighContrastColor: Color.fromARGB(255, 0, 0, 0),
+ elevatedColor: Color.fromARGB(255, 242, 242, 247),
+ darkElevatedColor: Color.fromARGB(255, 28, 28, 30),
+ highContrastElevatedColor: Color.fromARGB(255, 235, 235, 240),
+ darkHighContrastElevatedColor: Color.fromARGB(255, 36, 36, 38)
+ );
+
+ public static CupertinoDynamicColor secondarySystemGroupedBackground = new CupertinoDynamicColor(
+ debugLabel: "secondarySystemGroupedBackground",
+ color: Color.fromARGB(255, 255, 255, 255),
+ darkColor: Color.fromARGB(255, 28, 28, 30),
+ highContrastColor: Color.fromARGB(255, 255, 255, 255),
+ darkHighContrastColor: Color.fromARGB(255, 36, 36, 38),
+ elevatedColor: Color.fromARGB(255, 255, 255, 255),
+ darkElevatedColor: Color.fromARGB(255, 44, 44, 46),
+ highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255),
+ darkHighContrastElevatedColor: Color.fromARGB(255, 54, 54, 56)
+ );
+
+ public static CupertinoDynamicColor tertiarySystemGroupedBackground = new CupertinoDynamicColor(
+ debugLabel: "tertiarySystemGroupedBackground",
+ color: Color.fromARGB(255, 242, 242, 247),
+ darkColor: Color.fromARGB(255, 44, 44, 46),
+ highContrastColor: Color.fromARGB(255, 235, 235, 240),
+ darkHighContrastColor: Color.fromARGB(255, 54, 54, 56),
+ elevatedColor: Color.fromARGB(255, 242, 242, 247),
+ darkElevatedColor: Color.fromARGB(255, 58, 58, 60),
+ highContrastElevatedColor: Color.fromARGB(255, 235, 235, 240),
+ darkHighContrastElevatedColor: Color.fromARGB(255, 68, 68, 70)
+ );
+
+ public static CupertinoDynamicColor separator = new CupertinoDynamicColor(
+ debugLabel: "separator",
+ color: Color.fromARGB(73, 60, 60, 67),
+ darkColor: Color.fromARGB(153, 84, 84, 88),
+ highContrastColor: Color.fromARGB(94, 60, 60, 67),
+ darkHighContrastColor: Color.fromARGB(173, 84, 84, 88),
+ elevatedColor: Color.fromARGB(73, 60, 60, 67),
+ darkElevatedColor: Color.fromARGB(153, 84, 84, 88),
+ highContrastElevatedColor: Color.fromARGB(94, 60, 60, 67),
+ darkHighContrastElevatedColor: Color.fromARGB(173, 84, 84, 88)
+ );
+
+ /// The color for borders or divider lines that hide any underlying content,
+ /// equivalent to [UIColor.opaqueSeparator](https://developer.apple.com/documentation/uikit/uicolor/3173133-opaqueseparator).
+ public static CupertinoDynamicColor opaqueSeparator = new CupertinoDynamicColor(
+ debugLabel: "opaqueSeparator",
+ color: Color.fromARGB(255, 198, 198, 200),
+ darkColor: Color.fromARGB(255, 56, 56, 58),
+ highContrastColor: Color.fromARGB(255, 198, 198, 200),
+ darkHighContrastColor: Color.fromARGB(255, 56, 56, 58),
+ elevatedColor: Color.fromARGB(255, 198, 198, 200),
+ darkElevatedColor: Color.fromARGB(255, 56, 56, 58),
+ highContrastElevatedColor: Color.fromARGB(255, 198, 198, 200),
+ darkHighContrastElevatedColor: Color.fromARGB(255, 56, 56, 58)
+ );
+
+ public static CupertinoDynamicColor link =
+ new CupertinoDynamicColor(
+ debugLabel: "link",
+ color: Color.fromARGB(255, 0, 122, 255),
+ darkColor: Color.fromARGB(255, 9, 132, 255),
+ highContrastColor: Color.fromARGB(255, 0, 122, 255),
+ darkHighContrastColor: Color.fromARGB(255, 9, 132, 255),
+ elevatedColor: Color.fromARGB(255, 0, 122, 255),
+ darkElevatedColor: Color.fromARGB(255, 9, 132, 255),
+ highContrastElevatedColor: Color.fromARGB(255, 0, 122, 255),
+ darkHighContrastElevatedColor: Color.fromARGB(255, 9, 132, 255)
+ );
+ }
+
+ public class CupertinoDynamicColor : Color, Diagnosticable {
+
+ public CupertinoDynamicColor(
+ string debugLabel = null,
+ Color color = null,
+ Color darkColor = null,
+ Color highContrastColor = null,
+ Color darkHighContrastColor = null,
+ Color elevatedColor = null,
+ Color darkElevatedColor = null,
+ Color highContrastElevatedColor = null,
+ Color darkHighContrastElevatedColor = null
+ ) : base(0) {
+ /// ._
+ D.assert(color != null);
+ D.assert(darkColor != null);
+ D.assert(highContrastColor != null);
+ D.assert(darkHighContrastColor != null);
+ D.assert(elevatedColor != null);
+ D.assert(darkElevatedColor != null);
+ D.assert(highContrastElevatedColor != null);
+ D.assert(darkHighContrastElevatedColor != null);
+ D.assert(_effectiveColor != null);
+ _effectiveColor = color;
+ this.color = color;
+ this.darkColor = darkColor;
+ this.highContrastColor = highContrastColor;
+ this.darkHighContrastColor = darkHighContrastColor;
+ this.elevatedColor = elevatedColor;
+ this.darkElevatedColor = darkElevatedColor;
+ this.highContrastElevatedColor = highContrastElevatedColor;
+ this.darkHighContrastElevatedColor = darkHighContrastElevatedColor;
+ _debugResolveContext = null;
+ _debugLabel = debugLabel;
+ }
+
+ public static CupertinoDynamicColor create(
+ Color _effectiveColor,
+ Color color,
+ Color darkColor ,
+ Color highContrastColor ,
+ Color darkHighContrastColor ,
+ Color elevatedColor ,
+ Color darkElevatedColor ,
+ Color highContrastElevatedColor ,
+ Color darkHighContrastElevatedColor ,
+ Element _debugResolveContext ,
+ string _debugLabel
+ ) {
+ var dynamicColor = new CupertinoDynamicColor(
+ debugLabel: _debugLabel,
+ color: color,
+ darkColor: darkColor,
+ highContrastColor: color,
+ darkHighContrastColor: darkColor,
+ elevatedColor: color,
+ darkElevatedColor: darkColor,
+ highContrastElevatedColor: color,
+ darkHighContrastElevatedColor: darkColor
+ );
+ dynamicColor._effectiveColor = _effectiveColor;
+ dynamicColor._debugResolveContext = _debugResolveContext;
+ return dynamicColor;
+
+ }
+
+ public static CupertinoDynamicColor withBrightnessAndContrast(
+ string debugLabel = null,
+ Color color = null,
+ Color darkColor = null,
+ Color highContrastColor = null,
+ Color darkHighContrastColor = null
+ ) {
+
+ return new CupertinoDynamicColor(
+ debugLabel: debugLabel,
+ color: color,
+ darkColor: darkColor,
+ highContrastColor: highContrastColor,
+ darkHighContrastColor: darkHighContrastColor,
+ elevatedColor: color,
+ darkElevatedColor: darkColor,
+ highContrastElevatedColor: highContrastColor,
+ darkHighContrastElevatedColor: darkHighContrastColor
+ );
+ }
+
+ public static CupertinoDynamicColor withBrightness(
+ string debugLabel = null,
+ Color color = null,
+ Color darkColor = null
+ ) {
+ return new CupertinoDynamicColor(
+ debugLabel: debugLabel,
+ color: color,
+ darkColor: darkColor,
+ highContrastColor: color,
+ darkHighContrastColor: darkColor,
+ elevatedColor: color,
+ darkElevatedColor: darkColor,
+ highContrastElevatedColor: color,
+ darkHighContrastElevatedColor: darkColor);
+ }
+
+ public Color _effectiveColor;
+
+
+ public int value {
+ get { return (int) _effectiveColor.value; }
+ }
+
+
+ public readonly string _debugLabel;
+
+ public Element _debugResolveContext;
+ public readonly Color color;
+
+ public readonly Color darkColor;
+
+ public readonly Color highContrastColor;
+ public readonly Color darkHighContrastColor;
+
+ public readonly Color elevatedColor;
+
+ public readonly Color darkElevatedColor;
+ public readonly Color highContrastElevatedColor;
+ public readonly Color darkHighContrastElevatedColor;
+
+
+ public static Color resolve(Color resolvable, BuildContext context, bool nullOk = true) {
+ if (resolvable == null)
+ return null;
+ D.assert(context != null);
+ return (resolvable is CupertinoDynamicColor)
+ ? ((CupertinoDynamicColor) resolvable).resolveFrom(context, nullOk: nullOk)
+ : resolvable;
+ }
+
+ public bool _isPlatformBrightnessDependent {
+ get {
+ return color != darkColor
+ || elevatedColor != darkElevatedColor
+ || highContrastColor != darkHighContrastColor
+ || highContrastElevatedColor != darkHighContrastElevatedColor;
+ }
+
+ }
+
+ public bool _isHighContrastDependent {
+ get {
+ return color != highContrastColor
+ || darkColor != darkHighContrastColor
+ || elevatedColor != highContrastElevatedColor
+ || darkElevatedColor != darkHighContrastElevatedColor;
+ }
+ }
+
+ public bool _isInterfaceElevationDependent {
+ get {
+ return color != elevatedColor
+ || darkColor != darkElevatedColor
+ || highContrastColor != highContrastElevatedColor
+ || darkHighContrastColor != darkHighContrastElevatedColor;
+ }
+ }
+
+ public CupertinoDynamicColor resolveFrom(BuildContext context, bool nullOk = true) {
+ Brightness brightness = _isPlatformBrightnessDependent
+ ? CupertinoTheme.brightnessOf(context, nullOk: nullOk) ?? Brightness.light
+ : Brightness.light;
+
+ bool isHighContrastEnabled = _isHighContrastDependent
+ && (MediaQuery.of(context, nullOk: nullOk)?.highContrast ?? false);
+
+ CupertinoUserInterfaceLevelData? CupertinoUserInterfacelevel =
+ CupertinoUserInterfaceLevel.of(context, nullOk: nullOk);
+ CupertinoUserInterfaceLevelData level = _isInterfaceElevationDependent
+ ? CupertinoUserInterfacelevel ?? CupertinoUserInterfaceLevelData.baselayer
+ : CupertinoUserInterfaceLevelData.baselayer;
+
+ Color resolved = null;
+ switch (brightness) {
+ case Brightness.light:
+ switch (level) {
+ case CupertinoUserInterfaceLevelData.baselayer:
+ resolved = isHighContrastEnabled ? highContrastColor : color;
+ break;
+ case CupertinoUserInterfaceLevelData.elevatedlayer:
+ resolved = isHighContrastEnabled ? highContrastElevatedColor : elevatedColor;
+ break;
+ }
+
+ break;
+ case Brightness.dark:
+ switch (level) {
+ case CupertinoUserInterfaceLevelData.baselayer:
+ resolved = isHighContrastEnabled ? darkHighContrastColor : darkColor;
+ break;
+ case CupertinoUserInterfaceLevelData.elevatedlayer:
+ resolved = isHighContrastEnabled ? darkHighContrastElevatedColor : darkElevatedColor;
+ break;
+ }
+
+ break;
+ }
+
+ Element _debugContext = null;
+ D.assert(() => {
+ _debugContext = context as Element;
+ return true;
+ }
+ );
+ return create(
+ resolved,
+ color,
+ darkColor,
+ highContrastColor,
+ darkHighContrastColor,
+ elevatedColor,
+ darkElevatedColor,
+ highContrastElevatedColor,
+ darkHighContrastElevatedColor,
+ _debugContext,
+ _debugLabel
+
+ );
+ }
+
+ public bool Equals(CupertinoDynamicColor other) {
+ if (ReferenceEquals(null, other)) {
+ return false;
+ }
+
+ if (ReferenceEquals(this, other)) {
+ return true;
+ }
+
+ return Equals(value, other.value) && Equals(darkColor, other.darkColor) &&
+ Equals(highContrastColor, other.highContrastColor)
+ && Equals(darkHighContrastColor, other.darkHighContrastColor)
+ && Equals(elevatedColor, other.elevatedColor)
+ && Equals(darkElevatedColor, other.darkElevatedColor)
+ && Equals(highContrastElevatedColor, other.highContrastElevatedColor)
+ && Equals(darkHighContrastElevatedColor, other.darkHighContrastElevatedColor);
+ }
+
+ public override bool Equals(object obj) {
+
+ if (ReferenceEquals(null, obj)) {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj)) {
+ return true;
+ }
+
+ if (obj.GetType() != GetType()) {
+ return false;
+ }
+
+ return Equals((CupertinoDynamicColor) obj);
+ }
+
+ public override int GetHashCode() {
+ unchecked {
+ var hashCode = (value != null ? value.GetHashCode() : 0);
+ hashCode = (color != null ? color.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (darkColor != null ? darkColor.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (highContrastColor != null ? highContrastColor.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (elevatedColor != null ? elevatedColor.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (darkElevatedColor != null ? darkElevatedColor.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (darkHighContrastColor != null ? darkHighContrastColor.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (darkHighContrastElevatedColor != null
+ ? darkHighContrastElevatedColor.GetHashCode()
+ : 0);
+ hashCode = (hashCode * 397) ^
+ (highContrastElevatedColor != null ? highContrastElevatedColor.GetHashCode() : 0);
+ return hashCode;
+ }
+
+ }
+
+ public static bool operator ==(CupertinoDynamicColor left, CupertinoDynamicColor right) {
+ return Equals(left, right);
+ }
+
+ public static bool operator !=(CupertinoDynamicColor left, CupertinoDynamicColor right) {
+ return !Equals(left, right);
+ }
+
+ public override string ToString() {
+ return toString();
+ }
+
+ public string toString(DiagnosticLevel minLevel = DiagnosticLevel.debug) {
+ List xs = new List();
+ xs.Add(toStringColor("color",color));
+ if (_isPlatformBrightnessDependent)
+ xs.Add(toStringColor("darkColor", darkColor));
+ if (_isHighContrastDependent)
+ xs.Add( toStringColor("highContrastColor", highContrastColor));
+ if (_isPlatformBrightnessDependent && _isHighContrastDependent)
+ xs.Add(toStringColor("darkHighContrastColor", darkHighContrastColor));
+ if (_isInterfaceElevationDependent)
+ xs.Add( toStringColor("elevatedColor", elevatedColor));
+ if (_isPlatformBrightnessDependent && _isInterfaceElevationDependent)
+ xs.Add(toStringColor("darkElevatedColor", darkElevatedColor));
+ if (_isHighContrastDependent && _isInterfaceElevationDependent)
+ xs.Add(toStringColor("highContrastElevatedColor", highContrastElevatedColor));
+ if (_isPlatformBrightnessDependent && _isHighContrastDependent && _isInterfaceElevationDependent)
+ xs.Add(toStringColor("darkHighContrastElevatedColor", darkHighContrastElevatedColor));
+
+ string xsStr = "";
+ foreach (var xss in xs) {
+ xsStr += xss;
+ }
+ var debugContext = _debugResolveContext?.widget;
+ if (_debugResolveContext?.widget == null) {
+ return $"[{_debugLabel ?? GetType().ToString()}({xsStr}, resolved by: UNRESOLVED)]";
+ }
+ else {
+ return $"[{_debugLabel ?? GetType().ToString()}({xsStr}, resolved by: {_debugResolveContext?.widget })]";
+ }
+
+
+ }
+
+ public string toStringColor(string name, Color color) {
+ string marker = color == _effectiveColor ? "*" : "";
+ return marker + name + " = " + color.ToString() + marker;
+ }
+
+
+ public new void debugFillProperties(DiagnosticPropertiesBuilder properties) {
+ base.debugFillProperties(properties);
+ if (_debugLabel != null)
+ properties.add(new MessageProperty("debugLabel", _debugLabel));
+ properties.add(createCupertinoColorProperty("color", color));
+ if (_isPlatformBrightnessDependent)
+ properties.add(createCupertinoColorProperty("darkColor", darkColor));
+ if (_isHighContrastDependent)
+ properties.add(createCupertinoColorProperty("highContrastColor", highContrastColor));
+ if (_isPlatformBrightnessDependent && _isHighContrastDependent)
+ properties.add(createCupertinoColorProperty("darkHighContrastColor", darkHighContrastColor));
+ if (_isInterfaceElevationDependent)
+ properties.add(createCupertinoColorProperty("elevatedColor", elevatedColor));
+ if (_isPlatformBrightnessDependent && _isInterfaceElevationDependent)
+ properties.add(createCupertinoColorProperty("darkElevatedColor", darkElevatedColor));
+ if (_isHighContrastDependent && _isInterfaceElevationDependent)
+ properties.add(createCupertinoColorProperty("highContrastElevatedColor", highContrastElevatedColor));
+ if (_isPlatformBrightnessDependent && _isHighContrastDependent && _isInterfaceElevationDependent)
+ properties.add(createCupertinoColorProperty("darkHighContrastElevatedColor",
+ darkHighContrastElevatedColor));
+
+ if (_debugResolveContext != null)
+ properties.add(new DiagnosticsProperty("last resolved", _debugResolveContext));
+
+ }
+
+ public static DiagnosticsProperty createCupertinoColorProperty(
+ string name = null,
+ Color value = null,
+ bool showName = true,
+ object defaultValue = null,
+ DiagnosticsTreeStyle style = DiagnosticsTreeStyle.singleLine,
+ DiagnosticLevel level = DiagnosticLevel.info
+ ) {
+
+ if (value is CupertinoDynamicColor) {
+ return new DiagnosticsProperty(
+ name: name,
+ value: value,
+ // description: value._debugLabel,
+ showName: showName,
+ defaultValue: defaultValue,
+ style: style,
+ level: level
+ );
+ }
+ else {
+
+ return new ColorProperty(
+ name,
+ value,
+ showName: showName,
+ defaultValue: defaultValue,
+ style: style,
+ level: level
+ );
+ }
+ }
+ }
+}
diff --git a/com.unity.uiwidgets/Runtime/cupertino/color.cs.meta b/com.unity.uiwidgets/Runtime/cupertino/colors.cs.meta
similarity index 83%
rename from com.unity.uiwidgets/Runtime/cupertino/color.cs.meta
rename to com.unity.uiwidgets/Runtime/cupertino/colors.cs.meta
index f53080fe..3b149293 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/color.cs.meta
+++ b/com.unity.uiwidgets/Runtime/cupertino/colors.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: cf635163f4e847c4d8189105ba042987
+guid: 78e6aef01ceaee54bbcae56c25aa6147
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/com.unity.uiwidgets/Runtime/cupertino/context_menu.cs b/com.unity.uiwidgets/Runtime/cupertino/context_menu.cs
new file mode 100644
index 00000000..0f876910
--- /dev/null
+++ b/com.unity.uiwidgets/Runtime/cupertino/context_menu.cs
@@ -0,0 +1,1042 @@
+using System.Collections.Generic;
+using Unity.UIWidgets.foundation;
+using Unity.UIWidgets.animation;
+using Unity.UIWidgets.rendering;
+using Unity.UIWidgets.ui;
+using Unity.UIWidgets.widgets;
+using Unity.UIWidgets.scheduler2;
+using System;
+using Unity.UIWidgets.gestures;
+using Unity.UIWidgets.painting;
+using UnityEngine;
+using Color = Unity.UIWidgets.ui.Color;
+using Rect = Unity.UIWidgets.ui.Rect;
+using Transform = Unity.UIWidgets.widgets.Transform;
+
+namespace Unity.UIWidgets.cupertino {
+
+ class CupertinoContextMenuUtils {
+
+ public static float _kOpenScale = 1.1f;
+ public static float kMinFlingVelocity = 50.0f;
+
+ public static Rect _getRect(GlobalKey globalKey) {
+ D.assert(globalKey.currentContext != null);
+ RenderBox renderBoxContainer = globalKey.currentContext.findRenderObject() as RenderBox;
+ Offset containerOffset = renderBoxContainer.localToGlobal(
+ renderBoxContainer.paintBounds.topLeft
+ );
+ return containerOffset & renderBoxContainer.paintBounds.size;
+ }
+
+ public static Rect fromCenter(Offset center, float width, float height) {
+ return Rect.fromLTRB(
+ center.dx - width / 2,
+ center.dy - height / 2,
+ center.dx + width / 2,
+ center.dy + height / 2
+ );
+ }
+
+ }
+ public delegate Widget _DismissCallback(
+ BuildContext context,
+ float scale,
+ float opacity
+ );
+
+ public delegate Widget ContextMenuPreviewBuilder(
+ BuildContext context,
+ Animation animation,
+ Widget child
+ );
+
+ public delegate Widget _ContextMenuPreviewBuilderChildless (
+ BuildContext context,
+ Animation animation
+ );
+
+ public enum _ContextMenuLocation {
+ center,
+ left,
+ right,
+ }
+
+ public class CupertinoContextMenu : StatefulWidget {
+ public CupertinoContextMenu(
+ Key key = null,
+ List actions = null,
+ Widget child = null,
+ ContextMenuPreviewBuilder previewBuilder = null
+ ) : base(key: key) {
+ D.assert(actions != null && actions.isNotEmpty());
+ D.assert(child != null);
+ this.actions = actions;
+ this.child = child;
+ this.previewBuilder = previewBuilder;
+ }
+
+ public readonly Widget child;
+
+ public readonly List actions;
+
+ public readonly ContextMenuPreviewBuilder previewBuilder;
+
+ public override State createState() {
+ return new _CupertinoContextMenuState();
+ }
+
+ }
+
+ public class _CupertinoContextMenuState : State , TickerProviderStateMixin {
+
+ public readonly GlobalKey _childGlobalKey = new LabeledGlobalKey>();
+ //GlobalKey();//GlobalKey();
+ static readonly TimeSpan kLongPressTimeout = new TimeSpan(0, 0, 0, 0, 500);
+ public bool _childHidden = false;
+ \ public AnimationController _openController;
+ public Rect _decoyChildEndRect;
+ public OverlayEntry _lastOverlayEntry;
+ public _ContextMenuRoute _route;
+
+ public override void initState() {
+ base.initState();
+ _openController = new AnimationController(
+ duration: kLongPressTimeout,
+ vsync: this
+ );
+ _openController.addStatusListener(_onDecoyAnimationStatusChange);
+ }
+
+ public _ContextMenuLocation _contextMenuLocation {
+ get {
+ Rect childRect = CupertinoContextMenuUtils._getRect(_childGlobalKey);
+ float screenWidth = MediaQuery.of(context).size.width;
+ float center = screenWidth / 2;
+ bool centerDividesChild = childRect.left < center
+ && childRect.right > center;
+ float distanceFromCenter = (center - childRect.center.dx).abs();
+ if (centerDividesChild && distanceFromCenter <= childRect.width / 4) {
+ return _ContextMenuLocation.center;
+ }
+
+ if (childRect.center.dx > center) {
+ return _ContextMenuLocation.right;
+ }
+
+ return _ContextMenuLocation.left;
+ }
+ }
+ public void _openContextMenu() {
+ setState(()=>{
+ _childHidden = true;
+ });
+
+ _route = new _ContextMenuRoute(
+ actions: widget.actions,
+ barrierLabel: "Dismiss",
+ filter: ui.ImageFilter.blur(
+ sigmaX: 5.0f,
+ sigmaY: 5.0f
+ ),
+ contextMenuLocation: _contextMenuLocation,
+ previousChildRect: _decoyChildEndRect,
+ builder: (BuildContext context, Animation< float> animation)=>{
+ if (widget.previewBuilder == null) {
+ return widget.child;
+ }
+ return widget.previewBuilder(context, animation, widget.child);
+ }
+ );
+ Navigator.of(context, rootNavigator: true).push(_route);
+ _route.animation.addStatusListener(_routeAnimationStatusListener);
+ }
+
+ public void _onDecoyAnimationStatusChange(AnimationStatus animationStatus) {
+ switch (animationStatus) {
+ case AnimationStatus.dismissed:
+ if (_route == null) {
+ setState(()=> {
+ _childHidden = false;
+ });
+ }
+ _lastOverlayEntry?.remove();
+ _lastOverlayEntry = null;
+ break;
+ case AnimationStatus.completed:
+ setState(()=>{
+ _childHidden = true;
+ });
+ _openContextMenu();
+ SchedulerBinding.instance.addPostFrameCallback((TimeSpan timestamp) =>{
+ _lastOverlayEntry?.remove();
+ _lastOverlayEntry = null;
+ _openController.reset();
+ });
+ break;
+ default:
+ return;
+ }
+ }
+
+
+ public void _routeAnimationStatusListener(AnimationStatus status) {
+ if (status != AnimationStatus.dismissed) {
+ return;
+ }
+ setState(()=>{
+ _childHidden = false;
+ });
+ _route.animation.removeStatusListener(_routeAnimationStatusListener);
+ _route = null;
+ }
+
+ public void _onTap() {
+ if (_openController.isAnimating && _openController.value < 0.5f) {
+ _openController.reverse();
+ }
+ }
+
+ public void _onTapCancel() {
+ if (_openController.isAnimating && _openController.value < 0.5f) {
+ _openController.reverse();
+ }
+ }
+
+ public void _onTapUp(TapUpDetails details) {
+ if(_openController.isAnimating && _openController.value < 0.5f) {
+ _openController.reverse();
+ }
+ }
+
+ public void _onTapDown(TapDownDetails details) {
+ setState(()=>{
+ _childHidden = true;
+ });
+ Rect childRect = CupertinoContextMenuUtils._getRect(_childGlobalKey);
+ _decoyChildEndRect = CupertinoContextMenuUtils.fromCenter(
+ center: childRect.center,
+ width: childRect.width * CupertinoContextMenuUtils._kOpenScale,
+ height: childRect.height * CupertinoContextMenuUtils._kOpenScale
+ );
+ _lastOverlayEntry = new OverlayEntry(
+ opaque: false,
+ builder: (BuildContext context) => {
+ return new _DecoyChild(
+ beginRect: childRect,
+ child: widget.child,
+ controller: _openController,
+ endRect: _decoyChildEndRect
+ );
+ }
+ );
+ Overlay.of(context).insert(_lastOverlayEntry);
+ _openController.forward();
+ }
+
+ public override Widget build(BuildContext context) {
+ return new GestureDetector(
+ onTapCancel: _onTapCancel,
+ onTapDown: _onTapDown,
+ onTapUp: _onTapUp,
+ onTap: _onTap,
+ child: new TickerMode(
+ enabled: !_childHidden,
+ child: new Opacity(
+ key: _childGlobalKey,
+ opacity: _childHidden ? 0.0f : 1.0f,
+ child: widget.child
+ )
+ )
+ );
+ }
+ public override void dispose() {
+ _openController.dispose();
+ base.dispose();
+ }
+ }
+ public class _DecoyChild : StatefulWidget {
+ public _DecoyChild(
+ Key key = null,
+ Rect beginRect = null,
+ AnimationController controller = null,
+ Rect endRect = null,
+ Widget child = null
+ ) : base(key: key) {
+ this.beginRect = beginRect;
+ this.controller = controller;
+ this.endRect = endRect;
+ this.child = child;
+ }
+
+ public readonly Rect beginRect;
+ public readonly AnimationController controller;
+ public readonly Rect endRect;
+ public readonly Widget child;
+
+ public override State createState() {
+ return new _DecoyChildState();
+ }
+ }
+ public class _DecoyChildState : State<_DecoyChild> , TickerProviderStateMixin {
+
+ public static readonly Color _lightModeMaskColor = new Color(0xFF888888);
+ public static readonly Color _masklessColor = new Color(0xFFFFFFFF);
+ public readonly GlobalKey _childGlobalKey = new LabeledGlobalKey>();
+ public Animation _mask;
+ public Animation _rect;
+
+ public override void initState() {
+ base.initState();
+ _mask = new _OnOffAnimation(
+ controller: widget.controller,
+ onValue: _lightModeMaskColor,
+ offValue: _masklessColor,
+ intervalOn: 0.0f,
+ intervalOff: 0.5f
+ );
+ Rect midRect = widget.beginRect.deflate(
+ widget.beginRect.width * (CupertinoContextMenuUtils._kOpenScale - 1.0f) / 2f
+ );
+ List> tweenSequenceItems = new List>();
+ tweenSequenceItems.Add(
+ new TweenSequenceItem(
+ tween: new RectTween(
+ begin: widget.beginRect,
+ end: midRect
+ ).chain(new CurveTween(curve: Curves.easeInOutCubic)),
+ weight: 1.0f
+ ));
+
+ tweenSequenceItems.Add(
+ new TweenSequenceItem(
+ tween: new RectTween(
+ begin: midRect,
+ end: widget.endRect
+ ).chain(new CurveTween(curve: Curves.easeOutCubic)),
+ weight: 1.0f
+ ));
+
+ _rect = new TweenSequence(tweenSequenceItems).animate(widget.controller);
+ _rect.addListener(_rectListener);
+
+ }
+ public void _rectListener() {
+ if (widget.controller.value < 0.5f) {
+ return;
+ }
+ //HapticFeedback.selectionClick();????
+ /// tbc ???
+ _rect.removeListener(_rectListener);
+ }
+ public override void dispose() {
+ _rect.removeListener(_rectListener);
+ base.dispose();
+ }
+
+ public Widget _buildAnimation(BuildContext context, Widget child) {
+ Color color = widget.controller.status == AnimationStatus.reverse ? _masklessColor : _mask.value;
+ List colors = new List();
+ colors.Add(color);
+ colors.Add(color);
+ return Positioned.fromRect(
+ rect: _rect.value,
+ child: kIsweb
+ ? new Container(key: _childGlobalKey, child: widget.child)
+ : new ShaderMask(
+ key: _childGlobalKey,
+ shaderCallback: (Rect bounds) => {
+ return new LinearGradient(
+ begin: Alignment.topLeft,
+ end: Alignment.bottomRight,
+ colors: colors
+ ).createShader(bounds);
+ },
+ child: widget.child
+ )
+ );
+ }
+ public override Widget build(BuildContext context) {
+ List widgets = new List();
+ widgets.Add(new AnimatedBuilder(
+ builder: _buildAnimation,
+ animation: widget.controller
+ ));
+ return new Stack(
+ children: widgets
+ );
+ }
+ }
+ public class _ContextMenuRoute : PopupRoute {
+ public _ContextMenuRoute(
+ List actions = null,
+ _ContextMenuLocation contextMenuLocation = default,
+ string barrierLabel = null,
+ _ContextMenuPreviewBuilderChildless builder = null,
+ ui.ImageFilter filter = null,
+ Rect previousChildRect = null,
+ RouteSettings settings = null
+ ) : base(
+ filter: filter,
+ settings: settings
+ ){
+ D.assert(actions != null && actions.isNotEmpty());
+ D.assert(contextMenuLocation != null);
+ this.barrierLabel = barrierLabel;
+ _actions = actions;
+ _builder = builder;
+ _contextMenuLocation = contextMenuLocation;
+ _previousChildRect = previousChildRect;
+ }
+ public readonly static Color _kModalBarrierColor = new Color(0x6604040F);
+ public readonly TimeSpan _kModalPopupTransitionDuration =new TimeSpan(0, 0, 0, 0, 335);
+ public readonly List _actions;
+ public readonly _ContextMenuPreviewBuilderChildless _builder;
+ public readonly GlobalKey _childGlobalKey = new LabeledGlobalKey>();
+ public readonly _ContextMenuLocation _contextMenuLocation;
+ public bool _externalOffstage = false;
+ public bool _internalOffstage = false;
+ public Orientation _lastOrientation;
+ public readonly Rect _previousChildRect;
+ public float _scale = 1.0f;
+ public readonly GlobalKey _sheetGlobalKey = new LabeledGlobalKey>();//GlobalKey();
+ public readonly static CurveTween _curve = new CurveTween(
+ curve: Curves.easeOutBack
+ );
+ public readonly static CurveTween _curveReverse = new CurveTween(
+ curve: Curves.easeInBack
+ );
+ public readonly static RectTween _rectTween = new RectTween();
+ public readonly static Animatable _rectAnimatable = _rectTween.chain(_curve);
+ public readonly static RectTween _rectTweenReverse = new RectTween();
+ public readonly static Animatable _rectAnimatableReverse = _rectTweenReverse.chain(_curveReverse);
+
+ public readonly static RectTween _sheetRectTween = new RectTween();
+ public readonly Animatable _sheetRectAnimatable = _sheetRectTween.chain(_curve);
+ public readonly Animatable _sheetRectAnimatableReverse = _sheetRectTween.chain(_curveReverse);
+ public readonly static Tween< float> _sheetScaleTween = new Tween(0.0f,0.0f);
+ public readonly static Animatable< float> _sheetScaleAnimatable = _sheetScaleTween.chain(_curve);
+ public readonly static Animatable< float> _sheetScaleAnimatableReverse = _sheetScaleTween.chain(_curveReverse);
+ public readonly Tween< float> _opacityTween = new Tween< float>(begin: 0.0f, end: 1.0f);
+ public Animation< float> _sheetOpacity;
+ public readonly string barrierLabel;
+
+ public Color barrierColor {
+ get { return _kModalBarrierColor; }
+ }
+
+ public bool barrierDismissible{
+ get { return false; }
+ }
+
+ public bool semanticsDismissible {
+ get { return true; }
+ }
+
+ public TimeSpan transitionDuration {
+ get {
+ return _kModalPopupTransitionDuration;
+ }
+ }
+ public static Rect _getScaledRect(GlobalKey globalKey, float scale) {
+ Rect childRect = CupertinoContextMenuUtils._getRect(globalKey);
+ Size sizeScaled = childRect.size * scale;
+ Offset offsetScaled = new Offset(
+ childRect.left + (childRect.size.width - sizeScaled.width) / 2,
+ childRect.top + (childRect.size.height - sizeScaled.height) / 2
+ );
+ return offsetScaled & sizeScaled;
+ }
+ public static AlignmentDirectional getSheetAlignment(_ContextMenuLocation contextMenuLocation) {
+ switch (contextMenuLocation) {
+ case _ContextMenuLocation.center:
+ return AlignmentDirectional.topCenter;
+ case _ContextMenuLocation.right:
+ return AlignmentDirectional.topEnd;
+ default:
+ return AlignmentDirectional.topStart;
+ }
+ }
+ public static Rect _getSheetRectBegin(Orientation orientation, _ContextMenuLocation contextMenuLocation, Rect childRect, Rect sheetRect) {
+ switch (contextMenuLocation) {
+ case _ContextMenuLocation.center:
+ Offset target1 = (orientation == Orientation.portrait)
+ ? childRect.bottomCenter
+ : childRect.topCenter;
+ Offset centered = target1 - new Offset(sheetRect.width / 2, 0.0f);
+ return centered & sheetRect.size;
+ case _ContextMenuLocation.right:
+ Offset target2 = ((orientation == Orientation.portrait)
+ ? childRect.bottomRight
+ : childRect.topRight);
+ return (target2 - new Offset(sheetRect.width, 0.0f)) & sheetRect.size;
+ default:
+ Offset target3 = orientation == Orientation.portrait
+ ? childRect.bottomLeft
+ : childRect.topLeft;
+ return target3 & sheetRect.size;
+ }
+ }
+ public void _onDismiss(BuildContext context, float scale, float opacity) {
+ _scale = scale;
+ _opacityTween.end = opacity;
+ _sheetOpacity = _opacityTween.animate(
+ new CurvedAnimation(
+ parent: animation,
+ curve: new Interval(0.9f, 1.0f)
+ ));
+ Navigator.of(context).pop();
+ }
+
+ public void _updateTweenRects() {
+ Rect childRect = _scale == null
+ ? CupertinoContextMenuUtils._getRect(_childGlobalKey)
+ : _getScaledRect(_childGlobalKey, _scale);
+ _rectTween.begin = _previousChildRect;
+ _rectTween.end = childRect;
+ Rect childRectOriginal = CupertinoContextMenuUtils.fromCenter(
+ center: _previousChildRect.center,
+ width: _previousChildRect.width / CupertinoContextMenuUtils._kOpenScale,
+ height: _previousChildRect.height / CupertinoContextMenuUtils._kOpenScale
+ );
+ Rect sheetRect = CupertinoContextMenuUtils._getRect(_sheetGlobalKey);
+ Rect sheetRectBegin = _getSheetRectBegin(
+ _lastOrientation,
+ _contextMenuLocation,
+ childRectOriginal,
+ sheetRect
+ );
+ _sheetRectTween.begin = sheetRectBegin;
+ _sheetRectTween.end = sheetRect;
+ _sheetScaleTween.begin = 0.0f;
+ _sheetScaleTween.end = _scale;
+ _rectTweenReverse.begin = childRectOriginal;
+ _rectTweenReverse.end = childRect;
+ }
+ public void _setOffstageInternally() {
+ base.offstage = _externalOffstage || _internalOffstage;
+ changedInternalState();
+ }
+ public bool didPop(T result) {
+ _updateTweenRects();
+ return base.didPop(result);
+ }
+
+ /*public set offstage(bool value) {
+ _externalOffstage = value;
+ _setOffstageInternally();
+ }*/
+ // tbc ???
+
+ public TickerFuture didPush() {
+ _internalOffstage = true;
+ _setOffstageInternally();
+ SchedulerBinding.instance.addPostFrameCallback((TimeSpan timeSpan)=>{
+ _updateTweenRects();
+ _internalOffstage = false;
+ _setOffstageInternally();
+ });
+ return base.didPush();
+ }
+
+ public Animation createAnimation() {
+ Animation< float> animation = base.createAnimation();
+ _sheetOpacity = _opacityTween.animate(new CurvedAnimation(
+ parent: animation,
+ curve: Curves.linear
+ ));
+ return animation;
+ }
+ public override Widget buildPage(BuildContext context, Animation< float> animation, Animation< float> secondaryAnimation) {
+ return null;
+ }
+ public override Widget buildTransitions(BuildContext context1, Animation< float> animation, Animation< float> secondaryAnimation, Widget child) {
+ return new OrientationBuilder(
+ builder: (BuildContext context2, Orientation orientation)=>{
+ _lastOrientation = orientation;
+ if (!animation.isCompleted) {
+ bool reverse = animation.status == AnimationStatus.reverse;
+ Rect rect = reverse
+ ? _rectAnimatableReverse.evaluate(animation)
+ : _rectAnimatable.evaluate(animation);
+ Rect sheetRect = reverse
+ ? _sheetRectAnimatableReverse.evaluate(animation)
+ : _sheetRectAnimatable.evaluate(animation);
+ float sheetScale = reverse
+ ? _sheetScaleAnimatableReverse.evaluate(animation)
+ : _sheetScaleAnimatable.evaluate(animation);
+ List widgets = new List();
+ widgets.Add(
+ Positioned.fromRect(
+ rect: sheetRect,
+ child: new Opacity(
+ opacity: _sheetOpacity.value,
+ child: Transform.scale(
+ alignment: getSheetAlignment(_contextMenuLocation),
+ scale: sheetScale,
+ child: new _ContextMenuSheet(
+ key: _sheetGlobalKey,
+ actions: _actions,
+ contextMenuLocation: _contextMenuLocation,
+ orientation: orientation
+ )
+ )
+ )
+ )
+ );
+ widgets.Add(
+ Positioned.fromRect(
+ key: _childGlobalKey,
+ rect: rect,
+ child: _builder(context2, animation)
+ )
+ );
+ return new Stack(
+ children: widgets
+ );
+ }
+ return new _ContextMenuRouteStatic(
+ actions: _actions,
+ child: _builder(context1, animation),
+ childGlobalKey: _childGlobalKey,
+ contextMenuLocation: _contextMenuLocation,
+ onDismiss: _onDismiss,
+ orientation: orientation,
+ sheetGlobalKey: _sheetGlobalKey
+ );
+ }
+ );
+ }
+ }
+ public class _ContextMenuRouteStatic : StatefulWidget {
+ public _ContextMenuRouteStatic(
+ Key key = null,
+ List actions = null,
+ Widget child = null,
+ GlobalKey childGlobalKey = null,
+ _ContextMenuLocation contextMenuLocation = default,
+ _DismissCallback onDismiss =default,
+ Orientation orientation = default,
+ GlobalKey sheetGlobalKey = null
+ ) : base(key: key) {
+ D.assert(contextMenuLocation != null);
+ D.assert(orientation != null);
+ this.actions = actions;
+ this.child = child;
+ this.childGlobalKey = childGlobalKey;
+ this.contextMenuLocation = contextMenuLocation;
+ this.onDismiss = onDismiss;
+ this.orientation = orientation;
+ this.sheetGlobalKey = sheetGlobalKey;
+ }
+ public readonly List actions;
+ public readonly Widget child;
+ public readonly GlobalKey childGlobalKey;
+ public readonly _ContextMenuLocation contextMenuLocation;
+ public readonly _DismissCallback onDismiss;
+ public readonly Orientation orientation;
+ public readonly GlobalKey sheetGlobalKey;
+
+ public override State createState() {
+ return new _ContextMenuRouteStaticState();
+ }
+ }
+
+ public class _ContextMenuRouteStaticState : State<_ContextMenuRouteStatic> ,TickerProviderStateMixin {
+ public readonly static float _kMinScale = 0.8f;
+ public readonly static float _kSheetScaleThreshold = 0.9f;
+ public readonly static float _kPadding = 20.0f;
+ public readonly static float _kDamping = 400.0f;
+ public readonly static TimeSpan _kMoveControllerDuration = new TimeSpan(0,0,0,600);
+ public Offset _dragOffset;
+ public float _lastScale = 1.0f;
+ public AnimationController _moveController;
+ public AnimationController _sheetController;
+ public Animation _moveAnimation;
+ public Animation< float> _sheetScaleAnimation;
+ public Animation< float> _sheetOpacityAnimation;
+ public static float _getScale(Orientation orientation, float maxDragDistance, float dy) {
+ float dyDirectional = dy <= 0.0 ? dy : -dy;
+ return Mathf.Max(
+ _kMinScale,
+ (maxDragDistance + dyDirectional) / maxDragDistance
+ );
+ }
+ void _onPanStart(DragStartDetails details) {
+ _moveController.setValue(1.0f) ;
+ _setDragOffset(Offset.zero);
+ }
+ void _onPanUpdate(DragUpdateDetails details) {
+ _setDragOffset(_dragOffset + details.delta);
+ }
+ void _onPanEnd(DragEndDetails details) {
+ if (details.velocity.pixelsPerSecond.dy.abs() >= CupertinoContextMenuUtils.kMinFlingVelocity) {
+ bool flingIsAway = details.velocity.pixelsPerSecond.dy > 0;
+ float finalPosition = flingIsAway
+ ? _moveAnimation.value.dy + 100.0f
+ : 0.0f;
+ if (flingIsAway && _sheetController.status != AnimationStatus.forward) {
+ _sheetController.forward();
+ } else if (!flingIsAway && _sheetController.status != AnimationStatus.reverse) {
+ _sheetController.reverse();
+ }
+
+ _moveAnimation = new Tween(
+ begin: new Offset(0.0f, _moveAnimation.value.dy),
+ end:new Offset(0.0f, finalPosition)
+ ).animate(_moveController);
+ _moveController.reset();
+ _moveController.duration = new TimeSpan(0,0,0,64);
+ _moveController.forward();
+ _moveController.addStatusListener(_flingStatusListener);
+ return;
+ }
+ if (_lastScale == _kMinScale) {
+ widget.onDismiss(context, _lastScale, _sheetOpacityAnimation.value);
+ return;
+ }
+
+ // Otherwise animate back home.
+ _moveController.addListener(_moveListener);
+ _moveController.reverse();
+ }
+
+ void _moveListener() {
+ if (_lastScale > _kSheetScaleThreshold) {
+ _moveController.removeListener(_moveListener);
+ if (_sheetController.status != AnimationStatus.dismissed) {
+ _sheetController.reverse();
+ }
+ }
+ }
+
+ void _flingStatusListener(AnimationStatus status) {
+ if (status != AnimationStatus.completed) {
+ return;
+ }
+ _moveController.duration = _kMoveControllerDuration;
+ _moveController.removeStatusListener(_flingStatusListener);
+ if (_moveAnimation.value.dy == 0.0) {
+ return;
+ }
+ widget.onDismiss(context, _lastScale, _sheetOpacityAnimation.value);
+ }
+
+ Alignment _getChildAlignment(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
+ switch (contextMenuLocation) {
+ case _ContextMenuLocation.center:
+ return orientation == Orientation.portrait
+ ? Alignment.bottomCenter
+ : Alignment.topRight;
+ case _ContextMenuLocation.right:
+ return orientation == Orientation.portrait
+ ? Alignment.bottomCenter
+ : Alignment.topLeft;
+ default:
+ return orientation == Orientation.portrait
+ ? Alignment.bottomCenter
+ : Alignment.topRight;
+ }
+ }
+
+ void _setDragOffset(Offset dragOffset) {
+ // Allow horizontal and negative vertical movement, but damp it.
+ float endX = _kPadding * dragOffset.dx / _kDamping;
+ float endY = dragOffset.dy >= 0.0
+ ? dragOffset.dy
+ : _kPadding * dragOffset.dy / _kDamping;
+ setState(() =>{
+ _dragOffset = dragOffset;
+ _moveAnimation = new Tween(
+ begin: Offset.zero,
+ end: new Offset(
+ endX.clamp(-_kPadding, _kPadding) ,
+ endY
+ )
+ ).animate(
+ new CurvedAnimation(
+ parent: _moveController,
+ curve: Curves.elasticIn
+ )
+ );
+ if (_lastScale <= _kSheetScaleThreshold
+ && _sheetController.status != AnimationStatus.forward
+ && _sheetScaleAnimation.value != 0.0f) {
+ _sheetController.forward();
+ } else if (_lastScale > _kSheetScaleThreshold
+ && _sheetController.status != AnimationStatus.reverse
+ && _sheetScaleAnimation.value != 1.0f) {
+ _sheetController.reverse();
+ }
+ });
+ }
+
+ List _getChildren(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
+ Expanded child = new Expanded(
+ child: new Align(
+ alignment: _getChildAlignment(
+ widget.orientation,
+ widget.contextMenuLocation
+ ),
+ child: new AnimatedBuilder(
+ animation: _moveController,
+ builder: _buildChildAnimation,
+ child: widget.child
+ )
+ )
+ );
+ Container spacer = new Container(
+ width: _kPadding,
+ height: _kPadding
+ );
+ Expanded sheet = new Expanded(
+ child: new AnimatedBuilder(
+ animation: _sheetController,
+ builder: _buildSheetAnimation,
+ child: new _ContextMenuSheet(
+ key: widget.sheetGlobalKey,
+ actions: widget.actions,
+ contextMenuLocation: widget.contextMenuLocation,
+ orientation: widget.orientation
+ )
+ )
+ );
+ List centerWidgets = new List();
+ centerWidgets.Add(child);
+ centerWidgets.Add(spacer);
+ centerWidgets.Add(sheet);
+ List rightWidgets = new List();
+ rightWidgets.Add(sheet);
+ rightWidgets.Add(spacer);
+ rightWidgets.Add(child);
+ switch (contextMenuLocation) {
+ case _ContextMenuLocation.center:
+ return new List{child, spacer, sheet};
+ case _ContextMenuLocation.right:
+ return orientation == Orientation.portrait
+ ? new List{child, spacer, sheet}
+ : new List{sheet, spacer, child};
+ default:
+ return new List{child, spacer, sheet};
+ }
+ }
+
+ // Build the animation for the _ContextMenuSheet.
+ Widget _buildSheetAnimation(BuildContext context, Widget child) {
+ return Transform.scale(
+ //alignment: _ContextMenuRoute.getSheetAlignment(widget.contextMenuLocation),
+ scale: _sheetScaleAnimation.value,
+ child: new Opacity(
+ opacity: _sheetOpacityAnimation.value,
+ child: child
+ )
+ );
+ }
+
+ // Build the animation for the child.
+ Widget _buildChildAnimation(BuildContext context, Widget child) {
+ _lastScale = _getScale(
+ widget.orientation,
+ MediaQuery.of(context).size.height,
+ _moveAnimation.value.dy
+ );
+ return Transform.scale(
+ key: widget.childGlobalKey,
+ scale: _lastScale,
+ child: child
+ );
+ }
+
+ // Build the animation for the overall draggable dismissable content.
+ Widget _buildAnimation(BuildContext context, Widget child) {
+ return Transform.translate(
+ offset: _moveAnimation.value,
+ child: child
+ );
+ }
+
+
+ public override void initState() {
+ base.initState();
+ _moveController = new AnimationController(
+ duration: _kMoveControllerDuration,
+ value: 1.0f,
+ vsync: this
+ );
+ _sheetController = new AnimationController(
+ duration: new TimeSpan(0,0,0,100),
+ reverseDuration: new TimeSpan(0,0,0,300),/// TBC ???
+ vsync: this
+ );
+ _sheetScaleAnimation = new Tween< float>(
+ begin: 1.0f,
+ end: 0.0f
+ ).animate(
+ new CurvedAnimation(
+ parent: _sheetController,
+ curve: Curves.linear,
+ reverseCurve: Curves.easeInBack
+ )
+ );
+ _sheetOpacityAnimation = new Tween< float>(
+ begin: 1.0f,
+ end: 0.0f
+ ).animate(_sheetController);
+ _setDragOffset(Offset.zero);
+ }
+
+ public override void dispose() {
+ _moveController.dispose();
+ _sheetController.dispose();
+ base.dispose();
+ }
+
+
+ public override Widget build(BuildContext context) {
+ List children = _getChildren(
+ widget.orientation,
+ widget.contextMenuLocation
+ );
+
+ return new SafeArea(
+ child: new Padding(
+ padding: EdgeInsets.all(_kPadding),
+ child: new Align(
+ alignment: Alignment.topLeft,
+ child: new GestureDetector(
+ onPanEnd: _onPanEnd,
+ onPanStart: _onPanStart,
+ onPanUpdate: _onPanUpdate,
+ child: new AnimatedBuilder(
+ animation: _moveController,
+ builder: _buildAnimation,
+ child: widget.orientation == Orientation.portrait ?
+ (Widget) new Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: children
+ )
+ : new Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: children
+ )
+ )
+ )
+ )
+ )
+ );
+ }
+ }
+ public class _ContextMenuSheet : StatelessWidget {
+ public _ContextMenuSheet(
+ Key key = null,
+ List actions = null,
+ _ContextMenuLocation contextMenuLocation = default,
+ Orientation orientation = default
+ ) : base(key: key) {
+ D.assert(actions != null && actions.isNotEmpty());
+ D.assert(contextMenuLocation != null);
+ D.assert(orientation != null);
+ _contextMenuLocation = contextMenuLocation;
+ _orientation = orientation;
+ this.actions = actions;
+ }
+ public readonly List actions;
+ public readonly _ContextMenuLocation _contextMenuLocation;
+ public readonly Orientation _orientation;
+ public List children {
+ get{
+ Flexible menu = new Flexible(
+ fit: FlexFit.tight,
+ flex: 2,
+ child: new IntrinsicHeight(
+ child: new ClipRRect(
+ borderRadius: BorderRadius.circular(13.0f),
+ child: new Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: actions
+ )
+ )
+ )
+ );
+ List spacers1 = new List();
+ List spacers2 = new List();
+ spacers1.Add(new Spacer(
+ flex: 1
+ ));
+ spacers1.Add(menu);
+ spacers1.Add(new Spacer(
+ flex: 1
+ ));
+ spacers2.Add(menu);
+ spacers2.Add(new Spacer(
+ flex: 1
+ ));
+ List spacers3 = new List();
+ List spacers4 = new List();
+ spacers3.Add(new Spacer(
+ flex: 1
+ ));
+ spacers3.Add(menu);
+ spacers4.Add(menu);
+ spacers4.Add(new Spacer(
+ flex: 1
+ ));
+ switch (_contextMenuLocation) {
+ case _ContextMenuLocation.center:
+ return _orientation == Orientation.portrait
+ ? spacers1
+ : spacers2;
+ case _ContextMenuLocation.right:
+ return spacers3;
+ default:
+ return spacers4;
+ }
+
+ }
+ }
+ public override Widget build(BuildContext context) {
+ return new Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: children
+ );
+ }
+ }
+
+ public class _OnOffAnimation : CompoundAnimation {
+ public _OnOffAnimation(
+ AnimationController controller = null,
+ T onValue = default,
+ T offValue = default,
+ float? intervalOn = null,
+ float? intervalOff = null
+ ) /*: super(
+ first: new Tween(begin: offValue, end: onValue).animate(
+ new CurvedAnimation(
+ parent: controller,
+ curve: new Interval(intervalOn, intervalOn)
+ )
+ ),
+ next: new Tween(begin: onValue, end: offValue).animate(
+ new CurvedAnimation(
+ parent: controller,
+ curve: new Interval(intervalOff, intervalOff)
+ )
+ )
+ )*////?????
+ {
+ D.assert(intervalOn != null && intervalOn >= 0.0 && intervalOn <= 1.0);
+ D.assert(intervalOff !=null && intervalOff >= 0.0 && intervalOff <= 1.0);
+ D.assert(intervalOn <= intervalOff);
+ }
+ public readonly T _offValue;
+ public override T value {
+ get {
+ return next.value; // == _offValue ? next.value : first.value; ????/
+ }
+ }
+
+ }
+
+
+}
+
diff --git a/com.unity.uiwidgets/Runtime/cupertino/context_menu.cs.meta b/com.unity.uiwidgets/Runtime/cupertino/context_menu.cs.meta
new file mode 100644
index 00000000..19b24c7c
--- /dev/null
+++ b/com.unity.uiwidgets/Runtime/cupertino/context_menu.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 24797e4675ab3314ea1a636afd32bfee
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.uiwidgets/Runtime/cupertino/context_menu_action.cs b/com.unity.uiwidgets/Runtime/cupertino/context_menu_action.cs
new file mode 100644
index 00000000..6d555657
--- /dev/null
+++ b/com.unity.uiwidgets/Runtime/cupertino/context_menu_action.cs
@@ -0,0 +1,151 @@
+using System;
+using System.Collections.Generic;
+using Unity.UIWidgets.animation;
+using Unity.UIWidgets.foundation;
+using Unity.UIWidgets.gestures;
+using Unity.UIWidgets.painting;
+using Unity.UIWidgets.rendering;
+using Unity.UIWidgets.scheduler2;
+using Unity.UIWidgets.ui;
+using Unity.UIWidgets.widgets;
+using TextStyle = Unity.UIWidgets.painting.TextStyle;
+
+namespace Unity.UIWidgets.cupertino {
+
+ public class CupertinoContextMenuAction : StatefulWidget {
+
+ public CupertinoContextMenuAction(
+ Key key = null,
+ Widget child = null,
+ bool isDefaultAction = false,
+ bool isDestructiveAction = false,
+ VoidCallback onPressed = null,
+ IconData trailingIcon = null
+ ) : base(key: key) {
+ D.assert(child != null);
+ D.assert(isDefaultAction != null);
+ D.assert(isDestructiveAction != null);
+ this.child = child;
+ this.isDefaultAction = isDefaultAction;
+ this.isDestructiveAction = isDestructiveAction;
+ this.onPressed = onPressed;
+ this.trailingIcon = trailingIcon;
+
+ }
+ public readonly Widget child;
+ public readonly bool isDefaultAction;
+ public readonly bool isDestructiveAction;
+ public readonly VoidCallback onPressed;
+ public readonly IconData trailingIcon;
+
+ public override State createState() {
+ return new _CupertinoContextMenuActionState();
+ }
+ }
+ public class _CupertinoContextMenuActionState : State {
+ public static Color _kBackgroundColor = new Color(0xFFEEEEEE);
+ public static Color _kBackgroundColorPressed = new Color(0xFFDDDDDD);
+ public static float _kButtonHeight = 56.0f;
+
+ public static readonly TextStyle _kActionSheetActionStyle = new TextStyle(
+ fontFamily: ".SF UI Text",
+ inherit: false,
+ fontSize: 20.0f,
+ fontWeight: FontWeight.w400,
+ color: CupertinoColors.black,
+ textBaseline: TextBaseline.alphabetic
+ );
+ public GlobalKey _globalKey = new LabeledGlobalKey>();
+ //GlobalKey();
+ bool _isPressed = false;
+
+ void onTapDown(TapDownDetails details) {
+ setState(()=>{
+ _isPressed = true;
+ });
+ }
+
+ void onTapUp(TapUpDetails details) {
+ setState(()=>{
+ _isPressed = false;
+ });
+ }
+
+ void onTapCancel() {
+ setState(()=>{
+ _isPressed = false;
+ });
+ }
+
+ TextStyle _textStyle {
+ get {
+ if (widget.isDefaultAction) {
+ return _kActionSheetActionStyle.copyWith(
+ fontWeight: FontWeight.w600
+ );
+ }
+ if (widget.isDestructiveAction) {
+ return _kActionSheetActionStyle.copyWith(
+ color: CupertinoColors.destructiveRed
+ );
+ }
+ return _kActionSheetActionStyle;
+ }
+
+ }
+
+ public override Widget build(BuildContext context) {
+ List widgets = new List();
+ widgets.Add(new Flexible(child: widget.child));
+ if (widget.trailingIcon != null) {
+ widgets.Add(new Icon(
+ widget.trailingIcon,
+ color: _textStyle.color));
+ }
+
+ return new GestureDetector(
+ key: _globalKey,
+ onTapDown: onTapDown,
+ onTapUp: onTapUp,
+ onTapCancel: onTapCancel,
+ onTap: //widget.onPressed,
+ widget.onPressed == null
+ ? (GestureTapCallback) null
+ : () => {
+ if (widget.onPressed != null) {
+ widget.onPressed();
+ }
+ },
+ behavior: HitTestBehavior.opaque,
+ child: /////semantics tbc ???
+ new ConstrainedBox(
+ constraints: new BoxConstraints(
+ minHeight: _kButtonHeight
+ ),
+ child:
+ new Container(
+ padding: EdgeInsets.symmetric(
+ vertical: 16.0f,
+ horizontal: 10.0f
+ ),
+ decoration: new BoxDecoration(
+ color: _isPressed ? _kBackgroundColorPressed : _kBackgroundColor,
+ border: new Border(
+ bottom: new BorderSide(width: 1.0f, color: _kBackgroundColorPressed)
+ )
+ ),
+ child: new DefaultTextStyle(
+ style: _textStyle,
+ child: new Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children:widgets
+ )
+ )
+
+ )
+ )
+ );
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/com.unity.uiwidgets/Runtime/cupertino/context_menu_action.cs.meta b/com.unity.uiwidgets/Runtime/cupertino/context_menu_action.cs.meta
new file mode 100644
index 00000000..afa7a85a
--- /dev/null
+++ b/com.unity.uiwidgets/Runtime/cupertino/context_menu_action.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d5246034a96caf946b0142d694f1acac
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.uiwidgets/Runtime/cupertino/date_picker.cs b/com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
index 59a47598..700ef730 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
+++ b/com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
@@ -1102,4 +1102,1603 @@ namespace Unity.UIWidgets.cupertino {
);
}
}
-}
\ No newline at end of file
+}
+/*
+using System;
+using System.Collections.Generic;
+using Unity.UIWidgets.animation;
+using Unity.UIWidgets.foundation;
+using Unity.UIWidgets.painting;
+using Unity.UIWidgets.rendering;
+using Unity.UIWidgets.scheduler2;
+using Unity.UIWidgets.ui;
+using Unity.UIWidgets.widgets;
+using TextStyle = Unity.UIWidgets.painting.TextStyle;
+
+namespace Unity.UIWidgets.cupertino {
+ static class CupertinoDatePickerUtils {
+ public const float _kItemExtent = 32.0f;
+ public const float _kPickerWidth = 320.0f;
+ public const float _kPickerHeight = 216.0f;
+ public const bool _kUseMagnifier = true;
+ public const float _kMagnification = 1.05f;
+ public const float _kDatePickerPadSize = 12.0f;
+ public const float _kSqueeze = 1.25f;
+ public static Color _kBackgroundColor = CupertinoColors.white;
+
+ public static TextStyle _kDefaultPickerTextStyle = new TextStyle(
+ 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;
+ public const float _kTimerPickerNumberLabelFontSize = 23f;
+
+ public static TextStyle _themeTextStyle(BuildContext context, bool isValid = true ) {
+ TextStyle style = CupertinoTheme.of(context).textTheme.dateTimePickerTextStyle;
+ return isValid ? style : style.copyWith(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context));
+ }
+
+ public static void _animateColumnControllerToItem(FixedExtentScrollController controller, int targetItem) {
+ controller.animateToItem(
+ targetItem,
+ curve: Curves.easeInOut,
+ duration: new TimeSpan(0,0,0,0,200)
+ );
+ }
+ public delegate Widget listGenerateDelegate(int index);
+
+ public static List listGenerate(int count, listGenerateDelegate func) {
+ var list = new List();
+ for (int i = 0; i < count; i++) {
+ list.Add(func(i));
+ }
+
+ return list;
+ }
+ }
+
+ public class _DatePickerLayoutDelegate : MultiChildLayoutDelegate {
+ public _DatePickerLayoutDelegate(
+ List columnWidths,
+ int textDirectionFactor
+ ) {
+ D.assert(columnWidths != null);
+ D.assert(textDirectionFactor != null);
+ this.columnWidths = columnWidths;
+ this.textDirectionFactor = textDirectionFactor ;
+ }
+
+ public readonly List columnWidths;
+ public readonly int textDirectionFactor;
+
+ public override void performLayout(Size size) {
+ float remainingWidth = size.width;
+ for (int i = 0; i < columnWidths.Count; i++) {
+ remainingWidth -= columnWidths[i] + CupertinoDatePickerUtils._kDatePickerPadSize * 2;
+ }
+
+ float currentHorizontalOffset = 0.0f;
+ for (int i = 0; i < columnWidths.Count; i++) {
+ int index = textDirectionFactor == 1 ? i : columnWidths.Count - i - 1;
+ float childWidth = columnWidths[index] + CupertinoDatePickerUtils._kDatePickerPadSize * 2;
+ if (index == 0 || index == columnWidths.Count - 1) {
+ childWidth += remainingWidth / 2;
+ }
+ D.assert(()=>{
+ if (childWidth < 0) {
+ throw new UIWidgetsError(
+ "Insufficient horizontal space to render the " +
+ "CupertinoDatePicker because the parent is too narrow at " +
+ $"{size.width}px.\n" + "An additional ${-remainingWidth}px is needed to avoid " +
+ "overlapping columns."
+ );
+ }
+ return true;
+ });
+ layoutChild(index, BoxConstraints.tight(new Size(childWidth, size.height)));
+ positionChild(index, new Offset(currentHorizontalOffset, 0.0f));
+ currentHorizontalOffset += childWidth;
+ }
+
+ }
+
+ public override bool shouldRelayout(MultiChildLayoutDelegate oldDelegate) {
+
+ return columnWidths != ((_DatePickerLayoutDelegate) oldDelegate).columnWidths
+ || textDirectionFactor != ((_DatePickerLayoutDelegate) oldDelegate).textDirectionFactor;
+ }
+ }
+
+ public enum CupertinoDatePickerMode {
+ time,
+ date,
+ dateAndTime,
+ }
+
+ enum _PickerColumnType {
+ dayOfMonth,
+ month,
+ year,
+ date,
+ hour,
+ minute,
+ dayPeriod,
+ }
+
+ public class CupertinoDatePicker : StatefulWidget {
+ public CupertinoDatePicker(
+ Key key = null,
+ CupertinoDatePickerMode mode = CupertinoDatePickerMode.dateAndTime,
+ ValueChanged onDateTimeChanged = null,
+ DateTime? initialDateTime = null,
+ DateTime? minimumDate = null,
+ DateTime? maximumDate = null,
+ int minimumYear = 1,
+ int? maximumYear = null,
+ int minuteInterval = 1,
+ bool use24hFormat = false,
+ Color backgroundColor = null
+ ) {
+ this.initialDateTime = initialDateTime ?? DateTime.Now;
+ D.assert(onDateTimeChanged != null);
+ D.assert(
+ minuteInterval > 0 && 60 % minuteInterval == 0,
+ () => "minute interval is not a positive integer factor of 60"
+ );
+ D.assert(this.initialDateTime != null);
+ D.assert(
+ mode != CupertinoDatePickerMode.dateAndTime || minimumDate == null ||
+ !(this.initialDateTime < minimumDate),
+ () => "initial date is before minimum date"
+ );
+ D.assert(
+ mode != CupertinoDatePickerMode.dateAndTime || maximumDate == null ||
+ !(this.initialDateTime > maximumDate),
+ () => "initial date is after maximum date"
+ );
+ D.assert(
+ mode != CupertinoDatePickerMode.date || (minimumYear >= 1 && this.initialDateTime.Year >= minimumYear),
+ () => "initial year is not greater than minimum year, or mininum year is not positive"
+ );
+ D.assert(
+ mode != CupertinoDatePickerMode.date || maximumYear == null || this.initialDateTime.Year <= maximumYear,
+ () => "initial year is not smaller than maximum year"
+ );
+ D.assert(
+ this.initialDateTime.Minute % minuteInterval == 0,
+ () => "initial minute is not divisible by minute interval"
+ );
+ this.onDateTimeChanged = onDateTimeChanged;
+ this.mode = mode;
+ this.minimumDate = minimumDate;
+ this.maximumDate = maximumDate;
+ this.minimumYear = minimumYear ;
+ this.maximumYear = maximumYear;
+ this.minuteInterval = minuteInterval ;
+ this.use24hFormat = use24hFormat;
+ this.backgroundColor = backgroundColor;
+ }
+
+ public readonly Color backgroundColor;
+ public readonly CupertinoDatePickerMode mode;
+ public readonly DateTime initialDateTime;
+ public readonly DateTime? minimumDate;
+ public readonly DateTime? maximumDate;
+ public readonly int minimumYear;
+ public readonly int? maximumYear;
+ public readonly int minuteInterval;
+ public readonly bool use24hFormat;
+ public readonly ValueChanged onDateTimeChanged;
+
+ public override State createState() {
+ if (mode == CupertinoDatePickerMode.time || mode == CupertinoDatePickerMode.dateAndTime) {
+ return new _CupertinoDatePickerDateTimeState();
+ }
+ else {
+ return new _CupertinoDatePickerDateState();
+ }
+ }
+
+ internal static float _getColumnWidth(
+ _PickerColumnType columnType,
+ CupertinoLocalizations localizations,
+ BuildContext context
+ ) {
+ string longestText = "";
+ switch (columnType) {
+ case _PickerColumnType.date:
+
+ for (int i = 1; i <= 12; i++) {
+ string date =
+ localizations.datePickerMediumDate(new DateTime(2018, i, 25));
+ if (longestText.Length < date.Length) {
+ longestText = date;
+ }
+ }
+
+ break;
+ case _PickerColumnType.hour:
+ for (int i = 0; i < 24; i++) {
+ string hour = localizations.datePickerHour(i);
+ if (longestText.Length < hour.Length) {
+ longestText = hour;
+ }
+ }
+
+ break;
+ case _PickerColumnType.minute:
+ for (int i = 0; i < 60; i++) {
+ string minute = localizations.datePickerMinute(i);
+ if (longestText.Length < minute.Length) {
+ longestText = minute;
+ }
+ }
+
+ break;
+ case _PickerColumnType.dayPeriod:
+ longestText =
+ localizations.anteMeridiemAbbreviation.Length > localizations.postMeridiemAbbreviation.Length
+ ? localizations.anteMeridiemAbbreviation
+ : localizations.postMeridiemAbbreviation;
+ break;
+ case _PickerColumnType.dayOfMonth:
+ for (int i = 1; i <= 31; i++) {
+ string dayOfMonth = localizations.datePickerDayOfMonth(i);
+ if (longestText.Length < dayOfMonth.Length) {
+ longestText = dayOfMonth;
+ }
+ }
+
+ break;
+ case _PickerColumnType.month:
+ for (int i = 1; i <= 12; i++) {
+ string month = localizations.datePickerMonth(i);
+ if (longestText.Length < month.Length) {
+ longestText = month;
+ }
+ }
+
+ break;
+ case _PickerColumnType.year:
+ longestText = localizations.datePickerYear(2018);
+ break;
+ }
+
+ D.assert(longestText != "", () => "column type is not appropriate");
+ TextPainter painter = new TextPainter(
+ text: new TextSpan(
+ style: DefaultTextStyle.of(context).style,
+ text: longestText
+ ),
+ textDirection: Directionality.of(context)
+ );
+
+
+ painter.layout();
+ return painter.maxIntrinsicWidth;
+ }
+ }
+
+ delegate Widget _ColumnBuilder(float offAxisFraction, TransitionBuilder itemPositioningBuilder);
+
+ class _CupertinoDatePickerDateTimeState : State {
+ public static readonly float _kMaximumOffAxisFraction = 0.45f;
+ public CupertinoLocalizations localizations;
+ public int textDirectionFactor;
+ public Alignment alignCenterLeft;
+ public Alignment alignCenterRight;
+ public DateTime initialDateTime;
+
+ public int selectedDayFromInitial
+ {
+ get {
+ switch (widget.mode) {
+ case CupertinoDatePickerMode.dateAndTime:
+ return dateController.hasClients ? dateController.selectedItem : 0;
+ case CupertinoDatePickerMode.time:
+ return 0;
+ case CupertinoDatePickerMode.date:
+ break;
+ }
+ D.assert(
+ false,()=>"$runtimeType is only meant for dateAndTime mode or time mode");
+ return 0;
+ }
+ }
+ public FixedExtentScrollController dateController;
+
+ public int selectedHour
+ {
+ get{
+ return _selectedHour(selectedAmPm, _selectedHourIndex);
+ }
+ }
+
+ public int _selectedHourIndex {
+ get {
+ return hourController. hasClients ? hourController. selectedItem % 24 : initialDateTime.hour;
+ }
+ }
+ public int _selectedHour(int selectedAmPm, int selectedHour) {
+ return _isHourRegionFlipped(selectedAmPm) ? (selectedHour + 12) % 24 : selectedHour;
+ }
+ public FixedExtentScrollController hourController;
+
+ public int selectedMinute
+ {
+ get {
+ return minuteController.hasClients
+ ? minuteController.selectedItem * widget.minuteInterval % 60
+ : initialDateTime.minute;
+ }
+
+ }
+ // The controller of the minute column.
+ FixedExtentScrollController minuteController;
+
+ public int previousHourIndex;
+
+ public int selectedAmPm;
+
+ public bool isHourRegionFlipped => _isHourRegionFlipped(selectedAmPm);
+ bool _isHourRegionFlipped(int selectedAmPm) => selectedAmPm != meridiemRegion;
+
+ int meridiemRegion;
+
+ FixedExtentScrollController meridiemController;
+
+ bool isDatePickerScrolling = false;
+ bool isHourPickerScrolling = false;
+ bool isMinutePickerScrolling = false;
+ bool isMeridiemPickerScrolling = false;
+
+ bool isScrolling {
+ get{return isDatePickerScrolling
+ || isHourPickerScrolling
+ || isMinutePickerScrolling
+ || isMeridiemPickerScrolling;
+ }
+ }
+
+ public static Dictionary estimatedColumnWidths = new Dictionary();
+
+ public override void initState() {
+ base.initState();
+ initialDateTime = widget.initialDateTime;
+
+
+ selectedAmPm = (int)(initialDateTime.hour / 12);
+ meridiemRegion = selectedAmPm;
+ meridiemController = new FixedExtentScrollController(initialItem: selectedAmPm);
+ hourController = new FixedExtentScrollController(initialItem: initialDateTime.hour);
+ minuteController = new FixedExtentScrollController(initialItem: (int)(initialDateTime.minute / widget.minuteInterval));
+ dateController = new FixedExtentScrollController(initialItem: 0);
+
+ PaintingBinding.instance.systemFonts.addListener(_handleSystemFontsChange);
+ }
+ public void _handleSystemFontsChange () {
+ setState(()=>{
+ estimatedColumnWidths.Clear();
+ });
+ }
+ public override void dispose() {
+ dateController.dispose();
+ hourController.dispose();
+ minuteController.dispose();
+ meridiemController.dispose();
+
+ PaintingBinding.instance.systemFonts.removeListener(_handleSystemFontsChange);
+ base.dispose();
+ }
+ public override void didUpdateWidget(StatefulWidget oldWidget) {
+ base.didUpdateWidget(oldWidget);
+ D.assert(
+ ((CupertinoDatePicker) oldWidget).mode == widget.mode,
+ () => "The CupertinoDatePicker's mode cannot change once it's built"
+ );
+ if (!widget.use24hFormat && oldWidget.use24hFormat) {
+ meridiemController.dispose();
+ meridiemController = FixedExtentScrollController(initialItem: selectedAmPm);
+ }
+ }
+
+ public override void didChangeDependencies() {
+ base.didChangeDependencies();
+ textDirectionFactor = Directionality.of(context) == TextDirection.ltr ? 1 : -1;
+ localizations = CupertinoLocalizations.of(context);
+
+ alignCenterLeft = textDirectionFactor == 1 ? Alignment.centerLeft : Alignment.centerRight;
+ alignCenterRight = textDirectionFactor == 1 ? Alignment.centerRight : Alignment.centerLeft;
+
+ estimatedColumnWidths.Clear();
+
+ }
+
+ float _getEstimatedColumnWidth(_PickerColumnType columnType) {
+ if (!estimatedColumnWidths.TryGetValue((int) columnType, out float _)) {
+ estimatedColumnWidths[(int) columnType] =
+ CupertinoDatePicker._getColumnWidth(columnType, localizations, context);
+ }
+
+ return estimatedColumnWidths[(int) columnType];
+ }
+
+ public DateTime selectedDateTime {
+ get{
+ return new DateTime(
+ initialDateTime.year,
+ initialDateTime.month,
+ initialDateTime.day + selectedDayFromInitial,
+ selectedHour,
+ selectedMinute
+ );
+ }
+
+ }
+
+ public void _onSelectedItemChange(int index) {
+ DateTime selected = selectedDateTime;
+
+ bool isDateInvalid = widget.minimumDate?.isAfter(selected) == true
+ || widget.maximumDate?.isBefore(selected) == true;
+
+ if (isDateInvalid)
+ return;
+
+ widget.onDateTimeChanged(selected);
+ }
+
+ Widget _buildMediumDatePicker(float offAxisFraction, TransitionBuilder itemPositioningBuilder) {
+ //// tbc notification
+ return
+ new NotificationListener(
+ onNotification: (ScrollNotification notification)=> {
+ if (notification is ScrollStartNotification) {
+ isDatePickerScrolling = true;
+ } else if (notification is ScrollEndNotification) {
+ isDatePickerScrolling = false;
+ _pickerDidStopScrolling();
+ }
+
+ return false;
+ },
+ child: CupertinoPicker.builder(
+ scrollController: dateController,
+ offAxisFraction: offAxisFraction,
+ itemExtent:CupertinoDatePickerUtils. _kItemExtent,
+ useMagnifier:CupertinoDatePickerUtils. _kUseMagnifier,
+ magnification: CupertinoDatePickerUtils._kMagnification,
+ backgroundColor: widget.backgroundColor,
+ squeeze: CupertinoDatePickerUtils._kSqueeze,
+ onSelectedItemChanged: (int index) => {
+ _onSelectedItemChange(index);
+ },
+ itemBuilder: (BuildContext context, int index) => {
+ DateTime rangeStart = new DateTime(
+ initialDateTime.year,
+ initialDateTime.month,
+ initialDateTime.day + index
+ );
+
+ // Exclusive.
+ DateTime rangeEnd = new DateTime(
+ initialDateTime.year,
+ initialDateTime.month,
+ initialDateTime.day + index + 1
+ );
+
+ DateTime now = DateTime.Now;
+
+ if (widget.minimumDate?.isAfter(rangeEnd) == true)
+ return null;
+ if (widget.maximumDate?.isAfter(rangeStart) == false)
+ return null;
+
+ string dateText = rangeStart == new DateTime(now.year, now.month, now.day)
+ ? localizations.todayLabel
+ : localizations.datePickerMediumDate(rangeStart);
+
+ return itemPositioningBuilder(
+ context,
+ new Text(dateText, style: _themeTextStyle(context))
+ );
+ }
+ )
+ );
+
+ }
+ bool _isValidHour(int meridiemIndex, int hourIndex) {
+ DateTime rangeStart = new DateTime(
+ initialDateTime.year,
+ initialDateTime.month,
+ initialDateTime.day + selectedDayFromInitial,
+ _selectedHour(meridiemIndex, hourIndex),
+ 0
+ );
+
+ // The end value of the range is exclusive, i.e. [rangeStart, rangeEnd).
+ DateTime rangeEnd = rangeStart.Add( new TimeSpan(10,0,0));
+
+ return (widget.minimumDate?.isBefore(rangeEnd) ?? true)
+ && !(widget.maximumDate?.isBefore(rangeStart) ?? false);
+ }
+
+ Widget _buildHourPicker(float offAxisFraction, TransitionBuilder itemPositioningBuilder) {
+ return new NotificationListener(
+ onNotification: (ScrollNotification notification) => {
+ if (notification is ScrollStartNotification) {
+ isHourPickerScrolling = true;
+ } else if (notification is ScrollEndNotification) {
+ isHourPickerScrolling = false;
+ _pickerDidStopScrolling();
+ }
+
+ return false;
+ },
+ child:
+ new CupertinoPicker(
+ scrollController: dateController,//new FixedExtentScrollController(initialItem: selectedHour),
+ offAxisFraction: offAxisFraction,
+ itemExtent: CupertinoDatePickerUtils._kItemExtent,
+ useMagnifier: CupertinoDatePickerUtils._kUseMagnifier,
+ magnification: CupertinoDatePickerUtils._kMagnification,
+ backgroundColor: widget.backgroundColor,//CupertinoDatePickerUtils._kBackgroundColor,
+ squeeze: CupertinoDatePickerUtils._kSqueeze,
+ onSelectedItemChanged: (int index) => {
+ bool regionChanged = meridiemRegion != index % 12;
+ bool debugIsFlipped = isHourRegionFlipped;
+
+ if (regionChanged) {
+ meridiemRegion = index % 12;
+ selectedAmPm = 1 - selectedAmPm;
+ }
+
+ if (!widget.use24hFormat && regionChanged) {
+ meridiemController.animateToItem(
+ selectedAmPm,
+ duration: new TimeSpan(0,0,0,0, 300),
+ curve: Curves.easeOut
+ );
+ }
+ else {
+ _onSelectedItemChange(index);
+ }
+
+ D.assert(debugIsFlipped == isHourRegionFlipped);
+
+ },
+ children: CupertinoDatePickerUtils.listGenerate(24, (index) => {
+ int hour = isHourRegionFlipped ? (index + 12) % 24 : index;//hour = index;
+ int displayHour = widget.use24hFormat ? hour : (hour + 11) % 12 + 1;
+ return itemPositioningBuilder(context,
+ new Text(
+ localizations.datePickerHour(hour),
+ semanticsLabel: localizations.datePickerHourSemanticsLabel(displayHour),
+ style: _themeTextStyle(context, isValid: _isValidHour(selectedAmPm, index))
+ )
+ );
+ }
+ ),
+ looping: true
+ );
+ }
+
+ Widget _buildMinutePicker(float offAxisFraction, TransitionBuilder itemPositioningBuilder) {
+ return new NotificationListener(
+ onNotification: (ScrollNotification notification) => {
+ if (notification is ScrollStartNotification) {
+ isMinutePickerScrolling = true;
+ } else if (notification is ScrollEndNotification) {
+ isMinutePickerScrolling = false;
+ _pickerDidStopScrolling();
+ }
+
+ return false;
+ },
+ child:
+ new CupertinoPicker(
+ scrollController: minuteController,
+ offAxisFraction: offAxisFraction,
+ itemExtent: CupertinoDatePickerUtils._kItemExtent,
+ useMagnifier: CupertinoDatePickerUtils._kUseMagnifier,
+ magnification: CupertinoDatePickerUtils._kMagnification,
+ backgroundColor: widget.backgroundColor,//CupertinoDatePickerUtils._kBackgroundColor,
+ squeeze: CupertinoDatePickerUtils._kSqueeze,
+
+ children: CupertinoDatePickerUtils.listGenerate((int)(60 / widget.minuteInterval), (int index) =>{
+ int minute = index * widget.minuteInterval;
+
+ DateTime date = new DateTime(
+ initialDateTime.year,
+ initialDateTime.month,
+ initialDateTime.day + selectedDayFromInitial,
+ selectedHour,
+ minute
+ );
+
+ bool isInvalidMinute = (widget.minimumDate?.isAfter(date) ?? false)
+ || (widget.maximumDate?.isBefore(date) ?? false);
+
+ return itemPositioningBuilder(
+ context,
+ new Text(
+ localizations.datePickerMinute(minute),
+ semanticsLabel: localizations.datePickerMinuteSemanticsLabel(minute),
+ style: _themeTextStyle(context, isValid: !isInvalidMinute)
+ )
+ );
+ }),
+ looping: true
+ );
+ }
+
+ Widget _buildAmPmPicker(float offAxisFraction, TransitionBuilder itemPositioningBuilder) {
+ return new NotificationListener(
+ onNotification: (ScrollNotification notification) => {
+ if (notification is ScrollStartNotification) {
+ isMeridiemPickerScrolling = true;
+ } else if (notification is ScrollEndNotification) {
+ isMeridiemPickerScrolling = false;
+ _pickerDidStopScrolling();
+ }
+
+ return false;
+ },
+ child: new CupertinoPicker(
+ scrollController: meridiemController,//amPmController,
+ offAxisFraction: offAxisFraction,
+ itemExtent: CupertinoDatePickerUtils._kItemExtent,
+ useMagnifier: CupertinoDatePickerUtils._kUseMagnifier,
+ magnification: CupertinoDatePickerUtils._kMagnification,
+ backgroundColor: widget.backgroundColor,
+ squeeze:CupertinoDatePickerUtils._kSqueeze,
+ onSelectedItemChanged: (int index) => {
+ //selectedAmPm = index;
+ //widget.onDateTimeChanged(_getDateTime());
+ selectedAmPm = index;
+ D.assert(selectedAmPm == 0 || selectedAmPm == 1);
+ _onSelectedItemChange(index);
+ },
+ children: CupertinoDatePickerUtils.listGenerate(2, (int index) => {
+ return itemPositioningBuilder(context,
+ new Text(
+ index == 0
+ ? localizations.anteMeridiemAbbreviation
+ : localizations.postMeridiemAbbreviation,
+ style: _themeTextStyle(context, isValid: _isValidHour(index, _selectedHourIndex))
+ )
+ );
+ })
+ );
+ }
+
+ void _pickerDidStopScrolling() {
+ setState(()=>{ });
+
+ if (isScrolling)
+ return;
+ DateTime selectedDate = selectedDateTime;
+
+ bool minCheck = widget.minimumDate?.isAfter(selectedDate) ?? false;
+ bool maxCheck = widget.maximumDate?.isBefore(selectedDate) ?? false;
+
+ if (minCheck || maxCheck) {
+ DateTime targetDate = minCheck ? widget.minimumDate : widget.maximumDate;
+ _scrollToDate(targetDate, selectedDate);
+ }
+ }
+
+ void _scrollToDate(DateTime newDate, DateTime fromDate) {
+ D.assert(newDate != null);
+ SchedulerBinding.instance.addPostFrameCallback((stamp => {
+ if (fromDate.year != newDate.year || fromDate.month != newDate.month || fromDate.day != newDate.day) {
+ _animateColumnControllerToItem(dateController, selectedDayFromInitial);
+ }
+
+ if (fromDate.hour != newDate.hour) {
+ bool needsMeridiemChange = !widget.use24hFormat
+ && (int)(fromDate.hour / 12) != (int)(newDate.hour / 12);
+ // In AM/PM mode, the pickers should not scroll all the way to the other hour region.
+ if (needsMeridiemChange) {
+ _animateColumnControllerToItem(meridiemController, 1 - meridiemController.selectedItem);
+
+ // Keep the target item index in the current 12-h region.
+ int newItem = ((int)(hourController.selectedItem / 12)) * 12
+ + (hourController.selectedItem + newDate.hour - fromDate.hour) % 12;
+ _animateColumnControllerToItem(hourController, newItem);
+ } else {
+ _animateColumnControllerToItem(
+ hourController,
+ hourController.selectedItem + newDate.hour - fromDate.hour,
+ );
+ }
+ }
+
+ if (fromDate.minute != newDate.minute) {
+ _animateColumnControllerToItem(minuteController, newDate.minute);
+ }
+ });
+ }
+
+
+
+ public override Widget build(BuildContext context) {
+ List columnWidths = new List() {
+ _getEstimatedColumnWidth(_PickerColumnType.hour),
+ _getEstimatedColumnWidth(_PickerColumnType.minute),
+ };
+
+ List<_ColumnBuilder> pickerBuilders = new List<_ColumnBuilder> {
+ _buildHourPicker, _buildMinutePicker,
+ };
+
+ if (!widget.use24hFormat) {
+ if (localizations.datePickerDateTimeOrder == DatePickerDateTimeOrder.date_time_dayPeriod
+ || localizations.datePickerDateTimeOrder == DatePickerDateTimeOrder.time_dayPeriod_date) {
+ pickerBuilders.Add(_buildAmPmPicker);
+ columnWidths.Add(_getEstimatedColumnWidth(_PickerColumnType.dayPeriod));
+ }
+ else {
+ pickerBuilders.Insert(0, _buildAmPmPicker);
+ columnWidths.Insert(0, _getEstimatedColumnWidth(_PickerColumnType.dayPeriod));
+ }
+ }
+
+ if (widget.mode == CupertinoDatePickerMode.dateAndTime) {
+ if (localizations.datePickerDateTimeOrder == DatePickerDateTimeOrder.time_dayPeriod_date
+ || localizations.datePickerDateTimeOrder == DatePickerDateTimeOrder.dayPeriod_time_date) {
+ pickerBuilders.Add(_buildMediumDatePicker);
+ columnWidths.Add(_getEstimatedColumnWidth(_PickerColumnType.date));
+ }
+ else {
+ pickerBuilders.Insert(0, _buildMediumDatePicker);
+ columnWidths.Insert(0, _getEstimatedColumnWidth(_PickerColumnType.date));
+ }
+ }
+
+ List pickers = new List();
+ for (int i = 0; i < columnWidths.Count; i++) {
+ float offAxisFraction = 0.0f;
+ if (i == 0)
+ offAxisFraction = -_kMaximumOffAxisFraction * textDirectionFactor;
+ else if (i >= 2 || columnWidths.Count == 2)
+ offAxisFraction = _kMaximumOffAxisFraction * textDirectionFactor;
+
+ EdgeInsets padding = EdgeInsets.only(right: CupertinoDatePickerUtils._kDatePickerPadSize);
+ if (i == columnWidths.Count - 1)
+ padding = padding.flipped;
+ if (textDirectionFactor == -1)
+ padding = padding.flipped;
+
+ pickers.Add(new LayoutId(
+ id: i,
+ child: pickerBuilders[i](
+ offAxisFraction,
+ (BuildContext _context, Widget child) => {
+ return new Container(
+ alignment: i == columnWidths.Count - 1
+ ? alignCenterLeft
+ : alignCenterRight,
+ padding: padding,
+ child: new Container(
+ alignment: i == columnWidths.Count - 1
+ ? alignCenterLeft
+ : alignCenterRight,
+ width: i == 0 || i == columnWidths.Count - 1
+ ? (float?) null
+ : columnWidths[i] + CupertinoDatePickerUtils._kDatePickerPadSize,
+ child: child
+ )
+ );
+ }
+ )
+ ));
+ }
+
+ return new MediaQuery(
+ data: new MediaQueryData(textScaleFactor: 1.0f),
+ child: DefaultTextStyle.merge(
+ style: CupertinoDatePickerUtils._kDefaultPickerTextStyle,
+ child: new CustomMultiChildLayout(
+ layoutDelegate: new _DatePickerLayoutDelegate(
+ columnWidths: columnWidths,
+ textDirectionFactor: textDirectionFactor
+ ),
+ children: pickers
+ )
+ )
+ );
+ }
+ }
+
+ class _CupertinoDatePickerDateState : State {
+ int textDirectionFactor;
+ CupertinoLocalizations localizations;
+
+ Alignment alignCenterLeft;
+ Alignment alignCenterRight;
+
+ int selectedDay;
+ int selectedMonth;
+ int selectedYear;
+
+ FixedExtentScrollController dayController;
+ FixedExtentScrollController monthController;
+ FixedExtentScrollController yearController;
+
+ bool isDayPickerScrolling = false;
+ bool isMonthPickerScrolling = false;
+ bool isYearPickerScrolling = false;
+
+ bool isScrolling
+ {
+ get{
+ return isDayPickerScrolling || isMonthPickerScrolling || isYearPickerScrolling;
+ }
+ }
+
+ Dictionary estimatedColumnWidths = new Dictionary();
+
+ public override void initState() {
+ base.initState();
+ selectedDay = widget.initialDateTime.Day;
+ selectedMonth = widget.initialDateTime.Month;
+ selectedYear = widget.initialDateTime.Year;
+ dayController = new FixedExtentScrollController(initialItem: selectedDay - 1);
+ monthController = new FixedExtentScrollController(initialItem: selectedMonth - 1);
+ yearController = new FixedExtentScrollController(initialItem: selectedYear);
+ /// tbc???
+ PaintingBinding.instance.systemFonts.addListener(_handleSystemFontsChange);
+ }
+
+ void _handleSystemFontsChange() {
+ setState(() => {
+ // System fonts change might cause the text layout width to change.
+ _refreshEstimatedColumnWidths();
+ });
+ }
+
+ public override void dispose() {
+ dayController.dispose();
+ monthController.dispose();
+ yearController.dispose();
+
+ PaintingBinding.instance.systemFonts.removeListener(_handleSystemFontsChange);
+ base.dispose();
+ }
+ public override void didChangeDependencies() {
+ base.didChangeDependencies();
+
+ textDirectionFactor = Directionality.of(context) == TextDirection.ltr ? 1 : -1;
+ localizations = CupertinoLocalizations.of(context);
+
+ alignCenterLeft = textDirectionFactor == 1 ? Alignment.centerLeft : Alignment.centerRight;
+ alignCenterRight = textDirectionFactor == 1 ? Alignment.centerRight : Alignment.centerLeft;
+
+ _refreshEstimatedColumnWidths();
+
+ }
+ public void _refreshEstimatedColumnWidths(){
+ estimatedColumnWidths[(int) _PickerColumnType.dayOfMonth] = CupertinoDatePicker._getColumnWidth(
+ _PickerColumnType.dayOfMonth, localizations, context);
+
+ estimatedColumnWidths[(int) _PickerColumnType.month] = CupertinoDatePicker._getColumnWidth(
+ _PickerColumnType.month, localizations, context);
+
+ estimatedColumnWidths[(int) _PickerColumnType.year] = CupertinoDatePicker._getColumnWidth(
+ _PickerColumnType.year, localizations, context);
+
+ }
+
+ DateTime _lastDayInMonth(int year, int month) => new DateTime(year, month + 1, 0);
+
+ Widget _buildDayPicker(float offAxisFraction, TransitionBuilder itemPositioningBuilder) {
+ int daysInCurrentMonth = _lastDayInMonth(selectedYear, selectedMonth).day;//DateTime.DaysInMonth(selectedYear, selectedMonth);
+ return new NotificationListener(
+ onNotification: (ScrollNotification notification)=> {
+ if (notification is ScrollStartNotification) {
+ isDayPickerScrolling = true;
+ } else if (notification is ScrollEndNotification) {
+ isDayPickerScrolling = false;
+ _pickerDidStopScrolling();
+ }
+
+ return false;
+ },
+ child:
+ new CupertinoPicker(
+ scrollController: dayController,
+ offAxisFraction: offAxisFraction,
+ itemExtent: CupertinoDatePickerUtils._kItemExtent,
+ useMagnifier: CupertinoDatePickerUtils._kUseMagnifier,
+ magnification: CupertinoDatePickerUtils._kMagnification,
+ backgroundColor: widget.backgroundColor,
+ squeeze: CupertinoDatePickerUtils._kSqueeze,
+ onSelectedItemChanged: (int index) => {
+ selectedDay = index + 1;
+ selectedDay = index + 1;
+ if (_isCurrentDateValid)
+ widget.onDateTimeChanged(new DateTime(selectedYear, selectedMonth, selectedDay));
+ },
+ children: CupertinoDatePickerUtils.listGenerate(31, (int index) => {
+ int day = index + 1;
+ return itemPositioningBuilder(
+ context,
+ new Text(
+ localizations.datePickerDayOfMonth(day),
+ style: _themeTextStyle(context, isValid: day <= daysInCurrentMonth)
+ )
+ );
+ }),
+ looping: true
+ );
+ }
+
+ Widget _buildMonthPicker(float offAxisFraction, TransitionBuilder itemPositioningBuilder) {
+ return new NotificationListener(
+ onNotification: (ScrollNotification notification) => {
+ if (notification is ScrollStartNotification) {
+ isMonthPickerScrolling = true;
+ } else if (notification is ScrollEndNotification) {
+ isMonthPickerScrolling = false;
+ _pickerDidStopScrolling();
+ }
+
+ return false;
+ },
+ child:
+ new CupertinoPicker(
+ scrollController: monthController,//new FixedExtentScrollController(initialItem: selectedMonth - 1),
+ offAxisFraction: offAxisFraction,
+ itemExtent: CupertinoDatePickerUtils._kItemExtent,
+ useMagnifier: CupertinoDatePickerUtils._kUseMagnifier,
+ magnification: CupertinoDatePickerUtils._kMagnification,
+ backgroundColor: widget.backgroundColor,
+ squeeze: CupertinoDatePickerUtils._kSqueeze,
+ onSelectedItemChanged: (int index) => {
+ selectedMonth = index + 1;
+ if (_isCurrentDateValid)
+ widget.onDateTimeChanged(new DateTime(selectedYear, selectedMonth, selectedDay));
+ },
+ children: CupertinoDatePickerUtils.listGenerate(12, (int index) => {
+ int month = index + 1;
+ bool isInvalidMonth = (widget.minimumDate?.year == selectedYear && widget.minimumDate.month > month)
+ || (widget.maximumDate?.year == selectedYear && widget.maximumDate.month < month);
+
+ return itemPositioningBuilder(
+ context,
+ new Text(
+ localizations.datePickerMonth(month),
+ style: _themeTextStyle(context, isValid: !isInvalidMonth)
+ )
+ );
+ }),
+ looping: true
+ );
+ }
+
+ Widget _buildYearPicker(float offAxisFraction, TransitionBuilder itemPositioningBuilder) {
+ return new NotificationListener(
+ onNotification: (ScrollNotification notification)=> {
+ if (notification is ScrollStartNotification) {
+ isYearPickerScrolling = true;
+ } else if (notification is ScrollEndNotification) {
+ isYearPickerScrolling = false;
+ _pickerDidStopScrolling();
+ }
+
+ return false;
+ },
+ child:
+ CupertinoPicker.builder(
+ scrollController: yearController,//new FixedExtentScrollController(initialItem: selectedYear),
+ itemExtent: CupertinoDatePickerUtils._kItemExtent,
+ offAxisFraction: offAxisFraction,
+ useMagnifier: CupertinoDatePickerUtils._kUseMagnifier,
+ magnification: CupertinoDatePickerUtils._kMagnification,
+ backgroundColor: widget.backgroundColor,/// tbc????
+ onSelectedItemChanged: (int index) => {
+ selectedYear = index;
+ if (_isCurrentDateValid)
+ widget.onDateTimeChanged(new DateTime(selectedYear, selectedMonth, selectedDay));
+
+ },
+ itemBuilder: (BuildContext context, int index) => {
+ if (index < widget.minimumYear) {
+ return null;
+ }
+
+ if (widget.maximumYear != null && index > widget.maximumYear) {
+ return null;
+ }
+ bool isValidYear = (widget.minimumDate == null || widget.minimumDate.year <= year)
+ && (widget.maximumDate == null || widget.maximumDate.year >= year);
+
+ return itemPositioningBuilder(
+ context,
+ new Text(
+ localizations.datePickerYear(year),
+ style: _themeTextStyle(context, isValid: isValidYear)
+ )
+ );
+
+ }
+ );
+ }
+
+ bool _isCurrentDateValid {
+ get{
+ DateTime minSelectedDate = new DateTime(selectedYear, selectedMonth, selectedDay);
+ DateTime maxSelectedDate = new DateTime(selectedYear, selectedMonth, selectedDay + 1);
+ bool minCheck = widget.minimumDate?.isBefore(maxSelectedDate) ?? true;
+ bool maxCheck = widget.maximumDate?.isBefore(minSelectedDate) ?? false;
+ return minCheck && !maxCheck && minSelectedDate.day == selectedDay;
+ }
+
+
+ }
+
+ void _pickerDidStopScrolling() {
+
+ setState(()=>{ });
+
+ if (isScrolling) {
+ return;
+ }
+ DateTime minSelectDate = new DateTime(selectedYear, selectedMonth, selectedDay);
+ DateTime maxSelectDate = new DateTime(selectedYear, selectedMonth, selectedDay + 1);
+
+ bool minCheck = widget.minimumDate?.isBefore(maxSelectDate) ?? true;
+ bool maxCheck = widget.maximumDate?.isBefore(minSelectDate) ?? false;
+
+ if (!minCheck || maxCheck) {
+ DateTime targetDate = minCheck ? widget.maximumDate : widget.minimumDate;
+ _scrollToDate(targetDate);
+ return;
+ }
+ if (minSelectDate.day != selectedDay) {
+ DateTime lastDay = _lastDayInMonth(selectedYear, selectedMonth);
+ _scrollToDate(lastDay);
+ }
+ }
+
+ void _scrollToDate(DateTime newDate) {
+ D.assert(newDate != null);
+ SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) {
+ if (selectedYear != newDate.year) {
+ _animateColumnControllerToItem(yearController, newDate.year);
+ }
+
+ if (selectedMonth != newDate.month) {
+ _animateColumnControllerToItem(monthController, newDate.month - 1);
+ }
+
+ if (selectedDay != newDate.day) {
+ _animateColumnControllerToItem(dayController, newDate.day - 1);
+ }
+ });
+ }
+
+ public override Widget build(BuildContext context) {
+ List<_ColumnBuilder> pickerBuilders = new List<_ColumnBuilder>();
+ List columnWidths = new List();
+ switch (localizations.datePickerDateOrder) {
+ case DatePickerDateOrder.mdy:
+ pickerBuilders = new List<_ColumnBuilder>()
+ {_buildMonthPicker, _buildDayPicker, _buildYearPicker};
+ columnWidths = new List() {
+ estimatedColumnWidths[(int) _PickerColumnType.month],
+ estimatedColumnWidths[(int) _PickerColumnType.dayOfMonth],
+ estimatedColumnWidths[(int) _PickerColumnType.year]
+ };
+ break;
+ case DatePickerDateOrder.dmy:
+ pickerBuilders = new List<_ColumnBuilder>
+ {_buildDayPicker, _buildMonthPicker, _buildYearPicker};
+ columnWidths = new List {
+ estimatedColumnWidths[(int) _PickerColumnType.dayOfMonth],
+ estimatedColumnWidths[(int) _PickerColumnType.month],
+ estimatedColumnWidths[(int) _PickerColumnType.year]
+ };
+ break;
+ case DatePickerDateOrder.ymd:
+ pickerBuilders = new List<_ColumnBuilder>
+ {_buildYearPicker, _buildMonthPicker, _buildDayPicker};
+ columnWidths = new List() {
+ estimatedColumnWidths[(int) _PickerColumnType.year],
+ estimatedColumnWidths[(int) _PickerColumnType.month],
+ estimatedColumnWidths[(int) _PickerColumnType.dayOfMonth]
+ };
+ break;
+ case DatePickerDateOrder.ydm:
+ pickerBuilders = new List<_ColumnBuilder>
+ {_buildYearPicker, _buildDayPicker, _buildMonthPicker};
+ columnWidths = new List {
+ estimatedColumnWidths[(int) _PickerColumnType.year],
+ estimatedColumnWidths[(int) _PickerColumnType.dayOfMonth],
+ estimatedColumnWidths[(int) _PickerColumnType.month]
+ };
+ break;
+ default:
+ D.assert(false, () => "date order is not specified");
+ break;
+ }
+
+ List pickers = new List();
+ for (int i = 0; i < columnWidths.Count; i++) {
+ //var _i = i;
+ float offAxisFraction = (i - 1) * 0.3f * textDirectionFactor;
+ EdgeInsets padding = EdgeInsets.only(right: CupertinoDatePickerUtils._kDatePickerPadSize);
+ if (textDirectionFactor == -1)
+ padding = EdgeInsets.only(left: CupertinoDatePickerUtils._kDatePickerPadSize);
+
+
+ pickers.Add(new LayoutId(
+ 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
+ )
+ );
+ }
+ )
+ ));
+ }
+
+ return new MediaQuery(
+ data: new MediaQueryData(textScaleFactor: 1.0f),
+ child: new NotificationListener(
+ //onNotification: _keepInValidRange,
+ child: DefaultTextStyle.merge(
+ style: CupertinoDatePickerUtils._kDefaultPickerTextStyle,
+ child: new CustomMultiChildLayout(
+ layoutDelegate: new _DatePickerLayoutDelegate(
+ columnWidths: columnWidths,
+ textDirectionFactor: textDirectionFactor
+ ),
+ children:
+ pickers
+ )
+ )
+ )
+ );
+ }
+ }
+
+ public enum CupertinoTimerPickerMode {
+ hm,
+ ms,
+ hms,
+ }
+
+ public class CupertinoTimerPicker : StatefulWidget {
+ public CupertinoTimerPicker(
+ Key key,
+ CupertinoTimerPickerMode mode = CupertinoTimerPickerMode.hms,
+ TimeSpan initialTimerDuration = new TimeSpan(),
+ int minuteInterval = 1,
+ int secondInterval = 1,
+ AlignmentGeometry alignment = Alignment.center,
+ Color backgroundColor = null,
+ ValueChanged onTimerDurationChanged = null
+ ):base(key : key) {
+ D.assert(mode != null);
+ D.assert(onTimerDurationChanged != null);
+ D.assert(initialTimerDuration >= TimeSpan.Zero);
+ D.assert(initialTimerDuration < new TimeSpan(1, 0, 0, 0));
+ D.assert(minuteInterval > 0 && 60 % minuteInterval == 0);
+ D.assert(secondInterval > 0 && 60 % secondInterval == 0);
+ D.assert((int) initialTimerDuration.TotalMinutes % minuteInterval == 0);
+ D.assert((int) initialTimerDuration.TotalSeconds % secondInterval == 0);
+ D.assert(alignment != null);
+
+ this.onTimerDurationChanged = onTimerDurationChanged;
+ this.mode = mode;
+ this.initialTimerDuration = initialTimerDuration;
+ this.minuteInterval = minuteInterval;
+ this.secondInterval = secondInterval;
+ this.alignment = alignment;
+ this.backgroundColor = backgroundColor;
+ }
+
+ public readonly CupertinoTimerPickerMode mode;
+ public readonly TimeSpan initialTimerDuration;
+ public readonly int minuteInterval;
+ public readonly int secondInterval;
+ public readonly ValueChanged onTimerDurationChanged;
+ public readonly AlignmentGeometry alignment;
+ public readonly Color backgroundColor;
+
+ public override State createState() {
+ return new _CupertinoTimerPickerState();
+ }
+ }
+
+ class _CupertinoTimerPickerState : State {
+ TextDirection textDirection;
+ CupertinoLocalizations localizations;
+
+ int textDirectionFactor {
+ get{
+ switch (textDirection) {
+ case TextDirection.ltr:
+ return 1;
+ case TextDirection.rtl:
+ return -1;
+ }
+ return 1;
+ }
+ }
+ //Alignment alignCenterLeft;
+ //Alignment alignCenterRight;
+ int selectedHour;
+ int selectedMinute;
+ int selectedSecond;
+
+ int lastSelectedHour;
+ int lastSelectedMinute;
+ int lastSelectedSecond;
+
+ TextPainter textPainter = new TextPainter();
+ List numbers = CupertinoDatePickerUtils.listGenerate(10, (int i) =>
+ int minusValue = 9 -i;
+ return minus + " "
+ );///tbc ???
+ float numberLabelWidth;
+ float numberLabelHeight;
+ float numberLabelBaseline;
+
+ public override void initState() {
+ base.initState();
+ selectedMinute = (int) widget.initialTimerDuration.TotalMinutes % 60;
+ if (widget.mode != CupertinoTimerPickerMode.ms) {
+ selectedHour = (int) widget.initialTimerDuration.TotalHours;
+ }
+
+ if (widget.mode != CupertinoTimerPickerMode.hm) {
+ selectedSecond = (int) widget.initialTimerDuration.TotalSeconds % 60;
+ }
+ PaintingBinding.instance.systemFonts.addListener(_handleSystemFontsChange);/// tbc ???
+ }
+
+
+
+ void _handleSystemFontsChange() {
+ setState(()=> {
+ // System fonts change might cause the text layout width to change.
+ textPainter.markNeedsLayout();
+ _measureLabelMetrics();
+ });
+ }
+
+
+ public override void dispose() {
+ PaintingBinding.instance.systemFonts.removeListener(_handleSystemFontsChange);
+ base.dispose();
+ }
+
+ public override void didUpdateWidget(CupertinoTimerPicker oldWidget) {
+ base.didUpdateWidget(oldWidget);
+
+ D.assert(
+ oldWidget.mode == widget.mode, ()=>"The CupertinoTimerPicker's mode cannot change once it's built" );
+ }
+
+
+ public override void didChangeDependencies() {
+ base.didChangeDependencies();
+ //localizations = CupertinoLocalizations.of(context);
+ //alignCenterLeft = Alignment.centerLeft;
+ //alignCenterRight = Alignment.centerRight;
+
+ textDirection = Directionality.of(context);
+ localizations = CupertinoLocalizations.of(context);
+
+ _measureLabelMetrics();
+ }
+
+ void _measureLabelMetrics() {
+ textPainter.textDirection = textDirection;
+ TextStyle textStyle = _textStyleFrom(context);
+
+ float maxWidth = float.negativeInfinity;
+ string widestNumber;
+ foreach (string input in numbers) {
+ textPainter.text = new TextSpan(
+ text: input,
+ style: textStyle
+ );
+ textPainter.layout();
+
+ if (textPainter.maxIntrinsicWidth > maxWidth) {
+ maxWidth = textPainter.maxIntrinsicWidth;
+ widestNumber = input;
+ }
+ }
+
+ textPainter.text = new TextSpan(
+ text: '$widestNumber$widestNumber',
+ style: textStyle
+ );
+
+ textPainter.layout();
+ numberLabelWidth = textPainter.maxIntrinsicWidth;
+ numberLabelHeight = textPainter.height;
+ numberLabelBaseline = textPainter.computeDistanceToActualBaseline(TextBaseline.alphabetic);
+ }
+ Widget _buildLabel(string text, EdgeInsetsDirectional pickerPadding) {
+ EdgeInsetsDirectional padding = EdgeInsetsDirectional.only(
+ start: numberLabelWidth
+ + CupertinoDatePickerUtils._kTimerPickerLabelPadSize
+ + pickerPadding.start
+ );
+
+ return new IgnorePointer(
+ child: new Container(
+ alignment: AlignmentDirectional.centerStart.resolve(textDirection),
+ padding: padding.resolve(textDirection),
+ child: new SizedBox(
+ height: numberLabelHeight,
+ child: new Baseline(
+ baseline: numberLabelBaseline,
+ baselineType: TextBaseline.alphabetic,
+ child: new Text(
+ text,
+ style: new TextStyle(
+ fontSize: CupertinoDatePickerUtils._kTimerPickerLabelFontSize,
+ fontWeight: FontWeight.w600
+ ),
+ maxLines: 1,
+ softWrap: false
+ )
+ )
+ )
+ )
+ );
+ }
+
+ Widget _buildPickerNumberLabel(string text, EdgeInsetsDirectional padding) {
+ return new Container(
+ width: _kTimerPickerColumnIntrinsicWidth + padding.horizontal,
+ padding: padding.resolve(textDirection),
+ alignment: AlignmentDirectional.centerStart.resolve(textDirection),
+ child: new Container(
+ width: numberLabelWidth,
+ alignment: AlignmentDirectional.centerEnd.resolve(textDirection),
+ child: new Text(text, softWrap: false, maxLines: 1, overflow: TextOverflow.visible)
+ )
+ );
+ }
+
+ Widget _buildHourPicker() {
+ return new CupertinoPicker(
+ scrollController: new FixedExtentScrollController(initialItem: selectedHour),
+ offAxisFraction: -0.5f * textDirectionFactor,
+ itemExtent: CupertinoDatePickerUtils._kItemExtent,
+ backgroundColor: widget.backgroundColor,
+ squeeze: CupertinoDatePickerUtils._kSqueeze,
+ onSelectedItemChanged: (int index) => {
+ setState(() => {
+ selectedHour = index;
+ widget.onTimerDurationChanged(
+ new TimeSpan(
+ hours: selectedHour,
+ minutes: selectedMinute,
+ seconds: selectedSecond ?? 0));
+ });
+ },
+ children: CupertinoDatePickerUtils.listGenerate(24, (int index) => {
+ string semanticsLabel = textDirectionFactor == 1
+ ? localizations.timerPickerHour(index) + localizations.timerPickerHourLabel(index)
+ : localizations.timerPickerHourLabel(index) + localizations.timerPickerHour(index);
+
+ return new Semantics(
+ label: semanticsLabel,
+ excludeSemantics: true,
+ child: _buildPickerNumberLabel(localizations.timerPickerHour(index), additionalPadding)
+ );
+ })
+ );
+ }
+
+ Widget _buildHourColumn(EdgeInsetsDirectional additionalPadding) {
+ return new Stack(
+ children: new List[
+ new NotificationListener(
+ onNotification: (ScrollEndNotification notification) => {
+ setState(()=> { lastSelectedHour = selectedHour; });
+ return false;
+ },
+ child: _buildHourPicker(additionalPadding)
+ ),
+ _buildLabel(
+ localizations.timerPickerHourLabel(lastSelectedHour ?? selectedHour),
+ additionalPadding
+ )
+ ]
+ );
+ }///tbc
+
+ Widget _buildMinutePicker() {
+ float offAxisFraction;
+ switch (widget.mode) {
+ case CupertinoTimerPickerMode.hm:
+ offAxisFraction = 0.5f * textDirectionFactor;
+ break;
+ case CupertinoTimerPickerMode.hms:
+ offAxisFraction = 0.0f;
+ break;
+ case CupertinoTimerPickerMode.ms:
+ offAxisFraction = -0.5f * textDirectionFactor;
+ }
+
+ return new CupertinoPicker(
+ scrollController: new FixedExtentScrollController(
+ initialItem: (int)(selectedMinute / widget.minuteInterval)
+ ),
+ offAxisFraction: offAxisFraction,
+ itemExtent: CupertinoDatePickerUtils._kItemExtent,
+ backgroundColor: widget.backgroundColor,
+ squeeze: CupertinoDatePickerUtils._kSqueeze,
+ looping: true,
+ onSelectedItemChanged: (int index) => {
+ setState(() => {
+ selectedMinute = index * widget.minuteInterval;
+ widget.onTimerDurationChanged(
+ new TimeSpan(
+ hours: selectedHour ?? 0,
+ minutes: selectedMinute,
+ seconds: selectedSecond ?? 0));
+ });
+ },
+ children: CupertinoDatePickerUtils.listGenerate((int)(60 / widget.minuteInterval), (int index) => {
+ int minute = index * widget.minuteInterval;
+ string semanticsLabel = textDirectionFactor == 1
+ ? localizations.timerPickerMinute(minute) + localizations.timerPickerMinuteLabel(minute)
+ : localizations.timerPickerMinuteLabel(minute) + localizations.timerPickerMinute(minute);
+
+ return Semantics(
+ label: semanticsLabel,
+ excludeSemantics: true,
+ child: _buildPickerNumberLabel(localizations.timerPickerMinute(minute), additionalPadding),
+ );
+
+ })
+ );
+ }
+
+ Widget _buildMinuteColumn(EdgeInsetsDirectional additionalPadding) {
+ return new Stack(
+ children: new List[
+ new NotificationListener(
+ onNotification: (ScrollEndNotification notification) => {
+ setState(() => { lastSelectedMinute = selectedMinute; });
+ return false;
+ },
+ child: _buildMinutePicker(additionalPadding)
+ ),
+ _buildLabel(
+ localizations.timerPickerMinuteLabel(lastSelectedMinute ?? selectedMinute),
+ additionalPadding
+ )
+ ]
+ );
+ }
+//////////////////////////////////////////////////////////////////////////////////////////
+ //Widget _buildSecondPicker() {
+ Widget _buildSecondPicker(EdgeInsetsDirectional additionalPadding) {
+ float offAxisFraction = 0.5 * textDirectionFactor; //0.5f ;
+ float secondPickerWidth = widget.mode == CupertinoTimerPickerMode.ms
+ ? CupertinoDatePickerUtils._kPickerWidth / 10
+ : CupertinoDatePickerUtils._kPickerWidth / 6;
+
+ return new CupertinoPicker(
+ scrollController: new FixedExtentScrollController(
+ initialItem: (int)(selectedSecond / widget.secondInterval)
+ ),
+ offAxisFraction: offAxisFraction,
+ itemExtent: CupertinoDatePickerUtils._kItemExtent,
+ backgroundColor: widget.backgroundColor,
+ squeeze: CupertinoDatePickerUtils._kSqueeze,
+ looping: true,
+ onSelectedItemChanged: (int index) => {
+ setState(() => {
+ selectedSecond = index * widget.secondInterval;
+ widget.onTimerDurationChanged(
+ Duration(
+ hours: selectedHour ?? 0,
+ minutes: selectedMinute,
+ seconds: selectedSecond));
+ });
+ },
+ children: List.generate((int)(60 / widget.secondInterval), (int index) => {
+ int second = index * widget.secondInterval;
+
+ string semanticsLabel = textDirectionFactor == 1
+ ? localizations.timerPickerSecond(second) + localizations.timerPickerSecondLabel(second)
+ : localizations.timerPickerSecondLabel(second) + localizations.timerPickerSecond(second);
+
+ return Semantics(
+ label: semanticsLabel,
+ excludeSemantics: true,
+ child: _buildPickerNumberLabel(localizations.timerPickerSecond(second), additionalPadding),
+ );
+ }),
+ );
+
+ }
+
+ Widget _buildSecondColumn() {
+ float secondPickerWidth = widget.mode == CupertinoTimerPickerMode.ms
+ ? CupertinoDatePickerUtils._kPickerWidth / 10
+ : CupertinoDatePickerUtils._kPickerWidth / 6;
+ Widget secondLabel = new IgnorePointer(
+ child: new Container(
+ alignment: alignCenterLeft,
+ padding: EdgeInsets.only(left: secondPickerWidth),
+ child: new Container(
+ alignment: alignCenterLeft,
+ padding: EdgeInsets.symmetric(horizontal: 2.0f),
+ child: _buildLabel(localizations.timerPickerSecondLabel(selectedSecond))
+ )
+ )
+ );
+ return new Stack(
+ children: new List {
+ _buildSecondPicker(),
+ secondLabel
+ }
+ );
+ }
+
+ public override Widget build(BuildContext context) {
+ Widget picker;
+ if (widget.mode == CupertinoTimerPickerMode.hm) {
+ picker = new Row(
+ children: new List {
+ new Expanded(child: _buildHourColumn()),
+ new Expanded(child: _buildMinuteColumn()),
+ }
+ );
+ }
+ else if (widget.mode == CupertinoTimerPickerMode.ms) {
+ picker = new Row(
+ children: new List {
+ new Expanded(child: _buildMinuteColumn()),
+ new Expanded(child: _buildSecondColumn()),
+ }
+ );
+ }
+ else {
+ picker = new Row(
+ children: new List {
+ new Expanded(child: _buildHourColumn()),
+ new Container(
+ width: CupertinoDatePickerUtils._kPickerWidth / 3,
+ child: _buildMinuteColumn()
+ ),
+ new Expanded(child: _buildSecondColumn()),
+ }
+ );
+ }
+
+ return new MediaQuery(
+ data: new MediaQueryData(
+ textScaleFactor: 1.0f
+ ),
+ child: picker
+ );
+ }
+ }
+}*/
\ No newline at end of file
diff --git a/com.unity.uiwidgets/Runtime/cupertino/dialog.cs b/com.unity.uiwidgets/Runtime/cupertino/dialog.cs
index 9f733f66..c63dc1a7 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/dialog.cs
+++ b/com.unity.uiwidgets/Runtime/cupertino/dialog.cs
@@ -14,19 +14,20 @@ using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.cupertino {
class CupertinoDialogUtils {
public static readonly TextStyle _kCupertinoDialogTitleStyle = new TextStyle(
+ inherit:false,
fontFamily: ".SF UI Display",
fontSize: 18.0f,
fontWeight: FontWeight.w600,
- color: CupertinoColors.black,
letterSpacing: 0.48f,
textBaseline: TextBaseline.alphabetic
);
public static readonly TextStyle _kCupertinoDialogContentStyle = new TextStyle(
fontFamily: ".SF UI Text",
+ inherit:false,
fontSize: 13.4f,
fontWeight: FontWeight.w400,
- color: CupertinoColors.black,
+ //color: CupertinoColors.black,
height: 1.036f,
letterSpacing: -0.25f,
textBaseline: TextBaseline.alphabetic
@@ -34,6 +35,7 @@ namespace Unity.UIWidgets.cupertino {
public static readonly TextStyle _kCupertinoDialogActionStyle = new TextStyle(
fontFamily: ".SF UI Text",
+ inherit:false,
fontSize: 16.8f,
fontWeight: FontWeight.w400,
color: CupertinoColors.activeBlue,
@@ -56,10 +58,19 @@ namespace Unity.UIWidgets.cupertino {
public const float _kDividerThickness = 1.0f;
public const float _kMaxRegularTextScaleFactor = 1.4f;
- public static readonly Color _kDialogColor = new Color(0xC0FFFFFF);
- public static readonly Color _kDialogPressedColor = new Color(0x90FFFFFF);
+ //public static readonly Color _kDialogColor = new Color(0xC0FFFFFF);
+ //public static readonly Color _kDialogPressedColor = new Color(0x90FFFFFF);
public static readonly Color _kButtonDividerColor = new Color(0x40FFFFFF);
+ public static readonly Color _kDialogColor = CupertinoDynamicColor.withBrightness(
+ color: new Color(0xCCF2F2F2),
+ darkColor: new Color(0xBF1E1E1E)
+ );
+ public static readonly Color _kDialogPressedColor = CupertinoDynamicColor.withBrightness(
+ color: new Color(0xFFE1E1E1),
+ darkColor: new Color(0xFF2E2E2E)
+ );
+
public static bool _isInAccessibilityMode(BuildContext context) {
MediaQueryData data = MediaQuery.of(context, nullOk: true);
return data != null && data.textScaleFactor > _kMaxRegularTextScaleFactor;
@@ -300,7 +311,7 @@ namespace Unity.UIWidgets.cupertino {
_AlertDialogSections.actionsSection);
}
- protected override void forgetChild(Element child) {
+ public override void forgetChild(Element child) {
D.assert(child == _contentElement || child == _actionsElement);
if (_contentElement == child) {
_contentElement = null;
diff --git a/com.unity.uiwidgets/Runtime/cupertino/icon_theme_data.cs b/com.unity.uiwidgets/Runtime/cupertino/icon_theme_data.cs
new file mode 100644
index 00000000..5db41e2e
--- /dev/null
+++ b/com.unity.uiwidgets/Runtime/cupertino/icon_theme_data.cs
@@ -0,0 +1,45 @@
+using System.Runtime.CompilerServices;
+using Unity.UIWidgets.foundation;
+using Unity.UIWidgets.service;
+using Unity.UIWidgets.ui;
+using Unity.UIWidgets.widgets;
+using Brightness = Unity.UIWidgets.ui.Brightness;
+
+namespace Unity.UIWidgets.cupertino {
+ class CupertinoIconThemeData : IconThemeData {
+
+ public CupertinoIconThemeData(
+ Color color = null,
+ float? opacity = null,
+ float? size = null
+ ) : base(color: color, opacity: opacity, size: size) {
+
+ }
+
+ public new IconThemeData resolve(BuildContext context) {
+ Color resolvedColor = CupertinoDynamicColor.resolve(color, context);
+ return resolvedColor == color ? this : copyWith(color: resolvedColor);
+ }
+ public new CupertinoIconThemeData copyWith(Color color = null , float? opacity = null, float? size = null)
+ {
+ return new CupertinoIconThemeData(
+ color: color ?? this.color,
+ opacity: opacity ?? this.opacity,
+ size: size ?? this.size
+ );
+ }
+
+
+ public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
+ base.debugFillProperties(properties);
+ properties.add(CupertinoDynamicColor.createCupertinoColorProperty("color", color, defaultValue: null));
+ }
+ }
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/com.unity.uiwidgets/Runtime/cupertino/icon_theme_data.cs.meta b/com.unity.uiwidgets/Runtime/cupertino/icon_theme_data.cs.meta
new file mode 100644
index 00000000..e4fbdbdc
--- /dev/null
+++ b/com.unity.uiwidgets/Runtime/cupertino/icon_theme_data.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 696a8c3b3fd073847bc390f64a2b112f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.uiwidgets/Runtime/cupertino/interface_level.cs b/com.unity.uiwidgets/Runtime/cupertino/interface_level.cs
new file mode 100644
index 00000000..26673e83
--- /dev/null
+++ b/com.unity.uiwidgets/Runtime/cupertino/interface_level.cs
@@ -0,0 +1,65 @@
+using Unity.UIWidgets.foundation;
+using Unity.UIWidgets.widgets;
+using System;
+using System.Collections.Generic;
+
+namespace Unity.UIWidgets.cupertino {
+ public enum CupertinoUserInterfaceLevelData {
+ baselayer,
+ elevatedlayer,
+
+ }
+ public class CupertinoUserInterfaceLevel : InheritedWidget {
+
+ public CupertinoUserInterfaceLevel(
+ Key key = null,
+ CupertinoUserInterfaceLevelData data = default,
+ Widget child = null
+ ) : base(key: key, child: child)
+ {
+ D.assert(data != null);
+ _data = data;
+ }
+ public CupertinoUserInterfaceLevelData _data;
+
+ public static CupertinoUserInterfaceLevelData? of(BuildContext context, bool nullOk = false ) {
+ D.assert(context != null);
+ D.assert(nullOk != null);
+ CupertinoUserInterfaceLevel query = context.dependOnInheritedWidgetOfExactType(null);
+ if (query != null)
+ return query._data;
+ //if (nullOk)
+ // return ;
+ throw new UIWidgetsError(
+ "CupertinoUserInterfaceLevel.of() called with a context that does not contain a CupertinoUserInterfaceLevel.\n" +
+ "No CupertinoUserInterfaceLevel ancestor could be found starting from the context that was passed "+
+ "to CupertinoUserInterfaceLevel.of(). This can happen because you do not have a WidgetsApp or "+
+ "MaterialApp widget (those widgets introduce a CupertinoUserInterfaceLevel), or it can happen "+
+ "if the context you use comes from a widget above those widgets.\n"+
+ "The context used was:\n"+
+ context.ToString()
+ );
+ }
+
+ public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
+ base.debugFillProperties(properties);
+ properties.add(new EnumProperty("user interface level", _data));
+ }
+
+ public override bool updateShouldNotify(InheritedWidget oldWidget) {
+ //throw new System.NotImplementedException();
+ //oldWidget._data != _data;
+ /// ?????
+ if (oldWidget.GetType() == typeof(CupertinoUserInterfaceLevel)) {
+ return updateShouldNotify(oldWidget);
+ }
+
+ return false;
+ }
+ public bool updateShouldNotify(CupertinoUserInterfaceLevel oldWidget) => oldWidget._data != _data;
+
+ }
+
+}
+
+
\ No newline at end of file
diff --git a/com.unity.uiwidgets/Runtime/cupertino/interface_level.cs.meta b/com.unity.uiwidgets/Runtime/cupertino/interface_level.cs.meta
new file mode 100644
index 00000000..1afb1751
--- /dev/null
+++ b/com.unity.uiwidgets/Runtime/cupertino/interface_level.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 28fded021801d9047ab539e8b57eda6e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/com.unity.uiwidgets/Runtime/cupertino/localization.cs b/com.unity.uiwidgets/Runtime/cupertino/localization.cs
index 37f5072f..125775fb 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/localization.cs
+++ b/com.unity.uiwidgets/Runtime/cupertino/localization.cs
@@ -79,10 +79,7 @@ namespace Unity.UIWidgets.cupertino {
return locale.languageCode == "en";
}
- /* public override Future loadT(Locale locale) {
- return DefaultCupertinoLocalizations.load(locale);
- }*/
- //public override Future<> load(Locale locale) {
+
public override Future load(Locale locale) {
return DefaultCupertinoLocalizations.load(locale).to();
}
diff --git a/com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs b/com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs
index b0bc66f9..4b43519a 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs
+++ b/com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs
@@ -222,7 +222,7 @@ namespace Unity.UIWidgets.cupertino {
}
}
- public class CupertinoNavigationBar : StatefulWidget {
+ public class CupertinoNavigationBar : ObstructingPreferredSizeWidget {
public CupertinoNavigationBar(
Key key = null,
Widget leading = null,
@@ -238,10 +238,6 @@ namespace Unity.UIWidgets.cupertino {
bool transitionBetweenRoutes = true,
object heroTag = null
) : base(key: key) {
- //D.assert(automaticallyImplyLeading != null);
- //D.assert(automaticallyImplyMiddle != null);
- //D.assert(transitionBetweenRoutes != null);
-
this.leading = leading;
this.automaticallyImplyLeading = automaticallyImplyLeading;
this.automaticallyImplyMiddle = automaticallyImplyMiddle;
@@ -254,17 +250,18 @@ namespace Unity.UIWidgets.cupertino {
this.actionsForegroundColor = actionsForegroundColor;
this.transitionBetweenRoutes = transitionBetweenRoutes;
this.heroTag = heroTag ?? NavBarUtils._defaultHeroTag;
+
D.assert(
this.heroTag != null,
() => "heroTag cannot be null. Use transitionBetweenRoutes = false to " +
"disable Hero transition on this navigation bar."
);
+
D.assert(
!transitionBetweenRoutes || ReferenceEquals(this.heroTag, NavBarUtils._defaultHeroTag),
() => "Cannot specify a heroTag override if this navigation bar does not " +
"transition due to transitionBetweenRoutes = false."
);
-
}
public readonly Widget leading;
@@ -292,13 +289,11 @@ namespace Unity.UIWidgets.cupertino {
public readonly object heroTag;
- //public override bool? fullObstruction {
- public bool? fullObstruction {
+ public override bool? fullObstruction {
get { return backgroundColor == null ? null : (bool?) (backgroundColor.alpha == 0xFF); }
}
- //public override Size preferredSize {
- public Size preferredSize {
+ public override Size preferredSize {
get { return Size.fromHeight(NavBarUtils._kNavBarPersistentHeight); }
}
@@ -1709,9 +1704,10 @@ namespace Unity.UIWidgets.cupertino {
}
RenderAnimatedOpacity topBackLabelOpacity =
- (RenderAnimatedOpacity) topComponents.backLabelKey.currentContext?.ancestorRenderObjectOfType(
+ (RenderAnimatedOpacity) topComponents.backLabelKey.currentContext?.findAncestorRenderObjectOfType();
+ /*ancestorRenderObjectOfType(
new TypeMatcher()
- );
+ );*/
Animation midClickOpacity = null;
if (topBackLabelOpacity != null && topBackLabelOpacity.opacity.value < 1.0f) {
diff --git a/com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs b/com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs
index c6c2089b..e8b067cb 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs
+++ b/com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs
@@ -12,21 +12,18 @@ namespace Unity.UIWidgets.cupertino {
public CupertinoPageScaffold(
Widget child,
Key key = null,
- //ObstructingPreferredSizeWidget navigationBar = null,
- CupertinoNavigationBar navigationBar = null,
+ ObstructingPreferredSizeWidget navigationBar = null,
Color backgroundColor = null,
bool resizeToAvoidBottomInset = true
) : base(key: key) {
D.assert(child != null);
-
this.child = child;
this.navigationBar = navigationBar;
this.backgroundColor = backgroundColor;
this.resizeToAvoidBottomInset = resizeToAvoidBottomInset;
}
- //public readonly ObstructingPreferredSizeWidget navigationBar;
- public readonly CupertinoNavigationBar navigationBar;
+ public readonly ObstructingPreferredSizeWidget navigationBar;
public readonly Widget child;
public readonly Color backgroundColor;
public readonly bool resizeToAvoidBottomInset;
@@ -122,7 +119,6 @@ namespace Unity.UIWidgets.cupertino {
right: 0.0f,
height: existingMediaQuery.padding.top,
child: new GestureDetector(
- //excludeFromSemantics: true,
onTap: _handleStatusBarTap
)
)
@@ -141,10 +137,8 @@ namespace Unity.UIWidgets.cupertino {
public abstract class ObstructingPreferredSizeWidget : PreferredSizeWidget {
- protected ObstructingPreferredSizeWidget(Key key = null) : base(key: key) {}
- //public virtual Size preferredSize { get; }
- public virtual bool? fullObstruction { get; }
+ ///protected ObstructingPreferredSizeWidget(Key key = null) : base(key: key) {}
+ // public virtual bool? fullObstruction { get; }
+ public abstract bool shouldFullyObstruct(BuildContext context);
}
-
-
}
\ No newline at end of file
diff --git a/com.unity.uiwidgets/Runtime/cupertino/route.cs b/com.unity.uiwidgets/Runtime/cupertino/route.cs
index b3ed5c48..33630be1 100644
--- a/com.unity.uiwidgets/Runtime/cupertino/route.cs
+++ b/com.unity.uiwidgets/Runtime/cupertino/route.cs
@@ -70,7 +70,7 @@ namespace Unity.UIWidgets.cupertino {
)
);
}
-
+
public static readonly Animatable _dialogScaleTween = new FloatTween(begin: 1.3f, end: 1.0f)
.chain(new CurveTween(curve: Curves.linearToEaseOut));
@@ -98,12 +98,12 @@ namespace Unity.UIWidgets.cupertino {
);
}
- public static Future