Skip to content

Commit 147cc81

Browse files
committed
修改分支切换
1 parent d25c063 commit 147cc81

File tree

10 files changed

+695
-54
lines changed

10 files changed

+695
-54
lines changed

lib/common/style/GSYStringBase.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ abstract class GSYStringBase {
141141
String repos_tab_issue_open;
142142
String repos_tab_issue_closed;
143143
String repos_option_release;
144+
String repos_option_branch;
144145

145146
String repos_fork_at;
146147
String repos_create_at;

lib/common/style/GSYStringEn.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ class GSYStringEn extends GSYStringBase {
178178
@override
179179
String repos_option_release = "release";
180180
@override
181+
String repos_option_branch = "branch";
182+
@override
181183
String repos_fork_at = "Fork at ";
182184
@override
183185
String repos_create_at = "create at ";

lib/common/style/GSYStringZh.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ class GSYStringZh extends GSYStringBase {
178178
@override
179179
String repos_option_release = "版本";
180180
@override
181+
String repos_option_branch = "分支";
182+
@override
181183
String repos_fork_at = "Fork于 ";
182184
@override
183185
String repos_create_at = "创建于 ";

lib/page/RepositoryDetailPage.dart

Lines changed: 19 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -82,45 +82,6 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
8282
this._getReposStatus();
8383
}
8484

85-
_renderBranchPopItem(String data, List<String> list, onSelected) {
86-
if (list == null && list.length == 0) {
87-
return new Container(height: 0.0, width: 0.0);
88-
}
89-
return new Container(
90-
height: 30.0,
91-
child: new PopupMenuButton<String>(
92-
child: new FlatButton(
93-
onPressed: null,
94-
color: Theme.of(context).primaryColorDark,
95-
disabledColor: Theme.of(context).primaryColorDark,
96-
child: new GSYIConText(
97-
Icons.arrow_drop_up,
98-
data,
99-
GSYConstant.smallTextWhite,
100-
Color(GSYColors.white),
101-
30.0,
102-
padding: 3.0,
103-
mainAxisAlignment: MainAxisAlignment.center,
104-
),
105-
),
106-
onSelected: onSelected,
107-
itemBuilder: (BuildContext context) {
108-
return _renderHeaderPopItemChild(list);
109-
},
110-
),
111-
);
112-
}
113-
114-
_renderHeaderPopItemChild(List<String> data) {
115-
List<PopupMenuEntry<String>> list = new List();
116-
for (String item in data) {
117-
list.add(PopupMenuItem<String>(
118-
value: item,
119-
child: new Text(item),
120-
));
121-
}
122-
return list;
123-
}
12485

12586
_renderBottomItem(var text, var icon, var onPressed) {
12687
return new FlatButton(
@@ -161,21 +122,6 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
161122
Navigator.pop(context);
162123
});
163124
}),
164-
_renderBranchPopItem(reposDetailParentControl.currentBranch, branchList, (value) {
165-
setState(() {
166-
reposDetailParentControl.currentBranch = value;
167-
tarBarControl.footerButton = _getBottomWidget();
168-
});
169-
if (infoListKey.currentState != null && infoListKey.currentState.mounted) {
170-
infoListKey.currentState.showRefreshLoading();
171-
}
172-
if (fileListKey.currentState != null && fileListKey.currentState.mounted) {
173-
fileListKey.currentState.showRefreshLoading();
174-
}
175-
if (readmeKey.currentState != null && readmeKey.currentState.mounted) {
176-
readmeKey.currentState.refreshReadme();
177-
}
178-
}),
179125
];
180126
return bottomWidget;
181127
}
@@ -227,6 +173,25 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
227173
infoListKey.currentState.repository == null ? GSYConstant.app_default_share_url : infoListKey.currentState.repository.htmlUrl + "/tags";
228174
}
229175
NavigatorUtils.goReleasePage(context, userName, reposName, releaseUrl, tagUrl);
176+
}), ///Branch Page
177+
new GSYOptionModel(CommonUtils.getLocale(context).repos_option_branch, CommonUtils.getLocale(context).repos_option_branch, (model) {
178+
if(branchList.length == 0) {
179+
return;
180+
}
181+
CommonUtils.showCommitOptionDialog(context, branchList, (value){
182+
setState(() {
183+
reposDetailParentControl.currentBranch = branchList[value];
184+
});
185+
if (infoListKey.currentState != null && infoListKey.currentState.mounted) {
186+
infoListKey.currentState.showRefreshLoading();
187+
}
188+
if (fileListKey.currentState != null && fileListKey.currentState.mounted) {
189+
fileListKey.currentState.showRefreshLoading();
190+
}
191+
if (readmeKey.currentState != null && readmeKey.currentState.mounted) {
192+
readmeKey.currentState.refreshReadme();
193+
}
194+
});
230195
}),
231196
];
232197
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
library flutter_radial_menu;
2+
3+
export 'src/radial_menu.dart';
4+
export 'src/radial_menu_item.dart';
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
import 'dart:math' as Math;
2+
3+
import 'package:flutter/foundation.dart';
4+
import 'package:flutter/material.dart';
5+
6+
/// Draws an [ActionIcon] and [_ArcProgressPainter] that represent an active action.
7+
/// As the provided [Animation] progresses the ActionArc grows into a full
8+
/// circle and the ActionIcon moves along it.
9+
class ArcProgressIndicator extends StatelessWidget {
10+
// required
11+
final Animation<double> controller;
12+
final double radius;
13+
14+
// optional
15+
final double startAngle;
16+
final double width;
17+
18+
/// The color to use when filling the arc.
19+
///
20+
/// Defaults to the accent color of the current theme.
21+
final Color color;
22+
final IconData icon;
23+
final Color iconColor;
24+
final double iconSize;
25+
26+
// private
27+
final Animation<double> _progress;
28+
29+
ArcProgressIndicator({
30+
@required this.controller,
31+
@required this.radius,
32+
this.startAngle = 0.0,
33+
this.width,
34+
this.color,
35+
this.icon,
36+
this.iconColor,
37+
this.iconSize,
38+
}) : _progress = new Tween(begin: 0.0, end: 1.0).animate(controller);
39+
40+
@override
41+
Widget build(BuildContext context) {
42+
TextPainter _iconPainter;
43+
final ThemeData theme = Theme.of(context);
44+
final Color _iconColor = iconColor ?? theme.accentIconTheme.color;
45+
final double _iconSize = iconSize ?? IconTheme.of(context).size;
46+
47+
if (icon != null) {
48+
_iconPainter = new TextPainter(
49+
textDirection: Directionality.of(context),
50+
text: new TextSpan(
51+
text: new String.fromCharCode(icon.codePoint),
52+
style: new TextStyle(
53+
inherit: false,
54+
color: _iconColor,
55+
fontSize: _iconSize,
56+
fontFamily: icon.fontFamily,
57+
package: icon.fontPackage,
58+
),
59+
),
60+
)..layout();
61+
}
62+
63+
return new CustomPaint(
64+
painter: new _ArcProgressPainter(
65+
controller: _progress,
66+
color: color ?? theme.accentColor,
67+
radius: radius,
68+
width: width ?? _iconSize * 2,
69+
startAngle: startAngle,
70+
icon: _iconPainter,
71+
),
72+
);
73+
}
74+
}
75+
76+
class _ArcProgressPainter extends CustomPainter {
77+
// required
78+
final Animation<double> controller;
79+
final Color color;
80+
final double radius;
81+
final double width;
82+
83+
// optional
84+
final double startAngle;
85+
final TextPainter icon;
86+
87+
_ArcProgressPainter({
88+
@required this.controller,
89+
@required this.color,
90+
@required this.radius,
91+
@required this.width,
92+
this.startAngle = 0.0,
93+
this.icon,
94+
}) : super(repaint: controller);
95+
96+
@override
97+
void paint(Canvas canvas, Size size) {
98+
Paint paint = new Paint()
99+
..color = color
100+
..strokeWidth = width
101+
..strokeCap = StrokeCap.round
102+
..style = PaintingStyle.stroke;
103+
104+
final double sweepAngle = controller.value * 2 * Math.pi;
105+
106+
canvas.drawArc(
107+
Offset.zero & size,
108+
startAngle,
109+
sweepAngle,
110+
false,
111+
paint,
112+
);
113+
114+
if (icon != null) {
115+
double angle = startAngle + sweepAngle;
116+
Offset offset = new Offset(
117+
(size.width / 2 - icon.size.width / 2) + radius * Math.cos(angle),
118+
(size.height / 2 - icon.size.height / 2) + radius * Math.sin(angle),
119+
);
120+
121+
icon.paint(canvas, offset);
122+
}
123+
}
124+
125+
@override
126+
bool shouldRepaint(_ArcProgressPainter other) {
127+
return controller.value != other.controller.value ||
128+
color != other.color ||
129+
radius != other.radius ||
130+
width != other.width ||
131+
startAngle != other.startAngle ||
132+
icon != other.icon;
133+
}
134+
}

0 commit comments

Comments
 (0)