138 lines
4.2 KiB
Dart
Executable File
138 lines
4.2 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';
|
|
import 'motorPower_logic.dart';
|
|
import 'motorPower_state.dart';
|
|
|
|
class MotorPowerPage extends StatefulWidget {
|
|
const MotorPowerPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<MotorPowerPage> createState() => _MotorPowerPageState();
|
|
}
|
|
|
|
class _MotorPowerPageState extends State<MotorPowerPage> {
|
|
final MotorPowerLogic logic = Get.put(MotorPowerLogic());
|
|
final MotorPowerState state = Get.find<MotorPowerLogic>().state;
|
|
|
|
@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,
|
|
),
|
|
Obx(
|
|
() => _buildTipsView(
|
|
'${'小功率:'.tr}\n', '耗电少'.tr, state.motorTorsion.value == 1, () {
|
|
state.motorTorsion.value = 1;
|
|
logic.sendOpenDoorDirection();
|
|
}),
|
|
),
|
|
SizedBox(
|
|
height: 20.h,
|
|
),
|
|
Obx(
|
|
() => _buildTipsView(
|
|
'${'中功率'.tr}\n', '常规使用'.tr, state.motorTorsion.value == 2, () {
|
|
state.motorTorsion.value = 2;
|
|
logic.sendOpenDoorDirection();
|
|
}),
|
|
),
|
|
SizedBox(
|
|
height: 20.h,
|
|
),
|
|
Obx(
|
|
() => _buildTipsView(
|
|
'${'大功率'.tr}\n', '大功率提示'.tr, state.motorTorsion.value == 3, () {
|
|
state.motorTorsion.value = 3;
|
|
logic.sendOpenDoorDirection();
|
|
}),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildTipsView(
|
|
String titleStr, String subTitle, bool isClick, Function() action) {
|
|
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: action,
|
|
);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|