Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #22 from Parabeac/release-1.1.0
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
x64Eddie committed Sep 15, 2020
2 parents 89ac757 + 1ec8936 commit 72ecbf2
Show file tree
Hide file tree
Showing 175 changed files with 2,377 additions and 899 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ out/
temp/
.DS_Store
TestingSketch
debug
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,18 @@ Depending on the type of layout to add alignment to we have various services to

![Parabeac Alignment Generation Service Animation](https://kindling-sketch.s3.amazonaws.com/parabeac-alignment-generation-service2.gif)

# How to contribute
Welcome! The best way to contribute to Parabeac is through pull requests, filing issues on Github, writing documentation & helping others in our Discord community. We are an early project, but like many other projects, helping with bugs that others have filed on Stack Overflow is extremely helpful. We recommend filing bugs & feature requests on the Github issue tracker. For more details make sure to check out our [wiki](https://github.com/Parabeac/open_source_prep/wiki).


# How to create & run Parabeac eggs
Parabeac eggs are essentially plugins that change the way a set of design elements are interpreted. A very simple example of this are 2 eggs that we created called NavBar & TabBar. Eggs are loaded into the project before the runtime of Parabeac-Core because unfortunately dart doesn't support [dynamic module loading](https://github.com/dart-lang/sdk/issues/10530).

You can also create your own eggs! By using our [Parabeac Egg Template](https://github.com/Parabeac/parabeac-egg-template) you can quickly define your own semantics and corresponding code generation which allows for the most flexible and robust export customization possible. You can also upload your eggs to our **_git-based marketplace for templates_** to help support the community going forward.

To add a Parabeac egg, download the egg and add it to the `parabeac-core/plugins` folder. When you run Parabeac-Core it will automatically grab & import the egg into the project.

# Get Started

Parabeac currently supports conversions from [Sketch](https://www.sketch.com) but is designed to support more platforms in the future.

### Dependencies

Expand Down Expand Up @@ -96,6 +104,9 @@ Follow these steps in order to run Parabeac Core on your local environment:
$dart parabeac.dart -p <Absolute Path To Design File> -n <ProjectName>
```

## Metrics
Parabeac-core keeps track of how many times it is run. Although we do not collect any personal information, you can turn off metrics at any time by creating the environment variable `PB_METRICS = "false"`.

# Running the exported code
### Requirement(s)

Expand All @@ -104,16 +115,9 @@ Follow these steps in order to run Parabeac Core on your local environment:
- Call the screen you want to view
- Execute `flutter run`

# How to contribute
Welcome! The best way to contribute to Parabeac is through pull requests, filing issues on Github, writing documentation & helping others in our Discord community. We are an early project, but like many other projects, helping with bugs that others have filed on Stack Overflow is extremely helpful. We recommend filing bugs & feature requests on the Github issue tracker. For more details make sure to check out our [wiki](https://github.com/Parabeac/open_source_prep/wiki).


# How to create & run Parabeac eggs
Parabeac eggs are essentially plugins that change the way a set of design elements are interpreted. A very simple example of this are 2 eggs that we created called NavBar & TabBar. Eggs are loaded into the project before the runtime of Parabeac-Core because unfortunately dart doesn't support [dynamic module loading](https://github.com/dart-lang/sdk/issues/10530).

You can also create your own eggs! By using our [Parabeac Egg Template](https://github.com/Parabeac/parabeac-egg-template) you can quickly define your own semantics and corresponding code generation which allows for the most flexible and robust export customization possible. You can also upload your eggs to our **_git-based marketplace for templates_** to help support the community going forward.
# Get Started

To add a Parabeac egg, download the egg and add it to the `parabeac-core/plugins` folder. When you run Parabeac-Core it will automatically grab & import the egg into the project.
Parabeac currently supports conversions from [Sketch](https://www.sketch.com) but is designed to support more platforms in the future.

# Upcoming & Known Issues

Expand Down
18 changes: 11 additions & 7 deletions lib/controllers/interpret.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import 'package:parabeac_core/controllers/main_info.dart';
import 'package:parabeac_core/generation/generators/pb_flutter_generator.dart';
import 'package:parabeac_core/generation/generators/pb_flutter_writer.dart';
import 'package:parabeac_core/design_logic/design_node.dart';
import 'package:parabeac_core/generation/generators/pb_widget_manager.dart';
import 'package:parabeac_core/input/entities/layers/abstract_layer.dart';
import 'package:parabeac_core/input/helper/sketch_node_tree.dart';
import 'package:parabeac_core/input/helper/sketch_page.dart';
import 'package:parabeac_core/input/helper/sketch_page_item.dart';
import 'package:parabeac_core/generation/prototyping/pb_prototype_linker_service.dart';
import 'package:parabeac_core/input/sketch/helper/sketch_node_tree.dart';
import 'package:parabeac_core/input/sketch/helper/sketch_page.dart';
import 'package:parabeac_core/input/sketch/helper/sketch_page_item.dart';
import 'package:parabeac_core/interpret_and_optimize/entities/inherited_scaffold.dart';
import 'package:parabeac_core/interpret_and_optimize/entities/pb_shared_master_node.dart';
import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_intermediate_node.dart';
Expand Down Expand Up @@ -38,12 +37,14 @@ class Interpret {
String projectName;
PBIntermediateTree _pb_intermediate_tree;
PBSymbolLinkerService _pbSymbolLinkerService;
PBPrototypeLinkerService _pbPrototypeLinkerService;
PBGenerationManager _generationManager;

void init(String projectName) {
log = Logger(runtimeType.toString());
this.projectName = projectName;
_interpret._pbSymbolLinkerService = PBSymbolLinkerService();
_interpret._pbPrototypeLinkerService = PBPrototypeLinkerService();
}

Future<PBIntermediateTree> interpretAndOptimize(SketchNodeTree tree) async {
Expand Down Expand Up @@ -165,6 +166,9 @@ class Interpret {
log.error(e.toString());
parentLayoutIntermediateNode = parentPreLayoutIntermediateNode;
}

parentLayoutIntermediateNode = await _pbPrototypeLinkerService
.linkPrototypeNodes(parentLayoutIntermediateNode);
var parentAlignIntermediateNode;
// print(
// 'Layout Generation Service executed in ${stopwatch.elapsedMilliseconds} milliseconds.');
Expand Down Expand Up @@ -192,7 +196,7 @@ class Interpret {
return parentAlignIntermediateNode;
}

Future<PBIntermediateNode> generateNonRootItem(SketchNode root) async {
Future<PBIntermediateNode> generateNonRootItem(DesignNode root) async {
var currentContext = PBContext(
jsonConfigurations:
MainInfo().configurations ?? MainInfo().defaultConfigs);
Expand Down
6 changes: 6 additions & 0 deletions lib/controllers/main_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ class MainInfo {
Directory cwd;
Map configurations;

/// Unique ID for the device running parabeac-core
String deviceId;

/// Name of the project
String projectName;

Map defaultConfigs = {
'default': {
'widgetStyle': 'Material',
Expand Down
4 changes: 2 additions & 2 deletions lib/controllers/sketch_controller.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:archive/archive_io.dart';
import 'package:parabeac_core/controllers/interpret.dart';
import 'package:parabeac_core/generation/flutter_project_builder/flutter_project_builder.dart';
import 'package:parabeac_core/input/helper/sketch_node_tree.dart';
import 'package:parabeac_core/input/services/input_design.dart';
import 'package:parabeac_core/input/sketch/helper/sketch_node_tree.dart';
import 'package:parabeac_core/input/sketch/services/input_design.dart';
import 'package:quick_log/quick_log.dart';
import 'dart:convert';
import 'dart:io';
Expand Down
11 changes: 11 additions & 0 deletions lib/design_logic/artboard.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:parabeac_core/design_logic/design_node.dart';
import 'package:parabeac_core/design_logic/group_node.dart';
import 'package:parabeac_core/design_logic/rect.dart';

abstract class PBArtboard extends DesignNode implements GroupNode {
var backgroundColor;
PBArtboard(this.backgroundColor, UUID, String name, bool isVisible,
Rect boundaryRectangle, String type, style, prototypeNode)
: super(UUID, name, isVisible, boundaryRectangle, type, style,
prototypeNode);
}
13 changes: 13 additions & 0 deletions lib/design_logic/color.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
abstract class Color {
Color(
this.alpha,
this.red,
this.green,
this.blue,
);

double alpha;
double red;
double green;
double blue;
}
7 changes: 7 additions & 0 deletions lib/design_logic/design_element.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:parabeac_core/design_logic/design_node.dart';
import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_intermediate_node.dart';

abstract class DesignElement extends DesignNode {
DesignElement() : super('', '', false, null, '', null, null);
}
25 changes: 25 additions & 0 deletions lib/design_logic/design_node.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:parabeac_core/design_logic/rect.dart';
import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_intermediate_node.dart';
import 'package:parabeac_core/interpret_and_optimize/helpers/pb_context.dart';

abstract class DesignNode {
DesignNode(
this.UUID,
this.name,
this.isVisible,
this.boundaryRectangle,
this.type,
this.style,
this.prototypeNodeUUID,
);

String UUID;
String name;
bool isVisible;
var boundaryRectangle;
String type;
var style;
String prototypeNodeUUID;

Future<PBIntermediateNode> interpretNode(PBContext currentContext);
}
7 changes: 7 additions & 0 deletions lib/design_logic/design_shape.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:parabeac_core/design_logic/design_element.dart';

@JsonSerializable()
abstract class DesignShape extends DesignElement {
DesignShape() : super();
}
10 changes: 10 additions & 0 deletions lib/design_logic/group_node.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:json_annotation/json_annotation.dart';

@JsonSerializable(nullable: true)
abstract class GroupNode {
GroupNode(
this.children,
);

List children;
}
9 changes: 9 additions & 0 deletions lib/design_logic/image.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:parabeac_core/design_logic/design_element.dart';

abstract class Image extends DesignElement {
Image(
this.imageReference,
) : super();

String imageReference;
}
11 changes: 11 additions & 0 deletions lib/design_logic/pb_shared_instance_node.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:parabeac_core/design_logic/design_node.dart';

abstract class PBSharedInstanceNodeDesign extends DesignNode {
String symbolID;
List parameters;

PBSharedInstanceNodeDesign(String UUID, String name, bool isVisible,
boundaryRectangle, String type, style, prototypeNode)
: super(UUID, name, isVisible, boundaryRectangle, type, style,
prototypeNode);
}
11 changes: 11 additions & 0 deletions lib/design_logic/pb_shared_master_node.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:parabeac_core/design_logic/design_node.dart';

abstract class PBSharedMasterNodeDesign extends DesignNode {
String symbolID;
List overriadableProperties;

PBSharedMasterNodeDesign(String UUID, String name, bool isVisible,
boundaryRectangle, String type, style, prototypeNode)
: super(UUID, name, isVisible, boundaryRectangle, type, style,
prototypeNode);
}
13 changes: 13 additions & 0 deletions lib/design_logic/rect.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
abstract class Rect {
Rect(
this.x,
this.y,
this.width,
this.height,
);

double x;
double y;
double width;
double height;
}
5 changes: 5 additions & 0 deletions lib/design_logic/star.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:parabeac_core/design_logic/design_shape.dart';

abstract class Star extends DesignShape {
Star();
}
7 changes: 7 additions & 0 deletions lib/design_logic/text.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:parabeac_core/design_logic/design_element.dart';

abstract class Text extends DesignElement {
Text(this.content) : super();

String content;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import 'package:archive/archive.dart';
import 'package:parabeac_core/controllers/main_info.dart';
import 'package:parabeac_core/generation/generators/pb_flutter_generator.dart';
import 'package:parabeac_core/generation/generators/pb_flutter_writer.dart';
import 'package:parabeac_core/generation/prototyping/pb_dest_holder.dart';
import 'package:parabeac_core/interpret_and_optimize/entities/inherited_scaffold.dart';
import 'package:parabeac_core/interpret_and_optimize/entities/pb_shared_instance.dart';
import 'package:parabeac_core/interpret_and_optimize/entities/pb_shared_master_node.dart';
import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_intermediate_node.dart';
import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_layout_intermediate_node.dart';
import 'package:parabeac_core/interpret_and_optimize/helpers/pb_gen_cache.dart';
import 'package:parabeac_core/plugins/injected_app_bar.dart';
import 'package:parabeac_core/plugins/injected_tab.dart';
import 'package:parabeac_core/plugins/injected_tab_bar.dart';
import 'package:quick_log/quick_log.dart';
import 'package:parabeac_core/interpret_and_optimize/helpers/pb_intermediate_node_tree.dart';

Expand Down Expand Up @@ -126,8 +130,14 @@ class FlutterProjectBuilder {
List<String> imports = [];
if (node == null) return imports;

String id =
node is PBSharedInstanceIntermediateNode ? node.SYMBOL_ID : node.UUID;
String id;
if (node is PBSharedInstanceIntermediateNode) {
id = node.SYMBOL_ID;
} else if (node is PBDestHolder) {
id = node.pNode.destinationUUID;
} else {
id = node.UUID;
}

String nodePath = PBGenCache().getPath(id);
// Make sure nodePath exists and is not the same as path (importing yourself)
Expand All @@ -139,6 +149,18 @@ class FlutterProjectBuilder {
if (node is PBLayoutIntermediateNode) {
node.children
.forEach((child) => imports.addAll(_findImports(child, path)));
} else if (node is InheritedScaffold) {
imports.addAll(_findImports(node.navbar, path));
imports.addAll(_findImports(node.tabbar, path));
imports.addAll(_findImports(node.child, path));
} else if (node is InjectedNavbar) {
imports.addAll(_findImports(node.leadingItem, path));
imports.addAll(_findImports(node.middleItem, path));
imports.addAll(_findImports(node.trailingItem, path));
} else if (node is InjectedTabBar) {
for (var tab in node.tabs) {
imports.addAll(_findImports(tab, path));
}
} else {
imports.addAll(_findImports(node.child, path));
}
Expand Down Expand Up @@ -197,11 +219,19 @@ class FlutterProjectBuilder {
// Check if there are any imports needed for this screen
if (!isFirstTraversal) {
isSymbolsDir
? importSet.addAll(_findImports(intermediateItem.node,
isSymbolsDir ? symbolFilePath : fileNamePath))
: flutterGenerator.imports.addAll(_findImports(
intermediateItem.node,
isSymbolsDir ? symbolFilePath : fileNamePath));
? importSet
.addAll(_findImports(intermediateItem.node, symbolFilePath))
: flutterGenerator.imports
.addAll(_findImports(intermediateItem.node, fileNamePath));

// Check if [InheritedScaffold] is the homescreen
if (intermediateItem.node is InheritedScaffold &&
(intermediateItem.node as InheritedScaffold).isHomeScreen) {
var relPath = PBGenCache().getRelativePath(
'${projectName}/lib/main.dart', intermediateItem.node.UUID);
pageWriter.writeMainScreenWithHome(intermediateItem.node.name,
'${projectName}/lib/main.dart', relPath);
}

var page = flutterGenerator.generate(intermediateItem.node);

Expand Down
2 changes: 0 additions & 2 deletions lib/generation/generators/pb_flutter_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ class PBFlutterGenerator extends PBGenerationManager {
default:
return gen.generate(rootNode);
}
//return gen.generate(rootNode);
} else {
// print('[ERROR] Generator not registered for ${rootNode}');
log.error('Generator not registered for ${rootNode}');
}
return null;
Expand Down
Loading

0 comments on commit 72ecbf2

Please sign in to comment.