Skip to content

Commit

Permalink
chore: Adjust TimePicker logic for Skia
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Uno.UI/UI/Xaml/Media/ThemeShadow.cs
  • Loading branch information
MartinZikmund committed Jan 18, 2024
1 parent 4dab50e commit 9b84510
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/Controls/Primitives/PickerFlyoutBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void SetTitle(DependencyObject element, string value)
element.SetValue(TitleProperty, value);
}

protected virtual void OnConfirmed() => throw new InvalidOperationException();
protected virtual void OnConfirmed() => Hide();

protected virtual bool ShouldShowConfirmationButtons() => throw new InvalidOperationException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public TimePicker()
ResourceResolver.ApplyResource(this, LightDismissOverlayBackgroundProperty, "TimePickerLightDismissOverlayBackground", isThemeResourceExtension: true, isHotReloadSupported: false);

DefaultStyleKey = typeof(TimePicker);
InitPartial();
}

#region Time DependencyProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public TimePicker()
m_reactionToSelectionChangeAllowed = false;
m_defaultTime = new TimeSpan(GetNullTimeSentinelValue());
m_currentTime = new TimeSpan(GetNullTimeSentinelValue());
InitPartial();
PrepareState();
}

Expand Down Expand Up @@ -120,11 +121,6 @@ private void PrepareState()
RefreshSetup();

Loaded += OnLoaded;

if (pCurrentWindow is not null)
{
v
}
}

private void OnLoaded(object sender, RoutedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public string ClockIdentifier
typeof(string),
typeof(TimePickerFlyout),
new FrameworkPropertyMetadata(
defaultValue: (string)Windows.Globalization.ClockIdentifiers.TwelveHour,
defaultValue: (string)TimePickerFlyout.GetDefaultClockIdentifier(),
options: FrameworkPropertyMetadataOptions.None)
);

Expand All @@ -38,7 +38,7 @@ public int MinuteIncrement
typeof(int),
typeof(TimePickerFlyout),
new FrameworkPropertyMetadata(
defaultValue: (int)1,
defaultValue: (int)TimePickerFlyout.GetDefaultMinuteIncrement(),
options: FrameworkPropertyMetadataOptions.None)
);

Expand All @@ -54,7 +54,7 @@ public TimeSpan Time
typeof(TimeSpan),
typeof(TimePickerFlyout),
new FrameworkPropertyMetadata(
defaultValue: (TimeSpan)DateTime.Now.TimeOfDay,
defaultValue: (TimeSpan)TimePickerFlyout.GetDefaultTime(),
options: FrameworkPropertyMetadataOptions.None)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private void OnKeyDown(object pSender, KeyRoutedEventArgs pEventArgs)
}
}

private object GetDefaultTime()
private static TimeSpan GetDefaultTime()
{
TimeSpan retTimeSpan = default;

Expand Down Expand Up @@ -276,12 +276,12 @@ private object GetDefaultTime()
return retTimeSpan;
}

private object GetDefaultClockIdentifier()
private static string GetDefaultClockIdentifier()
{
var spFormatter = new DateTimeFormatter(s_strHourFormat);

return spFormatter.Clock;
}

private object GetDefaultMinuteIncrement() => 1;
private static int GetDefaultMinuteIncrement() => 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ partial class TimePickerFlyoutPresenter
private const string _strHourFormat = "{hour.integer(1)}";
private const string _strMinuteFormat = "{minute.integer(2)}";
private const string _strPeriodFormat = "{period.abbreviated(2)}";
private const long _timeSpanTicksPerMinute = 60000000;
private const long _timeSpanTicksPerHour = 3600000000;
private const long _timeSpanTicksPerDay = 86400000000;
private const long _timeSpanTicksPerMinute = 600000000;
private const long _timeSpanTicksPerHour = 36000000000;
private const long _timeSpanTicksPerDay = 864000000000;
internal const int _periodCoercionOffset = 12;
private const string _firstPickerHostName = "FirstPickerHost";
private const string _secondPickerHostName = "SecondPickerHost";
Expand Down
41 changes: 22 additions & 19 deletions src/Uno.UI/UI/Xaml/Media/ThemeShadow.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
namespace Microsoft.UI.Xaml.Media
namespace Microsoft.UI.Xaml.Media;

/// <summary>
/// A ThemeShadow is a preconfigured shadow effect that can be applied to any XAML element to draw shadows appropriately based on x,y,z coordinates.
/// ThemeShadow also automatically adjusts for other environmental specifications.
/// - Adapts to changes in lighting, user theme, app environment, and shell.
/// - Shadows elements automatically based on their elevation.
/// - Keeps elements in sync as they move and change elevation.
/// - Keeps shadows consistent throughout and across applications.
/// </summary>
public partial class ThemeShadow : Shadow
{
/// <summary>
/// A ThemeShadow is a preconfigured shadow effect that can be applied to any XAML element to draw shadows appropriately based on x,y,z coordinates.
/// ThemeShadow also automatically adjusts for other environmental specifications.
/// - Adapts to changes in lighting, user theme, app environment, and shell.
/// - Shadows elements automatically based on their elevation.
/// - Keeps elements in sync as they move and change elevation.
/// - Keeps shadows consistent throughout and across applications.
/// Initializes a new instance of the ThemeShadow class.
/// </summary>
public partial class ThemeShadow : Shadow
public ThemeShadow()
{
/// <summary>
/// Initializes a new instance of the ThemeShadow class.
/// </summary>
public ThemeShadow()
{
}

/// <summary>
/// Gets a collection of UI elements that this ThemeShadow is cast on.
/// </summary>
public UIElementWeakCollection Receivers { get; } = new UIElementWeakCollection();
}

/// <summary>
/// Gets a collection of UI elements that this ThemeShadow is cast on.
/// </summary>
public UIElementWeakCollection Receivers { get; } = new UIElementWeakCollection();

// Lifted Xaml had an old projected shadow code path that we're keeping around (disabled) as insurance. All shadows
// are going through the drop shadow code path, hence we just return true here.
internal static bool IsDropShadowMode => true;
}

0 comments on commit 9b84510

Please sign in to comment.