Skip to content

Commit

Permalink
Merge pull request #29 from moesaid/stage
Browse files Browse the repository at this point in the history
0.0.7
  • Loading branch information
moesaid authored Mar 4, 2024
2 parents fe368e4 + fb4de04 commit 65a3fc3
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 7 deletions.
10 changes: 8 additions & 2 deletions lib/App/Controllers/Dashboard/dashboard_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,17 @@ class DashboardController extends GetxController {
ProjectModel? item = _activeProjectStorage.read();

// if null add first project to active project
item ??= await _activeProjectStorage.write(_projects.first);
if (item == null) {
await _activeProjectStorage.write(_projects.first);

_activeProject.value = item;
item = _activeProjectStorage.read();
}

_activeProject.value = item ?? ProjectModel();

reorderProjectList();

update();
}

// update active project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,17 @@ class ProjectSingleCodeGenController extends GetxController {
List<EdgeInput> nextItems = [];

if (item.relations != null && item.relations!.isNotEmpty) {
if (item.relations == null || item.relations!.isEmpty) continue;

for (var relation in item.relations!) {
// get relation model id
String? relationModelId =
_models.firstWhere((el) => el.modelName == relation.name).id;
String? relationModelId = _models
.firstWhereOrNull((el) => el.modelName == relation.name)
?.id;

if (relationModelId == null) continue;

nextItems.add(EdgeInput(outcome: relationModelId!));
nextItems.add(EdgeInput(outcome: relationModelId));
}
}

Expand Down Expand Up @@ -195,6 +200,18 @@ class ProjectSingleCodeGenController extends GetxController {
return;
}

// if name already exists
if (_models.any((el) => el.modelName == _tempModel.value.modelName)) {
FlutterPlatformAlert.playAlertSound();
FlutterPlatformAlert.showAlert(
windowTitle: 'Oops!',
text: 'Model name already exists!',
alertStyle: AlertButtonStyle.ok,
iconStyle: IconStyle.error,
);
return;
}

Get.back();

_isLoading.value = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutterpp/App/Controllers/Dashboard/dashboard_controller.dart';
import 'package:flutterpp/App/Models/project_model.dart';
import 'package:flutterpp/App/Views/Pages/Project/Widgets/build_project_avatar.dart';
import 'package:flutterpp/Config/app_print.dart';
import 'package:flutterpp/Helpers/colors_helper.dart';
import 'package:get/get.dart';
import 'package:sizer/sizer.dart';
Expand All @@ -20,6 +21,10 @@ class BuildDashboardProjectItem extends StatelessWidget {

@override
Widget build(BuildContext context) {
AppPrint.print({
'item': item.id,
'active': controller.activeProject.id,
});
return Stack(
children: [
InkWell(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutterpp/App/Views/Global/buiuld_dialog.dart';
import 'package:flutterpp/App/Views/Pages/Mockup/Widgets/Create/Sidebar/build_pick_color.dart';
import 'package:flutterpp/Helpers/colors_helper.dart';
import 'package:flutterpp/Helpers/text_helper.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:get/get.dart';
import 'package:sizer/sizer.dart';

Expand All @@ -20,8 +21,10 @@ class BuildCreateOrEditSheet extends StatelessWidget {

@override
Widget build(BuildContext context) {
var formKey = GlobalKey<FormBuilderState>();
return SizedBox.expand(
child: FormBuilder(
key: formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
Expand Down Expand Up @@ -64,7 +67,12 @@ class BuildCreateOrEditSheet extends StatelessWidget {
),
SizedBox(width: 5.sp),
FilledButton(
onPressed: () => controller.createProjectModel(),
onPressed: () {
// validate the form
if (formKey.currentState!.saveAndValidate()) {
controller.createProjectModel();
}
},
child: Text(
'Save'.toUpperCase(),
),
Expand All @@ -90,6 +98,10 @@ class BuildCreateOrEditSheet extends StatelessWidget {
labelText: 'Model Name',
hintText: 'Enter model name',
),
validator: FormBuilderValidators.compose([
FormBuilderValidators.required(),
FormBuilderValidators.maxWordsCount(1)
]),
onChanged: (value) {
controller.updateTempModel(
ModelConfigModel(modelName: value),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutterpp
description: A new Flutter project.
publish_to: "none"
version: 0.0.6
version: 0.0.7
environment:
sdk: ">=2.18.6 <3.0.0"

Expand Down

0 comments on commit 65a3fc3

Please sign in to comment.