177 lines
4.4 KiB
Dart
177 lines
4.4 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/app_settings/app_colors.dart';
|
|
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
|
|
|
import '../../../../../tools/commonItem.dart';
|
|
import '../../../../../tools/submitBtn.dart';
|
|
import '../../../../appRouters.dart';
|
|
import '../../../../translations/trans_lib.dart';
|
|
|
|
class MassSendElectronicKeyPage extends StatefulWidget {
|
|
final String type;
|
|
|
|
const MassSendElectronicKeyPage({Key? key, required this.type})
|
|
: super(key: key);
|
|
|
|
@override
|
|
State<MassSendElectronicKeyPage> createState() =>
|
|
_MassSendElectronicKeyPageState();
|
|
}
|
|
|
|
class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
|
|
final FlutterContactPicker _contactPicker = FlutterContactPicker();
|
|
late Contact _contact;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return indexChangeWidget();
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
Widget indexChangeWidget() {
|
|
switch (int.parse(widget.type)) {
|
|
case 0:
|
|
{
|
|
// 限时
|
|
return Column(
|
|
children: [
|
|
keyInfoWidget(),
|
|
keyTimeWidget(),
|
|
remoteUnlockingWidget(),
|
|
keyBottomWidget()
|
|
],
|
|
);
|
|
}
|
|
case 1:
|
|
{
|
|
// 永久
|
|
return Column(
|
|
children: [
|
|
keyInfoWidget(),
|
|
remoteUnlockingWidget(),
|
|
keyBottomWidget()
|
|
],
|
|
);
|
|
}
|
|
case 2:
|
|
{
|
|
// 单次
|
|
return Column(
|
|
children: [
|
|
keyInfoWidget(),
|
|
periodValidityWidget(),
|
|
remoteUnlockingWidget(),
|
|
keyBottomWidget()
|
|
],
|
|
);
|
|
}
|
|
default:
|
|
return Container();
|
|
}
|
|
}
|
|
|
|
// 顶部钥匙信息widget
|
|
Widget keyInfoWidget() {
|
|
return Column(
|
|
children: [
|
|
Container(height: 10.h),
|
|
CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.receiver!.tr,
|
|
rightTitle: TranslationLoader.lanKeys!.pleaseAdd!.tr,
|
|
isHaveLine: true,
|
|
isHaveDirection: true,
|
|
action: () {}),
|
|
CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.lock!.tr,
|
|
rightTitle: TranslationLoader.lanKeys!.pleaseSelet!.tr,
|
|
isHaveDirection: true,
|
|
action: () {}),
|
|
Container(height: 10.h),
|
|
],
|
|
);
|
|
}
|
|
|
|
// 生效失效时间
|
|
Widget keyTimeWidget() {
|
|
return Column(
|
|
children: [
|
|
CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
|
|
rightTitle: "2020.06.20 11:49",
|
|
isHaveLine: true),
|
|
CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
|
|
rightTitle: "2020.06.20 11:49",
|
|
),
|
|
Container(height: 10.h),
|
|
],
|
|
);
|
|
}
|
|
|
|
// 远程开锁
|
|
Widget remoteUnlockingWidget() {
|
|
return Column(
|
|
children: [
|
|
CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
|
|
rightTitle: "",
|
|
isHaveRightWidget: true,
|
|
rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()),
|
|
action: () {}),
|
|
Container(height: 40.h),
|
|
],
|
|
);
|
|
}
|
|
|
|
// 有效期
|
|
Widget periodValidityWidget() {
|
|
return Column(
|
|
children: [
|
|
CommonItem(
|
|
leftTitel: TranslationLoader.lanKeys!.periodValidity!.tr,
|
|
rightTitle: "",
|
|
isHaveDirection: true,
|
|
action: () {
|
|
Navigator.pushNamed(
|
|
context, Routers.electronicKeyPeriodValidityPage);
|
|
}),
|
|
Container(height: 10.h),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget keyBottomWidget() {
|
|
return Column(
|
|
children: [
|
|
SubmitBtn(
|
|
btnName: TranslationLoader.lanKeys!.send!.tr,
|
|
onClick: () {
|
|
// Navigator.pushNamed(context, Routers.nearbyLockPage);
|
|
}),
|
|
],
|
|
);
|
|
}
|
|
|
|
CupertinoSwitch _switch() {
|
|
bool _isOn = false;
|
|
return CupertinoSwitch(
|
|
activeColor: CupertinoColors.activeBlue,
|
|
trackColor: CupertinoColors.systemGrey5,
|
|
thumbColor: CupertinoColors.white,
|
|
value: _isOn,
|
|
onChanged: (value) {
|
|
setState(() {
|
|
_isOn = value;
|
|
});
|
|
},
|
|
);
|
|
}
|
|
}
|