import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:star_lock/flavors.dart'; import '../../../app_settings/app_colors.dart'; import '../entity/lockListInfo_entity.dart'; class LockListGroupView extends StatefulWidget { const LockListGroupView( {Key? key, this.child, this.onTap, this.backgroundColor, this.textStyle, required this.groupItem, required this.typeImgList}) : super(key: key); final Widget? child; final List typeImgList; final Function()? onTap; final GroupList groupItem; final Color? backgroundColor; final TextStyle? textStyle; @override State createState() => _LockListGroupViewState(); } class _LockListGroupViewState extends State { bool _isExpanded = true; final Duration _animationDuration = const Duration(milliseconds: 200); @override Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, children: [ Container( color: widget.backgroundColor ?? Colors.white, height: 80.h, child: Row( children: _buildExpandRowList(), ), ), ClipRect( child: AnimatedAlign( heightFactor: _isExpanded ? 1.0 : 0.0, alignment: Alignment.center, duration: _animationDuration, child: widget.child), ), ], ); } List _buildExpandRowList() { final List widgetList = []; widgetList.add(GestureDetector( child: Container( width: ScreenUtil().screenWidth, color: widget.backgroundColor ?? Colors.white, child: Row( children: [ SizedBox(width: 40.w), F.sw( skyCall: () => Text( widget.groupItem.groupName ?? '', style: widget.textStyle ?? TextStyle( color: AppColors.blackColor, fontSize: 22.sp), ), xhjCall: () => Expanded( child: Text( widget.groupItem.groupName ?? '', maxLines: 2, overflow: TextOverflow.ellipsis, style: widget.textStyle ?? TextStyle( color: AppColors.blackColor, fontSize: 22.sp), ), )), 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; } }