fPaste.me

A free, anonymous, minimalist and open source paste tool.


Untitled
14-08-2021 15:52:55
Anonymous
class PostTile extends StatefulWidget {
PostTile({Key? key}) : super(key: key);

@override
_PostTileState createState() => _PostTileState();
}

// to do ...
/// padding verilceke simetrik olarak
/// margin de verilebilir list widget için marigin vermek daha mantıklı
/// sonsuza kadar giderse expanded ıcıne ala
class _PostTileState extends State<PostTile> {
final _dummyAvatar =
'https://static.wikia.nocookie.net/inuyasha/images/b/b5/Inuyasha.png/revision/latest?cb=20151128185518';
final _dummyImage =
'https://i1.wp.com/butwhythopodcast.com/wp-content/uploads/2020/09/maxresdefault-28.jpg?fit=1280%2C720&ssl=1';

// from https://github.com/MarcusNg/flutter_instagram_feed_ui_redesign/blob/master/lib/screens/view_post_screen.dart

// sadece listtile değil en ustte bir tanımlama yapılabilir
// gridviewde olabilir yan yana 2 wwidget....
// alt tarafa bottom navigationi eklee... mainapprouut kısmında
// her secimde setstate ile eşleme yap
// border: Border.all(color: Color(0xFF0001FC))

@override
Widget build(BuildContext context) {
return _postView(context);
//);
}

Widget _postAuthorRow(BuildContext context) {
const double avatarDiameter = 44;
return GestureDetector(
// to do -> go to profile ...
// onTap: () => BlocProvider.of<HomeNavigatorCubit>(context).showProfile(),
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(8),
child: Container(
width: avatarDiameter,
height: avatarDiameter,
decoration: BoxDecoration(
color: Colors.blue,
shape: BoxShape.circle,
),
child: ClipRRect(
borderRadius: BorderRadius.circular(avatarDiameter / 2),
child: CachedNetworkImage(
imageUrl: _dummyAvatar,
fit: BoxFit.cover,
),
),
),
),
Text(
'Username',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
],
),
);
}

Widget _postCommentsAndLikeButton(BuildContext context) {
bool _iconpressedlike = true;

return Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
// onTap: () =>
// BlocProvider.of<HomeNavigatorCubit>(context).showComments(),
child: Text(
'Add Comment',
style: TextStyle(fontWeight: FontWeight.w200),
),
),
GestureDetector(
// onTap: () =>
// BlocProvider.of<HomeNavigatorCubit>(context).showComments(),

child: Text(
'Add Like',
style: TextStyle(fontWeight: FontWeight.w200),
),
),
GestureDetector(
// onTap: () =>
// BlocProvider.of<HomeNavigatorCubit>(context).showComments(),

child: Text(
'Add Basket',
style: TextStyle(fontWeight: FontWeight.w200),
),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(
// onTap: () =>
// BlocProvider.of<HomeNavigatorCubit>(context).showComments(),
icon: Icon(Icons.comment),
onPressed: () {},
),
IconButton(
// onTap: () =>
// BlocProvider.of<HomeNavigatorCubit>(context).showComments(),
//icon: Icon(Icons.favorite,
// color: Colors.blue, //add this line here
// color: (iconpressedlike)
// ? Color(0xff007397)
// : Color(0xff9A9A9A),
/* icon:Icon(iconpressedlike ? Icons.favorite : Icons.favorite_border,
color: iconpressedlike ? Colors.red : null,
), */
icon: Icon(Icons.favorite),
color: _iconpressedlike ? Colors.blue : Colors.black,
//color: iconpressedlike ? Colors.red : Colors.blue,
//color: iconpressedlike ? Colors.red : Colors.black,
onPressed: () {
//_iconbuttonpresschange();

//_iconpressedlike = !_iconpressedlike;
// https://stackoverflow.com/questions/64417864/how-change-the-icon-of-an-iconbutton-when-it-is-pressed
// _iconpressedlike = !_iconpressedlike;
// print(_iconpressedlike);
setState(() {
_iconpressedlike = !_iconpressedlike;
//print(_iconpressedlike);
});
},
),
IconButton(
// onTap: () =>
// BlocProvider.of<HomeNavigatorCubit>(context).showComments(),
onPressed: () {},
icon: Icon(Icons.sell),
),
],
),
],
);

//);
}

Widget _postCaption() {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
child: Text('Welcome To My Selling store. Description'),
);
}

Widget _postImage() {
return AspectRatio(
aspectRatio: 1,
child: CachedNetworkImage(
fit: BoxFit.cover,
imageUrl: _dummyImage,
),
);
}

Widget _postView(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_postAuthorRow(context),
_postImage(),
_postCaption(),
_postCommentsAndLikeButton(context),
// _postAddsButton(context),
],
);
}
}