showPresetShape static method
List<Widget>
showPresetShape(
- PresentationPresetShapes presentationPresetShape,
- Map<
String, String> clearMap, - List<
PresentationColorSchemes> colorSchemes, - double divisionFactor,
- Map<
String, double> maxWidthHeight,
Implementation
static List<Widget> showPresetShape(PresentationPresetShapes presentationPresetShape, Map<String, String> clearMap,
List<PresentationColorSchemes> colorSchemes, double divisionFactor, Map<String, double> maxWidthHeight) {
List<Widget> tempShapes = [];
if (presentationPresetShape.left / divisionFactor + presentationPresetShape.width / divisionFactor > maxWidthHeight["maxWidth"]!) {
maxWidthHeight["maxWidth"] = presentationPresetShape.left / divisionFactor + presentationPresetShape.width / divisionFactor;
}
if (presentationPresetShape.top / divisionFactor + presentationPresetShape.height / divisionFactor > maxWidthHeight["maxHeight"]!) {
maxWidthHeight["maxHeight"] = presentationPresetShape.top / divisionFactor + presentationPresetShape.height / divisionFactor;
}
if (presentationPresetShape.type == "roundRect") {
String color = "0xff000000";
if (presentationPresetShape.fillColorScheme.isNotEmpty) {
String clrSchemeVal = presentationPresetShape.fillColorScheme;
if (clearMap[clrSchemeVal] != null) {
clrSchemeVal = clearMap[clrSchemeVal]!;
}
var clrScheme = colorSchemes.firstWhereOrNull((clrSch) {
//print(clrSch.name);
return clrSch.name == clrSchemeVal;
});
if (clrScheme != null) {
if (clrScheme.sysClrLast.isNotEmpty) {
color = "0xff${clrScheme.sysClrLast}";
} else if (clrScheme.srgbClr.isNotEmpty) {
color = "0xff${clrScheme.srgbClr}";
}
}
}
Color adjustedColor = Color(int.parse(color));
if (presentationPresetShape.lumMod != null || presentationPresetShape.lumOff != null) {
adjustedColor = modifyColor(adjustedColor, presentationPresetShape.lumMod, presentationPresetShape.lumOff);
}
double borderRadius = 0;
if (presentationPresetShape.adjValue.isNotEmpty) {
String tempBorderRadius = presentationPresetShape.adjValue.replaceAll("val ", "");
borderRadius = double.parse(tempBorderRadius) / 1000;
//print(borderRadius);
}
double rotate = 0;
bool flipH = false;
bool flipV = false;
if (presentationPresetShape.rotate != null) {
rotate = presentationPresetShape.rotate! * pi / 180;
}
if (presentationPresetShape.flipH != null && presentationPresetShape.flipH == "1") {
flipH = true;
}
if (presentationPresetShape.flipV != null && presentationPresetShape.flipV == "1") {
flipV = true;
}
tempShapes.add(Positioned(
top: presentationPresetShape.top != 0 ? presentationPresetShape.top / divisionFactor : 0,
left: presentationPresetShape.left != 0 ? presentationPresetShape.left / divisionFactor : 0,
child: Transform.rotate(
angle: rotate,
child: Transform.flip(
flipX: flipH,
flipY: flipV,
child: Container(
width: presentationPresetShape.width / (divisionFactor),
height: presentationPresetShape.height / divisionFactor,
decoration: BoxDecoration(color: adjustedColor, borderRadius: BorderRadius.circular(borderRadius.toDouble())),
),
),
)));
} else if (presentationPresetShape.type == "rect") {
String color = "";
if (presentationPresetShape.fillColorScheme.isNotEmpty) {
String clrSchemeVal = presentationPresetShape.fillColorScheme;
if (clearMap[clrSchemeVal] != null) {
clrSchemeVal = clearMap[clrSchemeVal]!;
}
var clrScheme = colorSchemes.firstWhereOrNull((clrSch) {
//print(clrSch.name);
return clrSch.name == clrSchemeVal;
});
if (clrScheme != null) {
if (clrScheme.sysClrLast.isNotEmpty) {
color = "0xff${clrScheme.sysClrLast}";
} else if (clrScheme.srgbClr.isNotEmpty) {
color = "0xff${clrScheme.srgbClr}";
}
}
}
Color adjustedColor = Colors.transparent;
if (color.isNotEmpty) {
adjustedColor = Color(int.parse(color));
if (presentationPresetShape.lumMod != null || presentationPresetShape.lumOff != null) {
adjustedColor = modifyColor(adjustedColor, presentationPresetShape.lumMod, presentationPresetShape.lumOff);
}
}
double rotate = 0;
bool flipH = false;
bool flipV = false;
if (presentationPresetShape.rotate != null) {
rotate = presentationPresetShape.rotate! * pi / 180;
}
if (presentationPresetShape.flipH != null && presentationPresetShape.flipH == "1") {
flipH = true;
}
if (presentationPresetShape.flipV != null && presentationPresetShape.flipV == "1") {
flipV = true;
}
tempShapes.add(Positioned(
top: presentationPresetShape.top != 0 ? presentationPresetShape.top / divisionFactor : 0,
left: presentationPresetShape.left != 0 ? presentationPresetShape.left / divisionFactor : 0,
child: Transform.rotate(
angle: rotate,
child: Transform.flip(
flipX: flipH,
flipY: flipV,
child: Container(
width: presentationPresetShape.width / (divisionFactor),
height: presentationPresetShape.height / divisionFactor,
decoration: BoxDecoration(
color: color.isNotEmpty ? adjustedColor : Colors.transparent,
),
),
),
)));
} else if (presentationPresetShape.type == "blockArc") {
String color = "";
if (presentationPresetShape.fillColorScheme.isNotEmpty) {
String clrSchemeVal = presentationPresetShape.fillColorScheme;
if (clearMap[clrSchemeVal] != null) {
clrSchemeVal = clearMap[clrSchemeVal]!;
}
var clrScheme = colorSchemes.firstWhereOrNull((clrSch) {
//print(clrSch.name);
return clrSch.name == clrSchemeVal;
});
if (clrScheme != null) {
if (clrScheme.sysClrLast.isNotEmpty) {
color = "0xff${clrScheme.sysClrLast}";
} else if (clrScheme.srgbClr.isNotEmpty) {
color = "0xff${clrScheme.srgbClr}";
}
}
}
Color adjustedColor = Colors.transparent;
if (color.isNotEmpty) {
adjustedColor = Color(int.parse(color));
if (presentationPresetShape.lumMod != null || presentationPresetShape.lumOff != null) {
adjustedColor = modifyColor(adjustedColor, presentationPresetShape.lumMod, presentationPresetShape.lumOff);
}
}
double rotate = 0;
bool flipH = false;
bool flipV = false;
if (presentationPresetShape.rotate != null) {
rotate = presentationPresetShape.rotate! * pi / 180;
}
if (presentationPresetShape.flipH != null && presentationPresetShape.flipH == "1") {
flipH = true;
}
if (presentationPresetShape.flipV != null && presentationPresetShape.flipV == "1") {
flipV = true;
}
tempShapes.add(Positioned(
top: presentationPresetShape.top != 0 ? presentationPresetShape.top / divisionFactor : 0,
left: presentationPresetShape.left != 0 ? presentationPresetShape.left / divisionFactor : 0,
child: Transform.rotate(
angle: rotate,
child: Transform.flip(
flipX: flipH,
flipY: flipV,
child: Container(
width: presentationPresetShape.width.toDouble() / divisionFactor,
height: presentationPresetShape.height.toDouble() / divisionFactor,
child: CustomPaint(child: Container(), painter: PresetDiagram(presentationPresetShape, divisionFactor.toDouble(), adjustedColor))),
),
)));
} else if (presentationPresetShape.type == "round2SameRect") {
String color = "0xff000000";
if (presentationPresetShape.fillColorScheme.isNotEmpty) {
String clrSchemeVal = presentationPresetShape.fillColorScheme;
if (clearMap[clrSchemeVal] != null) {
clrSchemeVal = clearMap[clrSchemeVal]!;
}
var clrScheme = colorSchemes.firstWhereOrNull((clrSch) {
//print(clrSch.name);
return clrSch.name == clrSchemeVal;
});
if (clrScheme != null) {
if (clrScheme.sysClrLast.isNotEmpty) {
color = "0xff${clrScheme.sysClrLast}";
} else if (clrScheme.srgbClr.isNotEmpty) {
color = "0xff${clrScheme.srgbClr}";
}
}
}
Color adjustedColor = Colors.transparent;
if (color.isNotEmpty) {
adjustedColor = Color(int.parse(color));
if (presentationPresetShape.lumMod != null || presentationPresetShape.lumOff != null) {
adjustedColor = modifyColor(adjustedColor, presentationPresetShape.lumMod, presentationPresetShape.lumOff);
}
}
double borderRadius = 0;
if (presentationPresetShape.adjValue.isNotEmpty) {
String tempBorderRadius = presentationPresetShape.adjValue.replaceAll("val ", "");
borderRadius = double.parse(tempBorderRadius) / 1000;
//print(borderRadius);
}
double rotate = 0;
bool flipH = false;
bool flipV = false;
if (presentationPresetShape.rotate != null) {
rotate = presentationPresetShape.rotate! * pi / 180;
}
if (presentationPresetShape.flipH != null && presentationPresetShape.flipH == "1") {
flipH = true;
}
if (presentationPresetShape.flipV != null && presentationPresetShape.flipV == "1") {
flipV = true;
}
tempShapes.add(Positioned(
top: presentationPresetShape.top != 0 ? presentationPresetShape.top / divisionFactor : 0,
left: presentationPresetShape.left != 0 ? presentationPresetShape.left / divisionFactor : 0,
child: Transform.rotate(
angle: rotate,
child: Transform.flip(
flipX: flipH,
flipY: flipV,
child: Container(
width: presentationPresetShape.width / (divisionFactor),
height: presentationPresetShape.height / divisionFactor,
decoration: BoxDecoration(
color: adjustedColor,
borderRadius: BorderRadius.only(topLeft: Radius.circular(borderRadius.toDouble()), topRight: Radius.circular(borderRadius))),
),
),
)));
} else if (presentationPresetShape.type == "parallelogram") {
String color = "";
if (presentationPresetShape.fillColorScheme.isNotEmpty) {
String clrSchemeVal = presentationPresetShape.fillColorScheme;
if (clearMap[clrSchemeVal] != null) {
clrSchemeVal = clearMap[clrSchemeVal]!;
}
var clrScheme = colorSchemes.firstWhereOrNull((clrSch) {
//print(clrSch.name);
return clrSch.name == clrSchemeVal;
});
if (clrScheme != null) {
if (clrScheme.sysClrLast.isNotEmpty) {
color = "0xff${clrScheme.sysClrLast}";
} else if (clrScheme.srgbClr.isNotEmpty) {
color = "0xff${clrScheme.srgbClr}";
}
}
}
Color adjustedColor = Colors.transparent;
if (color.isNotEmpty) {
adjustedColor = Color(int.parse(color));
if (presentationPresetShape.lumMod != null || presentationPresetShape.lumOff != null) {
adjustedColor = modifyColor(adjustedColor, presentationPresetShape.lumMod, presentationPresetShape.lumOff);
}
}
double rotate = 0;
bool flipH = false;
bool flipV = false;
if (presentationPresetShape.rotate != null) {
rotate = presentationPresetShape.rotate! * pi / 180;
}
if (presentationPresetShape.flipH != null && presentationPresetShape.flipH == "1") {
flipH = true;
}
if (presentationPresetShape.flipV != null && presentationPresetShape.flipV == "1") {
flipV = true;
}
tempShapes.add(Positioned(
top: presentationPresetShape.top != 0 ? presentationPresetShape.top / divisionFactor : 0,
left: presentationPresetShape.left != 0 ? presentationPresetShape.left / divisionFactor : 0,
child: Transform.rotate(
angle: rotate,
child: Transform.flip(
flipX: flipH,
flipY: flipV,
child: Container(
width: presentationPresetShape.width.toDouble() / divisionFactor,
height: presentationPresetShape.height.toDouble() / divisionFactor,
child: CustomPaint(
child: Container(),
painter:
PresetParallelogram(int.parse(presentationPresetShape.adjValue.replaceAll("val ", "")), adjustedColor, divisionFactor))),
),
)));
} else if (presentationPresetShape.type == "ellipse") {
String color = "0xff000000";
if (presentationPresetShape.fillColorScheme.isNotEmpty) {
String clrSchemeVal = presentationPresetShape.fillColorScheme;
if (clearMap[clrSchemeVal] != null) {
clrSchemeVal = clearMap[clrSchemeVal]!;
}
var clrScheme = colorSchemes.firstWhereOrNull((clrSch) {
//print(clrSch.name);
return clrSch.name == clrSchemeVal;
});
if (clrScheme != null) {
if (clrScheme.sysClrLast.isNotEmpty) {
color = "0xff${clrScheme.sysClrLast}";
} else if (clrScheme.srgbClr.isNotEmpty) {
color = "0xff${clrScheme.srgbClr}";
}
}
}
Color adjustedColor = Color(int.parse(color));
if (presentationPresetShape.lumMod != null || presentationPresetShape.lumOff != null) {
adjustedColor = modifyColor(adjustedColor, presentationPresetShape.lumMod, presentationPresetShape.lumOff);
}
double rotate = 0;
bool flipH = false;
bool flipV = false;
if (presentationPresetShape.rotate != null) {
rotate = presentationPresetShape.rotate! * pi / 180;
}
if (presentationPresetShape.flipH != null && presentationPresetShape.flipH == "1") {
flipH = true;
}
if (presentationPresetShape.flipV != null && presentationPresetShape.flipV == "1") {
flipV = true;
}
tempShapes.add(Positioned(
top: presentationPresetShape.top != 0 ? presentationPresetShape.top / divisionFactor : 0,
left: presentationPresetShape.left != 0 ? presentationPresetShape.left / divisionFactor : 0,
child: Transform.rotate(
angle: rotate,
child: Transform.flip(
flipX: flipH,
flipY: flipV,
child: Container(
width: presentationPresetShape.width / (divisionFactor),
height: presentationPresetShape.height / divisionFactor,
decoration: BoxDecoration(color: adjustedColor, shape: BoxShape.circle),
),
),
)));
}
return tempShapes;
}