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