You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
10 KiB

// Dart imports:
import 'dart:ui';
// Flutter imports:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
4 years ago
import 'package:get/get.dart';
4 years ago
import 'package:velocity_x/velocity_x.dart';
// Project imports:
import 'package:akuCommunity/base/base_style.dart';
4 years ago
import 'package:akuCommunity/extensions/num_ext.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/expandable_text.dart';
import 'package:akuCommunity/widget/views/horizontal_image_view.dart';
class TrendCard extends StatefulWidget {
final String name;
final String content;
final List<String> imageUrl;
final bool isLike;
final Image avatar;
4 years ago
TrendCard(
{Key key,
this.name,
this.content,
this.imageUrl,
this.isLike,
this.avatar})
: super(key: key);
@override
_TrendCardState createState() => _TrendCardState();
}
class _TrendCardState extends State<TrendCard> {
bool _isLike;
@override
4 years ago
void initState() {
super.initState();
4 years ago
_isLike = widget.isLike ?? false;
}
4 years ago
TextStyle _textStyleName() {
return TextStyle(
4 years ago
fontSize: 36.sp,
color: Color(0xff333333),
);
}
TextStyle _textStyleContent() {
return TextStyle(
4 years ago
fontSize: 32.sp,
color: Color(0xff333333),
);
}
TextStyle _textStyleTag() {
return TextStyle(
4 years ago
fontSize: 28.sp,
color: Color(0xff999999),
);
}
void _showDeletDialog() {
showCupertinoDialog(
context: context,
builder: (context) {
return CupertinoAlertDialog(
title: '你确定删除吗?'.text.black.size(34.sp).isIntrinsic.make(),
actions: <Widget>[
CupertinoDialogAction(
child: '取消'.text.black.size(34.sp).isIntrinsic.make(),
onPressed: () {
Get.back();
},
),
CupertinoDialogAction(
child: '确定'
.text
.color(Color(0xFFFF8200))
.size(34.sp)
.isIntrinsic
.make(),
onPressed: () {
Get.back();
},
),
],
);
});
}
4 years ago
Widget _columnCard(String name, String content, Image avatar) {
return Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
children: [
Container(
width: 86.w,
height: 86.w,
child: avatar,
),
4 years ago
SizedBox(width: 9.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
4 years ago
padding: EdgeInsets.only(left: 10.w),
child: Text(
name,
style: _textStyleName(),
),
),
4 years ago
SizedBox(height: 6.w),
Container(
4 years ago
padding: EdgeInsets.only(left: 14.w),
child: ExpandableText(
text: content,
maxLines: 2,
style: _textStyleContent(),
expand: false,
),
),
],
),
],
),
4 years ago
SizedBox(height: 20.w),
Padding(
4 years ago
padding: EdgeInsets.only(left: 95.w),
child: Column(
children: [
HorizontalImageView(widget.imageUrl),
4 years ago
SizedBox(height: 20.w),
Stack(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
'1分钟前',
style: _textStyleTag(),
),
40.wb,
InkWell(
onTap: () {
_showDeletDialog();
},
child: '删除'.text.black.size(28.sp).make()),
],
),
],
),
],
),
),
],
),
Positioned(
right: 0,
4 years ago
bottom: 0,
child: Builder(
builder: (context) {
return InkWell(
onTap: () => BotToast.showAttachedWidget(
attachedBuilder: (CancelFunc cancelFunc) {
return Material(
child: Container(
decoration: BoxDecoration(
color: Color(0xFFD8D8D8),
borderRadius: BorderRadius.circular(8.w),
),
padding: EdgeInsets.symmetric(
vertical: 15.w, horizontal: 30.w),
width: 363.w,
height: 78.w,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: InkWell(
onTap: () {
_isLike = !_isLike;
cancelFunc();
setState(() {});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
_isLike
? AntDesign.heart
: AntDesign.hearto,
color: _isLike
? Color(0xffff6666)
: Colors.black,
size: 32.w,
),
10.wb,
''
.text
.color(ktextPrimary)
.size(28.sp)
.make(),
],
),
),
),
Expanded(
child: VerticalDivider(
width: 0,
thickness: 1.w,
color: Color(0xFF979797),
),
),
Expanded(
child: InkWell(
onTap: () {},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
CupertinoIcons.ellipses_bubble,
color: Colors.black,
size: 32.w,
),
10.wb,
'评论'
.text
.color(ktextPrimary)
.size(28.sp)
.make(),
],
),
),
),
],
),
),
);
},
preferDirection: PreferDirection.rightCenter,
targetContext: context,
),
child: Icon(
MaterialIcons.more,
color: Color(0xffd8d8d8),
),
);
},
),
),
Positioned(
top: 0,
4 years ago
right: 0,
child: PopupMenuButton<int>(
onSelected: (value) {
switch (value) {
case 0:
BotToast.showText(text: '举报成功');
break;
default:
}
},
4 years ago
padding: EdgeInsets.zero,
icon: Icon(
CupertinoIcons.chevron_down,
size: 25.w,
),
4 years ago
itemBuilder: (context) {
return [
PopupMenuItem(
value: 0,
4 years ago
child: Container(
width: 150.w,
height: 50.w,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
CupertinoIcons.exclamationmark_triangle,
size: 50.w,
),
10.wb,
'举报'.text.black.size(30.sp).make()
],
),
),
)
];
},
),
),
],
);
}
@override
Widget build(BuildContext context) {
return Container(
4 years ago
decoration: BoxDecoration(
color: Colors.white,
border: Border(
bottom: BorderSide(
width: 0.5, //宽度
color: Color(0xffe5e5e5), //边框颜色
),
),
),
4 years ago
padding: EdgeInsets.only(
top: 46.w,
left: 32.w,
bottom: 22.w,
right: 32.w,
),
child: _columnCard(widget.name, widget.content, widget.avatar));
}
}