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 4c6ae79

Browse files
Make single post view page
1 parent c5040ad commit 4c6ae79

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

‎lib/pages/SinglePost.dart

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import 'dart:ui';
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter_photography/data/Sample.dart';
4+
import 'package:flutter_photography/helper/Colorsys.dart';
5+
import 'package:flutter_photography/models/Post.dart';
6+
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
7+
8+
class SinglePost extends StatelessWidget {
9+
final Post post;
10+
final String image;
11+
12+
const SinglePost({Key key, this.post, this.image}) : super(key: key);
13+
14+
@override
15+
Widget build(BuildContext context) {
16+
double height = MediaQuery.of(context).size.height;
17+
18+
return Scaffold(
19+
body: SingleChildScrollView(
20+
child: Column(
21+
children: <Widget>[
22+
Container(
23+
padding: EdgeInsets.only(top: 70, bottom: 20, right: 20, left: 20,),
24+
height: height / 2,
25+
width: double.infinity,
26+
decoration: BoxDecoration(
27+
borderRadius: BorderRadius.only(
28+
bottomLeft: Radius.circular(20),
29+
bottomRight: Radius.circular(20)
30+
),
31+
image: DecorationImage(
32+
fit: BoxFit.cover,
33+
image: AssetImage(image)
34+
)
35+
),
36+
child: Column(
37+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
38+
crossAxisAlignment: CrossAxisAlignment.start,
39+
children: <Widget>[
40+
InkWell(
41+
onTap: () {
42+
Navigator.pop(context);
43+
},
44+
child: ClipRect(
45+
child: BackdropFilter(
46+
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
47+
child: Container(
48+
width: 30.0,
49+
height: 30.0,
50+
decoration: BoxDecoration(
51+
borderRadius: BorderRadius.circular(4),
52+
color: Colors.black.withOpacity(0.2)
53+
),
54+
child: Center(
55+
child: Icon(Icons.arrow_back_ios, color: Colors.white, size: 18,),
56+
),
57+
),
58+
),
59+
),
60+
),
61+
Row(
62+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
63+
children: <Widget>[
64+
Row(
65+
children: <Widget>[
66+
CircleAvatar(
67+
maxRadius: 25,
68+
backgroundImage: AssetImage(post.user.profilePicture),
69+
),
70+
SizedBox(width: 10,),
71+
Text(post.user.name, style: TextStyle(
72+
color: Colors.white,
73+
fontWeight: FontWeight.w600
74+
),)
75+
],
76+
),
77+
ClipRect(
78+
child: BackdropFilter(
79+
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
80+
child: Container(
81+
width: 32.0,
82+
height: 32.0,
83+
padding: EdgeInsets.all(7),
84+
decoration: BoxDecoration(
85+
borderRadius: BorderRadius.circular(4),
86+
color: Colors.grey[600].withOpacity(0.1)
87+
),
88+
child: Center(
89+
child: Image.asset('assets/icons/download.png')
90+
),
91+
),
92+
),
93+
),
94+
],
95+
)
96+
],
97+
),
98+
),
99+
Padding(
100+
padding: EdgeInsets.all(20),
101+
child: Column(
102+
children: <Widget>[
103+
Row(
104+
children: <Widget>[
105+
Image.asset('assets/icons/location.png', scale: 2.2),
106+
SizedBox(width: 5,),
107+
Text("Kabul, Afghanistan", style: TextStyle(
108+
fontSize: 13,
109+
fontWeight: FontWeight.w600,
110+
color: Colorsys.grey
111+
),)
112+
],
113+
),
114+
makeRelatedPhotos(post)
115+
],
116+
),
117+
)
118+
],
119+
),
120+
),
121+
);
122+
}
123+
124+
Widget makeRelatedPhotos(Post post) {
125+
return StaggeredGridView.countBuilder(
126+
crossAxisCount: 4,
127+
itemCount: post.relatedPhotos.length,
128+
mainAxisSpacing: 10.0,
129+
crossAxisSpacing: 10.0,
130+
physics: NeverScrollableScrollPhysics(),
131+
shrinkWrap: true,
132+
itemBuilder: (context, index) => Container(
133+
decoration: BoxDecoration(
134+
borderRadius: BorderRadius.circular(5),
135+
image: DecorationImage(
136+
fit: BoxFit.cover,
137+
image: AssetImage(post.relatedPhotos[index])
138+
),
139+
color: Colors.green
140+
),
141+
),
142+
staggeredTileBuilder: (int index) => StaggeredTile.count(2, index.isEven ? 3 : 2),
143+
);
144+
}
145+
}

0 commit comments

Comments
(0)

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