Skip to content

Commit a47eb09

Browse files
committed
flutter chart item
1 parent 828f765 commit a47eb09

File tree

6 files changed

+103
-15
lines changed

6 files changed

+103
-15
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
**get_version**|**版本信息**
9898
**flutter_webview_plugin**|**全屏的webview**
9999
**sqflite**|**数据库**
100+
**flutter_statusbar**|**状态栏**
101+
**flutter_svg**|**svg**
100102

101103

102104
### 进行中:

VERSION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* webview点击跳转。
1515
* markdown htmlview 表格。
1616

17+
* trend修改为redux
1718
* 未读的通知进去issue提示其他异常
1819

1920
### 1.0.6(进行中)

lib/common/utils/CommonUtils.dart

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,31 @@ class CommonUtils {
3232
static double sStaticBarHeight = 0.0;
3333

3434
static void initStatusBarHeight(context) async {
35-
sStaticBarHeight = await FlutterStatusbar.height / MediaQuery.of(context).devicePixelRatio;
35+
sStaticBarHeight = await FlutterStatusbar.height / MediaQuery
36+
.of(context)
37+
.devicePixelRatio;
3638
}
3739

3840
static String getDateStr(DateTime date) {
3941
if (date == null || date.toString() == null) {
4042
return "";
41-
} else if (date.toString().length < 10) {
43+
} else if (date
44+
.toString()
45+
.length < 10) {
4246
return date.toString();
4347
}
4448
return date.toString().substring(0, 10);
4549
}
4650

51+
static String getUserChartAddress(String userName) {
52+
return Address.graphicHost + GSYColors.primaryValueString.replaceAll("#", "") + "/" + userName;
53+
}
54+
4755
///日期格式转换
4856
static String getNewsTimeStr(DateTime date) {
49-
int subTime = DateTime.now().millisecondsSinceEpoch - date.millisecondsSinceEpoch;
57+
int subTime = DateTime
58+
.now()
59+
.millisecondsSinceEpoch - date.millisecondsSinceEpoch;
5060

5161
if (subTime < MILLIS_LIMIT) {
5262
return "刚刚";
@@ -163,16 +173,15 @@ class CommonUtils {
163173
});
164174
}
165175

166-
static Future<Null> showEditDialog(
167-
BuildContext context,
168-
String dialogTitle,
169-
ValueChanged<String> onTitleChanged,
170-
ValueChanged<String> onContentChanged,
171-
VoidCallback onPressed, {
172-
TextEditingController titleController,
173-
TextEditingController valueController,
174-
bool needTitle = true,
175-
}) {
176+
static Future<Null> showEditDialog(BuildContext context,
177+
String dialogTitle,
178+
ValueChanged<String> onTitleChanged,
179+
ValueChanged<String> onContentChanged,
180+
VoidCallback onPressed, {
181+
TextEditingController titleController,
182+
TextEditingController valueController,
183+
bool needTitle = true,
184+
}) {
176185
return showDialog(
177186
context: context,
178187
builder: (BuildContext context) {

lib/widget/UserHeader.dart

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_spinkit/flutter_spinkit.dart';
3+
import 'package:flutter_svg/flutter_svg.dart';
24
import 'package:gsy_github_app_flutter/common/model/User.dart';
35
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
46
import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart';
@@ -68,6 +70,43 @@ class UserHeaderItem extends StatelessWidget {
6870
});
6971
}
7072

73+
_renderChart(context) {
74+
double height = 140.0;
75+
double width = 3 * MediaQuery.of(context).size.width / 2;
76+
return userInfo.login != null
77+
? new Card(
78+
margin: EdgeInsets.only(top: 0.0, left: 10.0, right: 10.0, bottom: 10.0),
79+
color: Colors.white,
80+
child: new SingleChildScrollView(
81+
scrollDirection: Axis.horizontal,
82+
child: new Container(
83+
padding: EdgeInsets.only(left: 10.0, right: 10.0),
84+
width: width,
85+
height: height,
86+
child: new SvgPicture.network(
87+
CommonUtils.getUserChartAddress(userInfo.login),
88+
width: width,
89+
height: height - 10,
90+
allowDrawingOutsideViewBox: true,
91+
placeholderBuilder: (BuildContext context) => new Container(
92+
height: height / 2,
93+
width: width,
94+
child: Center(
95+
child: const SpinKitRipple (color: Color(GSYColors.primaryValue)),
96+
),
97+
),
98+
),
99+
),
100+
),
101+
)
102+
: new Container(
103+
height: height,
104+
child: Center(
105+
child: const SpinKitRipple(color: Color(GSYColors.primaryValue)),
106+
),
107+
);
108+
}
109+
71110
@override
72111
Widget build(BuildContext context) {
73112
return new Column(
@@ -91,7 +130,7 @@ class UserHeaderItem extends StatelessWidget {
91130
placeholder: GSYICons.DEFAULT_USER_ICON,
92131
//预览图
93132
fit: BoxFit.fitWidth,
94-
image:userInfo.avatar_url ?? GSYICons.DEFAULT_REMOTE_PIC,
133+
image: userInfo.avatar_url ?? GSYICons.DEFAULT_REMOTE_PIC,
95134
width: 80.0,
96135
height: 80.0,
97136
),
@@ -217,6 +256,7 @@ class UserHeaderItem extends StatelessWidget {
217256
),
218257
margin: new EdgeInsets.only(top: 15.0, bottom: 15.0, left: 12.0),
219258
alignment: Alignment.topLeft),
259+
_renderChart(context),
220260
],
221261
);
222262
}

pubspec.lock

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ packages:
195195
url: "https://pub.flutter-io.cn"
196196
source: hosted
197197
version: "0.0.1"
198+
flutter_svg:
199+
dependency: "direct main"
200+
description:
201+
name: flutter_svg
202+
url: "https://pub.flutter-io.cn"
203+
source: hosted
204+
version: "0.5.4"
198205
flutter_webview_plugin:
199206
dependency: "direct main"
200207
description:
@@ -349,6 +356,27 @@ packages:
349356
url: "https://pub.flutter-io.cn"
350357
source: hosted
351358
version: "1.6.2"
359+
path_drawing:
360+
dependency: transitive
361+
description:
362+
name: path_drawing
363+
url: "https://pub.flutter-io.cn"
364+
source: hosted
365+
version: "0.3.0"
366+
path_parsing:
367+
dependency: transitive
368+
description:
369+
name: path_parsing
370+
url: "https://pub.flutter-io.cn"
371+
source: hosted
372+
version: "0.1.2"
373+
petitparser:
374+
dependency: transitive
375+
description:
376+
name: petitparser
377+
url: "https://pub.flutter-io.cn"
378+
source: hosted
379+
version: "1.7.7"
352380
plugin:
353381
dependency: transitive
354382
description:
@@ -501,6 +529,13 @@ packages:
501529
url: "https://pub.flutter-io.cn"
502530
source: hosted
503531
version: "0.9.7+10"
532+
xml:
533+
dependency: transitive
534+
description:
535+
name: xml
536+
url: "https://pub.flutter-io.cn"
537+
source: hosted
538+
version: "3.0.1"
504539
yaml:
505540
dependency: transitive
506541
description:
@@ -510,4 +545,4 @@ packages:
510545
version: "2.1.15"
511546
sdks:
512547
dart: ">=2.0.0-dev.62.0 <=2.0.0-dev.63.0.flutter-4c9689c1d2"
513-
flutter: ">=0.1.4 <2.0.0"
548+
flutter: ">=0.5.1 <2.0.0"

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dependencies:
2424
sqflite: ^0.11.0+5
2525
pub_semver: ^1.4.2
2626
flutter_statusbar: ^0.0.1
27+
flutter_svg: ^0.5.4
2728

2829
dev_dependencies:
2930
build_runner: ^0.7.6

0 commit comments

Comments
 (0)