Skip to content

Commit 32d121b

Browse files
committed
push code
1 parent 1906e23 commit 32d121b

5 files changed

Lines changed: 30 additions & 11 deletions

File tree

‎lib/common/utils/NavigatorUtils.dart‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class NavigatorUtils {
7676
}
7777

7878
///文件代码详情
79-
static gotoCodeDetailPage(BuildContext context, {String title, String userName, String reposName, String path, String data, String branch}) {
79+
static gotoCodeDetailPage(BuildContext context,
80+
{String title, String userName, String reposName, String path, String data, String branch, String htmlUrl}) {
8081
Navigator.push(
8182
context,
8283
new MaterialPageRoute(
@@ -87,6 +88,7 @@ class NavigatorUtils {
8788
path: path,
8889
data: data,
8990
branch: branch,
91+
htmlUrl: htmlUrl,
9092
)));
9193
}
9294

‎lib/page/CodeDetailPage.dart‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ class CodeDetailPage extends StatefulWidget {
2525

2626
final String branch;
2727

28-
CodeDetailPage({this.title, this.userName, this.reposName, this.path, this.data, this.branch});
28+
final String htmlUrl;
29+
30+
CodeDetailPage({this.title, this.userName, this.reposName, this.path, this.data, this.branch, this.htmlUrl});
2931

3032
@override
31-
_CodeDetailPageState createState() => _CodeDetailPageState(this.title, this.userName, this.reposName, this.path, this.data, this.branch);
33+
_CodeDetailPageState createState() => _CodeDetailPageState(this.title, this.userName, this.reposName, this.path, this.data, this.branch, this.htmlUrl);
3234
}
3335

3436
class _CodeDetailPageState extends State<CodeDetailPage> {
@@ -40,15 +42,18 @@ class _CodeDetailPageState extends State<CodeDetailPage> {
4042

4143
final String branch;
4244

45+
final String htmlUrl;
46+
4347
String data;
4448

4549
final String title;
4650

47-
_CodeDetailPageState(this.title, this.userName, this.reposName, this.path, this.data, this.branch);
51+
_CodeDetailPageState(this.title, this.userName, this.reposName, this.path, this.data, this.branch, this.htmlUrl);
4852

4953
@override
5054
void initState() {
5155
super.initState();
56+
print(data);
5257
if (data == null) {
5358
ReposDao.getReposFileDirDao(userName, reposName, path: path, branch: branch, text: true).then((res) {
5459
if (res != null && res.result) {
@@ -63,7 +68,10 @@ class _CodeDetailPageState extends State<CodeDetailPage> {
6368
@override
6469
Widget build(BuildContext context) {
6570
String currentBranch = ((branch == null) ? "" : ("/" + branch));
66-
String url = Address.hostWeb + userName + "/" + reposName + "/blob" + currentBranch + path;
71+
String url = htmlUrl;
72+
if(data == null) {
73+
url = Address.hostWeb + userName + "/" + reposName + "/blob" + currentBranch + path;
74+
}
6775
Widget widget = (data == null)
6876
? new Center(
6977
child: new Container(

‎lib/page/PushDetailPage.dart‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ class _PushDetailPageState extends GSYListState<PushDetailPage> {
7373
return new PushHeader(pushHeaderViewModel);
7474
}
7575
PushCodeItemViewModel itemViewModel = pullLoadWidgetControl.dataList[index - 1];
76-
return new PushCodeItem(itemViewModel, () {});
76+
return new PushCodeItem(itemViewModel, () {
77+
NavigatorUtils.gotoCodeDetailPage(context, title: itemViewModel.name, userName: userName, reposName: reposName, data: itemViewModel.patch,
78+
htmlUrl: itemViewModel.blob_url,);
79+
});
7780
}
7881

7982
_getDataLogic() async {

‎lib/widget/GSYMarkdownWidget.dart‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ class GSYMarkdownWidget extends StatelessWidget {
1414
@override
1515
Widget build(BuildContext context) {
1616
return Container(
17-
child: SingleChildScrollView(
18-
child: new MarkdownBody(data: markdownData),
19-
));
17+
padding: EdgeInsets.all(5.0),
18+
child: SingleChildScrollView(
19+
child: new MarkdownBody(data: markdownData),
20+
),
21+
);
2022
}
2123
}

‎lib/widget/PushCoedItem.dart‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ class PushCodeItem extends StatelessWidget {
1818
return new Column(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
1919
new Container(
2020
margin: EdgeInsets.only(left: 10.0, top: 5.0, right: 10.0, bottom: 0.0),
21-
child:
22-
new Text(
21+
child: new Text(
2322
pushCodeItemViewModel.path,
2423
style: GSYConstant.subLightSmallText,
2524
),
@@ -44,6 +43,9 @@ class PushCodeItem extends StatelessWidget {
4443
class PushCodeItemViewModel {
4544
String path;
4645
String name;
46+
String patch;
47+
48+
String blob_url;
4749

4850
PushCodeItemViewModel();
4951

@@ -52,5 +54,7 @@ class PushCodeItemViewModel {
5254
List<String> nameSplit = filename.split("/");
5355
name = nameSplit[nameSplit.length - 1];
5456
path = filename;
57+
patch = map["patch"];
58+
blob_url = map["blob_url"];
5559
}
5660
}

0 commit comments

Comments
 (0)