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.
158 lines
5.1 KiB
158 lines
5.1 KiB
4 years ago
|
import 'package:akuCommunity/base/base_style.dart';
|
||
|
import 'package:akuCommunity/constants/api.dart';
|
||
|
import 'package:akuCommunity/model/manager/questinnaire_model.dart';
|
||
|
import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart';
|
||
4 years ago
|
import 'package:akuCommunity/ui/manager/questionnaire/questionnaire_detail_page.dart';
|
||
4 years ago
|
import 'package:akuCommunity/widget/bee_scaffold.dart';
|
||
|
import 'package:akuCommunity/widget/others/stack_avatar.dart';
|
||
4 years ago
|
import 'package:flutter/material.dart';
|
||
4 years ago
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||
4 years ago
|
import 'package:akuCommunity/utils/headers.dart';
|
||
4 years ago
|
|
||
|
class QuestionnairePage extends StatefulWidget {
|
||
|
QuestionnairePage({Key key}) : super(key: key);
|
||
|
|
||
|
@override
|
||
|
_QuestionnairePageState createState() => _QuestionnairePageState();
|
||
|
}
|
||
|
|
||
|
class _QuestionnairePageState extends State<QuestionnairePage> {
|
||
4 years ago
|
EasyRefreshController _easyRefreshController;
|
||
4 years ago
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
}
|
||
|
|
||
4 years ago
|
String _getButtonText(int status) {
|
||
|
switch (status) {
|
||
|
case 1:
|
||
|
case 2:
|
||
|
return '去投票';
|
||
|
case 3:
|
||
|
return '已结束';
|
||
|
case 4:
|
||
|
return '已投票';
|
||
|
default:
|
||
|
return '';
|
||
|
}
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
Widget _buildCard(QuestionnaireModel model) {
|
||
|
return Container(
|
||
|
decoration: BoxDecoration(
|
||
|
borderRadius: BorderRadius.circular(8.w),
|
||
|
color: kForeGroundColor,
|
||
|
),
|
||
|
width: double.infinity,
|
||
|
// height: 236.w,
|
||
|
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 12.w),
|
||
|
child: Column(
|
||
|
mainAxisSize: MainAxisSize.min,
|
||
|
children: [
|
||
|
Row(
|
||
|
children: [
|
||
|
Container(
|
||
|
decoration:
|
||
|
BoxDecoration(borderRadius: BorderRadius.circular(8.w)),
|
||
|
width: 160.w,
|
||
|
height: 120.w,
|
||
|
child: ClipRRect(
|
||
|
child: FadeInImage.assetNetwork(
|
||
|
placeholder: R.ASSETS_IMAGES_LOGO_PNG,
|
||
|
image: API.image(model.imgUrls.first.url)),
|
||
|
),
|
||
|
),
|
||
|
20.w.widthBox,
|
||
|
Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
model.title.text.black.size(28.sp).make(),
|
||
|
6.w.heightBox,
|
||
|
model.description.text
|
||
|
.color(ktextSubColor)
|
||
|
.size(28.sp)
|
||
|
.maxLines(1)
|
||
|
.overflow(TextOverflow.ellipsis)
|
||
|
.make(),
|
||
|
6.w.heightBox,
|
||
|
RichText(
|
||
|
text: TextSpan(
|
||
|
text: '参与时间:',
|
||
|
style: TextStyle(
|
||
|
color: ktextSubColor,
|
||
|
fontSize: 24.sp,
|
||
|
),
|
||
|
children: [
|
||
|
TextSpan(
|
||
|
style: TextStyle(
|
||
|
color: ktextPrimary,
|
||
|
fontSize: 24.sp,
|
||
|
),
|
||
|
text: model.beginDate + '至' + model.endDate,
|
||
|
),
|
||
|
])),
|
||
|
],
|
||
|
).expand()
|
||
|
],
|
||
|
),
|
||
|
40.w.heightBox,
|
||
|
Row(
|
||
|
children: [
|
||
|
StackAvatar(
|
||
|
avatars: model.headImgURls.map((e) => e.url).toList()),
|
||
|
26.w.widthBox,
|
||
|
'${model.answerNum}人已参加'.text.black.size(20.sp).make(),
|
||
|
Spacer(),
|
||
|
MaterialButton(
|
||
|
shape: RoundedRectangleBorder(
|
||
|
borderRadius: BorderRadius.circular(22.w)),
|
||
|
color: model.status == 3 ? kDarkSubColor : kPrimaryColor,
|
||
|
minWidth: 120.w,
|
||
|
height: 44.w,
|
||
|
// padding:
|
||
|
// EdgeInsets.symmetric(horizontal: 30.w, vertical: 8.w),
|
||
|
elevation: 0,
|
||
4 years ago
|
onPressed: () {
|
||
|
QuestionnaireDetailPage(id: model.id,).to();
|
||
|
},
|
||
4 years ago
|
child: (_getButtonText(model.status))
|
||
|
.text
|
||
|
.black
|
||
|
.size(20.sp)
|
||
|
.bold
|
||
|
.make(),
|
||
|
),
|
||
|
],
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
);
|
||
4 years ago
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
4 years ago
|
return BeeScaffold(
|
||
|
title: '问卷调查',
|
||
4 years ago
|
body: BeeListView(
|
||
|
path: API.manager.questionnaireList,
|
||
|
controller: _easyRefreshController,
|
||
|
convert: (model) {
|
||
|
return model.tableList
|
||
|
.map((e) => QuestionnaireModel.fromJson(e))
|
||
|
.toList();
|
||
|
},
|
||
|
builder: (items) {
|
||
|
return ListView.separated(
|
||
|
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w),
|
||
|
itemBuilder: (context, index) {
|
||
|
return _buildCard(items[index]);
|
||
|
},
|
||
|
separatorBuilder: (_, __) {
|
||
|
return 24.w.heightBox;
|
||
|
},
|
||
|
itemCount: items.length);
|
||
|
}),
|
||
4 years ago
|
);
|
||
|
}
|
||
|
}
|