From 87e8505f698a38772216faf656f19f88ebefcaef Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Fri, 3 Nov 2017 10:55:45 -0700 Subject: [PATCH] Test of bidi with formatting (#12860) --- dev/manual_tests/lib/text.dart | 92 ++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 5 deletions(-) diff --git a/dev/manual_tests/lib/text.dart b/dev/manual_tests/lib/text.dart index 11b3a634e5..64effdc274 100644 --- a/dev/manual_tests/lib/text.dart +++ b/dev/manual_tests/lib/text.dart @@ -18,6 +18,7 @@ void main() { routes: { 'underlines': (BuildContext context) => const Underlines(), 'fallback': (BuildContext context) => const Fallback(), + 'bidi': (BuildContext context) => const Bidi(), 'fuzzer': (BuildContext context) => new Fuzzer(seed: seed), 'zalgo': (BuildContext context) => new Zalgo(seed: seed), 'painting': (BuildContext context) => new Painting(seed: seed), @@ -44,31 +45,37 @@ class _HomeState extends State { children: [ new FlatButton( child: const Text('Test Underlines'), - color: Colors.cyan.shade200, + color: Colors.red.shade800, textColor: Colors.white, onPressed: () { Navigator.of(context).pushNamed('underlines'); }, ), new FlatButton( child: const Text('Test Font Fallback'), - color: Colors.pink.shade700, + color: Colors.orange.shade700, textColor: Colors.white, onPressed: () { Navigator.of(context).pushNamed('fallback'); }, ), + new FlatButton( + child: const Text('Test Bidi Formatting'), + color: Colors.yellow.shade700, + textColor: Colors.black, + onPressed: () { Navigator.of(context).pushNamed('bidi'); }, + ), new FlatButton( child: const Text('TextSpan Fuzzer'), - color: Colors.yellow, + color: Colors.green.shade400, textColor: Colors.black, onPressed: () { Navigator.of(context).pushNamed('fuzzer'); }, ), new FlatButton( child: const Text('Diacritics Fuzzer'), - color: Colors.black, + color: Colors.blue.shade400, textColor: Colors.white, onPressed: () { Navigator.of(context).pushNamed('zalgo'); }, ), new FlatButton( child: const Text('Painting Fuzzer'), - color: Colors.blueGrey.shade200, + color: Colors.purple.shade200, textColor: Colors.black, onPressed: () { Navigator.of(context).pushNamed('painting'); }, ), @@ -699,6 +706,81 @@ class _FallbackState extends State { } } +class Bidi extends StatefulWidget { + const Bidi({ Key key }) : super(key: key); + + @override + _BidiState createState() => new _BidiState(); +} + +class _BidiState extends State { + @override + Widget build(BuildContext context) { + return new Container( + color: Colors.black, + child: new ListView( + padding: const EdgeInsets.symmetric(vertical: 40.0, horizontal: 20.0), + children: [ + new RichText( + text: new TextSpan( + children: [ + new TextSpan(text: 'abc', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.blue.shade100)), + new TextSpan(text: 'ghi', style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 40.0, color: Colors.blue.shade500)), + new TextSpan(text: 'mno', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 40.0, color: Colors.blue.shade900)), + new TextSpan(text: 'LKJ', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 40.0, color: Colors.blue.shade700)), + new TextSpan(text: 'FED', style: new TextStyle(fontWeight: FontWeight.w300, fontSize: 40.0, color: Colors.blue.shade300)), + ], + ), + textAlign: TextAlign.center, + textDirection: TextDirection.ltr, + ), + new RichText( + text: new TextSpan( + children: [ + new TextSpan(text: '${Unicode.LRO}abc', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.blue.shade100)), + new TextSpan(text: '${Unicode.RLO}DEF', style: new TextStyle(fontWeight: FontWeight.w300, fontSize: 40.0, color: Colors.blue.shade300)), + new TextSpan(text: '${Unicode.LRO}ghi', style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 40.0, color: Colors.blue.shade500)), + new TextSpan(text: '${Unicode.RLO}JKL', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 40.0, color: Colors.blue.shade700)), + new TextSpan(text: '${Unicode.LRO}mno', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 40.0, color: Colors.blue.shade900)), + ], + ), + textAlign: TextAlign.center, + textDirection: TextDirection.ltr, + ), + const SizedBox(height: 40.0), + new RichText( + text: new TextSpan( + children: [ + new TextSpan(text: '${Unicode.LRO}abc${Unicode.RLO}D', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), + new TextSpan(text: 'EF${Unicode.LRO}gh', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), + new TextSpan(text: 'i${Unicode.RLO}JKL${Unicode.LRO}mno', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), + ], + ), + textAlign: TextAlign.center, + textDirection: TextDirection.ltr, + ), + new RichText( + text: new TextSpan( + children: [ + new TextSpan(text: 'abc', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), + new TextSpan(text: 'gh', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), + new TextSpan(text: 'imno', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), + new TextSpan(text: 'LKJ', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), + new TextSpan(text: 'FE', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), + new TextSpan(text: 'D', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), + ], + ), + textAlign: TextAlign.center, + textDirection: TextDirection.ltr, + ), + const SizedBox(height: 40.0), + const Text('The pairs of lines above should match exactly.', textAlign: TextAlign.center, style: const TextStyle(inherit: false, fontSize: 14.0, color: Colors.white)), + ], + ), + ); + } +} + class Zalgo extends StatefulWidget { const Zalgo({ Key key, this.seed }) : super(key: key);