Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AnimationContext.cs
1using System;
2using Microsoft.Maui;
3using Microsoft.Maui.Devices;
4
6{
10 public interface IAnimationContext
11 {
15 string Platform { get; }
16
20 string? Theme { get; }
21
25 Thickness SafeAreaInsets { get; }
26
30 double KeyboardInset { get; }
31
35 double ViewportWidth { get; }
36
40 double ViewportHeight { get; }
41
45 bool ReduceMotion { get; }
46
50 double DurationScale { get; }
51 }
52
56 public sealed class AnimationContextOptions
57 {
62
66 public string? Platform { get; init; }
67
71 public string? Theme { get; init; }
72
76 public Thickness? SafeAreaInsets { get; init; }
77
81 public double? KeyboardInset { get; init; }
82
86 public double? ViewportWidth { get; init; }
87
91 public double? ViewportHeight { get; init; }
92 }
93
97 public sealed class AnimationContext : IAnimationContext
98 {
110 public AnimationContext(string Platform, string? Theme, Thickness SafeAreaInsets, double KeyboardInset, double ViewportWidth, double ViewportHeight, bool ReduceMotion, double DurationScale)
111 {
112 if (string.IsNullOrWhiteSpace(Platform))
113 throw new ArgumentException("Platform cannot be null or whitespace.", nameof(Platform));
114
115 this.Platform = Platform;
116 this.Theme = Theme;
117 this.SafeAreaInsets = SafeAreaInsets;
118 this.KeyboardInset = KeyboardInset;
119 this.ViewportWidth = ViewportWidth;
120 this.ViewportHeight = ViewportHeight;
121 this.ReduceMotion = ReduceMotion;
122 this.DurationScale = DurationScale;
123 }
124
126 public string Platform { get; }
127
129 public string? Theme { get; }
130
132 public Thickness SafeAreaInsets { get; }
133
135 public double KeyboardInset { get; }
136
138 public double ViewportWidth { get; }
139
141 public double ViewportHeight { get; }
142
144 public bool ReduceMotion { get; }
145
147 public double DurationScale { get; }
148 }
149
154 {
161 }
162
167 {
168 private readonly IMotionSettings motionSettings;
169
175 {
176 this.motionSettings = MotionSettings ?? throw new ArgumentNullException(nameof(MotionSettings));
177 }
178
181 {
182 AnimationContextOptions EffectiveOptions = Options ?? AnimationContextOptions.Default;
183 string Platform = EffectiveOptions.Platform ?? DeviceInfo.Platform.ToString();
184 string? Theme = EffectiveOptions.Theme;
185 Thickness SafeArea = EffectiveOptions.SafeAreaInsets ?? Thickness.Zero;
186 double KeyboardInset = EffectiveOptions.KeyboardInset ?? 0;
187 double ViewportWidth = EffectiveOptions.ViewportWidth ?? 0;
188 double ViewportHeight = EffectiveOptions.ViewportHeight ?? 0;
189 bool ReduceMotion = this.motionSettings.ReduceMotion;
190 double DurationScale = this.motionSettings.DurationScale;
191 return new AnimationContext(Platform, Theme, SafeArea, KeyboardInset, ViewportWidth, ViewportHeight, ReduceMotion, DurationScale);
192 }
193 }
194}
Concrete snapshot of contextual data used during animation execution.
string? Theme
Gets the optional theme key associated with the animation request.
string Platform
Gets the platform identifier (e.g., Android, iOS, WinUI).
bool ReduceMotion
Gets a value indicating whether the caller requests reduced motion.
double KeyboardInset
Gets the active keyboard inset height in device-independent units.
Thickness SafeAreaInsets
Gets the safe-area insets active for the request.
double ViewportWidth
Gets the available viewport width for the animation.
double DurationScale
Gets the multiplier applied to animation durations.
AnimationContext(string Platform, string? Theme, Thickness SafeAreaInsets, double KeyboardInset, double ViewportWidth, double ViewportHeight, bool ReduceMotion, double DurationScale)
Initializes a new instance of the AnimationContext class.
double ViewportHeight
Gets the available viewport height for the animation.
Data structure used when building animation contexts.
Thickness? SafeAreaInsets
Gets or sets an optional safe-area inset value.
static AnimationContextOptions Default
Gets a default instance with no overrides.
double? ViewportWidth
Gets or sets an optional viewport width value.
double? ViewportHeight
Gets or sets an optional viewport height value.
string? Theme
Gets or sets an optional theme identifier.
string? Platform
Gets or sets an optional platform override.
double? KeyboardInset
Gets or sets an optional keyboard inset height.
Default implementation of IAnimationContextProvider.
AnimationContextProvider(IMotionSettings MotionSettings)
Initializes a new instance of the AnimationContextProvider class.
IAnimationContext CreateContext(AnimationContextOptions? Options)
Builds a context instance using provided options. Created context instance.
Default implementation of IMotionSettings.
Represents contextual information required when executing an animation.
string Platform
Gets the platform identifier (e.g., Android, iOS, WinUI).
double KeyboardInset
Gets the active keyboard inset height in device-independent units.
bool ReduceMotion
Gets a value indicating whether the caller requests reduced motion.
string? Theme
Gets the optional theme key associated with the animation request.
double ViewportWidth
Gets the available viewport width for the animation.
Thickness SafeAreaInsets
Gets the safe-area insets active for the request.
double DurationScale
Gets the multiplier applied to animation durations.
double ViewportHeight
Gets the available viewport height for the animation.
Factory abstraction responsible for constructing animation contexts.
IAnimationContext CreateContext(AnimationContextOptions? Options)
Builds a context instance using provided options.
Represents motion preferences that affect animation execution.