Shiyun Wen
4 年前
当前提交
de06dd9e
共有 78 个文件被更改,包括 10352 次插入 和 126 次删除
-
218Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs
-
4com.unity.uiwidgets/Runtime/rendering/error.cs
-
6com.unity.uiwidgets/Runtime/ui2/painting.cs
-
2com.unity.uiwidgets/Runtime/widgets/automatic_keep_alive.cs
-
7com.unity.uiwidgets/Runtime/widgets/localizations.cs
-
4com.unity.uiwidgets/Runtime/widgets/sliver.cs
-
8Samples/UIWidgetsSamples_2019_4/Assets/Plugins.meta
-
318Samples/UIWidgetsSamples_2019_4/Packages/packages-lock.json
-
8com.unity.uiwidgets/Runtime/cupertino.meta
-
8com.unity.uiwidgets/Runtime/ui33.meta
-
5Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/codeStyles/codeStyleConfig.xml
-
390Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/contentModel.xml
-
25Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/indexLayout.xml
-
8Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/modules.xml
-
6Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/projectSettingsUpdater.xml
-
6Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/vcs.xml
-
23Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/.idea/workspace.xml
-
8Samples/UIWidgetsSamples_2019_4/.idea/.idea.UIWidgetsSamples_2019_4/riderModule.iml
-
8Samples/UIWidgetsSamples_2019_4/Assets/Plugins/x86_64.meta
-
52Samples/UIWidgetsSamples_2019_4/Assets/Plugins/x86_64/libUIWidgets_d.dll.meta
-
1001com.unity.uiwidgets/Runtime/cupertino/action_Sheet.cs
-
11com.unity.uiwidgets/Runtime/cupertino/action_Sheet.cs.meta
-
130com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs
-
11com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs.meta
-
181com.unity.uiwidgets/Runtime/cupertino/app.cs
-
11com.unity.uiwidgets/Runtime/cupertino/app.cs.meta
-
204com.unity.uiwidgets/Runtime/cupertino/bottom_app_bar.cs
-
11com.unity.uiwidgets/Runtime/cupertino/bottom_app_bar.cs.meta
-
245com.unity.uiwidgets/Runtime/cupertino/button.cs
-
11com.unity.uiwidgets/Runtime/cupertino/button.cs.meta
-
25com.unity.uiwidgets/Runtime/cupertino/color.cs
-
11com.unity.uiwidgets/Runtime/cupertino/color.cs.meta
-
1001com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
-
11com.unity.uiwidgets/Runtime/cupertino/date_picker.cs.meta
-
1001com.unity.uiwidgets/Runtime/cupertino/dialog.cs
-
11com.unity.uiwidgets/Runtime/cupertino/dialog.cs.meta
-
142com.unity.uiwidgets/Runtime/cupertino/icons.cs
-
11com.unity.uiwidgets/Runtime/cupertino/icons.cs.meta
-
247com.unity.uiwidgets/Runtime/cupertino/localization.cs
-
11com.unity.uiwidgets/Runtime/cupertino/localization.cs.meta
-
1001com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs
-
11com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs.meta
-
144com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs
-
11com.unity.uiwidgets/Runtime/cupertino/page_scaffold.cs.meta
-
262com.unity.uiwidgets/Runtime/cupertino/picker.cs
-
11com.unity.uiwidgets/Runtime/cupertino/picker.cs.meta
-
757com.unity.uiwidgets/Runtime/cupertino/route.cs
-
11com.unity.uiwidgets/Runtime/cupertino/route.cs.meta
-
140com.unity.uiwidgets/Runtime/cupertino/scrollbar.cs
-
11com.unity.uiwidgets/Runtime/cupertino/scrollbar.cs.meta
-
380com.unity.uiwidgets/Runtime/cupertino/slider.cs
-
11com.unity.uiwidgets/Runtime/cupertino/slider.cs.meta
-
495com.unity.uiwidgets/Runtime/cupertino/switch.cs
-
11com.unity.uiwidgets/Runtime/cupertino/switch.cs.meta
-
221com.unity.uiwidgets/Runtime/cupertino/tab_scaffold.cs
-
11com.unity.uiwidgets/Runtime/cupertino/tab_scaffold.cs.meta
-
141com.unity.uiwidgets/Runtime/cupertino/tab_view.cs
-
11com.unity.uiwidgets/Runtime/cupertino/tab_view.cs.meta
-
575com.unity.uiwidgets/Runtime/cupertino/text_field.cs
-
11com.unity.uiwidgets/Runtime/cupertino/text_field.cs.meta
-
316com.unity.uiwidgets/Runtime/cupertino/text_selection.cs
-
11com.unity.uiwidgets/Runtime/cupertino/text_selection.cs.meta
-
191com.unity.uiwidgets/Runtime/cupertino/text_theme.cs
-
11com.unity.uiwidgets/Runtime/cupertino/text_theme.cs.meta
-
242com.unity.uiwidgets/Runtime/cupertino/theme.cs
-
11com.unity.uiwidgets/Runtime/cupertino/theme.cs.meta
-
42com.unity.uiwidgets/Runtime/cupertino/thumb_painter.cs
-
11com.unity.uiwidgets/Runtime/cupertino/thumb_painter.cs.meta
-
8com.unity.uiwidgets/Scripts/node_modules.meta
-
8com.unity.uiwidgets/StreamingAssets.meta
|
|||
fileFormatVersion: 2 |
|||
guid: a9f98fcbc8b0bd142b329f9ae0b6778b |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
{ |
|||
"dependencies": { |
|||
"com.unity.collab-proxy": { |
|||
"version": "1.2.16", |
|||
"depth": 0, |
|||
"source": "registry", |
|||
"dependencies": {}, |
|||
"url": "https://packages.unity.com" |
|||
}, |
|||
"com.unity.ext.nunit": { |
|||
"version": "1.0.0", |
|||
"depth": 1, |
|||
"source": "registry", |
|||
"dependencies": {}, |
|||
"url": "https://packages.unity.com" |
|||
}, |
|||
"com.unity.ide.rider": { |
|||
"version": "1.1.4", |
|||
"depth": 0, |
|||
"source": "registry", |
|||
"dependencies": { |
|||
"com.unity.test-framework": "1.1.3" |
|||
}, |
|||
"url": "https://packages.unity.com" |
|||
}, |
|||
"com.unity.ide.vscode": { |
|||
"version": "1.2.1", |
|||
"depth": 0, |
|||
"source": "registry", |
|||
"dependencies": {}, |
|||
"url": "https://packages.unity.com" |
|||
}, |
|||
"com.unity.test-framework": { |
|||
"version": "1.1.14", |
|||
"depth": 0, |
|||
"source": "registry", |
|||
"dependencies": { |
|||
"com.unity.ext.nunit": "1.0.0", |
|||
"com.unity.modules.imgui": "1.0.0", |
|||
"com.unity.modules.jsonserialize": "1.0.0" |
|||
}, |
|||
"url": "https://packages.unity.com" |
|||
}, |
|||
"com.unity.textmeshpro": { |
|||
"version": "2.0.1", |
|||
"depth": 0, |
|||
"source": "registry", |
|||
"dependencies": { |
|||
"com.unity.ugui": "1.0.0" |
|||
}, |
|||
"url": "https://packages.unity.com" |
|||
}, |
|||
"com.unity.timeline": { |
|||
"version": "1.2.15", |
|||
"depth": 0, |
|||
"source": "registry", |
|||
"dependencies": {}, |
|||
"url": "https://packages.unity.com" |
|||
}, |
|||
"com.unity.ugui": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.ui": "1.0.0", |
|||
"com.unity.modules.imgui": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.uiwidgets": { |
|||
"version": "file:../../../com.unity.uiwidgets", |
|||
"depth": 0, |
|||
"source": "local", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.ai": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.androidjni": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.animation": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.assetbundle": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.audio": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.cloth": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.physics": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.director": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.audio": "1.0.0", |
|||
"com.unity.modules.animation": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.imageconversion": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.imgui": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.jsonserialize": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.particlesystem": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.physics": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.physics2d": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.screencapture": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.imageconversion": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.subsystems": { |
|||
"version": "1.0.0", |
|||
"depth": 1, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.jsonserialize": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.terrain": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.terrainphysics": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.physics": "1.0.0", |
|||
"com.unity.modules.terrain": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.tilemap": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.physics2d": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.ui": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.uielements": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.imgui": "1.0.0", |
|||
"com.unity.modules.jsonserialize": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.umbra": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.unityanalytics": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.unitywebrequest": "1.0.0", |
|||
"com.unity.modules.jsonserialize": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.unitywebrequest": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.unitywebrequestassetbundle": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.assetbundle": "1.0.0", |
|||
"com.unity.modules.unitywebrequest": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.unitywebrequestaudio": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.unitywebrequest": "1.0.0", |
|||
"com.unity.modules.audio": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.unitywebrequesttexture": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.unitywebrequest": "1.0.0", |
|||
"com.unity.modules.imageconversion": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.unitywebrequestwww": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.unitywebrequest": "1.0.0", |
|||
"com.unity.modules.unitywebrequestassetbundle": "1.0.0", |
|||
"com.unity.modules.unitywebrequestaudio": "1.0.0", |
|||
"com.unity.modules.audio": "1.0.0", |
|||
"com.unity.modules.assetbundle": "1.0.0", |
|||
"com.unity.modules.imageconversion": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.vehicles": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.physics": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.video": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.audio": "1.0.0", |
|||
"com.unity.modules.ui": "1.0.0", |
|||
"com.unity.modules.unitywebrequest": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.vr": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.jsonserialize": "1.0.0", |
|||
"com.unity.modules.physics": "1.0.0", |
|||
"com.unity.modules.xr": "1.0.0" |
|||
} |
|||
}, |
|||
"com.unity.modules.wind": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": {} |
|||
}, |
|||
"com.unity.modules.xr": { |
|||
"version": "1.0.0", |
|||
"depth": 0, |
|||
"source": "builtin", |
|||
"dependencies": { |
|||
"com.unity.modules.physics": "1.0.0", |
|||
"com.unity.modules.jsonserialize": "1.0.0", |
|||
"com.unity.modules.subsystems": "1.0.0" |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5c3d34af75804254da0566129e0d4ac0 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 628dbae83defc65479f1ad3d8c9acbfb |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
<component name="ProjectCodeStyleConfiguration"> |
|||
<state> |
|||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" /> |
|||
</state> |
|||
</component> |
|
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="ContentModelStore"> |
|||
<e p="C:\com.unity.uiwidgets\com.unity.uiwidgets\Editor" t="Include"> |
|||
<e p="UIWidgetsPanelEditor.cs" t="Include" /> |
|||
<e p="Unity.UIWidgets.Editor.asmdef" t="Include" /> |
|||
</e> |
|||
<e p="C:\com.unity.uiwidgets\com.unity.uiwidgets\Runtime" t="Include"> |
|||
<e p="animation" t="Include"> |
|||
<e p="animation.cs" t="Include" /> |
|||
<e p="animation_controller.cs" t="Include" /> |
|||
<e p="animations.cs" t="Include" /> |
|||
<e p="curves.cs" t="Include" /> |
|||
<e p="listener_helpers.mixin.gen.cs" t="Include" /> |
|||
<e p="tween.cs" t="Include" /> |
|||
</e> |
|||
<e p="async" t="Include"> |
|||
<e p="coroutine.cs" t="Include" /> |
|||
<e p="microtask_queue.cs" t="Include" /> |
|||
<e p="priority_queue.cs" t="Include" /> |
|||
<e p="timer.cs" t="Include" /> |
|||
</e> |
|||
<e p="async2" t="Include"> |
|||
<e p="future.cs" t="Include" /> |
|||
<e p="future_impl.cs" t="Include" /> |
|||
<e p="schedule_microtask.cs" t="Include" /> |
|||
<e p="timer.cs" t="Include" /> |
|||
<e p="zone.cs" t="Include" /> |
|||
</e> |
|||
<e p="cupertino" t="Include"> |
|||
<e p="action_Sheet.cs" t="Include" /> |
|||
<e p="activity_indicator.cs" t="Include" /> |
|||
<e p="app.cs" t="Include" /> |
|||
<e p="bottom_app_bar.cs" t="Include" /> |
|||
<e p="button.cs" t="Include" /> |
|||
<e p="color.cs" t="Include" /> |
|||
<e p="date_picker.cs" t="Include" /> |
|||
<e p="dialog.cs" t="Include" /> |
|||
<e p="icons.cs" t="Include" /> |
|||
<e p="localization.cs" t="Include" /> |
|||
<e p="nav_bar.cs" t="Include" /> |
|||
<e p="page_scaffold.cs" t="Include" /> |
|||
<e p="picker.cs" t="Include" /> |
|||
<e p="route.cs" t="Include" /> |
|||
<e p="scrollbar.cs" t="Include" /> |
|||
<e p="slider.cs" t="Include" /> |
|||
<e p="switch.cs" t="Include" /> |
|||
<e p="tab_scaffold.cs" t="Include" /> |
|||
<e p="tab_view.cs" t="Include" /> |
|||
<e p="text_field.cs" t="Include" /> |
|||
<e p="text_selection.cs" t="Include" /> |
|||
<e p="text_theme.cs" t="Include" /> |
|||
<e p="theme.cs" t="Include" /> |
|||
<e p="thumb_painter.cs" t="Include" /> |
|||
</e> |
|||
<e p="developer" t="Include"> |
|||
<e p="extension.cs" t="Include" /> |
|||
<e p="timeline.cs" t="Include" /> |
|||
</e> |
|||
<e p="engine" t="Include"> |
|||
<e p="DisplayMetrics.cs" t="Include" /> |
|||
<e p="input_utils.cs" t="Include" /> |
|||
<e p="raycastable" t="Include"> |
|||
<e p="RaycastableContainer.cs" t="Include" /> |
|||
<e p="RaycastManager.cs" t="Include" /> |
|||
<e p="UIWidgetsRaycastablePanel.cs" t="Include" /> |
|||
</e> |
|||
<e p="UIWidgetsMessageManager.cs" t="Include" /> |
|||
<e p="UIWidgetsPanel.cs" t="Include" /> |
|||
</e> |
|||
<e p="engine2" t="Include"> |
|||
<e p="UIWidgetsPanel.cs" t="Include" /> |
|||
</e> |
|||
<e p="external" t="Include"> |
|||
<e p="RTree.cs" t="Include" /> |
|||
<e p="simplejson" t="Include"> |
|||
<e p="SimpleJSON.cs" t="Include" /> |
|||
</e> |
|||
<e p="SplayTree.cs" t="Include" /> |
|||
</e> |
|||
<e p="foundation" t="Include"> |
|||
<e p="assertions.cs" t="Include" /> |
|||
<e p="basic_types.cs" t="Include" /> |
|||
<e p="binding.cs" t="Include" /> |
|||
<e p="change_notifier.cs" t="Include" /> |
|||
<e p="collections.cs" t="Include" /> |
|||
<e p="constants.cs" t="Include" /> |
|||
<e p="debug.cs" t="Include" /> |
|||
<e p="diagnostics.cs" t="Include" /> |
|||
<e p="isolates.cs" t="Include" /> |
|||
<e p="key.cs" t="Include" /> |
|||
<e p="node.cs" t="Include" /> |
|||
<e p="node.mixin.gen.cs" t="Include" /> |
|||
<e p="object.cs" t="Include" /> |
|||
<e p="observer_list.cs" t="Include" /> |
|||
<e p="print.cs" t="Include" /> |
|||
<e p="serialization.cs" t="Include" /> |
|||
<e p="synchronous_future.cs" t="Include" /> |
|||
</e> |
|||
<e p="gestures" t="Include"> |
|||
<e p="arena.cs" t="Include" /> |
|||
<e p="binding.cs" t="Include" /> |
|||
<e p="constants.cs" t="Include" /> |
|||
<e p="converter.cs" t="Include" /> |
|||
<e p="drag.cs" t="Include" /> |
|||
<e p="drag_details.cs" t="Include" /> |
|||
<e p="events.cs" t="Include" /> |
|||
<e p="hit_test.cs" t="Include" /> |
|||
<e p="hover.cs" t="Include" /> |
|||
<e p="long_press.cs" t="Include" /> |
|||
<e p="lsq_resolver.cs" t="Include" /> |
|||
<e p="monodrag.cs" t="Include" /> |
|||
<e p="mouse_tracking.cs" t="Include" /> |
|||
<e p="multidrag.cs" t="Include" /> |
|||
<e p="multitap.cs" t="Include" /> |
|||
<e p="pointer_router.cs" t="Include" /> |
|||
<e p="pointer_signal_resolver.cs" t="Include" /> |
|||
<e p="recognizer.cs" t="Include" /> |
|||
<e p="scale.cs" t="Include" /> |
|||
<e p="tap.cs" t="Include" /> |
|||
<e p="team.cs" t="Include" /> |
|||
<e p="velocity_tracker.cs" t="Include" /> |
|||
</e> |
|||
<e p="InternalBridge" t="Include"> |
|||
<e p="InternalBridge.asmdef" t="Include" /> |
|||
<e p="NoAllocHelpersBridge.cs" t="Include" /> |
|||
</e> |
|||
<e p="material" t="Include"> |
|||
<e p="colors.cs" t="Include" /> |
|||
</e> |
|||
<e p="painting" t="Include"> |
|||
<e p="alignment.cs" t="Include" /> |
|||
<e p="basic_types.cs" t="Include" /> |
|||
<e p="beveled_rectangle_border.cs" t="Include" /> |
|||
<e p="binding.cs" t="Include" /> |
|||
<e p="border_radius.cs" t="Include" /> |
|||
<e p="borders.cs" t="Include" /> |
|||
<e p="box_border.cs" t="Include" /> |
|||
<e p="box_decoration.cs" t="Include" /> |
|||
<e p="box_fit.cs" t="Include" /> |
|||
<e p="box_shadow.cs" t="Include" /> |
|||
<e p="circle_border.cs" t="Include" /> |
|||
<e p="clip.cs" t="Include" /> |
|||
<e p="colors.cs" t="Include" /> |
|||
<e p="continuous_rectangle_border.cs" t="Include" /> |
|||
<e p="decoration.cs" t="Include" /> |
|||
<e p="decoration_image.cs" t="Include" /> |
|||
<e p="edge_insets.cs" t="Include" /> |
|||
<e p="fractional_offset.cs" t="Include" /> |
|||
<e p="geometry.cs" t="Include" /> |
|||
<e p="gradient.cs" t="Include" /> |
|||
<e p="image_cache.cs" t="Include" /> |
|||
<e p="image_provider.cs" t="Include" /> |
|||
<e p="image_resolution.cs" t="Include" /> |
|||
<e p="image_stream.cs" t="Include" /> |
|||
<e p="inline_span.cs" t="Include" /> |
|||
<e p="matrix_utils.cs" t="Include" /> |
|||
<e p="notched_shapes.cs" t="Include" /> |
|||
<e p="paint_utilities.cs" t="Include" /> |
|||
<e p="rounded_rectangle_border.cs" t="Include" /> |
|||
<e p="shader_warmup.cs" t="Include" /> |
|||
<e p="shape_decoration.cs" t="Include" /> |
|||
<e p="stadium_border.cs" t="Include" /> |
|||
<e p="strut_style.cs" t="Include" /> |
|||
<e p="text_painter.cs" t="Include" /> |
|||
<e p="text_span.cs" t="Include" /> |
|||
<e p="text_style.cs" t="Include" /> |
|||
</e> |
|||
<e p="physics" t="Include"> |
|||
<e p="clamped_simulation.cs" t="Include" /> |
|||
<e p="friction_simulation.cs" t="Include" /> |
|||
<e p="gravity_simulation.cs" t="Include" /> |
|||
<e p="simulation.cs" t="Include" /> |
|||
<e p="spring_simulation.cs" t="Include" /> |
|||
<e p="tolerance.cs" t="Include" /> |
|||
<e p="utils.cs" t="Include" /> |
|||
</e> |
|||
<e p="rendering" t="Include"> |
|||
<e p="animated_size.cs" t="Include" /> |
|||
<e p="binding.cs" t="Include" /> |
|||
<e p="box.cs" t="Include" /> |
|||
<e p="box.mixin.gen.cs" t="Include" /> |
|||
<e p="custom_layout.cs" t="Include" /> |
|||
<e p="custom_paint.cs" t="Include" /> |
|||
<e p="debug.cs" t="Include" /> |
|||
<e p="debug_overflow_indicator.cs" t="Include" /> |
|||
<e p="editable.cs" t="Include" /> |
|||
<e p="error.cs" t="Include" /> |
|||
<e p="flex.cs" t="Include" /> |
|||
<e p="image.cs" t="Include" /> |
|||
<e p="layer.cs" t="Include" /> |
|||
<e p="list_body.cs" t="Include" /> |
|||
<e p="list_wheel_viewport.cs" t="Include" /> |
|||
<e p="object.cs" t="Include" /> |
|||
<e p="object.mixin.gen.cs" t="Include" /> |
|||
<e p="paragraph.cs" t="Include" /> |
|||
<e p="performance_overlay.cs" t="Include" /> |
|||
<e p="proxy_box.cs" t="Include" /> |
|||
<e p="proxy_box.mixin.gen.cs" t="Include" /> |
|||
<e p="rotated_box.cs" t="Include" /> |
|||
<e p="shifted_box.cs" t="Include" /> |
|||
<e p="sliver.cs" t="Include" /> |
|||
<e p="sliver_fill.cs" t="Include" /> |
|||
<e p="sliver_fixed_extent_list.cs" t="Include" /> |
|||
<e p="sliver_grid.cs" t="Include" /> |
|||
<e p="sliver_list.cs" t="Include" /> |
|||
<e p="sliver_multi_box_adaptor.cs" t="Include" /> |
|||
<e p="sliver_padding.cs" t="Include" /> |
|||
<e p="sliver_persistent_header.cs" t="Include" /> |
|||
<e p="stack.cs" t="Include" /> |
|||
<e p="table.cs" t="Include" /> |
|||
<e p="table_border.cs" t="Include" /> |
|||
<e p="texture.cs" t="Include" /> |
|||
<e p="tweens.cs" t="Include" /> |
|||
<e p="view.cs" t="Include" /> |
|||
<e p="viewport.cs" t="Include" /> |
|||
<e p="viewport_offset.cs" t="Include" /> |
|||
<e p="wrap.cs" t="Include" /> |
|||
</e> |
|||
<e p="Resources" t="Include"> |
|||
<e p="shaders" t="Include"> |
|||
<e p="computebuffer" t="Include"> |
|||
<e p="UIWidgets_canvas_cb.cginc" t="Include" /> |
|||
<e p="UIWidgets_canvas_convexFill_cb.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_fill0_cb.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_fill1_cb.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_filter_cb.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_shadowBox_cb.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_shadowRBox_cb.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_stencil_cb.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_stroke0_cb.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_stroke1_cb.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_strokeAlpha_cb.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_tex_cb.shader" t="Include" /> |
|||
</e> |
|||
<e p="UIWidgets_canvas.cginc" t="Include" /> |
|||
<e p="UIWidgets_canvas_convexFill.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_fill0.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_fill1.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_filter.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_shadowBox.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_shadowRBox.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_stencil.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_stroke0.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_stroke1.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_strokeAlpha.shader" t="Include" /> |
|||
<e p="UIWidgets_canvas_tex.shader" t="Include" /> |
|||
<e p="UIWidgets_GUITexture.shader" t="Include" /> |
|||
<e p="UIWidgets_UIDefault.shader" t="Include" /> |
|||
</e> |
|||
</e> |
|||
<e p="scheduler" t="Include"> |
|||
<e p="binding.cs" t="Include" /> |
|||
<e p="ticker.cs" t="Include" /> |
|||
</e> |
|||
<e p="scheduler2" t="Include"> |
|||
<e p="binding.cs" t="Include" /> |
|||
<e p="debug.cs" t="Include" /> |
|||
<e p="priority.cs" t="Include" /> |
|||
<e p="ticker.cs" t="Include" /> |
|||
</e> |
|||
<e p="service" t="Include"> |
|||
<e p="clipboard.cs" t="Include" /> |
|||
<e p="keyboard.cs" t="Include" /> |
|||
<e p="raw_keyboard.cs" t="Include" /> |
|||
<e p="system_chrome.cs" t="Include" /> |
|||
<e p="text_editing.cs" t="Include" /> |
|||
<e p="text_formatter.cs" t="Include" /> |
|||
<e p="text_input.cs" t="Include" /> |
|||
</e> |
|||
<e p="services" t="Include"> |
|||
<e p="asset_bundle.cs" t="Include" /> |
|||
<e p="binary_messenger.cs" t="Include" /> |
|||
<e p="binding.cs" t="Include" /> |
|||
<e p="message_codec.cs" t="Include" /> |
|||
<e p="message_codecs.cs" t="Include" /> |
|||
</e> |
|||
<e p="ui2" t="Include"> |
|||
<e p="channel_buffers.cs" t="Include" /> |
|||
<e p="compositing.cs" t="Include" /> |
|||
<e p="geometry.cs" t="Include" /> |
|||
<e p="hooks.cs" t="Include" /> |
|||
<e p="isolate.cs" t="Include" /> |
|||
<e p="Matrix4.cs" t="Include" /> |
|||
<e p="native_bindings.cs" t="Include" /> |
|||
<e p="painting.cs" t="Include" /> |
|||
<e p="pointer.cs" t="Include" /> |
|||
<e p="text.cs" t="Include" /> |
|||
<e p="window.cs" t="Include" /> |
|||
</e> |
|||
<e p="Unity.UIWidgets.asmdef" t="Include" /> |
|||
<e p="widgets" t="Include"> |
|||
<e p="animated_cross_fade.cs" t="Include" /> |
|||
<e p="animated_size.cs" t="Include" /> |
|||
<e p="animated_switcher.cs" t="Include" /> |
|||
<e p="annotated_region.cs" t="Include" /> |
|||
<e p="app.cs" t="Include" /> |
|||
<e p="automatic_keep_alive.cs" t="Include" /> |
|||
<e p="banner.cs" t="Include" /> |
|||
<e p="basic.cs" t="Include" /> |
|||
<e p="binding.cs" t="Include" /> |
|||
<e p="bottom_navigation_bar_item.cs" t="Include" /> |
|||
<e p="container.cs" t="Include" /> |
|||
<e p="debug.cs" t="Include" /> |
|||
<e p="dismissible.cs" t="Include" /> |
|||
<e p="drag_target.cs" t="Include" /> |
|||
<e p="editable_text.cs" t="Include" /> |
|||
<e p="fade_in_image.cs" t="Include" /> |
|||
<e p="focus_manager.cs" t="Include" /> |
|||
<e p="focus_scope.cs" t="Include" /> |
|||
<e p="form.cs" t="Include" /> |
|||
<e p="framework.cs" t="Include" /> |
|||
<e p="gesture_detector.cs" t="Include" /> |
|||
<e p="heroes.cs" t="Include" /> |
|||
<e p="icon.cs" t="Include" /> |
|||
<e p="icon_data.cs" t="Include" /> |
|||
<e p="icon_theme.cs" t="Include" /> |
|||
<e p="icon_theme_data.cs" t="Include" /> |
|||
<e p="image.cs" t="Include" /> |
|||
<e p="implicit_animations.cs" t="Include" /> |
|||
<e p="layout_builder.cs" t="Include" /> |
|||
<e p="list_wheel_scroll_view.cs" t="Include" /> |
|||
<e p="localizations.cs" t="Include" /> |
|||
<e p="media_query.cs" t="Include" /> |
|||
<e p="modal_barrier.cs" t="Include" /> |
|||
<e p="navigation_toolbar.cs" t="Include" /> |
|||
<e p="navigator.cs" t="Include" /> |
|||
<e p="nested_scroll_view.cs" t="Include" /> |
|||
<e p="notification_listener.cs" t="Include" /> |
|||
<e p="orientation_builder.cs" t="Include" /> |
|||
<e p="overlay.cs" t="Include" /> |
|||
<e p="overscroll_indicator.cs" t="Include" /> |
|||
<e p="page_storage.cs" t="Include" /> |
|||
<e p="page_view.cs" t="Include" /> |
|||
<e p="pages.cs" t="Include" /> |
|||
<e p="performance_overlay.cs" t="Include" /> |
|||
<e p="placeholder.cs" t="Include" /> |
|||
<e p="preferred_size.cs" t="Include" /> |
|||
<e p="primary_scroll_controller.cs" t="Include" /> |
|||
<e p="routes.cs" t="Include" /> |
|||
<e p="safe_area.cs" t="Include" /> |
|||
<e p="scroll_activity.cs" t="Include" /> |
|||
<e p="scroll_configuration.cs" t="Include" /> |
|||
<e p="scroll_context.cs" t="Include" /> |
|||
<e p="scroll_controller.cs" t="Include" /> |
|||
<e p="scroll_metrics.cs" t="Include" /> |
|||
<e p="scroll_notification.cs" t="Include" /> |
|||
<e p="scroll_notification.mixin.gen.cs" t="Include" /> |
|||
<e p="scroll_physics.cs" t="Include" /> |
|||
<e p="scroll_position.cs" t="Include" /> |
|||
<e p="scroll_position_with_single_context.cs" t="Include" /> |
|||
<e p="scroll_simulation.cs" t="Include" /> |
|||
<e p="scroll_view.cs" t="Include" /> |
|||
<e p="scrollable.cs" t="Include" /> |
|||
<e p="scrollbar.cs" t="Include" /> |
|||
<e p="selectable_text.cs" t="Include" /> |
|||
<e p="single_child_scroll_view.cs" t="Include" /> |
|||
<e p="sliver.cs" t="Include" /> |
|||
<e p="sliver_persistent_header.cs" t="Include" /> |
|||
<e p="table.cs" t="Include" /> |
|||
<e p="text.cs" t="Include" /> |
|||
<e p="text_selection.cs" t="Include" /> |
|||
<e p="texture.cs" t="Include" /> |
|||
<e p="ticker_provider.cs" t="Include" /> |
|||
<e p="transitions.cs" t="Include" /> |
|||
<e p="value_listenable_builder.cs" t="Include" /> |
|||
<e p="viewport.cs" t="Include" /> |
|||
<e p="visibility.cs" t="Include" /> |
|||
<e p="widget_inspector.cs" t="Include" /> |
|||
<e p="will_pop_scope.cs" t="Include" /> |
|||
</e> |
|||
</e> |
|||
<e p="C:\com.unity.uiwidgets\Samples\UIWidgetsSamples_2019_4" t="IncludeRecursive"> |
|||
<e p="Assets" t="Include"> |
|||
<e p="UIWidgetsExample.cs" t="Include" /> |
|||
<e p="UIWidgetsSample.asmdef" t="Include" /> |
|||
</e> |
|||
<e p="obj" t="ExcludeRecursive" /> |
|||
<e p="Packages" t="ExcludeRecursive" /> |
|||
<e p="Temp\bin" t="ExcludeRecursive" /> |
|||
<e p="UIWidgetsSample.csproj" t="IncludeRecursive" /> |
|||
<e p="UIWidgetsSamples_2019_4.sln" t="IncludeFlat" /> |
|||
<e p="Unity.InternalAPIEngineBridge.024.csproj" t="IncludeRecursive" /> |
|||
<e p="Unity.UIWidgets.csproj" t="IncludeRecursive" /> |
|||
<e p="Unity.UIWidgets.Editor.csproj" t="IncludeRecursive" /> |
|||
</e> |
|||
<e p="C:\Users\44255\AppData\Local\JetBrains\Rider2020.2\extResources" t="IncludeRecursive" /> |
|||
<e p="C:\Users\44255\AppData\Local\JetBrains\Rider2020.2\resharper-host\Local\Transient\Rider\v202\SolutionCaches\_UIWidgetsSamples_2019_4.-1067931337.00" t="ExcludeRecursive" /> |
|||
</component> |
|||
</project> |
|
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="ContentModelUserStore"> |
|||
<attachedFolders /> |
|||
<explicitIncludes> |
|||
<Path>Library/PackageCache/com.unity.collab-proxy@1.2.16</Path> |
|||
<Path>Library/PackageCache/com.unity.ext.nunit@1.0.0</Path> |
|||
<Path>Library/PackageCache/com.unity.ide.rider@1.1.4</Path> |
|||
<Path>Library/PackageCache/com.unity.ide.vscode@1.2.1</Path> |
|||
<Path>Library/PackageCache/com.unity.test-framework@1.1.14</Path> |
|||
<Path>Library/PackageCache/com.unity.textmeshpro@2.0.1</Path> |
|||
<Path>Library/PackageCache/com.unity.timeline@1.2.15</Path> |
|||
<Path>Packages</Path> |
|||
<Path>ProjectSettings</Path> |
|||
<Path>../../com.unity.uiwidgets</Path> |
|||
</explicitIncludes> |
|||
<explicitExcludes> |
|||
<Path>.idea</Path> |
|||
<Path>.vs</Path> |
|||
<Path>Library</Path> |
|||
<Path>Temp</Path> |
|||
<Path>obj</Path> |
|||
</explicitExcludes> |
|||
</component> |
|||
</project> |
|
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="ProjectModuleManager"> |
|||
<modules> |
|||
<module fileurl="file://$PROJECT_DIR$/.idea/.idea.UIWidgetsSamples_2019_4/riderModule.iml" filepath="$PROJECT_DIR$/.idea/.idea.UIWidgetsSamples_2019_4/riderModule.iml" /> |
|||
</modules> |
|||
</component> |
|||
</project> |
|
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="RiderProjectSettingsUpdater"> |
|||
<option name="vcsConfiguration" value="2" /> |
|||
</component> |
|||
</project> |
|
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="VcsDirectoryMappings"> |
|||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" /> |
|||
</component> |
|||
</project> |
|
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="RunManager" selected="Attach to Unity Editor.Attach to Unity Editor"> |
|||
<configuration name="Attach to Unity Editor & Play" type="UNITY_DEBUG_RUN_CONFIGURATION" factoryName="UNITY_ATTACH_AND_PLAY" show_console_on_std_err="false" show_console_on_std_out="false" port="50000" address="localhost"> |
|||
<option name="allowRunningInParallel" value="false" /> |
|||
<option name="listenPortForConnections" value="false" /> |
|||
<option name="pid" /> |
|||
<option name="selectedOptions"> |
|||
<set /> |
|||
</option> |
|||
<method v="2" /> |
|||
</configuration> |
|||
<configuration name="Attach to Unity Editor" type="UNITY_DEBUG_RUN_CONFIGURATION" factoryName="Unity Debug" show_console_on_std_err="false" show_console_on_std_out="false" port="50000" address="localhost"> |
|||
<option name="allowRunningInParallel" value="false" /> |
|||
<option name="listenPortForConnections" value="false" /> |
|||
<option name="pid" /> |
|||
<option name="selectedOptions"> |
|||
<set /> |
|||
</option> |
|||
<method v="2" /> |
|||
</configuration> |
|||
</component> |
|||
</project> |
|
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<module type="RIDER_MODULE" version="4"> |
|||
<component name="NewModuleRootManager"> |
|||
<content url="file://$MODULE_DIR$/../.." /> |
|||
<content url="file://$MODULE_DIR$/../../../../com.unity.uiwidgets" /> |
|||
<orderEntry type="sourceFolder" forTests="false" /> |
|||
</component> |
|||
</module> |
|
|||
fileFormatVersion: 2 |
|||
guid: 33884500f7984174c905ac5cf613ff08 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ef8445888386d7f479b700d769b35a63 |
|||
PluginImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
iconMap: {} |
|||
executionOrder: {} |
|||
defineConstraints: [] |
|||
isPreloaded: 0 |
|||
isOverridable: 0 |
|||
isExplicitlyReferenced: 0 |
|||
validateReferences: 1 |
|||
platformData: |
|||
- first: |
|||
Any: |
|||
second: |
|||
enabled: 1 |
|||
settings: {} |
|||
- first: |
|||
Editor: Editor |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: x86_64 |
|||
DefaultValueInitialized: true |
|||
- first: |
|||
Standalone: Linux64 |
|||
second: |
|||
enabled: 1 |
|||
settings: |
|||
CPU: x86_64 |
|||
- first: |
|||
Standalone: OSXUniversal |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: x86_64 |
|||
- first: |
|||
Standalone: Win |
|||
second: |
|||
enabled: 0 |
|||
settings: |
|||
CPU: None |
|||
- first: |
|||
Standalone: Win64 |
|||
second: |
|||
enabled: 1 |
|||
settings: |
|||
CPU: AnyCPU |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
com.unity.uiwidgets/Runtime/cupertino/action_Sheet.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: e4c32db980b96b84b81d7bee1bb997ba |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.animation; |
|||
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 const float _kTwoPI = Mathf.PI * 2.0f; |
|||
public const int _kTickCount = 12; |
|||
public const int _kHalfTickCount = _kTickCount / 2; |
|||
public static readonly Color _kTickColor = CupertinoColors.lightBackgroundGray; |
|||
public static readonly Color _kActiveTickColor = new Color(0xFF9D9D9D); |
|||
} |
|||
|
|||
public class CupertinoActivityIndicator : StatefulWidget { |
|||
public CupertinoActivityIndicator( |
|||
Key key = null, |
|||
bool animating = true, |
|||
float radius = CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius |
|||
) : base(key: key) { |
|||
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, |
|||
radius: widget.radius |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
class _CupertinoActivityIndicatorPainter : AbstractCustomPainter { |
|||
public _CupertinoActivityIndicatorPainter( |
|||
Animation<float> position, |
|||
float radius |
|||
) : base(repaint: position) { |
|||
tickFundamentalRRect = RRect.fromLTRBXY( |
|||
left: -radius, |
|||
top: 1.0f * radius / CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius, |
|||
right: -radius / 2.0f, |
|||
bottom: -1.0f * radius / CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius, |
|||
radiusX: 1.0f, |
|||
radiusY: 1.0f |
|||
); |
|||
this.position = position; |
|||
} |
|||
|
|||
readonly Animation<float> position; |
|||
readonly RRect tickFundamentalRRect; |
|||
|
|||
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) { |
|||
float t = (((i + activeTick) % CupertinoActivityIndicatorUtils._kTickCount) / |
|||
CupertinoActivityIndicatorUtils._kHalfTickCount).clamp(0, 1); |
|||
paint.color = Color.lerp(a: CupertinoActivityIndicatorUtils._kActiveTickColor, |
|||
b: CupertinoActivityIndicatorUtils._kTickColor, t: 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; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ed3ef7a3308cfad4e968eb19fe99ba4b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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, |
|||
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 |
|||
) : 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.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; |
|||
} |
|||
|
|||
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 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 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); |
|||
//_delegates.Add(DefaultMaterialLocalizations.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 CupertinoTheme( |
|||
data: effectiveThemeData, |
|||
child: new WidgetsApp( |
|||
pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) => |
|||
new CupertinoPageRoute(settings: settings, builder: builder), |
|||
home: widget.home, |
|||
routes: widget.routes, |
|||
initialRoute: widget.initialRoute, |
|||
onGenerateRoute: widget.onGenerateRoute, |
|||
onUnknownRoute: widget.onUnknownRoute, |
|||
builder: widget.builder, |
|||
title: widget.title, |
|||
onGenerateTitle: widget.onGenerateTitle, |
|||
textStyle: effectiveThemeData.textTheme.textStyle, |
|||
color: widget.color ?? CupertinoColors.activeBlue, |
|||
locale: widget.locale, |
|||
localizationsDelegates: _localizationsDelegates, |
|||
localeResolutionCallback: widget.localeResolutionCallback, |
|||
localeListResolutionCallback: widget.localeListResolutionCallback, |
|||
supportedLocales: widget.supportedLocales, |
|||
showPerformanceOverlay: widget.showPerformanceOverlay, |
|||
inspectorSelectButtonBuilder: (BuildContext _context, VoidCallback onPressed) => { |
|||
return CupertinoButton.filled( |
|||
child: new Icon( |
|||
CupertinoIcons.search, |
|||
size: 28.0f, |
|||
color: CupertinoColors.white |
|||
), |
|||
padding: EdgeInsets.zero, |
|||
onPressed: onPressed |
|||
); |
|||
} |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: eaa69370ca020aa4ca9cfeff075ab39c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
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; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
class BottomAppBarUtils { |
|||
public const float _kTabBarHeight = 50.0f; |
|||
public static readonly Color _kDefaultTabBarBorderColor = new Color(0x4C000000); |
|||
} |
|||
|
|||
|
|||
public class CupertinoTabBar : StatelessWidget { |
|||
public CupertinoTabBar( |
|||
Key key = null, |
|||
List<BottomNavigationBarItem> items = null, |
|||
ValueChanged<int> onTap = null, |
|||
int currentIndex = 0, |
|||
Color backgroundColor = null, |
|||
Color activeColor = null, |
|||
Color inactiveColor = null, |
|||
float iconSize = 30.0f, |
|||
Border border = null |
|||
) : base(key: key) { |
|||
D.assert(items != null); |
|||
D.assert(items.Count >= 2, |
|||
() => "Tabs need at least 2 items to conform to Apple's HIG" |
|||
); |
|||
D.assert(0 <= currentIndex && currentIndex < items.Count); |
|||
|
|||
|
|||
this.items = items; |
|||
this.onTap = onTap; |
|||
this.currentIndex = currentIndex; |
|||
|
|||
this.backgroundColor = backgroundColor; |
|||
this.activeColor = activeColor; |
|||
this.inactiveColor = inactiveColor ?? CupertinoColors.inactiveGray; |
|||
this.iconSize = iconSize; |
|||
this.border = border ?? new Border( |
|||
top: new BorderSide( |
|||
color: BottomAppBarUtils._kDefaultTabBarBorderColor, |
|||
width: 0.0f, // One physical pixel.
|
|||
style: BorderStyle.solid |
|||
) |
|||
); |
|||
} |
|||
|
|||
public readonly List<BottomNavigationBarItem> items; |
|||
|
|||
public readonly ValueChanged<int> onTap; |
|||
|
|||
public readonly int currentIndex; |
|||
|
|||
public readonly Color backgroundColor; |
|||
|
|||
public readonly Color activeColor; |
|||
|
|||
public readonly Color inactiveColor; |
|||
|
|||
public readonly float iconSize; |
|||
|
|||
public readonly Border border; |
|||
|
|||
public Size preferredSize { |
|||
get { return Size.fromHeight(BottomAppBarUtils._kTabBarHeight); } |
|||
} |
|||
|
|||
public bool opaque(BuildContext context) { |
|||
Color backgroundColor = |
|||
this.backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor; |
|||
return backgroundColor.alpha == 0xFF; |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
float bottomPadding = MediaQuery.of(context).padding.bottom; |
|||
|
|||
Widget result = new DecoratedBox( |
|||
decoration: new BoxDecoration( |
|||
border: border, |
|||
color: backgroundColor ?? CupertinoTheme.of(context).barBackgroundColor |
|||
), |
|||
child: new SizedBox( |
|||
height: BottomAppBarUtils._kTabBarHeight + bottomPadding, |
|||
child: IconTheme.merge( // Default with the inactive state.
|
|||
data: new IconThemeData( |
|||
color: inactiveColor, |
|||
size: iconSize |
|||
), |
|||
child: new DefaultTextStyle( // Default with the inactive state.
|
|||
style: CupertinoTheme.of(context).textTheme.tabLabelTextStyle |
|||
.copyWith(color: inactiveColor), |
|||
child: new Padding( |
|||
padding: EdgeInsets.only(bottom: bottomPadding), |
|||
child: new Row( |
|||
crossAxisAlignment: CrossAxisAlignment.end, |
|||
children: _buildTabItems(context) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
); |
|||
|
|||
if (!opaque(context)) { |
|||
result = new ClipRect( |
|||
child: new BackdropFilter( |
|||
filter: ImageFilter.blur(sigmaX: 10.0f, sigmaY: 10.0f), |
|||
child: result |
|||
) |
|||
); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
List<Widget> _buildTabItems(BuildContext context) { |
|||
List<Widget> result = new List<Widget> { }; |
|||
|
|||
for (int index = 0; index < items.Count; index += 1) { |
|||
bool active = index == currentIndex; |
|||
var tabIndex = index; |
|||
result.Add( |
|||
_wrapActiveItem( |
|||
context, |
|||
new Expanded( |
|||
child: new GestureDetector( |
|||
behavior: HitTestBehavior.opaque, |
|||
onTap: onTap == null ? null : (GestureTapCallback) (() => { onTap(tabIndex); }), |
|||
child: new Padding( |
|||
padding: EdgeInsets.only(bottom: 4.0f), |
|||
child: new Column( |
|||
mainAxisAlignment: MainAxisAlignment.end, |
|||
children: _buildSingleTabItem(items[index], active) |
|||
) |
|||
) |
|||
) |
|||
), |
|||
active: active |
|||
) |
|||
); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
List<Widget> _buildSingleTabItem(BottomNavigationBarItem item, bool active) { |
|||
List<Widget> components = new List<Widget> { |
|||
new Expanded( |
|||
child: new Center(child: active ? item.activeIcon : item.icon) |
|||
) |
|||
}; |
|||
|
|||
if (item.title != null) { |
|||
components.Add(item.title); |
|||
} |
|||
|
|||
return components; |
|||
} |
|||
|
|||
Widget _wrapActiveItem(BuildContext context, Widget item, bool active) { |
|||
if (!active) { |
|||
return item; |
|||
} |
|||
|
|||
Color activeColor = this.activeColor ?? CupertinoTheme.of(context).primaryColor; |
|||
return IconTheme.merge( |
|||
data: new IconThemeData(color: activeColor), |
|||
child: DefaultTextStyle.merge( |
|||
style: new TextStyle(color: activeColor), |
|||
child: item |
|||
) |
|||
); |
|||
} |
|||
|
|||
public CupertinoTabBar copyWith( |
|||
Key key = null, |
|||
List<BottomNavigationBarItem> items = null, |
|||
Color backgroundColor = null, |
|||
Color activeColor = null, |
|||
Color inactiveColor = null, |
|||
float? iconSize = null, |
|||
Border border = null, |
|||
int? currentIndex = null, |
|||
ValueChanged<int> onTap = null |
|||
) { |
|||
return new CupertinoTabBar( |
|||
key: key ?? this.key, |
|||
items: items ?? this.items, |
|||
backgroundColor: backgroundColor ?? this.backgroundColor, |
|||
activeColor: activeColor ?? this.activeColor, |
|||
inactiveColor: inactiveColor ?? this.inactiveColor, |
|||
iconSize: iconSize ?? this.iconSize, |
|||
border: border ?? this.border, |
|||
currentIndex: currentIndex ?? this.currentIndex, |
|||
onTap: onTap ?? this.onTap |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: aae818985ea0fb942b943da7205b523c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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.scheduler2; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
using TickerFuture = Unity.UIWidgets.scheduler2.TickerFuture; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
public class CupertinoButtonUtils { |
|||
public static readonly Color _kDisabledBackground = new Color(0xFFA9A9A9); |
|||
public static readonly Color _kDisabledForeground = new Color(0xFFD1D1D1); |
|||
public static readonly EdgeInsets _kButtonPadding = EdgeInsets.all(16.0f); |
|||
public static readonly EdgeInsets _kBackgroundButtonPadding = EdgeInsets.symmetric(vertical: 14.0f, horizontal: 64.0f); |
|||
} |
|||
|
|||
public class CupertinoButton : StatefulWidget { |
|||
public CupertinoButton( |
|||
Widget child, |
|||
VoidCallback onPressed, |
|||
Key key = null, |
|||
EdgeInsets padding = null, |
|||
Color color = null, |
|||
Color disabledColor = null, |
|||
float minSize = 44.0f, |
|||
float pressedOpacity = 0.1f, |
|||
BorderRadius borderRadius = null, |
|||
bool filled = false |
|||
) : base(key: key) { |
|||
D.assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0); |
|||
_filled = filled; |
|||
this.child = child; |
|||
this.onPressed = onPressed; |
|||
this.padding = padding; |
|||
this.color = color; |
|||
this.disabledColor = disabledColor; |
|||
this.minSize = minSize; |
|||
this.pressedOpacity = pressedOpacity; |
|||
this.borderRadius = borderRadius ?? BorderRadius.all(Radius.circular(8.0f)); |
|||
} |
|||
|
|||
public static CupertinoButton filled( |
|||
Widget child, |
|||
VoidCallback onPressed, |
|||
Key key = null, |
|||
EdgeInsets padding = null, |
|||
Color disabledColor = null, |
|||
float minSize = 44.0f, |
|||
float pressedOpacity = 0.1f, |
|||
BorderRadius borderRadius = null |
|||
) { |
|||
D.assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0); |
|||
return new CupertinoButton( |
|||
key: key, |
|||
color: null, |
|||
child: child, |
|||
onPressed: onPressed, |
|||
padding: padding, |
|||
disabledColor: disabledColor, |
|||
minSize: minSize, |
|||
pressedOpacity: pressedOpacity, |
|||
borderRadius: borderRadius, |
|||
filled: true |
|||
); |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public readonly EdgeInsets 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 readonly 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 FloatTween _opacityTween = new FloatTween(begin: 1.0f, end: 0.0f); |
|||
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 = widget.pressedOpacity ?? 1.0f; |
|||
} |
|||
} |
|||
|
|||
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(); |
|||
} |
|||
}); |
|||
/*ticker.then(() => { |
|||
if (mounted && wasHeldDown != _buttonHeldDown) { |
|||
_animate(); |
|||
} |
|||
});*/ |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
bool enabled = widget.enabled; |
|||
Color primaryColor = CupertinoTheme.of(context).primaryColor; |
|||
Color backgroundColor = widget.color ?? (widget._filled ? primaryColor : null); |
|||
|
|||
Color foregroundColor = backgroundColor != null |
|||
? CupertinoTheme.of(context).primaryContrastingColor |
|||
: enabled |
|||
? primaryColor |
|||
: CupertinoButtonUtils._kDisabledForeground; |
|||
|
|||
TextStyle textStyle = |
|||
CupertinoTheme.of(context).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: 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 |
|||
? widget.disabledColor ?? CupertinoButtonUtils._kDisabledBackground |
|||
: 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 |
|||
) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 629437eb94ae5aa4bbe7bcf510b6a7cc |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
public class CupertinoColors { |
|||
public static readonly Color activeBlue = new Color(0xFF007AFF); |
|||
|
|||
public static readonly Color activeGreen = new Color(0xFF4CD964); |
|||
|
|||
public static readonly Color activeOrange = new Color(0xFFFF9500); |
|||
|
|||
public static readonly Color white = new Color(0xFFFFFFFF); |
|||
|
|||
public static readonly Color black = new Color(0xFF000000); |
|||
|
|||
public static readonly Color lightBackgroundGray = new Color(0xFFE5E5EA); |
|||
|
|||
public static readonly Color extraLightBackgroundGray = new Color(0xFFEFEFF4); |
|||
|
|||
public static readonly Color darkBackgroundGray = new Color(0xFF171717); |
|||
|
|||
public static readonly Color inactiveGray = new Color(0xFF8E8E93); |
|||
|
|||
public static readonly Color destructiveRed = new Color(0xFFFF3B30); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: cf635163f4e847c4d8189105ba042987 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
com.unity.uiwidgets/Runtime/cupertino/date_picker.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 0afde46bc85349a49bb887e7ef46e8d9 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
com.unity.uiwidgets/Runtime/cupertino/dialog.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: ce028dee29b7b90409ab91e330e762e2 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
public static class CupertinoIcons { |
|||
public const string iconFont = "CupertinoIcons"; |
|||
|
|||
public static readonly IconData left_chevron = new IconData(0xf3d2, fontFamily: iconFont); |
|||
public static readonly IconData right_chevron = new IconData(0xf3d3, fontFamily: iconFont); |
|||
public static readonly IconData share = new IconData(0xf4ca, fontFamily: iconFont); |
|||
public static readonly IconData share_solid = new IconData(0xf4cb, fontFamily: iconFont); |
|||
public static readonly IconData book = new IconData(0xf3e7, fontFamily: iconFont); |
|||
public static readonly IconData book_solid = new IconData(0xf3e8, fontFamily: iconFont); |
|||
public static readonly IconData bookmark = new IconData(0xf3e9, fontFamily: iconFont); |
|||
public static readonly IconData bookmark_solid = new IconData(0xf3ea, fontFamily: iconFont); |
|||
public static readonly IconData info = new IconData(0xf44c, fontFamily: iconFont); |
|||
public static readonly IconData reply = new IconData(0xf4c6, fontFamily: iconFont); |
|||
public static readonly IconData conversation_bubble = new IconData(0xf3fb, fontFamily: iconFont); |
|||
public static readonly IconData profile_circled = new IconData(0xf419, fontFamily: iconFont); |
|||
public static readonly IconData plus_circled = new IconData(0xf48a, fontFamily: iconFont); |
|||
public static readonly IconData minus_circled = new IconData(0xf463, fontFamily: iconFont); |
|||
public static readonly IconData flag = new IconData(0xf42c, fontFamily: iconFont); |
|||
public static readonly IconData search = new IconData(0xf4a5, fontFamily: iconFont); |
|||
public static readonly IconData check_mark = new IconData(0xf3fd, fontFamily: iconFont); |
|||
public static readonly IconData check_mark_circled = new IconData(0xf3fe, fontFamily: iconFont); |
|||
public static readonly IconData check_mark_circled_solid = new IconData(0xf3ff, fontFamily: iconFont); |
|||
public static readonly IconData circle = new IconData(0xf401, fontFamily: iconFont); |
|||
public static readonly IconData circle_filled = new IconData(0xf400, fontFamily: iconFont); |
|||
public static readonly IconData back = new IconData(0xf3cf, fontFamily: iconFont); |
|||
public static readonly IconData forward = new IconData(0xf3d1, fontFamily: iconFont); |
|||
public static readonly IconData home = new IconData(0xf447, fontFamily: iconFont); |
|||
public static readonly IconData shopping_cart = new IconData(0xf3f7, fontFamily: iconFont); |
|||
public static readonly IconData ellipsis = new IconData(0xf46a, fontFamily: iconFont); |
|||
public static readonly IconData phone = new IconData(0xf4b8, fontFamily: iconFont); |
|||
public static readonly IconData phone_solid = new IconData(0xf4b9, fontFamily: iconFont); |
|||
public static readonly IconData down_arrow = new IconData(0xf35d, fontFamily: iconFont); |
|||
public static readonly IconData up_arrow = new IconData(0xf366, fontFamily: iconFont); |
|||
public static readonly IconData battery_charging = new IconData(0xf111, fontFamily: iconFont); |
|||
public static readonly IconData battery_empty = new IconData(0xf112, fontFamily: iconFont); |
|||
public static readonly IconData battery_full = new IconData(0xf113, fontFamily: iconFont); |
|||
public static readonly IconData battery_75_percent = new IconData(0xf114, fontFamily: iconFont); |
|||
public static readonly IconData battery_25_percent = new IconData(0xf115, fontFamily: iconFont); |
|||
public static readonly IconData bluetooth = new IconData(0xf116, fontFamily: iconFont); |
|||
public static readonly IconData restart = new IconData(0xf21c, fontFamily: iconFont); |
|||
public static readonly IconData reply_all = new IconData(0xf21d, fontFamily: iconFont); |
|||
public static readonly IconData reply_thick_solid = new IconData(0xf21e, fontFamily: iconFont); |
|||
public static readonly IconData share_up = new IconData(0xf220, fontFamily: iconFont); |
|||
public static readonly IconData shuffle_thick = new IconData(0xf221, fontFamily: iconFont); |
|||
public static readonly IconData photo_camera = new IconData(0xf3f5, fontFamily: iconFont); |
|||
public static readonly IconData photo_camera_solid = new IconData(0xf3f6, fontFamily: iconFont); |
|||
public static readonly IconData video_camera = new IconData(0xf4cc, fontFamily: iconFont); |
|||
public static readonly IconData video_camera_solid = new IconData(0xf4cd, fontFamily: iconFont); |
|||
public static readonly IconData switch_camera = new IconData(0xf49e, fontFamily: iconFont); |
|||
public static readonly IconData switch_camera_solid = new IconData(0xf49f, fontFamily: iconFont); |
|||
public static readonly IconData collections = new IconData(0xf3c9, fontFamily: iconFont); |
|||
public static readonly IconData collections_solid = new IconData(0xf3ca, fontFamily: iconFont); |
|||
public static readonly IconData folder = new IconData(0xf434, fontFamily: iconFont); |
|||
public static readonly IconData folder_solid = new IconData(0xf435, fontFamily: iconFont); |
|||
public static readonly IconData folder_open = new IconData(0xf38a, fontFamily: iconFont); |
|||
public static readonly IconData delete = new IconData(0xf4c4, fontFamily: iconFont); |
|||
public static readonly IconData delete_solid = new IconData(0xf4c5, fontFamily: iconFont); |
|||
public static readonly IconData delete_simple = new IconData(0xf37f, fontFamily: iconFont); |
|||
public static readonly IconData pen = new IconData(0xf2bf, fontFamily: iconFont); |
|||
public static readonly IconData pencil = new IconData(0xf37e, fontFamily: iconFont); |
|||
public static readonly IconData create = new IconData(0xf417, fontFamily: iconFont); |
|||
public static readonly IconData create_solid = new IconData(0xf417, fontFamily: iconFont); |
|||
public static readonly IconData refresh = new IconData(0xf49a, fontFamily: iconFont); |
|||
public static readonly IconData refresh_circled = new IconData(0xf49b, fontFamily: iconFont); |
|||
public static readonly IconData refresh_circled_solid = new IconData(0xf49c, fontFamily: iconFont); |
|||
public static readonly IconData refresh_thin = new IconData(0xf49d, fontFamily: iconFont); |
|||
public static readonly IconData refresh_thick = new IconData(0xf3a8, fontFamily: iconFont); |
|||
public static readonly IconData refresh_bold = new IconData(0xf21c, fontFamily: iconFont); |
|||
public static readonly IconData clear_thick = new IconData(0xf2d7, fontFamily: iconFont); |
|||
public static readonly IconData clear_thick_circled = new IconData(0xf36e, fontFamily: iconFont); |
|||
public static readonly IconData clear = new IconData(0xf404, fontFamily: iconFont); |
|||
public static readonly IconData clear_circled = new IconData(0xf405, fontFamily: iconFont); |
|||
public static readonly IconData clear_circled_solid = new IconData(0xf406, fontFamily: iconFont); |
|||
public static readonly IconData add = new IconData(0xf489, fontFamily: iconFont); |
|||
public static readonly IconData add_circled = new IconData(0xf48a, fontFamily: iconFont); |
|||
public static readonly IconData add_circled_solid = new IconData(0xf48b, fontFamily: iconFont); |
|||
public static readonly IconData gear = new IconData(0xf43c, fontFamily: iconFont); |
|||
public static readonly IconData gear_solid = new IconData(0xf43d, fontFamily: iconFont); |
|||
public static readonly IconData gear_big = new IconData(0xf2f7, fontFamily: iconFont); |
|||
public static readonly IconData settings = new IconData(0xf411, fontFamily: iconFont); |
|||
public static readonly IconData settings_solid = new IconData(0xf412, fontFamily: iconFont); |
|||
public static readonly IconData music_note = new IconData(0xf46b, fontFamily: iconFont); |
|||
public static readonly IconData double_music_note = new IconData(0xf46c, fontFamily: iconFont); |
|||
public static readonly IconData play_arrow = new IconData(0xf487, fontFamily: iconFont); |
|||
public static readonly IconData play_arrow_solid = new IconData(0xf488, fontFamily: iconFont); |
|||
public static readonly IconData pause = new IconData(0xf477, fontFamily: iconFont); |
|||
public static readonly IconData pause_solid = new IconData(0xf478, fontFamily: iconFont); |
|||
public static readonly IconData loop = new IconData(0xf449, fontFamily: iconFont); |
|||
public static readonly IconData loop_thick = new IconData(0xf44a, fontFamily: iconFont); |
|||
public static readonly IconData volume_down = new IconData(0xf3b7, fontFamily: iconFont); |
|||
public static readonly IconData volume_mute = new IconData(0xf3b8, fontFamily: iconFont); |
|||
public static readonly IconData volume_off = new IconData(0xf3b9, fontFamily: iconFont); |
|||
public static readonly IconData volume_up = new IconData(0xf3ba, fontFamily: iconFont); |
|||
public static readonly IconData fullscreen = new IconData(0xf386, fontFamily: iconFont); |
|||
public static readonly IconData fullscreen_exit = new IconData(0xf37d, fontFamily: iconFont); |
|||
public static readonly IconData mic_off = new IconData(0xf45f, fontFamily: iconFont); |
|||
public static readonly IconData mic = new IconData(0xf460, fontFamily: iconFont); |
|||
public static readonly IconData mic_solid = new IconData(0xf461, fontFamily: iconFont); |
|||
public static readonly IconData clock = new IconData(0xf4be, fontFamily: iconFont); |
|||
public static readonly IconData clock_solid = new IconData(0xf4bf, fontFamily: iconFont); |
|||
public static readonly IconData time = new IconData(0xf402, fontFamily: iconFont); |
|||
public static readonly IconData time_solid = new IconData(0xf403, fontFamily: iconFont); |
|||
public static readonly IconData padlock = new IconData(0xf4c8, fontFamily: iconFont); |
|||
public static readonly IconData padlock_solid = new IconData(0xf4c9, fontFamily: iconFont); |
|||
public static readonly IconData eye = new IconData(0xf424, fontFamily: iconFont); |
|||
public static readonly IconData eye_solid = new IconData(0xf425, fontFamily: iconFont); |
|||
public static readonly IconData person = new IconData(0xf47d, fontFamily: iconFont); |
|||
public static readonly IconData person_solid = new IconData(0xf47e, fontFamily: iconFont); |
|||
public static readonly IconData person_add = new IconData(0xf47f, fontFamily: iconFont); |
|||
public static readonly IconData person_add_solid = new IconData(0xf480, fontFamily: iconFont); |
|||
public static readonly IconData group = new IconData(0xf47b, fontFamily: iconFont); |
|||
public static readonly IconData group_solid = new IconData(0xf47c, fontFamily: iconFont); |
|||
public static readonly IconData mail = new IconData(0xf422, fontFamily: iconFont); |
|||
public static readonly IconData mail_solid = new IconData(0xf423, fontFamily: iconFont); |
|||
public static readonly IconData location = new IconData(0xf455, fontFamily: iconFont); |
|||
public static readonly IconData location_solid = new IconData(0xf456, fontFamily: iconFont); |
|||
public static readonly IconData tag = new IconData(0xf48c, fontFamily: iconFont); |
|||
public static readonly IconData tag_solid = new IconData(0xf48d, fontFamily: iconFont); |
|||
public static readonly IconData tags = new IconData(0xf48e, fontFamily: iconFont); |
|||
public static readonly IconData tags_solid = new IconData(0xf48f, fontFamily: iconFont); |
|||
public static readonly IconData bus = new IconData(0xf36d, fontFamily: iconFont); |
|||
public static readonly IconData car = new IconData(0xf36f, fontFamily: iconFont); |
|||
public static readonly IconData car_detailed = new IconData(0xf2c1, fontFamily: iconFont); |
|||
public static readonly IconData train_style_one = new IconData(0xf3af, fontFamily: iconFont); |
|||
public static readonly IconData train_style_two = new IconData(0xf3b4, fontFamily: iconFont); |
|||
public static readonly IconData paw = new IconData(0xf479, fontFamily: iconFont); |
|||
public static readonly IconData paw_solid = new IconData(0xf47a, fontFamily: iconFont); |
|||
public static readonly IconData game_controller = new IconData(0xf43a, fontFamily: iconFont); |
|||
public static readonly IconData game_controller_solid = new IconData(0xf43b, fontFamily: iconFont); |
|||
public static readonly IconData lab_flask = new IconData(0xf430, fontFamily: iconFont); |
|||
public static readonly IconData lab_flask_solid = new IconData(0xf431, fontFamily: iconFont); |
|||
public static readonly IconData heart = new IconData(0xf442, fontFamily: iconFont); |
|||
public static readonly IconData heart_solid = new IconData(0xf443, fontFamily: iconFont); |
|||
public static readonly IconData bell = new IconData(0xf3e1, fontFamily: iconFont); |
|||
public static readonly IconData bell_solid = new IconData(0xf3e2, fontFamily: iconFont); |
|||
public static readonly IconData news = new IconData(0xf471, fontFamily: iconFont); |
|||
public static readonly IconData news_solid = new IconData(0xf472, fontFamily: iconFont); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ed8c228d2f54415419ded075a9b16c89 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.async2; |
|||
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 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<CupertinoLocalizations> loadT(Locale locale) { |
|||
return DefaultCupertinoLocalizations.load(locale); |
|||
}*/ |
|||
//public override Future<> load(Locale locale) {
|
|||
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 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(); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 30e111327cb1ec2428eed691dcaee742 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
com.unity.uiwidgets/Runtime/cupertino/nav_bar.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 4fb1c214b61524a48b988f4e193ad97b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
public class CupertinoPageScaffold : StatefulWidget { |
|||
/// Creates a layout for pages with a navigation bar at the top.
|
|||
public CupertinoPageScaffold( |
|||
Widget child, |
|||
Key key = null, |
|||
ObstructingPreferredSizeWidget navigationBar = null, |
|||
Color backgroundColor = null, |
|||
bool resizeToAvoidBottomInset = true |
|||
) : base(key: key) { |
|||
D.assert(child != null); |
|||
|
|||
this.child = child; |
|||
this.navigationBar = navigationBar; |
|||
this.backgroundColor = backgroundColor; |
|||
this.resizeToAvoidBottomInset = resizeToAvoidBottomInset; |
|||
} |
|||
|
|||
public readonly ObstructingPreferredSizeWidget navigationBar; |
|||
public readonly Widget child; |
|||
public readonly Color backgroundColor; |
|||
public readonly bool resizeToAvoidBottomInset; |
|||
|
|||
|
|||
public override State createState() { |
|||
return new _CupertinoPageScaffoldState(); |
|||
} |
|||
} |
|||
|
|||
class _CupertinoPageScaffoldState : State<CupertinoPageScaffold> { |
|||
public readonly ScrollController _primaryScrollController = new ScrollController(); |
|||
|
|||
void _handleStatusBarTap() { |
|||
// Only act on the scroll controller if it has any attached scroll positions.
|
|||
if (_primaryScrollController.hasClients) { |
|||
_primaryScrollController.animateTo( |
|||
0.0f, |
|||
duration: new TimeSpan(0, 0, 0, 0, 500), |
|||
curve: Curves.linearToEaseOut |
|||
); |
|||
} |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
List<Widget> stacked = new List<Widget>(); |
|||
|
|||
Widget paddedContent = widget.child; |
|||
|
|||
MediaQueryData existingMediaQuery = MediaQuery.of(context); |
|||
if (widget.navigationBar != null) { |
|||
float topPadding = widget.navigationBar.preferredSize.height + existingMediaQuery.padding.top; |
|||
|
|||
float bottomPadding = widget.resizeToAvoidBottomInset |
|||
? existingMediaQuery.viewInsets.bottom |
|||
: 0.0f; |
|||
|
|||
EdgeInsets newViewInsets = widget.resizeToAvoidBottomInset |
|||
? existingMediaQuery.viewInsets.copyWith(bottom: 0.0f) |
|||
: existingMediaQuery.viewInsets; |
|||
|
|||
bool? fullObstruction = |
|||
widget.navigationBar.fullObstruction == false |
|||
? CupertinoTheme.of(context).barBackgroundColor.alpha == 0xFF |
|||
: widget.navigationBar.fullObstruction; |
|||
|
|||
if (fullObstruction == true) { |
|||
paddedContent = new MediaQuery( |
|||
data: existingMediaQuery |
|||
.removePadding(removeTop: true) |
|||
.copyWith( |
|||
viewInsets: newViewInsets |
|||
), |
|||
child: new Padding( |
|||
padding: EdgeInsets.only(top: topPadding, bottom: bottomPadding), |
|||
child: paddedContent |
|||
) |
|||
); |
|||
} |
|||
else { |
|||
paddedContent = new MediaQuery( |
|||
data: existingMediaQuery.copyWith( |
|||
padding: existingMediaQuery.padding.copyWith( |
|||
top: topPadding |
|||
), |
|||
viewInsets: newViewInsets |
|||
), |
|||
child: new Padding( |
|||
padding: EdgeInsets.only(bottom: bottomPadding), |
|||
child: paddedContent |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
stacked.Add(new PrimaryScrollController( |
|||
controller: _primaryScrollController, |
|||
child: paddedContent |
|||
)); |
|||
|
|||
if (widget.navigationBar != null) { |
|||
stacked.Add(new Positioned( |
|||
top: 0.0f, |
|||
left: 0.0f, |
|||
right: 0.0f, |
|||
child: widget.navigationBar |
|||
)); |
|||
} |
|||
|
|||
stacked.Add(new Positioned( |
|||
top: 0.0f, |
|||
left: 0.0f, |
|||
right: 0.0f, |
|||
height: existingMediaQuery.padding.top, |
|||
child: new GestureDetector( |
|||
onTap: _handleStatusBarTap |
|||
) |
|||
) |
|||
); |
|||
|
|||
return new DecoratedBox( |
|||
decoration: new BoxDecoration( |
|||
color: widget.backgroundColor ?? CupertinoTheme.of(context).scaffoldBackgroundColor |
|||
), |
|||
child: new Stack( |
|||
children: stacked |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
public abstract class ObstructingPreferredSizeWidget : PreferredSizeWidget { |
|||
|
|||
protected ObstructingPreferredSizeWidget(Key key = null) : base(key: key) {} |
|||
public virtual bool? fullObstruction { get; } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0e428c069ad6abb4e80e0a3483f6fe57 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
static class CupertinoPickerUtils { |
|||
public static Color _kHighlighterBorder = new Color(0xFF7F7F7F); |
|||
public static Color _kDefaultBackground = new Color(0xFFD2D4DB); |
|||
public const float _kDefaultDiameterRatio = 1.35f; |
|||
public const float _kDefaultPerspective = 0.004f; |
|||
public const float _kForegroundScreenOpacityFraction = 0.7f; |
|||
} |
|||
|
|||
public class CupertinoPicker : StatefulWidget { |
|||
public CupertinoPicker( |
|||
float itemExtent, |
|||
ValueChanged<int> onSelectedItemChanged, |
|||
List<Widget> children = null, |
|||
Key key = null, |
|||
float diameterRatio = CupertinoPickerUtils._kDefaultDiameterRatio, |
|||
Color backgroundColor = null, |
|||
float offAxisFraction = 0.0f, |
|||
bool useMagnifier = false, |
|||
float magnification = 1.0f, |
|||
FixedExtentScrollController scrollController = null, |
|||
bool looping = false, |
|||
ListWheelChildDelegate childDelegate = null |
|||
) : base(key: key) { |
|||
D.assert(children != null || childDelegate != null); |
|||
D.assert(diameterRatio > 0.0, () => RenderListWheelViewport.diameterRatioZeroMessage); |
|||
D.assert(magnification > 0); |
|||
D.assert(itemExtent > 0); |
|||
|
|||
this.childDelegate = childDelegate ?? (looping |
|||
? (ListWheelChildDelegate) new ListWheelChildLoopingListDelegate( |
|||
children: children) |
|||
: (ListWheelChildDelegate) new ListWheelChildListDelegate(children: children)); |
|||
|
|||
this.itemExtent = itemExtent; |
|||
this.onSelectedItemChanged = onSelectedItemChanged; |
|||
this.diameterRatio = diameterRatio; |
|||
this.backgroundColor = backgroundColor ?? CupertinoPickerUtils._kDefaultBackground; |
|||
this.offAxisFraction = offAxisFraction; |
|||
this.useMagnifier = useMagnifier; |
|||
this.magnification = magnification; |
|||
this.scrollController = scrollController; |
|||
} |
|||
|
|||
public static CupertinoPicker builder( |
|||
float itemExtent, |
|||
ValueChanged<int> onSelectedItemChanged, |
|||
IndexedWidgetBuilder itemBuilder, |
|||
Key key = null, |
|||
float diameterRatio = CupertinoPickerUtils._kDefaultDiameterRatio, |
|||
Color backgroundColor = null, |
|||
float offAxisFraction = 0.0f, |
|||
bool useMagnifier = false, |
|||
float magnification = 1.0f, |
|||
FixedExtentScrollController scrollController = null, |
|||
int? childCount = null |
|||
) { |
|||
D.assert(itemBuilder != null); |
|||
D.assert(diameterRatio > 0.0f, () => RenderListWheelViewport.diameterRatioZeroMessage); |
|||
D.assert(magnification > 0); |
|||
D.assert(itemExtent > 0); |
|||
|
|||
return new CupertinoPicker( |
|||
itemExtent: itemExtent, |
|||
onSelectedItemChanged: onSelectedItemChanged, |
|||
key: key, |
|||
diameterRatio: diameterRatio, |
|||
backgroundColor: backgroundColor, |
|||
offAxisFraction: offAxisFraction, |
|||
useMagnifier: useMagnifier, |
|||
magnification: magnification, |
|||
scrollController: scrollController, |
|||
childDelegate: new ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount) |
|||
); |
|||
} |
|||
|
|||
public readonly float diameterRatio; |
|||
public readonly Color backgroundColor; |
|||
public readonly float offAxisFraction; |
|||
public readonly bool useMagnifier; |
|||
public readonly float magnification; |
|||
public readonly FixedExtentScrollController scrollController; |
|||
public readonly float itemExtent; |
|||
public readonly ValueChanged<int> onSelectedItemChanged; |
|||
public readonly ListWheelChildDelegate childDelegate; |
|||
|
|||
public override State createState() { |
|||
return new _CupertinoPickerState(); |
|||
} |
|||
} |
|||
|
|||
class _CupertinoPickerState : State<CupertinoPicker> { |
|||
FixedExtentScrollController _controller; |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
if (widget.scrollController == null) { |
|||
_controller = new FixedExtentScrollController(); |
|||
} |
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget oldWidget) { |
|||
if (widget.scrollController != null && ((CupertinoPicker) oldWidget).scrollController == null) { |
|||
_controller = null; |
|||
} |
|||
else if (widget.scrollController == null && ((CupertinoPicker) oldWidget).scrollController != null) { |
|||
D.assert(_controller == null); |
|||
_controller = new FixedExtentScrollController(); |
|||
} |
|||
|
|||
base.didUpdateWidget(oldWidget); |
|||
} |
|||
|
|||
public override void dispose() { |
|||
_controller?.dispose(); |
|||
base.dispose(); |
|||
} |
|||
|
|||
void _handleSelectedItemChanged(int index) { |
|||
if (widget.onSelectedItemChanged != null) { |
|||
widget.onSelectedItemChanged(index); |
|||
} |
|||
} |
|||
|
|||
Widget _buildGradientScreen() { |
|||
if (widget.backgroundColor != null && widget.backgroundColor.alpha < 255) { |
|||
return new Container(); |
|||
} |
|||
|
|||
Color widgetBackgroundColor = widget.backgroundColor ?? new Color(0xFFFFFFFF); |
|||
return Positioned.fill( |
|||
child: new IgnorePointer( |
|||
child: new Container( |
|||
decoration: new BoxDecoration( |
|||
gradient: new LinearGradient( |
|||
colors: new List<Color> { |
|||
widgetBackgroundColor, |
|||
widgetBackgroundColor.withAlpha(0xF2), |
|||
widgetBackgroundColor.withAlpha(0xDD), |
|||
widgetBackgroundColor.withAlpha(0), |
|||
widgetBackgroundColor.withAlpha(0), |
|||
widgetBackgroundColor.withAlpha(0xDD), |
|||
widgetBackgroundColor.withAlpha(0xF2), |
|||
widgetBackgroundColor, |
|||
}, |
|||
stops: new List<float> { |
|||
0.0f, 0.05f, 0.09f, 0.22f, 0.78f, 0.91f, 0.95f, 1.0f |
|||
}, |
|||
begin: Alignment.topCenter, |
|||
end: Alignment.bottomCenter |
|||
) |
|||
) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
|
|||
Widget _buildMagnifierScreen() { |
|||
Color foreground = widget.backgroundColor?.withAlpha( |
|||
(int) (widget.backgroundColor.alpha * CupertinoPickerUtils._kForegroundScreenOpacityFraction) |
|||
); |
|||
|
|||
return new IgnorePointer( |
|||
child: new Column( |
|||
children: new List<Widget> { |
|||
new Expanded( |
|||
child: new Container( |
|||
color: foreground |
|||
) |
|||
), |
|||
new Container( |
|||
decoration: new BoxDecoration( |
|||
border: new Border( |
|||
top: new BorderSide(width: 0.0f, color: CupertinoPickerUtils._kHighlighterBorder), |
|||
bottom: new BorderSide(width: 0.0f, color: CupertinoPickerUtils._kHighlighterBorder) |
|||
) |
|||
), |
|||
constraints: BoxConstraints.expand( |
|||
height: widget.itemExtent * widget.magnification |
|||
) |
|||
), |
|||
new Expanded( |
|||
child: new Container( |
|||
color: foreground |
|||
) |
|||
), |
|||
} |
|||
) |
|||
); |
|||
} |
|||
|
|||
Widget _buildUnderMagnifierScreen() { |
|||
Color foreground = widget.backgroundColor?.withAlpha( |
|||
(int) (widget.backgroundColor.alpha * CupertinoPickerUtils._kForegroundScreenOpacityFraction) |
|||
); |
|||
|
|||
return new Column( |
|||
children: new List<Widget> { |
|||
new Expanded(child: new Container()), |
|||
new Container( |
|||
color: foreground, |
|||
constraints: BoxConstraints.expand( |
|||
height: widget.itemExtent * widget.magnification |
|||
) |
|||
), |
|||
new Expanded(child: new Container()) |
|||
} |
|||
); |
|||
} |
|||
|
|||
Widget _addBackgroundToChild(Widget child) { |
|||
return new DecoratedBox( |
|||
decoration: new BoxDecoration( |
|||
color: widget.backgroundColor |
|||
), |
|||
child: child |
|||
); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
Widget result = new Stack( |
|||
children: new List<Widget> { |
|||
Positioned.fill( |
|||
child: ListWheelScrollView.useDelegate( |
|||
controller: widget.scrollController ?? _controller, |
|||
physics: new FixedExtentScrollPhysics(), |
|||
diameterRatio: widget.diameterRatio, |
|||
perspective: CupertinoPickerUtils._kDefaultPerspective, |
|||
offAxisFraction: widget.offAxisFraction, |
|||
useMagnifier: widget.useMagnifier, |
|||
magnification: widget.magnification, |
|||
itemExtent: widget.itemExtent, |
|||
onSelectedItemChanged: _handleSelectedItemChanged, |
|||
childDelegate: widget.childDelegate |
|||
) |
|||
), |
|||
_buildGradientScreen(), |
|||
_buildMagnifierScreen() |
|||
} |
|||
); |
|||
if (widget.backgroundColor != null && widget.backgroundColor.alpha < 255) { |
|||
result = new Stack( |
|||
children: new List<Widget> { |
|||
_buildUnderMagnifierScreen(), _addBackgroundToChild(result), |
|||
} |
|||
); |
|||
} |
|||
else { |
|||
result = _addBackgroundToChild(result); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: bf0858feee06e8c46bf820fe90a17071 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.async2; |
|||
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 = new Color(0x6604040F); |
|||
|
|||
public static readonly TimeSpan _kModalPopupTransitionDuration = new TimeSpan(0, 0, 0, 0, 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, |
|||
WidgetBuilder builder |
|||
) { |
|||
return Navigator.of(context, rootNavigator: true).push( |
|||
new _CupertinoModalPopupRoute( |
|||
builder: builder, |
|||
barrierLabel: "Dismiss" |
|||
) |
|||
); |
|||
} |
|||
|
|||
|
|||
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<object> showCupertinoDialog( |
|||
BuildContext context, |
|||
WidgetBuilder builder |
|||
) { |
|||
D.assert(builder != null); |
|||
return DialogUtils.showGeneralDialog( |
|||
context: context, |
|||
barrierDismissible: false, |
|||
barrierColor: _kModalBarrierColor, |
|||
transitionDuration: new TimeSpan(0, 0, 0, 0, 250), |
|||
pageBuilder: |
|||
(BuildContext _context, Animation<float> animation, Animation<float> secondaryAnimation) => { |
|||
return builder(_context); |
|||
}, |
|||
transitionBuilder: _buildCupertinoDialogTransitions |
|||
); |
|||
} |
|||
} |
|||
|
|||
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 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 int hashCode { |
|||
get { return edgeGradient.GetHashCode(); } |
|||
} |
|||
|
|||
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; |
|||
} |
|||
|
|||
float deltaX = -configuration.size.width; |
|||
Rect rect = (offset & configuration.size).translate(deltaX, 0.0f); |
|||
Paint paint = new Paint(); |
|||
paint.shader = gradient.createShader(rect); |
|||
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 new TimeSpan(0, 0, 0, 0, 400); } |
|||
} |
|||
|
|||
public override Color barrierColor { |
|||
get { return null; } |
|||
} |
|||
|
|||
|
|||
public string barrierLabel { |
|||
get { return null; } |
|||
} |
|||
|
|||
|
|||
public override bool canTransitionFrom(TransitionRoute previousRoute) { |
|||
return previousRoute is CupertinoPageRoute; |
|||
} |
|||
|
|||
|
|||
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); } |
|||
} |
|||
|
|||
public bool popGestureEnabled { |
|||
get { return _isPopGestureEnabled(this); } |
|||
} |
|||
|
|||
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( |
|||
$"The builder for route {settings.name} returned null.\nRoute 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 |
|||
) { |
|||
if (route.fullscreenDialog) { |
|||
return new CupertinoFullscreenDialogTransition( |
|||
animation: animation, |
|||
child: child |
|||
); |
|||
} |
|||
|
|||
else { |
|||
return new CupertinoPageTransition( |
|||
primaryRouteAnimation: animation, |
|||
secondaryRouteAnimation: secondaryAnimation, |
|||
linearTransition: isPopGestureInProgress(route), |
|||
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( |
|||
Animation<float> primaryRouteAnimation, |
|||
Animation<float> secondaryRouteAnimation, |
|||
Widget child, |
|||
bool linearTransition, |
|||
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( |
|||
Animation<float> animation, |
|||
Widget child, |
|||
Key key = null |
|||
) : base(key: key) { |
|||
_positionAnimation = new CurvedAnimation( |
|||
parent: animation, |
|||
curve: Curves.linearToEaseOut, |
|||
reverseCurve: Curves.linearToEaseOut.flipped |
|||
).drive(CupertinoRouteUtils._kBottomUpTween); |
|||
this.child = child; |
|||
} |
|||
|
|||
readonly Animation<Offset> _positionAnimation; |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new SlideTransition( |
|||
position: _positionAnimation, |
|||
child: child |
|||
); |
|||
} |
|||
} |
|||
|
|||
class _CupertinoBackGestureDetector : StatefulWidget { |
|||
public _CupertinoBackGestureDetector( |
|||
Widget child, |
|||
ValueGetter<bool> enabledCallback, |
|||
ValueGetter<_CupertinoBackGestureController> onStartPopGesture, |
|||
Key key = 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); |
|||
_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 Positioned( |
|||
left: 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 ? false : true; |
|||
} |
|||
else { |
|||
animateForward = controller.value > 0.5 ? true : false; |
|||
} |
|||
|
|||
if (animateForward) { |
|||
int droppedPageForwardAnimationTime = Mathf.Min( |
|||
MathUtils.lerpFloat(CupertinoRouteUtils._kMaxDroppedSwipePageForwardAnimationTime, 0f, |
|||
controller.value).floor(), |
|||
CupertinoRouteUtils._kMaxPageBackAnimationTime |
|||
); |
|||
controller.animateTo(1.0f, duration: new TimeSpan(0, 0, 0, 0, droppedPageForwardAnimationTime), |
|||
curve: animationCurve); |
|||
} |
|||
else { |
|||
navigator.pop(); |
|||
|
|||
if (controller.isAnimating) { |
|||
int droppedPageBackAnimationTime = |
|||
MathUtils.lerpFloat(0f, CupertinoRouteUtils._kMaxDroppedSwipePageForwardAnimationTime, |
|||
controller.value).floor(); |
|||
controller.animateBack(0.0f, duration: new TimeSpan(0, 0, 0, 0, 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( |
|||
WidgetBuilder builder = null, |
|||
string barrierLabel = null, |
|||
RouteSettings settings = null |
|||
) : base(settings: settings) { |
|||
this.builder = builder; |
|||
this.barrierLabel = barrierLabel; |
|||
} |
|||
|
|||
public readonly WidgetBuilder builder; |
|||
|
|||
public readonly string barrierLabel; |
|||
|
|||
|
|||
public override Color barrierColor { |
|||
get { return CupertinoRouteUtils._kModalBarrierColor; } |
|||
} |
|||
|
|||
public override bool barrierDismissible { |
|||
get { return true; } |
|||
} |
|||
|
|||
public bool semanticsDismissible { |
|||
get { return false; } |
|||
} |
|||
|
|||
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 builder(context); |
|||
} |
|||
|
|||
|
|||
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 |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 699b3c09353fafc40b33fd5c0470048f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.async2; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
class CupertinoScrollbarUtils { |
|||
public static readonly Color _kScrollbarColor = new Color(0x99777777); |
|||
public const float _kScrollbarThickness = 2.5f; |
|||
public const float _kScrollbarMainAxisMargin = 4.0f; |
|||
public const float _kScrollbarCrossAxisMargin = 2.5f; |
|||
public const float _kScrollbarMinLength = 36.0f; |
|||
public const float _kScrollbarMinOverscrollLength = 8.0f; |
|||
public static readonly Radius _kScrollbarRadius = Radius.circular(1.25f); |
|||
public static readonly TimeSpan _kScrollbarTimeToFade = new TimeSpan(0, 0, 0, 0, 50); |
|||
public static readonly TimeSpan _kScrollbarFadeDuration = new TimeSpan(0, 0, 0, 0, 250); |
|||
} |
|||
|
|||
public class CupertinoScrollbar : StatefulWidget { |
|||
public CupertinoScrollbar( |
|||
Widget child, |
|||
Key key = null |
|||
) : base(key: key) { |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
public readonly ScrollController controller; |
|||
public readonly bool isAlwaysShown; |
|||
|
|||
public override State createState() { |
|||
return new _CupertinoScrollbarState(); |
|||
} |
|||
} |
|||
|
|||
class _CupertinoScrollbarState : TickerProviderStateMixin<CupertinoScrollbar> { |
|||
ScrollbarPainter _painter; |
|||
|
|||
TextDirection _textDirection; |
|||
|
|||
AnimationController _fadeoutAnimationController; |
|||
Animation<float> _fadeoutOpacityAnimation; |
|||
double _dragScrollbarPositionY; |
|||
Timer _fadeoutTimer; |
|||
|
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
_fadeoutAnimationController = new AnimationController( |
|||
vsync: this, |
|||
duration: CupertinoScrollbarUtils._kScrollbarFadeDuration |
|||
); |
|||
_fadeoutOpacityAnimation = new CurvedAnimation( |
|||
parent: _fadeoutAnimationController, |
|||
curve: Curves.fastOutSlowIn |
|||
); |
|||
} |
|||
|
|||
|
|||
public override void didChangeDependencies() { |
|||
base.didChangeDependencies(); |
|||
_textDirection = Directionality.of(context); |
|||
_painter = _buildCupertinoScrollbarPainter(); |
|||
} |
|||
|
|||
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 |
|||
); |
|||
} |
|||
|
|||
bool _handleScrollNotification(ScrollNotification notification) { |
|||
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(); |
|||
} |
|||
|
|||
/*_fadeoutTimer?.cancel(); |
|||
_fadeoutTimer = Window.instance.run(CupertinoScrollbarUtils._kScrollbarTimeToFade, () => { |
|||
_fadeoutAnimationController.reverse(); |
|||
_fadeoutTimer = null; |
|||
});*/ |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
|
|||
public override void dispose() { |
|||
_fadeoutAnimationController.dispose(); |
|||
_fadeoutTimer?.cancel(); |
|||
_painter.dispose(); |
|||
base.dispose(); |
|||
} |
|||
|
|||
void _startFadeoutTimer() { |
|||
if (!widget.isAlwaysShown) { |
|||
_fadeoutTimer?.cancel(); |
|||
_fadeoutTimer = Timer.create(CupertinoScrollbarUtils._kScrollbarTimeToFade, () => { |
|||
_fadeoutAnimationController.reverse(); |
|||
_fadeoutTimer = null; |
|||
}); |
|||
} |
|||
} |
|||
|
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new NotificationListener<ScrollNotification>( |
|||
onNotification: _handleScrollNotification, |
|||
child: new RepaintBoundary( |
|||
child: new CustomPaint( |
|||
foregroundPainter: _painter, |
|||
child: new RepaintBoundary( |
|||
child: widget.child |
|||
) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 55b1201340c47f94b91591a011603a8a |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.scheduler2; |
|||
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 = new TimeSpan(0, 0, 0, 0, 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 |
|||
) : 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; |
|||
} |
|||
|
|||
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 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.lerpFloat(widget.min, widget.max, value); |
|||
if (lerpValue != widget.value) { |
|||
widget.onChanged(lerpValue); |
|||
} |
|||
} |
|||
|
|||
void _handleDragStart(float value) { |
|||
D.assert(widget.onChangeStart != null); |
|||
widget.onChangeStart(MathUtils.lerpFloat(widget.min, widget.max, value)); |
|||
} |
|||
|
|||
void _handleDragEnd(float value) { |
|||
D.assert(widget.onChangeEnd != null); |
|||
widget.onChangeEnd(MathUtils.lerpFloat(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: widget.activeColor ?? CupertinoTheme.of(context).primaryColor, |
|||
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, |
|||
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; |
|||
} |
|||
|
|||
public readonly float? value; |
|||
public readonly int? divisions; |
|||
public readonly Color activeColor; |
|||
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, |
|||
onChanged: onChanged, |
|||
onChangeStart: onChangeStart, |
|||
onChangeEnd: onChangeEnd, |
|||
vsync: vsync |
|||
); |
|||
} |
|||
|
|||
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.onChanged = onChanged; |
|||
renderObject.onChangeStart = onChangeStart; |
|||
renderObject.onChangeEnd = onChangeEnd; |
|||
} |
|||
} |
|||
|
|||
class _RenderCupertinoSlider : RenderConstrainedBox { |
|||
public _RenderCupertinoSlider( |
|||
float value, |
|||
int? divisions = null, |
|||
Color activeColor = null, |
|||
ValueChanged<float> onChanged = null, |
|||
ValueChanged<float> onChangeStart = null, |
|||
ValueChanged<float> onChangeEnd = null, |
|||
TickerProvider vsync = null |
|||
) : base(additionalConstraints: BoxConstraints.tightFor(width: SliderUtils._kSliderWidth, |
|||
height: SliderUtils._kSliderHeight)) { |
|||
D.assert(value >= 0.0f && value <= 1.0f); |
|||
_value = value; |
|||
_divisions = divisions; |
|||
_activeColor = activeColor; |
|||
_onChanged = onChanged; |
|||
this.onChangeStart = onChangeStart; |
|||
this.onChangeEnd = onChangeEnd; |
|||
_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 ValueChanged<float> onChanged { |
|||
get { return _onChanged; } |
|||
set { |
|||
if (value == _onChanged) { |
|||
return; |
|||
} |
|||
|
|||
_onChanged = value; |
|||
} |
|||
} |
|||
|
|||
ValueChanged<float> _onChanged; |
|||
|
|||
public ValueChanged<float> onChangeStart; |
|||
public ValueChanged<float> onChangeEnd; |
|||
|
|||
|
|||
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 = _value; |
|||
|
|||
return MathUtils.lerpFloat(_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; |
|||
_currentDragValue += valueDelta ?? 0.0f; |
|||
|
|||
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; |
|||
Color leftColor; |
|||
Color rightColor; |
|||
visualPosition = _position.value; |
|||
leftColor = SliderUtils._kTrackColor; |
|||
rightColor = _activeColor; |
|||
|
|||
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); |
|||
_thumbPainter.paint(canvas, |
|||
Rect.fromCircle(center: thumbCenter, radius: CupertinoThumbPainter.radius)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c692b7c8464330e48a01d99464265341 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.scheduler2; |
|||
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 = new TimeSpan(0, 0, 0, 0, 300); |
|||
public static readonly TimeSpan _kToggleDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
} |
|||
|
|||
public class CupertinoSwitch : StatefulWidget { |
|||
public CupertinoSwitch( |
|||
bool value, |
|||
ValueChanged<bool> onChanged, |
|||
Key key = null, |
|||
Color activeColor = null, |
|||
DragStartBehavior dragStartBehavior = DragStartBehavior.start |
|||
) : base(key: key) { |
|||
this.value = value; |
|||
this.onChanged = onChanged; |
|||
this.activeColor = activeColor; |
|||
this.dragStartBehavior = dragStartBehavior; |
|||
} |
|||
|
|||
public readonly bool value; |
|||
|
|||
public readonly ValueChanged<bool> onChanged; |
|||
|
|||
public readonly Color activeColor; |
|||
|
|||
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 override Widget build(BuildContext context) { |
|||
return new Opacity( |
|||
opacity: widget.onChanged == null ? CupertinoSwitchUtils._kCupertinoSwitchDisabledOpacity : 1.0f, |
|||
child: new _CupertinoSwitchRenderObjectWidget( |
|||
value: widget.value, |
|||
activeColor: widget.activeColor ?? CupertinoColors.activeGreen, |
|||
onChanged: widget.onChanged, |
|||
vsync: this, |
|||
dragStartBehavior: widget.dragStartBehavior |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
class _CupertinoSwitchRenderObjectWidget : LeafRenderObjectWidget { |
|||
public _CupertinoSwitchRenderObjectWidget( |
|||
Key key = null, |
|||
bool value = false, |
|||
Color activeColor = null, |
|||
ValueChanged<bool> onChanged = null, |
|||
TickerProvider vsync = null, |
|||
DragStartBehavior dragStartBehavior = DragStartBehavior.start |
|||
) : base(key: key) { |
|||
this.value = value; |
|||
this.activeColor = activeColor; |
|||
this.onChanged = onChanged; |
|||
this.vsync = vsync; |
|||
this.dragStartBehavior = dragStartBehavior; |
|||
} |
|||
|
|||
public readonly bool value; |
|||
public readonly Color activeColor; |
|||
public readonly ValueChanged<bool> onChanged; |
|||
public readonly TickerProvider vsync; |
|||
public readonly DragStartBehavior dragStartBehavior; |
|||
|
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
return new _RenderCupertinoSwitch( |
|||
value: value, |
|||
activeColor: activeColor, |
|||
onChanged: onChanged, |
|||
textDirection: Directionality.of(context), |
|||
vsync: vsync, |
|||
dragStartBehavior: dragStartBehavior |
|||
); |
|||
} |
|||
|
|||
public override void updateRenderObject(BuildContext context, RenderObject renderObject) { |
|||
var _renderObject = renderObject as _RenderCupertinoSwitch; |
|||
_renderObject.value = value; |
|||
_renderObject.activeColor = activeColor; |
|||
_renderObject.onChanged = onChanged; |
|||
_renderObject.textDirection = Directionality.of(context); |
|||
_renderObject.vsync = vsync; |
|||
_renderObject.dragStartBehavior = dragStartBehavior; |
|||
} |
|||
} |
|||
|
|||
|
|||
class _RenderCupertinoSwitch : RenderConstrainedBox { |
|||
public _RenderCupertinoSwitch( |
|||
bool value, |
|||
Color activeColor, |
|||
TextDirection textDirection, |
|||
TickerProvider vsync, |
|||
ValueChanged<bool> onChanged = null, |
|||
DragStartBehavior dragStartBehavior = DragStartBehavior.start |
|||
) : base(additionalConstraints: BoxConstraints.tightFor( |
|||
width: CupertinoSwitchUtils._kSwitchWidth, |
|||
height: CupertinoSwitchUtils._kSwitchHeight) |
|||
) { |
|||
D.assert(activeColor != null); |
|||
D.assert(vsync != null); |
|||
_value = value; |
|||
_activeColor = activeColor; |
|||
_onChanged = onChanged; |
|||
_textDirection = textDirection; |
|||
_vsync = vsync; |
|||
|
|||
_tap = new TapGestureRecognizer() { |
|||
onTapDown = _handleTapDown, |
|||
onTap = _handleTap, |
|||
onTapUp = _handleTapUp, |
|||
onTapCancel = _handleTapCancel, |
|||
}; |
|||
|
|||
_drag = new HorizontalDragGestureRecognizer() { |
|||
onStart = _handleDragStart, |
|||
onUpdate = _handleDragUpdate, |
|||
onEnd = _handleDragEnd, |
|||
dragStartBehavior = dragStartBehavior |
|||
}; |
|||
|
|||
_positionController = new AnimationController( |
|||
duration: CupertinoSwitchUtils._kToggleDuration, |
|||
value: value ? 1.0f : 0.0f, |
|||
vsync: vsync |
|||
); |
|||
_position = new CurvedAnimation( |
|||
parent: _positionController, |
|||
curve: Curves.linear |
|||
); |
|||
_position.addListener(markNeedsPaint); |
|||
_position.addStatusListener(_handlePositionStateChanged); |
|||
|
|||
_reactionController = new AnimationController( |
|||
duration: CupertinoSwitchUtils._kReactionDuration, |
|||
vsync: vsync |
|||
); |
|||
_reaction = new CurvedAnimation( |
|||
parent: _reactionController, |
|||
curve: Curves.ease |
|||
); |
|||
_reaction.addListener(markNeedsPaint); |
|||
} |
|||
|
|||
AnimationController _positionController; |
|||
CurvedAnimation _position; |
|||
AnimationController _reactionController; |
|||
Animation<float> _reaction; |
|||
|
|||
public bool value { |
|||
get { return _value; } |
|||
set { |
|||
if (value == _value) { |
|||
return; |
|||
} |
|||
|
|||
_value = value; |
|||
// this.markNeedsSemanticsUpdate();
|
|||
_position.curve = Curves.ease; |
|||
_position.reverseCurve = Curves.ease.flipped; |
|||
if (value) { |
|||
_positionController.forward(); |
|||
} |
|||
else { |
|||
_positionController.reverse(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
bool _value; |
|||
|
|||
public TickerProvider vsync { |
|||
get { return _vsync; } |
|||
set { |
|||
D.assert(value != null); |
|||
if (value == _vsync) { |
|||
return; |
|||
} |
|||
|
|||
_vsync = value; |
|||
_positionController.resync(vsync); |
|||
_reactionController.resync(vsync); |
|||
} |
|||
} |
|||
|
|||
TickerProvider _vsync; |
|||
|
|||
public Color activeColor { |
|||
get { return _activeColor; } |
|||
set { |
|||
D.assert(value != null); |
|||
if (value == _activeColor) { |
|||
return; |
|||
} |
|||
|
|||
_activeColor = value; |
|||
markNeedsPaint(); |
|||
} |
|||
} |
|||
|
|||
Color _activeColor; |
|||
|
|||
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 DragStartBehavior dragStartBehavior { |
|||
get { return _drag.dragStartBehavior; } |
|||
set { |
|||
if (_drag.dragStartBehavior == value) { |
|||
return; |
|||
} |
|||
|
|||
_drag.dragStartBehavior = value; |
|||
} |
|||
} |
|||
|
|||
public bool isInteractive { |
|||
get { return onChanged != null; } |
|||
} |
|||
|
|||
TapGestureRecognizer _tap; |
|||
HorizontalDragGestureRecognizer _drag; |
|||
|
|||
public override void attach(object _owner) { |
|||
base.attach(_owner); |
|||
if (value) { |
|||
_positionController.forward(); |
|||
} |
|||
else { |
|||
_positionController.reverse(); |
|||
} |
|||
|
|||
if (isInteractive) { |
|||
switch (_reactionController.status) { |
|||
case AnimationStatus.forward: |
|||
_reactionController.forward(); |
|||
break; |
|||
case AnimationStatus.reverse: |
|||
_reactionController.reverse(); |
|||
break; |
|||
case AnimationStatus.dismissed: |
|||
case AnimationStatus.completed: |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override void detach() { |
|||
_positionController.stop(); |
|||
_reactionController.stop(); |
|||
base.detach(); |
|||
} |
|||
|
|||
void _handlePositionStateChanged(AnimationStatus status) { |
|||
if (isInteractive) { |
|||
if (status == AnimationStatus.completed && !_value) { |
|||
onChanged(true); |
|||
} |
|||
else if (status == AnimationStatus.dismissed && _value) { |
|||
onChanged(false); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void _handleTapDown(TapDownDetails details) { |
|||
if (isInteractive) { |
|||
_reactionController.forward(); |
|||
} |
|||
} |
|||
|
|||
void _handleTap() { |
|||
if (isInteractive) { |
|||
onChanged(!_value); |
|||
_emitVibration(); |
|||
} |
|||
} |
|||
|
|||
void _handleTapUp(TapUpDetails details) { |
|||
if (isInteractive) { |
|||
_reactionController.reverse(); |
|||
} |
|||
} |
|||
|
|||
void _handleTapCancel() { |
|||
if (isInteractive) { |
|||
_reactionController.reverse(); |
|||
} |
|||
} |
|||
|
|||
void _handleDragStart(DragStartDetails details) { |
|||
if (isInteractive) { |
|||
_reactionController.forward(); |
|||
_emitVibration(); |
|||
} |
|||
} |
|||
|
|||
void _handleDragUpdate(DragUpdateDetails details) { |
|||
if (isInteractive) { |
|||
_position.curve = null; |
|||
_position.reverseCurve = null; |
|||
float delta = details.primaryDelta / CupertinoSwitchUtils._kTrackInnerLength ?? 0f; |
|||
|
|||
_positionController.setValue(_positionController.value + delta); |
|||
|
|||
// switch (this.textDirection) {
|
|||
// case TextDirection.rtl:
|
|||
// this._positionController.setValue(this._positionController.value - delta);
|
|||
// break;
|
|||
// case TextDirection.ltr:
|
|||
// this._positionController.setValue(this._positionController.value + delta);
|
|||
// break;
|
|||
// }
|
|||
} |
|||
} |
|||
|
|||
void _handleDragEnd(DragEndDetails details) { |
|||
if (_position.value >= 0.5) { |
|||
_positionController.forward(); |
|||
} |
|||
else { |
|||
_positionController.reverse(); |
|||
} |
|||
|
|||
_reactionController.reverse(); |
|||
} |
|||
|
|||
void _emitVibration() { |
|||
// switch (Platform defaultTargetPlatform) {
|
|||
// case TargetPlatform.iOS:
|
|||
// HapticFeedback.lightImpact();
|
|||
// break;
|
|||
// case TargetPlatform.fuchsia:
|
|||
// case TargetPlatform.android:
|
|||
// break;
|
|||
// }
|
|||
return; |
|||
} |
|||
|
|||
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(evt as PointerDownEvent); |
|||
_tap.addPointer(evt as PointerDownEvent); |
|||
} |
|||
} |
|||
|
|||
// public override void describeSemanticsConfiguration(SemanticsConfiguration config) {
|
|||
// base.describeSemanticsConfiguration(config);
|
|||
//
|
|||
// if (isInteractive)
|
|||
// config.onTap = _handleTap;
|
|||
//
|
|||
// config.isEnabled = isInteractive;
|
|||
// config.isToggled = _value;
|
|||
// }
|
|||
|
|||
public readonly CupertinoThumbPainter _thumbPainter = new CupertinoThumbPainter(); |
|||
|
|||
public override void paint(PaintingContext context, Offset offset) { |
|||
Canvas canvas = context.canvas; |
|||
|
|||
float currentValue = _position.value; |
|||
float currentReactionValue = _reaction.value; |
|||
|
|||
float visualPosition = 0f; |
|||
switch (textDirection) { |
|||
case TextDirection.rtl: |
|||
visualPosition = 1.0f - currentValue; |
|||
break; |
|||
case TextDirection.ltr: |
|||
visualPosition = currentValue; |
|||
break; |
|||
} |
|||
|
|||
Color trackColor = _value ? activeColor : CupertinoSwitchUtils._kTrackColor; |
|||
float borderThickness = |
|||
1.5f + (CupertinoSwitchUtils._kTrackRadius - 1.5f) * Mathf.Max(currentReactionValue, currentValue); |
|||
|
|||
Paint paint = new Paint(); |
|||
paint.color = trackColor; |
|||
|
|||
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 outerRRect = RRect.fromRectAndRadius(trackRect, Radius.circular(CupertinoSwitchUtils |
|||
._kTrackRadius)); |
|||
RRect innerRRect = RRect.fromRectAndRadius(trackRect.deflate(borderThickness), Radius.circular |
|||
(CupertinoSwitchUtils._kTrackRadius)); |
|||
canvas.drawDRRect(outerRRect, innerRRect, paint); |
|||
|
|||
float currentThumbExtension = CupertinoThumbPainter.extension * currentReactionValue; |
|||
float thumbLeft = MathUtils.lerpFloat( |
|||
trackRect.left + CupertinoSwitchUtils._kTrackInnerStart - CupertinoThumbPainter.radius, |
|||
trackRect.left + CupertinoSwitchUtils._kTrackInnerEnd - CupertinoThumbPainter.radius - |
|||
currentThumbExtension, |
|||
visualPosition |
|||
); |
|||
float thumbRight = MathUtils.lerpFloat( |
|||
trackRect.left + CupertinoSwitchUtils._kTrackInnerStart + CupertinoThumbPainter.radius + |
|||
currentThumbExtension, |
|||
trackRect.left + CupertinoSwitchUtils._kTrackInnerEnd + CupertinoThumbPainter.radius, |
|||
visualPosition |
|||
); |
|||
float thumbCenterY = offset.dy + size.height / 2.0f; |
|||
|
|||
_thumbPainter.paint(canvas, Rect.fromLTRB( |
|||
thumbLeft, |
|||
thumbCenterY - CupertinoThumbPainter.radius, |
|||
thumbRight, |
|||
thumbCenterY + CupertinoThumbPainter.radius |
|||
)); |
|||
} |
|||
|
|||
|
|||
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)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6216d964b6d93c34cb861fd15181b25b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
public class CupertinoTabScaffold : StatefulWidget { |
|||
public CupertinoTabScaffold( |
|||
Key key = null, |
|||
CupertinoTabBar tabBar = null, |
|||
IndexedWidgetBuilder tabBuilder = null, |
|||
Color backgroundColor = null, |
|||
bool resizeToAvoidBottomInset = true |
|||
) : base(key: key) { |
|||
D.assert(tabBar != null); |
|||
D.assert(tabBuilder != null); |
|||
this.tabBar = tabBar; |
|||
this.tabBuilder = tabBuilder; |
|||
this.backgroundColor = backgroundColor; |
|||
this.resizeToAvoidBottomInset = resizeToAvoidBottomInset; |
|||
} |
|||
|
|||
|
|||
public readonly CupertinoTabBar tabBar; |
|||
|
|||
public readonly IndexedWidgetBuilder tabBuilder; |
|||
|
|||
public readonly Color backgroundColor; |
|||
|
|||
public readonly bool resizeToAvoidBottomInset; |
|||
|
|||
public override State createState() { |
|||
return new _CupertinoTabScaffoldState(); |
|||
} |
|||
} |
|||
|
|||
class _CupertinoTabScaffoldState : State<CupertinoTabScaffold> { |
|||
int _currentPage; |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
_currentPage = widget.tabBar.currentIndex; |
|||
|
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget _oldWidget) { |
|||
CupertinoTabScaffold oldWidget = _oldWidget as CupertinoTabScaffold; |
|||
base.didUpdateWidget(oldWidget); |
|||
if (_currentPage >= widget.tabBar.items.Count) { |
|||
_currentPage = widget.tabBar.items.Count - 1; |
|||
D.assert(_currentPage >= 0, |
|||
() => "CupertinoTabBar is expected to keep at least 2 tabs after updating" |
|||
); |
|||
} |
|||
|
|||
if (widget.tabBar.currentIndex != oldWidget.tabBar.currentIndex) { |
|||
_currentPage = widget.tabBar.currentIndex; |
|||
} |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
List<Widget> stacked = new List<Widget> { }; |
|||
|
|||
MediaQueryData existingMediaQuery = MediaQuery.of(context); |
|||
MediaQueryData newMediaQuery = MediaQuery.of(context); |
|||
|
|||
Widget content = new _TabSwitchingView( |
|||
currentTabIndex: _currentPage, |
|||
tabNumber: widget.tabBar.items.Count, |
|||
tabBuilder: widget.tabBuilder |
|||
); |
|||
EdgeInsets contentPadding = EdgeInsets.zero; |
|||
|
|||
if (widget.resizeToAvoidBottomInset) { |
|||
newMediaQuery = newMediaQuery.removeViewInsets(removeBottom: true); |
|||
contentPadding = EdgeInsets.only(bottom: existingMediaQuery.viewInsets.bottom); |
|||
} |
|||
|
|||
if (widget.tabBar != null && |
|||
(!widget.resizeToAvoidBottomInset || |
|||
widget.tabBar.preferredSize.height > existingMediaQuery.viewInsets.bottom)) { |
|||
float bottomPadding = widget.tabBar.preferredSize.height + existingMediaQuery.padding.bottom; |
|||
|
|||
if (widget.tabBar.opaque(context)) { |
|||
contentPadding = EdgeInsets.only(bottom: bottomPadding); |
|||
} |
|||
else { |
|||
newMediaQuery = newMediaQuery.copyWith( |
|||
padding: newMediaQuery.padding.copyWith( |
|||
bottom: bottomPadding |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
content = new MediaQuery( |
|||
data: newMediaQuery, |
|||
child: new Padding( |
|||
padding: contentPadding, |
|||
child: content |
|||
) |
|||
); |
|||
|
|||
stacked.Add(content); |
|||
|
|||
if (widget.tabBar != null) { |
|||
stacked.Add(new Align( |
|||
alignment: Alignment.bottomCenter, |
|||
child: widget.tabBar.copyWith( |
|||
currentIndex: _currentPage, |
|||
onTap: (int newIndex) => { |
|||
setState(() => { _currentPage = newIndex; }); |
|||
if (widget.tabBar.onTap != null) { |
|||
widget.tabBar.onTap(newIndex); |
|||
} |
|||
} |
|||
) |
|||
)); |
|||
} |
|||
|
|||
return new DecoratedBox( |
|||
decoration: new BoxDecoration( |
|||
color: widget.backgroundColor ?? CupertinoTheme.of(context).scaffoldBackgroundColor |
|||
), |
|||
child: new Stack( |
|||
children: stacked |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
class _TabSwitchingView : StatefulWidget { |
|||
public _TabSwitchingView( |
|||
int currentTabIndex, |
|||
int tabNumber, |
|||
IndexedWidgetBuilder tabBuilder |
|||
) { |
|||
D.assert(tabNumber > 0); |
|||
D.assert(tabBuilder != null); |
|||
this.currentTabIndex = currentTabIndex; |
|||
this.tabNumber = tabNumber; |
|||
this.tabBuilder = tabBuilder; |
|||
} |
|||
|
|||
public readonly int currentTabIndex; |
|||
public readonly int tabNumber; |
|||
public readonly IndexedWidgetBuilder tabBuilder; |
|||
|
|||
public override State createState() { |
|||
return new _TabSwitchingViewState(); |
|||
} |
|||
} |
|||
|
|||
class _TabSwitchingViewState : State<_TabSwitchingView> { |
|||
List<Widget> tabs; |
|||
List<FocusScopeNode> tabFocusNodes; |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
tabs = new List<Widget>(widget.tabNumber); |
|||
for (int i = 0; i < widget.tabNumber; i++) { |
|||
tabs.Add(null); |
|||
} |
|||
tabFocusNodes = Enumerable.Repeat(new FocusScopeNode(), widget.tabNumber).ToList(); |
|||
} |
|||
|
|||
public override void didChangeDependencies() { |
|||
base.didChangeDependencies(); |
|||
_focusActiveTab(); |
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget _oldWidget) { |
|||
_TabSwitchingView oldWidget = _oldWidget as _TabSwitchingView; |
|||
base.didUpdateWidget(oldWidget); |
|||
_focusActiveTab(); |
|||
} |
|||
|
|||
void _focusActiveTab() { |
|||
FocusScope.of(context).setFirstFocus(tabFocusNodes[widget.currentTabIndex]); |
|||
} |
|||
|
|||
public override void dispose() { |
|||
foreach (FocusScopeNode focusScopeNode in tabFocusNodes) { |
|||
focusScopeNode.detach(); |
|||
} |
|||
|
|||
base.dispose(); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
List<Widget> children = new List<Widget>(); |
|||
for (int index = 0; index < widget.tabNumber; index++) { |
|||
bool active = index == widget.currentTabIndex; |
|||
|
|||
var tabIndex = index; |
|||
if (active || tabs[index] != null) { |
|||
tabs[index] = widget.tabBuilder(context, tabIndex); |
|||
} |
|||
|
|||
children.Add(new Offstage( |
|||
offstage: !active, |
|||
child: new TickerMode( |
|||
enabled: active, |
|||
child: new FocusScope( |
|||
node: tabFocusNodes[index], |
|||
child: tabs[index] ?? new Container() |
|||
) |
|||
) |
|||
)); |
|||
} |
|||
|
|||
return new Stack( |
|||
fit: StackFit.expand, |
|||
children: children |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2cd55505780bfb04d86fe98f2c80b359 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
public class CupertinoTabView : StatefulWidget { |
|||
public CupertinoTabView( |
|||
Key key = null, |
|||
WidgetBuilder builder = null, |
|||
GlobalKey<NavigatorState> navigatorKey = null, |
|||
string defaultTitle = null, |
|||
Dictionary<string, WidgetBuilder> routes = null, |
|||
RouteFactory onGenerateRoute = null, |
|||
RouteFactory onUnknownRoute = null, |
|||
List<NavigatorObserver> navigatorObservers = null |
|||
) : base(key: key) { |
|||
this.builder = builder; |
|||
this.navigatorKey = navigatorKey; |
|||
this.defaultTitle = defaultTitle; |
|||
this.routes = routes; |
|||
this.onGenerateRoute = onGenerateRoute; |
|||
this.onUnknownRoute = onUnknownRoute; |
|||
this.navigatorObservers = navigatorObservers ?? new List<NavigatorObserver>(); |
|||
} |
|||
|
|||
public readonly WidgetBuilder builder; |
|||
|
|||
public readonly GlobalKey<NavigatorState> navigatorKey; |
|||
|
|||
public readonly string defaultTitle; |
|||
|
|||
public readonly Dictionary<string, WidgetBuilder> routes; |
|||
|
|||
public readonly RouteFactory onGenerateRoute; |
|||
|
|||
public readonly RouteFactory onUnknownRoute; |
|||
|
|||
public readonly List<NavigatorObserver> navigatorObservers; |
|||
|
|||
public override State createState() { |
|||
return new _CupertinoTabViewState(); |
|||
} |
|||
} |
|||
|
|||
class _CupertinoTabViewState : State<CupertinoTabView> { |
|||
HeroController _heroController; |
|||
List<NavigatorObserver> _navigatorObservers; |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
_heroController = CupertinoApp.createCupertinoHeroController(); |
|||
_updateObservers(); |
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget oldWidget) { |
|||
base.didUpdateWidget(oldWidget); |
|||
CupertinoTabView _oldWidget = (CupertinoTabView) oldWidget; |
|||
if (widget.navigatorKey != _oldWidget.navigatorKey |
|||
|| widget.navigatorObservers != _oldWidget.navigatorObservers) { |
|||
_updateObservers(); |
|||
} |
|||
} |
|||
|
|||
void _updateObservers() { |
|||
_navigatorObservers = |
|||
new List<NavigatorObserver>(widget.navigatorObservers); |
|||
_navigatorObservers.Add(_heroController); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new Navigator( |
|||
key: widget.navigatorKey, |
|||
onGenerateRoute: _onGenerateRoute, |
|||
onUnknownRoute: _onUnknownRoute, |
|||
observers: _navigatorObservers |
|||
); |
|||
} |
|||
|
|||
Route _onGenerateRoute(RouteSettings settings) { |
|||
string name = settings.name; |
|||
WidgetBuilder routeBuilder = null; |
|||
string title = null; |
|||
if (name == Navigator.defaultRouteName && widget.builder != null) { |
|||
routeBuilder = widget.builder; |
|||
title = widget.defaultTitle; |
|||
} |
|||
else if (widget.routes != null) { |
|||
routeBuilder = widget.routes[name]; |
|||
} |
|||
|
|||
if (routeBuilder != null) { |
|||
return new CupertinoPageRoute( |
|||
builder: routeBuilder, |
|||
title: title, |
|||
settings: settings |
|||
); |
|||
} |
|||
|
|||
if (widget.onGenerateRoute != null) { |
|||
return widget.onGenerateRoute(settings); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
Route _onUnknownRoute(RouteSettings settings) { |
|||
D.assert(() => { |
|||
if (widget.onUnknownRoute == null) { |
|||
throw new UIWidgetsError( |
|||
$"Could not find a generator for route {settings} in the {GetType()}.\n" + |
|||
"Generators for routes are searched for in the following order:\n" + |
|||
" 1. For the \"/\" route, the \"builder\" property, if non-null, is used.\n" + |
|||
" 2. Otherwise, the \"routes\" table is used, if it has an entry for " + |
|||
"the route.\n" + |
|||
" 3. Otherwise, onGenerateRoute is called. It should return a " + |
|||
"non-null value for any valid route not handled by \"builder\" and \"routes\".\n" + |
|||
" 4. Finally if all else fails onUnknownRoute is called.\n" + |
|||
"Unfortunately, onUnknownRoute was not set." |
|||
); |
|||
} |
|||
|
|||
return true; |
|||
}); |
|||
|
|||
Route result = widget.onUnknownRoute(settings); |
|||
D.assert(() => { |
|||
if (result == null) { |
|||
throw new UIWidgetsError( |
|||
"The onUnknownRoute callback returned null.\n" + |
|||
$"When the {GetType()} requested the route {settings} from its " + |
|||
"onUnknownRoute callback, the callback returned null. Such callbacks " + |
|||
"must never return null." |
|||
); |
|||
} |
|||
|
|||
return true; |
|||
}); |
|||
return result; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b95af00e8d4e2be499f76f5448914453 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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 StrutStyle = Unity.UIWidgets.painting.StrutStyle; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
class CupertinoTextFieldUtils { |
|||
public static readonly BorderSide _kDefaultRoundedBorderSide = new BorderSide( |
|||
color: CupertinoColors.lightBackgroundGray, |
|||
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( |
|||
border: _kDefaultRoundedBorder, |
|||
borderRadius: BorderRadius.all(Radius.circular(4.0f)) |
|||
); |
|||
|
|||
public static readonly Color _kSelectionHighlightColor = new Color(0x667FAACF); |
|||
|
|||
public static readonly Color _kInactiveTextColor = new Color(0xFFC2C2C2); |
|||
|
|||
public static readonly Color _kDisabledBackground = new Color(0xFFFAFAFA); |
|||
|
|||
public const int _iOSHorizontalCursorOffsetPixels = -2; |
|||
} |
|||
|
|||
public enum OverlayVisibilityMode { |
|||
never, |
|||
editing, |
|||
notEditing, |
|||
always |
|||
} |
|||
|
|||
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, |
|||
bool autofocus = false, |
|||
bool obscureText = false, |
|||
bool autocorrect = 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.Brightness? keyboardAppearance = null, |
|||
EdgeInsets scrollPadding = null, |
|||
DragStartBehavior dragStartBehavior = DragStartBehavior.start, |
|||
ScrollPhysics scrollPhysics = null) : base(key: key) { |
|||
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.w300, |
|||
color: CupertinoTextFieldUtils._kInactiveTextColor |
|||
); |
|||
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.autofocus = autofocus; |
|||
this.obscureText = obscureText; |
|||
this.autocorrect = autocorrect; |
|||
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.keyboardAppearance = keyboardAppearance; |
|||
this.scrollPadding = scrollPadding ?? EdgeInsets.all(20.0f); |
|||
this.dragStartBehavior = dragStartBehavior; |
|||
this.scrollPhysics = scrollPhysics; |
|||
this.keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline); |
|||
} |
|||
|
|||
public readonly TextEditingController controller; |
|||
|
|||
public readonly FocusNode focusNode; |
|||
|
|||
public readonly BoxDecoration decoration; |
|||
|
|||
public readonly EdgeInsets 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 ui.Brightness? keyboardAppearance; |
|||
|
|||
public readonly EdgeInsets scrollPadding; |
|||
|
|||
public readonly DragStartBehavior dragStartBehavior; |
|||
|
|||
public readonly ScrollPhysics scrollPhysics; |
|||
|
|||
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<EdgeInsets>("padding", padding)); |
|||
properties.add(new StringProperty("placeholder", placeholder)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("placeholderStyle", placeholderStyle)); |
|||
properties.add(new DiagnosticsProperty<OverlayVisibilityMode>("prefix", |
|||
prefix == null ? OverlayVisibilityMode.never : prefixMode)); |
|||
properties.add(new DiagnosticsProperty<OverlayVisibilityMode>("suffix", |
|||
suffix == null ? OverlayVisibilityMode.never : 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: false)); |
|||
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 DiagnosticsProperty<Color>("cursorColor", cursorColor, defaultValue: null)); |
|||
properties.add( |
|||
new DiagnosticsProperty<ScrollPhysics>("scrollPhysics", scrollPhysics, defaultValue: null)); |
|||
} |
|||
} |
|||
|
|||
class _CupertinoTextFieldState : AutomaticKeepAliveClientMixin<CupertinoTextField> { |
|||
GlobalKey<EditableTextState> _editableTextKey = GlobalKey<EditableTextState>.key(); |
|||
|
|||
TextEditingController _controller; |
|||
|
|||
TextEditingController _effectiveController { |
|||
get { return widget.controller ?? _controller; } |
|||
} |
|||
|
|||
FocusNode _focusNode; |
|||
|
|||
FocusNode _effectiveFocusNode { |
|||
get { return widget.focusNode ?? _focusNode ?? (_focusNode = new FocusNode()); } |
|||
} |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
if (widget.controller == null) { |
|||
_controller = new TextEditingController(); |
|||
_controller.addListener(updateKeepAlive); |
|||
} |
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget oldWidget) { |
|||
base.didUpdateWidget(oldWidget); |
|||
CupertinoTextField _oldWidget = (CupertinoTextField) oldWidget; |
|||
|
|||
if (widget.controller == null && _oldWidget.controller != null) { |
|||
_controller = TextEditingController.fromValue(_oldWidget.controller.value); |
|||
_controller.addListener(updateKeepAlive); |
|||
} |
|||
else if (widget.controller != null && _oldWidget.controller == null) { |
|||
_controller = null; |
|||
} |
|||
|
|||
bool isEnabled = widget.enabled ?? true; |
|||
bool wasEnabled = _oldWidget.enabled ?? true; |
|||
|
|||
if (wasEnabled && !isEnabled) { |
|||
_effectiveFocusNode.unfocus(); |
|||
} |
|||
} |
|||
|
|||
public override void dispose() { |
|||
_focusNode?.dispose(); |
|||
_controller?.removeListener(updateKeepAlive); |
|||
base.dispose(); |
|||
} |
|||
|
|||
void _requestKeyboard() { |
|||
_editableTextKey.currentState?.requestKeyboard(); |
|||
} |
|||
|
|||
RenderEditable _renderEditable { |
|||
get { return _editableTextKey.currentState.renderEditable; } |
|||
} |
|||
|
|||
void _handleTapDown(TapDownDetails details) { |
|||
_renderEditable.handleTapDown(details); |
|||
} |
|||
|
|||
|
|||
void _handleSingleTapUp(TapUpDetails details) { |
|||
_renderEditable.selectWordEdge(cause: SelectionChangedCause.tap); |
|||
_requestKeyboard(); |
|||
} |
|||
|
|||
void _handleSingleLongTapStart(LongPressStartDetails details) { |
|||
_renderEditable.selectPositionAt( |
|||
from: details.globalPosition, |
|||
cause: SelectionChangedCause.longPress |
|||
); |
|||
} |
|||
|
|||
void _handleSingleLongTapMoveUpdate(LongPressMoveUpdateDetails details) { |
|||
_renderEditable.selectPositionAt( |
|||
from: details.globalPosition, |
|||
cause: SelectionChangedCause.longPress |
|||
); |
|||
} |
|||
|
|||
void _handleSingleLongTapEnd(LongPressEndDetails details) { |
|||
_editableTextKey.currentState.showToolbar(); |
|||
} |
|||
|
|||
void _handleDoubleTapDown(TapDownDetails details) { |
|||
_renderEditable.selectWord(cause: SelectionChangedCause.tap); |
|||
_editableTextKey.currentState.showToolbar(); |
|||
} |
|||
|
|||
void _handleMouseDragSelectionStart(DragStartDetails details) { |
|||
_renderEditable.selectPositionAt( |
|||
from: details.globalPosition, |
|||
cause: SelectionChangedCause.drag |
|||
); |
|||
} |
|||
|
|||
void _handleMouseDragSelectionUpdate( |
|||
DragStartDetails startDetails, |
|||
DragUpdateDetails updateDetails |
|||
) { |
|||
_renderEditable.selectPositionAt( |
|||
from: startDetails.globalPosition, |
|||
to: updateDetails.globalPosition, |
|||
cause: SelectionChangedCause.drag |
|||
); |
|||
} |
|||
|
|||
void _handleMouseDragSelectionEnd(DragEndDetails details) { |
|||
_requestKeyboard(); |
|||
} |
|||
|
|||
void _handleSelectionChanged(TextSelection selection, SelectionChangedCause cause) { |
|||
if (cause == SelectionChangedCause.longPress) { |
|||
_editableTextKey.currentState?.bringIntoView(selection.basePos); |
|||
} |
|||
} |
|||
|
|||
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() |
|||
); |
|||
} |
|||
|
|||
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 Padding( |
|||
padding: widget.padding, |
|||
child: new Text( |
|||
widget.placeholder, |
|||
maxLines: 1, |
|||
overflow: TextOverflow.ellipsis, |
|||
style: placeholderStyle |
|||
) |
|||
) |
|||
); |
|||
} |
|||
|
|||
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: CupertinoTextFieldUtils._kInactiveTextColor |
|||
) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
|
|||
return new Row(children: rowChildren); |
|||
} |
|||
); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
base.build(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 textStyle = themeData.textTheme.textStyle.merge(widget.style); |
|||
TextStyle placeholderStyle = textStyle.merge(widget.placeholderStyle); |
|||
ui.Brightness keyboardAppearance = widget.keyboardAppearance ?? themeData.brightness; |
|||
Color cursorColor = widget.cursorColor ?? themeData.primaryColor; |
|||
|
|||
Widget paddedEditable = new Padding( |
|||
padding: widget.padding, |
|||
child: new RepaintBoundary( |
|||
child: new EditableText( |
|||
key: _editableTextKey, |
|||
controller: controller, |
|||
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, |
|||
maxLines: widget.maxLines, |
|||
minLines: widget.minLines, |
|||
expands: widget.expands, |
|||
selectionColor: CupertinoTextFieldUtils._kSelectionHighlightColor, |
|||
selectionControls: CupertinoTextSelectionUtils.cupertinoTextSelectionControls, |
|||
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: CupertinoColors.inactiveGray, |
|||
scrollPadding: widget.scrollPadding, |
|||
keyboardAppearance: keyboardAppearance, |
|||
dragStartBehavior: widget.dragStartBehavior, |
|||
scrollPhysics: widget.scrollPhysics |
|||
) |
|||
) |
|||
); |
|||
|
|||
return new IgnorePointer( |
|||
ignoring: !enabled, |
|||
child: new Container( |
|||
decoration: widget.decoration, |
|||
child: new Container( |
|||
color: enabled |
|||
? null |
|||
: CupertinoTheme.of(context).brightness == ui.Brightness.light |
|||
? CupertinoTextFieldUtils._kDisabledBackground |
|||
: CupertinoColors.darkBackgroundGray, |
|||
child: new TextSelectionGestureDetector( |
|||
onTapDown: _handleTapDown, |
|||
onSingleTapUp: _handleSingleTapUp, |
|||
onSingleLongTapStart: _handleSingleLongTapStart, |
|||
onSingleLongTapMoveUpdate: _handleSingleLongTapMoveUpdate, |
|||
onSingleLongTapEnd: _handleSingleLongTapEnd, |
|||
onDoubleTapDown: _handleDoubleTapDown, |
|||
onDragSelectionStart: _handleMouseDragSelectionStart, |
|||
onDragSelectionUpdate: _handleMouseDragSelectionUpdate, |
|||
onDragSelectionEnd: _handleMouseDragSelectionEnd, |
|||
behavior: HitTestBehavior.translucent, |
|||
child: _addTextDependentAttachments(paddedEditable, textStyle, placeholderStyle) |
|||
) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7d2dd8bd369e9e044a2480212136f639 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
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 Canvas = Unity.UIWidgets.ui.Canvas; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
using Rect = Unity.UIWidgets.ui.Rect; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
using Transform = Unity.UIWidgets.widgets.Transform; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
public static class CupertinoTextSelectionUtils { |
|||
public static readonly TextSelectionControls cupertinoTextSelectionControls = new _CupertinoTextSelectionControls(); |
|||
|
|||
public const float _kHandlesPadding = 18.0f; |
|||
|
|||
public const float _kToolbarScreenPadding = 8.0f; |
|||
|
|||
public const float _kToolbarHeight = 36.0f; |
|||
|
|||
public static readonly Color _kToolbarBackgroundColor = new Color(0xFF2E2E2E); |
|||
|
|||
public static readonly Color _kToolbarDividerColor = new Color(0xFFB9B9B9); |
|||
|
|||
public static readonly Color _kHandlesColor = new Color(0xFF136FE0); |
|||
|
|||
public static readonly Size _kSelectionOffset = new Size(20.0f, 30.0f); |
|||
|
|||
public static readonly Size _kToolbarTriangleSize = new Size(18.0f, 9.0f); |
|||
|
|||
public static readonly EdgeInsets _kToolbarButtonPadding = |
|||
EdgeInsets.symmetric(vertical: 10.0f, horizontal: 18.0f); |
|||
|
|||
public static readonly BorderRadius _kToolbarBorderRadius = BorderRadius.all(Radius.circular(7.5f)); |
|||
|
|||
public static readonly TextStyle _kToolbarButtonFontStyle = new TextStyle( |
|||
fontSize: 14.0f, |
|||
letterSpacing: -0.11f, |
|||
fontWeight: FontWeight.w300, |
|||
color: CupertinoColors.white |
|||
); |
|||
} |
|||
|
|||
class _TextSelectionToolbarNotchPainter : AbstractCustomPainter { |
|||
public override void paint(Canvas canvas, Size size) { |
|||
Paint paint = new Paint(); |
|||
paint.color = CupertinoTextSelectionUtils._kToolbarBackgroundColor; |
|||
paint.style = PaintingStyle.fill; |
|||
|
|||
Path triangle = new Path(); |
|||
triangle.lineTo(CupertinoTextSelectionUtils._kToolbarTriangleSize.width / 2, 0.0f); |
|||
triangle.lineTo(0.0f, CupertinoTextSelectionUtils._kToolbarTriangleSize.height); |
|||
triangle.lineTo(-(CupertinoTextSelectionUtils._kToolbarTriangleSize.width / 2), 0.0f); |
|||
triangle.close(); |
|||
canvas.drawPath(triangle, paint); |
|||
} |
|||
|
|||
public override bool shouldRepaint(CustomPainter oldPainter) { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
class _TextSelectionToolbar : StatelessWidget { |
|||
public _TextSelectionToolbar( |
|||
Key key = null, |
|||
VoidCallback handleCut = null, |
|||
VoidCallback handleCopy = null, |
|||
VoidCallback handlePaste = null, |
|||
VoidCallback handleSelectAll = null |
|||
) : base(key: key) { |
|||
this.handleCut = handleCut; |
|||
this.handleCopy = handleCopy; |
|||
this.handlePaste = handlePaste; |
|||
this.handleSelectAll = handleSelectAll; |
|||
} |
|||
|
|||
readonly VoidCallback handleCut; |
|||
|
|||
readonly VoidCallback handleCopy; |
|||
|
|||
readonly VoidCallback handlePaste; |
|||
|
|||
readonly VoidCallback handleSelectAll; |
|||
|
|||
|
|||
public override Widget build(BuildContext context) { |
|||
List<Widget> items = new List<Widget>(); |
|||
Widget onePhysicalPixelVerticalDivider = |
|||
new SizedBox(width: 1.0f / MediaQuery.of(context).devicePixelRatio); |
|||
CupertinoLocalizations localizations = CupertinoLocalizations.of(context); |
|||
|
|||
if (handleCut != null) { |
|||
items.Add(_buildToolbarButton(localizations.cutButtonLabel, handleCut)); |
|||
} |
|||
|
|||
if (handleCopy != null) { |
|||
if (items.isNotEmpty()) { |
|||
items.Add(onePhysicalPixelVerticalDivider); |
|||
} |
|||
|
|||
items.Add(_buildToolbarButton(localizations.copyButtonLabel, handleCopy)); |
|||
} |
|||
|
|||
if (handlePaste != null) { |
|||
if (items.isNotEmpty()) { |
|||
items.Add(onePhysicalPixelVerticalDivider); |
|||
} |
|||
|
|||
items.Add(_buildToolbarButton(localizations.pasteButtonLabel, handlePaste)); |
|||
} |
|||
|
|||
if (handleSelectAll != null) { |
|||
if (items.isNotEmpty()) { |
|||
items.Add(onePhysicalPixelVerticalDivider); |
|||
} |
|||
|
|||
items.Add(_buildToolbarButton(localizations.selectAllButtonLabel, handleSelectAll)); |
|||
} |
|||
|
|||
Widget triangle = SizedBox.fromSize( |
|||
size: CupertinoTextSelectionUtils._kToolbarTriangleSize, |
|||
child: new CustomPaint( |
|||
painter: new _TextSelectionToolbarNotchPainter() |
|||
) |
|||
); |
|||
|
|||
return new Column( |
|||
mainAxisSize: MainAxisSize.min, |
|||
children: new List<Widget> { |
|||
new ClipRRect( |
|||
borderRadius: CupertinoTextSelectionUtils._kToolbarBorderRadius, |
|||
child: new DecoratedBox( |
|||
decoration: new BoxDecoration( |
|||
color: CupertinoTextSelectionUtils._kToolbarDividerColor, |
|||
borderRadius: CupertinoTextSelectionUtils._kToolbarBorderRadius, |
|||
border: Border.all(color: CupertinoTextSelectionUtils._kToolbarBackgroundColor, |
|||
width: 0) |
|||
), |
|||
child: new Row(mainAxisSize: MainAxisSize.min, children: items) |
|||
) |
|||
), |
|||
triangle, |
|||
new Padding(padding: EdgeInsets.only(bottom: 10.0f)) |
|||
} |
|||
); |
|||
} |
|||
|
|||
CupertinoButton _buildToolbarButton(string text, VoidCallback onPressed) { |
|||
return new CupertinoButton( |
|||
child: new Text(text, style: CupertinoTextSelectionUtils._kToolbarButtonFontStyle), |
|||
color: CupertinoTextSelectionUtils._kToolbarBackgroundColor, |
|||
minSize: CupertinoTextSelectionUtils._kToolbarHeight, |
|||
padding: CupertinoTextSelectionUtils._kToolbarButtonPadding, |
|||
borderRadius: null, |
|||
pressedOpacity: 0.7f, |
|||
onPressed: onPressed |
|||
); |
|||
} |
|||
} |
|||
|
|||
class _TextSelectionToolbarLayout : SingleChildLayoutDelegate { |
|||
public _TextSelectionToolbarLayout( |
|||
Size screenSize, |
|||
Rect globalEditableRegion, |
|||
Offset position) { |
|||
this.screenSize = screenSize; |
|||
this.globalEditableRegion = globalEditableRegion; |
|||
this.position = position; |
|||
} |
|||
|
|||
readonly Size screenSize; |
|||
|
|||
readonly Rect globalEditableRegion; |
|||
|
|||
readonly Offset position; |
|||
|
|||
public override BoxConstraints getConstraintsForChild(BoxConstraints constraints) { |
|||
return constraints.loosen(); |
|||
} |
|||
|
|||
public override Offset getPositionForChild(Size size, Size childSize) { |
|||
Offset globalPosition = globalEditableRegion.topLeft + position; |
|||
|
|||
float x = globalPosition.dx - childSize.width / 2.0f; |
|||
float y = globalPosition.dy - childSize.height; |
|||
|
|||
if (x < CupertinoTextSelectionUtils._kToolbarScreenPadding) { |
|||
x = CupertinoTextSelectionUtils._kToolbarScreenPadding; |
|||
} |
|||
else if (x + childSize.width > screenSize.width - CupertinoTextSelectionUtils._kToolbarScreenPadding) { |
|||
x = screenSize.width - childSize.width - CupertinoTextSelectionUtils._kToolbarScreenPadding; |
|||
} |
|||
|
|||
if (y < CupertinoTextSelectionUtils._kToolbarScreenPadding) { |
|||
y = CupertinoTextSelectionUtils._kToolbarScreenPadding; |
|||
} |
|||
else if (y + childSize.height > |
|||
screenSize.height - CupertinoTextSelectionUtils._kToolbarScreenPadding) { |
|||
y = screenSize.height - childSize.height - CupertinoTextSelectionUtils._kToolbarScreenPadding; |
|||
} |
|||
|
|||
return new Offset(x, y); |
|||
} |
|||
|
|||
public override bool shouldRelayout(SingleChildLayoutDelegate oldDelegate) { |
|||
_TextSelectionToolbarLayout _oldDelegate = (_TextSelectionToolbarLayout) oldDelegate; |
|||
return screenSize != _oldDelegate.screenSize |
|||
|| globalEditableRegion != _oldDelegate.globalEditableRegion |
|||
|| position != _oldDelegate.position; |
|||
} |
|||
} |
|||
|
|||
class _TextSelectionHandlePainter : AbstractCustomPainter { |
|||
public _TextSelectionHandlePainter(Offset origin) { |
|||
this.origin = origin; |
|||
} |
|||
|
|||
readonly Offset origin; |
|||
|
|||
|
|||
public override void paint(Canvas canvas, Size size) { |
|||
Paint paint = new Paint(); |
|||
paint.color = CupertinoTextSelectionUtils._kHandlesColor; |
|||
paint.strokeWidth = 2.0f; |
|||
|
|||
canvas.drawCircle(origin.translate(0.0f, 4.0f), 5.5f, paint); |
|||
canvas.drawLine( |
|||
origin, |
|||
origin.translate( |
|||
0.0f, |
|||
-(size.height - 2.0f * CupertinoTextSelectionUtils._kHandlesPadding) |
|||
), |
|||
paint |
|||
); |
|||
} |
|||
|
|||
public override bool shouldRepaint(CustomPainter oldPainter) { |
|||
_TextSelectionHandlePainter _oldPainter = (_TextSelectionHandlePainter) oldPainter; |
|||
return origin != _oldPainter.origin; |
|||
} |
|||
} |
|||
|
|||
class _CupertinoTextSelectionControls : TextSelectionControls { |
|||
public override Size handleSize { |
|||
get { return CupertinoTextSelectionUtils._kSelectionOffset; } |
|||
} |
|||
|
|||
public override Widget buildToolbar(BuildContext context, Rect globalEditableRegion, Offset position, |
|||
TextSelectionDelegate del) { |
|||
D.assert(WidgetsD.debugCheckHasMediaQuery(context)); |
|||
return new ConstrainedBox( |
|||
constraints: BoxConstraints.tight(globalEditableRegion.size), |
|||
child: new CustomSingleChildLayout( |
|||
layoutDelegate: new _TextSelectionToolbarLayout( |
|||
MediaQuery.of(context).size, |
|||
globalEditableRegion, |
|||
position |
|||
), |
|||
child: new _TextSelectionToolbar( |
|||
handleCut: canCut(del) ? () => handleCut(del) : (VoidCallback) null, |
|||
handleCopy: canCopy(del) ? () => handleCopy(del) : (VoidCallback) null, |
|||
handlePaste: canPaste(del) ? () => handlePaste(del) : (VoidCallback) null, |
|||
handleSelectAll: canSelectAll(del) ? () => handleSelectAll(del) : (VoidCallback) null |
|||
) |
|||
) |
|||
); |
|||
} |
|||
|
|||
|
|||
public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight) { |
|||
Size desiredSize = new Size( |
|||
2.0f * CupertinoTextSelectionUtils._kHandlesPadding, |
|||
textLineHeight + 2.0f * CupertinoTextSelectionUtils._kHandlesPadding |
|||
); |
|||
|
|||
Widget handle = SizedBox.fromSize( |
|||
size: desiredSize, |
|||
child: new CustomPaint( |
|||
painter: new _TextSelectionHandlePainter( |
|||
origin: new Offset(CupertinoTextSelectionUtils._kHandlesPadding, |
|||
textLineHeight + CupertinoTextSelectionUtils._kHandlesPadding) |
|||
) |
|||
) |
|||
); |
|||
|
|||
switch (type) { |
|||
case TextSelectionHandleType.left: |
|||
Matrix4 matrix = new Matrix4().rotationZ(Mathf.PI); |
|||
matrix.translate(-CupertinoTextSelectionUtils._kHandlesPadding, |
|||
-CupertinoTextSelectionUtils._kHandlesPadding); |
|||
|
|||
return new Transform( |
|||
transform: matrix, |
|||
child: handle |
|||
); |
|||
case TextSelectionHandleType.right: |
|||
return new Transform( |
|||
transform:new Matrix4().translationValues( |
|||
-CupertinoTextSelectionUtils._kHandlesPadding, |
|||
-(textLineHeight + CupertinoTextSelectionUtils._kHandlesPadding), |
|||
0 |
|||
), |
|||
child: handle |
|||
); |
|||
case TextSelectionHandleType.collapsed: |
|||
return new Container(); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8f420271876af9a49b7c8e1faa3dff17 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Brightness = Unity.UIWidgets.ui.Brightness; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
static class CupertinoTextThemeDataUtils { |
|||
public static readonly TextStyle _kDefaultLightTextStyle = new TextStyle( |
|||
inherit: false, |
|||
fontFamily: ".SF Pro Text", |
|||
fontSize: 17.0f, |
|||
letterSpacing: -0.41f, |
|||
color: CupertinoColors.black, |
|||
decoration: TextDecoration.none |
|||
); |
|||
|
|||
public static readonly TextStyle _kDefaultDarkTextStyle = new TextStyle( |
|||
inherit: false, |
|||
fontFamily: ".SF Pro Text", |
|||
fontSize: 17.0f, |
|||
letterSpacing: -0.41f, |
|||
color: CupertinoColors.white, |
|||
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 _kDefaultMiddleTitleLightTextStyle = new TextStyle( |
|||
inherit: false, |
|||
fontFamily: ".SF Pro Text", |
|||
fontSize: 17.0f, |
|||
fontWeight: FontWeight.w600, |
|||
letterSpacing: -0.41f, |
|||
color: CupertinoColors.black |
|||
); |
|||
|
|||
public static readonly TextStyle _kDefaultMiddleTitleDarkTextStyle = new TextStyle( |
|||
inherit: false, |
|||
fontFamily: ".SF Pro Text", |
|||
fontSize: 17.0f, |
|||
fontWeight: FontWeight.w600, |
|||
letterSpacing: -0.41f, |
|||
color: CupertinoColors.white |
|||
); |
|||
|
|||
public static readonly TextStyle _kDefaultLargeTitleLightTextStyle = new TextStyle( |
|||
inherit: false, |
|||
fontFamily: ".SF Pro Display", |
|||
fontSize: 34.0f, |
|||
fontWeight: FontWeight.w700, |
|||
letterSpacing: 0.41f, |
|||
color: CupertinoColors.black |
|||
); |
|||
|
|||
public static readonly TextStyle _kDefaultLargeTitleDarkTextStyle = new TextStyle( |
|||
inherit: false, |
|||
fontFamily: ".SF Pro Display", |
|||
fontSize: 34.0f, |
|||
fontWeight: FontWeight.w700, |
|||
letterSpacing: 0.41f, |
|||
color: CupertinoColors.white |
|||
); |
|||
} |
|||
|
|||
|
|||
public class CupertinoTextThemeData : Diagnosticable { |
|||
public CupertinoTextThemeData( |
|||
Color primaryColor = null, |
|||
Brightness? brightness = null, |
|||
TextStyle textStyle = null, |
|||
TextStyle actionTextStyle = null, |
|||
TextStyle tabLabelTextStyle = null, |
|||
TextStyle navTitleTextStyle = null, |
|||
TextStyle navLargeTitleTextStyle = null, |
|||
TextStyle navActionTextStyle = null |
|||
) { |
|||
_primaryColor = primaryColor ?? CupertinoColors.activeBlue; |
|||
_brightness = brightness; |
|||
_textStyle = textStyle; |
|||
_actionTextStyle = actionTextStyle; |
|||
_tabLabelTextStyle = tabLabelTextStyle; |
|||
_navTitleTextStyle = navTitleTextStyle; |
|||
_navLargeTitleTextStyle = navLargeTitleTextStyle; |
|||
_navActionTextStyle = navActionTextStyle; |
|||
} |
|||
|
|||
readonly Color _primaryColor; |
|||
readonly Brightness? _brightness; |
|||
|
|||
bool _isLight { |
|||
get { return _brightness != Brightness.dark; } |
|||
} |
|||
|
|||
readonly TextStyle _textStyle; |
|||
|
|||
public TextStyle textStyle { |
|||
get { |
|||
return _textStyle ?? (_isLight |
|||
? CupertinoTextThemeDataUtils._kDefaultLightTextStyle |
|||
: CupertinoTextThemeDataUtils._kDefaultDarkTextStyle); |
|||
} |
|||
} |
|||
|
|||
readonly TextStyle _actionTextStyle; |
|||
|
|||
public TextStyle actionTextStyle { |
|||
get { |
|||
return _actionTextStyle ?? CupertinoTextThemeDataUtils._kDefaultActionTextStyle.copyWith( |
|||
color: _primaryColor |
|||
); |
|||
} |
|||
} |
|||
|
|||
readonly TextStyle _tabLabelTextStyle; |
|||
|
|||
public TextStyle tabLabelTextStyle { |
|||
get { return _tabLabelTextStyle ?? CupertinoTextThemeDataUtils._kDefaultTabLabelTextStyle; } |
|||
} |
|||
|
|||
readonly TextStyle _navTitleTextStyle; |
|||
|
|||
public TextStyle navTitleTextStyle { |
|||
get { |
|||
return _navTitleTextStyle ?? |
|||
(_isLight |
|||
? CupertinoTextThemeDataUtils._kDefaultMiddleTitleLightTextStyle |
|||
: CupertinoTextThemeDataUtils._kDefaultMiddleTitleDarkTextStyle); |
|||
} |
|||
} |
|||
|
|||
readonly TextStyle _navLargeTitleTextStyle; |
|||
|
|||
/// Typography of large titles in sliver navigation bars.
|
|||
public TextStyle navLargeTitleTextStyle { |
|||
get { |
|||
return _navLargeTitleTextStyle ?? |
|||
(_isLight |
|||
? CupertinoTextThemeDataUtils._kDefaultLargeTitleLightTextStyle |
|||
: CupertinoTextThemeDataUtils._kDefaultLargeTitleDarkTextStyle); |
|||
} |
|||
} |
|||
|
|||
readonly TextStyle _navActionTextStyle; |
|||
|
|||
public TextStyle navActionTextStyle { |
|||
get { |
|||
return _navActionTextStyle ?? CupertinoTextThemeDataUtils._kDefaultActionTextStyle.copyWith( |
|||
color: _primaryColor |
|||
); |
|||
} |
|||
} |
|||
|
|||
public CupertinoTextThemeData copyWith( |
|||
Color primaryColor, |
|||
Brightness? brightness, |
|||
TextStyle textStyle, |
|||
TextStyle actionTextStyle, |
|||
TextStyle tabLabelTextStyle, |
|||
TextStyle navTitleTextStyle, |
|||
TextStyle navLargeTitleTextStyle, |
|||
TextStyle navActionTextStyle |
|||
) { |
|||
return new CupertinoTextThemeData( |
|||
primaryColor: primaryColor ?? _primaryColor, |
|||
brightness: brightness ?? _brightness, |
|||
textStyle: textStyle ?? _textStyle, |
|||
actionTextStyle: actionTextStyle ?? _actionTextStyle, |
|||
tabLabelTextStyle: tabLabelTextStyle ?? _tabLabelTextStyle, |
|||
navTitleTextStyle: navTitleTextStyle ?? _navTitleTextStyle, |
|||
navLargeTitleTextStyle: navLargeTitleTextStyle ?? _navLargeTitleTextStyle, |
|||
navActionTextStyle: navActionTextStyle ?? _navActionTextStyle |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c7d45005fd9f6034c8dabd6d98cab122 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using Brightness = Unity.UIWidgets.ui.Brightness; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
static class CupertinoThemeDataUtils { |
|||
public static readonly Color _kDefaultBarLightBackgroundColor = new Color(0xCCF8F8F8); |
|||
public static readonly Color _kDefaultBarDarkBackgroundColor = new Color(0xB7212121); |
|||
} |
|||
|
|||
public class CupertinoTheme : StatelessWidget { |
|||
public CupertinoTheme( |
|||
CupertinoThemeData data, |
|||
Widget child, |
|||
Key key = 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 = |
|||
(_InheritedCupertinoTheme) context.inheritFromWidgetOfExactType(typeof(_InheritedCupertinoTheme)); |
|||
return inheritedTheme?.theme?.data ?? new CupertinoThemeData(); |
|||
} |
|||
|
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new _InheritedCupertinoTheme( |
|||
theme: this, |
|||
child: new IconTheme( |
|||
data: new IconThemeData(color: data.primaryColor), |
|||
child: child |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
class _InheritedCupertinoTheme : InheritedWidget { |
|||
public _InheritedCupertinoTheme( |
|||
CupertinoTheme theme, |
|||
Widget child, |
|||
Key key = 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 |
|||
) { |
|||
_brightness = brightness; |
|||
_primaryColor = primaryColor; |
|||
_primaryContrastingColor = primaryContrastingColor; |
|||
_textTheme = textTheme; |
|||
_barBackgroundColor = barBackgroundColor; |
|||
_scaffoldBackgroundColor = scaffoldBackgroundColor; |
|||
} |
|||
|
|||
public static CupertinoThemeData raw( |
|||
Brightness? brightness = null, |
|||
Color primaryColor = null, |
|||
Color primaryContrastingColor = null, |
|||
CupertinoTextThemeData textTheme = null, |
|||
Color barBackgroundColor = null, |
|||
Color scaffoldBackgroundColor = null |
|||
) { |
|||
D.assert(brightness != null); |
|||
D.assert(primaryColor != null); |
|||
D.assert(primaryContrastingColor != null); |
|||
D.assert(textTheme != null); |
|||
D.assert(barBackgroundColor != null); |
|||
D.assert(scaffoldBackgroundColor != null); |
|||
return new CupertinoThemeData( |
|||
brightness: brightness, |
|||
primaryColor: primaryColor, |
|||
primaryContrastingColor: primaryContrastingColor, |
|||
textTheme: textTheme, |
|||
barBackgroundColor: barBackgroundColor, |
|||
scaffoldBackgroundColor: scaffoldBackgroundColor |
|||
); |
|||
} |
|||
|
|||
bool _isLight { |
|||
get { return brightness == Brightness.light; } |
|||
} |
|||
|
|||
public Brightness brightness { |
|||
get { return _brightness ?? Brightness.light; } |
|||
} |
|||
|
|||
readonly Brightness? _brightness; |
|||
|
|||
public Color primaryColor { |
|||
get { |
|||
return _primaryColor ?? |
|||
(_isLight ? CupertinoColors.activeBlue : CupertinoColors.activeOrange); |
|||
} |
|||
} |
|||
|
|||
readonly Color _primaryColor; |
|||
|
|||
public Color primaryContrastingColor { |
|||
get { |
|||
return _primaryContrastingColor ?? |
|||
(_isLight ? CupertinoColors.white : CupertinoColors.black); |
|||
} |
|||
} |
|||
|
|||
readonly Color _primaryContrastingColor; |
|||
|
|||
public CupertinoTextThemeData textTheme { |
|||
get { |
|||
return _textTheme ?? new CupertinoTextThemeData( |
|||
brightness: brightness, |
|||
primaryColor: primaryColor |
|||
); |
|||
} |
|||
} |
|||
|
|||
readonly CupertinoTextThemeData _textTheme; |
|||
|
|||
public Color barBackgroundColor { |
|||
get { |
|||
return _barBackgroundColor ?? |
|||
(_isLight |
|||
? CupertinoThemeDataUtils._kDefaultBarLightBackgroundColor |
|||
: CupertinoThemeDataUtils._kDefaultBarDarkBackgroundColor); |
|||
} |
|||
} |
|||
|
|||
readonly Color _barBackgroundColor; |
|||
|
|||
public Color scaffoldBackgroundColor { |
|||
get { |
|||
return _scaffoldBackgroundColor ?? |
|||
(_isLight ? CupertinoColors.white : CupertinoColors.black); |
|||
} |
|||
} |
|||
|
|||
readonly Color _scaffoldBackgroundColor; |
|||
|
|||
public CupertinoThemeData noDefault() { |
|||
return new _NoDefaultCupertinoThemeData( |
|||
_brightness, |
|||
_primaryColor, |
|||
_primaryContrastingColor, |
|||
_textTheme, |
|||
_barBackgroundColor, |
|||
_scaffoldBackgroundColor |
|||
); |
|||
} |
|||
|
|||
public CupertinoThemeData copyWith( |
|||
Brightness? brightness = null, |
|||
Color primaryColor = null, |
|||
Color primaryContrastingColor = null, |
|||
CupertinoTextThemeData textTheme = null, |
|||
Color barBackgroundColor = null, |
|||
Color scaffoldBackgroundColor = null |
|||
) { |
|||
return new CupertinoThemeData( |
|||
brightness: brightness ?? _brightness, |
|||
primaryColor: primaryColor ?? _primaryColor, |
|||
primaryContrastingColor: primaryContrastingColor ?? _primaryContrastingColor, |
|||
textTheme: textTheme ?? _textTheme, |
|||
barBackgroundColor: barBackgroundColor ?? _barBackgroundColor, |
|||
scaffoldBackgroundColor: scaffoldBackgroundColor ?? _scaffoldBackgroundColor |
|||
); |
|||
} |
|||
|
|||
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)); |
|||
} |
|||
} |
|||
|
|||
class _NoDefaultCupertinoThemeData : CupertinoThemeData { |
|||
public _NoDefaultCupertinoThemeData( |
|||
Brightness? brightness, |
|||
Color primaryColor, |
|||
Color primaryContrastingColor, |
|||
CupertinoTextThemeData textTheme, |
|||
Color barBackgroundColor, |
|||
Color scaffoldBackgroundColor |
|||
) { |
|||
this.brightness = brightness; |
|||
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; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0b560c283dac79b49a529c6917cf840c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.cupertino { |
|||
public class CupertinoThumbPainter { |
|||
public CupertinoThumbPainter( |
|||
Color color = null, |
|||
Color shadowColor = null |
|||
) { |
|||
_shadowPaint = new BoxShadow( |
|||
color: shadowColor, |
|||
blurRadius: 1.0f |
|||
).toPaint(); |
|||
|
|||
this.color = color ?? CupertinoColors.white; |
|||
this.shadowColor = shadowColor ?? new Color(0x2C000000); |
|||
} |
|||
|
|||
public readonly Color color; |
|||
|
|||
public readonly Color shadowColor; |
|||
|
|||
public readonly Paint _shadowPaint; |
|||
|
|||
public const float radius = 14.0f; |
|||
|
|||
public const float extension = 7.0f; |
|||
|
|||
public void paint(Canvas canvas, Rect rect) { |
|||
RRect rrect = RRect.fromRectAndRadius( |
|||
rect, |
|||
Radius.circular(rect.shortestSide / 2.0f) |
|||
); |
|||
|
|||
canvas.drawRRect(rrect, _shadowPaint); |
|||
canvas.drawRRect(rrect.shift(new Offset(0.0f, 3.0f)), _shadowPaint); |
|||
var _paint = new Paint(); |
|||
_paint.color = color; |
|||
canvas.drawRRect(rrect, _paint); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a3bf47fd342929d4aabe1bd72fc22eb0 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 7d3f82c412afe4d419f727fcdca86158 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ab11c80750d2b144daf3455bc8ff7b19 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue