2020-04-18 20:34:03 +02:00
|
|
|
import 'package:flutter/services.dart';
|
2020-05-04 21:49:44 +02:00
|
|
|
import 'package:musicus_common/musicus_common.dart';
|
2020-04-18 20:34:03 +02:00
|
|
|
|
2020-05-04 21:49:44 +02:00
|
|
|
class MusicusAndroidPlatform extends MusicusPlatform {
|
2020-04-18 20:34:03 +02:00
|
|
|
static const _platform = MethodChannel('de.johrpan.musicus/platform');
|
|
|
|
|
|
2020-05-04 21:49:44 +02:00
|
|
|
@override
|
|
|
|
|
Future<List<Document>> getChildren(String parentId) async {
|
2020-04-18 20:34:03 +02:00
|
|
|
final List<Map<dynamic, dynamic>> childrenJson =
|
|
|
|
|
await _platform.invokeListMethod(
|
|
|
|
|
'getChildren',
|
|
|
|
|
{
|
2020-05-04 21:49:44 +02:00
|
|
|
'treeUri': basePath,
|
2020-04-18 20:34:03 +02:00
|
|
|
'parentId': parentId,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return childrenJson
|
|
|
|
|
.map((childJson) => Document.fromJson(childJson))
|
|
|
|
|
.toList();
|
|
|
|
|
}
|
2020-04-18 23:41:08 +02:00
|
|
|
|
2020-05-04 21:49:44 +02:00
|
|
|
@override
|
|
|
|
|
Future<String> getIdentifier(String parentId, String fileName) async {
|
2020-04-18 23:41:08 +02:00
|
|
|
return await _platform.invokeMethod(
|
2020-05-04 21:49:44 +02:00
|
|
|
'getUriByName',
|
2020-04-18 23:41:08 +02:00
|
|
|
{
|
2020-05-04 21:49:44 +02:00
|
|
|
'treeUri': basePath,
|
|
|
|
|
'parentId': parentId,
|
|
|
|
|
'fileName': fileName,
|
2020-04-18 23:41:08 +02:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-04 21:49:44 +02:00
|
|
|
@override
|
|
|
|
|
Future<String> readDocument(String id) async {
|
2020-04-19 18:37:16 +02:00
|
|
|
return await _platform.invokeMethod(
|
2020-05-04 21:49:44 +02:00
|
|
|
'readFile',
|
2020-04-19 18:37:16 +02:00
|
|
|
{
|
2020-05-04 21:49:44 +02:00
|
|
|
'treeUri': basePath,
|
|
|
|
|
'id': id,
|
2020-04-19 18:37:16 +02:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-04 21:49:44 +02:00
|
|
|
@override
|
|
|
|
|
Future<String> readDocumentByName(String parentId, String fileName) async {
|
2020-04-18 23:41:08 +02:00
|
|
|
return await _platform.invokeMethod(
|
|
|
|
|
'readFileByName',
|
|
|
|
|
{
|
2020-05-04 21:49:44 +02:00
|
|
|
'treeUri': basePath,
|
2020-04-18 23:41:08 +02:00
|
|
|
'parentId': parentId,
|
|
|
|
|
'fileName': fileName,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-04 21:49:44 +02:00
|
|
|
@override
|
|
|
|
|
Future<void> writeDocumentByName(
|
|
|
|
|
String parentId, String fileName, String contents) async {
|
2020-04-18 23:41:08 +02:00
|
|
|
await _platform.invokeMethod(
|
|
|
|
|
'writeFileByName',
|
|
|
|
|
{
|
2020-05-04 21:49:44 +02:00
|
|
|
'treeUri': basePath,
|
2020-04-18 23:41:08 +02:00
|
|
|
'parentId': parentId,
|
|
|
|
|
'fileName': fileName,
|
2020-05-04 21:49:44 +02:00
|
|
|
'content': contents,
|
2020-04-18 23:41:08 +02:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-04-18 20:34:03 +02:00
|
|
|
}
|