proxy.dart 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import 'package:flutter/widgets.dart';
  2. import '../model/document/node/leaf.dart';
  3. import '../rendering/proxy.dart';
  4. /* -------------------------------- Baseline -------------------------------- */
  5. class BaselineProxy extends SingleChildRenderObjectWidget {
  6. const BaselineProxy({
  7. Key? key,
  8. Widget? child,
  9. this.textStyle,
  10. this.padding,
  11. }) : super(key: key, child: child);
  12. final TextStyle? textStyle;
  13. final EdgeInsets? padding;
  14. @override
  15. RenderBaselineProxy createRenderObject(BuildContext context) {
  16. return RenderBaselineProxy(null, textStyle!, padding);
  17. }
  18. @override
  19. void updateRenderObject(
  20. BuildContext context, covariant RenderBaselineProxy renderObject) {
  21. renderObject
  22. ..textStyle = textStyle!
  23. ..padding = padding!;
  24. }
  25. }
  26. /* ---------------------------------- Embed --------------------------------- */
  27. typedef EmbedBuilderFuncion = Widget Function(BuildContext context, Embed node);
  28. class EmbedProxy extends SingleChildRenderObjectWidget {
  29. const EmbedProxy(Widget child) : super(child: child);
  30. @override
  31. RenderEmbedProxy createRenderObject(BuildContext context) =>
  32. RenderEmbedProxy(null);
  33. }
  34. /* ---------------------------------- Text ---------------------------------- */
  35. class RichTextProxy extends SingleChildRenderObjectWidget {
  36. const RichTextProxy(
  37. RichText child,
  38. this.textStyle,
  39. this.textAlign,
  40. this.textDirection,
  41. this.textScaleFactor,
  42. this.locale,
  43. this.strutStyle,
  44. this.textWidthBasis,
  45. this.textHeightBehavior,
  46. ) : super(child: child);
  47. final TextStyle textStyle;
  48. final TextAlign textAlign;
  49. final TextDirection textDirection;
  50. final double textScaleFactor;
  51. final Locale locale;
  52. final StrutStyle strutStyle;
  53. final TextWidthBasis textWidthBasis;
  54. final TextHeightBehavior? textHeightBehavior;
  55. @override
  56. RenderParagraphProxy createRenderObject(BuildContext context) {
  57. return RenderParagraphProxy(
  58. null,
  59. textStyle,
  60. textAlign,
  61. textDirection,
  62. textScaleFactor,
  63. strutStyle,
  64. locale,
  65. textWidthBasis,
  66. textHeightBehavior,
  67. );
  68. }
  69. @override
  70. void updateRenderObject(
  71. BuildContext context, covariant RenderParagraphProxy renderObject) {
  72. renderObject
  73. ..textStyle = textStyle
  74. ..textAlign = textAlign
  75. ..textDirection = textDirection
  76. ..textScaleFactor = textScaleFactor
  77. ..locale = locale
  78. ..strutStyle = strutStyle
  79. ..textWidthBasis = textWidthBasis
  80. ..textHeightBehavior = textHeightBehavior;
  81. }
  82. }