-
Notifications
You must be signed in to change notification settings - Fork 0
/
explore.dart
96 lines (93 loc) · 3.96 KB
/
explore.dart
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
import 'package:cached_network_image/cached_network_image.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:wallie/config/configuration.dart';
import 'package:wallie/screens/view_wallpaper.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
class ExplorePage extends StatefulWidget {
@override
_ExplorePageState createState() => _ExplorePageState();
}
class _ExplorePageState extends State<ExplorePage> {
final Firestore _db = Firestore.instance;
final spinKit = SpinKitFadingCircle(
itemBuilder: (BuildContext context, int index) {
return DecoratedBox(
decoration: BoxDecoration(
color: index.isEven ? Colors.red : Colors.green,
),
);
},
);
// List images = [
// ("https://images.pexels.com/photos/3584345/pexels-photo-3584345.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"),
// ("https://images.unsplash.com/photo-1586294839852-650d52bb6923?ixlib=rb-1.2.1&auto=format&fit=crop&w=334&q=80"),
// ("https://images.pexels.com/photos/1742370/pexels-photo-1742370.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"),
// ("https://images.pexels.com/photos/355952/pexels-photo-355952.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"),
// ("https://images.pexels.com/photos/2740956/pexels-photo-2740956.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"),
// ];
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Container(
child: Column(
children: <Widget>[
SizedBox(
height: 20,
),
Align(
child: Container(
padding: EdgeInsets.only(left: 15),
child: Text(
'Explore',
style: TextStyle(color: Colors.blue[100], fontSize: 35),
),
),
alignment: Alignment.centerLeft,
),
StreamBuilder(
stream: _db
.collection('Wallpapers')
.orderBy("date", descending: true)
.snapshots(),
builder: (ctx, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasData) {
return StaggeredGridView.countBuilder(
crossAxisCount: 2,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
staggeredTileBuilder: (int index) => StaggeredTile.fit(1),
itemCount: snapshot.data.documents.length,
mainAxisSpacing: 15,
crossAxisSpacing: 20,
padding: EdgeInsets.all(15),
itemBuilder: (context, index) {
return InkWell(
onTap: () {
Navigator.push((context),
MaterialPageRoute(builder: (context) {
return ViewWallpaper(
data: snapshot
.data.documents[index],
);
}));
},
child: Hero(
tag: snapshot.data.documents[index].data["url"],
child: ClipRRect(borderRadius: BorderRadius.circular(12),child: CachedNetworkImage(imageUrl: snapshot.data.documents[index].data['url']),)
));
},
);
}
return SpinKitDualRing(
color: primaryColor,
size: 50,
);
}),
],
),
),
);
}
}