fix lint errors

This commit is contained in:
shilangyu 2020-08-31 16:19:44 +02:00
parent f4bd1eb65b
commit 9133ef94cd
2 changed files with 160 additions and 168 deletions

View File

@ -24,10 +24,8 @@ void main() {
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Observer(
builder: (ctx) {
return MaterialApp(
Widget build(BuildContext context) => Observer(
builder: (ctx) => MaterialApp(
title: 'Flutter Demo',
themeMode: ctx.watch<ConfigStore>().theme,
darkTheme: ThemeData.dark(),
@ -37,10 +35,8 @@ class MyApp extends StatelessWidget {
),
home: UserProfileTab(User.fromJson(jsonDecode(
'''{"id":13917,"name":"shilangyu","preferred_username":null,"password_encrypted":"","email":"xmarcinmarcin@gmail.com","avatar":null,"admin":false,"banned":false,"published":"2020-08-23T07:13:23.229279","updated":"2020-08-29T21:11:11.508707","show_nsfw":true,"theme":"minty","default_sort_type":0,"default_listing_type":1,"lang":"browser","show_avatars":true,"send_notifications_to_email":false,"matrix_user_id":null,"actor_id":"https://dev.lemmy.ml/u/shilangyu","bio":null,"local":true,"private_key":null,"public_key":null,"last_refreshed_at":"2020-08-23T07:13:23.229279","banner":null}'''))),
);
},
);
}
),
);
}
class MyHomePage extends StatefulWidget {

View File

@ -43,155 +43,152 @@ class PostWidget extends StatelessWidget {
);
}
Widget _info() {
return Column(children: [
Padding(
padding: const EdgeInsets.all(10),
child: Row(children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
if (post.communityIcon != null)
Padding(
padding: const EdgeInsets.only(right: 10),
child: InkWell(
onTap: () => print('GO TO COMMUNITY'),
child: SizedBox(
height: 40,
width: 40,
child: CachedNetworkImage(
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
fit: BoxFit.cover,
image: imageProvider,
Widget _info() => Column(children: [
Padding(
padding: const EdgeInsets.all(10),
child: Row(children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
if (post.communityIcon != null)
Padding(
padding: const EdgeInsets.only(right: 10),
child: InkWell(
onTap: () => print('GO TO COMMUNITY'),
child: SizedBox(
height: 40,
width: 40,
child: CachedNetworkImage(
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
fit: BoxFit.cover,
image: imageProvider,
),
),
),
imageUrl: post.communityIcon,
errorWidget: (context, url, error) =>
Text(error.toString()),
),
imageUrl: post.communityIcon,
errorWidget: (context, url, error) =>
Text(error.toString()),
),
),
),
),
],
),
Column(
children: [
Row(children: [
RichText(
overflow: TextOverflow.ellipsis, // @TODO: fix overflowing
text: TextSpan(
style: TextStyle(
fontSize: 15, color: _theme.textTheme.bodyText1.color),
children: [
TextSpan(
text: '!',
style: TextStyle(fontWeight: FontWeight.w300)),
TextSpan(
text: post.communityName,
style: TextStyle(fontWeight: FontWeight.w600),
recognizer: TapGestureRecognizer()
..onTap = () => print('GO TO COMMUNITY')),
TextSpan(
text: '@',
style: TextStyle(fontWeight: FontWeight.w300)),
TextSpan(
text: hostUrl,
style: TextStyle(fontWeight: FontWeight.w600),
recognizer: TapGestureRecognizer()
..onTap = () => print('GO TO INSTANCE')),
],
),
)
]),
Row(children: [
RichText(
overflow: TextOverflow.ellipsis,
],
),
Column(
children: [
Row(children: [
RichText(
overflow: TextOverflow.ellipsis, // @TODO: fix overflowing
text: TextSpan(
style: TextStyle(
fontSize: 13,
fontSize: 15,
color: _theme.textTheme.bodyText1.color),
children: [
TextSpan(
text: 'by',
text: '!',
style: TextStyle(fontWeight: FontWeight.w300)),
TextSpan(
text:
''' ${post.creatorPreferredUsername ?? post.creatorName}''',
style: TextStyle(fontWeight: FontWeight.w600),
recognizer: TapGestureRecognizer()
..onTap = () => print('GO TO USER'),
),
text: post.communityName,
style: TextStyle(fontWeight: FontWeight.w600),
recognizer: TapGestureRecognizer()
..onTap = () => print('GO TO COMMUNITY')),
TextSpan(
text:
''' · ${timeago.format(post.published, locale: 'en_short')}'''),
if (linkPostDomain != null)
TextSpan(text: ' · $linkPostDomain'),
if (post.locked) TextSpan(text: ' · 🔒'),
text: '@',
style: TextStyle(fontWeight: FontWeight.w300)),
TextSpan(
text: hostUrl,
style: TextStyle(fontWeight: FontWeight.w600),
recognizer: TapGestureRecognizer()
..onTap = () => print('GO TO INSTANCE')),
],
))
]),
],
crossAxisAlignment: CrossAxisAlignment.start,
),
Spacer(),
Column(
children: [
IconButton(
onPressed: () => print('POPUP MENU'),
icon: Icon(Icons.more_vert),
)
],
)
]),
),
]);
}
Widget _title() {
return Padding(
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 10),
child: Row(
children: [
Flexible(
child: Text(
'${post.name}',
textAlign: TextAlign.left,
softWrap: true,
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
),
)
]),
Row(children: [
RichText(
overflow: TextOverflow.ellipsis,
text: TextSpan(
style: TextStyle(
fontSize: 13,
color: _theme.textTheme.bodyText1.color),
children: [
TextSpan(
text: 'by',
style: TextStyle(fontWeight: FontWeight.w300)),
TextSpan(
text:
''' ${post.creatorPreferredUsername ?? post.creatorName}''',
style: TextStyle(fontWeight: FontWeight.w600),
recognizer: TapGestureRecognizer()
..onTap = () => print('GO TO USER'),
),
TextSpan(
text:
''' · ${timeago.format(post.published, locale: 'en_short')}'''),
if (linkPostDomain != null)
TextSpan(text: ' · $linkPostDomain'),
if (post.locked) TextSpan(text: ' · 🔒'),
],
))
]),
],
crossAxisAlignment: CrossAxisAlignment.start,
),
),
if (post.thumbnailUrl != null)
InkWell(
onTap: () => print('OPEN LINK'),
child: Stack(children: [
ClipRRect(
borderRadius: BorderRadius.circular(20),
child: CachedNetworkImage(
imageUrl: post.thumbnailUrl,
width: 70,
height: 70,
fit: BoxFit.cover,
errorWidget: (context, url, error) =>
Text(error.toString()),
)),
Positioned(
top: 8,
right: 8,
child: Icon(
Icons.launch,
size: 20,
),
Spacer(),
Column(
children: [
IconButton(
onPressed: () => print('POPUP MENU'),
icon: Icon(Icons.more_vert),
)
]),
],
)
],
),
);
}
]),
),
]);
Widget _title() => Padding(
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 10),
child: Row(
children: [
Flexible(
child: Text(
'${post.name}',
textAlign: TextAlign.left,
softWrap: true,
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
),
),
if (post.thumbnailUrl != null)
InkWell(
onTap: () => print('OPEN LINK'),
child: Stack(children: [
ClipRRect(
borderRadius: BorderRadius.circular(20),
child: CachedNetworkImage(
imageUrl: post.thumbnailUrl,
width: 70,
height: 70,
fit: BoxFit.cover,
errorWidget: (context, url, error) =>
Text(error.toString()),
)),
Positioned(
top: 8,
right: 8,
child: Icon(
Icons.launch,
size: 20,
),
)
]),
)
],
),
);
Widget _content() {
if (post.url == null) return Container();
@ -252,33 +249,32 @@ class PostWidget extends StatelessWidget {
);
}
Widget _actions() {
return Padding(
padding: const EdgeInsets.fromLTRB(10, 5, 10, 5),
child: Row(
children: [
Icon(Icons.comment),
post.numberOfComments == 1
? Text(' 1 comment')
: Text(' ${post.numberOfComments} comments'),
Spacer(),
IconButton(
icon: Icon(Icons.share),
onPressed: () => Share.text('Share post url', post.apId,
'text/plain')), // @TODO: find a way to mark it as url
IconButton(
icon: post.saved == true
? Icon(Icons.bookmark)
: Icon(Icons.bookmark_border),
onPressed: () => print('SAVE')),
IconButton(
icon: Icon(Icons.arrow_upward), onPressed: () => print('UPVOTE')),
Text(post.score.toString()),
IconButton(
icon: Icon(Icons.arrow_downward),
onPressed: () => print('DOWNVOTE')),
],
),
);
}
Widget _actions() => Padding(
padding: const EdgeInsets.fromLTRB(10, 5, 10, 5),
child: Row(
children: [
Icon(Icons.comment),
post.numberOfComments == 1
? Text(' 1 comment')
: Text(' ${post.numberOfComments} comments'),
Spacer(),
IconButton(
icon: Icon(Icons.share),
onPressed: () => Share.text('Share post url', post.apId,
'text/plain')), // @TODO: find a way to mark it as url
IconButton(
icon: post.saved == true
? Icon(Icons.bookmark)
: Icon(Icons.bookmark_border),
onPressed: () => print('SAVE')),
IconButton(
icon: Icon(Icons.arrow_upward),
onPressed: () => print('UPVOTE')),
Text(post.score.toString()),
IconButton(
icon: Icon(Icons.arrow_downward),
onPressed: () => print('DOWNVOTE')),
],
),
);
}