Skip to content

Commit 52eacc4

Browse files
committed
修复调整部分代码
1 parent a90ab1d commit 52eacc4

File tree

6 files changed

+59
-48
lines changed

6 files changed

+59
-48
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55
flutter needs it to communicate with the running application
66
to allow setting breakpoints, to provide hot reload, etc.
77
-->
8+
9+
10+
<queries>
11+
<!-- If your app checks for call support -->
12+
<intent>
13+
<action android:name="android.intent.action.VIEW" />
14+
<data android:scheme="tel" />
15+
</intent>
16+
<!-- If your app checks for call support -->
17+
<intent>
18+
<action android:name="android.intent.action.VIEW" />
19+
<data android:scheme="https" />
20+
</intent>
21+
</queries>
22+
823
<uses-permission android:name="android.permission.INTERNET"/>
924
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
1025
<uses-permission android:name="android.permission.WAKE_LOCK" />

lib/common/dao/user_dao.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class UserDao {
3737
);
3838
dynamic resultData = null;
3939
if (res != null && res.result) {
40-
print("#### ${res.data}");
4140
var result = Uri.parse("gsy://oauth?" + res.data);
4241
var token = result.queryParameters["access_token"]!;
4342
var _token = 'token ' + token;

lib/common/utils/common_utils.dart

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ import 'package:url_launcher/url_launcher.dart';
3434
typedef StringList = List<String>;
3535

3636
class CommonUtils {
37-
static final double MILLIS_LIMIT = 1000.0;
37+
static const double MILLIS_LIMIT = 1000.0;
3838

39-
static final double SECONDS_LIMIT = 60 * MILLIS_LIMIT;
39+
static const double SECONDS_LIMIT = 60 * MILLIS_LIMIT;
4040

41-
static final double MINUTES_LIMIT = 60 * SECONDS_LIMIT;
41+
static const double MINUTES_LIMIT = 60 * SECONDS_LIMIT;
4242

43-
static final double HOURS_LIMIT = 24 * MINUTES_LIMIT;
43+
static const double HOURS_LIMIT = 24 * MINUTES_LIMIT;
4444

45-
static final double DAYS_LIMIT = 30 * HOURS_LIMIT;
45+
static const double DAYS_LIMIT = 30 * HOURS_LIMIT;
4646

4747
static Locale? curLocale;
4848

@@ -66,44 +66,38 @@ class CommonUtils {
6666
static String getNewsTimeStr(DateTime date) {
6767
int subTimes =
6868
DateTime.now().millisecondsSinceEpoch - date.millisecondsSinceEpoch;
69-
70-
if (subTimes < MILLIS_LIMIT) {
71-
return (curLocale != null)
69+
return switch (subTimes) {
70+
< MILLIS_LIMIT => (curLocale != null)
7271
? (curLocale!.languageCode != "zh")
7372
? "right now"
7473
: "刚刚"
75-
: "刚刚";
76-
} else if (subTimes < SECONDS_LIMIT) {
77-
return (subTimes / MILLIS_LIMIT).round().toString() +
74+
: "刚刚",
75+
< SECONDS_LIMIT => (subTimes / MILLIS_LIMIT).round().toString() +
7876
((curLocale != null)
7977
? (curLocale!.languageCode != "zh")
8078
? " seconds ago"
8179
: " 秒前"
82-
: " 秒前");
83-
} else if (subTimes < MINUTES_LIMIT) {
84-
return (subTimes / SECONDS_LIMIT).round().toString() +
80+
: " 秒前"),
81+
< MINUTES_LIMIT => (subTimes / SECONDS_LIMIT).round().toString() +
8582
((curLocale != null)
8683
? (curLocale!.languageCode != "zh")
8784
? " min ago"
8885
: " 分钟前"
89-
: " 分钟前");
90-
} else if (subTimes < HOURS_LIMIT) {
91-
return (subTimes / MINUTES_LIMIT).round().toString() +
86+
: " 分钟前"),
87+
< HOURS_LIMIT => (subTimes / MINUTES_LIMIT).round().toString() +
9288
((curLocale != null)
9389
? (curLocale!.languageCode != "zh")
9490
? " hours ago"
9591
: " 小时前"
96-
: " 小时前");
97-
} else if (subTimes < DAYS_LIMIT) {
98-
return (subTimes / HOURS_LIMIT).round().toString() +
92+
: " 小时前"),
93+
< DAYS_LIMIT => (subTimes / HOURS_LIMIT).round().toString() +
9994
((curLocale != null)
10095
? (curLocale!.languageCode != "zh")
10196
? " days ago"
10297
: " 天前"
103-
: " 天前");
104-
} else {
105-
return getDateStr(date);
106-
}
98+
: " 天前"),
99+
_ => getDateStr(date)
100+
};
107101
}
108102

109103
static getLocalPath() async {
@@ -326,18 +320,21 @@ class CommonUtils {
326320

327321
if (parseUrl.host == "github.com" && parseUrl.path.length > 0) {
328322
StringList pathnames = parseUrl.path.split("/");
329-
if (pathnames.length == 2) {
330-
//解析人
331-
String userName = pathnames[1];
332-
NavigatorUtils.goPerson(context, userName);
333-
} else if (pathnames.length >= 3) {
334-
//解析仓库
335-
if (pathnames.length == 3) {
336-
var [_, userName, repoName] = pathnames;
337-
NavigatorUtils.goReposDetail(context, userName, repoName);
338-
} else {
339-
launchWebView(context, "", url);
340-
}
323+
switch (pathnames.length) {
324+
case == 2:
325+
//解析人
326+
String userName = pathnames[1];
327+
NavigatorUtils.goPerson(context, userName);
328+
break;
329+
case >= 3:
330+
//解析仓库
331+
if (pathnames.length == 3) {
332+
var [_, userName, repoName] = pathnames;
333+
NavigatorUtils.goReposDetail(context, userName, repoName);
334+
} else {
335+
launchWebView(context, "", url);
336+
}
337+
break;
341338
}
342339
} else if (url.startsWith("http")) {
343340
launchWebView(context, "", url);

lib/common/utils/event_utils.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'package:gsy_github_app_flutter/common/utils/navigator_utils.dart';
1111
*/
1212
class EventUtils {
1313
///事件描述与动作
14-
static getActionAndDes(Event event) {
14+
static ({String? actionStr, String? des})getActionAndDes(Event event) {
1515
String? actionStr;
1616
String? des;
1717
switch (event.type) {
@@ -143,7 +143,7 @@ class EventUtils {
143143
break;
144144
}
145145

146-
return {"actionStr": actionStr, "des": des != null ? des : ""};
146+
return (actionStr: actionStr, des: des != null ? des : "");
147147
}
148148

149149
///跳转

lib/page/debug/debug_label.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DebugLabel {
2020
return false;
2121
}
2222
hadShow = true;
23-
var list = await _getDeviceInfo();
23+
var (version, platform) = await _getDeviceInfo();
2424
PackageInfo packInfo = await PackageInfo.fromPlatform();
2525
var language = GSYLocalizations.of(context)!.locale.languageCode;
2626
if (_overlayEntry != null) {
@@ -31,8 +31,8 @@ class DebugLabel {
3131
_overlayEntry = new OverlayEntry(builder: (context) {
3232
return GlobalLabel(
3333
version: packInfo.version,
34-
deviceInfo: list[0],
35-
platform: list[1],
34+
deviceInfo: version,
35+
platform: platform,
3636
language: language);
3737
});
3838
overlayState.insert(_overlayEntry!);
@@ -52,15 +52,15 @@ class DebugLabel {
5252
}
5353
}
5454

55-
Future<StringList> _getDeviceInfo() async {
55+
Future<(String, String)> _getDeviceInfo() async {
5656
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
5757
if (Platform.isAndroid) {
5858
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
59-
return [androidInfo.version.sdkInt.toString(), "Android"];
59+
return (androidInfo.version.sdkInt.toString(), "Android");
6060
}
6161
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
6262
String device = await CommonUtils.getDeviceInfo();
63-
return [iosInfo.systemVersion ?? "", device];
63+
return (iosInfo.systemVersion ?? "", device);
6464
}
6565

6666
class GlobalLabel extends StatefulWidget {

lib/widget/gsy_event_item.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ class EventViewModel {
9393
actionTime = CommonUtils.getNewsTimeStr(event.createdAt!);
9494
actionUser = event.actor!.login;
9595
actionUserPic = event.actor!.avatar_url;
96-
var other = EventUtils.getActionAndDes(event);
97-
actionDes = other["des"];
98-
actionTarget = other["actionStr"];
96+
var as = EventUtils.getActionAndDes(event);
97+
actionDes = as.des;
98+
actionTarget = as.actionStr;
9999
}
100100

101101
EventViewModel.fromCommitMap(RepoCommit eventMap) {

0 commit comments

Comments
 (0)