| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | import 'dart:io'; | 
					
						
							|  |  |  | import 'package:app_flowy/startup/startup.dart'; | 
					
						
							|  |  |  | import 'package:path_provider/path_provider.dart'; | 
					
						
							|  |  |  | import 'package:flowy_sdk/flowy_sdk.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-04 22:24:32 +08:00
										 |  |  | class InitRustSDKTask extends LaunchTask { | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  |   @override | 
					
						
							|  |  |  |   LaunchTaskType get type => LaunchTaskType.dataProcessing; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @override | 
					
						
							| 
									
										
										
										
											2021-07-12 23:27:58 +08:00
										 |  |  |   Future<void> initialize(LaunchContext context) async { | 
					
						
							| 
									
										
										
										
											2022-02-19 23:19:33 +08:00
										 |  |  |     switch (context.env) { | 
					
						
							| 
									
										
										
										
											2022-02-20 16:34:15 +08:00
										 |  |  |       case IntegrationMode.release: | 
					
						
							|  |  |  |         Directory documentsDir = await getApplicationDocumentsDirectory(); | 
					
						
							|  |  |  |         return Directory('${documentsDir.path}/flowy').create().then( | 
					
						
							| 
									
										
										
										
											2022-02-20 08:35:52 +08:00
										 |  |  |           (Directory directory) async { | 
					
						
							|  |  |  |             await context.getIt<FlowySDK>().init(directory); | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2022-02-20 16:34:15 +08:00
										 |  |  |       case IntegrationMode.develop: | 
					
						
							|  |  |  |         Directory documentsDir = await getApplicationDocumentsDirectory(); | 
					
						
							|  |  |  |         return Directory('${documentsDir.path}/flowy_dev').create().then( | 
					
						
							| 
									
										
										
										
											2022-02-19 23:19:33 +08:00
										 |  |  |           (Directory directory) async { | 
					
						
							|  |  |  |             await context.getIt<FlowySDK>().init(directory); | 
					
						
							|  |  |  |           }, | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2022-02-20 16:34:15 +08:00
										 |  |  |       case IntegrationMode.test: | 
					
						
							|  |  |  |         final directory = Directory("${Directory.current.path}/.sandbox"); | 
					
						
							|  |  |  |         await context.getIt<FlowySDK>().init(directory); | 
					
						
							| 
									
										
										
										
											2022-02-19 23:19:33 +08:00
										 |  |  |         break; | 
					
						
							|  |  |  |       default: | 
					
						
							|  |  |  |         assert(false, 'Unsupported env'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-06-19 23:41:19 +08:00
										 |  |  | } |