Skip to content

Commit 915b4bb

Browse files
committed
user info link click
1 parent 07d161c commit 915b4bb

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

lib/common/utils/CommonUtils.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ class CommonUtils {
136136
}
137137
}
138138

139+
static launchOutURL(String url) async {
140+
if (await canLaunch(url)) {
141+
await launch(url);
142+
} else {
143+
Fluttertoast.showToast(msg: GSYStrings.option_web_launcher_error + ": " + url);
144+
}
145+
}
146+
139147
static Future<Null> showLoadingDialog(BuildContext context) {
140148
return showDialog(
141149
context: context,

lib/widget/GSYCommonOptionWidget.dart

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter/services.dart';
3-
import 'package:fluttertoast/fluttertoast.dart';
42
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
53
import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart';
6-
import 'package:url_launcher/url_launcher.dart';
74
import 'package:share/share.dart';
85

96
/**
@@ -40,19 +37,12 @@ class GSYCommonOptionWidget extends StatelessWidget {
4037
return list;
4138
}
4239

43-
_launchURL() async {
44-
if (await canLaunch(control.url)) {
45-
await launch(control.url);
46-
} else {
47-
Fluttertoast.showToast(msg: GSYStrings.option_web_launcher_error + ": " + control.url);
48-
}
49-
}
5040

5141
@override
5242
Widget build(BuildContext context) {
5343
List<GSYOptionModel> list = [
5444
new GSYOptionModel(GSYStrings.option_web, GSYStrings.option_web, (model) {
55-
_launchURL();
45+
CommonUtils.launchOutURL(control.url);
5646
}),
5747
new GSYOptionModel(GSYStrings.option_copy, GSYStrings.option_copy, (model) {
5848
CommonUtils.copy(control.url ?? "");

lib/widget/UserHeader.dart

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class UserHeaderItem extends StatelessWidget {
163163
///用户组织
164164
new GSYIConText(
165165
GSYICons.USER_ITEM_COMPANY,
166-
userInfo.company == null ? GSYStrings.nothing_now : userInfo.company,
166+
userInfo.company ?? GSYStrings.nothing_now,
167167
GSYConstant.subLightSmallText,
168168
Color(GSYColors.subLightTextColor),
169169
10.0,
@@ -173,7 +173,7 @@ class UserHeaderItem extends StatelessWidget {
173173
///用户位置
174174
new GSYIConText(
175175
GSYICons.USER_ITEM_LOCATION,
176-
userInfo.location == null ? GSYStrings.nothing_now : userInfo.location,
176+
userInfo.location ?? GSYStrings.nothing_now,
177177
GSYConstant.subLightSmallText,
178178
Color(GSYColors.subLightTextColor),
179179
10.0,
@@ -187,13 +187,26 @@ class UserHeaderItem extends StatelessWidget {
187187
new Container(
188188

189189
///用户博客
190-
child: new GSYIConText(
191-
GSYICons.USER_ITEM_LINK,
192-
userInfo.blog == null ? GSYStrings.nothing_now : userInfo.blog,
193-
GSYConstant.subLightSmallText,
194-
Color(GSYColors.subLightTextColor),
195-
10.0,
196-
padding: 3.0,
190+
child: new RawMaterialButton(
191+
onPressed: () {
192+
if (userInfo.blog != null) {
193+
CommonUtils.launchOutURL(userInfo.blog);
194+
}
195+
},
196+
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
197+
padding: const EdgeInsets.all(0.0),
198+
constraints: const BoxConstraints(minWidth: 0.0, minHeight: 0.0),
199+
child: new GSYIConText(
200+
GSYICons.USER_ITEM_LINK,
201+
userInfo.blog ?? GSYStrings.nothing_now,
202+
TextStyle(
203+
color: (userInfo.blog == null) ? Color(GSYColors.subLightTextColor) : Color(GSYColors.actionBlue),
204+
fontSize: GSYConstant.smallTextSize,
205+
),
206+
Color(GSYColors.subLightTextColor),
207+
10.0,
208+
padding: 3.0,
209+
),
197210
),
198211
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
199212
alignment: Alignment.topLeft),

0 commit comments

Comments
 (0)