比较提交

...
此合并请求有变更与目标分支冲突。
/com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
/com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs
/com.unity.uiwidgets/Runtime/widgets/ticker_provider.cs
/com.unity.uiwidgets/Runtime/widgets/binding.cs
/com.unity.uiwidgets/Runtime/widgets/single_child_scroll_view.cs
/Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample
/Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample
/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery
/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery
/Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery
/com.unity.uiwidgets/Runtime/cupertino
/com.unity.uiwidgets/Runtime/cupertino
/com.unity.uiwidgets/Runtime/cupertino
/com.unity.uiwidgets/Runtime/cupertino
/com.unity.uiwidgets/Runtime/cupertino
/com.unity.uiwidgets/Runtime/cupertino
/com.unity.uiwidgets/Runtime/cupertino
/com.unity.uiwidgets/Runtime/cupertino
/com.unity.uiwidgets/Runtime/cupertino
/com.unity.uiwidgets/Runtime/cupertino
/com.unity.uiwidgets/Runtime/material
/com.unity.uiwidgets/Runtime/material
/Samples/UIWidgetsSamples_2019_4/Assets/Editor
/Samples/UIWidgetsSamples_2019_4/Assets/Editor

17 次代码提交

共有 654 个文件被更改,包括 12019 次插入65 次删除
  1. 3
      com.unity.uiwidgets/Runtime/animation/animation_controller.cs
  2. 18
      com.unity.uiwidgets/Runtime/developer/extension.cs
  3. 2
      com.unity.uiwidgets/Runtime/foundation/key.cs
  4. 11
      com.unity.uiwidgets/Runtime/foundation/binding.cs
  5. 13
      com.unity.uiwidgets/Runtime/foundation/diagnostics.cs
  6. 2
      com.unity.uiwidgets/Runtime/widgets/ticker_provider.cs
  7. 4
      com.unity.uiwidgets/Runtime/widgets/single_child_scroll_view.cs
  8. 6
      com.unity.uiwidgets/Runtime/widgets/binding.cs
  9. 106
      com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs
  10. 5
      Samples/UIWidgetsSamples_2019_4/Packages/manifest.json
  11. 2
      com.unity.uiwidgets/Runtime/semantics/semantics.cs.meta
  12. 74
      com.unity.uiwidgets/Editor/testDebugger.cs
  13. 3
      com.unity.uiwidgets/Editor/testDebugger.cs.meta
  14. 8
      com.unity.uiwidgets/Runtime/Plugins.meta
  15. 8
      com.unity.uiwidgets/Runtime/cupertino.meta
  16. 8
      com.unity.uiwidgets/Runtime/redux.meta
  17. 8
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample.meta
  18. 3
      Samples/UIWidgetsSamples_2019_4/Assets/Editor.meta
  19. 11
      com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs.meta
  20. 11
      com.unity.uiwidgets/Runtime/cupertino/app.cs.meta
  21. 11
      com.unity.uiwidgets/Runtime/cupertino/button.cs.meta
  22. 11
      com.unity.uiwidgets/Runtime/cupertino/date_picker.cs.meta
  23. 11
      com.unity.uiwidgets/Runtime/cupertino/dialog.cs.meta
  24. 11
      com.unity.uiwidgets/Runtime/cupertino/icons.cs.meta
  25. 11
      com.unity.uiwidgets/Runtime/cupertino/localization.cs.meta
  26. 11
      com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs.meta
  27. 11
      com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs.meta
  28. 11
      com.unity.uiwidgets/Runtime/cupertino/picker.cs.meta
  29. 11
      com.unity.uiwidgets/Runtime/cupertino/route.cs.meta
  30. 11
      com.unity.uiwidgets/Runtime/cupertino/scrollbar.cs.meta
  31. 11
      com.unity.uiwidgets/Runtime/cupertino/slider.cs.meta
  32. 11
      com.unity.uiwidgets/Runtime/cupertino/switch.cs.meta
  33. 11
      com.unity.uiwidgets/Runtime/cupertino/tab_scaffold.cs.meta
  34. 11
      com.unity.uiwidgets/Runtime/cupertino/tab_view.cs.meta
  35. 731
      com.unity.uiwidgets/Runtime/cupertino/text_field.cs
  36. 11
      com.unity.uiwidgets/Runtime/cupertino/text_field.cs.meta
  37. 11
      com.unity.uiwidgets/Runtime/cupertino/text_selection.cs.meta
  38. 324
      com.unity.uiwidgets/Runtime/cupertino/text_theme.cs
  39. 11
      com.unity.uiwidgets/Runtime/cupertino/text_theme.cs.meta
  40. 438
      com.unity.uiwidgets/Runtime/cupertino/theme.cs
  41. 11
      com.unity.uiwidgets/Runtime/cupertino/theme.cs.meta
  42. 11
      com.unity.uiwidgets/Runtime/cupertino/thumb_painter.cs.meta
  43. 11
      com.unity.uiwidgets/Runtime/cupertino/colors.cs.meta
  44. 149
      com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs
  45. 219
      com.unity.uiwidgets/Runtime/cupertino/app.cs
  46. 770
      com.unity.uiwidgets/Runtime/cupertino/colors.cs
  47. 251
      com.unity.uiwidgets/Runtime/cupertino/button.cs
  48. 1001
      com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
  49. 250
      com.unity.uiwidgets/Runtime/cupertino/localization.cs
  50. 829
      com.unity.uiwidgets/Runtime/cupertino/route.cs
  51. 380
      com.unity.uiwidgets/Runtime/cupertino/scrollbar.cs
  52. 468
      com.unity.uiwidgets/Runtime/cupertino/slider.cs
  53. 448
      com.unity.uiwidgets/Runtime/cupertino/switch.cs
  54. 690
      com.unity.uiwidgets/Runtime/material/colors.cs
  55. 11
      com.unity.uiwidgets/Runtime/material/colors.cs.meta
  56. 28
      com.unity.uiwidgets/Runtime/material/constants.cs
  57. 91
      com.unity.uiwidgets/Runtime/material/debug.cs
  58. 827
      com.unity.uiwidgets/Runtime/material/app_bar.cs
  59. 11
      com.unity.uiwidgets/Runtime/material/constants.cs.meta
  60. 264
      com.unity.uiwidgets/Runtime/material/app.cs
  61. 946
      com.unity.uiwidgets/Runtime/material/slider.cs
  62. 1001
      com.unity.uiwidgets/Runtime/material/tabs.cs
  63. 19
      com.unity.uiwidgets/Runtime/redux/redux_logging.cs
  64. 11
      com.unity.uiwidgets/Runtime/redux/redux_logging.cs.meta
  65. 32
      com.unity.uiwidgets/Runtime/redux/redux_thunk.cs
  66. 11
      com.unity.uiwidgets/Runtime/redux/redux_thunk.cs.meta
  67. 81
      com.unity.uiwidgets/Runtime/redux/store.cs
  68. 11
      com.unity.uiwidgets/Runtime/redux/store.cs.meta
  69. 172
      com.unity.uiwidgets/Runtime/redux/widget_redux.cs
  70. 11
      com.unity.uiwidgets/Runtime/redux/widget_redux.cs.meta
  71. 11
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs.meta
  72. 11
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs.meta
  73. 11
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs.meta
  74. 11
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs.meta
  75. 11
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs.meta
  76. 11
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs.meta
  77. 11
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs.meta
  78. 11
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs.meta
  79. 47
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/BottomAppBarSample.cs
  80. 107
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/DividerAndButton.cs
  81. 204
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialAppBarSample.cs
  82. 73
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs
  83. 56
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs
  84. 86
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs
  85. 61
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs
  86. 130
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs
  87. 82
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs
  88. 79
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs
  89. 53
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs
  90. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery.meta
  91. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/UIWidgetsGallery.asmdef

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


public override float value {
get { return _value; }
float _value;
public float _value;
public void setValue(float newValue) {
stop();

18
com.unity.uiwidgets/Runtime/developer/extension.cs


using System.Collections;
using System.Collections.Generic;
using Unity.UIWidgets.async;
}
static Dictionary<string, DeveloperExtensionFunc> extensions = new Dictionary<string, DeveloperExtensionFunc>();
public delegate Future<IDictionary<string, object>> DeveloperExtensionFunc(string method, IDictionary<string, string> parameters);
public static void registerExtension(string methodName, DeveloperExtensionFunc func) {
extensions[methodName] = func;
}
public static Future<IDictionary<string, object>> callExtension(string method,
IDictionary<string, string> parameters) {
if (extensions.ContainsKey(method)) {
return extensions[method].Invoke(method, parameters);
}
return null;
}
}
}

2
com.unity.uiwidgets/Runtime/foundation/key.cs


#pragma warning disable 0660
#pragma warning disable 0661
public abstract class Key {
protected Key() {
public Key() {
}
public static Key key(string value) {

11
com.unity.uiwidgets/Runtime/foundation/binding.cs


protected virtual void initServiceExtensions() {
}
protected void registerServiceExtension(string name, ServiceExtensionCallback callback) {
D.assert(name != null);
D.assert(callback != null);
string methodName = name;
developer_.registerExtension(methodName, (method, parameters) => {
var result = callback.Invoke(parameters);
return result;
});
}
protected bool locked => _lockCount > 0;
int _lockCount = 0;

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


public static string describeEnum(object enumEntry) {
string description = enumEntry.ToString();
int indexOfDot = description.IndexOf(".");
D.assert(indexOfDot != -1 && indexOfDot < description.Length - 1);
return description.Substring(indexOfDot + 1);
return description;
}
}

result["allowNameWrap"] = allowNameWrap;
}
Delegate.additionalNodeProperties(this);
var additional = Delegate.additionalNodeProperties(this);
foreach (var key in additional.Keys) {
result[key] = additional[key];
}
if (Delegate.includeProperties) {
result["properties"] = toJsonList(
Delegate.filterProperties(getProperties(), this),

int subtreeDepth = 0,
bool includeProperties = false
) {
new _DefaultDiagnosticsSerializationDelegate(includeProperties, subtreeDepth);
this.subtreeDepth = subtreeDepth;
this.includeProperties = includeProperties;
}
public abstract Dictionary<string, object> additionalNodeProperties(DiagnosticsNode node);

2
com.unity.uiwidgets/Runtime/widgets/ticker_provider.cs


// in AutomaticKeepAliveClientWithTickerProviderStateMixin, remember to keep the copy up to date
public abstract class TickerProviderStateMixin<T> : State<T>, TickerProvider where T : StatefulWidget {
HashSet<Ticker> _tickers;
public Ticker createTicker(TickerCallback onTick) {
_tickers = _tickers ?? new HashSet<Ticker>();

4
com.unity.uiwidgets/Runtime/widgets/single_child_scroll_view.cs


public class SingleChildScrollView : StatelessWidget {
public SingleChildScrollView(
Key key = null,
Axis scrollDirection = Axis.vertical,
Axis? scrollDirection = null,
bool reverse = false,
EdgeInsetsGeometry padding = null,
bool? primary = null,

() =>
"Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
"You cannot both set primary to true and pass an explicit controller.");
this.scrollDirection = scrollDirection;
this.scrollDirection = scrollDirection?? Axis.vertical;
this.reverse = reverse;
this.padding = padding;
this.primary = primary ?? controller == null && scrollDirection == Axis.vertical;

6
com.unity.uiwidgets/Runtime/widgets/binding.cs


set { RendererBinding.instance = value; }
}
protected override void initServiceExtensions() {
base.initServiceExtensions();
WidgetInspectorService.instance.initServiceExtensions(registerServiceExtension);
}
protected override void initInstances() {
base.initInstances();
instance = this;

106
com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs


using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.external;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;

using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Debug = System.Diagnostics.Debug;
using Rect = Unity.UIWidgets.ui.Rect;
using TextStyle = Unity.UIWidgets.painting.TextStyle;

public class WidgetInspectorService {
public readonly List<string> _serializeRing = new List<string>(20);
int _serializeRingIndex = 0;
public readonly WidgetsBinding widgetsBinding;
bool _debugShowInspector;
public DeveloperInspect developerInspect;
public InspectorShowCallback inspectorShowCallback;
get { //return WidgetsBinding.instance.widgetInspectorService;
get {
return _instance;
}
set {

static WidgetInspectorService _instance = new WidgetInspectorService();
static bool _debugServiceExtensionsRegistered = false;
int _nextId = 0;
int _nextId = 0;
List<string> _pubRootDirectories;
bool _trackRebuildDirtyWidgets = false;

}
public void _registerSignalServiceExtension(
string name = null,
CallBack callback = null // callback()
CallBack callback = null
) {
registerServiceExtension(
name: name,

registerServiceExtension(
name: name,
callback: (IDictionary<string, string> parameters) => {
var result = Future.value(FutureOr.value((new Dictionary<string, object>{{"result", callback(parameters["objectGroup"])}}))).to<IDictionary<string, object>>();
return result;
using (Isolate.getScope(UIWidgetsPanel.anyIsolate)) {
var result = Future.value(FutureOr.value((new Dictionary<string, object>
{{"result", callback(parameters["objectGroup"])}}))).to<IDictionary<string, object>>();
return result;
}
}
);
}

}
);
}*/
/*void _registerServiceExtensionWithArg(
void _registerServiceExtensionWithArg(
callback: (Dictionary<string, string> parameters) =>{
callback: (IDictionary<string, string> parameters) =>{
D.assert(parameters.ContainsKey("arg"));
return new Dictionary<string, object> {
{"result", callback(parameters["arg"], parameters["objectGroup"])}
};
using (Isolate.getScope(UIWidgetsPanel.anyIsolate)) {
var result = Future.value(FutureOr.value((new Dictionary<string, object>
{{"result", callback(parameters["arg"], parameters["objectGroup"])}}))).to<IDictionary<string, object>>();
return result;
}
}*/
}
/*void _registerServiceExtensionVarArgs(

_errorsSinceReload = 0;
}
/*void initServiceExtensions(_RegisterServiceExtensionCallback registerServiceExtensionCallback) {
public void initServiceExtensions(_RegisterServiceExtensionCallback registerServiceExtensionCallback) {
D.assert(!_debugServiceExtensionsRegistered);
D.assert(()=> {
//D.assert(!_debugServiceExtensionsRegistered);
/*D.assert(()=> {
});
});*/
SchedulerBinding.instance.addPersistentFrameCallback(_onFrameStart);
//SchedulerBinding.instance.addPersistentFrameCallback(_onFrameStart);
FlutterExceptionHandler structuredExceptionHandler = _reportError;
FlutterExceptionHandler defaultExceptionHandler = FlutterError.onError;
//FlutterExceptionHandler structuredExceptionHandler = _reportError;
//FlutterExceptionHandler defaultExceptionHandler = FlutterError.onError;
_registerBoolServiceExtension(
/*_registerBoolServiceExtension(
name: "structuredErrors",
getter: () => FlutterError.onError == structuredExceptionHandler,
setter: (bool value)=> {

);
);*/
_registerBoolServiceExtension(
/*_registerBoolServiceExtension(
name: "show",
getter: () => WidgetsApp.debugShowWidgetInspectorOverride,
setter: (bool value)=> {

WidgetsApp.debugShowWidgetInspectorOverride = value;
return forceRebuild();
}
);
if (isWidgetCreationTracked()) {
);*/
/*if (isWidgetCreationTracked()) {
_registerBoolServiceExtension(
name: "trackRebuildDirtyWidgets",
getter: () => _trackRebuildDirtyWidgets,

}
}
);
}
_registerSignalServiceExtension(
}*/
/*_registerSignalServiceExtension(
name: "disposeAllGroups",
callback: disposeAllGroups
);

_registerServiceExtensionWithArg(
name: "setSelectionById",
callback: setSelectionById
);
);*/
_registerServiceExtensionWithArg(
name: "getParentChain",
callback: _getParentChain

);
registerServiceExtension(
name: "getDetailsSubtree",
callback: (Dictionary<string, string> parameters) => {
callback: (IDictionary<string, string> parameters) => {
return new Dictionary<string, object>{{
"result", _getDetailsSubtree(
parameters["arg"],
parameters["objectGroup"],
subtreeDepth != null ? int.Parse(subtreeDepth) : 2
)
}};
using (Isolate.getScope(UIWidgetsPanel.anyIsolate)) {
var result = Future.value(FutureOr.value((new Dictionary<string, object>
{{"result", _getDetailsSubtree(
parameters["arg"],
parameters["objectGroup"],
subtreeDepth != null ? int.Parse(subtreeDepth) : 2
)}}))).to<IDictionary<string, object>>();
return result;
}
_registerServiceExtensionWithArg(
/*_registerServiceExtensionWithArg(
name: "getSelectedRenderObject",
callback: _getSelectedRenderObject
);

};
}
);
}*/
);*/
}
/*void _clearStats() {
_rebuildStats.resetCounts();

return _safeJsonEncode(_getRootWidget(groupName));
}
public Dictionary<string, object> _getRootWidget(string groupName) {
return _nodeToJson(WidgetsBinding.instance?.renderViewElement?.toDiagnosticsNode(), new InspectorSerializationDelegate(groupName: groupName, service: this));
var node = WidgetsBinding.instance?.renderViewElement?.toDiagnosticsNode();
var del = new InspectorSerializationDelegate(groupName: groupName, service: this);
return _nodeToJson(node , del);
}
string getRootWidgetSummaryTree(string groupName) {

_inspectAt(_lastPointerLocation);
if (selection != null) {
if (WidgetInspectorService.instance.developerInspect != null) {
WidgetInspectorService.instance.developerInspect();
}
//if (WidgetInspectorService.instance.developerInspect != null) {
// WidgetInspectorService.instance.developerInspect();
//}
}
}

5
Samples/UIWidgetsSamples_2019_4/Packages/manifest.json


"com.unity.collab-proxy": "1.2.16",
"com.unity.ide.rider": "1.1.4",
"com.unity.ide.vscode": "1.2.1",
"com.unity.uiwidgets": "file:../../../com.unity.uiwidgets",
"com.unity.test-framework": "1.1.14",
"com.unity.test-framework": "1.1.16",
"com.unity.uiwidgets": "file:../../../com.unity.uiwidgets",
"com.unity.uiwidgets.devtools": "file:../../../com.unity.uiwidgets.devtools",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",

2
com.unity.uiwidgets/Runtime/semantics/semantics.cs.meta


fileFormatVersion: 2
guid: 2f6601e4d6a788a458d2f9e1d06fa1ea
guid: 5b2b6b1be992fe64887b60d5c32c5508
MonoImporter:
externalObjects: {}
serializedVersion: 2

74
com.unity.uiwidgets/Editor/testDebugger.cs


using System;
using System.Collections.Generic;
using System.Text;
using developer;
using UnityEditor;
using UnityEngine;
namespace Unity.UIWidgets.Editor {
public class testDebugger : EditorWindow{
[MenuItem("Window/TestInspector")]
static void Init() {
var myWindow = (testDebugger) EditorWindow.GetWindow(typeof(testDebugger));
myWindow.Show();
; }
static void ShowJsonMap(IDictionary<string, object> jsonMap) {
StringBuilder sb = new StringBuilder();
foreach (var key in jsonMap.Keys) {
if (key == "result" && jsonMap[key] is Dictionary<string ,object>) {
var resultMap = jsonMap[key] as Dictionary<string, object>;
foreach (var ckey in resultMap.Keys) {
sb.Append($"result.{ckey} : {resultMap[ckey] ?? "Null"}\n");
}
}
sb.Append($"{key} : {jsonMap[key] ?? "Null"}\n");
}
Debug.Log(sb.ToString());
}
void OnGUI() {
if (GUILayout.Button("getRootWidget")) {
var result = developer_.callExtension("inspector.getRootWidget", new Dictionary<string, string> {
{"objectGroup", "root"}
});
result.then(o => {
var res = (IDictionary<string, object>) o;
ShowJsonMap(res);
});
}
if (GUILayout.Button("getRootRenderObject")) {
var result = developer_.callExtension("inspector.getRootRenderObject", new Dictionary<string, string> {
{"objectGroup", "root"}
});
result.then(o => {
var res = (IDictionary<string, object>) o;
ShowJsonMap(res);
});
}
if (GUILayout.Button("getRootWidgetSummaryTree")) {
var result = developer_.callExtension("inspector.getRootWidgetSummaryTree", new Dictionary<string, string> {
{"objectGroup", "root"}
});
result.then(o => {
var res = (IDictionary<string, object>) o;
ShowJsonMap(res);
});
}
if (GUILayout.Button("getChildren")) {
var result = developer_.callExtension("inspector.getChildren", new Dictionary<string, string> {
{"objectGroup", "root"},
{"arg", "inspector-0"}
});
result.then(o => {
var res = (IDictionary<string, object>) o;
ShowJsonMap(res);
});
}
}
}
}

3
com.unity.uiwidgets/Editor/testDebugger.cs.meta


fileFormatVersion: 2
guid: 21834a4aede04baa875605d4c82d7bd5
timeCreated: 1625239357

8
com.unity.uiwidgets/Runtime/Plugins.meta


fileFormatVersion: 2
guid: 13f5f7be9f33d144d89d2195786677c7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.uiwidgets/Runtime/cupertino.meta


fileFormatVersion: 2
guid: 5c3d34af75804254da0566129e0d4ac0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.uiwidgets/Runtime/redux.meta


fileFormatVersion: 2
guid: a074d5db1a47743f19fc0f9ac709e173
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample.meta


fileFormatVersion: 2
guid: c0f377c78881e9243879a01b93524d63
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
Samples/UIWidgetsSamples_2019_4/Assets/Editor.meta


fileFormatVersion: 2
guid: fbf4348f25a14fb7a48fd287e0d01b88
timeCreated: 1614220178

11
com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs.meta


fileFormatVersion: 2
guid: ed3ef7a3308cfad4e968eb19fe99ba4b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/app.cs.meta


fileFormatVersion: 2
guid: eaa69370ca020aa4ca9cfeff075ab39c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/button.cs.meta


fileFormatVersion: 2
guid: 629437eb94ae5aa4bbe7bcf510b6a7cc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/date_picker.cs.meta


fileFormatVersion: 2
guid: 0afde46bc85349a49bb887e7ef46e8d9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/dialog.cs.meta


fileFormatVersion: 2
guid: ce028dee29b7b90409ab91e330e762e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/icons.cs.meta


fileFormatVersion: 2
guid: ed8c228d2f54415419ded075a9b16c89
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/localization.cs.meta


fileFormatVersion: 2
guid: 30e111327cb1ec2428eed691dcaee742
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs.meta


fileFormatVersion: 2
guid: 4fb1c214b61524a48b988f4e193ad97b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs.meta


fileFormatVersion: 2
guid: 0e428c069ad6abb4e80e0a3483f6fe57
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/picker.cs.meta


fileFormatVersion: 2
guid: bf0858feee06e8c46bf820fe90a17071
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/route.cs.meta


fileFormatVersion: 2
guid: 699b3c09353fafc40b33fd5c0470048f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/scrollbar.cs.meta


fileFormatVersion: 2
guid: 55b1201340c47f94b91591a011603a8a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/slider.cs.meta


fileFormatVersion: 2
guid: c692b7c8464330e48a01d99464265341
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/switch.cs.meta


fileFormatVersion: 2
guid: 6216d964b6d93c34cb861fd15181b25b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/tab_scaffold.cs.meta


fileFormatVersion: 2
guid: 2cd55505780bfb04d86fe98f2c80b359
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/tab_view.cs.meta


fileFormatVersion: 2
guid: b95af00e8d4e2be499f76f5448914453
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

731
com.unity.uiwidgets/Runtime/cupertino/text_field.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using StrutStyle = Unity.UIWidgets.painting.StrutStyle;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using Brightness = Unity.UIWidgets.ui.Brightness;
using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.cupertino {
class CupertinoTextFieldUtils {
public static readonly BorderSide _kDefaultRoundedBorderSide = new BorderSide(
color: CupertinoDynamicColor.withBrightness(
color: new Color(0x33000000),
darkColor: new Color(0x33FFFFFF)
),
style: BorderStyle.solid,
width: 0.0f
);
public static readonly Border _kDefaultRoundedBorder = new Border(
top: _kDefaultRoundedBorderSide,
bottom: _kDefaultRoundedBorderSide,
left: _kDefaultRoundedBorderSide,
right: _kDefaultRoundedBorderSide
);
public static readonly BoxDecoration _kDefaultRoundedBorderDecoration = new BoxDecoration(
color: CupertinoDynamicColor.withBrightness(
color: CupertinoColors.white,
darkColor: CupertinoColors.black
),
border: _kDefaultRoundedBorder,
borderRadius: BorderRadius.all(Radius.circular(5.0f))
);
public static readonly Color _kDisabledBackground = CupertinoDynamicColor.withBrightness(
color: new Color(0xFFFAFAFA),
darkColor: new Color(0xFF050505)
);
public static readonly CupertinoDynamicColor _kClearButtonColor = CupertinoDynamicColor.withBrightness(
color: new Color(0xFF636366),
darkColor: new Color(0xFFAEAEB2)
);
public const int _iOSHorizontalCursorOffsetPixels = -2;
public static TextSelectionControls cupertinoTextSelectionControls = new _CupertinoTextSelectionControls();
}
public enum OverlayVisibilityMode {
never,
editing,
notEditing,
always
}
public class _CupertinoTextFieldSelectionGestureDetectorBuilder : TextSelectionGestureDetectorBuilder {
public _CupertinoTextFieldSelectionGestureDetectorBuilder(
_CupertinoTextFieldState state = null) : base(_delegate: state) {
_state = state;
}
public readonly _CupertinoTextFieldState _state;
protected override void onSingleTapUp(TapUpDetails details) {
if (_state._clearGlobalKey.currentContext != null) {
RenderBox renderBox = _state._clearGlobalKey.currentContext.findRenderObject() as RenderBox;
Offset localOffset = renderBox.globalToLocal(details.globalPosition);
if (renderBox.hitTest(new BoxHitTestResult(), position: localOffset)) {
return;
}
}
base.onSingleTapUp(details);
_state._requestKeyboard();
if (_state.widget.onTap != null)
_state.widget.onTap();
}
protected override void onDragSelectionEnd(DragEndDetails details) {
//(DragStartDetails details)
_state._requestKeyboard();
}
}
public class CupertinoTextField : StatefulWidget {
public CupertinoTextField(
Key key = null,
TextEditingController controller = null,
FocusNode focusNode = null,
BoxDecoration decoration = null,
EdgeInsets padding = null,
string placeholder = null,
TextStyle placeholderStyle = null,
Widget prefix = null,
OverlayVisibilityMode prefixMode = OverlayVisibilityMode.always,
Widget suffix = null,
OverlayVisibilityMode suffixMode = OverlayVisibilityMode.always,
OverlayVisibilityMode clearButtonMode = OverlayVisibilityMode.never,
TextInputType keyboardType = null,
TextInputAction? textInputAction = null,
TextCapitalization textCapitalization = TextCapitalization.none,
TextStyle style = null,
StrutStyle strutStyle = null,
TextAlign textAlign = TextAlign.left,
TextAlignVertical textAlignVertical = null,
bool readOnly = false,
ToolbarOptions toolbarOptions = null,
bool? showCursor = null,
bool autofocus = false,
bool obscureText = false,
bool autocorrect = true,
SmartDashesType? smartDashesType = null,
SmartQuotesType? smartQuotesType = null,
bool enableSuggestions = true,
int? maxLines = 1,
int? minLines = null,
bool expands = false,
int? maxLength = null,
bool maxLengthEnforced = true,
ValueChanged<string> onChanged = null,
VoidCallback onEditingComplete = null,
ValueChanged<string> onSubmitted = null,
List<TextInputFormatter> inputFormatters = null,
bool? enabled = null,
float cursorWidth = 2.0f,
Radius cursorRadius = null,
Color cursorColor = null,
ui.BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
ui.BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
Brightness? keyboardAppearance = null,
EdgeInsets scrollPadding = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
bool enableInteractiveSelection = true,
GestureTapCallback onTap = null,
ScrollController scrollController = null,
ScrollPhysics scrollPhysics = null
) : base(key: key) {
this.smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled);
this.smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled);
D.assert(maxLines == null || maxLines > 0);
D.assert(minLines == null || minLines > 0);
D.assert(maxLines == null || minLines == null || maxLines >= minLines,
() => "minLines can't be greater than maxLines");
D.assert(!expands || (maxLines == null && minLines == null),
() => "minLines and maxLines must be null when expands is true.");
D.assert(maxLength == null || maxLength > 0);
this.controller = controller;
this.focusNode = focusNode;
this.decoration = decoration ?? CupertinoTextFieldUtils._kDefaultRoundedBorderDecoration;
this.padding = padding ?? EdgeInsets.all(6.0f);
this.placeholder = placeholder;
this.placeholderStyle = placeholderStyle ?? new TextStyle(
fontWeight: FontWeight.w400,
color: CupertinoColors.placeholderText
);
this.prefix = prefix;
this.prefixMode = prefixMode;
this.suffix = suffix;
this.suffixMode = suffixMode;
this.clearButtonMode = clearButtonMode;
this.textInputAction = textInputAction;
this.textCapitalization = textCapitalization;
this.style = style;
this.strutStyle = strutStyle;
this.textAlign = textAlign;
this.textAlignVertical = textAlignVertical;
this.readOnly = readOnly;
this.showCursor = showCursor;
this.autofocus = autofocus;
this.obscureText = obscureText;
this.autocorrect = autocorrect;
this.enableSuggestions = enableSuggestions;
this.maxLines = maxLines;
this.minLines = minLines;
this.expands = expands;
this.maxLength = maxLength;
this.maxLengthEnforced = maxLengthEnforced;
this.onChanged = onChanged;
this.onEditingComplete = onEditingComplete;
this.onSubmitted = onSubmitted;
this.inputFormatters = inputFormatters;
this.enabled = enabled;
this.cursorWidth = cursorWidth;
this.cursorRadius = cursorRadius ?? Radius.circular(2.0f);
this.cursorColor = cursorColor;
this.selectionHeightStyle = selectionHeightStyle;
this.selectionWidthStyle = selectionWidthStyle;
this.keyboardAppearance = keyboardAppearance;
this.scrollPadding = scrollPadding ?? EdgeInsets.all(20.0f);
this.dragStartBehavior = dragStartBehavior ;
this.enableInteractiveSelection = enableInteractiveSelection;
this.scrollPhysics = scrollPhysics;
this.onTap = onTap;
this.scrollController = scrollController;
this.keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline);
this.toolbarOptions = toolbarOptions ?? (obscureText
? new ToolbarOptions(
selectAll: true,
paste: true
)
: new ToolbarOptions(
copy: true,
cut: true,
selectAll: true,
paste: true
));
}
public readonly TextEditingController controller;
public readonly FocusNode focusNode;
public readonly ToolbarOptions toolbarOptions;
public readonly BoxDecoration decoration;
public readonly EdgeInsetsGeometry padding;
public readonly string placeholder;
public readonly TextStyle placeholderStyle;
public readonly Widget prefix;
public readonly OverlayVisibilityMode prefixMode;
public readonly Widget suffix;
public readonly OverlayVisibilityMode suffixMode;
public readonly OverlayVisibilityMode clearButtonMode;
public readonly TextInputType keyboardType;
public readonly TextInputAction? textInputAction;
public readonly TextCapitalization textCapitalization;
public readonly TextStyle style;
public readonly StrutStyle strutStyle;
public readonly TextAlign textAlign;
public readonly bool autofocus;
public readonly bool obscureText;
public readonly bool autocorrect;
public readonly int? maxLines;
public readonly int? minLines;
public readonly bool expands;
public readonly int? maxLength;
public readonly bool maxLengthEnforced;
public readonly ValueChanged<string> onChanged;
public readonly VoidCallback onEditingComplete;
public readonly ValueChanged<string> onSubmitted;
public readonly List<TextInputFormatter> inputFormatters;
public readonly bool? enabled;
public readonly float cursorWidth;
public readonly Radius cursorRadius;
public readonly Color cursorColor;
public readonly Brightness? keyboardAppearance;
public readonly EdgeInsets scrollPadding;
public readonly DragStartBehavior dragStartBehavior;
public readonly ScrollPhysics scrollPhysics;
public readonly ui.BoxHeightStyle selectionHeightStyle;
public readonly ui.BoxWidthStyle selectionWidthStyle;
public readonly TextAlignVertical textAlignVertical;
public readonly bool readOnly;
public readonly bool enableInteractiveSelection;
public readonly bool? showCursor;
public readonly bool enableSuggestions;
public readonly GestureTapCallback onTap;
public readonly ScrollController scrollController;
public readonly SmartDashesType smartDashesType;
public readonly SmartQuotesType smartQuotesType;
public bool selectionEnabled {
get {
return enableInteractiveSelection;
}
}
public override State createState() {
return new _CupertinoTextFieldState();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add( new DiagnosticsProperty<TextEditingController>("controller", controller, defaultValue: null));
properties.add( new DiagnosticsProperty<FocusNode>("focusNode", focusNode, defaultValue: null));
properties.add( new DiagnosticsProperty<BoxDecoration>("decoration", decoration));
properties.add( new DiagnosticsProperty<EdgeInsetsGeometry>("padding", padding));
properties.add( new StringProperty("placeholder", placeholder));
properties.add( new DiagnosticsProperty<TextStyle>("placeholderStyle", placeholderStyle));
properties.add( new DiagnosticsProperty<OverlayVisibilityMode>("prefix", prefix == null ? default(OverlayVisibilityMode) : prefixMode));
properties.add( new DiagnosticsProperty<OverlayVisibilityMode>("suffix", suffix == null ? default(OverlayVisibilityMode) : suffixMode));
properties.add( new DiagnosticsProperty<OverlayVisibilityMode>("clearButtonMode", clearButtonMode));
properties.add( new DiagnosticsProperty<TextInputType>("keyboardType", keyboardType, defaultValue: TextInputType.text));
properties.add( new DiagnosticsProperty<TextStyle>("style", style, defaultValue: null));
properties.add( new DiagnosticsProperty<bool>("autofocus", autofocus, defaultValue: false));
properties.add( new DiagnosticsProperty<bool>("obscureText", obscureText, defaultValue: false));
properties.add( new DiagnosticsProperty<bool>("autocorrect", autocorrect, defaultValue: true));
properties.add( new EnumProperty<SmartDashesType>("smartDashesType", smartDashesType, defaultValue: obscureText ? SmartDashesType.disabled : SmartDashesType.enabled));
properties.add( new EnumProperty<SmartQuotesType>("smartQuotesType", smartQuotesType, defaultValue: obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled));
properties.add( new DiagnosticsProperty<bool>("enableSuggestions", enableSuggestions, defaultValue: true));
properties.add( new IntProperty("maxLines", maxLines, defaultValue: 1));
properties.add( new IntProperty("minLines", minLines, defaultValue: null));
properties.add( new DiagnosticsProperty<bool>("expands", expands, defaultValue: false));
properties.add( new IntProperty("maxLength", maxLength, defaultValue: null));
properties.add( new FlagProperty("maxLengthEnforced", value: maxLengthEnforced, ifTrue: "max length enforced"));
// properties.add( new createCupertinoColorProperty("cursorColor", cursorColor, defaultValue: null));
properties.add( new FlagProperty("selectionEnabled", value: selectionEnabled, defaultValue: true, ifFalse: "selection disabled"));
properties.add( new DiagnosticsProperty<ScrollController>("scrollController", scrollController, defaultValue: null));
properties.add( new DiagnosticsProperty<ScrollPhysics>("scrollPhysics", scrollPhysics, defaultValue: null));
properties.add( new EnumProperty<TextAlign>("textAlign", textAlign, defaultValue: TextAlign.start));
properties.add( new DiagnosticsProperty<TextAlignVertical>("textAlignVertical", textAlignVertical, defaultValue: null));
}
}
public class _CupertinoTextFieldState : AutomaticKeepAliveClientMixin<CupertinoTextField>, TextSelectionGestureDetectorBuilderDelegate{
public GlobalKey _clearGlobalKey = GlobalKey.key();
TextEditingController _controller;
TextEditingController _effectiveController {
get { return widget.controller ?? _controller; }
}
FocusNode _focusNode;
FocusNode _effectiveFocusNode {
get { return widget.focusNode ?? _focusNode ?? (_focusNode = new FocusNode()); }
}
bool _showSelectionHandles = false;
_CupertinoTextFieldSelectionGestureDetectorBuilder _selectionGestureDetectorBuilder;
public GlobalKey<EditableTextState> editableTextKey {
get {
return _editableTextKey;
}
}
public readonly GlobalKey<EditableTextState> _editableTextKey = GlobalKey<EditableTextState>.key();
public bool forcePressEnabled {
get { return true; }
}
public bool selectionEnabled {
get { return widget.selectionEnabled;}
}
public override void initState() {
base.initState();
_selectionGestureDetectorBuilder = new _CupertinoTextFieldSelectionGestureDetectorBuilder(state: this);
if (widget.controller == null) {
_controller = new TextEditingController();
_controller.addListener(updateKeepAlive);
}
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
oldWidget = (CupertinoTextField) oldWidget;
base.didUpdateWidget(oldWidget);
if (widget.controller == null && ((CupertinoTextField)oldWidget).controller != null) {
_controller = TextEditingController.fromValue(((CupertinoTextField)oldWidget).controller.value);
_controller.addListener(updateKeepAlive);
} else if (widget.controller != null &&((CupertinoTextField)oldWidget).controller == null) {
_controller = null;
}
bool isEnabled = widget.enabled ?? true;
bool wasEnabled = ((CupertinoTextField)oldWidget).enabled ?? true;
if (wasEnabled && !isEnabled) {
_effectiveFocusNode.unfocus();
}
}
public override void dispose() {
_focusNode?.dispose();
_controller?.removeListener(updateKeepAlive);
base.dispose();
}
public EditableTextState _editableText {
get {
return editableTextKey.currentState;
}
}
public void _requestKeyboard() {
_editableText?.requestKeyboard();
}
bool _shouldShowSelectionHandles(SelectionChangedCause cause) {
// When the text field is activated by something that doesn't trigger the
// selection overlay, we shouldn't show the handles either.
if (!_selectionGestureDetectorBuilder.shouldShowSelectionToolbar)
return false;
// On iOS, we don't show handles when the selection is collapsed.
if (_effectiveController.selection.isCollapsed)
return false;
if (cause == SelectionChangedCause.keyboard)
return false;
if (_effectiveController.text.isNotEmpty())
return true;
return false;
}
void _handleSelectionChanged(TextSelection selection, SelectionChangedCause cause) {
if (cause == SelectionChangedCause.longPress) {
_editableText?.bringIntoView(selection._base);
}
bool willShowSelectionHandles = _shouldShowSelectionHandles(cause);
if (willShowSelectionHandles != _showSelectionHandles) {
setState(()=> {
_showSelectionHandles = willShowSelectionHandles;
});
}
}
protected override bool wantKeepAlive {
get {
return _controller?.text?.isNotEmpty() == true;
}
}
bool _shouldShowAttachment(
OverlayVisibilityMode attachment,
bool hasText
) {
switch (attachment) {
case OverlayVisibilityMode.never:
return false;
case OverlayVisibilityMode.always:
return true;
case OverlayVisibilityMode.editing:
return hasText;
case OverlayVisibilityMode.notEditing:
return !hasText;
}
D.assert(false);
return false;
}
bool _showPrefixWidget(TextEditingValue text) {
return widget.prefix != null && _shouldShowAttachment(
attachment: widget.prefixMode,
hasText: text.text.isNotEmpty()
);
}
bool _showSuffixWidget(TextEditingValue text) {
return widget.suffix != null && _shouldShowAttachment(
attachment: widget.suffixMode,
hasText: text.text.isNotEmpty()
);
}
bool _showClearButton(TextEditingValue text) {
return _shouldShowAttachment(
attachment: widget.clearButtonMode,
hasText: text.text.isNotEmpty()
);
}
// True if any surrounding decoration widgets will be shown.
bool _hasDecoration {
get {
return widget.placeholder != null ||
widget.clearButtonMode != OverlayVisibilityMode.never ||
widget.prefix != null ||
widget.suffix != null;
}
}
TextAlignVertical _textAlignVertical {
get {
if (widget.textAlignVertical != null) {
return widget.textAlignVertical;
}
return _hasDecoration ? TextAlignVertical.center : TextAlignVertical.top;
}
}
Widget _addTextDependentAttachments(Widget editableText, TextStyle textStyle, TextStyle placeholderStyle) {
D.assert(editableText != null);
D.assert(textStyle != null);
D.assert(placeholderStyle != null);
if (widget.placeholder == null &&
widget.clearButtonMode == OverlayVisibilityMode.never &&
widget.prefix == null &&
widget.suffix == null) {
return editableText;
}
return new ValueListenableBuilder<TextEditingValue>(
valueListenable: _effectiveController,
child: editableText,
builder: (BuildContext context, TextEditingValue text, Widget child) => {
List<Widget> rowChildren = new List<Widget>();
if (_showPrefixWidget(text)) {
rowChildren.Add(widget.prefix);
}
List<Widget> stackChildren = new List<Widget>();
if (widget.placeholder != null && text.text.isEmpty()) {
stackChildren.Add(
new SizedBox(
width : float.PositiveInfinity,
child: new Padding(
padding: widget.padding,
child: new Text(
widget.placeholder,
maxLines: widget.maxLines,
overflow: TextOverflow.ellipsis,
style: placeholderStyle,
textAlign: widget.textAlign
)
)
)
);
}
stackChildren.Add(child);
rowChildren.Add(
new Expanded
(child: new Stack
(children: stackChildren)));
if (_showSuffixWidget(text)) {
rowChildren.Add(widget.suffix);
}
else if (_showClearButton(text)) {
rowChildren.Add(
new GestureDetector(
onTap: widget.enabled ?? true
? () => {
bool textChanged = _effectiveController.text.isNotEmpty();
_effectiveController.clear();
if (widget.onChanged != null && textChanged) {
widget.onChanged(_effectiveController.text);
}
}
: (GestureTapCallback) null,
child: new Padding(
padding: EdgeInsets.symmetric(horizontal: 6.0f),
child: new Icon(
CupertinoIcons.clear_thick_circled,
size: 18.0f,
color: CupertinoDynamicColor.resolve(CupertinoTextFieldUtils._kClearButtonColor, context)
)
)
)
);
}
return new Row(children: rowChildren);
}
);
}
public override Widget build(BuildContext context) {
base.build(context);
D.assert(WidgetsD.debugCheckHasDirectionality(context));
TextEditingController controller = _effectiveController;
List<TextInputFormatter> formatters = widget.inputFormatters ?? new List<TextInputFormatter>();
bool enabled = widget.enabled ?? true;
Offset cursorOffset =
new Offset(
CupertinoTextFieldUtils._iOSHorizontalCursorOffsetPixels / MediaQuery.of(context).devicePixelRatio,
0);
if (widget.maxLength != null && widget.maxLengthEnforced) {
formatters.Add(new LengthLimitingTextInputFormatter(widget.maxLength));
}
CupertinoThemeData themeData = CupertinoTheme.of(context);
TextStyle resolvedStyle = widget.style?.copyWith(
color: CupertinoDynamicColor.resolve(widget.style?.color, context),
backgroundColor: CupertinoDynamicColor.resolve(widget.style?.backgroundColor, context)
);
TextStyle textStyle = themeData.textTheme.textStyle.merge(resolvedStyle);
TextStyle resolvedPlaceholderStyle = widget.placeholderStyle?.copyWith(
color: CupertinoDynamicColor.resolve(widget.placeholderStyle?.color, context),
backgroundColor: CupertinoDynamicColor.resolve(widget.placeholderStyle?.backgroundColor, context)
);
TextStyle placeholderStyle = textStyle.merge(resolvedPlaceholderStyle);
Brightness? keyboardAppearance = widget.keyboardAppearance ?? CupertinoTheme.brightnessOf(context);
Color cursorColor = CupertinoDynamicColor.resolve(widget.cursorColor, context) ?? themeData.primaryColor;
Color disabledColor = CupertinoDynamicColor.resolve(CupertinoTextFieldUtils._kDisabledBackground, context);
Color decorationColor = CupertinoDynamicColor.resolve(widget.decoration?.color, context);
BoxBorder border = widget.decoration?.border;
Border resolvedBorder = border as Border;
if (border is Border) {
BorderSide resolveBorderSide(BorderSide side) {
return side == BorderSide.none
? side
: side.copyWith(color: CupertinoDynamicColor.resolve(side.color, context));
}
resolvedBorder = (Border) (border == null || border.GetType() != typeof(Border)
? border
: new Border(
top: resolveBorderSide(((Border)border).top),
left: resolveBorderSide(((Border)border).left),
bottom: resolveBorderSide(((Border)border).bottom),
right: resolveBorderSide(((Border)border).right)
));
}
BoxDecoration effectiveDecoration = widget.decoration?.copyWith(
border: resolvedBorder,
color: enabled ? decorationColor : (decorationColor == null ? disabledColor : decorationColor)
);
Widget paddedEditable = new Padding(
padding: widget.padding,
child: new RepaintBoundary(
child: new EditableText(
key: editableTextKey,
controller: controller,
readOnly: widget.readOnly,
toolbarOptions: widget.toolbarOptions,
showCursor: widget.showCursor,
showSelectionHandles: _showSelectionHandles,
focusNode: _effectiveFocusNode,
keyboardType: widget.keyboardType,
textInputAction: widget.textInputAction,
textCapitalization: widget.textCapitalization,
style: textStyle,
strutStyle: widget.strutStyle,
textAlign: widget.textAlign,
autofocus: widget.autofocus,
obscureText: widget.obscureText,
autocorrect: widget.autocorrect,
smartDashesType: widget.smartDashesType,
smartQuotesType: widget.smartQuotesType,
enableSuggestions: widget.enableSuggestions,
maxLines: widget.maxLines,
minLines: widget.minLines,
expands: widget.expands,
selectionColor: CupertinoTheme.of(context).primaryColor.withOpacity(0.2f),
selectionControls: widget.selectionEnabled
? CupertinoTextFieldUtils.cupertinoTextSelectionControls : null,
onChanged: widget.onChanged,
onSelectionChanged: _handleSelectionChanged,
onEditingComplete: widget.onEditingComplete,
onSubmitted: widget.onSubmitted,
inputFormatters: formatters,
rendererIgnoresPointer: true,
cursorWidth: widget.cursorWidth,
cursorRadius: widget.cursorRadius,
cursorColor: cursorColor,
cursorOpacityAnimates: true,
cursorOffset: cursorOffset,
paintCursorAboveText: true,
backgroundCursorColor: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context),
selectionHeightStyle: widget.selectionHeightStyle,
selectionWidthStyle: widget.selectionWidthStyle,
scrollPadding: widget.scrollPadding,
keyboardAppearance: keyboardAppearance,
dragStartBehavior: widget.dragStartBehavior,
scrollController: widget.scrollController,
scrollPhysics: widget.scrollPhysics,
enableInteractiveSelection: widget.enableInteractiveSelection
)
)
);
return new IgnorePointer(
ignoring: !enabled,
child: new Container(
decoration: effectiveDecoration,
child: _selectionGestureDetectorBuilder.buildGestureDetector(
behavior: HitTestBehavior.translucent,
child: new Align(
alignment: new Alignment(-1.0f, _textAlignVertical.y),
widthFactor: 1.0f,
heightFactor: 1.0f,
child: _addTextDependentAttachments(paddedEditable, textStyle, placeholderStyle)
)
)
)
);
}
}
}

11
com.unity.uiwidgets/Runtime/cupertino/text_field.cs.meta


fileFormatVersion: 2
guid: 7d2dd8bd369e9e044a2480212136f639
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/text_selection.cs.meta


fileFormatVersion: 2
guid: 8f420271876af9a49b7c8e1faa3dff17
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

324
com.unity.uiwidgets/Runtime/cupertino/text_theme.cs


using Unity.UIWidgets.foundation;
//using Unity.UIWidgets.material;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Brightness = Unity.UIWidgets.ui.Brightness;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.cupertino {
static class CupertinoTextThemeDataUtils {
public static readonly TextStyle _kDefaultTextStyle = new TextStyle(
inherit: false,
fontFamily: ".SF Pro Text",
fontSize: 17.0f,
letterSpacing: -0.41f,
color: CupertinoColors.label,
decoration: TextDecoration.none
);
public static readonly TextStyle _kDefaultActionTextStyle = new TextStyle(
inherit: false,
fontFamily: ".SF Pro Text",
fontSize: 17.0f,
letterSpacing: -0.41f,
color: CupertinoColors.activeBlue,
decoration: TextDecoration.none
);
public static readonly TextStyle _kDefaultTabLabelTextStyle = new TextStyle(
inherit: false,
fontFamily: ".SF Pro Text",
fontSize: 10.0f,
letterSpacing: -0.24f,
color: CupertinoColors.inactiveGray
);
public static readonly TextStyle _kDefaultMiddleTitleTextStyle = new TextStyle(
inherit: false,
fontFamily: ".SF Pro Text",
fontSize: 17.0f,
fontWeight: FontWeight.w600,
letterSpacing: -0.41f,
color: CupertinoColors.label
);
public static readonly TextStyle _kDefaultLargeTitleTextStyle = new TextStyle(
inherit: false,
fontFamily: ".SF Pro Display",
fontSize: 34.0f,
fontWeight: FontWeight.w700,
letterSpacing: 0.41f,
color: CupertinoColors.label
);
public static readonly TextStyle _kDefaultPickerTextStyle = new TextStyle(
inherit: false,
fontFamily: ".SF Pro Display",
fontSize: 21.0f,
fontWeight: FontWeight.w400,
letterSpacing: -0.41f,
color: CupertinoColors.label
);
public static readonly TextStyle _kDefaultDateTimePickerTextStyle = new TextStyle(
inherit: false,
fontFamily: ".SF Pro Display",
fontSize: 21.0f,
fontWeight: FontWeight.normal,
color: CupertinoColors.label
);
public static TextStyle _resolveTextStyle(TextStyle style, BuildContext context, bool nullOk) {
return style?.copyWith(
color: CupertinoDynamicColor.resolve(style?.color, context, nullOk: nullOk),
backgroundColor: CupertinoDynamicColor.resolve(style?.backgroundColor, context, nullOk: nullOk),
decorationColor: CupertinoDynamicColor.resolve(style?.decorationColor, context, nullOk: nullOk)
);
}
}
public class CupertinoTextThemeData : Diagnosticable {
public CupertinoTextThemeData(
_TextThemeDefaultsBuilder defaults = null,
Color primaryColor = null,
TextStyle textStyle = null,
TextStyle actionTextStyle = null,
TextStyle tabLabelTextStyle = null,
TextStyle navTitleTextStyle = null,
TextStyle navLargeTitleTextStyle = null,
TextStyle navActionTextStyle = null,
TextStyle pickerTextStyle = null,
TextStyle dateTimePickerTextStyle = null
) {
_defaults = defaults ?? new _TextThemeDefaultsBuilder(CupertinoColors.label, CupertinoColors.inactiveGray);
_primaryColor = primaryColor ?? CupertinoColors.systemBlue;
D.assert((_navActionTextStyle != null && _actionTextStyle != null) || _primaryColor != null);
_textStyle = textStyle;
_actionTextStyle = actionTextStyle;
_tabLabelTextStyle = tabLabelTextStyle;
_navTitleTextStyle = navTitleTextStyle;
_navLargeTitleTextStyle = navLargeTitleTextStyle;
_navActionTextStyle = navActionTextStyle;
_pickerTextStyle = pickerTextStyle;
_dateTimePickerTextStyle = dateTimePickerTextStyle;
}
public static CupertinoTextThemeData _raw(
_TextThemeDefaultsBuilder _defaults,
Color primaryColor,
TextStyle textStyle,
TextStyle actionTextStyle ,
TextStyle tabLabelTextStyle ,
TextStyle navTitleTextStyle ,
TextStyle navLargeTitleTextStyle ,
TextStyle navActionTextStyle ,
TextStyle pickerTextStyle,
TextStyle dateTimePickerTextStyle
) {
var textThemeData = new CupertinoTextThemeData(
_defaults,
primaryColor,
textStyle,
actionTextStyle,
tabLabelTextStyle,
navTitleTextStyle,
navLargeTitleTextStyle,
navActionTextStyle,
pickerTextStyle,
dateTimePickerTextStyle
);
return textThemeData;
}
public _TextThemeDefaultsBuilder _defaults;
readonly Color _primaryColor;
readonly Brightness? _brightness;
readonly TextStyle _textStyle;
public virtual TextStyle textStyle {
get {
return _textStyle ?? _defaults.textStyle;
}
}
readonly TextStyle _actionTextStyle;
public virtual TextStyle actionTextStyle {
get {
return _actionTextStyle ?? _defaults.actionTextStyle(primaryColor: _primaryColor);
}
}
readonly TextStyle _tabLabelTextStyle;
public virtual TextStyle tabLabelTextStyle {
get { return _tabLabelTextStyle ?? _defaults.tabLabelTextStyle;}
}
readonly TextStyle _navTitleTextStyle;
public virtual TextStyle navTitleTextStyle {
get {
return _navTitleTextStyle ?? _defaults.navTitleTextStyle;
}
}
readonly TextStyle _navLargeTitleTextStyle;
/// Typography of large titles in sliver navigation bars.
public virtual TextStyle navLargeTitleTextStyle {
get {
return _navLargeTitleTextStyle ?? _defaults.navLargeTitleTextStyle;
}
}
readonly TextStyle _navActionTextStyle;
public virtual TextStyle navActionTextStyle {
get {
return _navActionTextStyle ?? _defaults.navActionTextStyle(primaryColor: _primaryColor);
}
}
readonly TextStyle _pickerTextStyle;
public virtual TextStyle pickerTextStyle {
get {
return _pickerTextStyle ?? _defaults.pickerTextStyle;
}
}
readonly TextStyle _dateTimePickerTextStyle;
public virtual TextStyle dateTimePickerTextStyle {
get {
return _dateTimePickerTextStyle ?? _defaults.dateTimePickerTextStyle;
}
}
public CupertinoTextThemeData resolveFrom(BuildContext context, bool nullOk = false ) {
return new CupertinoTextThemeData(
_defaults?.resolveFrom(context, nullOk),
CupertinoDynamicColor.resolve(_primaryColor, context, nullOk: nullOk),
CupertinoTextThemeDataUtils._resolveTextStyle(_textStyle, context, nullOk),
CupertinoTextThemeDataUtils._resolveTextStyle(_actionTextStyle, context, nullOk),
CupertinoTextThemeDataUtils._resolveTextStyle(_tabLabelTextStyle, context, nullOk),
CupertinoTextThemeDataUtils._resolveTextStyle(_navTitleTextStyle, context, nullOk),
CupertinoTextThemeDataUtils._resolveTextStyle(_navLargeTitleTextStyle, context, nullOk),
CupertinoTextThemeDataUtils._resolveTextStyle(_navActionTextStyle, context, nullOk),
CupertinoTextThemeDataUtils._resolveTextStyle(_pickerTextStyle, context, nullOk),
CupertinoTextThemeDataUtils._resolveTextStyle(_dateTimePickerTextStyle, context, nullOk)
);
}
public new CupertinoTextThemeData copyWith(
Color primaryColor = null,
TextStyle textStyle = null,
TextStyle actionTextStyle = null,
TextStyle tabLabelTextStyle = null,
TextStyle navTitleTextStyle = null,
TextStyle navLargeTitleTextStyle = null,
TextStyle navActionTextStyle = null,
TextStyle pickerTextStyle = null,
TextStyle dateTimePickerTextStyle = null
) {
return new CupertinoTextThemeData(
_defaults,
primaryColor: primaryColor ?? _primaryColor,
textStyle: textStyle ?? _textStyle,
actionTextStyle: actionTextStyle ?? _actionTextStyle,
tabLabelTextStyle: tabLabelTextStyle ?? _tabLabelTextStyle,
navTitleTextStyle: navTitleTextStyle ?? _navTitleTextStyle,
navLargeTitleTextStyle: navLargeTitleTextStyle ?? _navLargeTitleTextStyle,
navActionTextStyle: navActionTextStyle ?? _navActionTextStyle,
pickerTextStyle ?? _pickerTextStyle,
dateTimePickerTextStyle ?? _dateTimePickerTextStyle
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
CupertinoTextThemeData defaultData = new CupertinoTextThemeData();
properties.add(new DiagnosticsProperty<TextStyle>("textStyle", textStyle, defaultValue: defaultData.textStyle));
properties.add(new DiagnosticsProperty<TextStyle>("actionTextStyle", actionTextStyle, defaultValue: defaultData.actionTextStyle));
properties.add(new DiagnosticsProperty<TextStyle>("tabLabelTextStyle", tabLabelTextStyle, defaultValue: defaultData.tabLabelTextStyle));
properties.add(new DiagnosticsProperty<TextStyle>("navTitleTextStyle", navTitleTextStyle, defaultValue: defaultData.navTitleTextStyle));
properties.add(new DiagnosticsProperty<TextStyle>("navLargeTitleTextStyle", navLargeTitleTextStyle, defaultValue: defaultData.navLargeTitleTextStyle));
properties.add(new DiagnosticsProperty<TextStyle>("navActionTextStyle", navActionTextStyle, defaultValue: defaultData.navActionTextStyle));
properties.add(new DiagnosticsProperty<TextStyle>("pickerTextStyle", pickerTextStyle, defaultValue: defaultData.pickerTextStyle));
properties.add(new DiagnosticsProperty<TextStyle>("dateTimePickerTextStyle", dateTimePickerTextStyle, defaultValue: defaultData.dateTimePickerTextStyle));
}
}
public class _TextThemeDefaultsBuilder {
public _TextThemeDefaultsBuilder(
Color labelColor = null,
Color inactiveGrayColor = null
) {
this.labelColor = labelColor;
this.inactiveGrayColor = inactiveGrayColor;
D.assert(labelColor != null);
D.assert(inactiveGrayColor != null);
}
public readonly Color labelColor;
public readonly Color inactiveGrayColor;
public static TextStyle _applyLabelColor(TextStyle original, Color color) {
return original?.color == color
? original
: original?.copyWith(color: color);
}
public TextStyle textStyle {
get {
return _applyLabelColor(CupertinoTextThemeDataUtils._kDefaultTextStyle, labelColor);
}
}
public TextStyle tabLabelTextStyle
{
get {
return _applyLabelColor(CupertinoTextThemeDataUtils._kDefaultTabLabelTextStyle, inactiveGrayColor);
}
}
public TextStyle navTitleTextStyle {
get {
return _applyLabelColor(CupertinoTextThemeDataUtils._kDefaultMiddleTitleTextStyle, labelColor);
}
}
public TextStyle navLargeTitleTextStyle {
get {
return _applyLabelColor(CupertinoTextThemeDataUtils._kDefaultLargeTitleTextStyle, labelColor);
}
}
public TextStyle pickerTextStyle {
get {
return _applyLabelColor(CupertinoTextThemeDataUtils._kDefaultPickerTextStyle, labelColor);
}
}
public TextStyle dateTimePickerTextStyle {
get {
return _applyLabelColor(CupertinoTextThemeDataUtils._kDefaultDateTimePickerTextStyle, labelColor);
}
}
public TextStyle actionTextStyle( Color primaryColor = null) => CupertinoTextThemeDataUtils._kDefaultActionTextStyle.copyWith(color: primaryColor);
public TextStyle navActionTextStyle( Color primaryColor = null) => actionTextStyle(primaryColor: primaryColor);
public _TextThemeDefaultsBuilder resolveFrom(BuildContext context, bool nullOk) {
Color resolvedLabelColor = CupertinoDynamicColor.resolve(labelColor, context, nullOk: nullOk);
Color resolvedInactiveGray = CupertinoDynamicColor.resolve(inactiveGrayColor, context, nullOk: nullOk);
return resolvedLabelColor == labelColor && resolvedInactiveGray == CupertinoColors.inactiveGray
? this
: new _TextThemeDefaultsBuilder(resolvedLabelColor, resolvedInactiveGray);
}
}
}

11
com.unity.uiwidgets/Runtime/cupertino/text_theme.cs.meta


fileFormatVersion: 2
guid: c7d45005fd9f6034c8dabd6d98cab122
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

438
com.unity.uiwidgets/Runtime/cupertino/theme.cs


using System.Runtime.CompilerServices;
using Unity.UIWidgets.foundation;
//using Unity.UIWidgets.material;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Brightness = Unity.UIWidgets.ui.Brightness;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.cupertino {
class CupertinoThemeDataUtils {
public static readonly _CupertinoThemeDefaults _kDefaultTheme =
new _CupertinoThemeDefaults(
null,
CupertinoColors.systemBlue,
CupertinoColors.systemBackground,
CupertinoDynamicColor.withBrightness(
color: new Color(0xF0F9F9F9),
darkColor: new Color(0xF01D1D1D)
// Values extracted from navigation bar. For toolbar or tabbar the dark color is 0xF0161616.
),
CupertinoColors.systemBackground,
new _CupertinoTextThemeDefaults(CupertinoColors.label, CupertinoColors.inactiveGray)
);
}
public class CupertinoTheme : StatelessWidget {
public CupertinoTheme(
Key key = null,
CupertinoThemeData data = null,
Widget child = null
) : base(key: key) {
D.assert(child != null);
D.assert(data != null);
this.data = data;
this.child = child;
}
public readonly CupertinoThemeData data;
public readonly Widget child;
public static CupertinoThemeData of(BuildContext context) {
_InheritedCupertinoTheme inheritedTheme = context.dependOnInheritedWidgetOfExactType<_InheritedCupertinoTheme>();
var result = (inheritedTheme?.theme?.data ?? new CupertinoThemeData()).resolveFrom(context, nullOk: true);
return result;
}
public static Brightness? brightnessOf(BuildContext context, bool nullOk = false) {
_InheritedCupertinoTheme inheritedTheme = context.dependOnInheritedWidgetOfExactType<_InheritedCupertinoTheme>();
return (inheritedTheme?.theme?.data?.brightness) ?? MediaQuery.of(context, nullOk: nullOk)?.platformBrightness;
}
public override Widget build(BuildContext context) {
return new _InheritedCupertinoTheme(
theme: this,
child: new IconTheme(
data: new CupertinoIconThemeData(color: data.primaryColor),
child: child
)
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
data.debugFillProperties(properties);
}
}
class _InheritedCupertinoTheme : InheritedWidget {
public _InheritedCupertinoTheme(
Key key = null,
CupertinoTheme theme = null,
Widget child = null
) : base(key: key, child: child) {
D.assert(theme != null);
this.theme = theme;
}
public readonly CupertinoTheme theme;
public override bool updateShouldNotify(InheritedWidget old) {
return theme.data != ((_InheritedCupertinoTheme) old).theme.data;
}
}
public class CupertinoThemeData : Diagnosticable {
public CupertinoThemeData(
Brightness? brightness = null,
Color primaryColor = null,
Color primaryContrastingColor = null,
CupertinoTextThemeData textTheme = null,
Color barBackgroundColor = null,
Color scaffoldBackgroundColor = null,
_CupertinoThemeDefaults defaults = null
) {
this.brightness = brightness;// ?? Brightness.light;
_primaryColor = primaryColor;
_primaryContrastingColor = primaryContrastingColor;
_textTheme = textTheme;
_barBackgroundColor = barBackgroundColor;
_scaffoldBackgroundColor = scaffoldBackgroundColor;
_defaults = defaults ?? CupertinoThemeDataUtils._kDefaultTheme;
}
public static CupertinoThemeData _rawWithDefaults(
Brightness? brightness,
Color primaryColor,
Color primaryContrastingColor ,
CupertinoTextThemeData textTheme ,
Color barBackgroundColor ,
Color scaffoldBackgroundColor ,
_CupertinoThemeDefaults defaults
) {
var themeData = new CupertinoThemeData(
brightness: brightness,
primaryColor: primaryColor,
primaryContrastingColor: primaryContrastingColor,
textTheme: textTheme,
barBackgroundColor: barBackgroundColor,
scaffoldBackgroundColor: scaffoldBackgroundColor,
defaults);
return themeData;
}
public _CupertinoThemeDefaults _defaults;
public readonly Brightness? brightness;
public Color primaryColor {
get {
return _primaryColor ?? _defaults.primaryColor;
}
}
readonly Color _primaryColor;
public Color primaryContrastingColor {
get {
return _primaryContrastingColor ?? _defaults.primaryContrastingColor;
}
}
readonly Color _primaryContrastingColor;
public CupertinoTextThemeData textTheme {
get {
return _textTheme ?? _defaults.textThemeDefaults.createDefaults(primaryColor: primaryColor);
}
}
readonly CupertinoTextThemeData _textTheme;
public Color barBackgroundColor {
get {
return _barBackgroundColor ?? _defaults.barBackgroundColor;
}
}
readonly Color _barBackgroundColor;
public Color scaffoldBackgroundColor {
get {
return _scaffoldBackgroundColor ?? _defaults.scaffoldBackgroundColor;
}
}
readonly Color _scaffoldBackgroundColor;
public CupertinoThemeData noDefault() {
return new _NoDefaultCupertinoThemeData(
brightness,
_primaryColor,
_primaryContrastingColor,
_textTheme,
_barBackgroundColor,
_scaffoldBackgroundColor
);
}
public CupertinoThemeData resolveFrom(BuildContext context, bool nullOk = false ) {
Color convertColor(Color color) => CupertinoDynamicColor.resolve(color, context, nullOk: nullOk);
return new CupertinoThemeData(
brightness:brightness,
primaryColor:convertColor(_primaryColor),
primaryContrastingColor:convertColor(_primaryContrastingColor),
textTheme:_textTheme?.resolveFrom(context, nullOk: nullOk),
barBackgroundColor:convertColor(_barBackgroundColor),
scaffoldBackgroundColor:convertColor(_scaffoldBackgroundColor),
defaults:_defaults.resolveFrom(context, _textTheme == null, nullOk: nullOk)
);
}
public CupertinoThemeData copyWith(
Brightness? brightness = null,
Color primaryColor = null,
Color primaryContrastingColor = null,
CupertinoTextThemeData textTheme = null,
Color barBackgroundColor = null,
Color scaffoldBackgroundColor = null
) {
//return new CupertinoThemeData(
return _rawWithDefaults(
brightness: brightness ?? this.brightness,
primaryColor: primaryColor ?? _primaryColor,
primaryContrastingColor: primaryContrastingColor ?? _primaryContrastingColor,
textTheme: textTheme ?? _textTheme,
barBackgroundColor: barBackgroundColor ?? _barBackgroundColor,
scaffoldBackgroundColor: scaffoldBackgroundColor ?? _scaffoldBackgroundColor,
_defaults
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
CupertinoThemeData defaultData = new CupertinoThemeData();
properties.add(
new EnumProperty<Brightness?>("brightness", brightness, defaultValue: defaultData.brightness));
properties.add(new DiagnosticsProperty<Color>("primaryColor", primaryColor,
defaultValue: defaultData.primaryColor));
properties.add(new DiagnosticsProperty<Color>("primaryContrastingColor", primaryContrastingColor,
defaultValue: defaultData.primaryContrastingColor));
properties.add(
new DiagnosticsProperty<CupertinoTextThemeData>("textTheme", textTheme,
defaultValue: defaultData.textTheme));
properties.add(new DiagnosticsProperty<Color>("barBackgroundColor", barBackgroundColor,
defaultValue: defaultData.barBackgroundColor));
properties.add(new DiagnosticsProperty<Color>("scaffoldBackgroundColor", scaffoldBackgroundColor,
defaultValue: defaultData.scaffoldBackgroundColor));
textTheme.debugFillProperties(properties);
}
}
class _NoDefaultCupertinoThemeData : CupertinoThemeData {
public _NoDefaultCupertinoThemeData(
Brightness? brightness,
Color primaryColor,
Color primaryContrastingColor,
CupertinoTextThemeData textTheme,
Color barBackgroundColor,
Color scaffoldBackgroundColor
) : base(
brightness,
primaryColor,
primaryContrastingColor,
textTheme,
barBackgroundColor,
scaffoldBackgroundColor,
null) {
this.primaryColor = primaryColor;
this.primaryContrastingColor = primaryContrastingColor;
this.textTheme = textTheme;
this.barBackgroundColor = barBackgroundColor;
this.scaffoldBackgroundColor = scaffoldBackgroundColor;
}
public new readonly Brightness? brightness;
public new readonly Color primaryColor;
public new readonly Color primaryContrastingColor;
public new readonly CupertinoTextThemeData textTheme;
public new readonly Color barBackgroundColor;
public new readonly Color scaffoldBackgroundColor;
public new _NoDefaultCupertinoThemeData resolveFrom(BuildContext context,bool nullOk = false ) {
Color convertColor(Color color) => CupertinoDynamicColor.resolve(color, context, nullOk: nullOk);
return new _NoDefaultCupertinoThemeData(
brightness,
convertColor(primaryColor),
convertColor(primaryContrastingColor),
textTheme?.resolveFrom(context, nullOk: nullOk),
convertColor(barBackgroundColor),
convertColor(scaffoldBackgroundColor)
);
}
public new CupertinoThemeData copyWith(
Brightness? brightness = null,
Color primaryColor = null,
Color primaryContrastingColor = null,
CupertinoTextThemeData textTheme = null,
Color barBackgroundColor = null,
Color scaffoldBackgroundColor = null
) {
return new _NoDefaultCupertinoThemeData(
brightness ?? this.brightness,
primaryColor ?? this.primaryColor,
primaryContrastingColor ?? this.primaryContrastingColor,
textTheme ?? this.textTheme,
barBackgroundColor ?? this.barBackgroundColor,
scaffoldBackgroundColor ?? this.scaffoldBackgroundColor
);
}
}
public class _CupertinoThemeDefaults {
public _CupertinoThemeDefaults(
Brightness? brightness ,
Color primaryColor ,
Color primaryContrastingColor ,
Color barBackgroundColor ,
Color scaffoldBackgroundColor ,
_CupertinoTextThemeDefaults textThemeDefaults
)
{
this.brightness = brightness;
this.primaryColor = primaryColor;
this.primaryContrastingColor = primaryContrastingColor;
this.barBackgroundColor = barBackgroundColor;
this.scaffoldBackgroundColor = scaffoldBackgroundColor;
this.textThemeDefaults = textThemeDefaults;
}
public Brightness? brightness;
public Color primaryColor;
public Color primaryContrastingColor;
public Color barBackgroundColor;
public Color scaffoldBackgroundColor;
public _CupertinoTextThemeDefaults textThemeDefaults;
public _CupertinoThemeDefaults resolveFrom(BuildContext context, bool resolveTextTheme, bool nullOk = false) {
D.assert(nullOk != null);
Color convertColor(Color color) => CupertinoDynamicColor.resolve(color, context, nullOk: nullOk);
return new _CupertinoThemeDefaults(
brightness:brightness,
primaryColor:convertColor(primaryColor),
primaryContrastingColor:convertColor(primaryContrastingColor),
barBackgroundColor:convertColor(barBackgroundColor),
scaffoldBackgroundColor:convertColor(scaffoldBackgroundColor),
textThemeDefaults:resolveTextTheme ? textThemeDefaults?.resolveFrom(context, nullOk: nullOk) : textThemeDefaults
);
}
}
public class _CupertinoTextThemeDefaults {
public _CupertinoTextThemeDefaults(
Color labelColor = null,
Color inactiveGray = null
) {
this.labelColor = labelColor;
this.inactiveGray = inactiveGray;
}
public readonly Color labelColor;
public readonly Color inactiveGray;
public _CupertinoTextThemeDefaults resolveFrom(BuildContext context, bool nullOk = false) {
return new _CupertinoTextThemeDefaults(
CupertinoDynamicColor.resolve(labelColor, context, nullOk: nullOk),
CupertinoDynamicColor.resolve(inactiveGray, context, nullOk: nullOk)
);
}
public CupertinoTextThemeData createDefaults(Color primaryColor ) {
D.assert(primaryColor != null);
return new _DefaultCupertinoTextThemeData(
primaryColor: primaryColor,
labelColor: labelColor,
inactiveGray: inactiveGray
);
}
}
class _DefaultCupertinoTextThemeData : CupertinoTextThemeData {
public _DefaultCupertinoTextThemeData(
Color labelColor = null,
Color inactiveGray = null,
Color primaryColor = null
) : base(primaryColor: primaryColor)
{
D.assert(labelColor != null);
D.assert(inactiveGray != null);
D.assert(primaryColor != null);
this.labelColor = labelColor;
this.inactiveGray = inactiveGray;
}
public readonly Color labelColor;
public readonly Color inactiveGray;
public override TextStyle textStyle {
get {
return base.textStyle.copyWith(color: labelColor);
}
}
public override TextStyle tabLabelTextStyle {
get {
return base.tabLabelTextStyle.copyWith(color: inactiveGray);
}
}
public override TextStyle navTitleTextStyle {
get {
return base.navTitleTextStyle.copyWith(color: labelColor);
}
}
public override TextStyle navLargeTitleTextStyle {
get {
return base.navLargeTitleTextStyle.copyWith(color: labelColor);
}
}
public override TextStyle pickerTextStyle {
get {
return base.pickerTextStyle.copyWith(color: labelColor);
}
}
public override TextStyle dateTimePickerTextStyle {
get {
return base.dateTimePickerTextStyle.copyWith(color: labelColor);
}
}
}
}

11
com.unity.uiwidgets/Runtime/cupertino/theme.cs.meta


fileFormatVersion: 2
guid: 0b560c283dac79b49a529c6917cf840c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/thumb_painter.cs.meta


fileFormatVersion: 2
guid: a3bf47fd342929d4aabe1bd72fc22eb0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
com.unity.uiwidgets/Runtime/cupertino/colors.cs.meta


fileFormatVersion: 2
guid: 78e6aef01ceaee54bbcae56c25aa6147
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

149
com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs


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;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.cupertino {
static class CupertinoActivityIndicatorUtils {
public const float _kDefaultIndicatorRadius = 10.0f;
public static readonly Color _kActiveTickColor = CupertinoDynamicColor.withBrightness(
color: new Color(0xFF3C3C44),
darkColor: new 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 class CupertinoActivityIndicator : StatefulWidget {
public CupertinoActivityIndicator(
Key key = null,
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;
}
public readonly bool animating;
public readonly float radius;
public override State createState() {
return new _CupertinoActivityIndicatorState();
}
}
class _CupertinoActivityIndicatorState : TickerProviderStateMixin<CupertinoActivityIndicator> {
AnimationController _controller;
public override void initState() {
base.initState();
_controller = new AnimationController(
duration: TimeSpan.FromSeconds(1),
vsync: this
);
if (widget.animating) {
_controller.repeat();
}
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget: oldWidget);
if (oldWidget is CupertinoActivityIndicator _oldWidget) {
if (widget.animating != _oldWidget.animating) {
if (widget.animating) {
_controller.repeat();
}
else {
_controller.stop();
}
}
}
}
public override void dispose() {
_controller.dispose();
base.dispose();
}
public override Widget build(BuildContext context) {
return new SizedBox(
height: widget.radius * 2,
width: widget.radius * 2,
child: new CustomPaint(
painter: new _CupertinoActivityIndicatorPainter(
position: _controller,
activeColor: CupertinoDynamicColor.resolve(CupertinoActivityIndicatorUtils._kActiveTickColor, context),
radius: widget.radius
)
)
);
}
}
class _CupertinoActivityIndicatorPainter : AbstractCustomPainter
{
public _CupertinoActivityIndicatorPainter(
Animation<float> 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 * radius / CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius,
radiusY: 1.0f * radius / CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius
);
this.position = position;
this.activeColor = activeColor;
}
public readonly Animation<float> position;
public readonly RRect tickFundamentalRRect;
public readonly Color activeColor;
public override void paint(Canvas canvas, Size size) {
Paint paint = new Paint();
canvas.save();
canvas.translate(size.width / 2.0f, size.height / 2.0f);
int activeTick = (CupertinoActivityIndicatorUtils._kTickCount * position.value).floor();
for (int i = 0; i < CupertinoActivityIndicatorUtils._kTickCount; ++i) {
int t = ((i + activeTick) % CupertinoActivityIndicatorUtils._kTickCount);
paint.color = activeColor.withAlpha(CupertinoActivityIndicatorUtils._alphaValues[t]);
canvas.drawRRect(tickFundamentalRRect,paint);
canvas.rotate(-CupertinoActivityIndicatorUtils._kTwoPI / CupertinoActivityIndicatorUtils._kTickCount);
}
canvas.restore();
}
public override bool shouldRepaint(CustomPainter oldPainter) {
return ((oldPainter as _CupertinoActivityIndicatorPainter).position != position) ||
((oldPainter as _CupertinoActivityIndicatorPainter).activeColor != activeColor);
}
}
}

219
com.unity.uiwidgets/Runtime/cupertino/app.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
//using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.cupertino {
public class CupertinoApp : StatefulWidget {
public CupertinoApp(
Key key = null,
GlobalKey<NavigatorState> navigatorKey = null,
Widget home = null,
CupertinoThemeData theme = null,
Dictionary<string, WidgetBuilder> routes = null,
string initialRoute = null,
RouteFactory onGenerateRoute = null,
InitialRouteListFactory onGenerateInitialRoutes = null,
RouteFactory onUnknownRoute = null,
List<NavigatorObserver> navigatorObservers = null,
TransitionBuilder builder = null,
string title = "",
GenerateAppTitle onGenerateTitle = null,
Color color = null,
Locale locale = null,
List<LocalizationsDelegate<CupertinoLocalizations>> localizationsDelegates = null,
LocaleListResolutionCallback localeListResolutionCallback = null,
LocaleResolutionCallback localeResolutionCallback = null,
List<Locale> supportedLocales = null,
bool showPerformanceOverlay = false,
bool checkerboardRasterCacheImages = false,
bool checkerboardOffscreenLayers = false,
bool showSemanticsDebugger = false,
bool debugShowCheckedModeBanner = true,
Dictionary<LogicalKeySet, Intent> shortcuts = null,
Dictionary<LocalKey, ActionFactory> actions = null
) : base(key: key) {
D.assert(title != null);
supportedLocales = supportedLocales ?? new List<Locale> {new Locale("en", "US")};
this.navigatorKey = navigatorKey;
this.home = home;
this.theme = theme;
this.routes = routes ?? new Dictionary<string, WidgetBuilder>();
this.initialRoute = initialRoute;
this.onGenerateRoute = onGenerateRoute;
this.onGenerateInitialRoutes = onGenerateInitialRoutes;
this.onUnknownRoute = onUnknownRoute;
this.navigatorObservers = navigatorObservers ?? new List<NavigatorObserver>();
this.builder = builder;
this.title = title;
this.onGenerateTitle = onGenerateTitle;
this.color = color;
this.locale = locale;
this.localizationsDelegates = localizationsDelegates;
this.localeListResolutionCallback = localeListResolutionCallback;
this.localeResolutionCallback = localeResolutionCallback;
this.supportedLocales = supportedLocales;
this.showPerformanceOverlay = showPerformanceOverlay;
this.showSemanticsDebugger = showSemanticsDebugger;
this.debugShowCheckedModeBanner = debugShowCheckedModeBanner;
this.shortcuts = shortcuts;
this.actions = actions;
}
public readonly GlobalKey<NavigatorState> navigatorKey;
public readonly Widget home;
public readonly CupertinoThemeData theme;
public readonly Dictionary<string, WidgetBuilder> routes;
public readonly string initialRoute;
public readonly RouteFactory onGenerateRoute;
public readonly InitialRouteListFactory onGenerateInitialRoutes;
public readonly RouteFactory onUnknownRoute;
public readonly List<NavigatorObserver> navigatorObservers;
public readonly TransitionBuilder builder;
public readonly string title;
public readonly GenerateAppTitle onGenerateTitle;
public readonly Color color;
public readonly Locale locale;
public readonly List<LocalizationsDelegate<CupertinoLocalizations>> localizationsDelegates;
public readonly LocaleListResolutionCallback localeListResolutionCallback;
public readonly LocaleResolutionCallback localeResolutionCallback;
public readonly List<Locale> supportedLocales;
public readonly bool showPerformanceOverlay;
public readonly bool checkerboardRasterCacheImages;
public readonly bool checkerboardOffscreenLayers;
public readonly bool showSemanticsDebugger;
public readonly bool debugShowCheckedModeBanner;
public readonly Dictionary<LogicalKeySet, Intent> shortcuts;
public readonly Dictionary<LocalKey, ActionFactory> actions;
public override State createState() {
return new _CupertinoAppState();
}
public static HeroController createCupertinoHeroController() {
return new HeroController();
}
}
public class _AlwaysCupertinoScrollBehavior : ScrollBehavior {
public override Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) {
return child;
}
public override ScrollPhysics getScrollPhysics(BuildContext context) {
return new BouncingScrollPhysics();
}
}
class _CupertinoAppState : State<CupertinoApp> {
HeroController _heroController;
public override void initState() {
base.initState();
_heroController = CupertinoApp.createCupertinoHeroController();
_updateNavigator();
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
if (widget.navigatorKey != ((CupertinoApp) oldWidget).navigatorKey) {
_heroController = CupertinoApp.createCupertinoHeroController();
}
_updateNavigator();
}
List<NavigatorObserver> _navigatorObservers;
void _updateNavigator() {
if (widget.home != null ||
widget.routes.isNotEmpty() ||
widget.onGenerateRoute != null ||
widget.onUnknownRoute != null) {
_navigatorObservers = new List<NavigatorObserver>();
foreach (var item in widget.navigatorObservers) {
_navigatorObservers.Add(item);
}
}
else {
_navigatorObservers = new List<NavigatorObserver>();
}
}
List<LocalizationsDelegate> _localizationsDelegates {
get {
var _delegates = new List<LocalizationsDelegate>();
if (widget.localizationsDelegates != null) {
_delegates.AddRange(widget.localizationsDelegates);
}
_delegates.Add(DefaultCupertinoLocalizations.del);
return new List<LocalizationsDelegate>(_delegates);
}
}
public override Widget build(BuildContext context) {
CupertinoThemeData effectiveThemeData = widget.theme ?? new CupertinoThemeData();
return new ScrollConfiguration(
behavior: new _AlwaysCupertinoScrollBehavior(),
child: new CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.baselayer,
child: new CupertinoTheme(
data: effectiveThemeData,
child: new Builder(
builder: (BuildContext context1)=> {
return new WidgetsApp(
key: new GlobalObjectKey<State<StatefulWidget>>(value: this),
navigatorKey: widget.navigatorKey,
navigatorObservers: _navigatorObservers,
pageRouteBuilder:(RouteSettings settings, WidgetBuilder builder) =>
new CupertinoPageRoute(settings: settings, builder: builder),
home: widget.home,
routes: widget.routes,
initialRoute: widget.initialRoute,
onGenerateRoute: widget.onGenerateRoute,
onGenerateInitialRoutes: widget.onGenerateInitialRoutes,
onUnknownRoute: widget.onUnknownRoute,
builder: widget.builder,
title: widget.title,
onGenerateTitle: widget.onGenerateTitle,
textStyle: CupertinoTheme.of(context1).textTheme.textStyle,
color: CupertinoDynamicColor.resolve(widget.color ?? effectiveThemeData.primaryColor, context1),
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 context3, VoidCallback onPressed) => {
return CupertinoButton.filled(
child: new Icon(
CupertinoIcons.search,
size: 28.0f,
color: CupertinoColors.white
),
padding: EdgeInsets.zero,
onPressed: onPressed
);
},
shortcuts: widget.shortcuts,
actions: widget.actions
);
}
)
)
)
);
}
}
}

770
com.unity.uiwidgets/Runtime/cupertino/colors.cs


using System;
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 readonly CupertinoDynamicColor activeBlue = systemBlue;
public static readonly CupertinoDynamicColor activeGreen = systemGreen;
public static readonly 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 readonly CupertinoDynamicColor inactiveGray = CupertinoDynamicColor.withBrightness(
debugLabel: "inactiveGray",
color: new Color(0xFF999999),
darkColor: new Color(0xFF757575)
);
public static readonly CupertinoDynamicColor destructiveRed = systemRed;
public static readonly 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 readonly 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 readonly 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 readonly 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 readonly 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 readonly 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 readonly 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 readonly 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 readonly 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 readonly 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 readonly 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 readonly 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 readonly 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 readonly 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 readonly 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 readonly CupertinoDynamicColor label = new CupertinoDynamicColor(
debugLabel: "label",
effectiveColor:Color.fromARGB(255, 0, 0, 0),
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 readonly CupertinoDynamicColor secondaryLabel = new CupertinoDynamicColor(
debugLabel: "secondaryLabel",
effectiveColor:Color.fromARGB(153, 60, 60, 67),
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 readonly CupertinoDynamicColor tertiaryLabel = new CupertinoDynamicColor(
debugLabel: "tertiaryLabel",
effectiveColor: Color.fromARGB(76, 60, 60, 67),
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 readonly CupertinoDynamicColor quaternaryLabel = new CupertinoDynamicColor(
debugLabel: "quaternaryLabel",
effectiveColor:Color.fromARGB(45, 60, 60, 67),
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 readonly CupertinoDynamicColor systemFill = new CupertinoDynamicColor(
debugLabel: "systemFill",
effectiveColor:Color.fromARGB(51, 120, 120, 128),
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 readonly CupertinoDynamicColor secondarySystemFill = new CupertinoDynamicColor(
debugLabel: "secondarySystemFill",
effectiveColor: Color.fromARGB(40, 120, 120, 128),
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 readonly CupertinoDynamicColor tertiarySystemFill = new CupertinoDynamicColor(
debugLabel: "tertiarySystemFill",
effectiveColor:Color.fromARGB(30, 118, 118, 128),
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 readonly CupertinoDynamicColor quaternarySystemFill = new CupertinoDynamicColor(
debugLabel: "quaternarySystemFill",
effectiveColor:Color.fromARGB(20, 116, 116, 128),
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 readonly CupertinoDynamicColor placeholderText = new CupertinoDynamicColor(
debugLabel: "placeholderText",
effectiveColor:Color.fromARGB(76, 60, 60, 67),
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 readonly CupertinoDynamicColor systemBackground = new CupertinoDynamicColor(
debugLabel: "systemBackground",
effectiveColor:Color.fromARGB(255, 255, 255, 255),
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 readonly CupertinoDynamicColor secondarySystemBackground = new CupertinoDynamicColor(
debugLabel: "secondarySystemBackground",
effectiveColor:Color.fromARGB(255, 242, 242, 247),
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 readonly CupertinoDynamicColor tertiarySystemBackground = new CupertinoDynamicColor(
debugLabel: "tertiarySystemBackground",
effectiveColor:Color.fromARGB(255, 255, 255, 255),
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 readonly CupertinoDynamicColor systemGroupedBackground = new CupertinoDynamicColor(
debugLabel: "systemGroupedBackground",
effectiveColor:Color.fromARGB(255, 242, 242, 247),
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 readonly CupertinoDynamicColor secondarySystemGroupedBackground = new CupertinoDynamicColor(
debugLabel: "secondarySystemGroupedBackground",
effectiveColor:Color.fromARGB(255, 255, 255, 255),
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 readonly CupertinoDynamicColor tertiarySystemGroupedBackground = new CupertinoDynamicColor(
debugLabel: "tertiarySystemGroupedBackground",
effectiveColor:Color.fromARGB(255, 242, 242, 247),
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 readonly CupertinoDynamicColor separator = new CupertinoDynamicColor(
debugLabel: "separator",
effectiveColor:Color.fromARGB(73, 60, 60, 67),
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 readonly CupertinoDynamicColor opaqueSeparator = new CupertinoDynamicColor(
debugLabel: "opaqueSeparator",
effectiveColor:Color.fromARGB(255, 198, 198, 200),
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 readonly CupertinoDynamicColor link =
new CupertinoDynamicColor(
debugLabel: "link",
effectiveColor:Color.fromARGB(255, 0, 122, 255),
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 : DiagnosticableMixinColor {
public CupertinoDynamicColor(
string debugLabel = null,
Color effectiveColor = 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,
Element debugResolveContext = null
): base(0)
{
D.assert(color != null,()=>"color8 == null");
D.assert(darkColor != null,()=>"color7 == null");
D.assert(highContrastColor != null,()=>"color6 == null");
D.assert(darkHighContrastColor != null,()=>"color5 == null");
D.assert(elevatedColor != null,()=>"color4 == null");
D.assert(darkElevatedColor != null,()=>"color3 == null");
D.assert(highContrastElevatedColor != null,()=>"color2 == null");
D.assert(darkHighContrastElevatedColor != null,()=>"color1 == null");
_effectiveColor = 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 = debugResolveContext;
_debugLabel = debugLabel;
}
public static CupertinoDynamicColor withBrightnessAndContrast(
string debugLabel ,
Color color ,
Color darkColor ,
Color highContrastColor ,
Color darkHighContrastColor
) {
return new CupertinoDynamicColor(
debugLabel: debugLabel,
color: color,
darkColor: darkColor,
highContrastColor: highContrastColor,
darkHighContrastColor: darkHighContrastColor,
elevatedColor: color,
darkElevatedColor: darkColor,
highContrastElevatedColor: highContrastColor,
darkHighContrastElevatedColor: darkHighContrastColor,
debugResolveContext: null
);
}
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,
debugResolveContext: null
);
}
public readonly Color _effectiveColor;
public new uint value {
get {
return _effectiveColor.value;
}
}
public readonly string _debugLabel;
public readonly 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);
//var resolveColor = (resolvable is CupertinoDynamicColor) ? ((CupertinoDynamicColor)resolvable).resolveFrom(context, nullOk: nullOk) : resolvable;
Color resolveColor = null;
if (resolvable is CupertinoDynamicColor) {
int i = 0;
resolveColor = ((CupertinoDynamicColor) resolvable).resolveFrom(context, nullOk: nullOk)._effectiveColor;
}
else {
int j = 0;
resolveColor = resolvable;
}
return resolveColor;
}
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 level = _isInterfaceElevationDependent
? CupertinoUserInterfaceLevel.of(context, nullOk: nullOk) ?? 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 new CupertinoDynamicColor(
debugLabel: _debugLabel,
effectiveColor: resolved,
color: color,
darkColor: darkColor,
highContrastColor: highContrastColor,
darkHighContrastColor: darkHighContrastColor,
elevatedColor: color,
darkElevatedColor: darkColor,
highContrastElevatedColor: highContrastColor,
darkHighContrastElevatedColor: darkHighContrastColor,
debugResolveContext: null
);
}
public bool Equals(CupertinoDynamicColor other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(value, other.value)
&& Equals(color, other.color)
&& 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 = (hashCode * 397) ^(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 override string toString(DiagnosticLevel minLevel = DiagnosticLevel.debug) {
string toStringColor(string name, Color color) {
string marker = color == _effectiveColor ? "*" : "";
return marker+ name+" = " + color + marker;
}
List<string> xs = new List<string>();
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 override 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<Element>("last resolved", _debugResolveContext));
}
public static DiagnosticsProperty<Color> createCupertinoColorProperty(
string name ,
Color value ,
bool showName = true,
object defaultValue = null,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.singleLine,
DiagnosticLevel level = DiagnosticLevel.info
) {
if (value is CupertinoDynamicColor) {
return new DiagnosticsProperty<Color>(
name: name,
value: value,
description: ((CupertinoDynamicColor)value)._debugLabel,
showName: showName,
defaultValue: defaultValue,
style: style,
level: level
);
}
else {
return new ColorProperty(
name,
value,
showName: showName,
defaultValue: defaultValue,
style: style,
level: level
);
}
}
}
}

251
com.unity.uiwidgets/Runtime/cupertino/button.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using TickerFuture = Unity.UIWidgets.scheduler.TickerFuture;
namespace Unity.UIWidgets.cupertino {
public class CupertinoButtonUtils {
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 float kMinInteractiveDimensionCupertino = 44.0f;
}
public class CupertinoButton : StatefulWidget {
public CupertinoButton(
Key key = null,
Widget child = null,
EdgeInsetsGeometry padding = null,
Color color = null,
Color disabledColor = null,
float minSize = 44.0f,
float pressedOpacity = 0.4f,
BorderRadius borderRadius = null,
VoidCallback onPressed = null
) : base(key: key) {
D.assert((pressedOpacity >= 0.0 && pressedOpacity <= 1.0));
_filled = false;
this.child = child;
this.onPressed = onPressed;
this.padding = padding;
this.color = color;
this.disabledColor = disabledColor ?? CupertinoColors.quaternarySystemFill;
this.minSize = minSize;
this.pressedOpacity = pressedOpacity;
this.borderRadius = borderRadius ?? BorderRadius.all(Radius.circular(8.0f));
}
public static CupertinoButton filled(
Key key = null,
Widget child = null,
EdgeInsetsGeometry padding = null,
Color disabledColor = null,
float minSize = 44.0f,
float pressedOpacity = 0.4f,
BorderRadius borderRadius = null,
VoidCallback onPressed = null
) {
disabledColor = disabledColor ?? CupertinoColors.quaternarySystemFill;
D.assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0);
var btn = new CupertinoButton(
key: key,
color: null,
child: child,
padding: padding,
disabledColor: disabledColor,
minSize: minSize,
pressedOpacity: pressedOpacity,
borderRadius: borderRadius,
onPressed: onPressed
);
btn._filled = true;
return btn;
}
public readonly Widget child;
public readonly EdgeInsetsGeometry padding;
public readonly Color color;
public readonly Color disabledColor;
public readonly VoidCallback onPressed;
public readonly float minSize;
public readonly float pressedOpacity;
public readonly BorderRadius borderRadius;
public bool _filled;
public bool enabled {
get { return onPressed != null; }
}
public override State createState() {
return new _CupertinoButtonState();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FlagProperty("enabled", value: enabled, ifFalse: "disabled"));
}
}
class _CupertinoButtonState : SingleTickerProviderStateMixin<CupertinoButton> {
static readonly TimeSpan kFadeOutDuration = new TimeSpan(0, 0, 0, 0, 10);
static readonly TimeSpan kFadeInDuration = new TimeSpan(0, 0, 0, 0, 100);
public readonly Tween<float> _opacityTween = new FloatTween(begin: 1.0f, end: 0.0f);//Tween<Float>
AnimationController _animationController;
Animation<float> _opacityAnimation;
public override void initState() {
base.initState();
_animationController = new AnimationController(
duration: new TimeSpan(0, 0, 0, 0, 200),
value: 0.0f,
vsync: this);
_opacityAnimation = _animationController
.drive(new CurveTween(curve: Curves.decelerate))
.drive(_opacityTween);
_setTween();
}
public override void didUpdateWidget(StatefulWidget old) {
base.didUpdateWidget(old);
_setTween();
}
void _setTween() {
if (widget != null) {
_opacityTween.end = 1.0f;
if (!widget.pressedOpacity.Equals(0f)) {
_opacityTween.end = widget.pressedOpacity;
}
}
}
public override void dispose() {
_animationController.dispose();
_animationController = null;
base.dispose();
}
bool _buttonHeldDown = false;
void _handleTapDown(TapDownDetails evt) {
if (!_buttonHeldDown) {
_buttonHeldDown = true;
_animate();
}
}
void _handleTapUp(TapUpDetails evt) {
if (_buttonHeldDown) {
_buttonHeldDown = false;
_animate();
}
}
void _handleTapCancel() {
if (_buttonHeldDown) {
_buttonHeldDown = false;
_animate();
}
}
void _animate() {
if (_animationController.isAnimating) {
return;
}
bool wasHeldDown = _buttonHeldDown;
TickerFuture ticker = _buttonHeldDown
? _animationController.animateTo(1.0f, duration: kFadeOutDuration)
: _animationController.animateTo(0.0f, duration: kFadeInDuration);
ticker.then(_ => {
if (mounted && wasHeldDown != _buttonHeldDown) {
_animate();
}
});
}
public override Widget build(BuildContext context) {
bool enabled = widget.enabled;
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
? themeData.primaryContrastingColor
: enabled
? primaryColor
: CupertinoDynamicColor.resolve(CupertinoColors.placeholderText, context);
TextStyle textStyle =
themeData.textTheme.textStyle.copyWith(color: foregroundColor);
return new GestureDetector(
behavior: HitTestBehavior.opaque,
onTapDown: enabled ? _handleTapDown : (GestureTapDownCallback) null,
onTapUp: enabled ? _handleTapUp : (GestureTapUpCallback) null,
onTapCancel: enabled ? _handleTapCancel : (GestureTapCancelCallback) null,
onTap: widget.onPressed == null
? (GestureTapCallback) null
: () => {
if (widget.onPressed != null) {
widget.onPressed();
}
},
child: new ConstrainedBox(
constraints: widget.minSize == null
? new BoxConstraints() :
new BoxConstraints(
minWidth: widget.minSize,
minHeight: widget.minSize
),
child: new FadeTransition(
opacity: _opacityAnimation,
child: new DecoratedBox(
decoration: new BoxDecoration(
borderRadius: widget.borderRadius,
color: backgroundColor != null && !enabled
? CupertinoDynamicColor.resolve(widget.disabledColor, context)
: backgroundColor
),
child: new Padding(
padding: widget.padding ?? (backgroundColor != null
? CupertinoButtonUtils._kBackgroundButtonPadding
: CupertinoButtonUtils._kButtonPadding),
child: new Center(
widthFactor: 1.0f,
heightFactor: 1.0f,
child: new DefaultTextStyle(
style: textStyle,
child: new IconTheme(
data: new IconThemeData(color: foregroundColor),
child: widget.child
)
)
)
)
)
)
)
);
}
}
}

1001
com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
文件差异内容过多而无法显示
查看文件

250
com.unity.uiwidgets/Runtime/cupertino/localization.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.cupertino {
public enum DatePickerDateTimeOrder {
date_time_dayPeriod,
date_dayPeriod_time,
time_dayPeriod_date,
dayPeriod_time_date
}
public enum DatePickerDateOrder {
dmy,
mdy,
ymd,
ydm
}
public abstract class CupertinoLocalizations {
public abstract string datePickerYear(int yearIndex);
public abstract string datePickerMonth(int monthIndex);
public abstract string datePickerDayOfMonth(int dayIndex);
public abstract string datePickerMediumDate(DateTime date);
public abstract string datePickerHour(int hour);
public abstract string datePickerHourSemanticsLabel(int hour);
public abstract string datePickerMinute(int minute);
public abstract string datePickerMinuteSemanticsLabel(int minute);
public abstract DatePickerDateOrder datePickerDateOrder { get; }
public abstract DatePickerDateTimeOrder datePickerDateTimeOrder { get; }
public abstract string anteMeridiemAbbreviation { get; }
public abstract string postMeridiemAbbreviation { get; }
public abstract string todayLabel { get; }
public abstract string alertDialogLabel { get; }
public abstract string timerPickerHour(int hour);
public abstract string timerPickerMinute(int minute);
public abstract string timerPickerSecond(int second);
public abstract string timerPickerHourLabel(int hour);
public abstract string timerPickerMinuteLabel(int minute);
public abstract string timerPickerSecondLabel(int second);
public abstract string cutButtonLabel { get; }
public abstract string copyButtonLabel { get; }
public abstract string pasteButtonLabel { get; }
public abstract string selectAllButtonLabel { get; }
public static CupertinoLocalizations of(BuildContext context) {
return Localizations.of<CupertinoLocalizations>(context, typeof(CupertinoLocalizations));
}
}
class _CupertinoLocalizationsDelegate : LocalizationsDelegate<CupertinoLocalizations> {
public _CupertinoLocalizationsDelegate() { }
public override bool isSupported(Locale locale) {
return locale.languageCode == "en";
}
public override Future<WidgetsLocalizations> load(Locale locale) {
return DefaultCupertinoLocalizations.load(locale).to<WidgetsLocalizations>();
}
public override bool shouldReload(LocalizationsDelegate old) {
return false;
}
public override string ToString() {
return "DefaultCupertinoLocalizations.delegate(en_US)";
}
}
public class DefaultCupertinoLocalizations : CupertinoLocalizations {
public DefaultCupertinoLocalizations() { }
static readonly List<string> _shortWeekdays = new List<string> {
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun"
};
static readonly List<string> _shortMonths = new List<string> {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
};
static readonly List<string> _months = new List<string> {
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};
public override string datePickerYear(int yearIndex) {
return yearIndex.ToString();
}
public override string datePickerMonth(int monthIndex) {
return _months[monthIndex - 1];
}
public override string datePickerDayOfMonth(int dayIndex) {
return dayIndex.ToString();
}
public override string datePickerHour(int hour) {
return hour.ToString();
}
public override string datePickerHourSemanticsLabel(int hour) {
return hour.ToString() + " o'clock";
}
public override string datePickerMinute(int minute) {
return minute.ToString().PadLeft(2, '0');
}
public override string datePickerMinuteSemanticsLabel(int minute) {
if (minute == 1) {
return "1 minute";
}
return minute.ToString() + " minutes";
}
public override string datePickerMediumDate(DateTime date) {
var day = _shortWeekdays[((int) date.DayOfWeek + 6) % 7];
var month = _shortMonths[date.Month - 1];
return $"{day} {month} {date.Day.ToString().PadRight(2)} ";
}
public override DatePickerDateOrder datePickerDateOrder {
get { return DatePickerDateOrder.mdy; }
}
public override DatePickerDateTimeOrder datePickerDateTimeOrder {
get { return DatePickerDateTimeOrder.date_time_dayPeriod; }
}
public override string anteMeridiemAbbreviation {
get { return "AM"; }
}
public override string postMeridiemAbbreviation {
get { return "PM"; }
}
public override string todayLabel {
get { return "Today"; }
}
public override string alertDialogLabel {
get { return "Alert"; }
}
public override string timerPickerHour(int hour) {
return hour.ToString();
}
public override string timerPickerMinute(int minute) {
return minute.ToString();
}
public override string timerPickerSecond(int second) {
return second.ToString();
}
public override string timerPickerHourLabel(int hour) {
return hour == 1 ? "hour" : "hours";
}
public override string timerPickerMinuteLabel(int minute) {
return "min";
}
public override string timerPickerSecondLabel(int second) {
return "sec";
}
public override string cutButtonLabel {
get { return "Cut"; }
}
public override string copyButtonLabel {
get { return "Copy"; }
}
public override string pasteButtonLabel {
get { return "Paste"; }
}
public override string selectAllButtonLabel {
get { return "Select All"; }
}
public static Future<CupertinoLocalizations> load(Locale locale) {
return new SynchronousFuture<CupertinoLocalizations>(new DefaultCupertinoLocalizations());
}
public static readonly LocalizationsDelegate<CupertinoLocalizations>
del = new _CupertinoLocalizationsDelegate();
}
}

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


using System;
using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.async;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.cupertino {
public class CupertinoRouteUtils {
public const float _kBackGestureWidth = 20.0f;
public const float _kMinFlingVelocity = 1.0f;
public const int _kMaxDroppedSwipePageForwardAnimationTime = 800; // Milliseconds.
public const int _kMaxPageBackAnimationTime = 300; // Milliseconds.
public static readonly Color _kModalBarrierColor = CupertinoDynamicColor.withBrightness(
color: new Color(0x33000000),
darkColor: new Color(0x7A000000)
);
public static readonly TimeSpan _kModalPopupTransitionDuration = TimeSpan.FromMilliseconds(335);
public static readonly Animatable<Offset> _kRightMiddleTween = new OffsetTween(
begin: new Offset(1.0f, 0.0f),
end: Offset.zero
);
public static readonly Animatable<Offset> _kMiddleLeftTween = new OffsetTween(
begin: Offset.zero,
end: new Offset(-1.0f / 3.0f, 0.0f)
);
public static readonly Animatable<Offset> _kBottomUpTween = new OffsetTween(
begin: new Offset(0.0f, 1.0f),
end: Offset.zero
);
public static readonly DecorationTween _kGradientShadowTween = new DecorationTween(
begin: _CupertinoEdgeShadowDecoration.none,
end: new _CupertinoEdgeShadowDecoration(
edgeGradient: new LinearGradient(
begin: new Alignment(0.9f, 0.0f),
end: Alignment.centerRight,
colors: new List<Color> {
new Color(0x00000000),
new Color(0x04000000),
new Color(0x12000000),
new Color(0x38000000),
},
stops: new List<float> {0.0f, 0.3f, 0.6f, 1.0f}
)
)
);
public static Future showCupertinoModalPopup(
BuildContext context = null,
WidgetBuilder builder = null,
ImageFilter filter = null,
bool useRootNavigator = true,
bool? semanticsDismissible =null
) {
return Navigator.of(context, rootNavigator: useRootNavigator).push(
new _CupertinoModalPopupRoute(
barrierColor: CupertinoDynamicColor.resolve(_kModalBarrierColor, context),
barrierLabel: "Dismiss",
builder: builder,
filter: filter
)
);
}
public static readonly Animatable<float> _dialogScaleTween = new FloatTween(begin: 1.3f, end: 1.0f)
.chain(new CurveTween(curve: Curves.linearToEaseOut));
public static Widget _buildCupertinoDialogTransitions(
BuildContext context,
Animation<float> animation,
Animation<float> secondaryAnimation,
Widget child) {
CurvedAnimation fadeAnimation = new CurvedAnimation(
parent: animation,
curve: Curves.easeInOut
);
if (animation.status == AnimationStatus.reverse) {
return new FadeTransition(
opacity: fadeAnimation,
child: child
);
}
return new FadeTransition(
opacity: fadeAnimation,
child: new ScaleTransition(
child: child,
scale: animation.drive(_dialogScaleTween)
)
);
}
public static Future showCupertinoDialog(
BuildContext context = null,
WidgetBuilder builder =null,
bool useRootNavigator = true,
RouteSettings routeSettings = null
) {
D.assert(builder != null);
return DialogUtils.showGeneralDialog<object>(
context: context,
barrierDismissible: false,
barrierColor: CupertinoDynamicColor.resolve(_kModalBarrierColor, context),
transitionDuration: TimeSpan.FromMilliseconds(250),
pageBuilder: (BuildContext context1, Animation<float> animation, Animation<float> secondaryAnimation)=> {
return builder(context1);
},
transitionBuilder: _buildCupertinoDialogTransitions,
useRootNavigator: useRootNavigator,
routeSettings: routeSettings
);
}
public static Future<T> showCupertinoDialog<T>(
BuildContext context = null,
WidgetBuilder builder =null,
bool useRootNavigator = true,
RouteSettings routeSettings = null
) {
D.assert(builder != null);
D.assert(useRootNavigator != null);
return DialogUtils.showGeneralDialog<T>(
context: context,
barrierDismissible: false,
barrierColor: CupertinoDynamicColor.resolve(_kModalBarrierColor, context),
// This transition duration was eyeballed comparing with iOS
transitionDuration: TimeSpan.FromMilliseconds(250),
pageBuilder: (BuildContext context1, Animation<float> animation, Animation<float> secondaryAnimation)=> {
return builder(context1);
},
transitionBuilder: _buildCupertinoDialogTransitions,
useRootNavigator: useRootNavigator,
routeSettings: routeSettings
);
}
public static Future<T> showCupertinoModalPopup<T>(
BuildContext context = null,
WidgetBuilder builder =null,
ImageFilter filter = null,
bool useRootNavigator = true,
bool? semanticsDismissible =null
) {
D.assert(useRootNavigator != null);
return Navigator.of(context, rootNavigator: useRootNavigator).push(
new _CupertinoModalPopupRoute(
barrierColor: CupertinoDynamicColor.resolve(_kModalBarrierColor, context),
barrierLabel: "Dismiss",
builder: builder,
filter: filter
)
).to<T>();
}
}
class _CupertinoEdgeShadowDecoration : Decoration, IEquatable<_CupertinoEdgeShadowDecoration> {
public _CupertinoEdgeShadowDecoration(
LinearGradient edgeGradient = null
) {
this.edgeGradient = edgeGradient;
}
public static _CupertinoEdgeShadowDecoration none =
new _CupertinoEdgeShadowDecoration();
public readonly LinearGradient edgeGradient;
static _CupertinoEdgeShadowDecoration lerpCupertino(
_CupertinoEdgeShadowDecoration a,
_CupertinoEdgeShadowDecoration b,
float t
) {
if (a == null && b == null) {
return null;
}
return new _CupertinoEdgeShadowDecoration(
edgeGradient: LinearGradient.lerp(a?.edgeGradient, b?.edgeGradient, t)
);
}
public override Decoration lerpFrom(Decoration a, float t) {
if (!(a is _CupertinoEdgeShadowDecoration)) {
return lerpCupertino(null, this, t);
}
return lerpCupertino((_CupertinoEdgeShadowDecoration) a, this, t);
}
public override Decoration lerpTo(Decoration b, float t) {
if (!(b is _CupertinoEdgeShadowDecoration)) {
return lerpCupertino(this, null, t);
}
return lerpCupertino(this, (_CupertinoEdgeShadowDecoration) b, t);
}
public override BoxPainter createBoxPainter(VoidCallback onChanged = null) {
return new _CupertinoEdgeShadowPainter(this, onChanged);
}
public override int GetHashCode() {
return edgeGradient.GetHashCode();
}
public bool Equals(_CupertinoEdgeShadowDecoration other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return other is _CupertinoEdgeShadowDecoration && Equals(edgeGradient, other.edgeGradient);
}
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((_CupertinoEdgeShadowDecoration) obj);
}
public static bool operator ==(_CupertinoEdgeShadowDecoration left, _CupertinoEdgeShadowDecoration right) {
return Equals(left, right);
}
public static bool operator !=(_CupertinoEdgeShadowDecoration left, _CupertinoEdgeShadowDecoration right) {
return !Equals(left, right);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<LinearGradient>("edgeGradient", edgeGradient));
}
}
class _CupertinoEdgeShadowPainter : BoxPainter {
public _CupertinoEdgeShadowPainter(
_CupertinoEdgeShadowDecoration decoration = null,
VoidCallback onChange = null
) : base(onChange) {
D.assert(decoration != null);
_decoration = decoration;
}
readonly _CupertinoEdgeShadowDecoration _decoration;
public override void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
LinearGradient gradient = _decoration.edgeGradient;
if (gradient == null) {
return;
}
TextDirection textDirection = configuration.textDirection;
D.assert(textDirection != null);
float deltaX = 0.0f;
switch (textDirection) {
case TextDirection.rtl:
deltaX = configuration.size.width;
break;
case TextDirection.ltr:
deltaX = -configuration.size.width;
break;
}
Rect rect = (offset & configuration.size).translate(deltaX, 0.0f);
Paint paint = new Paint() {
shader = gradient.createShader(rect, textDirection: textDirection)
};
canvas.drawRect(rect, paint);
}
}
public class CupertinoPageRoute : PageRoute {
public CupertinoPageRoute(
WidgetBuilder builder,
RouteSettings settings = null,
string title = "",
bool maintainState = true,
bool fullscreenDialog = false
) : base(settings: settings, fullscreenDialog: fullscreenDialog) {
D.assert(builder != null);
D.assert(opaque);
this.builder = builder;
this.title = title;
this.maintainState = maintainState;
}
public readonly WidgetBuilder builder;
public readonly string title;
ValueNotifier<string> _previousTitle;
public ValueListenable<string> previousTitle {
get {
D.assert(
_previousTitle != null,
() => "Cannot read the previousTitle for a route that has not yet been installed"
);
return _previousTitle;
}
}
protected internal override void didChangePrevious(Route previousRoute) {
string previousTitleString = previousRoute is CupertinoPageRoute
? ((CupertinoPageRoute) previousRoute).title
: null;
if (_previousTitle == null) {
_previousTitle = new ValueNotifier<string>(previousTitleString);
}
else {
_previousTitle.value = previousTitleString;
}
base.didChangePrevious(previousRoute);
}
public override bool maintainState { get; }
public override TimeSpan transitionDuration {
get { return TimeSpan.FromMilliseconds(400); }
}
public override Color barrierColor {
get { return null; }
}
public string barrierLabel {
get { return null; }
}
public override bool canTransitionTo(TransitionRoute nextRoute) {
return nextRoute is CupertinoPageRoute && !((CupertinoPageRoute) nextRoute).fullscreenDialog;
}
static bool isPopGestureInProgress(PageRoute route) {
return route.navigator.userGestureInProgress;
}
public bool popGestureInProgress {
get { return isPopGestureInProgress(this as PageRoute); }
}
public bool popGestureEnabled {
get { return _isPopGestureEnabled(this as PageRoute); }
}
static bool _isPopGestureEnabled(PageRoute route) {
if (route.isFirst) {
return false;
}
if (route.willHandlePopInternally) {
return false;
}
if (route.hasScopedWillPopCallback) {
return false;
}
if (route.fullscreenDialog) {
return false;
}
if (route.animation.status != AnimationStatus.completed) {
return false;
}
if (route.secondaryAnimation.status != AnimationStatus.dismissed) {
return false;
}
if (isPopGestureInProgress(route )) {
return false;
}
return true;
}
public override Widget buildPage(BuildContext context, Animation<float> animation, Animation<float> secondaryAnimation) {
Widget result = builder(context);
D.assert(() =>{
if (result == null) {
throw new UIWidgetsError(new List<DiagnosticsNode>{
new ErrorSummary($"The builder for route \"{settings.name}\" returned null."),
new ErrorDescription("Route builders must never return null."),
});
}
return true;
});
return result;
}
static _CupertinoBackGestureController _startPopGesture(PageRoute route) {
D.assert(_isPopGestureEnabled(route));
return new _CupertinoBackGestureController(
navigator: route.navigator,
controller: route.controller
);
}
public static Widget buildPageTransitions(
PageRoute route,
BuildContext context,
Animation<float> animation,
Animation<float> secondaryAnimation,
Widget child
) {
bool linearTransition = isPopGestureInProgress(route);
if (route.fullscreenDialog) {
return new CupertinoFullscreenDialogTransition(
primaryRouteAnimation: animation,
secondaryRouteAnimation: secondaryAnimation,
child: child,
linearTransition: linearTransition
);
}
else {
return new CupertinoPageTransition(
primaryRouteAnimation: animation,
secondaryRouteAnimation: secondaryAnimation,
linearTransition: linearTransition,
child: new _CupertinoBackGestureDetector(
enabledCallback: () => _isPopGestureEnabled(route),
onStartPopGesture: () => _startPopGesture(route),
child: child
)
);
}
}
public override Widget buildTransitions(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation, Widget child) {
return buildPageTransitions(this, context, animation, secondaryAnimation, child);
}
public new string debugLabel {
get { return $"{base.debugLabel}({settings.name})"; }
}
}
class CupertinoPageTransition : StatelessWidget {
public CupertinoPageTransition(
bool linearTransition,
Animation<float> primaryRouteAnimation = null,
Animation<float> secondaryRouteAnimation = null,
Widget child = null,
Key key = null
) : base(key: key) {
_primaryPositionAnimation =
(linearTransition
? primaryRouteAnimation
: new CurvedAnimation(
parent: primaryRouteAnimation,
curve: Curves.linearToEaseOut,
reverseCurve: Curves.easeInToLinear
)
).drive(CupertinoRouteUtils._kRightMiddleTween);
_secondaryPositionAnimation =
(linearTransition
? secondaryRouteAnimation
: new CurvedAnimation(
parent: secondaryRouteAnimation,
curve: Curves.linearToEaseOut,
reverseCurve: Curves.easeInToLinear
)
).drive(CupertinoRouteUtils._kMiddleLeftTween);
_primaryShadowAnimation =
(linearTransition
? primaryRouteAnimation
: new CurvedAnimation(
parent: primaryRouteAnimation,
curve: Curves.linearToEaseOut
)
).drive(CupertinoRouteUtils._kGradientShadowTween);
this.child = child;
}
public readonly Animation<Offset> _primaryPositionAnimation;
public readonly Animation<Offset> _secondaryPositionAnimation;
public readonly Animation<Decoration> _primaryShadowAnimation;
public readonly Widget child;
public override Widget build(BuildContext context) {
TextDirection textDirection = Directionality.of(context);
return new SlideTransition(
position: _secondaryPositionAnimation,
textDirection: textDirection,
transformHitTests: false,
child: new SlideTransition(
position: _primaryPositionAnimation,
textDirection: textDirection,
child: new DecoratedBoxTransition(
decoration: _primaryShadowAnimation,
child: child
)
)
);
}
}
class CupertinoFullscreenDialogTransition : StatelessWidget {
public CupertinoFullscreenDialogTransition(
Key key = null,
Animation<float> primaryRouteAnimation = null,
Animation<float> secondaryRouteAnimation = null,
Widget child = null,
bool linearTransition = false
) : base(key: key) {
_positionAnimation = new CurvedAnimation(
parent: primaryRouteAnimation,
curve: Curves.linearToEaseOut,
reverseCurve: Curves.linearToEaseOut.flipped
).drive(CupertinoRouteUtils._kBottomUpTween);
this.child = child;
_secondaryPositionAnimation =
(linearTransition
? secondaryRouteAnimation
: new CurvedAnimation(
parent: secondaryRouteAnimation,
curve: Curves.linearToEaseOut,
reverseCurve: Curves.easeInToLinear
)
).drive(CupertinoRouteUtils._kMiddleLeftTween);
}
public readonly Animation<Offset> _positionAnimation;
public readonly Animation<Offset> _secondaryPositionAnimation;
public readonly Widget child;
public override Widget build(BuildContext context) {
D.assert(WidgetsD.debugCheckHasDirectionality(context));
TextDirection textDirection = Directionality.of(context);
return new SlideTransition(
position: _secondaryPositionAnimation,
textDirection: textDirection,
transformHitTests: false,
child: new SlideTransition(
position: _positionAnimation,
child: child
)
);
}
}
class _CupertinoBackGestureDetector : StatefulWidget {
public _CupertinoBackGestureDetector(
Key key = null,
ValueGetter<bool> enabledCallback = null,
ValueGetter<_CupertinoBackGestureController> onStartPopGesture = null,
Widget child = null
) : base(key: key) {
D.assert(enabledCallback != null);
D.assert(onStartPopGesture != null);
D.assert(child != null);
this.child = child;
this.enabledCallback = enabledCallback;
this.onStartPopGesture = onStartPopGesture;
}
public readonly Widget child;
public readonly ValueGetter<bool> enabledCallback;
public readonly ValueGetter<_CupertinoBackGestureController> onStartPopGesture;
public override State createState() {
return new _CupertinoBackGestureDetectorState();
}
}
class _CupertinoBackGestureDetectorState : State<_CupertinoBackGestureDetector> {
_CupertinoBackGestureController _backGestureController;
HorizontalDragGestureRecognizer _recognizer;
public override void initState() {
base.initState();
_recognizer = new HorizontalDragGestureRecognizer(debugOwner: this);
_recognizer.onStart = _handleDragStart;
_recognizer.onUpdate = _handleDragUpdate;
_recognizer.onEnd = _handleDragEnd;
_recognizer.onCancel = _handleDragCancel;
}
public override void dispose() {
_recognizer.dispose();
base.dispose();
}
void _handleDragStart(DragStartDetails details) {
D.assert(mounted);
D.assert(_backGestureController == null);
_backGestureController = widget.onStartPopGesture();
}
void _handleDragUpdate(DragUpdateDetails details) {
D.assert(mounted);
D.assert(_backGestureController != null);
_backGestureController.dragUpdate(
_convertToLogical(details.primaryDelta / context.size.width));
}
void _handleDragEnd(DragEndDetails details) {
D.assert(mounted);
D.assert(_backGestureController != null);
_backGestureController.dragEnd(_convertToLogical(details.velocity.pixelsPerSecond.dx / context.size.width) ?? 0.0f);
_backGestureController = null;
}
void _handleDragCancel() {
D.assert(mounted);
_backGestureController?.dragEnd(0.0f);
_backGestureController = null;
}
void _handlePointerDown(PointerDownEvent evt) {
if (widget.enabledCallback()) {
_recognizer.addPointer(evt);
}
}
float? _convertToLogical(float? value) {
switch (Directionality.of(context)) {
case TextDirection.rtl:
return -value;
case TextDirection.ltr:
return value;
}
return value;
}
public override Widget build(BuildContext context) {
float dragAreaWidth = Directionality.of(context) == TextDirection.ltr
? MediaQuery.of(context).padding.left
: MediaQuery.of(context).padding.right;
dragAreaWidth = Mathf.Max(dragAreaWidth, CupertinoRouteUtils._kBackGestureWidth);
return new Stack(
fit: StackFit.passthrough,
children: new List<Widget> {
widget.child,
new PositionedDirectional(
start: 0.0f,
width: dragAreaWidth,
top: 0.0f,
bottom: 0.0f,
child: new Listener(
onPointerDown: _handlePointerDown,
behavior: HitTestBehavior.translucent
)
),
}
);
}
}
class _CupertinoBackGestureController {
public _CupertinoBackGestureController(
NavigatorState navigator,
AnimationController controller
) {
D.assert(navigator != null);
D.assert(controller != null);
this.navigator = navigator;
this.controller = controller;
this.navigator.didStartUserGesture();
}
public readonly AnimationController controller;
public readonly NavigatorState navigator;
public void dragUpdate(float? delta) {
if (delta != null) {
controller.setValue(controller.value - (float) delta);
}
}
public void dragEnd(float velocity) {
Curve animationCurve = Curves.fastLinearToSlowEaseIn;
bool animateForward;
if (velocity.abs() >= CupertinoRouteUtils._kMinFlingVelocity) {
animateForward = velocity <= 0;
}
else {
animateForward = controller.value > 0.5f;
}
if (animateForward) {
int droppedPageForwardAnimationTime = Mathf.Min(
MathUtils.lerpNullableFloat(CupertinoRouteUtils._kMaxDroppedSwipePageForwardAnimationTime, 0f,
controller.value).floor(),
CupertinoRouteUtils._kMaxPageBackAnimationTime
);
controller.animateTo(1.0f, duration: TimeSpan.FromMilliseconds(droppedPageForwardAnimationTime),
curve: animationCurve);
}
else {
navigator.pop<object>();
if (controller.isAnimating) {
int droppedPageBackAnimationTime =
MathUtils.lerpNullableFloat(0f, CupertinoRouteUtils._kMaxDroppedSwipePageForwardAnimationTime,
controller.value).floor();
controller.animateBack(0.0f, duration: TimeSpan.FromMilliseconds(droppedPageBackAnimationTime),
curve: animationCurve);
}
}
if (controller.isAnimating) {
AnimationStatusListener animationStatusCallback = null;
animationStatusCallback = (AnimationStatus status) => {
navigator.didStopUserGesture();
controller.removeStatusListener(animationStatusCallback);
};
controller.addStatusListener(animationStatusCallback);
}
else {
navigator.didStopUserGesture();
}
}
}
class _CupertinoModalPopupRoute : PopupRoute{
public _CupertinoModalPopupRoute(
Color barrierColor = null,
string barrierLabel = null,
WidgetBuilder builder = null,
ImageFilter filter = null,
RouteSettings settings = null
) : base(filter:filter,settings: settings) {
this.barrierColor = barrierColor;
this.builder = builder;
this.barrierLabel = barrierLabel;
}
public readonly WidgetBuilder builder;
public override Color barrierColor { get; }
public override string barrierLabel { get; }
public override bool barrierDismissible {
get { return true; }
}
public override TimeSpan transitionDuration {
get { return CupertinoRouteUtils._kModalPopupTransitionDuration; }
}
new Animation<float> _animation;
Tween<Offset> _offsetTween;
public override Animation<float> createAnimation() {
D.assert(_animation == null);
_animation = new CurvedAnimation(
parent: base.createAnimation(),
curve: Curves.linearToEaseOut,
reverseCurve: Curves.linearToEaseOut.flipped
);
_offsetTween = new OffsetTween(
begin: new Offset(0.0f, 1.0f),
end: new Offset(0.0f, 0.0f)
);
return _animation;
}
public override Widget buildPage(BuildContext context, Animation<float> animation, Animation<float> secondaryAnimation) {
return new CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.elevatedlayer,
child: new Builder(builder: builder)
);
}
public override Widget buildTransitions(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation, Widget child) {
return new Align(
alignment: Alignment.bottomCenter,
child: new FractionalTranslation(
translation: _offsetTween.evaluate(_animation),
child: child
)
);
}
}
}

380
com.unity.uiwidgets/Runtime/cupertino/scrollbar.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.cupertino {
class CupertinoScrollbarUtils {
public const float _kScrollbarMinLength = 36.0f;
public const float _kScrollbarMinOverscrollLength = 8.0f;
public static readonly TimeSpan _kScrollbarTimeToFade = TimeSpan.FromMilliseconds(1200);
public static readonly TimeSpan _kScrollbarFadeDuration = TimeSpan.FromMilliseconds(250);
public static readonly TimeSpan _kScrollbarResizeDuration = TimeSpan.FromMilliseconds(100);
public static readonly Color _kScrollbarColor = CupertinoDynamicColor.withBrightness(
color: new Color(0x59000000),
darkColor: new Color(0x80FFFFFF)
);
public const float _kScrollbarThickness = 3f;
public const float _kScrollbarThicknessDragging = 8.0f;
public static Radius _kScrollbarRadius = Radius.circular(1.5f);
public static Radius _kScrollbarRadiusDragging = Radius.circular(4.0f);
public const float _kScrollbarMainAxisMargin = 3.0f;
public const float _kScrollbarCrossAxisMargin = 3.0f;
public static bool _hitTestInteractive(GlobalKey customPaintKey, Offset offset) {
if (customPaintKey.currentContext == null) {
return false;
}
CustomPaint customPaint = customPaintKey.currentContext.widget as CustomPaint;
ScrollbarPainter painter = customPaint.foregroundPainter as ScrollbarPainter;
RenderBox renderBox = customPaintKey.currentContext.findRenderObject() as RenderBox;
Offset localOffset = renderBox.globalToLocal(offset);
return painter.hitTestInteractive(localOffset);
}
}
public class CupertinoScrollbar : StatefulWidget {
public CupertinoScrollbar(
Key key = null,
ScrollController controller = null,
bool isAlwaysShown = false,
Widget child = null
) : base(key: key) {
this.child = child;
this.controller = controller;
this.isAlwaysShown = isAlwaysShown;
}
public readonly Widget child;
public readonly ScrollController controller;
public readonly bool isAlwaysShown;
public override State createState() {
return new _CupertinoScrollbarState();
}
}
class _CupertinoScrollbarState : TickerProviderStateMixin<CupertinoScrollbar> {
GlobalKey _customPaintKey = GlobalKey.key();
ScrollbarPainter _painter;
TextDirection _textDirection;
AnimationController _fadeoutAnimationController;
Animation<float> _fadeoutOpacityAnimation;
AnimationController _thicknessAnimationController;
float _dragScrollbarPositionY;
Timer _fadeoutTimer;
Drag _drag;
float _thickness {
get {
return CupertinoScrollbarUtils._kScrollbarThickness + _thicknessAnimationController.value * (CupertinoScrollbarUtils._kScrollbarThicknessDragging - CupertinoScrollbarUtils._kScrollbarThickness);
}
}
Radius _radius {
get {
return Radius.lerp(CupertinoScrollbarUtils._kScrollbarRadius, CupertinoScrollbarUtils._kScrollbarRadiusDragging, _thicknessAnimationController.value);
}
}
ScrollController _currentController;
ScrollController _controller {
get {
return widget.controller ?? PrimaryScrollController.of(context);
}
}
public override void initState() {
base.initState();
_fadeoutAnimationController = new AnimationController(
vsync: this,
duration: CupertinoScrollbarUtils._kScrollbarFadeDuration
);
_fadeoutOpacityAnimation = new CurvedAnimation(
parent: _fadeoutAnimationController,
curve: Curves.fastOutSlowIn
);
_thicknessAnimationController = new AnimationController(
vsync: this,
duration: CupertinoScrollbarUtils._kScrollbarResizeDuration
);
_thicknessAnimationController.addListener(() => {
_painter.updateThickness(_thickness, _radius);
});
}
public override void didChangeDependencies() {
base.didChangeDependencies();
if (_painter == null) {
_painter = _buildCupertinoScrollbarPainter(context);
} else {
_painter.textDirection = Directionality.of(context);
_painter.color = CupertinoDynamicColor.resolve(CupertinoScrollbarUtils._kScrollbarColor, context);
_painter.padding = MediaQuery.of(context).padding;
}
WidgetsBinding.instance.addPostFrameCallback((TimeSpan duration)=> {
if (widget.isAlwaysShown) {
D.assert(widget.controller != null);
widget.controller.position.didUpdateScrollPositionBy(0);
}
});
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
oldWidget = (CupertinoScrollbar) oldWidget;
base.didUpdateWidget(oldWidget);
if (widget.isAlwaysShown != ((CupertinoScrollbar)oldWidget).isAlwaysShown) {
if (widget.isAlwaysShown == true) {
D.assert(widget.controller != null);
_fadeoutAnimationController.animateTo(1.0f);
} else {
_fadeoutAnimationController.reverse();
}
}
}
public ScrollbarPainter _buildCupertinoScrollbarPainter(BuildContext context) {
return new ScrollbarPainter(
color: CupertinoDynamicColor.resolve(CupertinoScrollbarUtils._kScrollbarColor, context),
textDirection: Directionality.of(context),
thickness: _thickness,
fadeoutOpacityAnimation: _fadeoutOpacityAnimation,
mainAxisMargin: CupertinoScrollbarUtils._kScrollbarMainAxisMargin,
crossAxisMargin: CupertinoScrollbarUtils._kScrollbarCrossAxisMargin,
radius: _radius,
padding: MediaQuery.of(context).padding,
minLength: CupertinoScrollbarUtils._kScrollbarMinLength,
minOverscrollLength: CupertinoScrollbarUtils._kScrollbarMinOverscrollLength
);
}
void _dragScrollbar(float primaryDelta) {
D.assert(_currentController != null);
float scrollOffsetLocal = _painter.getTrackToScroll(primaryDelta);
float scrollOffsetGlobal = scrollOffsetLocal + _currentController.position.pixels;
if (_drag == null) {
_drag = _currentController.position.drag(
new DragStartDetails(
globalPosition: new Offset(0.0f, scrollOffsetGlobal)
),
() =>{}
);
} else {
_drag.update(
new DragUpdateDetails(
delta: new Offset(0.0f, -scrollOffsetLocal),
primaryDelta: (float?) -1f * scrollOffsetLocal,
globalPosition: new Offset(0.0f, scrollOffsetGlobal)
)
);
}
}
void _startFadeoutTimer() {
if (!widget.isAlwaysShown) {
_fadeoutTimer?.cancel();
_fadeoutTimer = Timer.create(CupertinoScrollbarUtils._kScrollbarTimeToFade, () => {
_fadeoutAnimationController.reverse();
_fadeoutTimer = null;
});
}
}
bool _checkVertical() {
return _currentController.position.axis() == Axis.vertical;
}
float _pressStartY = 0.0f;
void _handleLongPressStart(LongPressStartDetails details) {
_currentController = _controller;
if (!_checkVertical()) {
return;
}
_pressStartY = details.localPosition.dy;
_fadeoutTimer?.cancel();
_fadeoutAnimationController.forward();
_dragScrollbar(details.localPosition.dy);
_dragScrollbarPositionY = details.localPosition.dy;
}
void _handleLongPress() {
if (!_checkVertical()) {
return;
}
_fadeoutTimer?.cancel();
_thicknessAnimationController.forward().then(
(_) => { return; }
);
}
void _handleLongPressMoveUpdate(LongPressMoveUpdateDetails details) {
if (!_checkVertical()) {
return;
}
_dragScrollbar(details.localPosition.dy - _dragScrollbarPositionY);
_dragScrollbarPositionY = details.localPosition.dy;
}
void _handleLongPressEnd(LongPressEndDetails details) {
if (!_checkVertical()) {
return;
}
_handleDragScrollEnd(details.velocity.pixelsPerSecond.dy);
if (details.velocity.pixelsPerSecond.dy.abs() < 10 &&
(details.localPosition.dy - _pressStartY).abs() > 0) {
//HapticFeedback.mediumImpact();
}
_currentController = null;
}
void _handleDragScrollEnd(float trackVelocityY) {
_startFadeoutTimer();
_thicknessAnimationController.reverse();
_dragScrollbarPositionY = 0.0f;
float scrollVelocityY = _painter.getTrackToScroll(trackVelocityY);
_drag?.end(new DragEndDetails(
primaryVelocity: -scrollVelocityY,
velocity: new Velocity(
pixelsPerSecond: new Offset(
0.0f,
-scrollVelocityY
)
)
));
_drag = null;
}
bool _handleScrollNotification(ScrollNotification notification) {
ScrollMetrics metrics = notification.metrics;
if (metrics.maxScrollExtent <= metrics.minScrollExtent) {
return false;
}
if (notification is ScrollUpdateNotification ||
notification is OverscrollNotification) {
if (_fadeoutAnimationController.status != AnimationStatus.forward) {
_fadeoutAnimationController.forward();
}
_fadeoutTimer?.cancel();
_painter.update(notification.metrics, notification.metrics.axisDirection);
} else if (notification is ScrollEndNotification) {
if (_dragScrollbarPositionY == null) {
_startFadeoutTimer();
}
}
return false;
}
Dictionary<Type, GestureRecognizerFactory> _gestures {
get {
Dictionary<Type, GestureRecognizerFactory> gestures =
new Dictionary<Type, GestureRecognizerFactory>();
gestures[typeof(_ThumbPressGestureRecognizer)] =
new GestureRecognizerFactoryWithHandlers<_ThumbPressGestureRecognizer>(
() => new _ThumbPressGestureRecognizer(
debugOwner: this,
customPaintKey: _customPaintKey
),
(_ThumbPressGestureRecognizer instance)=> {
instance.onLongPressStart = _handleLongPressStart;
instance.onLongPress = _handleLongPress;
instance.onLongPressMoveUpdate = _handleLongPressMoveUpdate;
instance.onLongPressEnd = _handleLongPressEnd;
}
);
return gestures;
}
}
public override void dispose() {
_fadeoutAnimationController.dispose();
_thicknessAnimationController.dispose();
_fadeoutTimer?.cancel();
_painter.dispose();
base.dispose();
}
ScrollbarPainter _buildCupertinoScrollbarPainter() {
return new ScrollbarPainter(
color: CupertinoScrollbarUtils._kScrollbarColor,
textDirection: _textDirection,
thickness: CupertinoScrollbarUtils._kScrollbarThickness,
fadeoutOpacityAnimation: _fadeoutOpacityAnimation,
mainAxisMargin: CupertinoScrollbarUtils._kScrollbarMainAxisMargin,
crossAxisMargin: CupertinoScrollbarUtils._kScrollbarCrossAxisMargin,
radius: CupertinoScrollbarUtils._kScrollbarRadius,
minLength: CupertinoScrollbarUtils._kScrollbarMinLength,
minOverscrollLength: CupertinoScrollbarUtils._kScrollbarMinOverscrollLength
);
}
public override Widget build(BuildContext context) {
return new NotificationListener<ScrollNotification>(
onNotification: _handleScrollNotification,
child: new RepaintBoundary(
child: new RawGestureDetector(
gestures: _gestures,
child: new CustomPaint(
key: _customPaintKey,
foregroundPainter: _painter,
child: new RepaintBoundary(child: widget.child)
)
)
)
);
}
}
public class _ThumbPressGestureRecognizer : LongPressGestureRecognizer {
public _ThumbPressGestureRecognizer(
float? postAcceptSlopTolerance = null,
PointerDeviceKind kind = default,
object debugOwner = null,
GlobalKey customPaintKey = null
) : base(
postAcceptSlopTolerance: postAcceptSlopTolerance,
kind: kind,
debugOwner: debugOwner,
duration: TimeSpan.FromMilliseconds(100)
) {
_customPaintKey = customPaintKey;
}
public readonly GlobalKey _customPaintKey;
protected override bool isPointerAllowed(PointerDownEvent _event) {
if (!CupertinoScrollbarUtils._hitTestInteractive(_customPaintKey, _event.position)) {
return false;
}
return base.isPointerAllowed(_event);
}
}
}

468
com.unity.uiwidgets/Runtime/cupertino/slider.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.cupertino {
class SliderUtils {
public const float _kPadding = 8.0f;
public static readonly Color _kTrackColor = new Color(0xFFB5B5B5);
public const float _kSliderHeight = 2.0f * (CupertinoThumbPainter.radius + _kPadding);
public const float _kSliderWidth = 176.0f; // Matches Material Design slider.
public static readonly TimeSpan _kDiscreteTransitionDuration = TimeSpan.FromMilliseconds(500);
public const float _kAdjustmentUnit = 0.1f; // Matches iOS implementation of material slider.
}
public class CupertinoSlider : StatefulWidget {
public CupertinoSlider(
Key key = null,
float? value = null,
ValueChanged<float> onChanged = null,
ValueChanged<float> onChangeStart = null,
ValueChanged<float> onChangeEnd = null,
float min = 0.0f,
float max = 1.0f,
int? divisions = null,
Color activeColor = null,
Color thumbColor = null
) : base(key: key) {
D.assert(value != null);
D.assert(onChanged != null);
D.assert(value >= min && value <= max);
D.assert(divisions == null || divisions > 0);
this.value = value.Value;
this.onChanged = onChanged;
this.onChangeStart = onChangeStart;
this.onChangeEnd = onChangeEnd;
this.min = min;
this.max = max;
this.divisions = divisions;
this.activeColor = activeColor;
this.thumbColor = thumbColor ?? CupertinoColors.white;
}
public readonly float value;
public readonly ValueChanged<float> onChanged;
public readonly ValueChanged<float> onChangeStart;
public readonly ValueChanged<float> onChangeEnd;
public readonly float min;
public readonly float max;
public readonly int? divisions;
public readonly Color activeColor;
public readonly Color thumbColor;
public override State createState() {
return new _CupertinoSliderState();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FloatProperty("value", value));
properties.add(new FloatProperty("min", min));
properties.add(new FloatProperty("max", max));
}
}
class _CupertinoSliderState : TickerProviderStateMixin<CupertinoSlider> {
void _handleChanged(float value) {
D.assert(widget.onChanged != null);
float lerpValue = MathUtils.lerpNullableFloat(widget.min, widget.max, value);
if (lerpValue != widget.value) {
widget.onChanged(lerpValue);
}
}
void _handleDragStart(float value) {
D.assert(widget.onChangeStart != null);
widget.onChangeStart(MathUtils.lerpNullableFloat(widget.min, widget.max, value));
}
void _handleDragEnd(float value) {
D.assert(widget.onChangeEnd != null);
widget.onChangeEnd(MathUtils.lerpNullableFloat(widget.min, widget.max, value));
}
public override Widget build(BuildContext context) {
return new _CupertinoSliderRenderObjectWidget(
value: (widget.value - widget.min) / (widget.max - widget.min),
divisions: widget.divisions,
activeColor: CupertinoDynamicColor.resolve(
widget.activeColor ?? CupertinoTheme.of(context).primaryColor,
context
),
thumbColor: widget.thumbColor,
onChanged: widget.onChanged != null ? (ValueChanged<float>) _handleChanged : null,
onChangeStart: widget.onChangeStart != null ? (ValueChanged<float>) _handleDragStart : null,
onChangeEnd: widget.onChangeEnd != null ? (ValueChanged<float>) _handleDragEnd : null,
vsync: this
);
}
}
class _CupertinoSliderRenderObjectWidget : LeafRenderObjectWidget {
public _CupertinoSliderRenderObjectWidget(
Key key = null,
float? value = null,
int? divisions = null,
Color activeColor = null,
Color thumbColor = null,
ValueChanged<float> onChanged = null,
ValueChanged<float> onChangeStart = null,
ValueChanged<float> onChangeEnd = null,
TickerProvider vsync = null
) : base(key: key) {
this.value = value;
this.divisions = divisions;
this.activeColor = activeColor;
this.onChanged = onChanged;
this.onChangeStart = onChangeStart;
this.onChangeEnd = onChangeEnd;
this.vsync = vsync;
this.thumbColor = thumbColor;
}
public readonly float? value;
public readonly int? divisions;
public readonly Color activeColor;
public readonly Color thumbColor;
public readonly ValueChanged<float> onChanged;
public readonly ValueChanged<float> onChangeStart;
public readonly ValueChanged<float> onChangeEnd;
public readonly TickerProvider vsync;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderCupertinoSlider(
value: value ?? 0.0f,
divisions: divisions,
activeColor: activeColor,
thumbColor: CupertinoDynamicColor.resolve(thumbColor, context),
trackColor: CupertinoDynamicColor.resolve(CupertinoColors.systemFill, context),
onChanged: onChanged,
onChangeStart: onChangeStart,
onChangeEnd: onChangeEnd,
vsync: vsync,
textDirection: Directionality.of(context)
);
}
public override void updateRenderObject(BuildContext context, RenderObject _renderObject) {
_RenderCupertinoSlider renderObject = _renderObject as _RenderCupertinoSlider;
renderObject.value = value ?? 0.0f;
renderObject.divisions = divisions;
renderObject.activeColor = activeColor;
renderObject.thumbColor = CupertinoDynamicColor.resolve(thumbColor, context);
renderObject.trackColor = CupertinoDynamicColor.resolve(CupertinoColors.systemFill, context);
renderObject.onChanged = onChanged;
renderObject.onChangeStart = onChangeStart;
renderObject.onChangeEnd = onChangeEnd;
renderObject.textDirection = Directionality.of(context);
}
}
class _RenderCupertinoSlider : RenderConstrainedBox {
public _RenderCupertinoSlider(
float value,
int? divisions = null,
Color activeColor = null,
Color thumbColor = null,
Color trackColor = null,
ValueChanged<float> onChanged = null,
ValueChanged<float> onChangeStart = null,
ValueChanged<float> onChangeEnd = null,
TickerProvider vsync = null,
TextDirection? textDirection = null
) : base(additionalConstraints: BoxConstraints.tightFor(width: SliderUtils._kSliderWidth,
height: SliderUtils._kSliderHeight)) {
D.assert(value >= 0.0f && value <= 1.0f && value != null) ;
_value = value;
_divisions = divisions;
_activeColor = activeColor;
_thumbColor = thumbColor;
_trackColor = trackColor;
_onChanged = onChanged;
this.onChangeStart = onChangeStart;
this.onChangeEnd = onChangeEnd;
_textDirection = textDirection;
_drag = new HorizontalDragGestureRecognizer();
_drag.onStart = _handleDragStart;
_drag.onUpdate = _handleDragUpdate;
_drag.onEnd = _handleDragEnd;
_position = new AnimationController(
value: value,
duration: SliderUtils._kDiscreteTransitionDuration,
vsync: vsync
);
_position.addListener(markNeedsPaint);
}
public float value {
get { return _value; }
set {
D.assert(value >= 0.0f && value <= 1.0f);
if (value == _value) {
return;
}
_value = value;
if (divisions != null) {
_position.animateTo(value, curve: Curves.fastOutSlowIn);
}
else {
_position.setValue(value);
}
}
}
float _value;
public int? divisions {
get { return _divisions; }
set {
if (value == _divisions) {
return;
}
_divisions = value;
markNeedsPaint();
}
}
int? _divisions;
public Color activeColor {
get { return _activeColor; }
set {
if (value == _activeColor) {
return;
}
_activeColor = value;
markNeedsPaint();
}
}
Color _activeColor;
public Color thumbColor {
get {
return _thumbColor;
}
set {
if (value == _thumbColor)
return;
_thumbColor = value;
markNeedsPaint();
}
}
Color _thumbColor;
public Color trackColor {
get {
return _trackColor;
}
set {
if (value == _trackColor)
return;
_trackColor = value;
markNeedsPaint();
}
}
Color _trackColor;
public ValueChanged<float> onChanged {
get { return _onChanged; }
set {
if (value == _onChanged) {
return;
}
_onChanged = value;
}
}
ValueChanged<float> _onChanged;
public ValueChanged<float> onChangeStart;
public ValueChanged<float> onChangeEnd;
public TextDirection? textDirection {
get {
return _textDirection;
}
set {
D.assert(value != null);
if (_textDirection == value)
return;
_textDirection = value;
markNeedsPaint();
}
}
TextDirection? _textDirection;
AnimationController _position;
HorizontalDragGestureRecognizer _drag;
float _currentDragValue = 0.0f;
float _discretizedCurrentDragValue {
get {
float dragValue = _currentDragValue.clamp(0.0f, 1.0f);
if (divisions != null) {
dragValue = Mathf.Round(dragValue * divisions.Value) / divisions.Value;
}
return dragValue;
}
}
public float _trackLeft {
get { return SliderUtils._kPadding; }
}
public float _trackRight {
get { return size.width - SliderUtils._kPadding; }
}
float _thumbCenter {
get {
float visualPosition = 0.0f;
switch (textDirection) {
case TextDirection.rtl:
visualPosition = 1.0f - _value;
break;
case TextDirection.ltr:
visualPosition = _value;
break;
}
return MathUtils.lerpNullableFloat(_trackLeft + CupertinoThumbPainter.radius, _trackRight - CupertinoThumbPainter.radius, visualPosition);
}
}
public bool isInteractive {
get { return onChanged != null; }
}
void _handleDragStart(DragStartDetails details) {
_startInteraction(details.globalPosition);
}
void _handleDragUpdate(DragUpdateDetails details) {
if (isInteractive) {
float extent = Mathf.Max(SliderUtils._kPadding,
size.width - 2.0f * (SliderUtils._kPadding + CupertinoThumbPainter.radius));
float? valueDelta = details.primaryDelta / extent;
switch (textDirection) {
case TextDirection.rtl:
_currentDragValue -= valueDelta ?? 0.0f;
break;
case TextDirection.ltr:
_currentDragValue += valueDelta ?? 0.0f;
break;
}
onChanged(_discretizedCurrentDragValue);
}
}
void _handleDragEnd(DragEndDetails details) {
_endInteraction();
}
void _startInteraction(Offset globalPosition) {
if (isInteractive) {
if (onChangeStart != null) {
onChangeStart(_discretizedCurrentDragValue);
}
_currentDragValue = _value;
onChanged(_discretizedCurrentDragValue);
}
}
void _endInteraction() {
if (onChangeEnd != null) {
onChangeEnd(_discretizedCurrentDragValue);
}
_currentDragValue = 0.0f;
}
protected override bool hitTestSelf(Offset position) {
return (position.dx - _thumbCenter).abs() < CupertinoThumbPainter.radius + SliderUtils._kPadding;
}
public override void handleEvent(PointerEvent e, HitTestEntry entry) {
D.assert(debugHandleEvent(e, entry));
if (e is PointerDownEvent pointerDownEvent && isInteractive) {
_drag.addPointer(pointerDownEvent);
}
}
CupertinoThumbPainter _thumbPainter = new CupertinoThumbPainter();
public override void paint(PaintingContext context, Offset offset) {
float visualPosition = 0.0f;
Color leftColor = null ;
Color rightColor = null;
switch (textDirection) {
case TextDirection.rtl:
visualPosition = 1.0f - _position.value;
leftColor = _activeColor;
rightColor = trackColor;
break;
case TextDirection.ltr:
visualPosition = _position.value;
leftColor = trackColor;
rightColor = _activeColor;
break;
}
float trackCenter = offset.dy + size.height / 2.0f;
float trackLeft = offset.dx + _trackLeft;
float trackTop = trackCenter - 1.0f;
float trackBottom = trackCenter + 1.0f;
float trackRight = offset.dx + _trackRight;
float trackActive = offset.dx + _thumbCenter;
Canvas canvas = context.canvas;
if (visualPosition > 0.0f) {
Paint paint = new Paint();
paint.color = rightColor;
canvas.drawRRect(RRect.fromLTRBXY(trackLeft, trackTop, trackActive, trackBottom, 1.0f, 1.0f), paint);
}
if (visualPosition < 1.0f) {
Paint paint = new Paint();
paint.color = leftColor;
canvas.drawRRect(RRect.fromLTRBXY(trackActive, trackTop, trackRight, trackBottom, 1.0f, 1.0f), paint);
}
Offset thumbCenter = new Offset(trackActive, trackCenter);
new CupertinoThumbPainter(color: thumbColor).paint(canvas, Rect.fromCircle(center: thumbCenter, radius: CupertinoThumbPainter.radius));
}
}
}

448
com.unity.uiwidgets/Runtime/cupertino/switch.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.cupertino {
class CupertinoSwitchUtils {
public const float _kTrackWidth = 51.0f;
public const float _kTrackHeight = 31.0f;
public const float _kTrackRadius = _kTrackHeight / 2.0f;
public const float _kTrackInnerStart = _kTrackHeight / 2.0f;
public const float _kTrackInnerEnd = _kTrackWidth - _kTrackInnerStart;
public const float _kTrackInnerLength = _kTrackInnerEnd - _kTrackInnerStart;
public const float _kSwitchWidth = 59.0f;
public const float _kSwitchHeight = 39.0f;
public const float _kCupertinoSwitchDisabledOpacity = 0.5f;
public static readonly Color _kTrackColor = CupertinoColors.lightBackgroundGray;
public static readonly TimeSpan _kReactionDuration = TimeSpan.FromMilliseconds(300);
public static readonly TimeSpan _kToggleDuration = TimeSpan.FromMilliseconds(200);
}
public class CupertinoSwitch : StatefulWidget {
public CupertinoSwitch(
bool value,
ValueChanged<bool> onChanged,
Key key = null,
Color activeColor = null,
Color trackColor = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start
) : base(key: key) {
this.value = value;
this.onChanged = onChanged;
this.activeColor = activeColor;
this.trackColor = trackColor;
this.dragStartBehavior = dragStartBehavior;
}
public readonly bool value;
public readonly ValueChanged<bool> onChanged;
public readonly Color activeColor;
public readonly Color trackColor;
public readonly DragStartBehavior dragStartBehavior;
public override State createState() {
return new _CupertinoSwitchState();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FlagProperty("value", value: value, ifTrue: "on", ifFalse: "off", showName: true));
properties.add(new ObjectFlagProperty<ValueChanged<bool>>("onChanged", onChanged, ifNull: "disabled"));
}
}
class _CupertinoSwitchState : TickerProviderStateMixin<CupertinoSwitch> {
public TapGestureRecognizer _tap;
public HorizontalDragGestureRecognizer _drag;
AnimationController _positionController;
public CurvedAnimation position;
AnimationController _reactionController;
public Animation<float> _reaction;
bool isInteractive {
get {
return widget.onChanged != null;
}
}
bool needsPositionAnimation = false;
public override void initState() {
base.initState();
_tap = new TapGestureRecognizer();
_tap.onTapDown = _handleTapDown;
_tap.onTapUp = _handleTapUp;
_tap.onTap = _handleTap;
_tap.onTapCancel = _handleTapCancel;
_drag = new HorizontalDragGestureRecognizer();
_drag.onStart = _handleDragStart;
_drag.onUpdate = _handleDragUpdate;
_drag.onEnd = _handleDragEnd;
_drag.dragStartBehavior = widget.dragStartBehavior;
_positionController = new AnimationController(
duration: CupertinoSwitchUtils._kToggleDuration,
value: widget.value ? 1.0f : 0.0f,
vsync: this
);
position = new CurvedAnimation(
parent: _positionController,
curve: Curves.linear
);
_reactionController = new AnimationController(
duration: CupertinoSwitchUtils._kReactionDuration,
vsync: this
);
_reaction = new CurvedAnimation(
parent: _reactionController,
curve: Curves.ease
);
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
oldWidget = (CupertinoSwitch) oldWidget;
base.didUpdateWidget(oldWidget);
_drag.dragStartBehavior = widget.dragStartBehavior;
if (needsPositionAnimation || ((CupertinoSwitch) oldWidget).value != widget.value)
_resumePositionAnimation(isLinear: needsPositionAnimation);
}
void _resumePositionAnimation( bool isLinear = true ) {
needsPositionAnimation = false;
position.curve = isLinear ? null : Curves.ease;
position.reverseCurve = isLinear ? null : Curves.ease.flipped;
if (widget.value)
_positionController.forward();
else
_positionController.reverse();
}
void _handleTapDown(TapDownDetails details) {
if (isInteractive)
needsPositionAnimation = false;
_reactionController.forward();
}
void _handleTap() {
if (isInteractive) {
widget.onChanged(!widget.value);
}
}
void _handleTapUp(TapUpDetails details) {
if (isInteractive) {
needsPositionAnimation = false;
_reactionController.reverse();
}
}
void _handleTapCancel() {
if (isInteractive)
_reactionController.reverse();
}
void _handleDragStart(DragStartDetails details) {
if (isInteractive) {
needsPositionAnimation = false;
_reactionController.forward();
}
}
void _handleDragUpdate(DragUpdateDetails details) {
if (isInteractive) {
position.curve = null;
position.reverseCurve = null;
float? delta = details.primaryDelta / CupertinoSwitchUtils._kTrackInnerLength;
switch (Directionality.of(context)) {
case TextDirection.rtl:
_positionController.setValue( _positionController.value - delta ?? 0.0f);
break;
case TextDirection.ltr:
_positionController.setValue( _positionController.value + delta ?? 0.0f);
break;
}
}
}
void _handleDragEnd(DragEndDetails details) {
setState(()=> { needsPositionAnimation = true; });
if (position.value >= 0.5 != widget.value)
widget.onChanged(!widget.value);
_reactionController.reverse();
}
public override Widget build(BuildContext context) {
if (needsPositionAnimation)
_resumePositionAnimation();
return new Opacity(
opacity: widget.onChanged == null ? CupertinoSwitchUtils._kCupertinoSwitchDisabledOpacity : 1.0f,
child: new _CupertinoSwitchRenderObjectWidget(
value: widget.value,
activeColor: CupertinoDynamicColor.resolve(
widget.activeColor ?? CupertinoColors.systemGreen,
context
),
trackColor: CupertinoDynamicColor.resolve(widget.trackColor ?? CupertinoColors.secondarySystemFill, context),
onChanged: widget.onChanged,
textDirection: Directionality.of(context),
state: this
)
);
}
public override void dispose() {
_tap.dispose();
_drag.dispose();
_positionController.dispose();
_reactionController.dispose();
base.dispose();
}
}
class _CupertinoSwitchRenderObjectWidget : LeafRenderObjectWidget {
public _CupertinoSwitchRenderObjectWidget(
Key key = null,
bool value = false,
Color activeColor = null,
Color trackColor = null,
ValueChanged<bool> onChanged = null,
TextDirection? textDirection = null,
_CupertinoSwitchState state = null
) : base(key: key) {
this.value = value;
this.activeColor = activeColor;
this.trackColor = trackColor;
this.onChanged = onChanged;
this.state = state;
this.textDirection = textDirection;
}
public readonly bool value;
public readonly Color activeColor;
public readonly Color trackColor;
public readonly ValueChanged<bool> onChanged;
public readonly _CupertinoSwitchState state;
public readonly TextDirection? textDirection;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderCupertinoSwitch(
value: value,
activeColor: activeColor,
trackColor: trackColor,
onChanged: onChanged,
textDirection: textDirection,
state: state
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
var _renderObject = renderObject as _RenderCupertinoSwitch;
_renderObject.value = value;
_renderObject.activeColor = activeColor;
_renderObject.trackColor = trackColor;
_renderObject.onChanged = onChanged;
_renderObject.textDirection = textDirection;
}
}
class _RenderCupertinoSwitch : RenderConstrainedBox {
public _RenderCupertinoSwitch(
bool value,
Color activeColor,
Color trackColor = null,
TextDirection? textDirection = null,
ValueChanged<bool> onChanged = null,
_CupertinoSwitchState state = null
) : base(additionalConstraints: BoxConstraints.tightFor(
width: CupertinoSwitchUtils._kSwitchWidth,
height: CupertinoSwitchUtils._kSwitchHeight)
) {
D.assert(state != null);
_value = value;
_activeColor = activeColor;
_trackColor = trackColor;
_onChanged = onChanged;
_textDirection = textDirection;
_state = state;
state.position.addListener(markNeedsPaint);
state._reaction.addListener(markNeedsPaint);
}
AnimationController _positionController;
CurvedAnimation _position;
AnimationController _reactionController;
Animation<float> _reaction;
public readonly _CupertinoSwitchState _state;
public bool value {
get { return _value; }
set {
D.assert(value != null);
if (value == _value)
return;
_value = value;
//markNeedsSemanticsUpdate();
}
}
bool _value;
public Color activeColor {
get { return _activeColor; }
set {
D.assert(value != null);
if (value == _activeColor) {
return;
}
_activeColor = value;
markNeedsPaint();
}
}
Color _activeColor;
public Color trackColor {
get { return _trackColor; }
set {
D.assert(value != null);
if (value == _trackColor)
return;
_trackColor = value;
markNeedsPaint();
}
}
Color _trackColor;
public ValueChanged<bool> onChanged {
get { return _onChanged; }
set {
if (value == _onChanged) {
return;
}
bool wasInteractive = isInteractive;
_onChanged = value;
if (wasInteractive != isInteractive) {
markNeedsPaint();
}
}
}
ValueChanged<bool> _onChanged;
public TextDirection? textDirection {
get { return _textDirection; }
set {
if (_textDirection == value) {
return;
}
_textDirection = value;
markNeedsPaint();
}
}
TextDirection? _textDirection;
public bool isInteractive {
get { return onChanged != null; }
}
protected override bool hitTestSelf(Offset position) {
return true;
}
public override void handleEvent(PointerEvent evt, HitTestEntry entry) {
D.assert(debugHandleEvent(evt, entry));
if (evt is PointerDownEvent && isInteractive) {
_state._drag.addPointer((PointerDownEvent) evt);
_state._tap.addPointer((PointerDownEvent) evt);
}
}
public override void paint(PaintingContext context, Offset offset) {
Canvas canvas = context.canvas;
float currentValue = _state.position.value;
float currentReactionValue = _state._reaction.value;
float visualPosition = 0.0f;
switch (textDirection) {
case TextDirection.rtl:
visualPosition = 1.0f - currentValue;
break;
case TextDirection.ltr:
visualPosition = currentValue;
break;
}
Paint paint = new Paint() {color = Color.lerp(trackColor, activeColor, currentValue)};
Rect trackRect = Rect.fromLTWH(
offset.dx + (size.width - CupertinoSwitchUtils._kTrackWidth) / 2.0f,
offset.dy + (size.height - CupertinoSwitchUtils._kTrackHeight) / 2.0f,
CupertinoSwitchUtils._kTrackWidth,
CupertinoSwitchUtils._kTrackHeight
);
RRect trackRRect = RRect.fromRectAndRadius(trackRect, Radius.circular(CupertinoSwitchUtils._kTrackRadius));
canvas.drawRRect(trackRRect, paint);
float currentThumbExtension = CupertinoThumbPainter.extension * currentReactionValue;
float thumbLeft = MathUtils.lerpNullableFloat(
trackRect.left + CupertinoSwitchUtils._kTrackInnerStart - CupertinoThumbPainter.radius,
trackRect.left + CupertinoSwitchUtils._kTrackInnerEnd - CupertinoThumbPainter.radius -
currentThumbExtension,
visualPosition
);
float thumbRight = MathUtils.lerpNullableFloat(
trackRect.left + CupertinoSwitchUtils._kTrackInnerStart + CupertinoThumbPainter.radius +
currentThumbExtension,
trackRect.left + CupertinoSwitchUtils._kTrackInnerEnd + CupertinoThumbPainter.radius,
visualPosition
);
float thumbCenterY = offset.dy + size.height / 2.0f;
Rect thumbBounds = Rect.fromLTRB(
thumbLeft,
thumbCenterY - CupertinoThumbPainter.radius,
thumbRight,
thumbCenterY + CupertinoThumbPainter.radius
);
context.pushClipRRect(needsCompositing, Offset.zero, thumbBounds, trackRRect,
(PaintingContext innerContext, Offset offset1) => {
CupertinoThumbPainter.switchThumb().paint(innerContext.canvas, thumbBounds);
});
}
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(
new FlagProperty("value", value: value, ifTrue: "checked", ifFalse: "unchecked", showName: true));
description.add(new FlagProperty("isInteractive", value: isInteractive, ifTrue: "enabled",
ifFalse: "disabled",
showName: true, defaultValue: true));
}
}
}

690
com.unity.uiwidgets/Runtime/material/colors.cs


using System.Collections.Generic;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
namespace uiwidgets {
public class MaterialColor : ColorSwatch<uint> {
public MaterialColor(uint primary, Dictionary<uint, Color> swatch) : base(primary, swatch) {
}
public Color shade50 {
get => this[50];
}
public Color shade100 {
get => this[100];
}
public Color shade200 {
get => this[200];
}
public Color shade300 {
get => this[300];
}
public Color shade400 {
get => this[400];
}
public Color shade500 {
get => this[500];
}
public Color shade600 {
get => this[600];
}
public Color shade700 {
get => this[700];
}
public Color shade800 {
get => this[800];
}
public Color shade900 {
get => this[900];
}
}
public class MaterialAccentColor : ColorSwatch<uint> {
public MaterialAccentColor(uint primary, Dictionary<uint, Color> swatch) : base(primary, swatch) {
}
public Color shade50 {
get => this[50];
}
public Color shade100 {
get => this[100];
}
public Color shade200 {
get => this[200];
}
public Color shade400 {
get => this[400];
}
public Color shade700 {
get => this[700];
}
}
public class Colors {
private Colors() {
}
public static Color transparent = new Color(0x00000000);
public static Color black = new Color(0xFF000000);
public static Color black87 = new Color(0xDD000000);
public static Color black54 = new Color(0x8A000000);
public static Color black45 = new Color(0x73000000);
public static Color black38 = new Color(0x61000000);
public static Color black26 = new Color(0x42000000);
public static Color black12 = new Color(0x1F000000);
public static Color white = new Color(0xFFFFFFFF);
public static Color white70 = new Color(0xB3FFFFFF);
public static Color white60 = new Color(0x99FFFFFF);
public static Color white54 = new Color(0x8AFFFFFF);
public static Color white38 = new Color(0x62FFFFFF);
public static Color white30 = new Color(0x4DFFFFFF);
public static Color white24 = new Color(0x3DFFFFFF);
public static Color white12 = new Color(0x1FFFFFFF);
public static Color white10 = new Color(0x1AFFFFFF);
public static readonly MaterialColor red = new MaterialColor(
_redPrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFFFEBEE)},
{100, new Color(0xFFFFCDD2)},
{200, new Color(0xFFEF9A9A)},
{300, new Color(0xFFE57373)},
{400, new Color(0xFFEF5350)},
{500, new Color(_redPrimaryValue)},
{600, new Color(0xFFE53935)},
{700, new Color(0xFFD32F2F)},
{800, new Color(0xFFC62828)},
{900, new Color(0xFFB71C1C)},
}
);
const uint _redPrimaryValue = 0xFFF44336;
public static readonly MaterialAccentColor redAccent = new MaterialAccentColor(
_redAccentValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFFFF8A80)},
{200, new Color(_redAccentValue)},
{400, new Color(0xFFFF1744)},
{700, new Color(0xFFD50000)},
}
);
const uint _redAccentValue = 0xFFFF5252;
public static readonly MaterialColor pink = new MaterialColor(
_pinkPrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFFCE4EC)},
{100, new Color(0xFFF8BBD0)},
{200, new Color(0xFFF48FB1)},
{300, new Color(0xFFF06292)},
{400, new Color(0xFFEC407A)},
{500, new Color(_pinkPrimaryValue)},
{600, new Color(0xFFD81B60)},
{700, new Color(0xFFC2185B)},
{800, new Color(0xFFAD1457)},
{900, new Color(0xFF880E4F)},
}
);
const uint _pinkPrimaryValue = 0xFFE91E63;
public static readonly MaterialAccentColor pinkAccent = new MaterialAccentColor(
_pinkAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFFFF80AB)},
{200, new Color(_pinkAccentPrimaryValue)},
{400, new Color(0xFFF50057)},
{700, new Color(0xFFC51162)},
}
);
const uint _pinkAccentPrimaryValue = 0xFFFF4081;
public static readonly MaterialColor purple = new MaterialColor(
_purplePrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFF3E5F5)},
{100, new Color(0xFFE1BEE7)},
{200, new Color(0xFFCE93D8)},
{300, new Color(0xFFBA68C8)},
{400, new Color(0xFFAB47BC)},
{500, new Color(_purplePrimaryValue)},
{600, new Color(0xFF8E24AA)},
{700, new Color(0xFF7B1FA2)},
{800, new Color(0xFF6A1B9A)},
{900, new Color(0xFF4A148C)},
}
);
const uint _purplePrimaryValue = 0xFF9C27B0;
public static readonly MaterialAccentColor purpleAccent = new MaterialAccentColor(
_purpleAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFFEA80FC)},
{200, new Color(_purpleAccentPrimaryValue)},
{400, new Color(0xFFD500F9)},
{700, new Color(0xFFAA00FF)},
}
);
const uint _purpleAccentPrimaryValue = 0xFFE040FB;
public static readonly MaterialColor deepPurple = new MaterialColor(
_deepPurplePrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFEDE7F6)},
{100, new Color(0xFFD1C4E9)},
{200, new Color(0xFFB39DDB)},
{300, new Color(0xFF9575CD)},
{400, new Color(0xFF7E57C2)},
{500, new Color(_deepPurplePrimaryValue)},
{600, new Color(0xFF5E35B1)},
{700, new Color(0xFF512DA8)},
{800, new Color(0xFF4527A0)},
{900, new Color(0xFF311B92)},
}
);
const uint _deepPurplePrimaryValue = 0xFF673AB7;
public static readonly MaterialAccentColor deepPurpleAccent = new MaterialAccentColor(
_deepPurpleAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFFB388FF)},
{200, new Color(_deepPurpleAccentPrimaryValue)},
{400, new Color(0xFF651FFF)},
{700, new Color(0xFF6200EA)},
}
);
const uint _deepPurpleAccentPrimaryValue = 0xFF7C4DFF;
public static readonly MaterialColor indigo = new MaterialColor(
_indigoPrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFE8EAF6)},
{100, new Color(0xFFC5CAE9)},
{200, new Color(0xFF9FA8DA)},
{300, new Color(0xFF7986CB)},
{400, new Color(0xFF5C6BC0)},
{500, new Color(_indigoPrimaryValue)},
{600, new Color(0xFF3949AB)},
{700, new Color(0xFF303F9F)},
{800, new Color(0xFF283593)},
{900, new Color(0xFF1A237E)},
}
);
const uint _indigoPrimaryValue = 0xFF3F51B5;
public static readonly MaterialAccentColor indigoAccent = new MaterialAccentColor(
_indigoAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFF8C9EFF)},
{200, new Color(_indigoAccentPrimaryValue)},
{400, new Color(0xFF3D5AFE)},
{700, new Color(0xFF304FFE)},
}
);
const uint _indigoAccentPrimaryValue = 0xFF536DFE;
public static readonly MaterialColor blue = new MaterialColor(
_bluePrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFE3F2FD)},
{100, new Color(0xFFBBDEFB)},
{200, new Color(0xFF90CAF9)},
{300, new Color(0xFF64B5F6)},
{400, new Color(0xFF42A5F5)},
{500, new Color(_bluePrimaryValue)},
{600, new Color(0xFF1E88E5)},
{700, new Color(0xFF1976D2)},
{800, new Color(0xFF1565C0)},
{900, new Color(0xFF0D47A1)},
}
);
const uint _bluePrimaryValue = 0xFF2196F3;
public static readonly MaterialAccentColor blueAccent = new MaterialAccentColor(
_blueAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFF82B1FF)},
{200, new Color(_blueAccentPrimaryValue)},
{400, new Color(0xFF2979FF)},
{700, new Color(0xFF2962FF)},
}
);
const uint _blueAccentPrimaryValue = 0xFF448AFF;
public static readonly MaterialColor lightBlue = new MaterialColor(
_lightBluePrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFE1F5FE)},
{100, new Color(0xFFB3E5FC)},
{200, new Color(0xFF81D4FA)},
{300, new Color(0xFF4FC3F7)},
{400, new Color(0xFF29B6F6)},
{500, new Color(_lightBluePrimaryValue)},
{600, new Color(0xFF039BE5)},
{700, new Color(0xFF0288D1)},
{800, new Color(0xFF0277BD)},
{900, new Color(0xFF01579B)},
}
);
const uint _lightBluePrimaryValue = 0xFF03A9F4;
public static readonly MaterialAccentColor lightBlueAccent = new MaterialAccentColor(
_lightBlueAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFF80D8FF)},
{200, new Color(_lightBlueAccentPrimaryValue)},
{400, new Color(0xFF00B0FF)},
{700, new Color(0xFF0091EA)},
}
);
const uint _lightBlueAccentPrimaryValue = 0xFF40C4FF;
public static readonly MaterialColor cyan = new MaterialColor(
_cyanPrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFE0F7FA)},
{100, new Color(0xFFB2EBF2)},
{200, new Color(0xFF80DEEA)},
{300, new Color(0xFF4DD0E1)},
{400, new Color(0xFF26C6DA)},
{500, new Color(_cyanPrimaryValue)},
{600, new Color(0xFF00ACC1)},
{700, new Color(0xFF0097A7)},
{800, new Color(0xFF00838F)},
{900, new Color(0xFF006064)},
}
);
const uint _cyanPrimaryValue = 0xFF00BCD4;
public static readonly MaterialAccentColor cyanAccent = new MaterialAccentColor(
_cyanAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFF84FFFF)},
{200, new Color(_cyanAccentPrimaryValue)},
{400, new Color(0xFF00E5FF)},
{700, new Color(0xFF00B8D4)},
}
);
const uint _cyanAccentPrimaryValue = 0xFF18FFFF;
public static readonly MaterialColor teal = new MaterialColor(
_tealPrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFE0F2F1)},
{100, new Color(0xFFB2DFDB)},
{200, new Color(0xFF80CBC4)},
{300, new Color(0xFF4DB6AC)},
{400, new Color(0xFF26A69A)},
{500, new Color(_tealPrimaryValue)},
{600, new Color(0xFF00897B)},
{700, new Color(0xFF00796B)},
{800, new Color(0xFF00695C)},
{900, new Color(0xFF004D40)},
}
);
const uint _tealPrimaryValue = 0xFF009688;
public static readonly MaterialAccentColor tealAccent = new MaterialAccentColor(
_tealAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFFA7FFEB)},
{200, new Color(_tealAccentPrimaryValue)},
{400, new Color(0xFF1DE9B6)},
{700, new Color(0xFF00BFA5)},
}
);
const uint _tealAccentPrimaryValue = 0xFF64FFDA;
public static readonly MaterialColor green = new MaterialColor(
_greenPrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFE8F5E9)},
{100, new Color(0xFFC8E6C9)},
{200, new Color(0xFFA5D6A7)},
{300, new Color(0xFF81C784)},
{400, new Color(0xFF66BB6A)},
{500, new Color(_greenPrimaryValue)},
{600, new Color(0xFF43A047)},
{700, new Color(0xFF388E3C)},
{800, new Color(0xFF2E7D32)},
{900, new Color(0xFF1B5E20)},
}
);
const uint _greenPrimaryValue = 0xFF4CAF50;
public static readonly MaterialAccentColor greenAccent = new MaterialAccentColor(
_greenAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFFB9F6CA)},
{200, new Color(_greenAccentPrimaryValue)},
{400, new Color(0xFF00E676)},
{700, new Color(0xFF00C853)},
}
);
const uint _greenAccentPrimaryValue = 0xFF69F0AE;
public static readonly MaterialColor lightGreen = new MaterialColor(
_lightGreenPrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFF1F8E9)},
{100, new Color(0xFFDCEDC8)},
{200, new Color(0xFFC5E1A5)},
{300, new Color(0xFFAED581)},
{400, new Color(0xFF9CCC65)},
{500, new Color(_lightGreenPrimaryValue)},
{600, new Color(0xFF7CB342)},
{700, new Color(0xFF689F38)},
{800, new Color(0xFF558B2F)},
{900, new Color(0xFF33691E)},
}
);
const uint _lightGreenPrimaryValue = 0xFF8BC34A;
public static readonly MaterialAccentColor lightGreenAccent = new MaterialAccentColor(
_lightGreenAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFFCCFF90)},
{200, new Color(_lightGreenAccentPrimaryValue)},
{400, new Color(0xFF76FF03)},
{700, new Color(0xFF64DD17)},
}
);
const uint _lightGreenAccentPrimaryValue = 0xFFB2FF59;
public static readonly MaterialColor lime = new MaterialColor(
_limePrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFF9FBE7)},
{100, new Color(0xFFF0F4C3)},
{200, new Color(0xFFE6EE9C)},
{300, new Color(0xFFDCE775)},
{400, new Color(0xFFD4E157)},
{500, new Color(_limePrimaryValue)},
{600, new Color(0xFFC0CA33)},
{700, new Color(0xFFAFB42B)},
{800, new Color(0xFF9E9D24)},
{900, new Color(0xFF827717)},
}
);
const uint _limePrimaryValue = 0xFFCDDC39;
public static readonly MaterialAccentColor limeAccent = new MaterialAccentColor(
_limeAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFFF4FF81)},
{200, new Color(_limeAccentPrimaryValue)},
{400, new Color(0xFFC6FF00)},
{700, new Color(0xFFAEEA00)},
}
);
const uint _limeAccentPrimaryValue = 0xFFEEFF41;
public static readonly MaterialColor yellow = new MaterialColor(
_yellowPrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFFFFDE7)},
{100, new Color(0xFFFFF9C4)},
{200, new Color(0xFFFFF59D)},
{300, new Color(0xFFFFF176)},
{400, new Color(0xFFFFEE58)},
{500, new Color(_yellowPrimaryValue)},
{600, new Color(0xFFFDD835)},
{700, new Color(0xFFFBC02D)},
{800, new Color(0xFFF9A825)},
{900, new Color(0xFFF57F17)},
}
);
const uint _yellowPrimaryValue = 0xFFFFEB3B;
public static readonly MaterialAccentColor yellowAccent = new MaterialAccentColor(
_yellowAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFFFFFF8D)},
{200, new Color(_yellowAccentPrimaryValue)},
{400, new Color(0xFFFFEA00)},
{700, new Color(0xFFFFD600)},
}
);
const uint _yellowAccentPrimaryValue = 0xFFFFFF00;
public static readonly MaterialColor amber = new MaterialColor(
_amberPrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFFFF8E1)},
{100, new Color(0xFFFFECB3)},
{200, new Color(0xFFFFE082)},
{300, new Color(0xFFFFD54F)},
{400, new Color(0xFFFFCA28)},
{500, new Color(_amberPrimaryValue)},
{600, new Color(0xFFFFB300)},
{700, new Color(0xFFFFA000)},
{800, new Color(0xFFFF8F00)},
{900, new Color(0xFFFF6F00)},
}
);
const uint _amberPrimaryValue = 0xFFFFC107;
public static readonly MaterialAccentColor amberAccent = new MaterialAccentColor(
_amberAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFFFFE57F)},
{200, new Color(_amberAccentPrimaryValue)},
{400, new Color(0xFFFFC400)},
{700, new Color(0xFFFFAB00)},
}
);
const uint _amberAccentPrimaryValue = 0xFFFFD740;
public static readonly MaterialColor orange = new MaterialColor(
_orangePrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFFFF3E0)},
{100, new Color(0xFFFFE0B2)},
{200, new Color(0xFFFFCC80)},
{300, new Color(0xFFFFB74D)},
{400, new Color(0xFFFFA726)},
{500, new Color(_orangePrimaryValue)},
{600, new Color(0xFFFB8C00)},
{700, new Color(0xFFF57C00)},
{800, new Color(0xFFEF6C00)},
{900, new Color(0xFFE65100)},
}
);
const uint _orangePrimaryValue = 0xFFFF9800;
public static readonly MaterialAccentColor orangeAccent = new MaterialAccentColor(
_orangeAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFFFFD180)},
{200, new Color(_orangeAccentPrimaryValue)},
{400, new Color(0xFFFF9100)},
{700, new Color(0xFFFF6D00)},
}
);
const uint _orangeAccentPrimaryValue = 0xFFFFAB40;
public static readonly MaterialColor deepOrange = new MaterialColor(
_deepOrangePrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFFBE9E7)},
{100, new Color(0xFFFFCCBC)},
{200, new Color(0xFFFFAB91)},
{300, new Color(0xFFFF8A65)},
{400, new Color(0xFFFF7043)},
{500, new Color(_deepOrangePrimaryValue)},
{600, new Color(0xFFF4511E)},
{700, new Color(0xFFE64A19)},
{800, new Color(0xFFD84315)},
{900, new Color(0xFFBF360C)},
}
);
const uint _deepOrangePrimaryValue = 0xFFFF5722;
public static readonly MaterialAccentColor deepOrangeAccent = new MaterialAccentColor(
_deepOrangeAccentPrimaryValue,
new Dictionary<uint, Color>() {
{100, new Color(0xFFFF9E80)},
{200, new Color(_deepOrangeAccentPrimaryValue)},
{400, new Color(0xFFFF3D00)},
{700, new Color(0xFFDD2C00)},
}
);
const uint _deepOrangeAccentPrimaryValue = 0xFFFF6E40;
public static readonly MaterialColor brown = new MaterialColor(
_brownPrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFEFEBE9)},
{100, new Color(0xFFD7CCC8)},
{200, new Color(0xFFBCAAA4)},
{300, new Color(0xFFA1887F)},
{400, new Color(0xFF8D6E63)},
{500, new Color(_brownPrimaryValue)},
{600, new Color(0xFF6D4C41)},
{700, new Color(0xFF5D4037)},
{800, new Color(0xFF4E342E)},
{900, new Color(0xFF3E2723)},
}
);
const uint _brownPrimaryValue = 0xFF795548;
public static readonly MaterialColor grey = new MaterialColor(
_greyPrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFFAFAFA)},
{100, new Color(0xFFF5F5F5)},
{200, new Color(0xFFEEEEEE)},
{300, new Color(0xFFE0E0E0)},
{350, new Color(0xFFD6D6D6)},
{400, new Color(0xFFBDBDBD)},
{500, new Color(_greyPrimaryValue)},
{600, new Color(0xFF757575)},
{700, new Color(0xFF616161)},
{800, new Color(0xFF424242)},
{850, new Color(0xFF303030)},
{900, new Color(0xFF212121)},
}
);
const uint _greyPrimaryValue = 0xFF9E9E9E;
public static readonly MaterialColor blueGrey = new MaterialColor(
_blueGreyPrimaryValue,
new Dictionary<uint, Color>() {
{50, new Color(0xFFECEFF1)},
{100, new Color(0xFFCFD8DC)},
{200, new Color(0xFFB0BEC5)},
{300, new Color(0xFF90A4AE)},
{400, new Color(0xFF78909C)},
{500, new Color(_blueGreyPrimaryValue)},
{600, new Color(0xFF546E7A)},
{700, new Color(0xFF455A64)},
{800, new Color(0xFF37474F)},
{900, new Color(0xFF263238)},
}
);
const uint _blueGreyPrimaryValue = 0xFF607D8B;
public static readonly List<MaterialColor> primaries = new List<MaterialColor>() {
red,
pink,
purple,
deepPurple,
indigo,
blue,
lightBlue,
cyan,
teal,
green,
lightGreen,
lime,
yellow,
amber,
orange,
deepOrange,
brown,
blueGrey
};
public static readonly List<MaterialAccentColor> accents = new List<MaterialAccentColor>() {
redAccent,
pinkAccent,
purpleAccent,
deepPurpleAccent,
indigoAccent,
blueAccent,
lightBlueAccent,
cyanAccent,
tealAccent,
greenAccent,
lightGreenAccent,
limeAccent,
yellowAccent,
amberAccent,
orangeAccent,
deepOrangeAccent,
};
}
}

11
com.unity.uiwidgets/Runtime/material/colors.cs.meta


fileFormatVersion: 2
guid: 2f6601e4d6a788a458d2f9e1d06fa1ea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

28
com.unity.uiwidgets/Runtime/material/constants.cs


using System;
using Unity.UIWidgets.painting;
namespace Unity.UIWidgets.material {
public partial class material_ {
public const float kMinInteractiveDimension = 48.0f;
public const float kToolbarHeight = 56.0f;
public const float kBottomNavigationBarHeight = 56.0f;
public const float kTextTabBarHeight = kMinInteractiveDimension;
public static readonly TimeSpan kThemeChangeDuration = new TimeSpan(0, 0, 0, 0, 200);
public const float kRadialReactionRadius = 20.0f;
public static readonly TimeSpan kRadialReactionDuration = new TimeSpan(0, 0, 0, 0, 100);
public const int kRadialReactionAlpha = 0x1F;
public static readonly TimeSpan kTabScrollDuration = new TimeSpan(0, 0, 0, 0, 300);
public static readonly EdgeInsets kTabLabelPadding = EdgeInsets.symmetric(horizontal: 16.0f);
public static readonly EdgeInsets kMaterialListPadding = EdgeInsets.symmetric(vertical: 8.0f);
}
}

91
com.unity.uiwidgets/Runtime/material/debug.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public partial class material_ {
public static bool debugCheckHasMaterial(BuildContext context) {
D.assert(() => {
if (!(context.widget is Material) && context.findAncestorWidgetOfExactType<Material>() == null) {
var list = new List<DiagnosticsNode>() {
new ErrorSummary("No Material widget found."),
new ErrorDescription(
$"{context.widget.GetType()} widgets require a Material " +
"widget ancestor.\n" +
"In material design, most widgets are conceptually \"printed\" on " +
"a sheet of material. In Flutter\"s material library, that " +
"material is represented by the Material widget. It is the " +
"Material widget that renders ink splashes, for instance. " +
"Because of this, many material library widgets require that " +
"there be a Material widget in the tree above them."
),
new ErrorHint(
"To introduce a Material widget, you can either directly " +
"include one, or use a widget that contains Material itself, " +
"such as a Card, Dialog, Drawer, or Scaffold."
)
// ...context.describeMissingAncestor(expectedAncestorType: Material)
};
list.AddRange(context.describeMissingAncestor(expectedAncestorType: typeof(Material)));
throw new UIWidgetsError(list);
}
return true;
});
return true;
}
public static bool debugCheckHasMaterialLocalizations(BuildContext context) {
D.assert(() => {
if (Localizations.of<MaterialLocalizations>(context, typeof(MaterialLocalizations)) == null) {
var list = new List<DiagnosticsNode>() {
new ErrorSummary("No MaterialLocalizations found."),
new ErrorDescription(
"${context.widget.runtimeType} widgets require MaterialLocalizations " +
"to be provided by a Localizations widget ancestor."
),
new ErrorDescription(
"Localizations are used to generate many different messages, labels, " +
"and abbreviations which are used by the material library."
),
new ErrorHint(
"To introduce a MaterialLocalizations, either use a " +
"MaterialApp at the root of your application to include them " +
"automatically, or add a Localization widget with a " +
"MaterialLocalizations delegate."
),
};
list.AddRange(context.describeMissingAncestor(expectedAncestorType: typeof(MaterialLocalizations)));
throw new UIWidgetsError(list);
}
return true;
});
return true;
}
public static bool debugCheckHasScaffold(BuildContext context) {
D.assert(() => {
if (!(context.widget is Scaffold) && context.findAncestorWidgetOfExactType<Scaffold>() == null) {
var list = new List<DiagnosticsNode>() {
new ErrorSummary("No Scaffold widget found."),
new ErrorDescription(
"${context.widget.runtimeType} widgets require a Scaffold widget ancestor."),
new ErrorHint(
"Typically, the Scaffold widget is introduced by the MaterialApp or " +
"WidgetsApp widget at the top of your application widget tree."
)
};
list.AddRange(context.describeMissingAncestor(expectedAncestorType: typeof(Scaffold)));
throw new UIWidgetsError(list);
}
return true;
});
return true;
}
}
}

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


using System;
using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using AsyncCallback = Unity.UIWidgets.foundation.AsyncCallback;
using Color = Unity.UIWidgets.ui.Color;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
static class AppBarUtils {
internal const float _kLeadingWidth = material_.kToolbarHeight;
}
class _ToolbarContainerLayout : SingleChildLayoutDelegate {
public _ToolbarContainerLayout() {
}
public override BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
return constraints.tighten(height: material_.kToolbarHeight);
}
public override Size getSize(BoxConstraints constraints) {
return new Size(constraints.maxWidth, material_.kToolbarHeight);
}
public override Offset getPositionForChild(Size size, Size childSize) {
return new Offset(0.0f, size.height - childSize.height);
}
public override bool shouldRelayout(SingleChildLayoutDelegate oldDelegate) {
return false;
}
}
public class AppBar : PreferredSizeWidget {
public AppBar(
Key key = null,
Widget leading = null,
bool automaticallyImplyLeading = true,
Widget title = null,
List<Widget> actions = null,
Widget flexibleSpace = null,
PreferredSizeWidget bottom = null,
float? elevation = null,
ShapeBorder shape = null,
Color backgroundColor = null,
Brightness? brightness = null,
IconThemeData iconTheme = null,
IconThemeData actionsIconTheme = null,
TextTheme textTheme = null,
bool primary = true,
bool? centerTitle = null,
float titleSpacing = NavigationToolbar.kMiddleSpacing,
float toolbarOpacity = 1.0f,
float bottomOpacity = 1.0f
) : base(key: key) {
D.assert(elevation == null || elevation >= 0.0);
this.leading = leading;
this.automaticallyImplyLeading = automaticallyImplyLeading;
this.title = title;
this.actions = actions;
this.flexibleSpace = flexibleSpace;
this.bottom = bottom;
this.elevation = elevation;
this.shape = shape;
this.backgroundColor = backgroundColor;
this.brightness = brightness;
this.iconTheme = iconTheme;
this.actionsIconTheme = actionsIconTheme;
this.textTheme = textTheme;
this.primary = primary;
this.centerTitle = centerTitle;
this.titleSpacing = titleSpacing;
this.toolbarOpacity = toolbarOpacity;
this.bottomOpacity = bottomOpacity;
preferredSize = Size.fromHeight(material_.kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0f));
}
public readonly Widget leading;
public readonly bool automaticallyImplyLeading;
public readonly Widget title;
public readonly List<Widget> actions;
public readonly Widget flexibleSpace;
public readonly PreferredSizeWidget bottom;
public readonly float? elevation;
public readonly ShapeBorder shape;
public readonly Color backgroundColor;
public readonly Brightness? brightness;
public readonly IconThemeData iconTheme;
public readonly IconThemeData actionsIconTheme;
public readonly TextTheme textTheme;
public readonly bool primary;
public readonly bool? centerTitle;
public readonly float titleSpacing;
public readonly float toolbarOpacity;
public readonly float bottomOpacity;
public override Size preferredSize { get; }
public bool? _getEffectiveCenterTitle(ThemeData theme) {
if (centerTitle != null) {
return centerTitle;
}
D.assert(theme.platform != null);
switch (theme.platform) {
case RuntimePlatform.Android:
case RuntimePlatform.LinuxEditor:
case RuntimePlatform.LinuxPlayer:
case RuntimePlatform.WindowsEditor:
case RuntimePlatform.WindowsPlayer:
return false;
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
return actions == null || actions.Count < 2;
default:
return false;
}
}
public override State createState() {
return new _AppBarState();
}
}
class _AppBarState : State<AppBar> {
const float _defaultElevation = 4.0f;
void _handleDrawerButton() {
Scaffold.of(context).openDrawer();
}
void _handleDrawerButtonEnd() {
Scaffold.of(context).openEndDrawer();
}
public override Widget build(BuildContext context) {
D.assert(material_.debugCheckHasMaterialLocalizations(context));
ThemeData theme = Theme.of(context);
AppBarTheme appBarTheme = AppBarTheme.of(context);
ScaffoldState scaffold = Scaffold.of(context, nullOk: true);
ModalRoute parentRoute = ModalRoute.of(context);
bool hasDrawer = scaffold?.hasDrawer ?? false;
bool hasEndDrawer = scaffold?.hasEndDrawer ?? false;
bool canPop = parentRoute?.canPop ?? false;
bool useCloseButton = parentRoute is PageRoute && ((PageRoute) parentRoute).fullscreenDialog;
IconThemeData overallIconTheme = widget.iconTheme
?? appBarTheme.iconTheme
?? theme.primaryIconTheme;
IconThemeData actionsIconTheme = widget.actionsIconTheme
?? appBarTheme.actionsIconTheme
?? overallIconTheme;
TextStyle centerStyle = widget.textTheme?.headline6
?? appBarTheme.textTheme?.headline6
?? theme.primaryTextTheme.headline6;
TextStyle sideStyle = widget.textTheme?.bodyText2
?? appBarTheme.textTheme?.bodyText2
?? theme.primaryTextTheme.bodyText2;
if (widget.toolbarOpacity != 1.0f) {
float opacity =
new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(widget.toolbarOpacity);
if (centerStyle?.color != null) {
centerStyle = centerStyle.copyWith(color: centerStyle.color.withOpacity(opacity));
}
if (sideStyle?.color != null) {
sideStyle = sideStyle.copyWith(color: sideStyle.color.withOpacity(opacity));
}
overallIconTheme = overallIconTheme.copyWith(
opacity: opacity * (overallIconTheme.opacity ?? 1.0f)
);
actionsIconTheme = actionsIconTheme.copyWith(
opacity: opacity * (actionsIconTheme.opacity ?? 1.0f)
);
}
Widget leading = widget.leading;
if (leading == null && widget.automaticallyImplyLeading) {
if (hasDrawer) {
leading = new IconButton(
icon: new Icon(Icons.menu),
onPressed: _handleDrawerButton,
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip);
}
else {
if (canPop) {
leading = useCloseButton ? (Widget) new CloseButton() : new BackButton();
}
}
}
if (leading != null) {
leading = new ConstrainedBox(
constraints: BoxConstraints.tightFor(width: AppBarUtils._kLeadingWidth),
child: leading);
}
Widget title = widget.title;
if (title != null) {
bool namesRoute;
switch (theme.platform) {
case RuntimePlatform.Android:
case RuntimePlatform.LinuxEditor:
case RuntimePlatform.LinuxPlayer:
case RuntimePlatform.WindowsEditor:
case RuntimePlatform.WindowsPlayer:
namesRoute = true;
break;
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
break;
default:
break;
}
title = new _AppBarTitleBox(child: title);
title = new DefaultTextStyle(
style: centerStyle,
softWrap: false,
overflow: TextOverflow.ellipsis,
child: title
);
}
Widget actions = null;
if (widget.actions != null && widget.actions.isNotEmpty()) {
actions = new Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: widget.actions);
}
else if (hasEndDrawer) {
actions = new IconButton(
icon: new Icon(Icons.menu),
onPressed: _handleDrawerButtonEnd,
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip);
}
if (actions != null) {
actions = IconTheme.merge(
data: actionsIconTheme,
child: actions
);
}
Widget toolbar = new NavigationToolbar(
leading: leading,
middle: title,
trailing: actions,
centerMiddle: widget._getEffectiveCenterTitle(theme).Value,
middleSpacing: widget.titleSpacing);
Widget appBar = new ClipRect(
child: new CustomSingleChildLayout(
layoutDelegate: new _ToolbarContainerLayout(),
child: IconTheme.merge(
data: overallIconTheme,
child: new DefaultTextStyle(
style: sideStyle,
child: toolbar)
)
)
);
if (widget.bottom != null) {
appBar = new Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: new List<Widget> {
new Flexible(
child: new ConstrainedBox(
constraints: new BoxConstraints(maxHeight: material_.kToolbarHeight),
child: appBar
)
),
foundation_.FloatEqual(widget.bottomOpacity, 1.0f)
? (Widget) widget.bottom
: new Opacity(
opacity: new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(widget
.bottomOpacity),
child: widget.bottom
)
}
);
}
if (widget.primary) {
appBar = new SafeArea(
bottom: false,
top: true,
child: appBar);
}
appBar = new Align(
alignment: Alignment.topCenter,
child: appBar);
if (widget.flexibleSpace != null) {
appBar = new Stack(
fit: StackFit.passthrough,
children: new List<Widget> {
widget.flexibleSpace,
appBar
}
);
}
Brightness brightness = widget.brightness
?? appBarTheme.brightness
?? theme.primaryColorBrightness;
SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark
? SystemUiOverlayStyle.light
: SystemUiOverlayStyle.dark;
return new AnnotatedRegion<SystemUiOverlayStyle>(
value: overlayStyle,
child: new Material(
color: widget.backgroundColor
?? appBarTheme.color
?? theme.primaryColor,
elevation: widget.elevation
?? appBarTheme.elevation
?? _defaultElevation,
shape: widget.shape,
child: appBar
));
}
}
class _FloatingAppBar : StatefulWidget {
public _FloatingAppBar(Key key = null, Widget child = null) : base(key: key) {
this.child = child;
}
public readonly Widget child;
public override State createState() {
return new _FloatingAppBarState();
}
}
class _FloatingAppBarState : State<_FloatingAppBar> {
ScrollPosition _position;
public _FloatingAppBarState() {
}
public override void didChangeDependencies() {
base.didChangeDependencies();
if (_position != null) {
_position.isScrollingNotifier.removeListener(_isScrollingListener);
}
_position = Scrollable.of(context)?.position;
if (_position != null) {
_position.isScrollingNotifier.addListener(_isScrollingListener);
}
}
public override void dispose() {
if (_position != null) {
_position.isScrollingNotifier.removeListener(_isScrollingListener);
}
base.dispose();
}
RenderSliverFloatingPersistentHeader _headerRenderer() {
return context.findAncestorRenderObjectOfType<RenderSliverFloatingPersistentHeader>();
}
void _isScrollingListener() {
if (_position == null) {
return;
}
RenderSliverFloatingPersistentHeader header = _headerRenderer();
if (_position.isScrollingNotifier.value) {
header?.maybeStopSnapAnimation(_position.userScrollDirection);
}
else {
header?.maybeStartSnapAnimation(_position.userScrollDirection);
}
}
public override Widget build(BuildContext context) {
return widget.child;
}
}
class _SliverAppBarDelegate : SliverPersistentHeaderDelegate {
public _SliverAppBarDelegate(
Widget leading,
bool automaticallyImplyLeading,
Widget title,
List<Widget> actions,
Widget flexibleSpace,
PreferredSizeWidget bottom,
float? elevation,
bool forceElevated,
Color backgroundColor,
Brightness? brightness,
IconThemeData iconTheme,
IconThemeData actionsIconTheme,
TextTheme textTheme,
bool primary,
bool? centerTitle,
float titleSpacing,
float? expandedHeight,
float? collapsedHeight,
float? topPadding,
bool floating,
bool pinned,
FloatingHeaderSnapConfiguration snapConfiguration,
OverScrollHeaderStretchConfiguration stretchConfiguration,
ShapeBorder shape
) {
D.assert(primary || topPadding == 0.0);
this.leading = leading;
this.automaticallyImplyLeading = automaticallyImplyLeading;
this.title = title;
this.actions = actions;
this.flexibleSpace = flexibleSpace;
this.bottom = bottom;
this.elevation = elevation;
this.forceElevated = forceElevated;
this.backgroundColor = backgroundColor;
this.brightness = brightness;
this.iconTheme = iconTheme;
this.actionsIconTheme = actionsIconTheme;
this.textTheme = textTheme;
this.primary = primary;
this.centerTitle = centerTitle;
this.titleSpacing = titleSpacing;
this.expandedHeight = expandedHeight;
this.collapsedHeight = collapsedHeight;
this.topPadding = topPadding;
this.floating = floating;
this.pinned = pinned;
this.snapConfiguration = snapConfiguration;
_bottomHeight = bottom?.preferredSize?.height ?? 0.0f;
this.snapConfiguration = snapConfiguration;
this.stretchConfiguration = stretchConfiguration;
}
public readonly Widget leading;
public readonly bool automaticallyImplyLeading;
public readonly Widget title;
public readonly List<Widget> actions;
public readonly Widget flexibleSpace;
public readonly PreferredSizeWidget bottom;
public readonly float? elevation;
public readonly bool forceElevated;
public readonly Color backgroundColor;
public readonly Brightness? brightness;
public readonly IconThemeData iconTheme;
public readonly IconThemeData actionsIconTheme;
public readonly TextTheme textTheme;
public readonly bool primary;
public readonly bool? centerTitle;
public readonly float titleSpacing;
public readonly float? expandedHeight;
public readonly float? collapsedHeight;
public readonly float? topPadding;
public readonly bool floating;
public readonly bool pinned;
public readonly ShapeBorder shape;
readonly float _bottomHeight;
public override float? minExtent {
get { return collapsedHeight ?? (topPadding + material_.kToolbarHeight + _bottomHeight); }
}
public override float? maxExtent {
get {
return Mathf.Max(
(topPadding ?? 0.0f) + (expandedHeight ?? material_.kToolbarHeight + _bottomHeight),
minExtent ?? 0.0f);
}
}
public override FloatingHeaderSnapConfiguration snapConfiguration { get; }
public override OverScrollHeaderStretchConfiguration stretchConfiguration { get; }
public override Widget build(BuildContext context, float shrinkOffset, bool overlapsContent) {
float? visibleMainHeight = maxExtent - shrinkOffset - topPadding;
float toolbarOpacity = !pinned || (!floating && bottom != null)
? ((visibleMainHeight - _bottomHeight) / material_.kToolbarHeight)?.clamp(0.0f, 1.0f) ?? 1.0f
: 1.0f;
Widget appBar = FlexibleSpaceBar.createSettings(
minExtent: minExtent,
maxExtent: maxExtent,
currentExtent: Mathf.Max(minExtent ?? 0.0f, maxExtent ?? 0.0f - shrinkOffset),
toolbarOpacity: toolbarOpacity,
child: new AppBar(
leading: leading,
automaticallyImplyLeading: automaticallyImplyLeading,
title: title,
actions: actions,
flexibleSpace: flexibleSpace,
bottom: bottom,
elevation: forceElevated || overlapsContent ||
(pinned && shrinkOffset > maxExtent - minExtent)
? elevation ?? 4.0f
: 0.0f,
backgroundColor: backgroundColor,
brightness: brightness,
iconTheme: iconTheme,
textTheme: textTheme,
primary: primary,
centerTitle: centerTitle,
titleSpacing: titleSpacing,
shape: shape,
toolbarOpacity: toolbarOpacity,
bottomOpacity: pinned
? 1.0f
: (visibleMainHeight / _bottomHeight)?.clamp(0.0f, 1.0f) ?? 1.0f
)
);
return floating ? new _FloatingAppBar(child: appBar) : appBar;
}
public override bool shouldRebuild(SliverPersistentHeaderDelegate _oldDelegate) {
_SliverAppBarDelegate oldDelegate = _oldDelegate as _SliverAppBarDelegate;
return leading != oldDelegate.leading
|| automaticallyImplyLeading != oldDelegate.automaticallyImplyLeading
|| title != oldDelegate.title
|| actions != oldDelegate.actions
|| flexibleSpace != oldDelegate.flexibleSpace
|| bottom != oldDelegate.bottom
|| _bottomHeight != oldDelegate._bottomHeight
|| elevation != oldDelegate.elevation
|| backgroundColor != oldDelegate.backgroundColor
|| brightness != oldDelegate.brightness
|| iconTheme != oldDelegate.iconTheme
|| actionsIconTheme != oldDelegate.actionsIconTheme
|| textTheme != oldDelegate.textTheme
|| primary != oldDelegate.primary
|| centerTitle != oldDelegate.centerTitle
|| titleSpacing != oldDelegate.titleSpacing
|| expandedHeight != oldDelegate.expandedHeight
|| topPadding != oldDelegate.topPadding
|| pinned != oldDelegate.pinned
|| floating != oldDelegate.floating
|| snapConfiguration != oldDelegate.snapConfiguration
|| stretchConfiguration != oldDelegate.stretchConfiguration;
}
public override string ToString() {
return
$"{foundation_.describeIdentity(this)}(topPadding: {topPadding?.ToString("F1")}, bottomHeight: {_bottomHeight.ToString("F1")}, ...)";
}
}
public class SliverAppBar : StatefulWidget {
public SliverAppBar(
Key key = null,
Widget leading = null,
bool automaticallyImplyLeading = true,
Widget title = null,
List<Widget> actions = null,
Widget flexibleSpace = null,
PreferredSizeWidget bottom = null,
float? elevation = null,
bool forceElevated = false,
Color backgroundColor = null,
Brightness? brightness = null,
IconThemeData iconTheme = null,
IconThemeData actionsIconTheme = null,
TextTheme textTheme = null,
bool primary = true,
bool? centerTitle = null,
float titleSpacing = NavigationToolbar.kMiddleSpacing,
float? expandedHeight = null,
bool floating = false,
bool pinned = false,
bool snap = false,
bool stretch = false,
float stretchTriggerOffset = 100.0f,
AsyncCallback onStretchTrigger = null,
ShapeBorder shape = null
) : base(key: key) {
D.assert(floating || !snap, () => "The 'snap' argument only makes sense for floating app bars.");
D.assert(stretchTriggerOffset > 0.0);
this.leading = leading;
this.automaticallyImplyLeading = true;
this.title = title;
this.actions = actions;
this.flexibleSpace = flexibleSpace;
this.bottom = bottom;
this.elevation = elevation;
this.forceElevated = forceElevated;
this.backgroundColor = backgroundColor;
this.brightness = brightness;
this.iconTheme = iconTheme;
this.actionsIconTheme = actionsIconTheme;
this.textTheme = textTheme;
this.primary = primary;
this.centerTitle = centerTitle;
this.titleSpacing = NavigationToolbar.kMiddleSpacing;
this.expandedHeight = expandedHeight;
this.floating = floating;
this.pinned = pinned;
this.snap = snap;
this.stretch = stretch;
this.stretchTriggerOffset = stretchTriggerOffset;
this.onStretchTrigger = onStretchTrigger;
this.shape = shape;
}
public readonly Widget leading;
public readonly bool automaticallyImplyLeading;
public readonly Widget title;
public readonly List<Widget> actions;
public readonly Widget flexibleSpace;
public readonly PreferredSizeWidget bottom;
public readonly float? elevation;
public readonly bool forceElevated;
public readonly Color backgroundColor;
public readonly Brightness? brightness;
public readonly IconThemeData iconTheme;
public readonly IconThemeData actionsIconTheme;
public readonly TextTheme textTheme;
public readonly bool primary;
public readonly bool? centerTitle;
public readonly bool? excludeHeaderSemantics;
public readonly float titleSpacing;
public readonly float? expandedHeight;
public readonly bool floating;
public readonly bool pinned;
public readonly ShapeBorder shape;
public readonly bool snap;
public readonly bool stretch;
public readonly float stretchTriggerOffset;
public readonly AsyncCallback onStretchTrigger;
public override State createState() {
return new _SliverAppBarState();
}
}
class _SliverAppBarState : TickerProviderStateMixin<SliverAppBar> {
FloatingHeaderSnapConfiguration _snapConfiguration;
OverScrollHeaderStretchConfiguration _stretchConfiguration;
void _updateSnapConfiguration() {
if (widget.snap && widget.floating) {
_snapConfiguration = new FloatingHeaderSnapConfiguration(
vsync: this,
curve: Curves.easeOut,
duration: new TimeSpan(0, 0, 0, 0, 200)
);
}
else {
_snapConfiguration = null;
}
}
void _updateStretchConfiguration() {
if (widget.stretch) {
_stretchConfiguration = new OverScrollHeaderStretchConfiguration(
stretchTriggerOffset: widget.stretchTriggerOffset,
onStretchTrigger: widget.onStretchTrigger
);
} else {
_stretchConfiguration = null;
}
}
public override void initState() {
base.initState();
_updateSnapConfiguration();
_updateStretchConfiguration();
}
public override void didUpdateWidget(StatefulWidget _oldWidget) {
base.didUpdateWidget(_oldWidget);
SliverAppBar oldWidget = _oldWidget as SliverAppBar;
if (widget.snap != oldWidget.snap || widget.floating != oldWidget.floating) {
_updateSnapConfiguration();
}
if (widget.stretch != oldWidget.stretch) {
_updateStretchConfiguration();
}
}
public override Widget build(BuildContext context) {
D.assert(!widget.primary || WidgetsD.debugCheckHasMediaQuery(context));
float? topPadding = widget.primary ? MediaQuery.of(context).padding.top : 0.0f;
float? collapsedHeight = (widget.pinned && widget.floating && widget.bottom != null)
? widget.bottom.preferredSize.height + topPadding
: null;
return MediaQuery.removePadding(
context: context,
removeBottom: true,
child: new SliverPersistentHeader(
floating: widget.floating,
pinned: widget.pinned,
del: new _SliverAppBarDelegate(
leading: widget.leading,
automaticallyImplyLeading: widget.automaticallyImplyLeading,
title: widget.title,
actions: widget.actions,
flexibleSpace: widget.flexibleSpace,
bottom: widget.bottom,
elevation: widget.elevation,
forceElevated: widget.forceElevated,
backgroundColor: widget.backgroundColor,
brightness: widget.brightness,
iconTheme: widget.iconTheme,
actionsIconTheme: widget.actionsIconTheme,
textTheme: widget.textTheme,
primary: widget.primary,
centerTitle: widget.centerTitle,
titleSpacing: widget.titleSpacing,
expandedHeight: widget.expandedHeight,
collapsedHeight: collapsedHeight,
topPadding: topPadding,
floating: widget.floating,
pinned: widget.pinned,
shape: widget.shape,
snapConfiguration: _snapConfiguration,
stretchConfiguration: _stretchConfiguration
)
)
);
}
}
internal class _AppBarTitleBox : SingleChildRenderObjectWidget {
internal _AppBarTitleBox(Key key = null, Widget child = null) : base(key: key, child: child) {
D.assert(child != null);
}
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderAppBarTitleBox(
textDirection: Directionality.of(context)
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
if (renderObject is _RenderAppBarTitleBox renderAppBarTitleBox) {
renderAppBarTitleBox.textDirection = Directionality.of(context);
}
}
}
class _RenderAppBarTitleBox : RenderAligningShiftedBox {
internal _RenderAppBarTitleBox(
RenderBox child = null,
TextDirection textDirection = TextDirection.ltr
) : base(child: child, alignment: Alignment.center, textDirection: textDirection) {
}
protected override void performLayout() {
BoxConstraints constraints = this.constraints;
BoxConstraints innerConstraints = constraints.copyWith(maxHeight: float.PositiveInfinity);
child.layout(innerConstraints, parentUsesSize: true);
size = constraints.constrain(child.size);
alignChild();
}
}
}

11
com.unity.uiwidgets/Runtime/material/constants.cs.meta


fileFormatVersion: 2
guid: 458362f6f20be1348bf63c0a5a912024
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

264
com.unity.uiwidgets/Runtime/material/app.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Brightness = Unity.UIWidgets.ui.Brightness;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public partial class material_ {
public static readonly TextStyle _errorTextStyle = new TextStyle(
color: new Color(0xD0FF0000),
fontFamily: "monospace",
fontSize: 48.0f,
fontWeight: FontWeight.w700,
decoration: TextDecoration.underline,
decorationColor: new Color(0xFFFFFF00),
decorationStyle: TextDecorationStyle.doubleLine
);
}
public enum ThemeMode {
system,
light,
dark,
}
public class MaterialApp : StatefulWidget {
public MaterialApp(
Key key = null,
GlobalKey<NavigatorState> navigatorKey = null,
Widget home = null,
Dictionary<string, WidgetBuilder> routes = null,
string initialRoute = null,
RouteFactory onGenerateRoute = null,
InitialRouteListFactory onGenerateInitialRoutes = null,
RouteFactory onUnknownRoute = null,
List<NavigatorObserver> navigatorObservers = null,
TransitionBuilder builder = null,
string title = "",
GenerateAppTitle onGenerateTitle = null,
Color color = null,
ThemeData theme = null,
ThemeData darkTheme = null,
ThemeMode themeMode = ThemeMode.system,
Locale locale = null,
List<LocalizationsDelegate> localizationsDelegates = null,
LocaleListResolutionCallback localeListResolutionCallback = null,
LocaleResolutionCallback localeResolutionCallback = null,
List<Locale> supportedLocales = null,
bool showPerformanceOverlay = false,
bool checkerboardRasterCacheImages = false,
bool checkerboardOffscreenLayers = false,
bool debugShowCheckedModeBanner = true,
Dictionary<LogicalKeySet, Intent> shortcuts = null,
Dictionary<LocalKey, ActionFactory> actions = null
) : base(key: key) {
supportedLocales = supportedLocales ?? new List<Locale> {new Locale("en", "US")};
this.navigatorKey = navigatorKey;
this.home = home;
this.routes = routes ?? new Dictionary<string, WidgetBuilder>();
this.onGenerateInitialRoutes = onGenerateInitialRoutes;
this.initialRoute = initialRoute;
this.onGenerateRoute = onGenerateRoute;
this.onUnknownRoute = onUnknownRoute;
this.navigatorObservers = navigatorObservers ?? new List<NavigatorObserver>();
this.builder = builder;
this.title = title;
this.onGenerateTitle = onGenerateTitle;
this.color = color;
this.theme = theme;
this.darkTheme = darkTheme;
this.themeMode = themeMode;
this.locale = locale;
this.localizationsDelegates = localizationsDelegates;
this.localeListResolutionCallback = localeListResolutionCallback;
this.localeResolutionCallback = localeResolutionCallback;
this.supportedLocales = supportedLocales;
this.showPerformanceOverlay = showPerformanceOverlay;
this.checkerboardRasterCacheImages = checkerboardRasterCacheImages;
this.checkerboardOffscreenLayers = checkerboardOffscreenLayers;
this.debugShowCheckedModeBanner = debugShowCheckedModeBanner;
this.shortcuts = shortcuts;
this.actions = actions;
}
public readonly GlobalKey<NavigatorState> navigatorKey;
public readonly Widget home;
public readonly Dictionary<string, WidgetBuilder> routes;
public readonly string initialRoute;
public readonly RouteFactory onGenerateRoute;
public readonly InitialRouteListFactory onGenerateInitialRoutes;
public readonly RouteFactory onUnknownRoute;
public readonly List<NavigatorObserver> navigatorObservers;
public readonly TransitionBuilder builder;
public readonly string title;
public readonly GenerateAppTitle onGenerateTitle;
public readonly ThemeData theme;
public readonly ThemeData darkTheme;
public readonly ThemeMode themeMode;
public readonly Color color;
public readonly Locale locale;
public readonly List<LocalizationsDelegate> localizationsDelegates;
public readonly LocaleListResolutionCallback localeListResolutionCallback;
public readonly LocaleResolutionCallback localeResolutionCallback;
public readonly List<Locale> supportedLocales;
public readonly bool showPerformanceOverlay;
public readonly bool checkerboardRasterCacheImages;
public readonly bool checkerboardOffscreenLayers;
public readonly bool debugShowCheckedModeBanner;
public readonly Dictionary<LogicalKeySet, Intent> shortcuts;
public readonly Dictionary<LocalKey, ActionFactory> actions;
public override State createState() {
return new _MaterialAppState();
}
}
class _MaterialAppState : State<MaterialApp> {
HeroController _heroController;
public override void initState() {
base.initState();
_heroController = new HeroController(createRectTween: _createRectTween);
_updateNavigator();
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
if (widget.navigatorKey != (oldWidget as MaterialApp).navigatorKey) {
_heroController = new HeroController(createRectTween: _createRectTween);
}
_updateNavigator();
}
List<NavigatorObserver> _navigatorObservers;
void _updateNavigator() {
if (widget.home != null ||
widget.routes.isNotEmpty() ||
widget.onGenerateRoute != null ||
widget.onUnknownRoute != null) {
_navigatorObservers = new List<NavigatorObserver>(widget.navigatorObservers);
_navigatorObservers.Add(_heroController);
}
else {
_navigatorObservers = new List<NavigatorObserver>();
}
}
RectTween _createRectTween(Rect begin, Rect end) {
return new MaterialRectArcTween(begin: begin, end: end);
}
List<LocalizationsDelegate> _localizationsDelegates {
get {
var _delegates = new List<LocalizationsDelegate>();
if (widget.localizationsDelegates != null) {
_delegates.AddRange(widget.localizationsDelegates);
}
_delegates.Add(DefaultCupertinoLocalizations.del);
_delegates.Add(DefaultMaterialLocalizations.del);
return new List<LocalizationsDelegate>(_delegates);
}
}
public override Widget build(BuildContext context) {
Widget result = new WidgetsApp(
key: new GlobalObjectKey<State>(this),
navigatorKey: widget.navigatorKey,
navigatorObservers: _navigatorObservers,
pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
new MaterialPageRoute(settings: settings, builder: builder),
home: widget.home,
routes: widget.routes,
initialRoute: widget.initialRoute,
onGenerateRoute: widget.onGenerateRoute,
onGenerateInitialRoutes: widget.onGenerateInitialRoutes,
onUnknownRoute: widget.onUnknownRoute,
builder: (BuildContext _context, Widget child) => {
ThemeMode mode = widget.themeMode;
ThemeData theme = null;
if (widget.darkTheme != null) {
ui.Brightness platformBrightness = MediaQuery.platformBrightnessOf(context);
if (mode == ThemeMode.dark ||
(mode == ThemeMode.system && platformBrightness == ui.Brightness.dark)) {
theme = widget.darkTheme;
}
}
theme = theme ?? widget.theme ?? ThemeData.fallback();
return new AnimatedTheme(
data: theme,
isMaterialAppTheme: true,
child: widget.builder != null
? new Builder(
builder: (__context) => { return widget.builder(__context, child); }
)
: child
);
},
textStyle: material_._errorTextStyle,
title: widget.title,
onGenerateTitle: widget.onGenerateTitle,
color: widget.color ?? widget.theme?.primaryColor ?? Colors.blue,
locale: widget.locale,
localizationsDelegates: _localizationsDelegates,
localeResolutionCallback: widget.localeResolutionCallback,
localeListResolutionCallback: widget.localeListResolutionCallback,
supportedLocales: widget.supportedLocales,
showPerformanceOverlay: widget.showPerformanceOverlay,
checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages,
checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers,
debugShowCheckedModeBanner: widget.debugShowCheckedModeBanner,
inspectorSelectButtonBuilder: (BuildContext contextIn, VoidCallback onPressed) => {
return new FloatingActionButton(
child: new Icon(Icons.search),
onPressed: onPressed,
mini: true
);
},
shortcuts: widget.shortcuts,
actions: widget.actions
);
return result;
}
}
}

946
com.unity.uiwidgets/Runtime/material/slider.cs


using System;
using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.material {
public enum _SliderType {
material,
adaptive
}
public class Slider : StatefulWidget {
public Slider(
Key key = null,
float? value = null,
ValueChanged<float> onChanged = null,
ValueChanged<float> onChangeStart = null,
ValueChanged<float> onChangeEnd = null,
float min = 0.0f,
float max = 1.0f,
int? divisions = null,
string label = null,
Color activeColor = null,
Color inactiveColor = null,
_SliderType _sliderType = _SliderType.material
) : base(key: key) {
D.assert(value != null);
D.assert(min <= max);
D.assert(value >= min && value <= max);
D.assert(divisions == null || divisions > 0);
this.value = value.Value;
this.onChanged = onChanged;
this.onChangeStart = onChangeStart;
this.onChangeEnd = onChangeEnd;
this.min = min;
this.max = max;
this.divisions = divisions;
this.label = label;
this.activeColor = activeColor;
this.inactiveColor = inactiveColor;
this._sliderType = _sliderType;
}
public static Slider adaptive(
Key key = null,
float? value = null,
ValueChanged<float> onChanged = null,
ValueChanged<float> onChangeStart = null,
ValueChanged<float> onChangeEnd = null,
float min = 0.0f,
float max = 1.0f,
int? divisions = null,
string label = null,
Color activeColor = null,
Color inactiveColor = null
) {
return new Slider(
key: key,
value: value,
onChanged: onChanged,
onChangeStart: onChangeStart,
onChangeEnd: onChangeEnd,
min: min,
max: max,
divisions: divisions,
label: label,
activeColor: activeColor,
inactiveColor: inactiveColor,
_sliderType: _SliderType.adaptive
);
}
public readonly float value;
public readonly ValueChanged<float> onChanged;
public readonly ValueChanged<float> onChangeStart;
public readonly ValueChanged<float> onChangeEnd;
public readonly float min;
public readonly float max;
public readonly int? divisions;
public readonly string label;
public readonly Color activeColor;
public readonly Color inactiveColor;
public readonly _SliderType _sliderType;
public override State createState() {
return new _SliderState();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FloatProperty("value", value));
properties.add(new ObjectFlagProperty<ValueChanged<float>>("onChanged", onChanged, ifNull: "disabled"));
properties.add(ObjectFlagProperty<ValueChanged<float>>.has("onChangeStart", onChangeStart));
properties.add(ObjectFlagProperty<ValueChanged<float>>.has("onChangeEnd", onChangeEnd));
properties.add(new FloatProperty("min", min));
properties.add(new FloatProperty("max", max));
properties.add(new IntProperty("divisions", divisions));
properties.add(new StringProperty("label", label));
properties.add(new ColorProperty("activeColor", activeColor));
properties.add(new ColorProperty("inactiveColor", inactiveColor));
}
}
class _SliderState : TickerProviderStateMixin<Slider> {
static TimeSpan enableAnimationDuration = new TimeSpan(0, 0, 0, 0, 75);
static TimeSpan valueIndicatorAnimationDuration = new TimeSpan(0, 0, 0, 0, 100);
public AnimationController overlayController;
public AnimationController valueIndicatorController;
public AnimationController enableController;
public AnimationController positionController;
public Timer interactionTimer;
public override void initState() {
base.initState();
overlayController = new AnimationController(
duration: material_.kRadialReactionDuration,
vsync: this
);
valueIndicatorController = new AnimationController(
duration: valueIndicatorAnimationDuration,
vsync: this
);
enableController = new AnimationController(
duration: enableAnimationDuration,
vsync: this
);
positionController = new AnimationController(
duration: TimeSpan.Zero,
vsync: this
);
enableController.setValue(widget.onChanged != null ? 1.0f : 0.0f);
positionController.setValue(_unlerp(widget.value));
}
public override void dispose() {
interactionTimer?.cancel();
overlayController.dispose();
valueIndicatorController.dispose();
enableController.dispose();
positionController.dispose();
base.dispose();
}
void _handleChanged(float value) {
D.assert(widget.onChanged != null);
float lerpValue = _lerp(value);
if (lerpValue != widget.value) {
widget.onChanged(lerpValue);
}
}
void _handleDragStart(float value) {
D.assert(widget.onChangeStart != null);
widget.onChangeStart(_lerp(value));
}
void _handleDragEnd(float value) {
D.assert(widget.onChangeEnd != null);
widget.onChangeEnd(_lerp(value));
}
float _lerp(float value) {
D.assert(value >= 0.0f);
D.assert(value <= 1.0f);
return value * (widget.max - widget.min) + widget.min;
}
float _unlerp(float value) {
D.assert(value <= widget.max);
D.assert(value >= widget.min);
return widget.max > widget.min
? (value - widget.min) / (widget.max - widget.min)
: 0.0f;
}
const float _defaultTrackHeight = 2f;
static readonly SliderTrackShape _defaultTrackShape = new RoundedRectSliderTrackShape();
static readonly SliderTickMarkShape _defaultTickMarkShape = new RoundSliderTickMarkShape();
static readonly SliderComponentShape _defaultOverlayShape = new RoundSliderOverlayShape();
static readonly SliderComponentShape _defaultThumbShape = new RoundSliderThumbShape();
static readonly SliderComponentShape _defaultValueIndicatorShape = new PaddleSliderValueIndicatorShape();
static readonly ShowValueIndicator _defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete;
public override Widget build(BuildContext context) {
D.assert(material_.debugCheckHasMaterial(context));
D.assert(WidgetsD.debugCheckHasMediaQuery(context));
switch (widget._sliderType) {
case _SliderType.material:
return _buildMaterialSlider(context);
case _SliderType.adaptive: {
ThemeData theme = Theme.of(context);
return _buildMaterialSlider(context);
}
}
D.assert(false);
return null;
}
Widget _buildMaterialSlider(BuildContext context) {
ThemeData theme = Theme.of(context);
SliderThemeData sliderTheme = SliderTheme.of(context);
sliderTheme = sliderTheme.copyWith(
trackHeight: sliderTheme.trackHeight ?? _defaultTrackHeight,
activeTrackColor: widget.activeColor ?? sliderTheme.activeTrackColor ?? theme.colorScheme.primary,
inactiveTrackColor: widget.inactiveColor ?? sliderTheme.inactiveTrackColor ?? theme.colorScheme.primary.withOpacity(0.24f),
disabledActiveTrackColor: sliderTheme.disabledActiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.32f),
disabledInactiveTrackColor: sliderTheme.disabledInactiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.12f),
activeTickMarkColor: widget.inactiveColor ?? sliderTheme.activeTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.54f),
inactiveTickMarkColor: widget.activeColor ?? sliderTheme.inactiveTickMarkColor ?? theme.colorScheme.primary.withOpacity(0.54f),
disabledActiveTickMarkColor: sliderTheme.disabledActiveTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.12f),
disabledInactiveTickMarkColor: sliderTheme.disabledInactiveTickMarkColor ?? theme.colorScheme.onSurface.withOpacity(0.12f),
thumbColor: widget.activeColor ?? sliderTheme.thumbColor ?? theme.colorScheme.primary,
disabledThumbColor: sliderTheme.disabledThumbColor ?? theme.colorScheme.onSurface.withOpacity(0.38f),
overlayColor: widget.activeColor?.withOpacity(0.12f) ?? sliderTheme.overlayColor ?? theme.colorScheme.primary.withOpacity(0.12f),
valueIndicatorColor: widget.activeColor ?? sliderTheme.valueIndicatorColor ?? theme.colorScheme.primary,
trackShape: sliderTheme.trackShape ?? _defaultTrackShape,
tickMarkShape: sliderTheme.tickMarkShape ?? _defaultTickMarkShape,
thumbShape: sliderTheme.thumbShape ?? _defaultThumbShape,
overlayShape: sliderTheme.overlayShape ?? _defaultOverlayShape,
valueIndicatorShape: sliderTheme.valueIndicatorShape ?? _defaultValueIndicatorShape,
showValueIndicator: sliderTheme.showValueIndicator ?? _defaultShowValueIndicator,
valueIndicatorTextStyle: sliderTheme.valueIndicatorTextStyle ?? theme.textTheme.bodyText1.copyWith(
color: theme.colorScheme.onPrimary
)
);
return new _SliderRenderObjectWidget(
value: _unlerp(widget.value),
divisions: widget.divisions,
label: widget.label,
sliderTheme: sliderTheme,
mediaQueryData: MediaQuery.of(context),
onChanged: (widget.onChanged != null) && (widget.max > widget.min) ? _handleChanged : (ValueChanged<float>)null,
onChangeStart: widget.onChangeStart != null ? _handleDragStart : (ValueChanged<float>)null,
onChangeEnd: widget.onChangeEnd != null ? _handleDragEnd : (ValueChanged<float>)null,
state: this
);
}
}
class _SliderRenderObjectWidget : LeafRenderObjectWidget {
public _SliderRenderObjectWidget(
Key key = null,
float? value = null,
int? divisions = null,
string label = null,
SliderThemeData sliderTheme = null,
MediaQueryData mediaQueryData = null,
ValueChanged<float> onChanged = null,
ValueChanged<float> onChangeStart = null,
ValueChanged<float> onChangeEnd = null,
_SliderState state = null
) : base(key: key) {
this.value = value.Value;
this.divisions = divisions;
this.label = label;
this.sliderTheme = sliderTheme;
this.mediaQueryData = mediaQueryData;
this.onChanged = onChanged;
this.onChangeStart = onChangeStart;
this.onChangeEnd = onChangeEnd;
this.state = state;
}
public readonly float value;
public readonly int? divisions;
public readonly string label;
public readonly SliderThemeData sliderTheme;
public readonly MediaQueryData mediaQueryData;
public readonly ValueChanged<float> onChanged;
public readonly ValueChanged<float> onChangeStart;
public readonly ValueChanged<float> onChangeEnd;
public readonly _SliderState state;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderSlider(
value: value,
divisions: divisions,
label: label,
sliderTheme: sliderTheme,
mediaQueryData: mediaQueryData,
onChanged: onChanged,
onChangeStart: onChangeStart,
onChangeEnd: onChangeEnd,
state: state,
textDirection: Directionality.of(context),
platform: Theme.of(context).platform
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
_RenderSlider _renderObject = (_RenderSlider) renderObject;
_renderObject.value = value;
_renderObject.divisions = divisions;
_renderObject.label = label;
_renderObject.sliderTheme = sliderTheme;
_renderObject.theme = Theme.of(context);
_renderObject.mediaQueryData = mediaQueryData;
_renderObject.onChanged = onChanged;
_renderObject.onChangeStart = onChangeStart;
_renderObject.onChangeEnd = onChangeEnd;
_renderObject.textDirection = Directionality.of(context);
_renderObject.platform = Theme.of(context).platform;
}
}
class _RenderSlider : RelayoutWhenSystemFontsChangeMixinRenderBox {
static float _positionAnimationDurationMilliSeconds = 75;
static float _minimumInteractionTimeMilliSeconds = 500;
const float _minPreferredTrackWidth = 144.0f;
public _RenderSlider(
float? value = null,
int? divisions = null,
string label = null,
SliderThemeData sliderTheme = null,
MediaQueryData mediaQueryData = null,
RuntimePlatform? platform = null,
ValueChanged<float> onChanged = null,
ValueChanged<float> onChangeStart = null,
ValueChanged<float> onChangeEnd = null,
_SliderState state = null,
TextDirection? textDirection = null
) {
D.assert(value != null && value >= 0.0 && value <= 1.0);
D.assert(state != null);
D.assert(textDirection != null);
this.onChangeStart = onChangeStart;
this.onChangeEnd = onChangeEnd;
_platform = platform;
_label = label;
_value = value.Value;
_divisions = divisions;
_sliderTheme = sliderTheme;
_mediaQueryData = mediaQueryData;
_onChanged = onChanged;
_state = state;
_textDirection = textDirection.Value;
_updateLabelPainter();
GestureArenaTeam team = new GestureArenaTeam();
_drag = new HorizontalDragGestureRecognizer {
team = team,
onStart = _handleDragStart,
onUpdate = _handleDragUpdate,
onEnd = _handleDragEnd,
onCancel = _endInteraction
};
_tap = new TapGestureRecognizer {
team = team,
onTapDown = _handleTapDown,
onTapUp = _handleTapUp,
onTapCancel = _endInteraction
};
_overlayAnimation = new CurvedAnimation(
parent: _state.overlayController,
curve: Curves.fastOutSlowIn);
_valueIndicatorAnimation = new CurvedAnimation(
parent: _state.valueIndicatorController,
curve: Curves.fastOutSlowIn);
_enableAnimation = new CurvedAnimation(
parent: _state.enableController,
curve: Curves.easeInOut);
}
float _maxSliderPartWidth {
get {
float maxValue = 0;
foreach (Size size in _sliderPartSizes) {
if (size.width > maxValue) {
maxValue = size.width;
}
}
return maxValue;
}
}
float _maxSliderPartHeight {
get {
float maxValue = 0;
foreach (Size size in _sliderPartSizes) {
if (size.width > maxValue) {
maxValue = size.height;
}
}
return maxValue;
}
}
List<Size> _sliderPartSizes {
get {
return new List<Size> {
_sliderTheme.overlayShape.getPreferredSize(isInteractive, isDiscrete),
_sliderTheme.thumbShape.getPreferredSize(isInteractive, isDiscrete),
_sliderTheme.tickMarkShape.getPreferredSize(isEnabled: isInteractive,
sliderTheme: sliderTheme)
};
}
}
float _minPreferredTrackHeight {
get { return _sliderTheme.trackHeight.Value; }
}
_SliderState _state;
Animation<float> _overlayAnimation;
Animation<float> _valueIndicatorAnimation;
Animation<float> _enableAnimation;
TextPainter _labelPainter = new TextPainter();
HorizontalDragGestureRecognizer _drag;
TapGestureRecognizer _tap;
bool _active = false;
float _currentDragValue = 0.0f;
Rect _trackRect {
get {
return _sliderTheme.trackShape.getPreferredRect(
parentBox: this,
offset: Offset.zero,
sliderTheme: _sliderTheme,
isDiscrete: false
);
}
}
bool isInteractive {
get { return onChanged != null; }
}
bool isDiscrete {
get { return divisions != null && divisions.Value > 0; }
}
public float value {
get { return _value; }
set {
D.assert(value >= 0.0f && value <= 1.0f);
float convertedValue = isDiscrete ? _discretize(value) : value;
if (convertedValue == _value) {
return;
}
_value = convertedValue;
if (isDiscrete) {
float distance = (_value - _state.positionController.value).abs();
_state.positionController.duration = distance != 0.0f
? new TimeSpan(0, 0, 0, 0, (int) (_positionAnimationDurationMilliSeconds * (1.0f / distance)))
: TimeSpan.Zero;
_state.positionController.animateTo(convertedValue, curve: Curves.easeInOut);
}
else {
_state.positionController.setValue(convertedValue);
}
}
}
float _value;
public RuntimePlatform? platform {
get { return _platform; }
set {
if (_platform == value) {
return;
}
_platform = value;
}
}
RuntimePlatform? _platform;
public int? divisions {
get { return _divisions; }
set {
if (value == _divisions) {
return;
}
_divisions = value;
markNeedsPaint();
}
}
int? _divisions;
public string label {
get { return _label; }
set {
if (value == _label) {
return;
}
_label = value;
_updateLabelPainter();
}
}
string _label;
public SliderThemeData sliderTheme {
get { return _sliderTheme; }
set {
if (value == _sliderTheme) {
return;
}
_sliderTheme = value;
markNeedsPaint();
}
}
SliderThemeData _sliderTheme;
public ThemeData theme {
get { return _theme; }
set {
if (value == _theme) {
return;
}
_theme = value;
markNeedsPaint();
}
}
ThemeData _theme;
public MediaQueryData mediaQueryData {
get { return _mediaQueryData; }
set {
if (value == _mediaQueryData) {
return;
}
_mediaQueryData = value;
_updateLabelPainter();
}
}
MediaQueryData _mediaQueryData;
public ValueChanged<float> onChanged {
get { return _onChanged; }
set {
if (value == _onChanged) {
return;
}
bool wasInteractive = isInteractive;
_onChanged = value;
if (wasInteractive != isInteractive) {
if (isInteractive) {
_state.enableController.forward();
}
else {
_state.enableController.reverse();
}
markNeedsPaint();
}
}
}
ValueChanged<float> _onChanged;
public ValueChanged<float> onChangeStart;
public ValueChanged<float> onChangeEnd;
public TextDirection textDirection {
get { return _textDirection; }
set {
if (value == _textDirection) {
return;
}
_textDirection = value;
_updateLabelPainter();
}
}
TextDirection _textDirection;
public bool showValueIndicator {
get {
bool showValueIndicator = false;
switch (_sliderTheme.showValueIndicator) {
case ShowValueIndicator.onlyForDiscrete:
showValueIndicator = isDiscrete;
break;
case ShowValueIndicator.onlyForContinuous:
showValueIndicator = !isDiscrete;
break;
case ShowValueIndicator.always:
showValueIndicator = true;
break;
case ShowValueIndicator.never:
showValueIndicator = false;
break;
}
return showValueIndicator;
}
}
float _adjustmentUnit {
get {
switch (_platform) {
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXPlayer:
case RuntimePlatform.OSXEditor:
return 0.1f;
default:
return 0.05f;
}
}
}
void _updateLabelPainter() {
if (label != null) {
_labelPainter.text = new TextSpan(
style: _sliderTheme.valueIndicatorTextStyle,
text: label
);
_labelPainter.textDirection = textDirection;
_labelPainter.textScaleFactor = _mediaQueryData.textScaleFactor;
_labelPainter.layout();
}
else {
_labelPainter.text = null;
}
markNeedsLayout();
}
public override void systemFontsDidChange() {
base.systemFontsDidChange();
_labelPainter.markNeedsLayout();
_updateLabelPainter();
}
public override void attach(object owner) {
base.attach(owner);
_overlayAnimation.addListener(markNeedsPaint);
_valueIndicatorAnimation.addListener(markNeedsPaint);
_enableAnimation.addListener(markNeedsPaint);
_state.positionController.addListener(markNeedsPaint);
}
public override void detach() {
_overlayAnimation.removeListener(markNeedsPaint);
_valueIndicatorAnimation.removeListener(markNeedsPaint);
_enableAnimation.removeListener(markNeedsPaint);
_state.positionController.removeListener(markNeedsPaint);
base.detach();
}
float _getValueFromVisualPosition(float visualPosition) {
switch (textDirection) {
case TextDirection.rtl:
return 1.0f - visualPosition;
case TextDirection.ltr:
return visualPosition;
}
return visualPosition;
}
float _getValueFromGlobalPosition(Offset globalPosition) {
float visualPosition =
(globalToLocal(globalPosition).dx - _trackRect.left) / _trackRect.width;
return _getValueFromVisualPosition(visualPosition);
}
float _discretize(float value) {
float result = value.clamp(0.0f, 1.0f);
if (isDiscrete) {
result = (result * divisions.Value).round() * 1.0f / divisions.Value;
}
return result;
}
void _startInteraction(Offset globalPosition) {
if (isInteractive) {
_active = true;
if (onChangeStart != null) {
onChangeStart(_discretize(value));
}
_currentDragValue = _getValueFromGlobalPosition(globalPosition);
onChanged(_discretize(_currentDragValue));
_state.overlayController.forward();
if (showValueIndicator) {
_state.valueIndicatorController.forward();
_state.interactionTimer?.cancel();
_state.interactionTimer = Timer.create(
new TimeSpan(0, 0, 0, 0,
(int) (_minimumInteractionTimeMilliSeconds * scheduler_.timeDilation)),
() => {
_state.interactionTimer = null;
if (!_active &&
_state.valueIndicatorController.status == AnimationStatus.completed) {
_state.valueIndicatorController.reverse();
}
}
);
}
}
}
void _endInteraction() {
if (_active && _state.mounted) {
if (onChangeEnd != null) {
onChangeEnd(_discretize(_currentDragValue));
}
_active = false;
_currentDragValue = 0.0f;
_state.overlayController.reverse();
if (showValueIndicator && _state.interactionTimer == null) {
_state.valueIndicatorController.reverse();
}
}
}
void _handleDragStart(DragStartDetails details) {
_startInteraction(details.globalPosition);
}
void _handleDragUpdate(DragUpdateDetails details) {
if (isInteractive) {
float valueDelta = details.primaryDelta.Value / _trackRect.width;
switch (textDirection) {
case TextDirection.rtl:
_currentDragValue -= valueDelta;
break;
case TextDirection.ltr:
_currentDragValue += valueDelta;
break;
}
onChanged(_discretize(_currentDragValue));
}
}
void _handleDragEnd(DragEndDetails details) {
_endInteraction();
}
void _handleTapDown(TapDownDetails details) {
_startInteraction(details.globalPosition);
}
void _handleTapUp(TapUpDetails details) {
_endInteraction();
}
protected override bool hitTestSelf(Offset position) {
return true;
}
public override void handleEvent(PointerEvent evt, HitTestEntry entry) {
D.assert(debugHandleEvent(evt, entry));
if (evt is PointerDownEvent && isInteractive) {
_drag.addPointer((PointerDownEvent) evt);
_tap.addPointer((PointerDownEvent) evt);
}
}
protected internal override float computeMinIntrinsicWidth(float height) {
return _minPreferredTrackWidth + _maxSliderPartWidth;
}
protected internal override float computeMaxIntrinsicWidth(float height) {
return _minPreferredTrackWidth + _maxSliderPartWidth;
}
protected internal override float computeMinIntrinsicHeight(float width) {
return Mathf.Max(_minPreferredTrackHeight, _maxSliderPartHeight);
}
protected internal override float computeMaxIntrinsicHeight(float width) {
return Mathf.Max(_minPreferredTrackHeight, _maxSliderPartHeight);
}
protected override bool sizedByParent {
get { return true; }
}
protected override void performResize() {
size = new Size(
constraints.hasBoundedWidth
? constraints.maxWidth
: _minPreferredTrackWidth + _maxSliderPartWidth,
constraints.hasBoundedHeight
? constraints.maxHeight
: Mathf.Max(_minPreferredTrackHeight, _maxSliderPartHeight)
);
}
public override void paint(PaintingContext context, Offset offset) {
float value = _state.positionController.value;
float visualPosition = value;
switch (textDirection) {
case TextDirection.rtl:
visualPosition = 1.0f - value;
break;
case TextDirection.ltr:
visualPosition = value;
break;
}
Rect trackRect = _sliderTheme.trackShape.getPreferredRect(
parentBox: this,
offset: offset,
sliderTheme: _sliderTheme,
isDiscrete: isDiscrete
);
Offset thumbCenter = new Offset(trackRect.left + visualPosition * trackRect.width, trackRect.center.dy);
_sliderTheme.trackShape.paint(
context,
offset,
parentBox: this,
sliderTheme: _sliderTheme,
enableAnimation: _enableAnimation,
textDirection: _textDirection,
thumbCenter: thumbCenter,
isDiscrete: isDiscrete,
isEnabled: isInteractive
);
if (!_overlayAnimation.isDismissed) {
_sliderTheme.overlayShape.paint(
context,
thumbCenter,
activationAnimation: _overlayAnimation,
enableAnimation: _enableAnimation,
isDiscrete: isDiscrete,
labelPainter: _labelPainter,
parentBox: this,
sliderTheme: _sliderTheme,
textDirection: _textDirection,
value: _value
);
}
if (isDiscrete) {
float tickMarkWidth = _sliderTheme.tickMarkShape.getPreferredSize(
isEnabled: isInteractive,
sliderTheme: _sliderTheme
).width;
float adjustedTrackWidth = trackRect.width - tickMarkWidth;
if (adjustedTrackWidth / divisions.Value >= 3.0f * tickMarkWidth) {
float dy = trackRect.center.dy;
for (int i = 0; i <= divisions; i++) {
float tickValue = i / divisions.Value;
float dx = trackRect.left + tickValue * adjustedTrackWidth + tickMarkWidth / 2;
Offset tickMarkOffset = new Offset(dx, dy);
_sliderTheme.tickMarkShape.paint(
context,
tickMarkOffset,
parentBox: this,
sliderTheme: _sliderTheme,
enableAnimation: _enableAnimation,
textDirection: _textDirection,
thumbCenter: thumbCenter,
isEnabled: isInteractive
);
}
}
}
if (isInteractive && label != null && !_valueIndicatorAnimation.isDismissed) {
if (showValueIndicator) {
_sliderTheme.valueIndicatorShape.paint(
context,
thumbCenter,
activationAnimation: _valueIndicatorAnimation,
enableAnimation: _enableAnimation,
isDiscrete: isDiscrete,
labelPainter: _labelPainter,
parentBox: this,
sliderTheme: _sliderTheme,
textDirection: _textDirection,
value: _value
);
}
}
_sliderTheme.thumbShape.paint(
context,
thumbCenter,
activationAnimation: _valueIndicatorAnimation,
enableAnimation: _enableAnimation,
isDiscrete: isDiscrete,
labelPainter: _labelPainter,
parentBox: this,
sliderTheme: _sliderTheme,
textDirection: _textDirection,
value: _value
);
}
}
}

1001
com.unity.uiwidgets/Runtime/material/tabs.cs
文件差异内容过多而无法显示
查看文件

19
com.unity.uiwidgets/Runtime/redux/redux_logging.cs


using UnityEngine;
namespace Unity.UIWidgets.Redux {
public static class ReduxLogging {
public static Middleware<State> create<State>() {
return (store) => (next) => new DispatcherImpl((action) => {
var previousState = store.getState();
var previousStateDump = JsonUtility.ToJson(previousState);
var result = next.dispatch(action);
var afterState = store.getState();
var afterStateDump = JsonUtility.ToJson(afterState);
Debug.LogFormat("Action name={0} data={1}", action.ToString(), JsonUtility.ToJson(action));
Debug.LogFormat("previousState=\n{0}", previousStateDump);
Debug.LogFormat("afterState=\n{0}", afterStateDump);
return result;
});
}
}
}

11
com.unity.uiwidgets/Runtime/redux/redux_logging.cs.meta


fileFormatVersion: 2
guid: 66d5d5237e5f84f7f870b6e8d2b87815
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

32
com.unity.uiwidgets/Runtime/redux/redux_thunk.cs


using System;
namespace Unity.UIWidgets.Redux {
public static class ReduxThunk {
public static Middleware<State> create<State>() {
return store => next => new DispatcherImpl(action => {
var thunkAction = action as ThunkAction<State>;
if (thunkAction != null && thunkAction.action != null) {
return thunkAction.action(store.dispatcher, store.getState);
}
return next.dispatch(action);
});
}
}
public sealed class ThunkAction<State> {
public readonly Func<Dispatcher, Func<State>, object> action;
public readonly string displayName;
public ThunkAction(
Func<Dispatcher, Func<State>, object> action = null,
string displayName = null) {
this.action = action;
this.displayName = displayName ?? "";
}
public override string ToString() {
return "ThunkAction(" + displayName + ")";
}
}
}

11
com.unity.uiwidgets/Runtime/redux/redux_thunk.cs.meta


fileFormatVersion: 2
guid: f837de040a3fa4a3fb3e6c344153e1eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

81
com.unity.uiwidgets/Runtime/redux/store.cs


using System;
using System.Linq;
namespace Unity.UIWidgets {
public interface Dispatcher {
T dispatch<T>(object action);
object dispatch(object action);
}
public class DispatcherImpl : Dispatcher {
readonly Func<object, object> _impl;
public DispatcherImpl(Func<object, object> impl) {
_impl = impl;
}
public T dispatch<T>(object action) {
if (_impl == null) {
return default;
}
return (T) _impl(action);
}
public object dispatch(object action) {
if (_impl == null) {
return default;
}
return _impl(action);
}
}
public delegate State Reducer<State>(State previousState, object action);
public delegate Func<Dispatcher, Dispatcher> Middleware<State>(Store<State> store);
public delegate void StateChangedHandler<State>(State action);
public class Store<State> {
public StateChangedHandler<State> stateChanged;
readonly Dispatcher _dispatcher;
readonly Reducer<State> _reducer;
State _state;
public Store(
Reducer<State> reducer,
State initialState = default,
params Middleware<State>[] middleware) {
_reducer = reducer;
_dispatcher = _applyMiddleware(middleware);
_state = initialState;
}
public Dispatcher dispatcher {
get { return _dispatcher; }
}
public State getState() {
return _state;
}
Dispatcher _applyMiddleware(params Middleware<State>[] middleware) {
return middleware.Reverse().Aggregate<Middleware<State>, Dispatcher>(
new DispatcherImpl(_innerDispatch),
(current, middlewareItem) => middlewareItem(this)(current));
}
object _innerDispatch(object action) {
_state = _reducer(_state, action);
if (stateChanged != null) {
stateChanged(_state);
}
return action;
}
}
}

11
com.unity.uiwidgets/Runtime/redux/store.cs.meta


fileFormatVersion: 2
guid: 14bfb41ffcfd144f1b32a04eff5f93d0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

172
com.unity.uiwidgets/Runtime/redux/widget_redux.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.Redux {
public class StoreProvider<State> : InheritedWidget {
readonly Store<State> _store;
public StoreProvider(
Store<State> store = null,
Widget child = null,
Key key = null) : base(key: key, child: child) {
D.assert(store != null);
D.assert(child != null);
_store = store;
}
public static Store<State> of(BuildContext context) {
var type = _typeOf<StoreProvider<State>>();
StoreProvider<State> provider = context.inheritFromWidgetOfExactType(type) as StoreProvider<State>;
if (provider == null) {
throw new UIWidgetsError("StoreProvider is missing");
}
return provider._store;
}
static Type _typeOf<T>() {
return typeof(T);
}
public override bool updateShouldNotify(InheritedWidget old) {
return !Equals(objA: _store, objB: ((StoreProvider<State>) old)._store);
}
}
public delegate Widget ViewModelBuilder<in ViewModel>(BuildContext context, ViewModel viewModel, Dispatcher dispatcher);
public delegate ViewModel StoreConverter<in State, out ViewModel>(State state);
public delegate bool ShouldRebuildCallback<in ViewModel>(ViewModel previous, ViewModel current);
public class StoreConnector<State, ViewModel> : StatelessWidget {
public readonly ViewModelBuilder<ViewModel> builder;
public readonly StoreConverter<State, ViewModel> converter;
public readonly ShouldRebuildCallback<ViewModel> shouldRebuild;
public readonly bool pure;
public StoreConnector(
ViewModelBuilder<ViewModel> builder = null,
StoreConverter<State, ViewModel> converter = null,
bool pure = false,
ShouldRebuildCallback<ViewModel> shouldRebuild = null,
Key key = null) : base(key) {
D.assert(builder != null);
D.assert(converter != null);
this.pure = pure;
this.builder = builder;
this.converter = converter;
this.shouldRebuild = shouldRebuild;
}
public override Widget build(BuildContext context) {
return new _StoreListener<State, ViewModel>(
store: StoreProvider<State>.of(context),
builder: builder,
converter: converter,
pure: pure,
shouldRebuild: shouldRebuild
);
}
}
public class _StoreListener<State, ViewModel> : StatefulWidget {
public readonly ViewModelBuilder<ViewModel> builder;
public readonly StoreConverter<State, ViewModel> converter;
public readonly Store<State> store;
public readonly ShouldRebuildCallback<ViewModel> shouldRebuild;
public readonly bool pure;
public _StoreListener(
ViewModelBuilder<ViewModel> builder = null,
StoreConverter<State, ViewModel> converter = null,
Store<State> store = null,
bool pure = false,
ShouldRebuildCallback<ViewModel> shouldRebuild = null,
Key key = null) : base(key) {
D.assert(builder != null);
D.assert(converter != null);
D.assert(store != null);
this.store = store;
this.builder = builder;
this.converter = converter;
this.pure = pure;
this.shouldRebuild = shouldRebuild;
}
public override widgets.State createState() {
return new _StoreListenerState<State, ViewModel>();
}
}
class _StoreListenerState<State, ViewModel> : State<_StoreListener<State, ViewModel>> {
ViewModel latestValue;
public override void initState() {
base.initState();
_init();
}
public override void dispose() {
widget.store.stateChanged -= _handleStateChanged;
base.dispose();
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
var oldStore = ((_StoreListener<State, ViewModel>) oldWidget).store;
if (widget.store != oldStore) {
oldStore.stateChanged -= _handleStateChanged;
_init();
}
base.didUpdateWidget(oldWidget);
}
void _init() {
widget.store.stateChanged += _handleStateChanged;
latestValue = widget.converter(widget.store.getState());
}
void _handleStateChanged(State state) {
if (Window.instance._panel != null) {
_innerStateChanged(state: state);
}
else {
var isolate = Isolate.current;
using (Isolate.getScope(isolate: isolate)) {
_innerStateChanged(state: state);
}
}
}
void _innerStateChanged(State state) {
var preValue = latestValue;
latestValue = widget.converter(widget.store.getState());
if (widget.shouldRebuild != null) {
if (!widget.shouldRebuild(preValue, latestValue)) {
return;
}
}
else if (widget.pure) {
if (Equals(preValue, latestValue)) {
return;
}
}
setState();
}
public override Widget build(BuildContext context) {
return widget.builder(context, latestValue, widget.store.dispatcher);
}
}
}

11
com.unity.uiwidgets/Runtime/redux/widget_redux.cs.meta


fileFormatVersion: 2
guid: a1765e003a4744e39b381a0bd927735a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs.meta


fileFormatVersion: 2
guid: 347e0378e419f46f2af69e1214f1ae5b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs.meta


fileFormatVersion: 2
guid: b9e88c33e9f304d40bab9c27f1276033
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs.meta


fileFormatVersion: 2
guid: cc34344049d222b468f2487b97076448
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs.meta


fileFormatVersion: 2
guid: 0152b6f575e6ca44baea965a23ebe498
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs.meta


fileFormatVersion: 2
guid: fecd06f805d0b0f4ead134b1ad6a9a49
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs.meta


fileFormatVersion: 2
guid: b2a39cf0b83823749a13aebaf25cfb1b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs.meta


fileFormatVersion: 2
guid: 1cba65c03fbf50f4cac974273a7c9445
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

11
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs.meta


fileFormatVersion: 2
guid: f510d7fbd19431046bfb4b92c39b4da4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

47
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/BottomAppBarSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class BottomAppBarSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
showPerformanceOverlay: false,
home: new BottomAppBarWidget()));
}
protected new void OnEnable() {
base.OnEnable();
}
}
public class BottomAppBarWidget : StatelessWidget {
public BottomAppBarWidget(Key key = null) : base(key) {
}
public override Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Colors.grey,
bottomNavigationBar: new BottomAppBar(
child: new Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: new List<Widget> {
new IconButton(icon: new Icon(Unity.UIWidgets.material.Icons.menu), onPressed: () => { }),
new IconButton(icon: new Icon(Unity.UIWidgets.material.Icons.account_balance),
onPressed: () => { })
})));
}
}
}

107
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/DividerAndButton.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class DividerAndButton : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MyApp());
}
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new MaterialApp(
home: new DividerAndButtonSample()
);
}
}
public class DividerAndButtonSample : StatefulWidget {
public DividerAndButtonSample(Key key = null) : base(key) {
}
public override State createState() {
return new _DividerAndButtonState();
}
}
public class _DividerAndButtonState : State<DividerAndButtonSample> {
string title = "Hello";
string subtitle = "World";
TextEditingController controller = new TextEditingController("xxxxxx");
public override Widget build(BuildContext context) {
return new DividerTheme(
data: new DividerThemeData(
),
child: new Container(
height: 200,
padding: EdgeInsets.all(10),
decoration: new BoxDecoration(
color: new Color(0xFFEF1F7F),
border: Border.all(color: Color.fromARGB(255, 0xDF, 0x10, 0x70), width: 5),
borderRadius: BorderRadius.all(20)
),
child: new Center(
child: new Column(
children: new List<Widget>() {
new Text(this.title),
new Divider(),
new Text(this.subtitle),
new Divider(),
new Container(
width: 500,
decoration: new BoxDecoration(border: Border.all(new Color(0xFF00FF00), 1)),
child: new EditableText(
controller: this.controller,
focusNode: new FocusNode(),
style: new TextStyle(
fontSize: 18,
height: 1.5f,
color: new Color(0xFFFF89FD)),
cursorColor: Color.fromARGB(255, 0, 0, 0),
backgroundCursorColor: Colors.grey
)
),
new Divider(),
new ButtonBar(
children: new List<Widget> {
new FlatButton(
onPressed: () => {
this.setState(() => { this.title = this.controller.text; });
},
padding: EdgeInsets.all(5.0f),
child: new Center(
child: new Text("Set Title")
)
),
new RaisedButton(
onPressed: () => {
this.setState(() => { this.subtitle = this.controller.text; });
},
padding: EdgeInsets.all(5.0f),
child: new Center(
child: new Text("Set Subtitle")
)
)
}
)
}
)
)
));
}
}
}
}

204
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialAppBarSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class MaterialAppBarSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
showPerformanceOverlay: false,
home: new MaterialAppBarWidget()));
}
protected new void OnEnable() {
base.OnEnable();
}
}
public class MaterialAppBarWidget : StatefulWidget {
public MaterialAppBarWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialAppBarWidgetState();
}
}
public class MaterialAppBarWidgetState : State<MaterialAppBarWidget> {
Choice _selectedChoice = Choice.choices[0];
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
VoidCallback _showBottomSheetCallback;
public override void initState() {
base.initState();
this._showBottomSheetCallback = this._showBottomSheet;
}
void _showBottomSheet() {
this.setState(() => { this._showBottomSheetCallback = null; });
this._scaffoldKey.currentState.showBottomSheet((BuildContext subContext) => {
ThemeData themeData = Theme.of(subContext);
return new Container(
decoration: new BoxDecoration(
border: new Border(
top: new BorderSide(
color: themeData.disabledColor))),
child: new Padding(
padding: EdgeInsets.all(32.0f),
child: new Text("This is a Material persistent bottom sheet. Drag downwards to dismiss it.",
textAlign: TextAlign.center,
style: new TextStyle(
color: themeData.accentColor,
fontSize: 16.0f))
)
);
}).closed.then((object obj) => {
if (this.mounted) {
this.setState(() => { this._showBottomSheetCallback = this._showBottomSheet; });
}
});
}
void _select(Choice choice) {
this.setState(() => { this._selectedChoice = choice; });
}
public override Widget build(BuildContext context) {
return new Scaffold(
key: this._scaffoldKey,
appBar: new AppBar(
title: new Text("Basic AppBar"),
actions: new List<Widget> {
new IconButton(
icon: new Icon(Choice.choices[0].icon),
//color: Colors.blue,
onPressed: () => { this._select((Choice.choices[0])); }
),
new IconButton(
icon: new Icon(Choice.choices[1].icon),
//color: Colors.blue,
onPressed: () => { this._select((Choice.choices[1])); }
),
new PopupMenuButton<Choice>(
onSelected: this._select,
itemBuilder: (BuildContext subContext) => {
List<PopupMenuEntry<Choice>> popupItems = new List<PopupMenuEntry<Choice>>();
for (int i = 2; i < Choice.choices.Count; i++) {
popupItems.Add(new PopupMenuItem<Choice>(
value: Choice.choices[i],
child: new Text(Choice.choices[i].title)));
}
return popupItems;
}
)
}
),
body: new Padding(
padding: EdgeInsets.all(16.0f),
child: new ChoiceCard(choice: this._selectedChoice)
),
floatingActionButton: new FloatingActionButton(
backgroundColor: Colors.redAccent,
child: new Icon(Unity.UIWidgets.material.Icons.add_alert),
onPressed: this._showBottomSheetCallback
),
drawer: new Drawer(
child: new ListView(
padding: EdgeInsets.zero,
children: new List<Widget> {
new ListTile(
leading: new Icon(Unity.UIWidgets.material.Icons.account_circle),
title: new Text("Login"),
onTap: () => { }
),
new Divider(
height: 2.0f),
new ListTile(
leading: new Icon(Unity.UIWidgets.material.Icons.account_balance_wallet),
title: new Text("Wallet"),
onTap: () => { }
),
new Divider(
height: 2.0f),
new ListTile(
leading: new Icon(Unity.UIWidgets.material.Icons.accessibility),
title: new Text("Balance"),
onTap: () => { }
)
}
)
)
);
}
}
class Choice {
public Choice(string title, IconData icon) {
this.title = title;
this.icon = icon;
}
public readonly string title;
public readonly IconData icon;
public static List<Choice> choices = new List<Choice> {
new Choice("Car", Unity.UIWidgets.material.Icons.directions_car),
new Choice("Bicycle", Unity.UIWidgets.material.Icons.directions_bike),
new Choice("Boat", Unity.UIWidgets.material.Icons.directions_boat),
new Choice("Bus", Unity.UIWidgets.material.Icons.directions_bus),
new Choice("Train", Unity.UIWidgets.material.Icons.directions_railway),
new Choice("Walk", Unity.UIWidgets.material.Icons.directions_walk)
};
}
class ChoiceCard : StatelessWidget {
public ChoiceCard(Key key = null, Choice choice = null) : base(key: key) {
this.choice = choice;
}
public readonly Choice choice;
public override Widget build(BuildContext context) {
TextStyle textStyle = Theme.of(context).textTheme.display1;
return new Card(
color: Colors.white,
child: new Center(
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: new List<Widget> {
new Icon(this.choice.icon, size: 128.0f, color: textStyle.color),
new RaisedButton(
child: new Text(this.choice.title, style: textStyle),
onPressed: () => {
SnackBar snackBar = new SnackBar(
content: new Text(this.choice.title + " is chosen !"),
action: new SnackBarAction(
label: "Ok",
onPressed: () => { }));
Scaffold.of(context).showSnackBar(snackBar);
})
}
)
)
);
}
}
}

73
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Material = Unity.UIWidgets.material.Material;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class MaterialButtonSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
showPerformanceOverlay: false,
home: new MaterialButtonWidget()));
}
protected new void OnEnable() {
base.OnEnable();
}
}
public class MaterialButtonWidget : StatefulWidget {
public MaterialButtonWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialButtonWidgetState();
}
}
public class MaterialButtonWidgetState : State<MaterialButtonWidget> {
public override Widget build(BuildContext context) {
return new Stack(
children: new List<Widget> {
new Material(
child: new Center(
child: new Column(
children: new List<Widget> {
new Padding(padding: EdgeInsets.only(top: 30f)),
new MaterialButton(
shape: new RoundedRectangleBorder(borderRadius: BorderRadius.all(20.0f)),
color: new Color(0xFF00FF00),
splashColor: new Color(0xFFFF0011),
highlightColor: new Color(0x88FF0011),
child: new Text("Click Me"),
onPressed: () => { Debug.Log("pressed flat button"); }
),
new Padding(padding: EdgeInsets.only(top: 30f)),
new MaterialButton(
shape: new RoundedRectangleBorder(borderRadius: BorderRadius.all(20.0f)),
color: new Color(0xFFFF00FF),
splashColor: new Color(0xFFFF0011),
highlightColor: new Color(0x88FF0011),
elevation: 4.0f,
child: new Text("Click Me"),
onPressed: () => { Debug.Log("pressed raised button"); }
)
}
)
)
)
}
);
}
}
}

56
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs


using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Material = Unity.UIWidgets.material.Material;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class MaterialInkWellSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
showPerformanceOverlay: false,
home: new MaterialInkWellWidget()));
}
protected new void OnEnable() {
base.OnEnable();
}
}
public class MaterialInkWellWidget : StatefulWidget {
public MaterialInkWellWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialInkWidgetState();
}
}
public class MaterialInkWidgetState : State<MaterialInkWellWidget> {
public override Widget build(BuildContext context) {
return new Material(
//color: Colors.blue,
child: new Center(
child: new Container(
width: 200,
height: 200,
child: new InkWell(
borderRadius: BorderRadius.circular(2.0f),
highlightColor: new Color(0xAAFF0000),
splashColor: new Color(0xAA0000FF),
onTap: () => { Debug.Log("on tap"); }
)
)
)
);
}
}
}

86
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class MaterialNavigationBarSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
showPerformanceOverlay: false,
home: new MaterialNavigationBarWidget()));
}
protected new void OnEnable() {
base.OnEnable();
}
}
class MaterialNavigationBarWidget : StatefulWidget {
public MaterialNavigationBarWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialNavigationBarWidgetState();
}
}
class MaterialNavigationBarWidgetState : SingleTickerProviderStateMixin<MaterialNavigationBarWidget> {
int _currentIndex = 0;
public MaterialNavigationBarWidgetState() {
}
public override Widget build(BuildContext context) {
return new Scaffold(
bottomNavigationBar: new Container(
height: 100,
color: Colors.blue,
child: new Center(
child: new BottomNavigationBar(
type: BottomNavigationBarType.shifting,
// type: BottomNavigationBarType.fix,
items: new List<BottomNavigationBarItem> {
new BottomNavigationBarItem(
icon: new Icon(icon: Unity.UIWidgets.material.Icons.work, size: 30),
title: new Text("Work"),
activeIcon: new Icon(icon: Unity.UIWidgets.material.Icons.work, size: 50),
backgroundColor: Colors.blue
),
new BottomNavigationBarItem(
icon: new Icon(icon: Unity.UIWidgets.material.Icons.home, size: 30),
title: new Text("Home"),
activeIcon: new Icon(icon: Unity.UIWidgets.material.Icons.home, size: 50),
backgroundColor: Colors.blue
),
new BottomNavigationBarItem(
icon: new Icon(icon: Unity.UIWidgets.material.Icons.shop, size: 30),
title: new Text("Shop"),
activeIcon: new Icon(icon: Unity.UIWidgets.material.Icons.shop, size: 50),
backgroundColor: Colors.blue
),
new BottomNavigationBarItem(
icon: new Icon(icon: Unity.UIWidgets.material.Icons.school, size: 30),
title: new Text("School"),
activeIcon: new Icon(icon: Unity.UIWidgets.material.Icons.school, size: 50),
backgroundColor: Colors.blue
),
},
currentIndex: this._currentIndex,
onTap: (value) => { this.setState(() => { this._currentIndex = value; }); }
)
)
)
);
}
}
}

61
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class MaterialSliderSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
showPerformanceOverlay: false,
home: new MaterialSliderWidget()));
}
protected new void OnEnable() {
base.OnEnable();
}
}
public class MaterialSliderWidget : StatefulWidget {
public override State createState() {
return new MaterialSliderState();
}
}
public class MaterialSliderState : State<MaterialSliderWidget> {
float _value = 0.8f;
void onChanged(float value) {
this.setState(() => { this._value = value; });
}
public override Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Slider and Indicators")),
body: new Column(
children: new List<Widget> {
new Padding(
padding: EdgeInsets.only(top: 100.0f),
child: new Container(
child: new Slider(
divisions: 10,
min: 0.4f,
label: "Here",
value: this._value,
onChanged: this.onChanged))
)
}
)
);
}
}
}

130
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class MaterialTabBarSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
showPerformanceOverlay: false,
home: new TabBarDemo()));
}
protected new void OnEnable() {
base.OnEnable();
}
}
public class TabBarDemo : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new MaterialTabBarWidget();
/*
return new DefaultTabController(
length: 3,
child: new Scaffold(
appBar: new AppBar(
bottom: new TabBar(
tabs: new List<Widget> {
new Tab(icon: new Icon(Icons.directions_car)),
new Tab(icon: new Icon(Icons.directions_transit)),
new Tab(icon: new Icon(Icons.directions_bike)),
}
),
title: new Text("Tabs Demo")
),
body: new TabBarView(
children: new List<Widget> {
new Icon(Icons.directions_car),
new Icon(Icons.directions_transit),
new Icon(Icons.directions_bike),
}
)
)
);*/
}
}
public class MaterialTabBarWidget : StatefulWidget {
public MaterialTabBarWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialTabBarWidgetState();
}
}
public class MaterialTabBarWidgetState : SingleTickerProviderStateMixin<MaterialTabBarWidget> {
TabController _tabController;
public override void initState() {
base.initState();
this._tabController = new TabController(vsync: this, length: Choice.choices.Count);
}
public override void dispose() {
this._tabController.dispose();
base.dispose();
}
void _nextPage(int delta) {
int newIndex = this._tabController.index + delta;
if (newIndex < 0 || newIndex >= this._tabController.length) {
return;
}
this._tabController.animateTo(newIndex);
}
public override Widget build(BuildContext context) {
List<Widget> tapChildren = new List<Widget>();
foreach (Choice choice in Choice.choices) {
tapChildren.Add(
new Padding(
padding: EdgeInsets.all(16.0f),
child: new ChoiceCard(choice: choice)));
}
return new Scaffold(
appBar: new AppBar(
title: new Center(
child: new Text("AppBar Bottom Widget")
),
leading: new IconButton(
tooltip: "Previous choice",
icon: new Icon(Unity.UIWidgets.material.Icons.arrow_back),
onPressed: () => { this._nextPage(-1); }
),
actions: new List<Widget> {
new IconButton(
icon: new Icon(Unity.UIWidgets.material.Icons.arrow_forward),
tooltip: "Next choice",
onPressed: () => { this._nextPage(1); })
},
bottom: new PreferredSize(
preferredSize: Size.fromHeight(48.0f),
child: new Theme(
data: Theme.of(context).copyWith(accentColor: Colors.white),
child: new Container(
height: 48.0f,
alignment: Alignment.center,
child: new TabPageSelector(
controller: this._tabController))))
),
body: new TabBarView(
controller: this._tabController,
children: tapChildren
));
}
}
}

82
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Image = Unity.UIWidgets.widgets.Image;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class MaterialThemeSample: UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
home: new MaterialThemeSampleWidget(),
darkTheme: new ThemeData(primaryColor: Colors.black26)
));
}
protected new void OnEnable() {
base.OnEnable();
}
}
public class MaterialThemeSampleWidget: StatefulWidget {
public override State createState() {
return new _MaterialThemeSampleWidgetState();
}
}
class _MaterialThemeSampleWidgetState : State<MaterialThemeSampleWidget> {
public override Widget build(BuildContext context) {
return new Theme(
data: new ThemeData(
appBarTheme: new AppBarTheme(
color: Colors.purple
),
bottomAppBarTheme: new BottomAppBarTheme(
color: Colors.blue
),
cardTheme: new CardTheme(
color: Colors.red,
elevation: 2.0f
)
),
child: new Scaffold(
appBar: new AppBar(title: new Text("Test App Bar Theme")),
body: new Center(
child: new Card(
shape: new RoundedRectangleBorder(
borderRadius: BorderRadius.all(5.0f)
),
child: new Container(
height: 250,
child: new Column(
children: new List<Widget> {
new Text("Card Theme")
}
)
)
)
),
bottomNavigationBar: new BottomAppBar(
child: new Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: new List<Widget> {
new IconButton(icon: new Icon(Unity.UIWidgets.material.Icons.menu), onPressed: () => { }),
new IconButton(icon: new Icon(Unity.UIWidgets.material.Icons.account_balance), onPressed: () => { })
})
)
)
);
}
}
}

79
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs


using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Material = Unity.UIWidgets.material.Material;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class ReorderableListSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
showPerformanceOverlay: false,
home: new MaterialReorderableListViewWidget()));
}
protected new void OnEnable() {
base.OnEnable();
}
}
class MaterialReorderableListViewWidget : StatefulWidget {
public MaterialReorderableListViewWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialReorderableListViewWidgetState();
}
}
class MaterialReorderableListViewWidgetState : State<MaterialReorderableListViewWidget> {
List<string> _list = new List<string> {"Apple", "Ball", "Cat", "Dog", "Elephant"};
public override Widget build(BuildContext context) {
return new Scaffold(
body: new ReorderableListView(
children: this._list.Select<string, Widget>((item) =>
{
return new ListTile(
Key.key(item),
title: new Text(item),
trailing: new Icon(Icons.menu));
}).ToList(),
onReorder: (int start, int current) =>
{
if (start < current) {
int end = current - 1;
string startItem = _list[start];
int i = 0;
int local = start;
do {
_list[local] = _list[++local];
i++;
} while (i < end - start);
_list[end] = startItem;
}
// dragging from bottom to top
else if (start > current) {
string startItem = _list[start];
for (int i = start; i > current; i--) {
_list[i] = _list[i - 1];
}
_list[current] = startItem;
}
setState(() => {});
}
)
);
}
}
}

53
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class TableSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
showPerformanceOverlay: false,
home: new TableWidget()));
}
protected new void OnEnable() {
base.OnEnable();
}
}
public class TableWidget : StatelessWidget {
public TableWidget(Key key = null) : base(key) {
}
public override Widget build(BuildContext context) {
return new Scaffold(
body: new Table(
children: new List<TableRow> {
new TableRow(
decoration: new BoxDecoration(color: Colors.blue),
children: new List<Widget> {
new Text("item 1"),
new Text("item 2")
}
),
new TableRow(children: new List<Widget> {
new Text("item 3"),
new Text("item 4")
}
)
},
defaultVerticalAlignment: TableCellVerticalAlignment.middle));
}
}
}

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery.meta


fileFormatVersion: 2
guid: 20b07a92c4c64919aa3adf9322758a65
timeCreated: 1612322595

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/UIWidgetsGallery.asmdef


{
"name": "UIWidgetsGallery",
"references": [
"Unity.UIWidgets"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存