Merge pull request #846 from abarth/text_decoration
Update to the new TextDecoration API
This commit is contained in:
@@ -18,7 +18,7 @@ const TextStyle _errorTextStyle = const TextStyle(
|
||||
fontSize: 48.0,
|
||||
fontWeight: FontWeight.w900,
|
||||
textAlign: TextAlign.right,
|
||||
decoration: underline,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationColor: const Color(0xFFFF00),
|
||||
decorationStyle: TextDecorationStyle.double
|
||||
);
|
||||
|
||||
@@ -71,7 +71,7 @@ class Typography {
|
||||
fontSize: 48.0,
|
||||
fontWeight: FontWeight.w900,
|
||||
textAlign: TextAlign.right,
|
||||
decoration: underline,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationColor: const Color(0xFFFF00),
|
||||
decorationStyle: TextDecorationStyle.double
|
||||
);
|
||||
|
||||
@@ -6,21 +6,6 @@ import 'dart:ui' as ui;
|
||||
|
||||
import 'basic_types.dart';
|
||||
|
||||
/// A normal font weight
|
||||
const normal = FontWeight.w400;
|
||||
|
||||
/// A bold font weight
|
||||
const bold = FontWeight.w700;
|
||||
|
||||
/// Draw a line underneath each line of text
|
||||
const underline = const <TextDecoration>[TextDecoration.underline];
|
||||
|
||||
/// Draw a line above each line of text
|
||||
const overline = const <TextDecoration>[TextDecoration.overline];
|
||||
|
||||
/// Draw a line through each line of text
|
||||
const lineThrough = const <TextDecoration>[TextDecoration.lineThrough];
|
||||
|
||||
/// An immutable style in which paint text
|
||||
class TextStyle {
|
||||
const TextStyle({
|
||||
@@ -70,8 +55,8 @@ class TextStyle {
|
||||
/// The distance between the text baselines, as a multiple of the font size.
|
||||
final double height;
|
||||
|
||||
/// A list of decorations to paint near the text.
|
||||
final List<TextDecoration> decoration; // TODO(ianh): Switch this to a Set<> once Dart supports constant Sets
|
||||
/// The decorations to paint near the text.
|
||||
final TextDecoration decoration;
|
||||
|
||||
/// The color in which to paint the text decorations.
|
||||
final Color decorationColor;
|
||||
@@ -91,7 +76,7 @@ class TextStyle {
|
||||
TextAlign textAlign,
|
||||
TextBaseline textBaseline,
|
||||
double height,
|
||||
List<TextDecoration> decoration,
|
||||
TextDecoration decoration,
|
||||
Color decorationColor,
|
||||
TextDecorationStyle decorationStyle
|
||||
}) {
|
||||
@@ -302,26 +287,7 @@ class TextStyle {
|
||||
if (decoration != null) {
|
||||
if (haveDecorationDescription)
|
||||
decorationDescription += ' ';
|
||||
bool multipleDecorations = false;
|
||||
for (TextDecoration value in decoration) {
|
||||
if (multipleDecorations)
|
||||
decorationDescription += '+';
|
||||
switch (value) {
|
||||
case TextDecoration.none:
|
||||
decorationDescription += 'none';
|
||||
break;
|
||||
case TextDecoration.underline:
|
||||
decorationDescription += 'underline';
|
||||
break;
|
||||
case TextDecoration.overline:
|
||||
decorationDescription += 'overline';
|
||||
break;
|
||||
case TextDecoration.lineThrough:
|
||||
decorationDescription += 'line-through';
|
||||
break;
|
||||
}
|
||||
multipleDecorations = true;
|
||||
}
|
||||
decorationDescription += '$decoration';
|
||||
haveDecorationDescription = true;
|
||||
}
|
||||
assert(haveDecorationDescription);
|
||||
|
||||
@@ -17,12 +17,7 @@ export 'package:flutter/painting.dart' show
|
||||
TextDecoration,
|
||||
TextDecorationStyle,
|
||||
TextSpan,
|
||||
TextStyle,
|
||||
normal,
|
||||
bold,
|
||||
underline,
|
||||
overline,
|
||||
lineThrough;
|
||||
TextStyle;
|
||||
|
||||
/// A render object that displays a paragraph of text
|
||||
class RenderParagraph extends RenderBox {
|
||||
|
||||
@@ -63,12 +63,7 @@ export 'package:flutter/rendering.dart' show
|
||||
TextStyle,
|
||||
TransferMode,
|
||||
ValueChanged,
|
||||
VoidCallback,
|
||||
bold,
|
||||
normal,
|
||||
underline,
|
||||
overline,
|
||||
lineThrough;
|
||||
VoidCallback;
|
||||
|
||||
|
||||
// PAINTING NODES
|
||||
|
||||
@@ -269,7 +269,7 @@ class _EditableTextWidget extends LeafRenderObjectWidget {
|
||||
TextSpan _buildTextSpan() {
|
||||
if (!hideText && value.composing.isValid) {
|
||||
TextStyle composingStyle = style.merge(
|
||||
const TextStyle(decoration: underline)
|
||||
const TextStyle(decoration: TextDecoration.underline)
|
||||
);
|
||||
|
||||
return new StyledTextSpan(style, <TextSpan>[
|
||||
|
||||
@@ -7,8 +7,8 @@ dependencies:
|
||||
collection: '>=1.1.3 <2.0.0'
|
||||
intl: '>=0.12.4+2 <0.13.0'
|
||||
material_design_icons: '>=0.0.3 <0.1.0'
|
||||
sky_engine: 0.0.69
|
||||
sky_services: 0.0.69
|
||||
sky_engine: 0.0.70
|
||||
sky_services: 0.0.70
|
||||
vector_math: '>=1.4.3 <2.0.0'
|
||||
|
||||
# To pin the transitive dependency through mojo_sdk.
|
||||
|
||||
Reference in New Issue
Block a user