Skip to content

Commit

Permalink
Merge pull request #31 from moesaid/stage
Browse files Browse the repository at this point in the history
0.0.8
  • Loading branch information
moesaid authored Mar 10, 2024
2 parents 65a3fc3 + c348c7e commit 221740b
Show file tree
Hide file tree
Showing 37 changed files with 2,035 additions and 367 deletions.
Binary file added assets/images/bloc_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/getx_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 7 additions & 44 deletions lib/App/Controllers/Dashboard/dashboard_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import 'package:flutterpp/App/Services/Project/wiki_services.dart';
import 'package:flutterpp/App/Services/Team/team_member_services.dart';
import 'package:flutterpp/App/Services/Team/team_services.dart';
import 'package:flutterpp/App/Views/Global/build_overlay.dart';
import 'package:flutterpp/App/Views/Global/build_snackbar.dart';
import 'package:flutterpp/Config/app_gradients.dart';
import 'package:flutterpp/Helpers/colors_helper.dart';
import 'package:flutterpp/Routes/app_pages.dart';
Expand Down Expand Up @@ -142,51 +141,15 @@ class DashboardController extends GetxController {
}

// create project
Future<void> createProject({required Map formData}) async {
// make sure icon and colors are selected
if (_selectedSVG.value.isEmpty || _selectedColors.isEmpty) {
BuildSnackBar(
title: 'Error',
message: 'Please select icon and colors',
).error();
return;
}

// form data
String title = formData['title'];
String description = formData['description'];

await Get.showOverlay(
loadingWidget: const BuildOverlay(),
asyncFunction: () async {
ProjectModel? project = await _projectServices.createProject(
teamId: team.id!,
color1: ColorHelper.colorToHex(_selectedColors.first),
color2: ColorHelper.colorToHex(_selectedColors.last),
icon: _selectedSVG.value,
title: title,
description: description,
);

if (project == null) return;

_projects.add(project);

// if no active project set active project
if (activeProject.id == null) {
await updateActiveProject(project);
}
Future<void> onCreateProject({required ProjectModel project}) async {
_projects.add(project);

update();
// if no active project set active project
if (activeProject.id == null) {
await updateActiveProject(project);
}

if (project.id == null) return;
await _wikiServices.createWiki(
title: 'default',
projectId: project.id!,
document: _wikiServices.getDefultDocument,
);
},
);
update();

reorderProjectList();

Expand Down
14 changes: 13 additions & 1 deletion lib/App/Controllers/Global/app_update_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ class AppUpdateController extends GetxController {
final _url = ''.obs;
String get url => _url.value;

final _updateAvailable = false.obs;
bool get updateAvailable => _updateAvailable.value;

@override
Future<void> onInit() async {
await _fetchCurrentVersion();
await _fetchApi();
await _checkIfUpdateAvailable();
_updateLoading(false);

AppPrint.print({
Expand Down Expand Up @@ -87,7 +91,6 @@ class AppUpdateController extends GetxController {
throw UnsupportedError("Unsupported platform");
}

// https://github.com/moesaid/FlutterPP_Public/releases/download/0.0.4/FlutterPP-macos-0.0.4.dmg
return "https://github.com/moesaid/FlutterPP_Public/releases/download/$val/FlutterPP-$operatingSystem-$val.$platformExt";
}

Expand All @@ -100,4 +103,13 @@ class AppUpdateController extends GetxController {
launchUrl(url);
}
}

// check if update available
_checkIfUpdateAvailable() {
if (currentVersion.isEmpty || lastVersion.isEmpty) return;

if (currentVersion != lastVersion) {
_updateAvailable.value = true;
}
}
}
2 changes: 0 additions & 2 deletions lib/App/Controllers/Mockup/mockup_single_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,6 @@ class MockupSingleController extends GetxController {
await MockupExportServices().export(items: _mockup.value.jsonData!);
},
loadingWidget: const BuildTimeOverlay(),
opacity: 0.8,
opacityColor: Get.theme.colorScheme.background,
);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:flutter_platform_alert/flutter_platform_alert.dart';
import 'package:flutterpp/App/Controllers/Project/Single/project_single_controller.dart';
import 'package:flutterpp/App/Enums/state_manegment_enum.dart';
import 'package:flutterpp/App/Models/build_option_model.dart';
import 'package:flutterpp/App/Models/model_config_model.dart';
import 'package:flutterpp/App/Providers/Cmd/cmd_flutter_provider.dart';
import 'package:flutterpp/App/Providers/FilesGen/Json/json_to_freezed_class_provider.dart';
import 'package:flutterpp/App/Providers/FilesGen/build_runner_provider.dart';
import 'package:flutterpp/App/Services/Cmd/cmd_init_bloc_services.dart';
import 'package:flutterpp/App/Services/Cmd/cmd_init_getx_mvc_services.dart';
import 'package:flutterpp/App/Services/Cmd/cmd_read_create_dir_services.dart';
import 'package:flutterpp/App/Services/Project/project_model_services.dart';
Expand All @@ -22,6 +24,8 @@ class ProjectSingleCodeGenController extends GetxController {
final CmdInitGetxMvcServices _cmdInitGetxMvcServices =
CmdInitGetxMvcServices();

final CmdInitBlocServices _cmdInitBlocServices = CmdInitBlocServices();

final JsonToFreezedClassProvider _jsonToFreezedClassProvider =
JsonToFreezedClassProvider();
final CmdFlutterProvider _cmdF = CmdFlutterProvider();
Expand Down Expand Up @@ -314,6 +318,18 @@ class ProjectSingleCodeGenController extends GetxController {

// generate code
Future<void> generateCode(BuildOptionModel option) async {
// must have at least one option true
if (option.models == null || !option.models!) {
FlutterPlatformAlert.playAlertSound();
FlutterPlatformAlert.showAlert(
windowTitle: 'Oops!',
text: 'models must be selected to generate code!',
alertStyle: AlertButtonStyle.ok,
iconStyle: IconStyle.error,
);
return;
}

FlutterPlatformAlert.playAlertSound();
CustomButton res = await FlutterPlatformAlert.showCustomAlert(
windowTitle: 'note!'.toUpperCase(),
Expand All @@ -324,6 +340,11 @@ class ProjectSingleCodeGenController extends GetxController {

if (res == CustomButton.negativeButton) return;

// project State
StateManegmentEnum state = useController.project.stateManagement != null
? StateManegmentEnum.fromString(useController.project.stateManagement!)
: StateManegmentEnum.getx;

Get.showOverlay(
asyncFunction: () async {
for (var item in _models) {
Expand All @@ -334,18 +355,35 @@ class ProjectSingleCodeGenController extends GetxController {
);
}

await _cmdInitGetxMvcServices.createCase(
useController.projectLocalPath,
item.modelName!,
isCrud: item.isCrud,
option: option,
await state.when(
type: state,
getx: () async {
await _cmdInitGetxMvcServices.createCase(
useController.projectLocalPath,
item.modelName!,
isCrud: item.isCrud,
option: option,
);
},

// bloc
bloc: () async {
await _cmdInitBlocServices.createCase(
useController.projectLocalPath,
item.modelName!,
isCrud: item.isCrud,
option: option,
);
},
);
}

// run build runner
await _cmdBuild.createBuildYaml(useController.projectLocalPath);
await _cmdF.runDartCommand(useController.projectLocalPath,
['run', 'build_runner', 'build', '--delete-conflicting-outputs']);
await _cmdF.runDartCommand(
useController.projectLocalPath,
['run', 'build_runner', 'build', '--delete-conflicting-outputs'],
);

await checkModelDiff();
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'package:flutterpp/App/Controllers/Project/Single/project_single_controller.dart';
import 'package:flutterpp/App/Enums/state_manegment_enum.dart';
import 'package:flutterpp/App/Services/Cmd/cmd_init_bloc_services.dart';
import 'package:flutterpp/App/Services/Cmd/cmd_init_getx_mvc_services.dart';
import 'package:flutterpp/App/Views/Global/build_overlay.dart';
import 'package:flutterpp/App/Views/Global/build_time_overlay.dart';
import 'package:flutterpp/Config/app_print.dart';
import 'package:get/get.dart';

class ProjectSingleConfigController extends GetxController {
final CmdInitGetxMvcServices _cmd = CmdInitGetxMvcServices();
final CmdInitGetxMvcServices _getxCmd = CmdInitGetxMvcServices();
final CmdInitBlocServices _blocCmd = CmdInitBlocServices();
late ProjectSingleController useController;

final _isLoading = true.obs;
Expand All @@ -31,10 +34,22 @@ class ProjectSingleConfigController extends GetxController {
try {
await Get.showOverlay(
asyncFunction: () async {
await _cmd.init(useController.projectLocalPath);
// getx
if (useController.project.stateManagement == null ||
useController.project.stateManagement ==
StateManegmentEnum.getx.name) {
await _getxCmd.init(useController.projectLocalPath);
}

// bloc
if (useController.project.stateManagement ==
StateManegmentEnum.bloc.name) {
await _blocCmd.init(useController.projectLocalPath);
}

await useController.checkIfFlutterPPProject();
},
loadingWidget: const BuildOverlay(),
loadingWidget: const BuildTimeOverlay(),
);
} catch (e) {
AppPrint.printError('Error starting project config: $e');
Expand Down
42 changes: 36 additions & 6 deletions lib/App/Controllers/Project/Single/project_single_controller.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import 'dart:math';

import 'package:flutterpp/App/Controllers/Dashboard/dashboard_controller.dart';
import 'package:flutterpp/App/Enums/state_manegment_enum.dart';
import 'package:flutterpp/App/Models/project_local_path_model.dart';
import 'package:flutterpp/App/Models/project_model.dart';
import 'package:flutterpp/App/Services/Cmd/cmd_init_bloc_services.dart';
import 'package:flutterpp/App/Services/Cmd/cmd_init_getx_mvc_services.dart';
import 'package:flutterpp/App/Services/Cmd/cmd_read_create_dir_services.dart';
import 'package:flutterpp/App/Services/Project/create_load_project_path.dart';
import 'package:flutterpp/App/Services/Project/project_services.dart';
import 'package:flutterpp/App/Views/Global/build_overlay.dart';
import 'package:flutterpp/App/Views/Global/build_time_overlay.dart';
import 'package:flutterpp/Routes/app_pages.dart';
import 'package:flutterpp/Storage/local_flutter_path.dart';
import 'package:flutterpp/Storage/projects_local_path_storage.dart';
Expand All @@ -23,6 +25,7 @@ class ProjectSingleController extends GetxController {

final CmdInitGetxMvcServices _cmdInitGetxMvcServices =
CmdInitGetxMvcServices();
final CmdInitBlocServices _cmdInitBlocServices = CmdInitBlocServices();

final _isLoading = true.obs;
bool get isLoading => _isLoading.value;
Expand Down Expand Up @@ -125,12 +128,10 @@ class ProjectSingleController extends GetxController {

Get.showOverlay(
asyncFunction: () async {
String? path = await _cmdInitGetxMvcServices.createProject(
_project.value.title ?? 'NewFlutterPP${Random().nextInt(100)}',
String? path = await createProjectPathBasedOnState(
type: project.stateManagement,
);

if (path == null) return;

// save project path
await _projectLocalPathStorage.write(
project: ProjectLocalPathModel(
Expand All @@ -145,7 +146,7 @@ class ProjectSingleController extends GetxController {
// check if project is flutterpp project
await checkIfFlutterPPProject();
},
loadingWidget: const BuildOverlay(),
loadingWidget: const BuildTimeOverlay(),
);
}

Expand Down Expand Up @@ -178,4 +179,33 @@ class ProjectSingleController extends GetxController {

return true;
}

// create project path based on state type
Future<String?> createProjectPathBasedOnState({String? type}) async {
if (type == null || type.isEmpty) return null;

StateManegmentEnum state = StateManegmentEnum.fromString(type);

String path = '';

await state.when(
type: state,
getx: () async {
String? localPath = await _cmdInitGetxMvcServices.createProject(
_project.value.title ?? 'NewFlutterPP${Random().nextInt(100)}',
);

if (localPath != null) path = localPath;
},
bloc: () async {
String? localPath = await _cmdInitBlocServices.createProject(
_project.value.title ?? 'NewFlutterPP${Random().nextInt(100)}',
);

if (localPath != null) path = localPath;
},
);

return path;
}
}
Loading

0 comments on commit 221740b

Please sign in to comment.