You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.1 KiB

4 years ago
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
4 years ago
import 'package:flutter_screenutil/flutter_screenutil.dart';
4 years ago
class ItemTitle extends StatelessWidget {
final String text;
final String imgPath;
final int moreType;
final String moreText;
final List<DropdownMenuItem<String>> items;
ItemTitle(
4 years ago
{this.text,
this.imgPath,
4 years ago
this.moreText = "",
this.moreType = 0,
this.items,
this.onChanged,
this.onTap});
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(left: 16.w, right: 17.w,),
4 years ago
alignment: Alignment.center,
4 years ago
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
4 years ago
mainAxisSize: MainAxisSize.min,
4 years ago
children: [
Text(
text,
4 years ago
textAlign: TextAlign.center,
4 years ago
style: TextStyle(
color: Colors.black,
4 years ago
fontSize: 16.sp,
4 years ago
fontWeight: FontWeight.bold,
),
),
SizedBox(
4 years ago
width: 8.w,
4 years ago
),
Image.asset(
imgPath,
4 years ago
width: 24.w,
height: 24.h,
4 years ago
),
],
),
if (moreText != "") buildMore()
],
),
);
}
final GestureTapCallback onTap;
final Function(String) onChanged;
Widget buildMore() {
return moreType == 0
? GestureDetector(
onTap: onTap,
child: Container(
4 years ago
padding:
EdgeInsets.only(left: 8.w, right: 8.w, top: 2.h, bottom: 2.h),
4 years ago
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(25),
offset: Offset(0, 1),
blurRadius: 12,
spreadRadius: 0)
],
borderRadius: BorderRadius.all(Radius.circular(2))),
child: Row(
children: [
Text(
moreText,
4 years ago
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w400
4 years ago
),
4 years ago
),
Icon(
moreType == 0
? Icons.keyboard_arrow_right
: (Icons.keyboard_arrow_down),
size: 16,
)
],
),
),
)
: Container(
4 years ago
padding: EdgeInsets.only(left: 10.w, right: 10.w),
4 years ago
child: DropdownButton(
items: items,
value: moreText,
onChanged: onChanged,
),
);
}
}