forked from firka/flutter
Provide asset lookup key on ios (flutter/engine#4817)
This commit is contained in:
@@ -23,6 +23,26 @@ FLUTTER_EXPORT
|
||||
|
||||
- (instancetype)initFromDefaultSourceForConfiguration;
|
||||
|
||||
/**
|
||||
Returns the file name for the given asset.
|
||||
The returned file name can be used to access the asset in the application's main bundle.
|
||||
|
||||
- Parameter asset: The name of the asset. The name can be hierarchical.
|
||||
- Returns: the file name to be used for lookup in the main bundle.
|
||||
*/
|
||||
+ (NSString*)lookupKeyForAsset:(NSString*)asset;
|
||||
|
||||
/**
|
||||
Returns the file name for the given asset which originates from the specified package.
|
||||
The returned file name can be used to access the asset in the application's main bundle.
|
||||
|
||||
- Parameters:
|
||||
- asset: The name of the asset. The name can be hierarchical.
|
||||
- package: The name of the package from which the asset originates.
|
||||
- Returns: the file name to be used for lookup in the main bundle.
|
||||
*/
|
||||
+ (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package;
|
||||
|
||||
@end
|
||||
|
||||
#endif // FLUTTER_FLUTTERDARTPROJECT_H_
|
||||
|
||||
@@ -183,6 +183,26 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- Parameters delegate: The receiving object, such as the plugin's main class.
|
||||
*/
|
||||
- (void)addApplicationDelegate:(NSObject<FlutterPlugin>*)delegate;
|
||||
|
||||
/**
|
||||
Returns the file name for the given asset.
|
||||
The returned file name can be used to access the asset in the application's main bundle.
|
||||
|
||||
- Parameter asset: The name of the asset. The name can be hierarchical.
|
||||
- Returns: the file name to be used for lookup in the main bundle.
|
||||
*/
|
||||
- (NSString*)lookupKeyForAsset:(NSString*)asset;
|
||||
|
||||
/**
|
||||
Returns the file name for the given asset which originates from the specified package.
|
||||
The returned file name can be used to access the asset in the application's main bundle.
|
||||
|
||||
- Parameters:
|
||||
- asset: The name of the asset. The name can be hierarchical.
|
||||
- package: The name of the package from which the asset originates.
|
||||
- Returns: the file name to be used for lookup in the main bundle.
|
||||
*/
|
||||
- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package;
|
||||
@end
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,26 @@ FLUTTER_EXPORT
|
||||
|
||||
- (void)handleStatusBarTouches:(UIEvent*)event;
|
||||
|
||||
/**
|
||||
Returns the file name for the given asset.
|
||||
The returned file name can be used to access the asset in the application's main bundle.
|
||||
|
||||
- Parameter asset: The name of the asset. The name can be hierarchical.
|
||||
- Returns: the file name to be used for lookup in the main bundle.
|
||||
*/
|
||||
- (NSString*)lookupKeyForAsset:(NSString*)asset;
|
||||
|
||||
/**
|
||||
Returns the file name for the given asset which originates from the specified package.
|
||||
The returned file name can be used to access the asset in the application's main bundle.
|
||||
|
||||
- Parameters:
|
||||
- asset: The name of the asset. The name can be hierarchical.
|
||||
- package: The name of the package from which the asset originates.
|
||||
- Returns: the file name to be used for lookup in the main bundle.
|
||||
*/
|
||||
- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package;
|
||||
|
||||
/**
|
||||
Sets the first route that the Flutter app shows. The default is "/".
|
||||
|
||||
|
||||
@@ -284,4 +284,13 @@
|
||||
- (void)addApplicationDelegate:(NSObject<FlutterPlugin>*)delegate {
|
||||
[_appDelegate.pluginDelegates addObject:delegate];
|
||||
}
|
||||
|
||||
- (NSString*)lookupKeyForAsset:(NSString*)asset {
|
||||
return [FlutterDartProject lookupKeyForAsset:asset];
|
||||
}
|
||||
|
||||
- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package {
|
||||
return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -146,16 +146,29 @@ static NSURL* URLForSwitch(const fxl::StringView name) {
|
||||
|
||||
#pragma mark - Assets-related utilities
|
||||
|
||||
+ (NSString*)pathForFlutterAssetsFromBundle:(NSBundle*)bundle {
|
||||
+ (NSString*)flutterAssetsName:(NSBundle*)bundle {
|
||||
NSString* flutterAssetsName = [bundle objectForInfoDictionaryKey:@"FLTAssetsPath"];
|
||||
if (flutterAssetsName == nil) {
|
||||
// Default to "flutter_assets"
|
||||
flutterAssetsName = @"flutter_assets";
|
||||
}
|
||||
return flutterAssetsName;
|
||||
}
|
||||
|
||||
+ (NSString*)pathForFlutterAssetsFromBundle:(NSBundle*)bundle {
|
||||
NSString* flutterAssetsName = [FlutterDartProject flutterAssetsName:bundle];
|
||||
return [bundle pathForResource:flutterAssetsName ofType:nil];
|
||||
}
|
||||
|
||||
+ (NSString*)lookupKeyForAsset:(NSString*)asset {
|
||||
NSString* flutterAssetsName = [FlutterDartProject flutterAssetsName: [NSBundle mainBundle]];
|
||||
return [NSString stringWithFormat:@"%@/%@", flutterAssetsName, asset];
|
||||
}
|
||||
|
||||
+ (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package {
|
||||
return [self lookupKeyForAsset:[NSString stringWithFormat:@"packages/%@/%@", package, asset]];
|
||||
}
|
||||
|
||||
#pragma mark - Launching the project in a preconfigured engine.
|
||||
|
||||
static NSString* NSStringFromVMType(VMType type) {
|
||||
|
||||
@@ -908,4 +908,13 @@ constexpr CGFloat kStandardStatusBarHeight = 20.0;
|
||||
- (void)textureFrameAvailable:(int64_t)textureId {
|
||||
_platformView->MarkTextureFrameAvailable(textureId);
|
||||
}
|
||||
|
||||
- (NSString*)lookupKeyForAsset:(NSString*)asset {
|
||||
return [FlutterDartProject lookupKeyForAsset:asset];
|
||||
}
|
||||
|
||||
- (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package {
|
||||
return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user