|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter/widgets.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/article.dart'; |
|
|
|
|
import 'package:huixiang/utils/flutter_utils.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
@ -22,6 +21,8 @@ class HotArticleItem extends StatefulWidget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class _HotArticleItem extends State<HotArticleItem> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return GestureDetector( |
|
|
|
@ -41,7 +42,7 @@ class _HotArticleItem extends State<HotArticleItem> {
|
|
|
|
|
|
|
|
|
|
Widget hotItem(BuildContext context) { |
|
|
|
|
return Container( |
|
|
|
|
padding: EdgeInsets.all((widget.isHot == null || !widget.isHot) ? 8 : 0), |
|
|
|
|
padding: EdgeInsets.all((widget.isHot == null || !widget.isHot) ? 4 : 0), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Colors.white, |
|
|
|
|
boxShadow: [ |
|
|
|
@ -55,8 +56,90 @@ class _HotArticleItem extends State<HotArticleItem> {
|
|
|
|
|
borderRadius: BorderRadius.circular(4), |
|
|
|
|
), |
|
|
|
|
child: (widget.isHot == null || !widget.isHot) |
|
|
|
|
? Row( |
|
|
|
|
? Column( |
|
|
|
|
children: [ |
|
|
|
|
Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
height: 44, |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
MImage( |
|
|
|
|
(widget.article != null && |
|
|
|
|
widget.article.author != null) |
|
|
|
|
? widget.article.author.avatar |
|
|
|
|
: "", |
|
|
|
|
width: 44, |
|
|
|
|
height: 44, |
|
|
|
|
isCircle: true, |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
errorSrc: "assets/image/default_1.png", |
|
|
|
|
fadeSrc: "assets/image/default_1.png", |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 8, |
|
|
|
|
), |
|
|
|
|
Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
(widget.article != null && |
|
|
|
|
widget.article.author != null) |
|
|
|
|
? widget.article.author.name |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Color(0xFF1A1A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
widget.article != null |
|
|
|
|
? (widget.article.createTime.split(" ")[0]) |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFF808080), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: (){ |
|
|
|
|
}, |
|
|
|
|
child: RoundButton( |
|
|
|
|
padding: EdgeInsets.symmetric( |
|
|
|
|
horizontal: 8, |
|
|
|
|
vertical: 3, |
|
|
|
|
), |
|
|
|
|
backgroup: Color(0xFF32A060), |
|
|
|
|
textColor: Colors.white , |
|
|
|
|
text: "关注", |
|
|
|
|
radius: 20, |
|
|
|
|
icons: Icon( |
|
|
|
|
Icons.check, |
|
|
|
|
color: Color(0xFF808080), |
|
|
|
|
size: 14, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
Expanded(child:Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: Container( |
|
|
|
|
margin: EdgeInsets.only(left: 12.w), |
|
|
|
|
child: articleTextTow(context), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Visibility( |
|
|
|
|
visible: widget.article != null && |
|
|
|
|
widget.article.coverImg != null && |
|
|
|
@ -85,12 +168,8 @@ class _HotArticleItem extends State<HotArticleItem> {
|
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Container( |
|
|
|
|
margin: EdgeInsets.only(left: 8.w), |
|
|
|
|
child: articleText(context), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
)), |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
: Column( |
|
|
|
@ -113,7 +192,7 @@ class _HotArticleItem extends State<HotArticleItem> {
|
|
|
|
|
maxLines: 1, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
color: Colors.black, |
|
|
|
|
), |
|
|
|
@ -140,7 +219,7 @@ class _HotArticleItem extends State<HotArticleItem> {
|
|
|
|
|
maxLines: 1, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
color: Colors.black, |
|
|
|
|
), |
|
|
|
@ -158,7 +237,7 @@ class _HotArticleItem extends State<HotArticleItem> {
|
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: FontWeight.w400, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFF353535), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
@ -174,49 +253,50 @@ class _HotArticleItem extends State<HotArticleItem> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
S.of(context).zuozhe((widget.article != null && |
|
|
|
|
// S.of(context).zuozhe(), |
|
|
|
|
(widget.article != null && |
|
|
|
|
widget.article.author != null) |
|
|
|
|
? widget.article.author.name |
|
|
|
|
: ""), |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
fontWeight: FontWeight.w400, |
|
|
|
|
color: Color(0xFFB2B2B2), |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Color(0xFF1A1A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 12.w, |
|
|
|
|
width: 14.w, |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
alignment: Alignment.topRight, |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Image.asset( |
|
|
|
|
"assets/image/icon_likes.png", |
|
|
|
|
"assets/image/browse.png", |
|
|
|
|
width: 16.w, |
|
|
|
|
height: 16.h, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
(widget.article != null) |
|
|
|
|
? "${widget.article.likes}" |
|
|
|
|
? "${widget.article.viewers}" |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
color: Color(0xFFB2B2B2), |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
color: Color(0xFF1A1A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 12.w, |
|
|
|
|
width: 14.w, |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
alignment: Alignment.topRight, |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Image.asset( |
|
|
|
|
"assets/image/icon_views.png", |
|
|
|
|
"assets/image/leaving_message.png", |
|
|
|
|
width: 16.w, |
|
|
|
|
height: 16.h, |
|
|
|
|
), |
|
|
|
@ -225,8 +305,32 @@ class _HotArticleItem extends State<HotArticleItem> {
|
|
|
|
|
? "${widget.article.viewers}" |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
color: Color(0xFFB2B2B2), |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
color: Color(0xFF1A1A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 14.w, |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
alignment: Alignment.topRight, |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Image.asset( |
|
|
|
|
"assets/image/follow.png", |
|
|
|
|
width: 16.w, |
|
|
|
|
height: 16.h, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
(widget.article != null) |
|
|
|
|
? "${widget.article.likes}" |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
color: Color(0xFF1A1A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
@ -242,11 +346,11 @@ class _HotArticleItem extends State<HotArticleItem> {
|
|
|
|
|
? (widget.article.createTime.split(" ")[0]) |
|
|
|
|
: "", |
|
|
|
|
textStyle: TextStyle( |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
fontWeight: FontWeight.w400, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFFB2B2B2), |
|
|
|
|
), |
|
|
|
|
leftIcon: Icons.access_time_rounded, |
|
|
|
|
// leftIcon: Icons.access_time_rounded, |
|
|
|
|
iconSize: 10, |
|
|
|
|
iconColor: Color(0xFFB2B2B2), |
|
|
|
|
), |
|
|
|
@ -256,6 +360,159 @@ class _HotArticleItem extends State<HotArticleItem> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget articleTextTow(context) { |
|
|
|
|
return Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
(widget.isHot == null || !widget.isHot) |
|
|
|
|
? Text( |
|
|
|
|
widget.article != null ? widget.article.mainTitle : "", |
|
|
|
|
maxLines: 1, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
color: Colors.black, |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
: Row( |
|
|
|
|
children: [ |
|
|
|
|
RoundButton( |
|
|
|
|
text: "HOT", |
|
|
|
|
textColor: Colors.white, |
|
|
|
|
backgroup: Color(0xFFFF441A), |
|
|
|
|
radius: 2, |
|
|
|
|
fontSize: 10.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
padding: EdgeInsets.all(2), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 6.w, |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
widget.article != null |
|
|
|
|
? widget.article.mainTitle |
|
|
|
|
: "", |
|
|
|
|
maxLines: 1, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
color: Colors.black, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 4.h, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
widget.article != null ? (widget.article.viceTitle ?? "") : "", |
|
|
|
|
maxLines: AppUtils.textScale(context) > 1.05 ? 1 : 2, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Color(0xFF353535), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
alignment: Alignment.topRight, |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Image.asset( |
|
|
|
|
"assets/image/browse.png", |
|
|
|
|
width: 16.w, |
|
|
|
|
height: 16.h, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
(widget.article != null) |
|
|
|
|
? "${widget.article.viewers}" |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
color: Color(0xFF1A1A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 32.w, |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
alignment: Alignment.topRight, |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Image.asset( |
|
|
|
|
"assets/image/leaving_message.png", |
|
|
|
|
width: 16.w, |
|
|
|
|
height: 16.h, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
(widget.article != null) |
|
|
|
|
? "${widget.article.viewers}" |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
color: Color(0xFF1A1A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 32.w, |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
alignment: Alignment.topRight, |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Image.asset( |
|
|
|
|
"assets/image/follow.png", |
|
|
|
|
width: 16.w, |
|
|
|
|
height: 16.h, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
(widget.article != null) |
|
|
|
|
? "${widget.article.likes}" |
|
|
|
|
: "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
color: Color(0xFF1A1A1A), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<Widget> articleContent(context) { |
|
|
|
|
return [ |
|
|
|
|
Expanded( |
|
|
|
|