Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1e5a542

Browse files
ADD:添加新英雄-镜
1 parent a167f9a commit 1e5a542

File tree

12 files changed

+700
-129
lines changed

12 files changed

+700
-129
lines changed

‎.flutter-plugins-dependencies‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"webview_flutter","dependencies":[]}]}
1+
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"webview_flutter","dependencies":[]}]}

‎ios/Podfile.lock‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ PODS:
77
- Flutter
88
- path_provider (0.0.1):
99
- Flutter
10+
- path_provider_macos (0.0.1):
11+
- Flutter
1012
- shared_preferences (0.0.1):
1113
- Flutter
1214
- shared_preferences_macos (0.0.1):
@@ -23,6 +25,7 @@ DEPENDENCIES:
2325
- Flutter (from `Flutter`)
2426
- package_info (from `.symlinks/plugins/package_info/ios`)
2527
- path_provider (from `.symlinks/plugins/path_provider/ios`)
28+
- path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
2629
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
2730
- shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`)
2831
- shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`)
@@ -40,6 +43,8 @@ EXTERNAL SOURCES:
4043
:path: ".symlinks/plugins/package_info/ios"
4144
path_provider:
4245
:path: ".symlinks/plugins/path_provider/ios"
46+
path_provider_macos:
47+
:path: ".symlinks/plugins/path_provider_macos/ios"
4348
shared_preferences:
4449
:path: ".symlinks/plugins/shared_preferences/ios"
4550
shared_preferences_macos:
@@ -56,6 +61,7 @@ SPEC CHECKSUMS:
5661
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
5762
package_info: 48b108e75b8802c2d5e126f208ef540561c98aef
5863
path_provider: fb74bd0465e96b594bb3b5088ee4a4e7bb1f2a9d
64+
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
5965
shared_preferences: 430726339841afefe5142b9c1f50cb6bd7793e01
6066
shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087
6167
shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import 'package:flutter/widgets.dart';
2+
3+
class Photo {
4+
/// tag
5+
String tag;
6+
7+
/// url
8+
String url;
9+
10+
/// 是否本地图片
11+
bool isLocal;
12+
13+
/// 构造函数
14+
Photo({@required this.url, this.tag, this.isLocal = false});
15+
16+
Photo.fromJson(Map<String, dynamic> json) {
17+
tag = json['tag'];
18+
url = json['url'];
19+
isLocal = json['isLocal'];
20+
}
21+
22+
Map<String, dynamic> toJson() {
23+
final Map<String, dynamic> data = new Map<String, dynamic>();
24+
data['tag'] = this.tag;
25+
data['url'] = this.url;
26+
data['isLocal'] = this.isLocal;
27+
return data;
28+
}
29+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import 'package:flutter/material.dart';
2+
3+
import 'package:photo_view/photo_view.dart';
4+
import 'package:photo_view/photo_view_gallery.dart';
5+
import 'package:cached_network_image/cached_network_image.dart';
6+
// -[flutter_page_indicator](https://github.com/best-flutter/flutter_page_indicator)
7+
import 'package:flutter_page_indicator/flutter_page_indicator.dart';
8+
9+
import 'package:flutter_wechat/components/photo_browser/photo.dart';
10+
11+
class PhotoBrowser extends StatefulWidget {
12+
PhotoBrowser({
13+
this.loadingBuilder,
14+
this.backgroundDecoration,
15+
this.minScale,
16+
this.maxScale,
17+
this.initialIndex,
18+
@required this.photos,
19+
this.scrollDirection = Axis.horizontal,
20+
}) : pageController = PageController(initialPage: initialIndex);
21+
22+
final LoadingBuilder loadingBuilder;
23+
final Decoration backgroundDecoration;
24+
final dynamic minScale;
25+
final dynamic maxScale;
26+
final int initialIndex;
27+
final PageController pageController;
28+
final List<Photo> photos;
29+
final Axis scrollDirection;
30+
31+
@override
32+
State<StatefulWidget> createState() {
33+
return _PhotoBrowserState();
34+
}
35+
}
36+
37+
class _PhotoBrowserState extends State<PhotoBrowser> {
38+
int currentIndex;
39+
40+
@override
41+
void initState() {
42+
currentIndex = widget.initialIndex;
43+
super.initState();
44+
}
45+
46+
void onPageChanged(int index) {
47+
setState(() {
48+
currentIndex = index;
49+
});
50+
}
51+
52+
@override
53+
Widget build(BuildContext context) {
54+
return Scaffold(
55+
// 设置成黑色
56+
backgroundColor: Colors.black,
57+
body: Container(
58+
decoration: widget.backgroundDecoration,
59+
constraints: BoxConstraints.expand(
60+
height: MediaQuery.of(context).size.height,
61+
),
62+
child: Stack(
63+
alignment: Alignment.center,
64+
children: <Widget>[
65+
PhotoViewGallery.builder(
66+
scrollPhysics: const BouncingScrollPhysics(),
67+
builder: _buildItem,
68+
itemCount: widget.photos.length,
69+
loadingBuilder: (context, progress) => Center(
70+
child: Container(
71+
width: 30.0,
72+
height: 30.0,
73+
child: CircularProgressIndicator(
74+
backgroundColor: Colors.black45,
75+
valueColor: new AlwaysStoppedAnimation<Color>(Colors.white),
76+
value: progress == null
77+
? null
78+
: progress.cumulativeBytesLoaded /
79+
progress.expectedTotalBytes,
80+
),
81+
),
82+
),
83+
backgroundDecoration: widget.backgroundDecoration,
84+
pageController: widget.pageController,
85+
onPageChanged: onPageChanged,
86+
scrollDirection: widget.scrollDirection,
87+
// gaplessPlayback: true,
88+
// reverse: true,
89+
),
90+
Positioned(
91+
bottom: 20.0,
92+
child: new PageIndicator(
93+
layout: PageIndicatorLayout.SCALE,
94+
size: 10.0,
95+
controller: widget.pageController,
96+
space: 5.0,
97+
count: widget.photos.length,
98+
),
99+
)
100+
],
101+
),
102+
),
103+
);
104+
}
105+
106+
PhotoViewGalleryPageOptions _buildItem(BuildContext context, int index) {
107+
final Photo item = widget.photos[index];
108+
// NetworkImage(item.url)
109+
return PhotoViewGalleryPageOptions(
110+
imageProvider: item.isLocal
111+
? AssetImage(item.url)
112+
: CachedNetworkImageProvider(item.url),
113+
initialScale: PhotoViewComputedScale.contained,
114+
minScale: PhotoViewComputedScale.contained * (0.5 + index / 10),
115+
maxScale: PhotoViewComputedScale.covered * 1.1,
116+
heroAttributes: PhotoViewHeroAttributes(tag: item.tag),
117+
onTapUp: (context, detail, value) {
118+
Navigator.pop(context);
119+
},
120+
);
121+
}
122+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import 'dart:convert';
2+
3+
import 'package:fluro/fluro.dart';
4+
5+
import 'package:flutter_wechat/components/photo_browser/photo.dart';
6+
import 'package:flutter_wechat/routers/router_init.dart';
7+
8+
import 'photo_browser.dart';
9+
10+
class PhotoBrowserRouter implements IRouterProvider {
11+
/// 图片浏览器 root页
12+
static String photoBrowserPage = "/photo-browser";
13+
14+
@override
15+
void initRouter(Router router) {
16+
router.define(
17+
photoBrowserPage,
18+
handler: Handler(handlerFunc: (_, params) {
19+
final String initialIndex = params['initialIndex']?.first;
20+
final String jsonStr = params['photos']?.first;
21+
final List jsons = json.decode(jsonStr);
22+
23+
/// photos
24+
final List<Photo> photos = [];
25+
// // 遍历
26+
jsons.forEach((json) {
27+
final Photo m = Photo.fromJson(json);
28+
photos.add(m);
29+
});
30+
return PhotoBrowser(
31+
photos: photos,
32+
initialIndex: int.parse(initialIndex),
33+
);
34+
}),
35+
);
36+
}
37+
}

‎lib/model/picture/picture.dart‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
class Picture {
2+
String name;
3+
PictureMeta small;
4+
PictureMeta big;
5+
6+
Picture({this.name, this.small, this.big});
7+
8+
Picture.fromJson(Map<String, dynamic> json) {
9+
name = json['name'];
10+
small =
11+
json['small'] != null ? new PictureMeta.fromJson(json['small']) : null;
12+
big = json['big'] != null ? new PictureMeta.fromJson(json['big']) : null;
13+
}
14+
15+
Map<String, dynamic> toJson() {
16+
final Map<String, dynamic> data = new Map<String, dynamic>();
17+
data['name'] = this.name;
18+
if (this.small != null) {
19+
data['small'] = this.small.toJson();
20+
}
21+
if (this.big != null) {
22+
data['big'] = this.big.toJson();
23+
}
24+
return data;
25+
}
26+
}
27+
28+
class PictureMeta {
29+
String url;
30+
31+
PictureMeta({this.url});
32+
33+
PictureMeta.fromJson(Map<String, dynamic> json) {
34+
url = json['url'];
35+
}
36+
37+
Map<String, dynamic> toJson() {
38+
final Map<String, dynamic> data = new Map<String, dynamic>();
39+
data['url'] = this.url;
40+
return data;
41+
}
42+
}

‎lib/model/user/user.dart‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:azlistview/azlistview.dart';
2+
import 'package:flutter_wechat/model/picture/picture.dart';
23

34
///
45
class User extends ISuspensionBean {
@@ -22,7 +23,7 @@ class User extends ISuspensionBean {
2223
/// 地区
2324
String region;
2425
List phones;
25-
List pictures;
26+
List<Picture> pictures;
2627
String remarks;
2728

2829
/// 用于通讯录排序
@@ -72,7 +73,12 @@ class User extends ISuspensionBean {
7273
zoneCode = json['zoneCode'];
7374
region = json['region'];
7475
phones = json['phones'];
75-
pictures = json['pictures'];
76+
if (json['pictures'] != null) {
77+
pictures = new List<Picture>();
78+
json['pictures'].forEach((v) {
79+
pictures.add(new Picture.fromJson(v));
80+
});
81+
}
7682
remarks = json['remarks'];
7783
screenNamePinyin = json['screenNamePinyin'];
7884
tagIndex = json['tagIndex'];
@@ -96,7 +102,9 @@ class User extends ISuspensionBean {
96102
data['zoneCode'] = this.zoneCode;
97103
data['region'] = this.region;
98104
data['phones'] = this.phones;
99-
data['pictures'] = this.pictures;
105+
if (this.pictures != null) {
106+
data['pictures'] = this.pictures.map((v) => v.toJson()).toList();
107+
}
100108
data['remarks'] = this.remarks;
101109
data['screenNamePinyin'] = this.screenNamePinyin;
102110
data['tagIndex'] = this.tagIndex;

‎lib/routers/routers.dart‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import 'package:fluro/fluro.dart';
22
import 'package:flutter/material.dart';
3+
import 'package:flutter_wechat/components/photo_browser/photo_browser.dart';
34

45
// import 'package:flutter_wechat/account/account_router.dart';
56
// import 'package:flutter_wechat/goods/goods_router.dart';
67
// import 'package:flutter_wechat/routers/404.dart';
78
import 'package:flutter_wechat/views/login/login_router.dart';
89
import 'package:flutter_wechat/views/profile/profile_rourer.dart';
910
import 'package:flutter_wechat/views/contacts/contacts_router.dart';
11+
import 'package:flutter_wechat/components/photo_browser/photo_browser_router.dart';
1012

1113
import 'package:flutter_wechat/views/login/current_login/current_login_page.dart';
1214
import 'package:flutter_wechat/routers/router_init.dart';
@@ -62,6 +64,7 @@ class Routers {
6264
_listRouter.add(LoginRouter());
6365
_listRouter.add(ProfileRouter());
6466
_listRouter.add(ContactsRouter());
67+
_listRouter.add(PhotoBrowserRouter());
6568
// _listRouter.add(StoreRouter());
6669
// _listRouter.add(AccountRouter());
6770
// _listRouter.add(SettingRouter());

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /