1+ import 'dart:io' ;
2+
13import 'package:flutter/material.dart' ;
4+ import 'package:fluttertoast/fluttertoast.dart' ;
25import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart' ;
36import 'package:gsy_github_app_flutter/common/net/Address.dart' ;
47import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart' ;
8+ import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart' ;
9+ import 'package:gsy_github_app_flutter/common/utils/HtmlUtils.dart' ;
10+ import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart' ;
511import 'package:gsy_github_app_flutter/widget/GSYCommonOptionWidget.dart' ;
612import 'package:gsy_github_app_flutter/widget/GSYListState.dart' ;
713import 'package:gsy_github_app_flutter/widget/GSYPullLoadWidget.dart' ;
814import 'package:gsy_github_app_flutter/widget/GSYSelectItemWidget.dart' ;
915import 'package:gsy_github_app_flutter/widget/GSYTitleBar.dart' ;
1016import 'package:gsy_github_app_flutter/widget/ReleaseItem.dart' ;
17+ import 'package:url_launcher/url_launcher.dart' ;
1118
1219/**
1320 * 版本页
@@ -32,26 +39,56 @@ class _ReleasePageState extends GSYListState<ReleasePage> {
3239
3340 final String reposName;
3441
35- int selectIndex;
42+ int selectIndex = 0 ;
3643
3744 _ReleasePageState (this .userName, this .reposName);
3845
3946 _renderEventItem (index) {
4047 ReleaseItemViewModel releaseItemViewModel = pullLoadWidgetControl.dataList[index];
4148 return new ReleaseItem (
4249 releaseItemViewModel,
43- onPressed: () {},
44- onLongPress: () {},
50+ onPressed: () {
51+ if (selectIndex == 0 ) {
52+ if (Platform .isIOS) {
53+ NavigatorUtils .gotoCodeDetailPage (
54+ context,
55+ title: releaseItemViewModel.actionTitle,
56+ userName: userName,
57+ reposName: reposName,
58+ data: HtmlUtils .generateHtml (releaseItemViewModel.actionTargetHtml, backgroundColor: GSYColors .webDraculaBackgroundColorString),
59+ );
60+ } else {
61+ String html = HtmlUtils .generateHtml (releaseItemViewModel.actionTargetHtml, backgroundColor: GSYColors .miWhiteString, userBR: false );
62+ CommonUtils .launchWebView (context, releaseItemViewModel.actionTitle, html);
63+ }
64+ }
65+ },
66+ onLongPress: () {
67+ _launchURL ();
68+ },
4569 );
4670 }
4771
72+ _launchURL () async {
73+ String url = _getUrl ();
74+ if (await canLaunch (url)) {
75+ await launch (url);
76+ } else {
77+ Fluttertoast .showToast (msg: GSYStrings .option_web_launcher_error + ": " + url);
78+ }
79+ }
80+
81+ _getUrl () {
82+ return selectIndex == 0 ? Address .hostWeb + userName + "/" + reposName + "/releases" : Address .hostWeb + userName + "/" + reposName + "/tags" ;
83+ }
84+
4885 _resolveSelectIndex () {
4986 clearData ();
5087 showRefreshLoading ();
5188 }
5289
5390 _getDataLogic () async {
54- return await ReposDao .getRepositoryReleaseDao (userName, reposName, page, needHtml: false , release: selectIndex == 0 );
91+ return await ReposDao .getRepositoryReleaseDao (userName, reposName, page, needHtml: Platform .isAndroid , release: selectIndex == 0 );
5592 }
5693
5794 @override
@@ -76,7 +113,7 @@ class _ReleasePageState extends GSYListState<ReleasePage> {
76113 @override
77114 Widget build (BuildContext context) {
78115 super .build (context); // See AutomaticKeepAliveClientMixin.
79- String url = Address .hostWeb + userName + "/" + reposName + "/releases" ;
116+ String url = _getUrl () ;
80117 return new Scaffold (
81118 backgroundColor: Color (GSYColors .mainBackgroundColor),
82119 appBar: new AppBar (
0 commit comments