Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lindexi_gd
Uno
提交
e8ad72bf
U
Uno
项目概览
lindexi_gd
/
Uno
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
Uno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e8ad72bf
编写于
4月 26, 2023
作者:
X
Xiaotian Gu
提交者:
GitHub
4月 26, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12054 from unoplatform/dev/xygu/20230418/toggleswitch
上级
d0c4c526
101606e2
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
619 addition
and
10 deletion
+619
-10
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Animation/Given_DoubleAnimationUsingKeyFrames.cs
...ml_Media_Animation/Given_DoubleAnimationUsingKeyFrames.cs
+53
-0
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Animation/TestPages/QuickMultiTransitionsPage.xaml
..._Media_Animation/TestPages/QuickMultiTransitionsPage.xaml
+502
-0
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Animation/TestPages/QuickMultiTransitionsPage.xaml.cs
...dia_Animation/TestPages/QuickMultiTransitionsPage.xaml.cs
+32
-0
src/Uno.UI/UI/Xaml/Media/Animation/ColorAnimationUsingKeyFrames.cs
...I/UI/Xaml/Media/Animation/ColorAnimationUsingKeyFrames.cs
+14
-4
src/Uno.UI/UI/Xaml/Media/Animation/DoubleAnimationUsingKeyFrames.cs
.../UI/Xaml/Media/Animation/DoubleAnimationUsingKeyFrames.cs
+15
-4
src/Uno.UI/UI/Xaml/Media/Animation/ObjectAnimationUsingKeyFrames.cs
.../UI/Xaml/Media/Animation/ObjectAnimationUsingKeyFrames.cs
+2
-2
src/Uno.UI/UI/Xaml/Media/Animation/Storyboard.cs
src/Uno.UI/UI/Xaml/Media/Animation/Storyboard.cs
+1
-0
未找到文件。
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Animation/Given_DoubleAnimationUsingKeyFrames.cs
0 → 100644
浏览文件 @
e8ad72bf
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
Uno.UI.RuntimeTests.Helpers
;
using
Windows.UI
;
using
Windows.UI.Xaml
;
using
Windows.UI.Xaml.Controls
;
using
Windows.UI.Xaml.Media
;
using
Windows.UI.Xaml.Shapes
;
using
static
Private
.
Infrastructure
.
TestServices
;
namespace
Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Media_Animation
;
[
TestClass
]
[
RunsOnUIThread
]
public
class
Given_DoubleAnimationUsingKeyFrames
{
[
TestMethod
]
public
async
Task
When_Quickly_Transitions
()
{
// We are mimicking Fluent-style ToggleSwitch's ToggleStates here.
var
sut
=
new
TestPages
.
QuickMultiTransitionsPage
();
WindowHelper
.
WindowContent
=
sut
;
await
WindowHelper
.
WaitForLoaded
(
sut
);
await
Task
.
Delay
(
1000
);
// Quickly play through multiple visual-states to simulate what happens when tapping(*1) on a ToggleSwitch.
/* *1: The full tapping experience is: [InitialState: Off]->Dragging->Off->On or [InitialState: A]->B->A->C
* where A=Off, B=Dragging, C=Off
* SwitchKnobOn.Opacity ToggleStates\AOff->COn 1 @[ControlFasterAnimationDuration] f=Linear
* SwitchKnobOn.Opacity ToggleStates\BDragging->AOff 0 @[ControlFasterAnimationDuration] f=Linear
* SwitchKnobOn.Opacity ToggleStates\BDragging->COn 1 @[ControlFasterAnimationDuration] f=Linear
* SwitchKnobOn.Opacity ToggleStates\COn->AOff 0 @[ControlFasterAnimationDuration] f=Linear
* SwitchKnobOn.Opacity ToggleStates\COn->BDragging 1 @0 f=Linear
* SwitchKnobOn.Opacity ToggleStates\COn 1 @[ControlFasterAnimationDuration] f=Linear
*/
VisualStateManager
.
GoToState
(
sut
,
TestPages
.
QuickMultiTransitionsPage
.
TestStateNames
.
PhaseB
,
useTransitions
:
true
);
VisualStateManager
.
GoToState
(
sut
,
TestPages
.
QuickMultiTransitionsPage
.
TestStateNames
.
PhaseA
,
useTransitions
:
true
);
VisualStateManager
.
GoToState
(
sut
,
TestPages
.
QuickMultiTransitionsPage
.
TestStateNames
.
PhaseC
,
useTransitions
:
true
);
await
WindowHelper
.
WaitForIdle
();
await
Task
.
Delay
(
1000
);
// Given that it involves a race condition, we use a matrix of 4x4 to boost the failure rate.
// If everything went smoothly, the end result should be an opacity of 1 for all the borders.
var
total
=
sut
.
RootGrid
.
Children
.
OfType
<
Border
>().
Count
();
var
passed
=
sut
.
RootGrid
.
Children
.
OfType
<
Border
>()
.
Count
(
x
=>
x
.
Opacity
==
1.0
);
Assert
.
AreEqual
(
total
,
passed
,
$"Only
{
passed
}
of
{
total
}
Border.Opacity is at expected value of 1.0"
);
}
}
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Animation/TestPages/QuickMultiTransitionsPage.xaml
0 → 100644
浏览文件 @
e8ad72bf
此差异已折叠。
点击以展开。
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Animation/TestPages/QuickMultiTransitionsPage.xaml.cs
0 → 100644
浏览文件 @
e8ad72bf
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Runtime.InteropServices.WindowsRuntime
;
using
Windows.Foundation
;
using
Windows.Foundation.Collections
;
using
Windows.UI.Xaml
;
using
Windows.UI.Xaml.Controls
;
using
Windows.UI.Xaml.Controls.Primitives
;
using
Windows.UI.Xaml.Data
;
using
Windows.UI.Xaml.Input
;
using
Windows.UI.Xaml.Media
;
using
Windows.UI.Xaml.Navigation
;
namespace
Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Media_Animation.TestPages
;
public
sealed
partial
class
QuickMultiTransitionsPage
:
Page
{
public
static
class
TestStateNames
{
public
const
string
PhaseA
=
nameof
(
PhaseA
);
public
const
string
PhaseB
=
nameof
(
PhaseB
);
public
const
string
PhaseC
=
nameof
(
PhaseC
);
}
public
QuickMultiTransitionsPage
()
{
this
.
InitializeComponent
();
this
.
Loaded
+=
(
s
,
e
)
=>
VisualStateManager
.
GoToState
(
this
,
TestStateNames
.
PhaseA
,
useTransitions
:
true
);
}
}
src/Uno.UI/UI/Xaml/Media/Animation/ColorAnimationUsingKeyFrames.cs
浏览文件 @
e8ad72bf
...
...
@@ -15,6 +15,8 @@ namespace Windows.UI.Xaml.Media.Animation
partial
class
ColorAnimationUsingKeyFrames
:
Timeline
,
ITimeline
{
private
readonly
Stopwatch
_activeDuration
=
new
Stopwatch
();
private
bool
_wasBeginScheduled
;
private
bool
_wasRequestedToStop
;
private
int
_replayCount
=
1
;
private
ColorOffset
?
_startingValue
;
private
ColorOffset
_finalValue
;
...
...
@@ -79,7 +81,6 @@ namespace Windows.UI.Xaml.Media.Animation
return
base
.
GetCalculatedDuration
();
}
bool
_wasBeginScheduled
;
void
ITimeline
.
Begin
()
{
if
(!
_wasBeginScheduled
)
...
...
@@ -87,7 +88,9 @@ namespace Windows.UI.Xaml.Media.Animation
// We dispatch the begin so that we can use bindings on ColorKeyFrame.Value from RelativeParent.
// This works because the template bindings are executed just after the constructor.
// WARNING: This does not allow us to bind ColorKeyFrame.Value with ViewModel properties.
_wasBeginScheduled
=
true
;
_wasRequestedToStop
=
false
;
#if !NET461
#if __ANDROID__
...
...
@@ -97,14 +100,17 @@ namespace Windows.UI.Xaml.Media.Animation
#endif
#endif
{
if
(
KeyFrames
.
Count
<
1
)
_wasBeginScheduled
=
false
;
if
(
KeyFrames
.
Count
<
1
||
// nothing to do
_wasRequestedToStop
// was requested to stop, between Begin() and dispatched here
)
{
return
;
// nothing to do
return
;
}
PropertyInfo
?.
CloneShareableObjectsInPath
();
_wasBeginScheduled
=
false
;
_activeDuration
.
Restart
();
_replayCount
=
1
;
...
...
@@ -207,7 +213,9 @@ namespace Windows.UI.Xaml.Media.Animation
_currentAnimator
.
Cancel
();
//Stop the animator if it is running
_startingValue
=
null
;
}
State
=
TimelineState
.
Stopped
;
_wasRequestedToStop
=
true
;
}
void
ITimeline
.
Stop
()
...
...
@@ -215,7 +223,9 @@ namespace Windows.UI.Xaml.Media.Animation
_currentAnimator
?.
Cancel
();
// stop could be called before the initialization
_startingValue
=
null
;
ClearValue
();
State
=
TimelineState
.
Stopped
;
_wasRequestedToStop
=
true
;
}
/// <summary>
...
...
src/Uno.UI/UI/Xaml/Media/Animation/DoubleAnimationUsingKeyFrames.cs
浏览文件 @
e8ad72bf
...
...
@@ -15,6 +15,8 @@ namespace Windows.UI.Xaml.Media.Animation
public
partial
class
DoubleAnimationUsingKeyFrames
:
Timeline
,
ITimeline
{
private
readonly
Stopwatch
_activeDuration
=
new
Stopwatch
();
private
bool
_wasBeginScheduled
;
private
bool
_wasRequestedToStop
;
private
int
_replayCount
=
1
;
private
double
?
_startingValue
;
private
double
_finalValue
;
...
...
@@ -55,7 +57,6 @@ namespace Windows.UI.Xaml.Media.Animation
return
base
.
GetCalculatedDuration
();
}
bool
_wasBeginScheduled
;
void
ITimeline
.
Begin
()
{
if
(!
_wasBeginScheduled
)
...
...
@@ -63,7 +64,10 @@ namespace Windows.UI.Xaml.Media.Animation
// We dispatch the begin so that we can use bindings on DoubleKeyFrame.Value from RelativeParent.
// This works because the template bindings are executed just after the constructor.
// WARNING: This does not allow us to bind DoubleKeyFrame.Value with ViewModel properties.
_wasBeginScheduled
=
true
;
_wasRequestedToStop
=
false
;
#if !NET461
#if __ANDROID__
_
=
Dispatcher
.
RunAnimation
(()
=>
...
...
@@ -72,11 +76,14 @@ namespace Windows.UI.Xaml.Media.Animation
#endif
#endif
{
if
(
KeyFrames
.
Count
<
1
)
_wasBeginScheduled
=
false
;
if
(
KeyFrames
.
Count
<
1
||
// nothing to do
_wasRequestedToStop
// was requested to stop, between Begin() and dispatched here
)
{
return
;
// nothing to do
return
;
}
_wasBeginScheduled
=
false
;
_activeDuration
.
Restart
();
_replayCount
=
1
;
...
...
@@ -175,7 +182,9 @@ namespace Windows.UI.Xaml.Media.Animation
_currentAnimator
.
Cancel
();
//Stop the animator if it is running
_startingValue
=
null
;
}
State
=
TimelineState
.
Stopped
;
_wasRequestedToStop
=
true
;
}
void
ITimeline
.
Stop
()
...
...
@@ -183,7 +192,9 @@ namespace Windows.UI.Xaml.Media.Animation
_currentAnimator
?.
Cancel
();
// stop could be called before the initialization
_startingValue
=
null
;
ClearValue
();
State
=
TimelineState
.
Stopped
;
_wasRequestedToStop
=
true
;
}
/// <summary>
...
...
src/Uno.UI/UI/Xaml/Media/Animation/ObjectAnimationUsingKeyFrames.cs
浏览文件 @
e8ad72bf
...
...
@@ -114,8 +114,8 @@ namespace Windows.UI.Xaml.Media.Animation
);
}
// We explicitly call the Stop of the _frameScheduler bef
ire teh Reste
dispose it,
// so the EndReason will
stopped instead of Aborted
// We explicitly call the Stop of the _frameScheduler bef
ore the Reset
dispose it,
// so the EndReason will
be Stopped instead of Aborted.
_frameScheduler
?.
Stop
();
Reset
();
...
...
src/Uno.UI/UI/Xaml/Media/Animation/Storyboard.cs
浏览文件 @
e8ad72bf
...
...
@@ -114,6 +114,7 @@ namespace Windows.UI.Xaml.Media.Animation
private
void
Play
()
{
_runningChildren
=
0
;
if
(
Children
!=
null
&&
Children
.
Count
>
0
)
{
for
(
int
i
=
0
;
i
<
Children
.
Count
;
i
++)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录