Repository navigation
Expand file tree
/
Copy pathCodeDetailPage.dart
More file actions
105 lines (83 loc) · 2.87 KB
/
Copy pathCodeDetailPage.dart
File metadata and controls
105 lines (83 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart';
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart';
import 'package:gsy_github_app_flutter/widget/GSYCommonOptionWidget.dart';
import 'package:gsy_github_app_flutter/widget/GSYMarkdownWidget.dart';
import 'package:gsy_github_app_flutter/widget/GSYTitleBar.dart';
/**
* 文件代码详情
* Created by guoshuyu
* Date: 2018-07-24
*/
class CodeDetailPage extends StatefulWidget {
final String userName;
final String reposName;
final String path;
final String data;
final String title;
final String branch;
final String htmlUrl;
CodeDetailPage({this.title, this.userName, this.reposName, this.path, this.data, this.branch, this.htmlUrl});
@override
_CodeDetailPageState createState() => _CodeDetailPageState(this.title, this.userName, this.reposName, this.path, this.data, this.branch, this.htmlUrl);
}
class _CodeDetailPageState extends State<CodeDetailPage> {
final String userName;
final String reposName;
final String path;
final String branch;
final String htmlUrl;
final String title;
final OptionControl titleOptionControl = new OptionControl();
String data;
_CodeDetailPageState(this.title, this.userName, this.reposName, this.path, this.data, this.branch, this.htmlUrl);
@override
void initState() {
super.initState();
if (data == null) {
ReposDao.getReposFileDirDao(userName, reposName, path: path, branch: branch, text: true).then((res) {
if (res != null && res.result) {
setState(() {
data = res.data;
titleOptionControl.url = htmlUrl ?? "";
});
}
});
}
}
@override
Widget build(BuildContext context) {
Widget widget = (data == null)
? new Center(
child: new Container(
width: 200.0,
height: 200.0,
padding: new EdgeInsets.all(4.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new SpinKitDoubleBounce(color: Theme.of(context).primaryColor),
new Container(width: 10.0),
new Container(child: new Text(CommonUtils.getLocale(context).loading_text, style: GSYConstant.middleText)),
],
),
),
)
: new GSYMarkdownWidget(
markdownData: data,
style: GSYMarkdownWidget.DARK_LIGHT,
);
return new Scaffold(
appBar: new AppBar(
title: GSYTitleBar(
title,
rightWidget: new GSYCommonOptionWidget(titleOptionControl),
needRightLocalIcon: false,
),
),
body: widget,
);
}
}