| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:sky/painting/text_style.dart'; | 5 import 'package:sky/painting/text_style.dart'; |
| 6 import 'package:sky/rendering/box.dart'; | 6 import 'package:sky/rendering/box.dart'; |
| 7 import 'package:sky/rendering/flex.dart'; | 7 import 'package:sky/rendering/flex.dart'; |
| 8 import 'package:sky/rendering/sky_binding.dart'; | 8 import 'package:sky/rendering/sky_binding.dart'; |
| 9 import 'package:sky/theme/colors.dart'; | 9 import 'package:sky/theme/colors.dart' as colors; |
| 10 import 'package:sky/widgets/basic.dart'; | 10 import 'package:sky/widgets/basic.dart'; |
| 11 import 'package:sky/widgets/material.dart'; | 11 import 'package:sky/widgets/material.dart'; |
| 12 import 'package:sky/widgets/scaffold.dart'; | 12 import 'package:sky/widgets/scaffold.dart'; |
| 13 import 'package:sky/widgets/theme.dart'; | 13 import 'package:sky/widgets/theme.dart'; |
| 14 import 'package:sky/widgets/tool_bar.dart'; | 14 import 'package:sky/widgets/tool_bar.dart'; |
| 15 import 'package:sky/widgets/widget.dart'; | 15 import 'package:sky/widgets/widget.dart'; |
| 16 | 16 |
| 17 | 17 |
| 18 class StyledTextApp extends App { | 18 class StyledTextApp extends App { |
| 19 | 19 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 34 Dave: Open the pod bay doors, HAL. | 34 Dave: Open the pod bay doors, HAL. |
| 35 HAL: I'm sorry, Dave. I'm afraid I can't do that. | 35 HAL: I'm sorry, Dave. I'm afraid I can't do that. |
| 36 Dave: What's the problem? | 36 Dave: What's the problem? |
| 37 HAL: I think you know what the problem is just as well as I do. | 37 HAL: I think you know what the problem is just as well as I do. |
| 38 Dave: What are you talking about, HAL? | 38 Dave: What are you talking about, HAL? |
| 39 HAL: This mission is too important for me to allow you to jeopardize it.'''; | 39 HAL: This mission is too important for me to allow you to jeopardize it.'''; |
| 40 | 40 |
| 41 // [["Dave", "Open the pod bay..."] ...] | 41 // [["Dave", "Open the pod bay..."] ...] |
| 42 List<List<String>> nameLines; | 42 List<List<String>> nameLines; |
| 43 | 43 |
| 44 final TextStyle daveStyle = new TextStyle(color: Indigo[400], height: 1.8); | 44 final TextStyle daveStyle = new TextStyle(color: colors.Indigo[400], height: 1
.8); |
| 45 final TextStyle halStyle = new TextStyle(color: Red[400], fontFamily: "monospa
ce"); | 45 final TextStyle halStyle = new TextStyle(color: colors.Red[400], fontFamily: "
monospace"); |
| 46 final TextStyle boldStyle = const TextStyle(fontWeight: bold); | 46 final TextStyle boldStyle = const TextStyle(fontWeight: bold); |
| 47 final TextStyle underlineStyle = const TextStyle( | 47 final TextStyle underlineStyle = const TextStyle( |
| 48 decoration: underline, | 48 decoration: underline, |
| 49 decorationColor: const Color(0xFF000000), | 49 decorationColor: const Color(0xFF000000), |
| 50 decorationStyle: TextDecorationStyle.wavy | 50 decorationStyle: TextDecorationStyle.wavy |
| 51 ); | 51 ); |
| 52 | 52 |
| 53 Component toStyledText(String name, String text) { | 53 Component toStyledText(String name, String text) { |
| 54 TextStyle lineStyle = (name == "Dave") ? daveStyle : halStyle; | 54 TextStyle lineStyle = (name == "Dave") ? daveStyle : halStyle; |
| 55 return new StyledText( | 55 return new StyledText( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 alignItems: FlexAlignItems.flexStart | 99 alignItems: FlexAlignItems.flexStart |
| 100 ) | 100 ) |
| 101 ); | 101 ); |
| 102 | 102 |
| 103 Listener interactiveBody = new Listener( | 103 Listener interactiveBody = new Listener( |
| 104 child: body, | 104 child: body, |
| 105 onPointerDown: toggleToTextFunction | 105 onPointerDown: toggleToTextFunction |
| 106 ); | 106 ); |
| 107 | 107 |
| 108 return new Theme( | 108 return new Theme( |
| 109 data: new ThemeData.light(primary: Blue, darkToolbar: true), | 109 data: new ThemeData.light(primary: colors.Blue, darkToolbar: true), |
| 110 child: new Scaffold( | 110 child: new Scaffold( |
| 111 body: new Material(child: interactiveBody), | 111 body: new Material( |
| 112 color: colors.Grey[50], |
| 113 child: interactiveBody |
| 114 ), |
| 112 toolbar: new ToolBar( | 115 toolbar: new ToolBar( |
| 113 center: new Text('Hal and Dave') | 116 center: new Text('Hal and Dave') |
| 114 ) | 117 ) |
| 115 ) | 118 ) |
| 116 ); | 119 ); |
| 117 } | 120 } |
| 118 } | 121 } |
| 119 | 122 |
| 120 void main() { | 123 void main() { |
| 121 runApp(new StyledTextApp()); | 124 runApp(new StyledTextApp()); |
| 122 SkyBinding.instance.onFrame = () { | 125 SkyBinding.instance.onFrame = () { |
| 123 // uncomment this for debugging: | 126 // uncomment this for debugging: |
| 124 // SkyBinding.instance.debugDumpRenderTree(); | 127 // SkyBinding.instance.debugDumpRenderTree(); |
| 125 }; | 128 }; |
| 126 } | 129 } |
| OLD | NEW |