chore: rename some enum

This commit is contained in:
appflowy 2022-02-20 16:34:15 +08:00
parent 22742c904b
commit e3d9d4c42a
2 changed files with 19 additions and 22 deletions

View File

@ -52,7 +52,7 @@ class FlowyRunner {
Future<void> initGetIt( Future<void> initGetIt(
GetIt getIt, GetIt getIt,
IntegrationEnv env, IntegrationMode env,
EntryPoint f, EntryPoint f,
) async { ) async {
getIt.registerFactory<EntryPoint>(() => f); getIt.registerFactory<EntryPoint>(() => f);
@ -65,7 +65,7 @@ Future<void> initGetIt(
class LaunchContext { class LaunchContext {
GetIt getIt; GetIt getIt;
IntegrationEnv env; IntegrationMode env;
LaunchContext(this.getIt, this.env); LaunchContext(this.getIt, this.env);
} }
@ -83,7 +83,7 @@ abstract class LaunchTask {
class AppLauncher { class AppLauncher {
List<LaunchTask> tasks; List<LaunchTask> tasks;
IntegrationEnv env; IntegrationMode env;
GetIt getIt; GetIt getIt;
AppLauncher(this.env, this.getIt) : tasks = List.from([]); AppLauncher(this.env, this.getIt) : tasks = List.from([]);
@ -100,26 +100,26 @@ class AppLauncher {
} }
} }
enum IntegrationEnv { enum IntegrationMode {
develop, develop,
release, release,
test, test,
} }
extension IntegrationEnvExt on IntegrationEnv { extension IntegrationEnvExt on IntegrationMode {
bool isTest() { bool isTest() {
return this == IntegrationEnv.test; return this == IntegrationMode.test;
} }
} }
IntegrationEnv integrationEnv() { IntegrationMode integrationEnv() {
if (Platform.environment.containsKey('FLUTTER_TEST')) { if (Platform.environment.containsKey('FLUTTER_TEST')) {
return IntegrationEnv.test; return IntegrationMode.test;
} }
if (kReleaseMode) { if (kReleaseMode) {
return IntegrationEnv.release; return IntegrationMode.release;
} }
return IntegrationEnv.develop; return IntegrationMode.develop;
} }

View File

@ -10,29 +10,26 @@ class InitRustSDKTask extends LaunchTask {
@override @override
Future<void> initialize(LaunchContext context) async { Future<void> initialize(LaunchContext context) async {
switch (context.env) { switch (context.env) {
case IntegrationEnv.develop: case IntegrationMode.release:
Directory directory = await getApplicationDocumentsDirectory(); Directory documentsDir = await getApplicationDocumentsDirectory();
return Directory('${directory.path}/flowy_dev').create().then( return Directory('${documentsDir.path}/flowy').create().then(
(Directory directory) async { (Directory directory) async {
await context.getIt<FlowySDK>().init(directory); await context.getIt<FlowySDK>().init(directory);
}, },
); );
case IntegrationEnv.release: case IntegrationMode.develop:
Directory directory = await getApplicationDocumentsDirectory(); Directory documentsDir = await getApplicationDocumentsDirectory();
return Directory('${directory.path}/flowy').create().then( return Directory('${documentsDir.path}/flowy_dev').create().then(
(Directory directory) async { (Directory directory) async {
await context.getIt<FlowySDK>().init(directory); await context.getIt<FlowySDK>().init(directory);
}, },
); );
case IntegrationEnv.test: case IntegrationMode.test:
await context.getIt<FlowySDK>().init(testWorkingDirectory()); final directory = Directory("${Directory.current.path}/.sandbox");
await context.getIt<FlowySDK>().init(directory);
break; break;
default: default:
assert(false, 'Unsupported env'); assert(false, 'Unsupported env');
} }
} }
Directory testWorkingDirectory() {
return Directory("${Directory.current.path}/.sandbox");
}
} }