From 9f4df079a2e5127f8b86afae0a26e0db36b30cd5 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Wed, 1 Jan 2020 12:55:27 +0800 Subject: [PATCH] refactor: text with organization --- lib/screens/me.dart | 2 +- lib/screens/user.dart | 2 +- lib/screens/users.dart | 1 - lib/widgets/text_contains_organization.dart | 10 ++++++---- lib/widgets/user_item.dart | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/screens/me.dart b/lib/screens/me.dart index b5cf877..aaaa58d 100644 --- a/lib/screens/me.dart +++ b/lib/screens/me.dart @@ -95,7 +95,7 @@ class MeScreen extends StatelessWidget { text: TextContainsOrganization( user.company, style: TextStyle(fontSize: 16, color: theme.palette.text), - overflow: TextOverflow.ellipsis, + oneLine: true, ), ), if (isNotNullOrEmpty(user.location)) diff --git a/lib/screens/user.dart b/lib/screens/user.dart index 23ab001..418ae1e 100644 --- a/lib/screens/user.dart +++ b/lib/screens/user.dart @@ -143,7 +143,7 @@ class UserScreen extends StatelessWidget { text: TextContainsOrganization( user.company, style: TextStyle(fontSize: 16, color: theme.palette.text), - overflow: TextOverflow.ellipsis, + oneLine: true, ), ), if (isNotNullOrEmpty(user.location)) diff --git a/lib/screens/users.dart b/lib/screens/users.dart index a99321c..a4ccbc4 100644 --- a/lib/screens/users.dart +++ b/lib/screens/users.dart @@ -105,7 +105,6 @@ class UsersScreen extends StatelessWidget { name: payload.name, avatarUrl: payload.avatarUrl, bio: payload.bio, - inUserScreen: true, ); }, ); diff --git a/lib/widgets/text_contains_organization.dart b/lib/widgets/text_contains_organization.dart index 49f7a42..9be038a 100644 --- a/lib/widgets/text_contains_organization.dart +++ b/lib/widgets/text_contains_organization.dart @@ -4,10 +4,9 @@ import 'package:git_touch/utils/utils.dart'; class TextContainsOrganization extends StatelessWidget { final String text; final TextStyle style; - final TextOverflow overflow; + final bool oneLine; - TextContainsOrganization(this.text, - {this.style, this.overflow = TextOverflow.clip}); + TextContainsOrganization(this.text, {this.style, this.oneLine = false}); static final _reg = RegExp(r'@[A-Za-z-]+'); @@ -29,6 +28,9 @@ class TextContainsOrganization extends StatelessWidget { } return RichText( - text: TextSpan(children: spans, style: style), overflow: overflow); + text: TextSpan(children: spans, style: style), + overflow: oneLine ? TextOverflow.ellipsis : null, + maxLines: oneLine ? 1 : null, + ); } } diff --git a/lib/widgets/user_item.dart b/lib/widgets/user_item.dart index 45ec942..c41aec3 100644 --- a/lib/widgets/user_item.dart +++ b/lib/widgets/user_item.dart @@ -76,7 +76,7 @@ class UserItem extends StatelessWidget { color: theme.palette.secondaryText, fontSize: 15, ), - overflow: TextOverflow.ellipsis, + oneLine: true, ), ], ),