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.
 
 
 
 
 
 

134 lines
4.2 KiB

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/view_widget/border_text.dart';
import 'package:huixiang/view_widget/round_button.dart';
class TextImageWidget extends StatefulWidget {
final src;
final mainText;
final subText;
final leftText;
final rightText;
final width;
final height;
final heightRatioWithWidth;
final Function(bool) open;
TextImageWidget(this.src, this.mainText, this.subText, this.rightText,
this.open, {
this.leftText,
this.width,
this.height,
this.heightRatioWithWidth = 0.9,
});
@override
State<StatefulWidget> createState() {
return _TextImageWidget();
}
}
class _TextImageWidget extends State<TextImageWidget> {
@override
Widget build(BuildContext context) {
return Material(
type: MaterialType.transparency,
child: Center(
child: Container(
width: double.infinity,
margin: EdgeInsets.symmetric(horizontal:26.w),
padding: EdgeInsets.symmetric(vertical: 20.h, horizontal: 24.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: AspectRatio(
aspectRatio: widget.heightRatioWithWidth,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Image.asset(
widget.src,
// width: 0.7867.sw * 0.9,
// height: 0.7867.sw * 0.9 * 0.7,
fit: BoxFit.fill,
),
SizedBox(
height: 20.w,
),
Text(
widget.mainText,
style: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
if(widget.subText != "" && widget.subText != null)
SizedBox(
height: 3.w,
),
if(widget.subText != "" && widget.subText != null)
Text(
widget.subText,
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF727272),
),
),
SizedBox(
height: 20.w,
),
Row(
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
child: InkWell(
onTap: () {
widget.open(false);
},
child: BorderText(
text: S.of(context).quxiao,
textColor: Color(0xFF32A060),
borderWidth: 1.w,
borderColor: Color(0xFF32A060),
padding: EdgeInsets.all(12.w),
fontSize: 16.sp,
fontWeight: FontWeight.bold,
radius: 4,
),
),
flex: 1,
),
SizedBox(
width: 13.w,
),
Expanded(
child: InkWell(
onTap: () {
widget.open(true);
},
child: RoundButton(
text: widget.rightText,
textColor: Colors.white,
padding: EdgeInsets.all(12.w),
fontSize: 16.sp,
backgroup: Color(0xFF32A060),
fontWeight: FontWeight.bold,
radius: 4,
),
),
flex: 1,
),
],
),
],
),
),
),
),
);
}
}