feat: format numbers with group seperator

This commit is contained in:
Rongjian Zhang 2019-09-13 23:34:19 +08:00
parent a2cb2fb9e9
commit ede2d064f1
6 changed files with 17 additions and 13 deletions

View File

@ -156,8 +156,8 @@ class IssuesScreen extends StatelessWidget {
Icon(Octicons.comment,
size: 13, color: PrimerColors.gray700),
SizedBox(width: 4),
Text(payload['comments']['totalCount']
.toString())
Text(numberFormat
.format(payload['comments']['totalCount']))
],
],
),

View File

@ -251,7 +251,7 @@ class RepoScreen extends StatelessWidget {
text: Text('Issues'),
rightWidget: Row(
children: <Widget>[
Text(payload['issues']['totalCount'].toString()),
Text(numberFormat.format(payload['issues']['totalCount'])),
Icon(
CupertinoIcons.right_chevron,
size: 18,
@ -266,7 +266,8 @@ class RepoScreen extends StatelessWidget {
text: Text('Pull requests'),
rightWidget: Row(
children: <Widget>[
Text(payload['pullRequests']['totalCount'].toString()),
Text(numberFormat
.format(payload['pullRequests']['totalCount'])),
Icon(
CupertinoIcons.right_chevron,
size: 18,
@ -286,17 +287,15 @@ class RepoScreen extends StatelessWidget {
rightWidget: Text(payload['licenseInfo'] == null
? 'Unknown'
: (payload['licenseInfo']['spdxId'] ??
payload['licenseInfo']['name'])
.toString()),
payload['licenseInfo']['name'])),
),
TableViewItem(
leftWidget: Icon(Octicons.history, size: 20),
text: Text('Commits'),
rightWidget: Row(
children: <Widget>[
Text(payload['defaultBranchRef']['target']['history']
['totalCount']
.toString()),
Text(numberFormat.format(payload['defaultBranchRef']
['target']['history']['totalCount'])),
Icon(
CupertinoIcons.right_chevron,
size: 18,

View File

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:git_touch/screens/user.dart';
import 'package:intl/intl.dart';
import 'package:primer/primer.dart';
import '../screens/repo.dart';
export 'package:flutter_vector_icons/flutter_vector_icons.dart';
@ -125,6 +126,8 @@ K ifNotNull<T, K>(T value, K Function(T v) builder) {
return value == null ? null : builder(value);
}
final numberFormat = NumberFormat();
class BorderView extends StatelessWidget {
final double height;

View File

@ -88,7 +88,7 @@ class CommentItem extends StatelessWidget {
children: <Widget>[
Text(emoji, style: TextStyle(fontSize: 18)),
SizedBox(width: 4),
Text(count.toString(),
Text(numberFormat.format(count),
style: TextStyle(
color: PrimerColors.blue500, fontSize: 14))
],

View File

@ -1,4 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:intl/intl.dart';
import 'package:primer/primer.dart';
import 'link.dart';
@ -19,7 +21,7 @@ class EntryItem extends StatelessWidget {
child: Column(
children: <Widget>[
Text(
count.toString(),
numberFormat.format(count),
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w600),
),
Text(

View File

@ -54,7 +54,7 @@ class RepoItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Icon(Octicons.star, size: 14, color: PrimerColors.gray600),
Text(payload['stargazers']['totalCount'].toString()),
Text(numberFormat.format(payload['stargazers']['totalCount'])),
],
),
),
@ -64,7 +64,7 @@ class RepoItem extends StatelessWidget {
children: <Widget>[
Icon(Octicons.repo_forked,
size: 14, color: PrimerColors.gray600),
Text(payload['forks']['totalCount'].toString())
Text(numberFormat.format(payload['forks']['totalCount'])),
],
),
),