Unverified Commit 4676e1d7 authored by Mikkel Nygaard Ravn's avatar Mikkel Nygaard Ravn Committed by GitHub

Add support for iOS plugin class prefix (#13095)

parent 928d2cc7
......@@ -12,19 +12,34 @@ import 'globals.dart';
class Plugin {
final String name;
final String path;
final String pluginClass;
final String androidPackage;
final String iosPrefix;
final String pluginClass;
Plugin(this.name, this.path, this.pluginClass, this.androidPackage);
Plugin({
this.name,
this.path,
this.androidPackage,
this.iosPrefix,
this.pluginClass,
});
factory Plugin.fromYaml(String name, String path, dynamic pluginYaml) {
String androidPackage;
String iosPrefix;
String pluginClass;
if (pluginYaml != null) {
androidPackage = pluginYaml['androidPackage'];
iosPrefix = pluginYaml['iosPrefix'] ?? '';
pluginClass = pluginYaml['pluginClass'];
}
return new Plugin(name, path, pluginClass, androidPackage);
return new Plugin(
name: name,
path: path,
androidPackage: androidPackage,
iosPrefix: iosPrefix,
pluginClass: pluginClass,
);
}
}
......@@ -146,7 +161,7 @@ const String _iosPluginRegistryImplementationTemplate = '''//
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
{{#plugins}}
[{{class}} registerWithRegistrar:[registry registrarForPlugin:@"{{class}}"]];
[{{prefix}}{{class}} registerWithRegistrar:[registry registrarForPlugin:@"{{prefix}}{{class}}"]];
{{/plugins}}
}
......@@ -158,6 +173,7 @@ void _writeIOSPluginRegistry(String directory, List<Plugin> plugins) {
.where((Plugin p) => p.pluginClass != null)
.map((Plugin p) => <String, dynamic>{
'name': p.name,
'prefix': p.iosPrefix,
'class': p.pluginClass,
}).
toList();
......
......@@ -45,8 +45,9 @@
"additionalProperties": false,
"properties": {
"androidPackage": { "type": "string" },
"iosPrefix": { "type": "string" },
"pluginClass": { "type": "string" }
}
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment