mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-03 05:59:37 +08:00
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:
@ -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);
|
||||
}
|
||||
}];
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user