Move TextAlign out of TextStyle (#3789)

TextAlign applies to a whole paragraph instead of applying to an individual
text span. This patch moves the property out of TextStyle and into a separate
property on Text and RichText.
This commit is contained in:
Adam Barth
2016-05-06 17:33:27 -07:00
parent 8f4a5659b0
commit ee903af03f
20 changed files with 194 additions and 132 deletions

View File

@@ -4,15 +4,14 @@
import 'package:flutter/material.dart';
final TextStyle _kTextStyle = new TextStyle(
color: Colors.indigo[400],
fontSize: 24.0
);
class ModalBottomSheetDemo extends StatelessWidget {
static const String routeName = '/modal-bottom-sheet';
final TextStyle textStyle = new TextStyle(
color: Colors.indigo[400],
fontSize: 24.0,
textAlign: TextAlign.center
);
@override
Widget build(BuildContext context) {
return new Scaffold(
@@ -25,7 +24,10 @@ class ModalBottomSheetDemo extends StatelessWidget {
return new Container(
child: new Padding(
padding: const EdgeInsets.all(32.0),
child: new Text('This is the modal bottom sheet. Click anywhere to dismiss.', style: textStyle)
child: new Text('This is the modal bottom sheet. Click anywhere to dismiss.',
style: _kTextStyle,
textAlign: TextAlign.center
)
)
);
});

View File

@@ -4,6 +4,11 @@
import 'package:flutter/material.dart';
final TextStyle _kTextStyle = new TextStyle(
color: Colors.indigo[400],
fontSize: 24.0
);
class PersistentBottomSheetDemo extends StatefulWidget {
static const String routeName = '/persistent-bottom-sheet';
@@ -14,12 +19,6 @@ class PersistentBottomSheetDemo extends StatefulWidget {
class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
final TextStyle textStyle = new TextStyle(
color: Colors.indigo[400],
fontSize: 24.0,
textAlign: TextAlign.center
);
VoidCallback _showBottomSheetCallback;
@override
@@ -40,7 +39,10 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
),
child: new Padding(
padding: const EdgeInsets.all(32.0),
child: new Text('This is a Material persistent bottom sheet. Drag downwards to dismiss it.', style: textStyle)
child: new Text('This is a Material persistent bottom sheet. Drag downwards to dismiss it.',
style: _kTextStyle,
textAlign: TextAlign.center
)
)
);
})

View File

@@ -72,18 +72,18 @@ class _TabsFabDemoState extends State<TabsFabDemo> {
Widget buildTabView(_Page page) {
return new Builder(
builder: (BuildContext context) {
final TextStyle textStyle = new TextStyle(
color: page.labelColor,
fontSize: 32.0,
textAlign: TextAlign.center
);
return new Container(
key: new ValueKey<String>(page.label),
padding: const EdgeInsets.fromLTRB(48.0, 48.0, 48.0, 96.0),
child: new Card(
child: new Center(
child: new Text(page.label, style: textStyle)
child: new Text(page.label,
style: new TextStyle(
color: page.labelColor,
fontSize: 32.0
),
textAlign: TextAlign.center
)
)
)
);

View File

@@ -100,18 +100,18 @@ class StockRow extends StatelessWidget {
new Flexible(
child: new Text(
lastSale,
style: const TextStyle(textAlign: TextAlign.right)
textAlign: TextAlign.right
)
),
new Flexible(
child: new Text(
changeInPrice,
style: const TextStyle(textAlign: TextAlign.right)
textAlign: TextAlign.right
)
),
],
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: DefaultTextStyle.of(context).textBaseline
textBaseline: DefaultTextStyle.of(context).style.textBaseline
)
),
]

View File

@@ -52,7 +52,7 @@ class StockSymbolView extends StatelessWidget {
),
new RichText(
text: new TextSpan(
style: DefaultTextStyle.of(context).merge(new TextStyle(fontSize: 8.0)),
style: DefaultTextStyle.of(context).style.merge(new TextStyle(fontSize: 8.0)),
text: 'Prices may be delayed by ',
children: <TextSpan>[
new TextSpan(text: 'several', style: new TextStyle(fontStyle: FontStyle.italic)),