refactor: text with organization

This commit is contained in:
Rongjian Zhang 2020-01-01 12:55:27 +08:00
parent cdd8876657
commit 9f4df079a2
5 changed files with 9 additions and 8 deletions

View File

@ -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))

View File

@ -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))

View File

@ -105,7 +105,6 @@ class UsersScreen extends StatelessWidget {
name: payload.name,
avatarUrl: payload.avatarUrl,
bio: payload.bio,
inUserScreen: true,
);
},
);

View File

@ -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,
);
}
}

View File

@ -76,7 +76,7 @@ class UserItem extends StatelessWidget {
color: theme.palette.secondaryText,
fontSize: 15,
),
overflow: TextOverflow.ellipsis,
oneLine: true,
),
],
),