|
| 1 | +import 'package:cached_network_image/cached_network_image.dart'; |
1 | 2 | import 'package:figma_squircle/figma_squircle.dart';
|
2 | 3 | import 'package:fistagram/custom_icons_icons.dart';
|
3 | 4 | import 'package:fistagram/utils/colors.dart';
|
4 | 5 | import 'package:flutter/material.dart';
|
| 6 | +import 'package:shimmer/shimmer.dart'; |
5 | 7 |
|
6 | 8 | class PostBox extends StatefulWidget {
|
7 | 9 | final String userId;
|
8 | 10 | final likes, numberOfComments;
|
9 | 11 | final String imagePath;
|
| 12 | + final String profileImage; |
10 | 13 | const PostBox({
|
11 | 14 | Key? key,
|
12 | 15 | required this.userId,
|
| 16 | + required this.profileImage, |
13 | 17 | required this.likes,
|
14 | 18 | required this.numberOfComments,
|
15 | 19 | required this.imagePath,
|
@@ -40,7 +44,7 @@ class _PostBoxState extends State<PostBox> {
|
40 | 44 | ),
|
41 | 45 | CircleAvatar(
|
42 | 46 | radius: 13,
|
43 |
| - child: Image.asset("assets/img/profile_pic.png"), |
| 47 | + backgroundImage: NetworkImage(widget.profileImage), |
44 | 48 | ),
|
45 | 49 | const Padding(
|
46 | 50 | padding: EdgeInsets.only(
|
@@ -75,10 +79,22 @@ class _PostBoxState extends State<PostBox> {
|
75 | 79 | cornerRadius: 12,
|
76 | 80 | cornerSmoothing: 1,
|
77 | 81 | ),
|
78 |
| - child: Container( |
79 |
| - height: MediaQuery.of(context).size.height * 0.45, |
80 |
| - width: MediaQuery.of(context).size.width * 0.9, |
81 |
| - child: Image.asset(widget.imagePath, fit: BoxFit.cover)), |
| 82 | + child: SizedBox( |
| 83 | + height: MediaQuery.of(context).size.height * 0.45, |
| 84 | + width: MediaQuery.of(context).size.width * 0.9, |
| 85 | + child: CachedNetworkImage( |
| 86 | + imageUrl: widget.imagePath, |
| 87 | + placeholder: (context, url) { |
| 88 | + return Shimmer.fromColors( |
| 89 | + baseColor: Colors.grey[300]!, |
| 90 | + highlightColor: Colors.grey[100]!, |
| 91 | + child: Container( |
| 92 | + color: Colors.grey[300], |
| 93 | + )); |
| 94 | + }, |
| 95 | + fit: BoxFit.cover, |
| 96 | + ), |
| 97 | + ), |
82 | 98 | ),
|
83 | 99 | //-----------------------Footer section----------------------
|
84 | 100 | Container(
|
@@ -127,7 +143,7 @@ class _PostBoxState extends State<PostBox> {
|
127 | 143 | style: const TextStyle(
|
128 | 144 | fontSize: 16, fontWeight: FontWeight.w300))
|
129 | 145 | ]),
|
130 |
| - Spacer(), |
| 146 | + const Spacer(), |
131 | 147 | SizedBox(
|
132 | 148 | width: 32,
|
133 | 149 | child: IconButton(
|
|
0 commit comments