feat: 对接Google Home接口并完成相关功能

This commit is contained in:
“DaisyWu” 2024-09-11 10:43:59 +08:00
parent 30383710b5
commit 57c7a41742
12 changed files with 412 additions and 121 deletions

View File

@ -47,6 +47,7 @@ import 'package:star_lock/mine/mineSet/amazon_alexa/amazon_alexa_page.dart';
import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorAssociationLock/administratorAssociationLock_page.dart';
import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorChangeDate/adminDetailChangeDate_page.dart';
import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart';
import 'package:star_lock/mine/mineSet/google_home/google_home_page.dart';
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart'; import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockManage_page.dart'; import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockManage_page.dart';
import 'package:star_lock/mine/mineSet/mineSet/mineSet_page.dart'; import 'package:star_lock/mine/mineSet/mineSet/mineSet_page.dart';
@ -503,6 +504,7 @@ abstract class Routers {
static const String login = '/login'; // static const String login = '/login'; //
static const String amazonAlexaPage = '/amazonAlexaPage'; //AmazonAlexa static const String amazonAlexaPage = '/amazonAlexaPage'; //AmazonAlexa
static const String googleHomePage = '/googleHomePage'; //GoogleHome
} }
abstract class AppRouters { abstract class AppRouters {
@ -1172,5 +1174,7 @@ abstract class AppRouters {
name: Routers.palmDetailPage, page: () => const PalmDetailPage()), name: Routers.palmDetailPage, page: () => const PalmDetailPage()),
GetPage<dynamic>( GetPage<dynamic>(
name: Routers.amazonAlexaPage, page: () => const AmazonAlexaPage()), name: Routers.amazonAlexaPage, page: () => const AmazonAlexaPage()),
GetPage<dynamic>(
name: Routers.googleHomePage, page: () => const GoogleHomePage()),
]; ];
} }

View File

@ -0,0 +1,26 @@
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
import 'package:star_lock/mine/mineSet/google_home/google_home_state.dart';
import 'package:star_lock/network/api_repository.dart';
import '../../../../tools/baseGetXController.dart';
class GoogleHomeLogic extends BaseGetXController {
final GoogleHomeState state = GoogleHomeState();
//-google home
Future<void> updateUserInfoWithGoogle() async {
final PasswordKeyListEntity entity =
await ApiRepository.to.updateUserInfoWithGoogle(
isGoogle: state.isGoogleHome.value ? 0 : 1,
);
if (entity.errorCode!.codeIsSuccessful) {
state.isGoogleHome.value = !state.isGoogleHome.value;
state.isGoogleHome.refresh();
if (state.isGoogleHome.value) {
state.isOpenedText.value = '关闭';
} else {
state.isOpenedText.value = '开启';
}
showToast('操作成功');
}
}
}

View File

@ -0,0 +1,120 @@
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),
_buildBottomWidget(),
],
),
),
);
}
Widget _buildTopWidget() {
return Column(
children: [
CommonItem(
leftTitel: 'Action name',
rightTitle: 'ScienerSmart',
),
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() {
return Container(
color: Colors.white,
width: ScreenUtil().screenWidth,
padding: _contentPadding,
child: Column(
children: [
_buildInfoSection('支持的语言'.tr, '英语'.tr),
SizedBox(height: 20.h),
_buildInfoSection(
'操作流程'.tr,
'1.用智能锁APP添加锁和网关\n\n2.在APP里开启锁的远程开锁功能这个功能默认是关闭的。如果没有这个选项则锁不支持Google Home \n\n3.安装Google Home APP点击左上角的“+”按钮\n\n4.在设置页面选择“与Google协同工作”\n\n5.搜索“ScienerSmart”并用智能锁APP的账号和密码进行授权\n\n6.在智能锁APP里设置安全码使用Google Home开锁时提供此安全码'
.tr),
],
),
);
}
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)),
),
],
);
}
}

View File

@ -0,0 +1,18 @@
import 'package:get/get.dart';
class GoogleHomeState {
GoogleHomeState() {
final Map map = Get.arguments;
if (map['isGoogleHome'] != null) {
isGoogleHome.value = map['isGoogleHome'];
if (isGoogleHome.value) {
isOpenedText.value = '关闭';
} else {
isOpenedText.value = '开启';
}
}
}
RxBool isGoogleHome = false.obs;
RxString isOpenedText = '开启'.obs;
}

View File

@ -48,6 +48,15 @@ class MineSetLogic extends BaseGetXController {
} else { } else {
state.isWechatPublicAccountPush.value = false; state.isWechatPublicAccountPush.value = false;
} }
//Amazon Alexa
entity.data!.isAmazonAlexa! == 1
? state.isAmazonAlexa.value = true
: state.isAmazonAlexa.value = false;
//Google Home
entity.data!.isGoogleHome! == 1
? state.isGoogleHome.value = true
: state.isGoogleHome.value = false;
} }
} }

View File

@ -333,8 +333,9 @@ class _MineSetPageState extends State<MineSetPage>
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
// logic.showToast('功能暂未开放'.tr); Get.toNamed(Routers.amazonAlexaPage, arguments: <String, dynamic>{
Get.toNamed(Routers.amazonAlexaPage); 'isAmazonAlexa': state.isAmazonAlexa.value
});
}), }),
CommonItem( CommonItem(
leftTitel: 'Google Home', leftTitel: 'Google Home',
@ -342,7 +343,11 @@ class _MineSetPageState extends State<MineSetPage>
isHaveLine: true, isHaveLine: true,
isHaveDirection: true, isHaveDirection: true,
action: () { action: () {
logic.showToast('功能暂未开放'.tr); Get.toNamed(Routers.googleHomePage, arguments: <String, dynamic>{
'isGoogleHome': state.isGoogleHome.value
})?.then((Object? value) {
logic.userSettingsInfoRequest();
});
}), }),
if (!F.isProductionEnv) if (!F.isProductionEnv)
CommonItem( CommonItem(

View File

@ -16,6 +16,8 @@ class MineSetState {
var lockScreen = 2.obs; // var lockScreen = 2.obs; //
var hideExpiredAccessFlag = 2.obs; // var hideExpiredAccessFlag = 2.obs; //
var currentLanguage = "".obs; // var currentLanguage = "".obs; //
RxBool isAmazonAlexa = false.obs; //Alexa
RxBool isGoogleHome = false.obs; //Home
late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin(); FlutterLocalNotificationsPlugin();

View File

@ -42,6 +42,8 @@ class UserSettingInfoData {
int? hasGoogleHome; int? hasGoogleHome;
int? alertMode; int? alertMode;
int? mpWechatPushSwitch; int? mpWechatPushSwitch;
int? isAmazonAlexa;
int? isGoogleHome;
UserSettingInfoData( UserSettingInfoData(
{this.userSettings, {this.userSettings,
@ -56,7 +58,9 @@ class UserSettingInfoData {
this.hasCameraLock, this.hasCameraLock,
this.hasGoogleHome, this.hasGoogleHome,
this.alertMode, this.alertMode,
this.mpWechatPushSwitch}); this.mpWechatPushSwitch,
this.isAmazonAlexa,
this.isGoogleHome});
UserSettingInfoData.fromJson(Map<String, dynamic> json) { UserSettingInfoData.fromJson(Map<String, dynamic> json) {
userSettings = json['userSettings'] != null userSettings = json['userSettings'] != null
@ -74,6 +78,8 @@ class UserSettingInfoData {
hasGoogleHome = json['hasGoogleHome']; hasGoogleHome = json['hasGoogleHome'];
alertMode = json['alertMode']; alertMode = json['alertMode'];
mpWechatPushSwitch = json['mpWechatPushSwitch']; mpWechatPushSwitch = json['mpWechatPushSwitch'];
isAmazonAlexa = json['is_amazon_alexa'];
isGoogleHome = json['is_google_home'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -93,6 +99,8 @@ class UserSettingInfoData {
data['hasGoogleHome'] = hasGoogleHome; data['hasGoogleHome'] = hasGoogleHome;
data['alertMode'] = alertMode; data['alertMode'] = alertMode;
data['mpWechatPushSwitch'] = mpWechatPushSwitch; data['mpWechatPushSwitch'] = mpWechatPushSwitch;
data['is_amazon_alexa'] = isAmazonAlexa;
data['is_google_home'] = isGoogleHome;
return data; return data;
} }
} }

View File

@ -128,7 +128,8 @@ class _ValueAddedServicesPageListState
fontWeight: FontWeight.w600), fontWeight: FontWeight.w600),
), ),
'Google Home', () { 'Google Home', () {
EasyLoading.showToast('功能暂未开放', duration: 2000.milliseconds); // EasyLoading.showToast('功能暂未开放', duration: 2000.milliseconds);
Get.toNamed(Routers.googleHomePage);
}), }),
if (!F.isProductionEnv) if (!F.isProductionEnv)
_valueAddedServicesItem( _valueAddedServicesItem(

View File

@ -342,13 +342,15 @@ class ApiProvider extends BaseProvider {
); );
// //
Future<Response> lockReportLockSuccessfullyUploadData(int lockId, int keyId) => post( Future<Response> lockReportLockSuccessfullyUploadData(
lockRecordUploadURL.toUrl, int lockId, int keyId) =>
jsonEncode({ post(
'lockId': lockId, lockRecordUploadURL.toUrl,
'keyId': keyId, jsonEncode({
}), 'lockId': lockId,
isUnShowLoading: true); 'keyId': keyId,
}),
isUnShowLoading: true);
// token // token
Future<Response> getLockNetToken(String lockId) => post( Future<Response> getLockNetToken(String lockId) => post(
@ -1477,7 +1479,7 @@ class ApiProvider extends BaseProvider {
// //
Future<Response> getRemoteControlListData( Future<Response> getRemoteControlListData(
String lockId, String pageNo, String pageSize, String searchStr) => String lockId, String pageNo, String pageSize, String searchStr) =>
post( post(
getRemoteControlListURL.toUrl, getRemoteControlListURL.toUrl,
jsonEncode({ jsonEncode({
@ -1489,21 +1491,21 @@ class ApiProvider extends BaseProvider {
// //
Future<Response> addRemoteControlData( Future<Response> addRemoteControlData(
String lockId, String lockId,
String remoteName, String remoteName,
String remoteNumber, String remoteNumber,
int remoteType, int remoteType,
int startDate, int startDate,
int endDate, int endDate,
int addType, int addType,
List weekDay, List weekDay,
int startTime, int startTime,
int endTime, int endTime,
int remoteRight, int remoteRight,
// String mac, // String mac,
// int electricQuantity, // int electricQuantity,
// List firmwareInfo // List firmwareInfo
) => ) =>
post( post(
addRemoteControlURL.toUrl, addRemoteControlURL.toUrl,
jsonEncode({ jsonEncode({
@ -1525,27 +1527,30 @@ class ApiProvider extends BaseProvider {
// //
Future<Response> updateRemoteUserNoLoadData( Future<Response> updateRemoteUserNoLoadData(
int lockId, int remoteId, String remoteUserNo) => int lockId, int remoteId, String remoteUserNo) =>
post( post(
updateRemoteUserNoURL.toUrl, updateRemoteUserNoURL.toUrl,
jsonEncode( jsonEncode({
{'lockId': lockId, 'remoteId': remoteId, 'remoteUserNo': remoteUserNo})); 'lockId': lockId,
'remoteId': remoteId,
'remoteUserNo': remoteUserNo
}));
// //
Future<Response> editRemoteControlData( Future<Response> editRemoteControlData(
int lockId, int lockId,
int remoteId, int remoteId,
int startDate, int startDate,
int endDate, int endDate,
int startTime, int startTime,
int endTime, int endTime,
int remoteType, int remoteType,
List weekDay, List weekDay,
String remoteName, String remoteName,
int addType, int addType,
int isCoerced, int isCoerced,
int remoteRight, int remoteRight,
) => ) =>
post( post(
editRemoteControlURL.toUrl, editRemoteControlURL.toUrl,
jsonEncode({ jsonEncode({
@ -1564,30 +1569,28 @@ class ApiProvider extends BaseProvider {
})); }));
// //
Future<Response> deletRemoteControlData(int remoteId) => Future<Response> deletRemoteControlData(int remoteId) => post(
post( deleteRemoteControlURL.toUrl,
deleteRemoteControlURL.toUrl, jsonEncode({
jsonEncode({ 'remoteId': remoteId,
'remoteId': remoteId, }));
}));
// //
Future<Response> resetRemoteControlData(int lockId) => Future<Response> resetRemoteControlData(int lockId) => post(
post( clearRemoteControlURL.toUrl,
clearRemoteControlURL.toUrl, jsonEncode({
jsonEncode({ 'lockId': lockId,
'lockId': lockId, }));
}));
// //
Future<Response> checkRemoteControlNameDuplicatedData( Future<Response> checkRemoteControlNameDuplicatedData(
String lockId, String remoteName) => String lockId, String remoteName) =>
post(checkRemoteControlNameURL.toUrl, post(checkRemoteControlNameURL.toUrl,
jsonEncode({'lockId': lockId, 'remoteName': remoteName})); jsonEncode({'lockId': lockId, 'remoteName': remoteName}));
// //
Future<Response> getPalmListData( Future<Response> getPalmListData(
String lockId, String pageNo, String pageSize, String searchStr) => String lockId, String pageNo, String pageSize, String searchStr) =>
post( post(
getPalmListURL.toUrl, getPalmListURL.toUrl,
jsonEncode({ jsonEncode({
@ -1599,18 +1602,17 @@ class ApiProvider extends BaseProvider {
// //
Future<Response> addPalmData( Future<Response> addPalmData(
String lockId, String lockId,
String palmVeinName, String palmVeinName,
String palmVeinNumber, String palmVeinNumber,
int palmVeinType, int palmVeinType,
int startDate, int startDate,
int endDate, int endDate,
int addType, int addType,
List weekDay, List weekDay,
int startTime, int startTime,
int endTime, int endTime,
int palmVeinRight int palmVeinRight) =>
) =>
post( post(
addPalmURL.toUrl, addPalmURL.toUrl,
jsonEncode({ jsonEncode({
@ -1629,27 +1631,30 @@ class ApiProvider extends BaseProvider {
// //
Future<Response> updatePalmUserNoLoadData( Future<Response> updatePalmUserNoLoadData(
int lockId, int palmVeinId, String palmVeinUserNo) => int lockId, int palmVeinId, String palmVeinUserNo) =>
post( post(
updatePalmUserNoURL.toUrl, updatePalmUserNoURL.toUrl,
jsonEncode( jsonEncode({
{'lockId': lockId, 'palmVeinId': palmVeinId, 'palmVeinUserNo': palmVeinUserNo})); 'lockId': lockId,
'palmVeinId': palmVeinId,
'palmVeinUserNo': palmVeinUserNo
}));
// //
Future<Response> editPalmData( Future<Response> editPalmData(
int lockId, int lockId,
int palmVeinId, int palmVeinId,
int startDate, int startDate,
int endDate, int endDate,
int startTime, int startTime,
int endTime, int endTime,
int palmVeinType, int palmVeinType,
List weekDay, List weekDay,
String palmVeinName, String palmVeinName,
int addType, int addType,
int isCoerced, int isCoerced,
int palmVeinRight, int palmVeinRight,
) => ) =>
post( post(
editPalmURL.toUrl, editPalmURL.toUrl,
jsonEncode({ jsonEncode({
@ -1668,24 +1673,22 @@ class ApiProvider extends BaseProvider {
})); }));
// //
Future<Response> deletPalmData(int palmVeinId) => Future<Response> deletPalmData(int palmVeinId) => post(
post( deletePalmURL.toUrl,
deletePalmURL.toUrl, jsonEncode({
jsonEncode({ 'palmVeinId': palmVeinId,
'palmVeinId': palmVeinId, }));
}));
// //
Future<Response> resetPalmData(int lockId) => Future<Response> resetPalmData(int lockId) => post(
post( clearPalmURL.toUrl,
clearPalmURL.toUrl, jsonEncode({
jsonEncode({ 'lockId': lockId,
'lockId': lockId, }));
}));
// //
Future<Response> checkPalmNameDuplicatedData( Future<Response> checkPalmNameDuplicatedData(
String lockId, String palmVeinName) => String lockId, String palmVeinName) =>
post(checkPalmNameURL.toUrl, post(checkPalmNameURL.toUrl,
jsonEncode({'lockId': lockId, 'palmVeinName': palmVeinName})); jsonEncode({'lockId': lockId, 'palmVeinName': palmVeinName}));
@ -1932,6 +1935,20 @@ class ApiProvider extends BaseProvider {
'headUrl': headUrl, 'headUrl': headUrl,
})); }));
//-amazon alexa 0 1
Future<Response> updateUserInfoWithAlexa(int isAlexa) => post(
updateUserInfoURL.toUrl,
jsonEncode({
'is_amazon_alexa': isAlexa,
}));
//-google home 0 1
Future<Response> updateUserInfoWithGoogle(int isGoogle) => post(
updateUserInfoURL.toUrl,
jsonEncode({
'is_google_home': isGoogle,
}));
// //
Future<Response> bindPhone(String countryCode, String account, Future<Response> bindPhone(String countryCode, String account,
String verificationCode, String unbindToken) => String verificationCode, String unbindToken) =>
@ -2125,8 +2142,7 @@ class ApiProvider extends BaseProvider {
})); }));
// //
Future<Response> updateFacePreventMisrun( Future<Response> updateFacePreventMisrun(int lockId, int faceEnErrUnlock) =>
int lockId, int faceEnErrUnlock) =>
post( post(
updateLockSettingUrl.toUrl, updateLockSettingUrl.toUrl,
jsonEncode({ jsonEncode({
@ -2588,9 +2604,9 @@ class ApiProvider extends BaseProvider {
// //
Future<Response> updateZoneOffsetsAndLanguages( Future<Response> updateZoneOffsetsAndLanguages(
int timezoneOffset, int timezoneOffset,
// String language // String language
) => ) =>
post( post(
updateZoneOffsetsAndLanguagesURL.toUrl, updateZoneOffsetsAndLanguagesURL.toUrl,
jsonEncode(<String, dynamic>{ jsonEncode(<String, dynamic>{

View File

@ -314,7 +314,8 @@ class ApiRepository {
// //
Future<KeyOperationRecordEntity> lockReportLockSuccessfullyUploadData( Future<KeyOperationRecordEntity> lockReportLockSuccessfullyUploadData(
{required int lockId, required int keyId}) async { {required int lockId, required int keyId}) async {
final res = await apiProvider.lockReportLockSuccessfullyUploadData(lockId, keyId); final res =
await apiProvider.lockReportLockSuccessfullyUploadData(lockId, keyId);
return KeyOperationRecordEntity.fromJson(res.body); return KeyOperationRecordEntity.fromJson(res.body);
} }
@ -1705,8 +1706,8 @@ class ApiRepository {
// ICCard用户序号 // ICCard用户序号
Future<LoginEntity> updateRemoteUserNoLoadData( Future<LoginEntity> updateRemoteUserNoLoadData(
{required int lockId, {required int lockId,
required int remoteId, required int remoteId,
required String remoteUserNo}) async { required String remoteUserNo}) async {
final res = await apiProvider.updateRemoteUserNoLoadData( final res = await apiProvider.updateRemoteUserNoLoadData(
lockId, remoteId, remoteUserNo); lockId, remoteId, remoteUserNo);
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
@ -1758,7 +1759,8 @@ class ApiRepository {
// //
Future<LoginEntity> checkRemoteControlNameDuplicatedData( Future<LoginEntity> checkRemoteControlNameDuplicatedData(
{required String lockId, required String remoteName}) async { {required String lockId, required String remoteName}) async {
final res = await apiProvider.checkRemoteControlNameDuplicatedData(lockId, remoteName); final res = await apiProvider.checkRemoteControlNameDuplicatedData(
lockId, remoteName);
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
} }
@ -1769,8 +1771,8 @@ class ApiRepository {
required String pageSize, required String pageSize,
required String searchStr, required String searchStr,
}) async { }) async {
final res = await apiProvider.getPalmListData( final res =
lockId, pageNo, pageSize, searchStr); await apiProvider.getPalmListData(lockId, pageNo, pageSize, searchStr);
return FingerprintListDataEntity.fromJson(res.body); return FingerprintListDataEntity.fromJson(res.body);
} }
@ -1806,8 +1808,8 @@ class ApiRepository {
// //
Future<LoginEntity> updatePalmUserNoLoadData( Future<LoginEntity> updatePalmUserNoLoadData(
{required int lockId, {required int lockId,
required int palmVeinId, required int palmVeinId,
required String palmVeinUserNo}) async { required String palmVeinUserNo}) async {
final res = await apiProvider.updatePalmUserNoLoadData( final res = await apiProvider.updatePalmUserNoLoadData(
lockId, palmVeinId, palmVeinUserNo); lockId, palmVeinId, palmVeinUserNo);
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
@ -1859,7 +1861,8 @@ class ApiRepository {
// //
Future<LoginEntity> checkPalmNameDuplicatedData( Future<LoginEntity> checkPalmNameDuplicatedData(
{required String lockId, required String palmVeinName}) async { {required String lockId, required String palmVeinName}) async {
final res = await apiProvider.checkPalmNameDuplicatedData(lockId, palmVeinName); final res =
await apiProvider.checkPalmNameDuplicatedData(lockId, palmVeinName);
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
} }
@ -1977,6 +1980,22 @@ class ApiRepository {
return PasswordKeyListEntity.fromJson(res.body); return PasswordKeyListEntity.fromJson(res.body);
} }
//-amazon alexa 0 1
Future<PasswordKeyListEntity> updateUserInfoWithAlexa({
required int isAlexa,
}) async {
final res = await apiProvider.updateUserInfoWithAlexa(isAlexa);
return PasswordKeyListEntity.fromJson(res.body);
}
//-google home 0 1
Future<PasswordKeyListEntity> updateUserInfoWithGoogle({
required int isGoogle,
}) async {
final res = await apiProvider.updateUserInfoWithGoogle(isGoogle);
return PasswordKeyListEntity.fromJson(res.body);
}
// //
Future<PasswordKeyListEntity> bindPhone(String countryCode, String account, Future<PasswordKeyListEntity> bindPhone(String countryCode, String account,
String verificationCode, String unbindToken) async { String verificationCode, String unbindToken) async {
@ -2579,13 +2598,13 @@ class ApiRepository {
} }
// //
Future<LoginEntity> updateZoneOffsetsAndLanguages( Future<LoginEntity> updateZoneOffsetsAndLanguages({
{ required int timezoneOffset,
required int timezoneOffset, // required String language
// required String language }) async {
}) async { final res = await apiProvider.updateZoneOffsetsAndLanguages(
final res = await apiProvider.updateZoneOffsetsAndLanguages(timezoneOffset, timezoneOffset,
// language // language
); );
return LoginEntity.fromJson(res.body); return LoginEntity.fromJson(res.body);
} }

View File

@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart'; import 'package:star_lock/app_settings/app_colors.dart';
import 'package:star_lock/tools/showTFView.dart'; import 'package:star_lock/tools/showTFView.dart';
@ -125,7 +126,7 @@ class ShowTipView {
); );
} }
void resetGetController(){ void resetGetController() {
getController.text = ''; getController.text = '';
} }
@ -148,4 +149,66 @@ class ShowTipView {
}, },
); );
} }
//
void showTipWithInputDialog({
required String title,
required String sureText,
required String contentText,
required Function(String) sureClick,
String cancelText = '取消',
VoidCallback? onCancel,
}) {
final TextEditingController controller = TextEditingController();
controller.text = contentText;
showDialog(
context: Get.context!,
barrierDismissible: true,
builder: (BuildContext context) {
return CupertinoAlertDialog(
title: Text(
title,
style: TextStyle(color: AppColors.blackColor),
),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const SizedBox(height: 16),
CupertinoTextField(
controller: controller,
placeholder: '请输入',
style: TextStyle(color: AppColors.blackColor),
),
const SizedBox(height: 16),
],
),
actions: <Widget>[
CupertinoDialogAction(
child: Text(
cancelText,
style: TextStyle(color: AppColors.blackColor),
),
onPressed: () {
if (onCancel != null) {
onCancel();
}
Get.back();
},
),
CupertinoDialogAction(
child: Text(
sureText,
style: const TextStyle(color: AppColors.blueTextTipsColor),
),
onPressed: () {
sureClick(controller.text);
// Get.back(); //
},
),
],
);
},
);
}
} }