156 lines
4.2 KiB
Dart
Executable File
156 lines
4.2 KiB
Dart
Executable File
|
|
import 'dart:core';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:star_lock/app_settings/app_colors.dart';
|
|
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
|
|
|
class ExpandedListTile extends StatefulWidget {
|
|
const ExpandedListTile(
|
|
{required this.isShowBtn,
|
|
required this.groupItem,
|
|
required this.typeImgList,
|
|
this.isCheck = false,
|
|
this.child,
|
|
this.onTap,
|
|
Key? key})
|
|
: super(key: key);
|
|
|
|
final Widget? child;
|
|
final List typeImgList;
|
|
final Function()? onTap;
|
|
final GroupListItem groupItem;
|
|
final bool isShowBtn;
|
|
final bool isCheck;
|
|
@override
|
|
_ExpandedListTileState createState() => _ExpandedListTileState();
|
|
}
|
|
|
|
class _ExpandedListTileState extends State<ExpandedListTile> {
|
|
bool _isExpanded = false;
|
|
final Duration _animationDuration = const Duration(milliseconds: 200);
|
|
bool _isCheck = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_isCheck = widget.isCheck; // Initialize _isCheck with the value from the widget
|
|
}
|
|
|
|
@override
|
|
void didUpdateWidget(ExpandedListTile oldWidget) {
|
|
super.didUpdateWidget(oldWidget);
|
|
_isCheck = widget.isCheck; // Initialize _isCheck with the value from the widget
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
color: Colors.white,
|
|
height: 80.h,
|
|
width: 1.sw,
|
|
child: Row(
|
|
children: _buildExpandRowList(),
|
|
),
|
|
),
|
|
ClipRect(
|
|
child: AnimatedAlign(
|
|
heightFactor: _isExpanded ? 1.0 : 0.0,
|
|
alignment: Alignment.center,
|
|
duration: _animationDuration,
|
|
child: widget.child),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
List<Widget> _buildExpandRowList() {
|
|
List<Widget> widgetList = [];
|
|
|
|
if(widget.isShowBtn){
|
|
widgetList.add(GestureDetector(
|
|
child: Container(
|
|
color: Colors.white,
|
|
width: 80.w,
|
|
child: Row(
|
|
children: [
|
|
SizedBox(
|
|
width: 30.w,
|
|
),
|
|
Image.asset(
|
|
_isCheck
|
|
? 'images/icon_round_select.png'
|
|
: 'images/icon_round_unSelect.png',
|
|
width: 30.w,
|
|
height: 30.w,
|
|
color: widget.groupItem.isVip ? AppColors.mainColor : Colors.grey,
|
|
),
|
|
SizedBox(
|
|
width: 20.w,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
if (widget.groupItem.isVip == false) {
|
|
return;
|
|
}
|
|
//点击左侧是否勾选按钮
|
|
setState(() {
|
|
_isCheck = !_isCheck;
|
|
widget.groupItem.isChecked = _isCheck;
|
|
});
|
|
widget.onTap?.call();
|
|
},
|
|
));
|
|
}
|
|
|
|
widgetList.add(GestureDetector(
|
|
child: Container(
|
|
width: 1.sw - (widget.isShowBtn ? 80.w : 0),
|
|
color: Colors.white,
|
|
child: Row(
|
|
children: [
|
|
// Image.asset(
|
|
// widget.imgName,
|
|
// width: 36.w,
|
|
// height: 36.w,
|
|
// ),
|
|
SizedBox(
|
|
width: widget.isShowBtn ? 10.w :30.w,
|
|
),
|
|
Expanded(
|
|
child: Text(
|
|
widget.groupItem.keyGroupName ?? '',
|
|
style: TextStyle(color: AppColors.blackColor, fontSize: 22.sp),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
SizedBox(width: 10.w),
|
|
AnimatedRotation(
|
|
turns: _isExpanded ? -0.5 : 0,
|
|
duration: _animationDuration,
|
|
child: const Icon(Icons.keyboard_arrow_down),
|
|
),
|
|
SizedBox(
|
|
width: 30.w,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
//点击右侧上拉下拉按钮
|
|
setState(() {
|
|
_isExpanded = !_isExpanded;
|
|
});
|
|
},
|
|
));
|
|
return widgetList;
|
|
}
|
|
}
|