1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-14 01:15:12 +01:00

refactor: use spread operator

This commit is contained in:
Rongjian Zhang 2019-05-12 14:01:12 +08:00
parent cac2c664cc
commit fdc0872789
6 changed files with 43 additions and 44 deletions

View File

@ -101,30 +101,30 @@ class _LoginScreenState extends State<LoginScreen> {
return Container(
child: Column(
children: settings.githubAccountMap.entries
.map<Widget>((entry) => _buildAccountItem(AccountModel(
avatarUrl: entry.value.avatarUrl,
token: entry.value.token,
platform: PlatformType.github,
domain: 'https://github.com',
login: entry.key)))
.toList()
..addAll(accounts.map(_buildAccountItem))
..addAll([
_buildAddItem(
text: 'GitHub Account',
onTap: () {
var state = settings.generateRandomString();
launch(
'https://github.com/login/oauth/authorize?client_id=$clientId&redirect_uri=gittouch://login&scope=user%20repo&state=$state',
);
},
),
// _buildAddItem(
// text: 'GitLab Account',
// screenBuilder: (_) => LoginGitlabScreen(),
// )
]),
children: [
...settings.githubAccountMap.entries
.map<Widget>((entry) => _buildAccountItem(AccountModel(
avatarUrl: entry.value.avatarUrl,
token: entry.value.token,
platform: PlatformType.github,
domain: 'https://github.com',
login: entry.key)))
.toList(),
...accounts.map(_buildAccountItem),
_buildAddItem(
text: 'GitHub Account',
onTap: () {
var state = settings.generateRandomString();
launch(
'https://github.com/login/oauth/authorize?client_id=$clientId&redirect_uri=gittouch://login&scope=user%20repo&state=$state',
);
},
),
// _buildAddItem(
// text: 'GitLab Account',
// screenBuilder: (_) => LoginGitlabScreen(),
// )
],
),
);
},

View File

@ -274,11 +274,12 @@ $key: pullRequest(number: ${item.number}) {
bodyBuilder: () {
return groupMap.isEmpty
? EmptyWidget()
: Column(
children: [Padding(padding: EdgeInsets.only(top: 10))]..addAll(
groupMap.entries
.map((entry) => _buildGroupItem(context, entry))
.toList()));
: Column(children: [
Padding(padding: EdgeInsets.only(top: 10)),
...groupMap.entries
.map((entry) => _buildGroupItem(context, entry))
.toList()
]);
},
);
}

View File

@ -134,9 +134,7 @@ class _OrganizationScreenState extends State<OrganizationScreen> {
onRefresh: query,
title: Text(widget.login),
trailingBuilder: (payload) {
List<Action> actions = [];
actions.addAll([
return ActionButton(title: 'User Actions', actions: [
Action(
text: 'Share',
onPress: () {
@ -150,8 +148,6 @@ class _OrganizationScreenState extends State<OrganizationScreen> {
},
),
]);
return ActionButton(title: 'User Actions', actions: actions);
},
bodyBuilder: (payload) {
return Column(

View File

@ -56,12 +56,6 @@ class EventItem extends StatelessWidget {
IconData iconData = Octicons.octoface,
WidgetBuilder screenBuilder,
}) {
var _spans = [
createLinkSpan(
context, event.actorLogin, () => UserScreen(event.actorLogin))
];
_spans.addAll(spans);
return Container(
padding: EdgeInsets.all(8),
child: Column(
@ -76,7 +70,14 @@ class EventItem extends StatelessWidget {
text: TextSpan(
style: TextStyle(
color: Colors.black, height: 1.3, fontSize: 15),
children: _spans,
children: [
createLinkSpan(
context,
event.actorLogin,
() => UserScreen(event.actorLogin),
),
...spans,
],
),
),
),

View File

@ -46,7 +46,7 @@ class TableView extends StatelessWidget {
),
padding: EdgeInsets.only(top: 4),
),
]..addAll(items.map((item) {
...items.map((item) {
List<Widget> children = [
Expanded(
child: Text(
@ -71,7 +71,8 @@ class TableView extends StatelessWidget {
child: Row(children: children),
),
);
}).toList()),
}).toList()
],
),
);
}

View File

@ -10,7 +10,7 @@ description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.3.0-dev <3.0.0"
dependencies:
flutter: