👨🏫14 instagram part 2
class PostScreen extends StatefulWidget {
const PostScreen({super.key});
@override
State<PostScreen> createState() => _PostScreenState();
}
class _PostScreenState extends State<PostScreen> {
List<Map<String, dynamic>> stories = [
{'isWatched': true, 'profileImage': 'assets/apple.png', 'name': 'Eldiar'},
{'isWatched': true, 'profileImage': 'assets/apple.png', 'name': 'Madina'},
{'isWatched': true, 'profileImage': 'assets/apple.png', 'name': 'Darhan'},
{'isWatched': true, 'profileImage': 'assets/apple.png', 'name': 'Nursaid'},
{'isWatched': true, 'profileImage': 'assets/apple.png', 'name': 'Saikal'},
{'isWatched': true, 'profileImage': 'assets/apple.png', 'name': 'Nurjigit'},
];
List<Map<String, dynamic>> posts = [
{
'profileImage': 'assets/peach1.png',
'name': 'Eldiar',
'place': '',
'images': ['assets/apple.png', 'assets/Content.png'],
'isLike': false,
'comments': 123,
'repost': 12,
'send': 234,
'isBookmark': false,
},
{
'profileImage': 'assets/peach1.png',
'name': 'Madina',
'place': '',
'images': ['assets/apple.png', 'assets/Content.png'],
'isLike': false,
'comments': 123,
'repost': 12,
'send': 234,
'isBookmark': false,
},
{
'profileImage': 'assets/peach1.png',
'name': 'Darhan',
'place': '',
'images': ['assets/apple.png', 'assets/Content.png'],
'isLike': false,
'comments': 123,
'repost': 12,
'send': 234,
'isBookmark': false,
},
];
@override
Widget build(BuildContext context) {
return CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: Row(
mainAxisAlignment: .spaceBetween,
children: [
IconButton(onPressed: () {}, icon: Icon(Icons.add)),
Text('Instagram'),
IconButton(onPressed: () {}, icon: Icon(Icons.favorite_border)),
],
),
),
SliverToBoxAdapter(
child: SizedBox(
height: 110,
child: ListView.builder(
shrinkWrap: true,
itemCount: 10,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.only(right: 10),
child: Column(
children: [
GestureDetector(
onTap: () {
setState(() {
stories[index]['isWatched'] = false;
});
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => StoriesScreen(),
),
);
},
child: CircleAvatar(
radius: 40,
backgroundColor: stories[index]['isWatched']
? Colors.red
: Colors.grey.shade400,
child: CircleAvatar(
radius: 35,
backgroundImage: AssetImage(
stories[index]['profileImage'],
),
),
),
),
Text(stories[index]['name']),
],
),
);
},
),
),
),
SliverFixedExtentList.builder(
itemCount: 20,
itemBuilder: (context, index) {
return Column(
children: [
ListTile(
leading: CircleAvatar(
backgroundImage: AssetImage(posts[index]['profileImage']),
),
title: Text(posts[index]['name']),
subtitle: Text('place'),
trailing: Icon(Icons.more_horiz),
),
SizedBox(
height: 300,
width: double.infinity,
child: ListView.builder(
shrinkWrap: true,
itemCount: posts[index]['images'].length,
scrollDirection: Axis.horizontal,
itemBuilder: (context, imagesIndex) {
return Image.asset(
posts[index]['images'][imagesIndex],
fit: BoxFit.cover,
);
},
),
),
],
);
},
itemExtent: 550,
),
],
);
}
}Last updated