Commit ab89d2e4 authored by Adam Barth's avatar Adam Barth

Update to the new TextDecoration API

Now with fewer lists.
parent 3b3d5983
......@@ -31,7 +31,7 @@ const List<Color> textColors = const <Color>[
];
final List<TextStyle> textStyles = textColors.map((Color color) {
return new TextStyle(color: color, fontWeight: bold, textAlign: TextAlign.center);
return new TextStyle(color: color, fontWeight: FontWeight.bold, textAlign: TextAlign.center);
}).toList();
enum CellState { covered, exploded, cleared, flagged, shown }
......
......@@ -26,7 +26,7 @@ class CardCollection extends StatefulComponent {
class CardCollectionState extends State<CardCollection> {
static const TextStyle cardLabelStyle =
const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: bold);
const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.bold);
// TODO(hansmuller): need a local image asset
static const _sunshineURL = "http://www.walltor.com/images/wallpaper/good-morning-sunshine-58540.jpg";
......
......@@ -25,13 +25,13 @@ class TappableCard extends StatelessComponent {
static const TextStyle cardLabelStyle = const TextStyle(
color: Colors.white,
fontSize: 18.0,
fontWeight: bold
fontWeight: FontWeight.bold
);
static const TextStyle selectedCardLabelStyle = const TextStyle(
color: Colors.white,
fontSize: 24.0,
fontWeight: bold
fontWeight: FontWeight.bold
);
Widget build(BuildContext context) {
......
......@@ -20,7 +20,7 @@ class IndexedStackDemoState extends State<IndexedStackDemo> {
}
List<PopupMenuItem> _buildMenu() {
TextStyle style = const TextStyle(fontSize: 18.0, fontWeight: bold);
TextStyle style = const TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold);
String pad = '';
return new List<PopupMenuItem>.generate(_itemCount, (int i) {
pad += '-';
......
......@@ -91,7 +91,7 @@ class OverlayGeometryApp extends StatefulComponent {
class OverlayGeometryAppState extends State<OverlayGeometryApp> {
static const TextStyle cardLabelStyle =
const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: bold);
const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.bold);
List<CardModel> cardModels;
Map<MarkerType, Point> markers = new Map<MarkerType, Point>();
......
......@@ -34,7 +34,7 @@ class PageableListAppState extends State<PageableListApp> {
}
static const TextStyle cardLabelStyle =
const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: bold);
const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.bold);
List<CardModel> cardModels;
Size pageSize = new Size(200.0, 200.0);
......
......@@ -39,9 +39,9 @@ HAL: This mission is too important for me to allow you to jeopardize it.''';
final TextStyle daveStyle = new TextStyle(color: Colors.indigo[400], height: 1.8);
final TextStyle halStyle = new TextStyle(color: Colors.red[400], fontFamily: "monospace");
final TextStyle boldStyle = const TextStyle(fontWeight: bold);
final TextStyle boldStyle = const TextStyle(fontWeight: FontWeight.bold);
final TextStyle underlineStyle = const TextStyle(
decoration: underline,
decoration: TextDecoration.underline,
decorationColor: const Color(0xFF000000),
decorationStyle: TextDecorationStyle.wavy
);
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment