瀏覽代碼

handled text overflow for text in title bar

ashilkn 2 年之前
父節點
當前提交
cb810266bf
共有 2 個文件被更改,包括 21 次插入4 次删除
  1. 18 3
      lib/ui/components/title_bar_title_widget.dart
  2. 3 1
      lib/ui/components/title_bar_widget.dart

+ 18 - 3
lib/ui/components/title_bar_title_widget.dart

@@ -18,16 +18,31 @@ class TitleBarTitleWidget extends StatelessWidget {
           mainAxisSize: MainAxisSize.min,
           crossAxisAlignment: CrossAxisAlignment.center,
           children: <Widget>[
-            Text(title!, style: textTheme.h3Bold),
+            Text(
+              title!,
+              style: textTheme.h3Bold,
+              overflow: TextOverflow.ellipsis,
+              maxLines: 1,
+            ),
             const SizedBox(width: 8),
             Icon(icon, size: 20, color: colorTheme.strokeMuted),
           ],
         );
       }
       if (isTitleH2) {
-        return Text(title!, style: textTheme.h2Bold);
+        return Text(
+          title!,
+          style: textTheme.h2Bold,
+          overflow: TextOverflow.ellipsis,
+          maxLines: 1,
+        );
       } else {
-        return Text(title!, style: textTheme.h3Bold);
+        return Text(
+          title!,
+          style: textTheme.h3Bold,
+          overflow: TextOverflow.ellipsis,
+          maxLines: 1,
+        );
       }
     }
 

+ 3 - 1
lib/ui/components/title_bar_widget.dart

@@ -88,10 +88,12 @@ class TitleBarWidget extends StatelessWidget {
               flexibleSpaceCaption == null
                   ? const SizedBox.shrink()
                   : Text(
-                      'Caption',
+                      flexibleSpaceCaption!,
                       style: textTheme.small.copyWith(
                         color: colorTheme.textMuted,
                       ),
+                      overflow: TextOverflow.ellipsis,
+                      maxLines: 1,
                     )
             ],
           ),