魏少阳 15af50d951 1、完善星锁APP国际化 36种语言。
2、修复国际化问题
2024-10-15 18:32:11 +08:00

114 lines
3.5 KiB
Dart
Executable File

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/titleAppBar.dart';
class MotorPowerPage extends StatefulWidget {
const MotorPowerPage({Key? key}) : super(key: key);
@override
State<MotorPowerPage> createState() => _MotorPowerPageState();
}
class _MotorPowerPageState extends State<MotorPowerPage> {
bool isCheck = false;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: TitleAppBar(
barTitle: '电机功率设置'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
children: [
SizedBox(
height: 40.h,
),
Container(
margin: EdgeInsets.only(left: 40.w),
alignment: Alignment.centerLeft,
child: Text(
'请根据门锁实际情况,请谨慎选择电机功率:'.tr,
style: TextStyle(
fontSize: 24.sp,
color: Colors.black,
fontWeight: FontWeight.w500),
),
),
SizedBox(
height: 40.h,
),
_buildTipsView('${'小功率:'.tr}\n', '耗电少'.tr, isCheck),
SizedBox(
height: 20.h,
),
_buildTipsView('${'大功率'.tr}\n',
'大功率提示'.tr, !isCheck)
],
));
}
Widget _buildTipsView(String titleStr, String subTitle, bool isClick) {
return GestureDetector(
child: Container(
width: ScreenUtil().screenWidth - 40.w,
margin: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 10.h),
padding: EdgeInsets.only(
left: 20.w, top: 30.h, bottom: 30.h, right: 15.w),
decoration: BoxDecoration(
color: isClick
? AppColors.blueViewBgColor
: AppColors.greyBackgroundColor,
borderRadius: BorderRadius.circular(10.0),
),
child: Row(
children: [
if (isClick) Image.asset(
'images/mine/icon_mine_blueSelect.png',
width: 20.w,
height: 14.w,
) else SizedBox(
width: 20.w,
height: 14.w,
),
SizedBox(width: 20.w),
SizedBox(
width: ScreenUtil().screenWidth - 40.w - 20.w*4,
child: _buildRichText(titleStr, subTitle, isClick)
),
],
),
),
onTap: () {
setState(() {
isCheck = !isCheck;
});
},
);
}
Widget _buildRichText(String titleStr, String subTitle, bool isClick) {
//高亮样式
final TextStyle titleStyle = TextStyle(
color: isClick ? AppColors.blueTextTipsColor : Colors.black,
fontSize: 24.sp,
fontWeight: FontWeight.w500);
//默认样式
final TextStyle subTipsStyle = TextStyle(
color: isClick
? AppColors.blueTextTipsColor
: AppColors.placeholderTextColor,
fontSize: 20.sp);
late InlineSpan tipsPreviewSpan = TextSpan(children: [
TextSpan(text: titleStr, style: titleStyle),
TextSpan(text: subTitle, style: subTipsStyle),
]);
return RichText(text: tipsPreviewSpan);
}
}