mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 08:04:51 +01:00
feat: text contains organization
This commit is contained in:
parent
a1fe2df552
commit
562c67dac0
@ -359,14 +359,13 @@ class RepositoryScreen extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
],
|
||||
if ((payload['releases']['totalCount'] as int) > 0)
|
||||
TableViewItem(
|
||||
leftIconData: Octicons.tag,
|
||||
text: Text('Releases'),
|
||||
rightWidget: Text(
|
||||
(payload['releases']['totalCount'] as int).toString()),
|
||||
url: payload['url'] + '/releases',
|
||||
),
|
||||
TableViewItem(
|
||||
leftIconData: Octicons.tag,
|
||||
text: Text('Releases'),
|
||||
rightWidget: Text(
|
||||
(payload['releases']['totalCount'] as int).toString()),
|
||||
url: payload['url'] + '/releases',
|
||||
),
|
||||
TableViewItem(
|
||||
leftIconData: Octicons.law,
|
||||
text: Text('License'),
|
||||
|
@ -4,7 +4,9 @@ import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/screens/repositories.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/table_view.dart';
|
||||
import 'package:git_touch/widgets/text_contains_organization.dart';
|
||||
import 'package:git_touch/widgets/user_item.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:share/share.dart';
|
||||
import 'package:github_contributions/github_contributions.dart';
|
||||
@ -237,7 +239,10 @@ class UserScreen extends StatelessWidget {
|
||||
if (isNotNullOrEmpty(payload['company']))
|
||||
TableViewItem(
|
||||
leftIconData: Octicons.organization,
|
||||
text: Text(payload['company']),
|
||||
text: TextContainsOrganization(payload['company'],
|
||||
style: TextStyle(
|
||||
fontSize: 16, color: PrimerColors.gray900),
|
||||
overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
if (isNotNullOrEmpty(payload['location']))
|
||||
TableViewItem(
|
||||
|
35
lib/widgets/text_contains_organization.dart
Normal file
35
lib/widgets/text_contains_organization.dart
Normal file
@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/screens/organization.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
|
||||
class TextContainsOrganization extends StatelessWidget {
|
||||
final String text;
|
||||
final TextStyle style;
|
||||
final TextOverflow overflow;
|
||||
|
||||
TextContainsOrganization(this.text,
|
||||
{this.style, this.overflow = TextOverflow.clip});
|
||||
|
||||
static final _reg = RegExp(r'@\S+');
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final orgs = _reg.allMatches(text).map((m) => m.group(0)).toList();
|
||||
final chunks = text.split(_reg);
|
||||
|
||||
List<TextSpan> spans = [];
|
||||
for (var index in List.generate(orgs.length, (i) => (i))) {
|
||||
if (chunks[index].isNotEmpty) {
|
||||
spans.add(TextSpan(text: chunks[index]));
|
||||
}
|
||||
spans.add(createLinkSpan(context, orgs[index],
|
||||
(_) => OrganizationScreen(orgs[index].substring(1))));
|
||||
}
|
||||
if (chunks.last.isNotEmpty) {
|
||||
spans.add(TextSpan(text: chunks.last));
|
||||
}
|
||||
|
||||
return RichText(
|
||||
text: TextSpan(children: spans, style: style), overflow: overflow);
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ import 'package:git_touch/screens/organization.dart';
|
||||
import 'package:git_touch/screens/user.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
import 'package:git_touch/widgets/link.dart';
|
||||
import 'package:git_touch/widgets/text_contains_organization.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
|
||||
const userGqlChunk = '''
|
||||
@ -68,7 +69,7 @@ class UserItem extends StatelessWidget {
|
||||
),
|
||||
SizedBox(height: 6),
|
||||
if (bio != null && bio.isNotEmpty)
|
||||
Text(
|
||||
TextContainsOrganization(
|
||||
bio,
|
||||
style: TextStyle(color: PrimerColors.gray700, fontSize: 15),
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user