Skip to content

Commit

Permalink
Refactor computeLuminance in text_editor, improve hitbox for textlaye…
Browse files Browse the repository at this point in the history
…r in layer_widget, and add keyboard shortcuts to pro_image_editor_main

- Enhanced computeLuminance function in text_editor for better performance
- Improved hitbox detection for text layers in layer_widget
- Extended pro_image_editor_main with additional keyboard shortcuts for increased usability
  • Loading branch information
hm21 committed Jan 4, 2024
1 parent 4cca5f0 commit c34fc35
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 21 deletions.
2 changes: 1 addition & 1 deletion example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"device_info_plus","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-9.1.1\\\\","native_build":true,"dependencies":[]},{"name":"emoji_picker_flutter","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\emoji_picker_flutter-1.6.3\\\\","native_build":true,"dependencies":[]},{"name":"file_picker","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\file_picker-6.1.1\\\\","native_build":true,"dependencies":[]},{"name":"image_editor_common","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\image_editor_common-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.3.1\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_foundation-2.3.4\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"vibration","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\vibration-1.8.4\\\\","native_build":true,"dependencies":["device_info_plus"]}],"android":[{"name":"device_info_plus","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-9.1.1\\\\","native_build":true,"dependencies":[]},{"name":"emoji_picker_flutter","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\emoji_picker_flutter-1.6.3\\\\","native_build":true,"dependencies":[]},{"name":"file_picker","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\file_picker-6.1.1\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_plugin_android_lifecycle-2.0.17\\\\","native_build":true,"dependencies":[]},{"name":"image_editor_common","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\image_editor_common-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.2\\\\","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_android-2.2.1\\\\","native_build":true,"dependencies":[]},{"name":"vibration","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\vibration-1.8.4\\\\","native_build":true,"dependencies":["device_info_plus"]}],"macos":[{"name":"device_info_plus","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-9.1.1\\\\","native_build":true,"dependencies":[]},{"name":"emoji_picker_flutter","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\emoji_picker_flutter-1.6.3\\\\","native_build":true,"dependencies":[]},{"name":"image_editor_common","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\image_editor_common-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.3.1\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_foundation-2.3.4\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-9.1.1\\\\","native_build":false,"dependencies":[]},{"name":"emoji_picker_flutter","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\emoji_picker_flutter-1.6.3\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_linux","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_linux-2.3.2\\\\","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"device_info_plus","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-9.1.1\\\\","native_build":false,"dependencies":[]},{"name":"emoji_picker_flutter","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\emoji_picker_flutter-1.6.3\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.2.1\\\\","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_windows-2.3.2\\\\","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"device_info_plus","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-9.1.1\\\\","dependencies":[]},{"name":"emoji_picker_flutter","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\emoji_picker_flutter-1.6.3\\\\","dependencies":[]},{"name":"file_picker","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\file_picker-6.1.1\\\\","dependencies":[]},{"name":"shared_preferences_web","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_web-2.2.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"device_info_plus","dependencies":[]},{"name":"emoji_picker_flutter","dependencies":["shared_preferences"]},{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_editor","dependencies":["image_editor_common"]},{"name":"image_editor_common","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"vibration","dependencies":["device_info_plus"]}],"date_created":"2024-01-03 20:35:27.626990","version":"3.16.5"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"device_info_plus","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-9.1.1\\\\","native_build":true,"dependencies":[]},{"name":"emoji_picker_flutter","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\emoji_picker_flutter-1.6.3\\\\","native_build":true,"dependencies":[]},{"name":"file_picker","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\file_picker-6.1.1\\\\","native_build":true,"dependencies":[]},{"name":"image_editor_common","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\image_editor_common-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.3.1\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_foundation-2.3.4\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"vibration","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\vibration-1.8.4\\\\","native_build":true,"dependencies":["device_info_plus"]}],"android":[{"name":"device_info_plus","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-9.1.1\\\\","native_build":true,"dependencies":[]},{"name":"emoji_picker_flutter","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\emoji_picker_flutter-1.6.3\\\\","native_build":true,"dependencies":[]},{"name":"file_picker","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\file_picker-6.1.1\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\flutter_plugin_android_lifecycle-2.0.17\\\\","native_build":true,"dependencies":[]},{"name":"image_editor_common","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\image_editor_common-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.2\\\\","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_android-2.2.1\\\\","native_build":true,"dependencies":[]},{"name":"vibration","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\vibration-1.8.4\\\\","native_build":true,"dependencies":["device_info_plus"]}],"macos":[{"name":"device_info_plus","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-9.1.1\\\\","native_build":true,"dependencies":[]},{"name":"emoji_picker_flutter","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\emoji_picker_flutter-1.6.3\\\\","native_build":true,"dependencies":[]},{"name":"image_editor_common","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\image_editor_common-1.0.1\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.3.1\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_foundation-2.3.4\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-9.1.1\\\\","native_build":false,"dependencies":[]},{"name":"emoji_picker_flutter","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\emoji_picker_flutter-1.6.3\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_linux","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_linux-2.3.2\\\\","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"device_info_plus","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-9.1.1\\\\","native_build":false,"dependencies":[]},{"name":"emoji_picker_flutter","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\emoji_picker_flutter-1.6.3\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.2.1\\\\","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_windows-2.3.2\\\\","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"device_info_plus","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-9.1.1\\\\","dependencies":[]},{"name":"emoji_picker_flutter","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\emoji_picker_flutter-1.6.3\\\\","dependencies":[]},{"name":"file_picker","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\file_picker-6.1.1\\\\","dependencies":[]},{"name":"shared_preferences_web","path":"C:\\\\Users\\\\AlexF\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_web-2.2.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"device_info_plus","dependencies":[]},{"name":"emoji_picker_flutter","dependencies":["shared_preferences"]},{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_editor","dependencies":["image_editor_common"]},{"name":"image_editor_common","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"vibration","dependencies":["device_info_plus"]}],"date_created":"2024-01-04 09:54:25.029279","version":"3.16.5"}
5 changes: 1 addition & 4 deletions lib/modules/text_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ class TextEditorState extends State<TextEditor> {

/// Calculates the contrast color for a given color.
Color _getContrastColor(Color color) {
int d = 0;
double luminance = (0.299 * color.red + 0.587 * color.green + 0.114 * color.blue) / 255;

d = luminance > 0.65 ? 0 : 255;
int d = color.computeLuminance() > 0.5 ? 0 : 255;

return Color.fromARGB(color.alpha, d, d, d);
}
Expand Down
61 changes: 54 additions & 7 deletions lib/pro_image_editor_main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,35 @@ class ProImageEditorState extends State<ProImageEditor> {
final key = event.logicalKey.keyLabel;

if (mounted && event is KeyDownEvent) {
if (key == 'Escape') {
if (!_activeCrop && !_openDialog) {
if (_openEditor) {
Navigator.pop(context);
} else {
closeEditor();
switch (key) {
case 'Escape':
if (!_activeCrop && !_openDialog) {
if (_openEditor) {
Navigator.pop(context);
} else {
closeEditor();
}
}
}
break;

case 'Subtract':
case 'Numpad Subtract':
case 'Page Down':
case 'Arrow Down':
_keyboardZoom(true);
break;
case 'Add':
case 'Numpad Add':
case 'Page Up':
case 'Arrow Up':
_keyboardZoom(false);
break;
case 'Arrow Left':
_keyboardRotate(true);
break;
case 'Arrow Right':
_keyboardRotate(false);
break;
}
}

Expand Down Expand Up @@ -1385,6 +1406,32 @@ class ProImageEditorState extends State<ProImageEditor> {
_openDialog = false;
}

/// Handles Keyboard zoom event
void _keyboardRotate(bool left) {
if (left) {
_activeLayer.rotation -= 0.087266;
} else {
_activeLayer.rotation += 0.087266;
}
setState(() {});
}

/// Handles Keyboard zoom event
void _keyboardZoom(bool zoomIn) {
double factor = _activeLayer is PaintingLayerData
? 0.1
: _activeLayer is TextLayerData
? 0.15
: widget.configs.textEditorConfigs.initFontSize / 50;
if (zoomIn) {
_activeLayer.scale -= factor;
_activeLayer.scale = max(0.1, _activeLayer.scale);
} else {
_activeLayer.scale += factor;
}
setState(() {});
}

/// Handles mouse scroll events.
void _mouseScroll(PointerSignalEvent event) {
bool shiftDown = RawKeyboard.instance.keysPressed.contains(LogicalKeyboardKey.shiftLeft) ||
Expand Down
35 changes: 26 additions & 9 deletions lib/widgets/layer_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,26 +256,43 @@ class _LayerWidgetState extends State<LayerWidget> {
}
}

double getLineHeight(TextStyle style) {
final span = TextSpan(text: 'X', style: style);
final painter = TextPainter(
text: span,
textAlign: TextAlign.left,
textDirection: TextDirection.ltr,
);

painter.layout();
return painter.preferredLineHeight;
}

/// Build the text widget
Widget _buildText() {
var fontSize = widget.textFontSize * _layer.scale;
var layer = _layer as TextLayerData;
double horizontalHelper = 10 * layer.scale;
var style = TextStyle(
fontSize: fontSize,
fontWeight: FontWeight.w400,
color: layer.color,
);

double height = getLineHeight(style);
const horizontalPaddingFactor = 0.3;

return Container(
// Fix Hit-Box
padding: EdgeInsets.only(
left: horizontalHelper,
right: horizontalHelper,
bottom: widget.textFontSize * 1.3 * 0.175 * layer.scale,
left: height * horizontalPaddingFactor,
right: height * horizontalPaddingFactor,
bottom: height * 0.175 / 2,
),
child: RoundedBackgroundText(
layer.text.toString(),
backgroundColor: layer.background,
textAlign: layer.align,
style: TextStyle(
fontSize: widget.textFontSize * _layer.scale,
fontWeight: FontWeight.w400,
color: layer.color,
),
style: style,
),
);
}
Expand Down

0 comments on commit c34fc35

Please sign in to comment.