202 lines
7.6 KiB
Dart
Executable File

import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/flavors.dart';
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_logic.dart';
import 'package:star_lock/mine/valueAddedServices/valueAddedServicesList/valueAddedServicesList_state.dart';
import 'package:star_lock/tools/commonDataManage.dart';
import 'package:star_lock/tools/storage.dart';
import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart';
import '../../../tools/titleAppBar.dart';
class ValueAddedServicesListPage extends StatefulWidget {
const ValueAddedServicesListPage({Key? key}) : super(key: key);
@override
State<ValueAddedServicesListPage> createState() =>
_ValueAddedServicesPageListState();
}
class _ValueAddedServicesPageListState
extends State<ValueAddedServicesListPage> {
final ValueAddedServicesListLogic logic =
Get.put(ValueAddedServicesListLogic());
final ValueAddedServicesListState state =
Get.find<ValueAddedServicesListLogic>().state;
@override
void initState() {
super.initState();
logic.getServicePackageBuyUrl();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.mainBackgroundColor,
appBar: TitleAppBar(
barTitle: '增值服务'.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: ListView(
children: <Widget>[
_valueAddedServicesItem(
Image.asset('images/mine/icon_mine_valueAddedServices_note.png'),
'短信'.tr, () {
Get.toNamed(Routers.valueAddedServicesNoteAndEmailDetailPage,
arguments: <String, int>{'type': 1});
}),
_valueAddedServicesItem(
Image.asset('images/mine/icon_mine_valueAddedServices_email.png'),
'邮件'.tr, () {
Get.toNamed(Routers.valueAddedServicesNoteAndEmailDetailPage,
arguments: <String, int>{'type': 2});
}),
_valueAddedServicesItem(
Image.asset(
'images/mine/icon_mine_valueAddedServices_realName.png'),
'实名认证'.tr, () {
Get.toNamed(Routers.valueAddedServicesRealNamePage);
}),
_valueAddedServicesItem(
Image.asset('images/mine/icon_mine_valueAddedServices_vip.png'),
'高级功能'.tr, () async {
final bool? isVip = await Storage.getBool(saveIsVip);
if (isVip == null || !isVip) {
if (CommonDataManage().currentKeyInfo.isLockOwner != 1) {
logic.showToast('请先添加锁'.tr);
} else {
//刷新购买状态
Get.toNamed(Routers.advancedFeaturesWebPage,
arguments: <String, int>{
'webBuyType': XSConstantMacro.webBuyTypeVip,
})?.then((value) => logic.getUserInfoRequest());
}
} else {
Get.toNamed(Routers.valueAddedServicesHighFunctionPage);
}
}),
// _valueAddedServicesItem(
// Image.asset('images/mine/icon_mine_valueAddedServices_push.png'),
// TranslationLoader.lanKeys!.pushMessage!.tr, () {
// Navigator.pushNamed(context, Routers.gatewayDetailPage);
// }),
// _valueAddedServicesItem(
// Image.asset(
// 'images/mine/icon_mine_valueAddedServices_checkIn.png'),
// TranslationLoader.lanKeys!.checkingIn!.tr, () {
// Navigator.pushNamed(context, Routers.gatewayDetailPage);
// }),
//去掉记录保存
// _valueAddedServicesItem(
// Image.asset(
// 'images/mine/icon_mine_valueAddedServices_storage.png'),
// TranslationLoader.lanKeys!.recordsRetention!.tr, () {
// EasyLoading.showToast('功能暂未开放', duration: 2000.milliseconds);
// }),
if (!F.isProductionEnv)
_valueAddedServicesItem(
Image.asset('images/mine/icon_mine_valueAddedServices_vip.png'),
'可视对讲'.tr, () {
EasyLoading.showToast('功能暂未开放'.tr, duration: 2000.milliseconds);
}),
if (!F.isProductionEnv)
_valueAddedServicesItem(
Text(
'A',
style: TextStyle(
color: Colors.white,
fontSize: 38.sp,
fontWeight: FontWeight.w600),
),
'Amazon Alexa', () {
Get.toNamed(Routers.amazonAlexaPage, arguments: <String, dynamic>{
'isAmazonAlexa': state.isAmazonAlexa.value,
'amazonAlexaData': state.amazonAlexaData.value
});
}),
if (!F.isProductionEnv)
_valueAddedServicesItem(
Text(
'G',
style: TextStyle(
color: Colors.white,
fontSize: 38.sp,
fontWeight: FontWeight.w600),
),
'Google Home', () {
// EasyLoading.showToast('功能暂未开放', duration: 2000.milliseconds);
Get.toNamed(Routers.googleHomePage, arguments: <String, dynamic>{
'isGoogleHome': state.isGoogleHome.value,
'googleHomeData': state.googleHomeData.value
})?.then((Object? value) {
logic.userSettingsInfoRequest();
});
}),
// if (!F.isProductionEnv)
// _valueAddedServicesItem(
// Text(
// 'M',
// style: TextStyle(
// color: Colors.white,
// fontSize: 38.sp,
// fontWeight: FontWeight.w600),
// ),
// '小米IOT平台', () {
// EasyLoading.showToast('功能暂未开放'.tr, duration: 2000.milliseconds);
// }),
],
),
);
}
Widget _valueAddedServicesItem(
Widget widget, String gateWayName, Function() action) {
return GestureDetector(
onTap: action,
child: Container(
margin: EdgeInsets.only(top: 20.h, right: 20.w, left: 20.w),
padding:
EdgeInsets.only(left: 20.w, right: 20.w, top: 16.h, bottom: 16.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.w),
),
child: Row(
children: <Widget>[
Container(
width: 50.w,
height: 50.w,
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: AppColors.mainColor,
borderRadius: BorderRadius.circular(40.w)),
child: Center(child: widget),
),
SizedBox(
width: 20.w,
),
Expanded(
child: Text(
gateWayName,
style: TextStyle(fontSize: 24.sp, fontWeight: FontWeight.w600),
),
),
SizedBox(width: 20.h),
Image.asset(
'images/icon_right_grey.png',
width: 12.w,
height: 21.w,
)
],
),
),
);
}
}