初始化项目
This commit is contained in:
31
lib/controller/device/blueteeth_bind_controller.dart
Normal file
31
lib/controller/device/blueteeth_bind_controller.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'blueteeth_bind_controller.g.dart'; // 由json_serializable自动生成的部分
|
||||
|
||||
@JsonSerializable()
|
||||
class BlueteethBindModel {
|
||||
int read = 1;//是否不再提示教程 0 不再提示 1 需要提示
|
||||
|
||||
BlueteethBindModel();
|
||||
|
||||
// 从JSON反序列化时的异常处理
|
||||
|
||||
factory BlueteethBindModel.fromJson(Map<String, dynamic> json) {
|
||||
try {
|
||||
return _$BlueteethBindModelFromJson(json);
|
||||
} catch (e) {
|
||||
// 在实际应用中,应该有更细致的异常处理策略和错误日志
|
||||
return BlueteethBindModel(); // 或者返回一个带有错误信息的特定DeviceInfoModel实例
|
||||
}
|
||||
}
|
||||
|
||||
// 序列化为JSON时的异常处理
|
||||
Map<String, dynamic> toJson() => _$BlueteethBindModelToJson(this);
|
||||
}
|
||||
|
||||
class BlueteethBindController extends GetControllerEx<BlueteethBindModel> {
|
||||
BlueteethBindController() {
|
||||
attr = GetModel(BlueteethBindModel()).obs;
|
||||
}
|
||||
}
|
||||
15
lib/controller/device/blueteeth_bind_controller.g.dart
Normal file
15
lib/controller/device/blueteeth_bind_controller.g.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'blueteeth_bind_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
BlueteethBindModel _$BlueteethBindModelFromJson(Map<String, dynamic> json) =>
|
||||
BlueteethBindModel()..read = (json['read'] as num).toInt();
|
||||
|
||||
Map<String, dynamic> _$BlueteethBindModelToJson(BlueteethBindModel instance) =>
|
||||
<String, dynamic>{
|
||||
'read': instance.read,
|
||||
};
|
||||
172
lib/controller/main_bottom/global_controller.dart
Normal file
172
lib/controller/main_bottom/global_controller.dart
Normal file
@@ -0,0 +1,172 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/main_page_controller.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
|
||||
class GlobalModel {
|
||||
List deviceList = [];
|
||||
Map deviceMain = {};
|
||||
|
||||
Map useBedController = {}; //之前控制的设备
|
||||
|
||||
List deviceType = [];
|
||||
|
||||
List homeImgList = []; //轮播图
|
||||
|
||||
bool hideBottomNavigationBar = false;
|
||||
|
||||
get deviceMainIsShare {
|
||||
if (deviceMain != null && deviceMain["type"] == 2) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// get JunheDevices {
|
||||
// List arr = [];
|
||||
|
||||
// deviceList.forEach((d) {
|
||||
// d?["personnelInfo"]?.forEach((item) {
|
||||
// if (item["mac"] == d["bindMacA"] &&
|
||||
// arr.indexWhere((a) => a["mac"] == item["mac"]) == -1) {
|
||||
// arr.add(item);
|
||||
// }
|
||||
// });
|
||||
// if (d["bindMacB"] != null && d["bindMacB"] != "") {
|
||||
// d["personnelInfo"].forEach((item) {
|
||||
// if (item["mac"] == d["bindMacB"] &&
|
||||
// arr.indexWhere((a) => a["mac"] == item["mac"]) == -1) {
|
||||
// arr.add(item);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
// return arr;
|
||||
// }
|
||||
|
||||
get JunheDevices {
|
||||
List arr = [];
|
||||
try {
|
||||
if (deviceList != null) {
|
||||
deviceList.forEach((d) {
|
||||
if (d?["personnelInfo"] != null) {
|
||||
d["personnelInfo"].forEach((item) {
|
||||
if (item["mac"] == d["bindMacA"] &&
|
||||
arr.indexWhere((a) => a["mac"] == item["mac"]) == -1) {
|
||||
arr.add(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (d["bindMacB"] != null && d["bindMacB"] != "") {
|
||||
if (d["personnelInfo"] != null) {
|
||||
d["personnelInfo"].forEach((item) {
|
||||
if (item["mac"] == d["bindMacB"] &&
|
||||
arr.indexWhere((a) => a["mac"] == item["mac"]) == -1) {
|
||||
arr.add(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
get mainDevicePeople {
|
||||
if (deviceMain == null || deviceMain["mac"] == null) {
|
||||
return [{}, {}];
|
||||
}
|
||||
List arr = [{}, {}];
|
||||
if (deviceMain["personnelInfo"] != null) {
|
||||
if (deviceMain["bindMacA"] != null) {
|
||||
deviceMain["personnelInfo"]?.forEach((d) {
|
||||
if (d["mac"] == deviceMain["bindMacA"]) {
|
||||
arr[0] = d;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (deviceMain["bindMacB"] != null) {
|
||||
deviceMain["personnelInfo"]?.forEach((d) {
|
||||
if (d["mac"] == deviceMain["bindMacB"]) {
|
||||
arr[1] = d;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
GlobalModel();
|
||||
}
|
||||
|
||||
class GlobalController extends GetControllerEx<GlobalModel> {
|
||||
GlobalController() {
|
||||
attr = GetModel(GlobalModel()).obs;
|
||||
}
|
||||
|
||||
get userInfoController => Get.find<UserInfoController>();
|
||||
|
||||
Timer? getDeviceListTimer;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
resetParmAll() {
|
||||
resetParm();
|
||||
Get.find<MainPageController>().resetParm();
|
||||
}
|
||||
|
||||
resetParm() {
|
||||
getDeviceListTimer?.cancel();
|
||||
getDeviceListTimer = null;
|
||||
model.deviceList = [];
|
||||
model.deviceMain = {};
|
||||
model.useBedController = {};
|
||||
model.deviceType = [];
|
||||
model.homeImgList = [];
|
||||
model.hideBottomNavigationBar = false;
|
||||
}
|
||||
|
||||
deviceUpdateTimerCreated() {
|
||||
if (getDeviceListTimer == null) {
|
||||
getDeviceListTimer = Timer.periodic(const Duration(seconds: 10), (t) {
|
||||
if (userInfoController.model.token != null) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
getDeviceGroupName(device) {
|
||||
return "${device['roomName']}/${device["deviceType"]?["name"]}/${device["name"]}";
|
||||
}
|
||||
|
||||
getDeviceGroupName2(device) {
|
||||
return "${device["deviceType"]?["name"]}/${device["name"]}";
|
||||
}
|
||||
|
||||
getUpperCaseMac(mac) {
|
||||
if (mac == null || mac == "") {
|
||||
return "";
|
||||
}
|
||||
return "$mac".toUpperCase();
|
||||
}
|
||||
|
||||
getDeviceType() async {
|
||||
var rs =
|
||||
await ef.from("app_device_type").select().order("id", ascending: true);
|
||||
model.deviceType = rs.where((d) => d["page"] != null).toList();
|
||||
updateAll();
|
||||
}
|
||||
}
|
||||
34
lib/controller/main_bottom/main_page_controller.dart
Normal file
34
lib/controller/main_bottom/main_page_controller.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'main_page_controller.g.dart'; // 由json_serializable自动生成的部分
|
||||
|
||||
@JsonSerializable()
|
||||
class MainPageModel {
|
||||
int currentIndex = 0;
|
||||
MainPageModel();
|
||||
|
||||
// 从JSON反序列化时的异常处理
|
||||
|
||||
factory MainPageModel.fromJson(Map<String, dynamic> json) {
|
||||
try {
|
||||
return _$MainPageModelFromJson(json);
|
||||
} catch (e) {
|
||||
// 在实际应用中,应该有更细致的异常处理策略和错误日志
|
||||
return MainPageModel(); // 或者返回一个带有错误信息的特定DeviceInfoModel实例
|
||||
}
|
||||
}
|
||||
|
||||
// 序列化为JSON时的异常处理
|
||||
Map<String, dynamic> toJson() => _$MainPageModelToJson(this);
|
||||
}
|
||||
|
||||
class MainPageController extends GetControllerEx<MainPageModel> {
|
||||
MainPageController() {
|
||||
attr = GetModel(MainPageModel()).obs;
|
||||
}
|
||||
|
||||
resetParm() {
|
||||
model.currentIndex = 0;
|
||||
}
|
||||
}
|
||||
15
lib/controller/main_bottom/main_page_controller.g.dart
Normal file
15
lib/controller/main_bottom/main_page_controller.g.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'main_page_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
MainPageModel _$MainPageModelFromJson(Map<String, dynamic> json) =>
|
||||
MainPageModel()..currentIndex = (json['currentIndex'] as num).toInt();
|
||||
|
||||
Map<String, dynamic> _$MainPageModelToJson(MainPageModel instance) =>
|
||||
<String, dynamic>{
|
||||
'currentIndex': instance.currentIndex,
|
||||
};
|
||||
18
lib/controller/theme_controller/ThemeController.dart
Normal file
18
lib/controller/theme_controller/ThemeController.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vbvs_app/model/CustomThemeColor.dart';
|
||||
|
||||
class ThemeController extends GetControllerEx {
|
||||
//todo 数据库查询的颜色等于这个
|
||||
CustomThemeColor currentColor = CustomThemeColor.light;
|
||||
ThemeData currentTheme = ThemeData();
|
||||
|
||||
void changeTheme(CustomThemeColor color) {
|
||||
currentColor = color;
|
||||
currentTheme = ThemeData(
|
||||
primaryColor: color.sc1,
|
||||
scaffoldBackgroundColor: color.sc2,
|
||||
);
|
||||
update();
|
||||
}
|
||||
}
|
||||
50
lib/controller/user_info_controller.dart
Normal file
50
lib/controller/user_info_controller.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/CommonVariables.dart';
|
||||
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
import 'package:vbvs_app/model/user_data.dart';
|
||||
|
||||
|
||||
part 'user_info_controller.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class UserInfoModel {
|
||||
int? message = 0; //消息数量
|
||||
|
||||
UserModel? user; //用户信息
|
||||
String? token; //token值
|
||||
String? runSystem; //运行系统
|
||||
String? phoneVersion; //手机版本
|
||||
String? deviceId; //手机唯一
|
||||
String? deviceModel; //设备可见型号(如 "iPhone","iPad")
|
||||
String? appVersion; //app版本信息
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
Session? superbase_session;
|
||||
@JsonKey(ignore: true)
|
||||
User? superbase_user;
|
||||
|
||||
String? img_bucket = 'user';
|
||||
int? login = 0; //是否登录0:未登录 1:已登录
|
||||
|
||||
UserInfoModel();
|
||||
static UserInfoModel fromJson(Map<String, dynamic> json) =>
|
||||
_$UserInfoModelFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$UserInfoModelToJson(this);
|
||||
}
|
||||
|
||||
class UserInfoController extends GetControllerEx<UserInfoModel> {
|
||||
// 初始化实例
|
||||
UserInfoController() {
|
||||
attr = GetModel(UserInfoModel()).obs;
|
||||
}
|
||||
}
|
||||
36
lib/controller/user_info_controller.g.dart
Normal file
36
lib/controller/user_info_controller.g.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_info_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
UserInfoModel _$UserInfoModelFromJson(Map<String, dynamic> json) =>
|
||||
UserInfoModel()
|
||||
..message = (json['message'] as num?)?.toInt()
|
||||
..user = json['user'] == null
|
||||
? null
|
||||
: UserModel.fromJson(json['user'] as Map<String, dynamic>)
|
||||
..token = json['token'] as String?
|
||||
..runSystem = json['runSystem'] as String?
|
||||
..phoneVersion = json['phoneVersion'] as String?
|
||||
..deviceId = json['deviceId'] as String?
|
||||
..deviceModel = json['deviceModel'] as String?
|
||||
..appVersion = json['appVersion'] as String?
|
||||
..img_bucket = json['img_bucket'] as String?
|
||||
..login = (json['login'] as num?)?.toInt();
|
||||
|
||||
Map<String, dynamic> _$UserInfoModelToJson(UserInfoModel instance) =>
|
||||
<String, dynamic>{
|
||||
'message': instance.message,
|
||||
'user': instance.user,
|
||||
'token': instance.token,
|
||||
'runSystem': instance.runSystem,
|
||||
'phoneVersion': instance.phoneVersion,
|
||||
'deviceId': instance.deviceId,
|
||||
'deviceModel': instance.deviceModel,
|
||||
'appVersion': instance.appVersion,
|
||||
'img_bucket': instance.img_bucket,
|
||||
'login': instance.login,
|
||||
};
|
||||
Reference in New Issue
Block a user