3
3
// found in the LICENSE file.
4
4
5
5
6
+ import 'package:flutter/foundation.dart' ;
6
7
import 'package:flutter/painting.dart' ;
8
+ import 'package:meta/meta.dart' ;
7
9
8
10
import 'colors.dart' ;
9
11
@@ -51,7 +53,7 @@ class TextTheme {
51
53
this .button
52
54
});
53
55
54
- const TextTheme ._black ()
56
+ const TextTheme ._blackMountainView ()
55
57
: display4 = const TextStyle (fontFamily: 'Roboto' , inherit: false , fontSize: 112.0 , fontWeight: FontWeight .w100, color: Colors .black54, textBaseline: TextBaseline .alphabetic),
56
58
display3 = const TextStyle (fontFamily: 'Roboto' , inherit: false , fontSize: 56.0 , fontWeight: FontWeight .w400, color: Colors .black54, textBaseline: TextBaseline .alphabetic),
57
59
display2 = const TextStyle (fontFamily: 'Roboto' , inherit: false , fontSize: 45.0 , fontWeight: FontWeight .w400, color: Colors .black54, textBaseline: TextBaseline .alphabetic),
@@ -64,7 +66,7 @@ class TextTheme {
64
66
caption = const TextStyle (fontFamily: 'Roboto' , inherit: false , fontSize: 12.0 , fontWeight: FontWeight .w400, color: Colors .black54, textBaseline: TextBaseline .alphabetic),
65
67
button = const TextStyle (fontFamily: 'Roboto' , inherit: false , fontSize: 14.0 , fontWeight: FontWeight .w500, color: Colors .black87, textBaseline: TextBaseline .alphabetic);
66
68
67
- const TextTheme ._white ()
69
+ const TextTheme ._whiteMountainView ()
68
70
: display4 = const TextStyle (fontFamily: 'Roboto' , inherit: false , fontSize: 112.0 , fontWeight: FontWeight .w100, color: Colors .white70, textBaseline: TextBaseline .alphabetic),
69
71
display3 = const TextStyle (fontFamily: 'Roboto' , inherit: false , fontSize: 56.0 , fontWeight: FontWeight .w400, color: Colors .white70, textBaseline: TextBaseline .alphabetic),
70
72
display2 = const TextStyle (fontFamily: 'Roboto' , inherit: false , fontSize: 45.0 , fontWeight: FontWeight .w400, color: Colors .white70, textBaseline: TextBaseline .alphabetic),
@@ -77,6 +79,32 @@ class TextTheme {
77
79
caption = const TextStyle (fontFamily: 'Roboto' , inherit: false , fontSize: 12.0 , fontWeight: FontWeight .w400, color: Colors .white70, textBaseline: TextBaseline .alphabetic),
78
80
button = const TextStyle (fontFamily: 'Roboto' , inherit: false , fontSize: 14.0 , fontWeight: FontWeight .w500, color: Colors .white, textBaseline: TextBaseline .alphabetic);
79
81
82
+ const TextTheme ._blackCupertino ()
83
+ : display4 = const TextStyle (fontFamily: '.SF UI Display' , inherit: false , fontSize: 112.0 , fontWeight: FontWeight .w100, color: Colors .black54, textBaseline: TextBaseline .alphabetic),
84
+ display3 = const TextStyle (fontFamily: '.SF UI Display' , inherit: false , fontSize: 56.0 , fontWeight: FontWeight .w400, color: Colors .black54, textBaseline: TextBaseline .alphabetic),
85
+ display2 = const TextStyle (fontFamily: '.SF UI Display' , inherit: false , fontSize: 45.0 , fontWeight: FontWeight .w400, color: Colors .black54, textBaseline: TextBaseline .alphabetic),
86
+ display1 = const TextStyle (fontFamily: '.SF UI Display' , inherit: false , fontSize: 34.0 , fontWeight: FontWeight .w400, color: Colors .black54, textBaseline: TextBaseline .alphabetic),
87
+ headline = const TextStyle (fontFamily: '.SF UI Display' , inherit: false , fontSize: 24.0 , fontWeight: FontWeight .w400, color: Colors .black87, textBaseline: TextBaseline .alphabetic),
88
+ title = const TextStyle (fontFamily: '.SF UI Display' , inherit: false , fontSize: 20.0 , fontWeight: FontWeight .w500, color: Colors .black87, textBaseline: TextBaseline .alphabetic),
89
+ subhead = const TextStyle (fontFamily: '.SF UI Text' , inherit: false , fontSize: 16.0 , fontWeight: FontWeight .w400, color: Colors .black87, textBaseline: TextBaseline .alphabetic),
90
+ body2 = const TextStyle (fontFamily: '.SF UI Text' , inherit: false , fontSize: 14.0 , fontWeight: FontWeight .w500, color: Colors .black87, textBaseline: TextBaseline .alphabetic),
91
+ body1 = const TextStyle (fontFamily: '.SF UI Text' , inherit: false , fontSize: 14.0 , fontWeight: FontWeight .w400, color: Colors .black87, textBaseline: TextBaseline .alphabetic),
92
+ caption = const TextStyle (fontFamily: '.SF UI Text' , inherit: false , fontSize: 12.0 , fontWeight: FontWeight .w400, color: Colors .black54, textBaseline: TextBaseline .alphabetic),
93
+ button = const TextStyle (fontFamily: '.SF UI Text' , inherit: false , fontSize: 14.0 , fontWeight: FontWeight .w500, color: Colors .black87, textBaseline: TextBaseline .alphabetic);
94
+
95
+ const TextTheme ._whiteCupertino ()
96
+ : display4 = const TextStyle (fontFamily: '.SF UI Display' , inherit: false , fontSize: 112.0 , fontWeight: FontWeight .w100, color: Colors .white70, textBaseline: TextBaseline .alphabetic),
97
+ display3 = const TextStyle (fontFamily: '.SF UI Display' , inherit: false , fontSize: 56.0 , fontWeight: FontWeight .w400, color: Colors .white70, textBaseline: TextBaseline .alphabetic),
98
+ display2 = const TextStyle (fontFamily: '.SF UI Display' , inherit: false , fontSize: 45.0 , fontWeight: FontWeight .w400, color: Colors .white70, textBaseline: TextBaseline .alphabetic),
99
+ display1 = const TextStyle (fontFamily: '.SF UI Display' , inherit: false , fontSize: 34.0 , fontWeight: FontWeight .w400, color: Colors .white70, textBaseline: TextBaseline .alphabetic),
100
+ headline = const TextStyle (fontFamily: '.SF UI Display' , inherit: false , fontSize: 24.0 , fontWeight: FontWeight .w400, color: Colors .white, textBaseline: TextBaseline .alphabetic),
101
+ title = const TextStyle (fontFamily: '.SF UI Display' , inherit: false , fontSize: 20.0 , fontWeight: FontWeight .w500, color: Colors .white, textBaseline: TextBaseline .alphabetic),
102
+ subhead = const TextStyle (fontFamily: '.SF UI Text' , inherit: false , fontSize: 16.0 , fontWeight: FontWeight .w400, color: Colors .white, textBaseline: TextBaseline .alphabetic),
103
+ body2 = const TextStyle (fontFamily: '.SF UI Text' , inherit: false , fontSize: 14.0 , fontWeight: FontWeight .w500, color: Colors .white, textBaseline: TextBaseline .alphabetic),
104
+ body1 = const TextStyle (fontFamily: '.SF UI Text' , inherit: false , fontSize: 14.0 , fontWeight: FontWeight .w400, color: Colors .white, textBaseline: TextBaseline .alphabetic),
105
+ caption = const TextStyle (fontFamily: '.SF UI Text' , inherit: false , fontSize: 12.0 , fontWeight: FontWeight .w400, color: Colors .white70, textBaseline: TextBaseline .alphabetic),
106
+ button = const TextStyle (fontFamily: '.SF UI Text' , inherit: false , fontSize: 14.0 , fontWeight: FontWeight .w500, color: Colors .white, textBaseline: TextBaseline .alphabetic);
107
+
80
108
/// Extremely large text.
81
109
///
82
110
/// The font size is 112 pixels.
@@ -255,10 +283,10 @@ class TextTheme {
255
283
256
284
/// The two material design text themes.
257
285
///
258
- /// [Typography. black] and [Typography. white] define the two text themes used in
259
- /// material design. The black text theme, which uses dark glyphs, is used on
260
- /// light backgrounds in light themes. The white text theme, which uses light
261
- /// glyphs, is used in dark themes and on dark backgrounds in in light themes.
286
+ /// Material design defines two text themes: [ black] and [white] . The black
287
+ /// text theme, which uses dark glyphs, is used on light backgrounds in light
288
+ /// themes. The white text theme, which uses light glyphs, is used in dark
289
+ /// themes and on dark backgrounds in light themes.
262
290
///
263
291
/// To obtain the current text theme, call [Theme.of] with the current
264
292
/// [BuildContext] and read the [ThemeData.textTheme] property.
@@ -269,11 +297,30 @@ class TextTheme {
269
297
/// * [ThemeData]
270
298
/// * <http://material.google.com/style/typography.html>
271
299
class Typography {
272
- Typography ._();
300
+ /// Creates the default typography for the specified platform.
301
+ factory Typography ({ @required TargetPlatform platform }) {
302
+ assert (platform != null );
303
+ switch (platform) {
304
+ case TargetPlatform .android:
305
+ case TargetPlatform .fuchsia:
306
+ return const Typography ._(
307
+ const TextTheme ._blackMountainView (),
308
+ const TextTheme ._whiteMountainView (),
309
+ );
310
+ case TargetPlatform .iOS:
311
+ return const Typography ._(
312
+ const TextTheme ._blackCupertino (),
313
+ const TextTheme ._whiteCupertino (),
314
+ );
315
+ }
316
+ return null ;
317
+ }
318
+
319
+ const Typography ._(this .black, this .white);
273
320
274
321
/// A material design text theme with dark glyphs.
275
- static const TextTheme black = const TextTheme . _black () ;
322
+ final TextTheme black;
276
323
277
324
/// A material design text theme with light glyphs.
278
- static const TextTheme white = const TextTheme . _white () ;
325
+ final TextTheme white;
279
326
}
0 commit comments