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 #317 from Parabeac/release/1.4.1
Browse files Browse the repository at this point in the history
Release/1.4.1
  • Loading branch information
mergify[bot] committed Mar 18, 2021
2 parents a9307da + 08353e2 commit 0901569
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 23 deletions.
16 changes: 8 additions & 8 deletions lib/configurations/configurations.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"default": {
"widgetStyle": "Material",
"widgetType": "Stateless",
"widgetSpacing": "Expanded",
"layoutPrecedence": ["column", "row", "stack"]
},
"state-management": "provider"
}
"default": {
"widgetStyle": "Material",
"widgetType": "Stateless",
"widgetSpacing": "Expanded",
"layoutPrecedence": ["column", "row", "stack"]
},
"state-management": "none"
}
2 changes: 2 additions & 0 deletions lib/controllers/main_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class MainInfo {
}
};

Map pbdf;

factory MainInfo() {
return _singleton;
}
Expand Down
35 changes: 25 additions & 10 deletions lib/design_logic/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,30 @@ class Image extends DesignElement implements DesignNodeFactory, DesignNode {

@override
Future<PBIntermediateNode> interpretNode(PBContext currentContext) async {
var img = await AzureAssetService().downloadImage(UUID);
var file =
File('${MainInfo().outputPath}pngs/${UUID}.png'.replaceAll(':', '_'))
..createSync(recursive: true);
file.writeAsBytesSync(img);
return Future.value(InheritedBitmap(
this,
name,
currentContext: currentContext,
));
try {
var img = await AzureAssetService().downloadImage(UUID);
var file =
File('${MainInfo().outputPath}pngs/${UUID}.png'.replaceAll(':', '_'))
..createSync(recursive: true);
file.writeAsBytesSync(img);
return Future.value(InheritedBitmap(
this,
name,
currentContext: currentContext,
));
} catch (e) {
var img = File(
'${MainInfo().cwd?.path}/lib/input/assets/image-conversion-error.png')
.readAsBytesSync();
var file =
File('${MainInfo().outputPath}pngs/${UUID}.png'.replaceAll(':', '_'))
..createSync(recursive: true);
file.writeAsBytesSync(img);
return Future.value(InheritedBitmap(
this,
name,
currentContext: currentContext,
));
}
}
}
10 changes: 10 additions & 0 deletions lib/generation/generators/middleware/middleware.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ abstract class Middleware {
return name + '_' + (++variableNames[name]).toString();
}
}

String wrapOnLayout(String className) {
return '''
LayoutBuilder(builder: (context, constraints) {
return $className(
constraints,
);
})
''';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class StatefulMiddleware extends Middleware {
'var ',
true,
node.functionCallName == symbolMaster.name
? '${symbolMaster.name.pascalCase}()'
? wrapOnLayout('${symbolMaster.name.pascalCase}')
: null,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@ class BLoCStateTemplateStrategy extends TemplateStrategy {
var overrideVars = '';
if (node is PBSharedMasterNode && node.overridableProperties.isNotEmpty) {
node.overridableProperties.forEach((prop) {
overrides += 'this.${prop.friendlyName}, ';
overrideVars += 'final ${prop.friendlyName};';
overrides += '${prop.friendlyName}, ';
overrideVars += 'var ${prop.friendlyName};';
});
}

return '''
${isFirst ? _getHeader(manager) : ''}
class ${node.name.pascalCase}State extends ${abstractClassName.pascalCase}State{
${manager.generateGlobalVariables()}
${overrideVars}
${widgetName + 'State'}(${(overrides.isNotEmpty ? '{$overrides}' : '')}){}
@override
Widget get widget => ${returnStatement};
Expand Down
12 changes: 12 additions & 0 deletions lib/input/figma/helper/figma_project.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:parabeac_core/controllers/main_info.dart';
import 'package:parabeac_core/input/figma/entities/layers/canvas.dart';
import 'package:parabeac_core/input/figma/helper/figma_page.dart';
import 'package:parabeac_core/input/helper/design_project.dart';
Expand Down Expand Up @@ -30,11 +31,22 @@ class FigmaProject extends DesignProject {
List<FigmaPage> _setConventionalPages(var canvasAndArtboards) {
var figmaPages = <FigmaPage>[];
for (var canvas in canvasAndArtboards) {
// Skip current canvas if its convert property is false
var pbdlPage = getPbdlPage(canvas['id']);
if (pbdlPage != null && !(pbdlPage['convert'] ?? true)) {
continue;
}

var pg = FigmaPage(canvas['name'], canvas['id']);

var node = Canvas.fromJson(canvas);

for (var layer in node.children) {
// Skip current screen if its convert property is false
var pbdlScreen = getPbdlScreen(pbdlPage, layer.UUID);
if (pbdlScreen != null && !(pbdlScreen['convert'] ?? true)) {
continue;
}
if (layer.UUID == node.prototypeStartNodeID) {
layer.isFlowHome = true;
}
Expand Down
23 changes: 23 additions & 0 deletions lib/input/helper/design_project.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:parabeac_core/controllers/main_info.dart';
import 'package:parabeac_core/design_logic/abstract_design_node_factory.dart';
import 'package:parabeac_core/design_logic/design_node.dart';
import 'package:parabeac_core/input/helper/design_page.dart';
Expand Down Expand Up @@ -64,4 +65,26 @@ class DesignProject implements DesignNodeFactory {
}
return project;
}

/// Returns a [Map] that represents the PBDL page with ID `pageId`,
/// or `null` if not found.
Map getPbdlPage(String pageId) {
if (MainInfo().pbdf != null) {
List pages = MainInfo().pbdf['pages'];
return pages.singleWhere((element) => element['id'] == pageId,
orElse: () => null);
}
return null;
}

/// Returns a [Map] that represents the PBDL screen with ID `screenId`
/// inside `pbdlPage`'s screens property.
Map getPbdlScreen(Map pbdlPage, String screenId) {
if (MainInfo().pbdf != null) {
List screens = pbdlPage['screens'];
return screens.singleWhere((element) => element['id'] == screenId,
orElse: () => null);
}
return null;
}
}
9 changes: 9 additions & 0 deletions lib/input/sketch/helper/sketch_project.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,21 @@ class SketchProject extends DesignProject {
_originalArchive.findFile('pages/${entry.key}.json').content;
var jsonData = json.decode(utf8.decode(pageContent));

var pbdlPage = getPbdlPage(jsonData['do_objectID']);
if (pbdlPage != null && !(pbdlPage['convert'] ?? true)) {
continue;
}

var pg = SketchPage(
jsonData['name'], jsonData['do_objectID']); // Sketch Node Holder
var node = Page.fromJson(jsonData); // Actual Sketch Node

// Turn layers into PBNodes
for (var layer in node.children) {
var pbdlScreen = getPbdlScreen(pbdlPage, layer.UUID);
if (pbdlScreen != null && !(pbdlScreen['convert'] ?? true)) {
continue;
}
pg.addScreen(SketchScreen(
layer,
layer.UUID,
Expand Down
14 changes: 13 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ ${parser.usage}
'Too many arguments: Please provide either the path to Sketch file or the Figma File ID and API Key');
} else if (argResults['figKey'] != null && argResults['fig'] != null) {
designType = 'figma';
} else if (argResults['path'] != null) {
designType = 'sketch';
} else if (argResults['pbdl-in'] != null) {
designType = 'pbdl';
}
Expand Down Expand Up @@ -139,6 +141,11 @@ ${parser.usage}
.create(recursive: true);

if (designType == 'sketch') {
if (argResults['pbdl-in'] != null) {
var pbdlPath = argResults['pbdl-in'];
var jsonString = File(pbdlPath).readAsStringSync();
MainInfo().pbdf = json.decode(jsonString);
}
Process process;
if (!jsonOnly) {
var file = await FileSystemEntity.isFile(path);
Expand Down Expand Up @@ -188,6 +195,11 @@ ${parser.usage}
} else if (designType == 'xd') {
assert(false, 'We don\'t support Adobe XD.');
} else if (designType == 'figma') {
if (argResults['pbdl-in'] != null) {
var pbdlPath = argResults['pbdl-in'];
var jsonString = File(pbdlPath).readAsStringSync();
MainInfo().pbdf = json.decode(jsonString);
}
if (MainInfo().figmaKey == null || MainInfo().figmaKey.isEmpty) {
assert(false, 'Please provided a Figma API key to proceed.');
}
Expand Down Expand Up @@ -318,7 +330,7 @@ bool hasTooManyArgs(ArgResults args) {

var hasAll = hasSketch && hasFigma && hasPbdl;

return hasAll || !(hasSketch ^ hasFigma ^ hasPbdl);
return hasAll || !(hasSketch ^ hasFigma /*^ hasPbdl*/);
}

/// Returns true if `args` does not contain any intake
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: parabeac_core
description: A starting point for Dart libraries or applications.
version: 1.4.0
version: 1.4.1


environment:
sdk: ">=2.7.0 <3.0.0"
Expand Down

0 comments on commit 0901569

Please sign in to comment.