ios: Allow the app to be run

* Implemented a fake gitInit which just created the folder for now
* AndroidDeviceInfo doesn't exist on ios
This commit is contained in:
Vishesh Handa
2019-05-20 20:32:26 +02:00
parent be4e6f32eb
commit b07df91aa0
2 changed files with 34 additions and 18 deletions

View File

@ -15,21 +15,33 @@ NSString* GetDirectoryOfType(NSSearchPathDirectory dir) {
methodChannelWithName:@"gitjournal.io/git" binaryMessenger:controller];
[gitChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
NSString* filesDir = [self getApplicationDocumentsDirectory];
if ([@"getBaseDirectory" isEqualToString:call.method]) {
/*
int batteryLevel = [weakSelf getBatteryLevel];
NSString *method = [call method];
NSDictionary *arguments = [call arguments];
if (batteryLevel == -1) {
result([FlutterError errorWithCode:@"UNAVAILABLE"
message:@"Battery info unavailable"
details:nil]);
} else {
result(@(batteryLevel));
}
*/
NSString* filesDir = [self getApplicationDocumentsDirectory];
if ([@"getBaseDirectory" isEqualToString:method]) {
result(filesDir);
} else {
}
else if ([@"gitInit" isEqualToString:method]) {
NSString *folderName = arguments[@"folderName"];
NSArray *components = [NSArray arrayWithObjects:filesDir, folderName, nil];
NSString* dirPath = [NSString pathWithComponents:components];
NSError *error;
if (![[NSFileManager defaultManager] createDirectoryAtPath:dirPath
withIntermediateDirectories:NO
attributes:nil
error:&error])
{
NSLog(@"Create directory error: %@", error);
result([FlutterError errorWithCode:@"FAILED"
message:@"Failed to perform fake gitInit" details:nil]);
}
else {
result(@YES);
}
}
else {
result(FlutterMethodNotImplemented);
}
}];

View File

@ -30,12 +30,16 @@ class JournalApp extends StatelessWidget {
// Check if in debugMode or not a real device
//
assert(JournalApp.isInDebugMode = true);
try {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
if (androidInfo.isPhysicalDevice == false) {
print("Not running in a physcial device");
JournalApp.isInDebugMode = true;
}
} catch (e) {
print(e);
}
if (JournalApp.isInDebugMode) {
JournalApp.analytics.setAnalyticsCollectionEnabled(false);