99 lines
3.2 KiB
Dart
99 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import '../../constants/color_constant.dart';
|
|
import '../../utils/helper_function.dart';
|
|
|
|
class EnhancedFilePickerTile extends StatelessWidget {
|
|
final String hintText;
|
|
final String? fileName;
|
|
final IconData icon;
|
|
final VoidCallback onTap;
|
|
final VoidCallback? onClear;
|
|
final Color? fillColor;
|
|
final Color? borderColor;
|
|
final double? height;
|
|
|
|
const EnhancedFilePickerTile({
|
|
super.key,
|
|
required this.hintText,
|
|
this.fileName,
|
|
required this.icon,
|
|
required this.onTap,
|
|
this.onClear,
|
|
this.fillColor,
|
|
this.borderColor,
|
|
this.height,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
bool hasFileName = fileName != null && fileName!.isNotEmpty;
|
|
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
height: hasFileName ? height : 60.h,
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.h),
|
|
decoration: BoxDecoration(
|
|
color: fillColor ?? textFieldFillColor,
|
|
borderRadius: BorderRadius.circular(10.r),
|
|
border: Border.all(color: borderColor ?? lightGreyColor, width: 1),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child:
|
|
hasFileName
|
|
? Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
hintText,
|
|
style: TextStyle(
|
|
fontSize: (isTablet ? 11.sp : 14.sp),
|
|
fontWeight: FontWeight.w500,
|
|
color: greyTextColor1,
|
|
),
|
|
),
|
|
SizedBox(height: 4.h),
|
|
Text(
|
|
fileName!,
|
|
style: TextStyle(
|
|
fontSize: isTablet ? 14.sp : 15.sp,
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.black,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
)
|
|
: Text(
|
|
hintText,
|
|
style: TextStyle(
|
|
fontSize: isTablet ? 15.sp : 16.sp,
|
|
fontWeight: FontWeight.w500,
|
|
color: greyTextColor1,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
if (hasFileName && onClear != null)
|
|
GestureDetector(
|
|
onTap: onClear,
|
|
child: Icon(
|
|
Icons.close,
|
|
color: greyTextColor1,
|
|
size: isTablet ? 18.sp : 18.sp,
|
|
),
|
|
)
|
|
else
|
|
Icon(icon, color: greyTextColor1, size: isTablet ? 20.sp : 18.sp),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|