public void TriggerHapticFeedback(HapticFeedbackType hapticFeedback) { switch (hapticFeedback) { case HapticFeedbackType.ImpactLight: TriggerImpactFeedback(ImpactFeedbackStyle.Light); break; case HapticFeedbackType.ImpactMedium: TriggerImpactFeedback(ImpactFeedbackStyle.Medium); break; case HapticFeedbackType.ImpactHeavy: TriggerImpactFeedback(ImpactFeedbackStyle.Heavy); break; case HapticFeedbackType.NotificationError: TriggerNotificationFeedback(NotificationFeedbackType.Error); break; case HapticFeedbackType.NotificationSuccess: TriggerNotificationFeedback(NotificationFeedbackType.Success); break; case HapticFeedbackType.NotificationWarning: TriggerNotificationFeedback(NotificationFeedbackType.Warning); break; case HapticFeedbackType.Selection: TriggerSelectionFeedback(); break; } }
static void PlatformPerform(HapticFeedbackType type) { if (type == HapticFeedbackType.LongPress) { NSHapticFeedbackManager.DefaultPerformer.PerformFeedback(NSHapticFeedbackPattern.Generic, NSHapticFeedbackPerformanceTime.Default); } }
public static void Perform(HapticFeedbackType type = HapticFeedbackType.Click) { if (!IsSupported) { throw new FeatureNotSupportedException(); } PlatformPerform(type); }
static void PlatformPerform(HapticFeedbackType type) { switch (type) { case HapticFeedbackType.LongPress: PlatformLongPress(); break; default: PlatformClick(); break; } }
public void Perform(HapticFeedbackType type) { switch (type) { case HapticFeedbackType.LongPress: LongPress(); break; default: Click(); break; } }
static void PlatformPerform(HapticFeedbackType type) { Permissions.EnsureDeclared <Permissions.Vibrate>(); try { Platform.CurrentActivity?.Window?.DecorView?.PerformHapticFeedback(ConvertType(type)); } catch (Exception ex) { Debug.WriteLine($"HapticFeedback Exception: {ex.Message}"); } }
public void Perform(HapticFeedbackType type) { Permissions.EnsureDeclared <Permissions.Vibrate>(); try { ActivityStateManager.Default.GetCurrentActivity()?.Window?.DecorView?.PerformHapticFeedback(ConvertType(type)); } catch (Exception ex) { Debug.WriteLine($"HapticFeedback Exception: {ex.Message}"); } }
public void Perform(HapticFeedbackType type) { Permissions.EnsureDeclared <Permissions.Vibrate>(); try { var feedback = new Feedback(); var pattern = ConvertType(type); if (feedback.IsSupportedPattern(FeedbackType.Vibration, pattern)) { feedback.Play(FeedbackType.Vibration, pattern); } } catch (Exception ex) { Debug.WriteLine($"HapticFeedback Exception: {ex.Message}"); } }
public void Run(HapticFeedbackType hapticFeedbackType) { switch (hapticFeedbackType) { case HapticFeedbackType.Softy: activity.Window.DecorView.RootView.PerformHapticFeedback(FeedbackConstants.ContextClick); break; case HapticFeedbackType.Medium: activity.Window.DecorView.RootView.PerformHapticFeedback(FeedbackConstants.KeyboardPress); break; case HapticFeedbackType.Heavy: activity.Window.DecorView.RootView.PerformHapticFeedback(FeedbackConstants.KeyboardPress); break; } }
internal static void DoHaptic(HapticFeedbackType type) { try { // Perform click feedback // Use default vibration length Vibration.Vibrate(TimeSpan.FromMilliseconds(50)); // Xamarin.Essentials.HapticFeedback.Perform(type); } catch (FeatureNotSupportedException ex) { // Feature not supported on device } catch (Exception ex) { // Other error has occurred. } }
public void Run(HapticFeedbackType hapticFeedbackType) { UIImpactFeedbackGenerator impact = null; switch (hapticFeedbackType) { case HapticFeedbackType.Softy: impact = new UIImpactFeedbackGenerator(UIImpactFeedbackStyle.Light); break; case HapticFeedbackType.Medium: impact = new UIImpactFeedbackGenerator(UIImpactFeedbackStyle.Medium); break; case HapticFeedbackType.Heavy: impact = new UIImpactFeedbackGenerator(UIImpactFeedbackStyle.Heavy); break; } impact.Prepare(); impact.ImpactOccurred(); }
public async void Perform(HapticFeedbackType type) { try { if (ApiInformation.IsTypePresent(vibrationDeviceApiType) && await VibrationDevice.RequestAccessAsync() == VibrationAccessStatus.Allowed) { var controller = (await VibrationDevice.GetDefaultAsync())?.SimpleHapticsController; if (controller != null) { var feedback = FindFeedback(controller, ConvertType(type)); if (feedback != null) { controller.SendHapticFeedback(feedback); } } } } catch (Exception ex) { Debug.WriteLine($"HapticFeedback Exception: {ex.Message}"); } }
static FeedbackConstants ConvertType(HapticFeedbackType type) => type switch {
static ushort ConvertType(HapticFeedbackType type) => type switch {
static void PlatformPerform(HapticFeedbackType type) => throw ExceptionUtils.NotSupportedOrImplementedException;
public static void Perform(HapticFeedbackType type = HapticFeedbackType.Click) => Current.Perform(type);
public void Run(HapticFeedbackType hapticFeedbackType) { //This is a default thing should not be used; //throw new System.Exception("Not initialized in device platforms isbrubles"); }
static string ConvertType(HapticFeedbackType type) => type switch {
public static void Perform(HapticFeedbackType type = HapticFeedbackType.Click) => Default.Perform(type);