Skip to content

Commit 257ce20

Browse files
committed
add issue copy
1 parent d8f8d71 commit 257ce20

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

‎lib/common/style/GSYStyle.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ class GSYStrings {
301301
static const String issue_edit_issue_commit = "编译回复";
302302
static const String issue_edit_issue_edit_commit = "编辑";
303303
static const String issue_edit_issue_delete_commit = "删除";
304+
static const String issue_edit_issue_copy_commit = "复制";
304305
static const String issue_edit_issue_content_not_be_null = "内容不能为空";
305306
static const String issue_edit_issue_title_not_be_null = "标题不能为空";
306307
static const String issue_edit_issue_title_tip = "请输入标题";

‎lib/common/utils/CommonUtils.dart‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import 'dart:async';
22
import 'dart:convert';
33

44
import 'package:flutter/material.dart';
5+
import 'package:flutter/services.dart';
6+
import 'package:fluttertoast/fluttertoast.dart';
57
import 'package:gsy_github_app_flutter/common/net/Address.dart';
68
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
79
import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart';
@@ -75,6 +77,11 @@ class CommonUtils {
7577
return image;
7678
}
7779

80+
static copy(String data) {
81+
Clipboard.setData(new ClipboardData(text: data));
82+
Fluttertoast.showToast(msg: GSYStrings.option_share_copy_success);
83+
}
84+
7885
static launchUrl(context, String url) {
7986
if (url == null && url.length == 0) return;
8087
Uri parseUrl = Uri.parse(url);
@@ -107,7 +114,8 @@ class CommonUtils {
107114
if (url.startsWith("http")) {
108115
NavigatorUtils.goGSYWebView(context, url, title);
109116
} else {
110-
NavigatorUtils.goGSYWebView(context, new Uri.dataFromString(url, mimeType: 'text/html', encoding: Encoding.getByName("utf-8")).toString(), title);
117+
NavigatorUtils.goGSYWebView(
118+
context, new Uri.dataFromString(url, mimeType: 'text/html', encoding: Encoding.getByName("utf-8")).toString(), title);
111119
}
112120
}
113121

‎lib/page/IssueDetailPage.dart‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
9797
_deleteCommit(issue.id.toString());
9898
},
9999
),
100+
new GSYFlexButton(
101+
color: Colors.white,
102+
text: GSYStrings.issue_edit_issue_copy_commit,
103+
onPress: () {
104+
CommonUtils.copy(issue.body);
105+
},
106+
),
100107
],
101108
),
102109
),
@@ -244,12 +251,14 @@ class _IssueDetailPageState extends GSYListState<IssueDetailPage> {
244251
new FlatButton(
245252
onPressed: () {
246253
CommonUtils.showLoadingDialog(context);
247-
IssueDao.editIssueDao(userName, reposName, issueNum, {"state": (issueHeaderViewModel.state == "closed") ? 'open' : 'closed'}).then((result) {
254+
IssueDao.editIssueDao(userName, reposName, issueNum, {"state": (issueHeaderViewModel.state == "closed") ? 'open' : 'closed'}).then(
255+
(result) {
248256
_getHeaderInfo();
249257
Navigator.pop(context);
250258
});
251259
},
252-
child: new Text((issueHeaderViewModel.state == 'closed') ? GSYStrings.issue_open : GSYStrings.issue_close, style: GSYConstant.smallText)),
260+
child: new Text((issueHeaderViewModel.state == 'closed') ? GSYStrings.issue_open : GSYStrings.issue_close,
261+
style: GSYConstant.smallText)),
253262
new Container(width: 0.3, height: 30.0, color: Color(GSYColors.subLightTextColor)),
254263
new FlatButton(
255264
onPressed: () {

‎lib/widget/GSYCommonOptionWidget.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:flutter/services.dart';
33
import 'package:fluttertoast/fluttertoast.dart';
44
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
5+
import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart';
56
import 'package:url_launcher/url_launcher.dart';
67
import 'package:share/share.dart';
78

@@ -55,8 +56,7 @@ class GSYCommonOptionWidget extends StatelessWidget {
5556
_launchURL();
5657
}),
5758
new GSYOptionModel(GSYStrings.option_copy, GSYStrings.option_copy, (model) {
58-
Clipboard.setData(new ClipboardData(text: control.url ?? ""));
59-
Fluttertoast.showToast(msg: GSYStrings.option_share_copy_success);
59+
CommonUtils.copy(control.url ?? "");
6060
}),
6161
new GSYOptionModel(GSYStrings.option_share, GSYStrings.option_share, (model) {
6262
Share.share(text);

0 commit comments

Comments
 (0)