Skip to content

Commit

Permalink
Added font family feature to element text widget to allow different f…
Browse files Browse the repository at this point in the history
…onts
  • Loading branch information
SL-Pirate committed Jan 24, 2024
1 parent 693012b commit bf5ab79
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/src/elements/flow_element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class FlowElement extends ChangeNotifier {
/// Text color
Color textColor;

/// Text font family
String? fontFamily;

/// Text size
double textSize;

Expand Down Expand Up @@ -74,6 +77,7 @@ class FlowElement extends ChangeNotifier {
this.size = Size.zero,
this.text = '',
this.textColor = Colors.black,
this.fontFamily,
this.textSize = 24,
this.textIsBold = false,
this.kind = ElementKind.rectangle,
Expand Down Expand Up @@ -122,6 +126,12 @@ class FlowElement extends ChangeNotifier {
notifyListeners();
}

/// Set text font family
setFontFamily(String? fontFamily) {
this.fontFamily = fontFamily;
notifyListeners();
}

/// Set text size
setTextSize(double size) {
textSize = size;
Expand Down Expand Up @@ -185,6 +195,7 @@ class FlowElement extends ChangeNotifier {
size.hashCode ^
text.hashCode ^
textColor.hashCode ^
fontFamily.hashCode ^
textSize.hashCode ^
textIsBold.hashCode ^
id.hashCode ^
Expand All @@ -206,6 +217,7 @@ class FlowElement extends ChangeNotifier {
'size.height': size.height,
'text': text,
'textColor': textColor.value,
'fontFamily': fontFamily,
'textSize': textSize,
'textIsBold': textIsBold,
'id': id,
Expand All @@ -229,6 +241,7 @@ class FlowElement extends ChangeNotifier {
size: Size(map['size.width'] as double, map['size.height'] as double),
text: map['text'] as String,
textColor: Color(map['textColor'] as int),
fontFamily: map['fontFamily'] as String?,
textSize: map['textSize'] as double,
textIsBold: map['textIsBold'] as bool,
kind: ElementKind.values[map['kind'] as int],
Expand Down
1 change: 1 addition & 0 deletions lib/src/objects/element_text_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ElementTextWidget extends StatelessWidget {
color: element.textColor,
fontSize: element.textSize,
fontWeight: element.textIsBold ? FontWeight.bold : FontWeight.normal,
fontFamily: element.fontFamily,
),
),
);
Expand Down

0 comments on commit bf5ab79

Please sign in to comment.