Skip to content

Commit 84fd78e

Browse files
committed
增加主题颜色item的显示
1 parent 4f88fdb commit 84fd78e

4 files changed

Lines changed: 29 additions & 33 deletions

File tree

‎lib/common/utils/CommonUtils.dart‎

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -85,32 +85,23 @@ class CommonUtils {
8585

8686
static pushTheme(Store store, int index) {
8787
ThemeData themeData;
88-
switch (index) {
89-
case 0:
90-
themeData = new ThemeData(primarySwatch: GSYColors.primarySwatch);
91-
break;
92-
case 1:
93-
themeData = new ThemeData(primarySwatch: Colors.brown);
94-
break;
95-
case 2:
96-
themeData = new ThemeData(primarySwatch: Colors.blue);
97-
break;
98-
case 3:
99-
themeData = new ThemeData(primarySwatch: Colors.teal);
100-
break;
101-
case 4:
102-
themeData = new ThemeData(primarySwatch: Colors.amber);
103-
break;
104-
case 5:
105-
themeData = new ThemeData(primarySwatch: Colors.blueGrey);
106-
break;
107-
case 6:
108-
themeData = new ThemeData(primarySwatch: Colors.deepOrange);
109-
break;
110-
}
88+
List<Color> colors = getThemeListColor();
89+
themeData = new ThemeData(primarySwatch: colors[index]);
11190
store.dispatch(new RefreshThemeDataAction(themeData));
11291
}
11392

93+
static List<Color> getThemeListColor() {
94+
return [
95+
GSYColors.primarySwatch,
96+
Colors.brown,
97+
Colors.blue,
98+
Colors.teal,
99+
Colors.amber,
100+
Colors.blueGrey,
101+
Colors.deepOrange,
102+
];
103+
}
104+
114105
static const IMAGE_END = [".png", ".jpg", ".jpeg", ".gif", ".svg"];
115106

116107
static isImageEnd(path) {
@@ -132,7 +123,7 @@ class CommonUtils {
132123
if (url == null && url.length == 0) return;
133124
Uri parseUrl = Uri.parse(url);
134125
bool isImage = isImageEnd(parseUrl.toString());
135-
if(parseUrl.toString().endsWith("?raw=true")) {
126+
if (parseUrl.toString().endsWith("?raw=true")) {
136127
isImage = isImageEnd(parseUrl.toString().replaceAll("?raw=true", ""));
137128
}
138129
if (isImage) {
@@ -165,8 +156,7 @@ class CommonUtils {
165156
if (url.startsWith("http")) {
166157
NavigatorUtils.goGSYWebView(context, url, title);
167158
} else {
168-
NavigatorUtils.goGSYWebView(
169-
context, new Uri.dataFromString(url, mimeType: 'text/html', encoding: Encoding.getByName("utf-8")).toString(), title);
159+
NavigatorUtils.goGSYWebView(context, new Uri.dataFromString(url, mimeType: 'text/html', encoding: Encoding.getByName("utf-8")).toString(), title);
170160
}
171161
}
172162

@@ -237,8 +227,14 @@ class CommonUtils {
237227
});
238228
}
239229

240-
static Future<Null> showCommitOptionDialog(BuildContext context, List<String> commitMaps, ValueChanged<int> onTap,
241-
{width = 250.0, height = 400.0}) {
230+
static Future<Null> showCommitOptionDialog(
231+
BuildContext context,
232+
List<String> commitMaps,
233+
ValueChanged<int> onTap, {
234+
width = 250.0,
235+
height = 400.0,
236+
List<Color> colorList,
237+
}) {
242238
return showDialog(
243239
context: context,
244240
builder: (BuildContext context) {
@@ -260,7 +256,7 @@ class CommonUtils {
260256
maxLines: 2,
261257
mainAxisAlignment: MainAxisAlignment.start,
262258
fontSize: 14.0,
263-
color: Theme.of(context).primaryColor,
259+
color: colorList != null ? colorList[index] : Theme.of(context).primaryColor,
264260
text: commitMaps[index],
265261
textColor: Color(GSYColors.white),
266262
onPress: () {

‎lib/page/MyPage.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class _MyPageState extends GSYListState<MyPage> {
8686
if (res != null && res.result && res.data.length > 0) {
8787
notifyColor = Color(GSYColors.actionBlue);
8888
} else {
89-
notifyColor = Color(GSYColors.subTextColor);
89+
notifyColor = Color(GSYColors.subLightTextColor);
9090
}
9191
});
9292
}

‎lib/widget/HomeDrawer.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class HomeDrawer extends StatelessWidget {
4747
CommonUtils.showCommitOptionDialog(context, list, (index) {
4848
CommonUtils.pushTheme(store, index);
4949
LocalStorage.save(Config.THEME_COLOR, index.toString());
50-
});
50+
}, colorList: CommonUtils.getThemeListColor());
5151
}
5252

5353
@override

‎lib/widget/IssueHeaderItem.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class IssueHeaderItem extends StatelessWidget {
6666
: new Container(
6767
child: new Text(
6868
"Close By " + issueHeaderViewModel.closedBy,
69-
style: GSYConstant.smallSubText,
69+
style: GSYConstant.smallSubLightText,
7070
),
7171
margin: new EdgeInsets.only(right: 5.0, top: 10.0, bottom: 10.0),
7272
alignment: Alignment.topRight);
@@ -107,7 +107,7 @@ class IssueHeaderItem extends StatelessWidget {
107107
///时间
108108
new Text(
109109
issueHeaderViewModel.actionTime,
110-
style: GSYConstant.smallSubText,
110+
style: GSYConstant.smallSubLightText,
111111
overflow: TextOverflow.ellipsis,
112112
),
113113
],

0 commit comments

Comments
 (0)