您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
57 行
1.6 KiB
57 行
1.6 KiB
using RSG;
|
|
using Unity.UIWidgets.gestures;
|
|
using Unity.UIWidgets.widgets;
|
|
using UnityEngine;
|
|
|
|
namespace Unity.UIWidgets.material {
|
|
public class Feedback {
|
|
Feedback() {
|
|
}
|
|
|
|
public static IPromise forTap(BuildContext context) {
|
|
switch (_platform(context)) {
|
|
case RuntimePlatform.Android:
|
|
return
|
|
Promise.Resolved(); // SystemSound.play(SystemSoundType.click); TODO: replace with unity equivalent
|
|
default:
|
|
return Promise.Resolved();
|
|
}
|
|
}
|
|
|
|
public static GestureTapCallback wrapForTap(GestureTapCallback callback, BuildContext context) {
|
|
if (callback == null) {
|
|
return null;
|
|
}
|
|
|
|
return () => {
|
|
forTap(context);
|
|
callback();
|
|
};
|
|
}
|
|
|
|
public static IPromise forLongPress(BuildContext context) {
|
|
switch (_platform(context)) {
|
|
case RuntimePlatform.Android:
|
|
return Promise.Resolved(); // HapticFeedback.vibrate(); TODO
|
|
default:
|
|
return Promise.Resolved();
|
|
}
|
|
}
|
|
|
|
public static GestureLongPressCallback
|
|
wrapForLongPress(GestureLongPressCallback callback, BuildContext context) {
|
|
if (callback == null) {
|
|
return null;
|
|
}
|
|
|
|
return () => {
|
|
forLongPress(context);
|
|
callback();
|
|
};
|
|
}
|
|
|
|
static RuntimePlatform _platform(BuildContext context) {
|
|
return Theme.of(context).platform;
|
|
}
|
|
}
|
|
}
|