Skip to content

Commit

Permalink
added import from code, small ui improvements and code generation sho…
Browse files Browse the repository at this point in the history
…uld work better now
  • Loading branch information
oxelf committed Sep 10, 2024
1 parent 803a4e5 commit 90e3523
Show file tree
Hide file tree
Showing 34 changed files with 720 additions and 566 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"file_picker","path":"/Users/joscha/.pub-cache/hosted/pub.dev/file_picker-8.1.2/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/joscha/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"url_launcher_ios","path":"/Users/joscha/.pub-cache/hosted/pub.dev/url_launcher_ios-6.3.1/","native_build":true,"dependencies":[]}],"android":[{"name":"file_picker","path":"/Users/joscha/.pub-cache/hosted/pub.dev/file_picker-8.1.2/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/joscha/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.22/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/joscha/.pub-cache/hosted/pub.dev/path_provider_android-2.2.10/","native_build":true,"dependencies":[]},{"name":"url_launcher_android","path":"/Users/joscha/.pub-cache/hosted/pub.dev/url_launcher_android-6.3.9/","native_build":true,"dependencies":[]}],"macos":[{"name":"file_picker","path":"/Users/joscha/.pub-cache/hosted/pub.dev/file_picker-8.1.2/","native_build":false,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/joscha/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"url_launcher_macos","path":"/Users/joscha/.pub-cache/hosted/pub.dev/url_launcher_macos-3.2.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"file_picker","path":"/Users/joscha/.pub-cache/hosted/pub.dev/file_picker-8.1.2/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/joscha/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"url_launcher_linux","path":"/Users/joscha/.pub-cache/hosted/pub.dev/url_launcher_linux-3.2.0/","native_build":true,"dependencies":[]}],"windows":[{"name":"file_picker","path":"/Users/joscha/.pub-cache/hosted/pub.dev/file_picker-8.1.2/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/joscha/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"url_launcher_windows","path":"/Users/joscha/.pub-cache/hosted/pub.dev/url_launcher_windows-3.1.2/","native_build":true,"dependencies":[]}],"web":[{"name":"file_picker","path":"/Users/joscha/.pub-cache/hosted/pub.dev/file_picker-8.1.2/","dependencies":[]},{"name":"url_launcher_web","path":"/Users/joscha/.pub-cache/hosted/pub.dev/url_launcher_web-2.3.3/","dependencies":[]}]},"dependencyGraph":[{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2024-09-10 09:35:53.300015","version":"3.22.3"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"file_picker","path":"/Users/joscha/.pub-cache/hosted/pub.dev/file_picker-8.1.2/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/joscha/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"url_launcher_ios","path":"/Users/joscha/.pub-cache/hosted/pub.dev/url_launcher_ios-6.3.1/","native_build":true,"dependencies":[]}],"android":[{"name":"file_picker","path":"/Users/joscha/.pub-cache/hosted/pub.dev/file_picker-8.1.2/","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/joscha/.pub-cache/hosted/pub.dev/flutter_plugin_android_lifecycle-2.0.22/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/joscha/.pub-cache/hosted/pub.dev/path_provider_android-2.2.10/","native_build":true,"dependencies":[]},{"name":"url_launcher_android","path":"/Users/joscha/.pub-cache/hosted/pub.dev/url_launcher_android-6.3.9/","native_build":true,"dependencies":[]}],"macos":[{"name":"file_picker","path":"/Users/joscha/.pub-cache/hosted/pub.dev/file_picker-8.1.2/","native_build":false,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/joscha/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"url_launcher_macos","path":"/Users/joscha/.pub-cache/hosted/pub.dev/url_launcher_macos-3.2.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"file_picker","path":"/Users/joscha/.pub-cache/hosted/pub.dev/file_picker-8.1.2/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/joscha/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"url_launcher_linux","path":"/Users/joscha/.pub-cache/hosted/pub.dev/url_launcher_linux-3.2.0/","native_build":true,"dependencies":[]}],"windows":[{"name":"file_picker","path":"/Users/joscha/.pub-cache/hosted/pub.dev/file_picker-8.1.2/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/joscha/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"url_launcher_windows","path":"/Users/joscha/.pub-cache/hosted/pub.dev/url_launcher_windows-3.1.2/","native_build":true,"dependencies":[]}],"web":[{"name":"file_picker","path":"/Users/joscha/.pub-cache/hosted/pub.dev/file_picker-8.1.2/","dependencies":[]},{"name":"url_launcher_web","path":"/Users/joscha/.pub-cache/hosted/pub.dev/url_launcher_web-2.3.3/","dependencies":[]}]},"dependencyGraph":[{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2024-09-10 18:47:07.872963","version":"3.22.3"}
24 changes: 24 additions & 0 deletions .idea/libraries/Dart_Packages.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,14 @@ how to solve this:
- click open again

### Roadmap
- [x] Case statement
- [ ] Resizing of blocks inside an if or case block.
- [ ] copy paste
- [ ] Control - Z | Reverse previous action
- [ ] Custom Appbar | Menubar
- [ ] Floating Editing Panel
- [ ] Floating tree view panel
- [x] Canvas
- [x] Zoom to fit
- [ ] Home Page (see previous projects)
- [ ] Import Structogram from cpp code
- [ ] UML Diagrams
- [ ] Database Diagrams
- [x] Multilanguage
- [x] Save structogram as json
- [x] Import Structogram from json
- [x] Add struct inside for the following blocks: function, if, forLoop, whileLoop, do while loop



### Run locally
Expand Down
Binary file removed assets/libs/cpp.dylib
Binary file not shown.
3 changes: 3 additions & 0 deletions l10n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
21 changes: 21 additions & 0 deletions lib/context_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

extension ContextExtension on BuildContext {
AppLocalizations get l => AppLocalizations.of(this)!;
double get width => MediaQuery.of(this).size.width;
double get height => MediaQuery.of(this).size.height;
Orientation get orientation => MediaQuery.of(this).orientation;
ThemeData get t => Theme.of(this);
String get locale => Localizations.localeOf(this).languageCode;
bool get isDark => Theme.of(this).brightness == Brightness.dark;
String os() {
if (kIsWeb) return "web";
if (Platform.isAndroid) return "android";
if (Platform.isIOS) return "ios";
return "web";
}
}
14 changes: 7 additions & 7 deletions assets/translation/de.json → lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
"caseStatement": "Fall Auswahl",
"whileLoop": "While Schleife",
"doWhileLoop": "Do While Schleife",
"StructType.loop": "Schleife",
"StructType.ifSelect": "Bedingte Verzweigung",
"StructType.instruction": "Anweisung",
"StructType.caseSelect": "Fall Auswahl",
"StructType.repeat": "Do While Schleife",
"StructType.function": "Funktion",
"loop": "Schleife",
"ifSelect": "Bedingte Verzweigung",
"caseSelect": "Fall Auswahl",
"repeat": "Do While Schleife",
"function": "Funktion",
"copy": "kopieren",
"paste": "einsetzen",
"delete": "löschen",
Expand All @@ -34,5 +33,6 @@
"english": "Englisch",
"german": "Deutsch",
"color": "Farbe",
"importFromCode": "Code importieren"
"importFromCode": "Code importieren",
"fillColor": "Hintergrundfarbe"
}
16 changes: 8 additions & 8 deletions assets/translation/en.json → lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"forLoop": "for loop",
"ifStatement": "if statement",
"instruction": "instruction",
"caseStatement": "case statement",
"whileLoop": "while loop",
"doWhileLoop": "do while loop",
"StructType.loop": "loop",
"StructType.ifSelect": "if statement",
"StructType.instruction": "instruction",
"StructType.caseSelect": "case statement",
"StructType.repeat": "do while loop",
"StructType.function": "function",
"loop": "loop",
"ifSelect": "if statement",
"instruction": "instruction",
"caseSelect": "case statement",
"repeat": "do while loop",
"function": "function",
"copy": "copy",
"paste": "paste",
"delete": "delete",
Expand All @@ -34,5 +33,6 @@
"english": "english",
"german": "german",
"color": "color",
"importFromCode": "import from code"
"importFromCode": "import from code",
"fillColor": "fill color"
}
8 changes: 3 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,18 @@
// }



import 'package:flutter/foundation.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:structogrammar/pages/main/main_page.dart';
import 'package:flutter_web_plugins/url_strategy.dart';
import 'package:structogrammar/riverpod/settings.dart';
import 'package:structogrammar/riverpod/translation.dart';


void main() {
usePathUrlStrategy();
WidgetsFlutterBinding.ensureInitialized();
if (kIsWeb) print("is web");
runApp(const ProviderScope( child: MainApp()));
}

Expand All @@ -92,14 +89,15 @@ class _MainAppState extends ConsumerState<MainApp> {
}
@override
Widget build(BuildContext context) {return MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
scrollBehavior: const MaterialScrollBehavior().copyWith(
dragDevices: PointerDeviceKind.values.toSet(),
),
theme: ThemeData(primaryColor: Colors.blue),
debugShowCheckedModeBanner: false,
home: MainPage(),
);

}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/models/struct.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ class Struct extends Equatable {
Map<String, dynamic> newData = additionalData ?? {};
newData["condition"] = condition;
for (int i = 0; i < trueSubStructs.length; i++) {
trueSubStructs[i].data["ifValue"] = true;
trueSubStructs[i].data["ifCondition"] = "true";
}
for (int i = 0; i < falseSubStructs.length; i++) {
falseSubStructs[i].data["ifValue"] = false;
falseSubStructs[i].data["ifCondition"] = "false";
}
//Struct trueStruct = Struct.instruction("do on true", additionalData: {"ifValue": true});
//Struct falseStruct = Struct.instruction("do on false", additionalData: {"ifValue": false});
//Struct trueStruct = Struct.instruction("do on true", additionalData: {"condition": true});
//Struct falseStruct = Struct.instruction("do on false", additionalData: {"condition": false});
return Struct(
id: generateUUID(),
type: StructType.ifSelect,
Expand Down
20 changes: 20 additions & 0 deletions lib/models/tree_node.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class TreeNode {
final String type;
final String data;
final String? condition;
final List<TreeNode> nodes;

TreeNode({required this.data,required this.type, required this.nodes, this.condition});

factory TreeNode.fromJson(Map<String, dynamic> json) {
List<TreeNode> nodes = [];
List<dynamic> jsonNodes = [];
if (json["nodes"] != null) {
jsonNodes = json["nodes"];
}
for (int i = 0; i < jsonNodes.length; i++) {
nodes.add(TreeNode.fromJson(jsonNodes[i]));
}
return TreeNode(type: json["type"] ?? "instruction", data: json["data"]?? "", nodes: nodes, condition: json["condition"]);
}
}
31 changes: 24 additions & 7 deletions lib/pages/main/edit_panel.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:structogrammar/context_extension.dart';
import 'package:structogrammar/models/struct.dart';
import 'package:structogrammar/riverpod/code_notifier.dart';
import 'package:structogrammar/riverpod/structs.dart';
import 'package:structogrammar/riverpod/translation.dart';
import 'package:structogrammar/widgets/property_section.dart';
import 'package:structogrammar/widgets/property_textfield.dart';

import '../../widgets/color_picker.dart';

class EditPanel extends ConsumerStatefulWidget {
const EditPanel({super.key});
Expand All @@ -16,12 +15,11 @@ class EditPanel extends ConsumerStatefulWidget {
}

class _EditPanelState extends ConsumerState<EditPanel> {
List<String> ignoreProps = ["ifValue", "dragging", "size", "startPosition", "loopType", "case"];
List<String> ignoreProps = ["ifCondition", "dragging", "size", "startPosition", "loopType", "case"];

@override
Widget build(BuildContext context) {
var currentStruct = ref.watch(currentStructPod);
var translations = ref.watch(translationsPod);
return (currentStruct == null)
? Center(
child: Text("Select something to edit"),
Expand All @@ -31,11 +29,11 @@ class _EditPanelState extends ConsumerState<EditPanel> {
Row(
children: [
SizedBox(width: 8,),
Text(translations[currentStruct.type.toString()] ?? currentStruct.type.toString(), style: TextStyle(fontWeight: FontWeight.bold),),
Text(translateStructType(context, currentStruct.type), style: TextStyle(fontWeight: FontWeight.bold),),
],
),
Divider(),
PropertySectionBuilder(data: currentStruct.data, onChanged: (data) {
PropertySectionBuilder(data: currentStruct.data, structType: currentStruct.type, onChanged: (data) {
ref.read(structsPod.notifier).editStructData(currentStruct.id, data);
if (ref
.read(structsPod.notifier)
Expand All @@ -49,3 +47,22 @@ class _EditPanelState extends ConsumerState<EditPanel> {
);
}
}

String translateStructType(BuildContext context, StructType type) {
switch (type) {
case StructType.repeat:
return context.l.repeat;
case StructType.caseSelect:
return context.l.caseSelect;
case StructType.ifSelect:
return context.l.ifSelect;
case StructType.loop:
return context.l.loop;
case StructType.function:
return context.l.function;
case StructType.tryBlock:
return "try";
default:
return context.l.instruction;
}
}
Loading

0 comments on commit 90e3523

Please sign in to comment.