app-starlock/lib/mine/mineSet/google_home/google_home_page.dart

125 lines
4.0 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/mineSet/google_home/google_home_logic.dart';
import 'package:star_lock/mine/mineSet/google_home/google_home_state.dart';
import 'package:star_lock/tools/commonItem.dart';
import 'package:star_lock/tools/showTipView.dart';
import 'package:star_lock/tools/submitBtn.dart';
import '../../../../app_settings/app_colors.dart';
import '../../../../tools/titleAppBar.dart';
class GoogleHomePage extends StatefulWidget {
const GoogleHomePage({Key? key}) : super(key: key);
@override
State<GoogleHomePage> createState() => _GoogleHomePageState();
}
class _GoogleHomePageState extends State<GoogleHomePage> {
final EdgeInsets _contentPadding =
EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.h);
final GoogleHomeLogic logic = Get.put(GoogleHomeLogic());
final GoogleHomeState state = Get.find<GoogleHomeLogic>().state;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
resizeToAvoidBottomInset: false,
appBar: TitleAppBar(
barTitle: 'Google Home'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor,
),
body: SingleChildScrollView(
child: Column(
children: [
_buildTopWidget(),
SizedBox(height: 20.h),
Obx(_buildBottomWidget),
],
),
),
);
}
Widget _buildTopWidget() {
return Column(
children: [
Obx(() => CommonItem(
leftTitel: 'Action name'.tr,
rightTitle: state.googleHomeData.value.actionName ?? '',
)),
SizedBox(
height: 20.h,
),
Obx(() => SubmitBtn(
btnName: state.isOpenedText.value,
onClick: () {
// ShowTipView().showTipWithInputDialog(
// contentText: '',
// sureClick: (String value) {
// Get.back();
// },
// sureText: '确定',
// title: '设置安全码');
logic.updateUserInfoWithGoogle();
},
)),
SizedBox(
height: 20.h,
),
],
);
}
Widget _buildBottomWidget() {
final String instructions = '1.用智能锁APP添加锁和网关\n\n'
'2.在APP里开启锁的远程开锁功能这个功能默认是关闭的。如果没有这个选项则锁不支持Google Home\n\n'
'3.安装Google Home APP点击左上角的“+”按钮\n\n'
'4.在设置页面选择“与Google协同工作”\n\n'
'5.搜索“${state.googleHomeData.value.actionName ?? ''}并用智能锁APP的账号和密码进行授权';
return Container(
color: Colors.white,
width: ScreenUtil().screenWidth,
padding: _contentPadding,
child: Column(
children: [
_buildInfoSection(
'支持的语言'.tr, state.googleHomeData.value.langs?.join('') ?? ''),
SizedBox(height: 20.h),
_buildInfoSection('操作流程'.tr, instructions),
],
),
);
}
Widget _buildInfoSection(String title, String content) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(Icons.radio_button_checked_outlined,
color: AppColors.mainColor),
SizedBox(width: 6.w),
Text(title.tr, style: TextStyle(fontSize: 20.sp)),
],
),
Container(
margin: EdgeInsets.only(top: 10.h, left: 10.w, right: 10.w),
padding: EdgeInsets.all(10.w),
decoration: BoxDecoration(
color: AppColors.lightBlueBgColor,
borderRadius: BorderRadius.circular(6),
),
child: Text(content.tr, style: TextStyle(fontSize: 20.sp)),
),
],
);
}
}