add single check widget

dock interface:voteDetail
hmxc
张萌 4 years ago
parent 2f5bb3cdc5
commit dd1b166dc5

@ -1,8 +1,10 @@
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/manager/voting_detail_model.dart';
import 'package:akuCommunity/pages/manager_func.dart';
import 'package:akuCommunity/widget/bee_divider.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/widget/buttons/bee_check_box.dart';
import 'package:akuCommunity/widget/buttons/bee_single_check.dart';
import 'package:flutter/material.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
@ -18,6 +20,9 @@ class VotingDetailPage extends StatefulWidget {
class _VotingDetailPageState extends State<VotingDetailPage> {
VotingDetailModel _model;
EasyRefreshController _refreshController;
bool _isOnload = true;
// List<int> _select = [];
int _selectId;
@override
void initState() {
super.initState();
@ -33,17 +38,40 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
Widget _buildVoteCard(AppVoteCandidateVos model) {
return Container(
padding: EdgeInsets.symmetric(vertical: 40.w),
constraints: BoxConstraints(maxHeight: 230.w),
child: Row(
children: [
GestureDetector(
onTap: () {},
child: Material(
color: Colors.transparent,
child: SizedBox(
width: 88.w,
height: 150.w,
child: BeeCheckBox(isRound: true)),
),
Container(
alignment: Alignment.center,
width: 88.w,
height: 150.w,
//
// child: BeeCheckBox(
// isRound: true,
// size: 30.w,
// onChange: (value) {
// if (value) {
// if (!_select.contains(model.id)) {
// _select.add(model.id);
// }
// } else {
// _select.remove(model.id);
// }
// },
// ),
//
//
//
child: GestureDetector(
onTap: () {
_selectId = model.id;
setState(() {});
},
child: BeeSingleCheck(
value: model.id,
groupValue: _selectId,
),
).material(color: Colors.transparent),
),
ClipRRect(
borderRadius: BorderRadius.circular(4.w),
@ -55,60 +83,81 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
'测试'.text.black.size(32.sp).make(),
10.w.heightBox,
// '测试'.text.black.size(32.sp).make(),
// 10.w.heightBox,
model.name.text.black.size(32.sp).make()
],
),
Spacer()
Spacer(),
],
),
);
}
Widget _emptyWidget() {
return Container();
}
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '活动详情',
body: ListView(
padding: EdgeInsets.symmetric(
horizontal: 32.w,
vertical: 26.w,
),
children: [
_model.title.text.black.size(32.sp).bold.maxLines(2).make(),
44.w.heightBox,
SizedBox(
width: double.infinity,
height: 228.w,
child: ClipRRect(
borderRadius: BorderRadius.circular(8.w),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_LOGO_PNG,
image: API.image(_model.imgUrls.first.url)),
),
),
44.w.heightBox,
_model.content.text.black.size(28.sp).make(),
44.w.heightBox,
Container(
padding: EdgeInsets.fromLTRB(32.w, 50.w, 32.w, 0),
decoration: BoxDecoration(
color: Color(0xFFD9D9D9),
borderRadius: BorderRadius.circular(8.w),
),
child: Column(
children: [
'测试标题'
.text
.color(Color(0xFF999999))
.size(32.sp)
.make(), //TODO:
26.w.heightBox,
],
),
)
],
body: EasyRefresh(
firstRefresh: true,
controller: _refreshController,
onRefresh: () async {
await ManagerFunc.voteDetail(widget.id)
.then((value) => _model = value);
_isOnload = false;
},
header: MaterialHeader(),
child: _isOnload
? _emptyWidget()
: ListView(
padding: EdgeInsets.symmetric(
horizontal: 32.w,
vertical: 26.w,
),
children: [
_model.title.text.black.size(32.sp).bold.maxLines(2).make(),
44.w.heightBox,
SizedBox(
width: double.infinity,
height: 228.w,
child: ClipRRect(
borderRadius: BorderRadius.circular(8.w),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_LOGO_PNG,
image: API.image(_model.imgUrls.first.url)),
),
),
44.w.heightBox,
_model.content.text.black.size(28.sp).make(),
44.w.heightBox,
Container(
padding: EdgeInsets.fromLTRB(32.w, 50.w, 32.w, 0),
decoration: BoxDecoration(
color: Color(0xFFD9D9D9),
borderRadius: BorderRadius.circular(8.w),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// '测试标题'
// .text
// .color(Color(0xFF999999))
// .size(32.sp)
// .make(), //TODO:
// 26.w.heightBox,
..._model.appVoteCandidateVos
.map((e) => _buildVoteCard(e))
.toList()
.sepWidget(separate: BeeDivider.horizontal()),
],
),
)
],
),
),
);
}

@ -1,6 +1,7 @@
// Package imports:
import 'package:akuCommunity/model/manager/article_QR_code_model.dart';
import 'package:akuCommunity/model/manager/moving_company_model.dart';
import 'package:akuCommunity/model/manager/voting_detail_model.dart';
import 'package:dio/dio.dart';
import 'package:flustars/flustars.dart';
@ -165,12 +166,12 @@ class ManagerFunc {
return baseModel.data;
}
static Future<BaseModel> voteDetail(int id) async {
static Future<VotingDetailModel> voteDetail(int id) async {
BaseModel baseModel = await NetUtil().get(API.manager.voteDetail,
params: {
'voteId': 1,
},
showMessage: false);
return baseModel.data;
return VotingDetailModel.fromJson(baseModel.data);
}
}

@ -0,0 +1,44 @@
import 'package:akuCommunity/base/base_style.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:akuCommunity/utils/headers.dart';
class BeeSingleCheck<T> extends StatefulWidget {
final T value;
final T groupValue;
BeeSingleCheck({Key key, this.value, this.groupValue}) : super(key: key);
@override
_BeeSingleCheckState createState() => _BeeSingleCheckState();
}
class _BeeSingleCheckState extends State<BeeSingleCheck> {
bool get _selected => widget.value == widget.groupValue;
@override
Widget build(BuildContext context) {
return AnimatedContainer(
height: 40.w,
width: 40.w,
decoration: BoxDecoration(
border: Border.all(
color: _selected ? kPrimaryColor : Color(0xFF979797),
width: 3.w,
),
borderRadius: BorderRadius.circular(20.w),
),
duration: Duration(milliseconds: 300),
curve: Curves.easeInOutCubic,
alignment: Alignment.center,
child: AnimatedOpacity(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOutCubic,
opacity: _selected ? 1 : 0,
child: Icon(
CupertinoIcons.chevron_up,
color: Colors.white,
size: 24.w,
),
),
);
}
}
Loading…
Cancel
Save