showTextBox static method
List<Widget>
showTextBox(
- PresentationTextBox presentationTextBox,
- double divisionFactor,
- Map<
String, double> maxWidthHeight, - SlideLayout? slideLayout,
- Map<
String, String> clearMap, - List<
PresentationColorSchemes> colorSchemes,
Implementation
static List<Widget> showTextBox(PresentationTextBox presentationTextBox, double divisionFactor, Map<String, double> maxWidthHeight,
SlideLayout? slideLayout, Map<String, String> clearMap, List<PresentationColorSchemes> colorSchemes) {
List<Widget> tempShapes = [];
if (presentationTextBox.offset.dx / divisionFactor + presentationTextBox.size.width / divisionFactor > maxWidthHeight["maxWidth"]!) {
maxWidthHeight["maxWidth"] = presentationTextBox.offset.dx / divisionFactor + presentationTextBox.size.width / divisionFactor;
}
if (presentationTextBox.offset.dy / divisionFactor + presentationTextBox.size.height / divisionFactor > maxWidthHeight["maxHeight"]!) {
maxWidthHeight["maxHeight"] = presentationTextBox.offset.dy / divisionFactor + presentationTextBox.size.height / divisionFactor;
}
List<Widget> textBoxTexts = [];
String align = "";
String paraColorScheme = "";
String paraLumMod = "";
String paraLumOff = "";
double paraFontSize = 0;
double paraX = 0;
double paraY = 0;
int paraWidth = 0;
int paraHeight = 0;
for (int k = 0; k < presentationTextBox.presentationParas.length; k++) {
List<TextSpan> textSpans = [];
if (presentationTextBox.presentationParas[k].align != null) {
align = presentationTextBox.presentationParas[k].align!;
}
if (presentationTextBox.presentationParas[k].type != null && presentationTextBox.presentationParas[k].idx != null) {
var paraDetails = slideLayout?.paragraphs.firstWhereOrNull((para) {
return para.type == presentationTextBox.presentationParas[k].type && para.idx == presentationTextBox.presentationParas[k].idx;
});
if (paraDetails != null) {
align = paraDetails.anchor;
paraColorScheme = paraDetails.schemeClr;
paraFontSize = paraDetails.defaultSz / 180;
paraX = paraDetails.x ?? 0;
paraY = paraDetails.y ?? 0;
paraWidth = paraDetails.width ?? 0;
paraHeight = paraDetails.height ?? 0;
if (paraDetails.lumOff != null) {
paraLumOff = paraDetails.lumOff!;
}
if (paraDetails.lumMod != null) {
paraLumMod = paraDetails.lumMod!;
}
}
}
for (int l = 0; l < presentationTextBox.presentationParas[k].textSpans.length; l++) {
double fontSize = presentationTextBox.presentationParas[k].textSpans[l].fontSize;
if (paraFontSize != 0) {
fontSize = paraFontSize.toDouble();
}
bool isBold = false;
if (presentationTextBox.presentationParas[k].textSpans[l].isBold) {
isBold = true;
}
TextStyle textStyle = TextStyle(fontSize: fontSize, fontWeight: isBold ? FontWeight.bold : FontWeight.normal, color: Colors.black);
if (presentationTextBox.presentationParas[k].textSpans[l].colorScheme != null || paraColorScheme.isNotEmpty) {
//print("---");
//print(params.slide.presentationTextBoxes[j].presentationParas[k]
// .textSpans[l].colorScheme);
String clrSchemeVal = presentationTextBox.presentationParas[k].textSpans[l].colorScheme ?? paraColorScheme;
if (clearMap[clrSchemeVal] != null) {
clrSchemeVal = clearMap[clrSchemeVal]!;
}
var clrScheme = colorSchemes.firstWhereOrNull((clrSch) {
//print(clrSch.name);
return clrSch.name == clrSchemeVal;
});
//print("----");
if (clrScheme != null) {
//print("---");
//print(clrScheme.name);
String color = "";
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 (presentationTextBox.presentationParas[k].textSpans[l].lumMod != null ||
presentationTextBox.presentationParas[k].textSpans[l].lumOff != null) {
adjustedColor = modifyColor(adjustedColor, presentationTextBox.presentationParas[k].textSpans[l].lumMod,
presentationTextBox.presentationParas[k].textSpans[l].lumOff);
}
}
//print(color);
//textStyle=textStyle..copyWith(color: Color(int.parse(color)));
textStyle = TextStyle(fontSize: fontSize, fontWeight: isBold ? FontWeight.bold : FontWeight.normal, color: adjustedColor);
//print(textStyle.color.toString());
}
}
textSpans.add(TextSpan(text: presentationTextBox.presentationParas[k].textSpans[l].text, style: textStyle));
}
textBoxTexts.add(Expanded(
child: RichText(
text: TextSpan(children: textSpans),
textAlign: TextAlign.start,
)));
}
double offsetX = presentationTextBox.offset.dx;
double offsetY = presentationTextBox.offset.dy;
if (offsetX == 0 && offsetY == 0 && paraX != 0 && paraY != 0) {
offsetX = paraX;
offsetY = paraY;
}
if (presentationTextBox.size.height != 0 && presentationTextBox.size.width != 0) {
tempShapes.add(Positioned(
top: offsetY / divisionFactor,
left: offsetX / divisionFactor,
child: SizedBox(
height: presentationTextBox.size.height / divisionFactor,
width: presentationTextBox.size.width / divisionFactor,
child: Column(
crossAxisAlignment: align == "ctr" ? CrossAxisAlignment.center : CrossAxisAlignment.start,
children: textBoxTexts,
),
)));
} else if (paraHeight != 0 && paraWidth != 0) {
tempShapes.add(Positioned(
top: offsetY / divisionFactor,
left: offsetX / divisionFactor,
child: SizedBox(
height: paraHeight / divisionFactor,
width: paraWidth / divisionFactor,
child: Column(
crossAxisAlignment: align == "ctr" ? CrossAxisAlignment.center : CrossAxisAlignment.start,
children: textBoxTexts,
),
)));
} else {
tempShapes.add(Positioned(
top: offsetY / divisionFactor,
left: offsetX / divisionFactor,
child: Column(
crossAxisAlignment: align == "ctr" ? CrossAxisAlignment.center : CrossAxisAlignment.start,
children: textBoxTexts,
)));
}
return tempShapes;
}