Refactor ios play input sound logic. (flutter/engine#7783)
As there are extra requirement to use playInputClick in iOS, use AudioServicesPlaySystemSound instead to play input sound.
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr char kTextPlainFormat[] = "text/plain";
|
constexpr char kTextPlainFormat[] = "text/plain";
|
||||||
|
const UInt32 kKeyPressClickSoundId = 1306;
|
||||||
|
|
||||||
} // namespaces
|
} // namespaces
|
||||||
|
|
||||||
@@ -93,9 +94,8 @@ using namespace shell;
|
|||||||
- (void)playSystemSound:(NSString*)soundType {
|
- (void)playSystemSound:(NSString*)soundType {
|
||||||
if ([soundType isEqualToString:@"SystemSoundType.click"]) {
|
if ([soundType isEqualToString:@"SystemSoundType.click"]) {
|
||||||
// All feedback types are specific to Android and are treated as equal on
|
// All feedback types are specific to Android and are treated as equal on
|
||||||
// iOS. The surface must (and does) adopt the UIInputViewAudioFeedback
|
// iOS.
|
||||||
// protocol
|
AudioServicesPlaySystemSound(kKeyPressClickSoundId);
|
||||||
[[UIDevice currentDevice] playInputClick];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,6 @@
|
|||||||
#include "flutter/shell/platform/darwin/ios/ios_surface_software.h"
|
#include "flutter/shell/platform/darwin/ios/ios_surface_software.h"
|
||||||
#include "third_party/skia/include/utils/mac/SkCGUtils.h"
|
#include "third_party/skia/include/utils/mac/SkCGUtils.h"
|
||||||
|
|
||||||
@interface FlutterView () <UIInputViewAudioFeedback>
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation FlutterView
|
@implementation FlutterView
|
||||||
|
|
||||||
id<FlutterViewEngineDelegate> _delegate;
|
id<FlutterViewEngineDelegate> _delegate;
|
||||||
@@ -97,10 +93,6 @@ id<FlutterViewEngineDelegate> _delegate;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)enableInputClicksWhenVisible {
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context {
|
- (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context {
|
||||||
TRACE_EVENT0("flutter", "SnapshotFlutterView");
|
TRACE_EVENT0("flutter", "SnapshotFlutterView");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user