diff --git a/.DS_Store b/.DS_Store
index e5bcb7e3..a15ea279 100755
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 61b6c4de..7a875bfc 100755
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,29 +1,287 @@
-# This file configures the analyzer, which statically analyzes Dart code to
-# check for errors, warnings, and lints.
+# For a list of lints, see: http://dart-lang.github.io/linter/lints/
+# See the configuration guide for more
+# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
#
-# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
-# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
-# invoked from the command line by running `flutter analyze`.
+# There are other similar analysis options files in the flutter repos,
+# which should be kept in sync with this file:
+#
+# - analysis_options.yaml (this file)
+# - packages/flutter/lib/analysis_options_user.yaml
+# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
+# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
+#
+# This file contains the analysis options used by Flutter tools, such as IntelliJ,
+# Android Studio, and the `flutter analyze` command.
-# The following line activates a set of recommended lints for Flutter apps,
-# packages, and plugins designed to encourage good coding practices.
-include: package:flutter_lints/flutter.yaml
+analyzer:
+ strong-mode:
+ implicit-casts: true
+ implicit-dynamic: true
+ errors:
+ # treat missing required parameters as a warning (not a hint)
+ missing_required_param: warning
+ # treat missing returns as a warning (not a hint)
+ missing_return: warning
+ # allow having TODOs in the code
+ todo: ignore
+ # allow self-reference to deprecated members (we do this because otherwise we have
+ # to annotate every member in every test, assert, etc, when we deprecate something)
+ # deprecated_member_use_from_same_package: ignore
+ # Ignore analyzer hints for updating pub specs when using Future or
+ # Stream and not importing dart:async
+ # Please see https://github.com/flutter/flutter/pull/24528 for details.
+ sdk_version_async_exported_from_core: ignore
+ exclude:
+ # - "**"
+ # the following two are relative to the stocks example and the flutter package respectively
+ # see https://github.com/dart-lang/sdk/issues/28463
+ - "ios/*"
+ - "android/*"
+ - "analysis_options.yaml"
linter:
- # The lint rules applied to this project can be customized in the
- # section below to disable rules from the `package:flutter_lints/flutter.yaml`
- # included above or to enable additional rules. A list of all available lints
- # and their documentation is published at
- # https://dart-lang.github.io/linter/lints/index.html.
- #
- # Instead of disabling a lint rule for the entire project in the
- # section below, it can also be suppressed for a single line of code
- # or a specific dart file by using the `// ignore: name_of_lint` and
- # `// ignore_for_file: name_of_lint` syntax on the line or in the file
- # producing the lint.
rules:
- # avoid_print: false # Uncomment to disable the `avoid_print` rule
- # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
-
-# Additional information about this file can be found at
-# https://dart.dev/guides/language/analysis-options
+ # these rules are documented on and in the same order as
+ # the Dart Lint rules page to make maintenance easier
+ # https://github.com/dart-lang/linter/blob/master/example/all.yaml
+ - always_declare_return_types
+ - avoid_bool_literals_in_conditional_expressions
+ - avoid_field_initializers_in_const_classes
+ - avoid_return_types_on_setters
+ - avoid_slow_async_io
+ - avoid_unused_constructor_parameters
+ - avoid_void_async
+ - cast_nullable_to_non_nullable
+ - flutter_style_todos
+ - iterable_contains_unrelated_type
+ - leading_newlines_in_multiline_strings
+ - library_prefixes
+ - no_adjacent_strings_in_list
+ - null_check_on_nullable_type_parameter
+ - package_api_docs
+ - package_prefixed_library_names
+ - prefer_final_in_for_each
+ - prefer_for_elements_to_map_fromIterable
+ - prefer_foreach
+ - prefer_generic_function_type_aliases
+ - prefer_if_elements_to_conditional_expressions
+ - prefer_iterable_whereType
+ - prefer_single_quotes
+ - prefer_spread_collections
+ - throw_in_finally
+ - tighten_type_of_initializing_formals
+ - type_init_formals
+ - unnecessary_nullable_for_final_variable_declarations
+ - use_is_even_rather_than_modulo
+ - use_late_for_private_fields_and_variables
+ - use_raw_strings
+ # ======================= 自定义规则
+ # -------------------------命名
+ # - 类型定义采用大写驼峰
+ - camel_case_types
+ # - 函数拓展采用大写驼峰
+ - camel_case_extensions
+ # - 库和文件名采用小写+下划线的方式命名
+ - library_names
+ - file_names
+ # - 普通变量使用驼峰命名
+ - non_constant_identifier_names
+ # - 静态变量推荐使用驼峰命名
+ - constant_identifier_names
+ # -------------------------排
+ # - 包引用排序:
+ # - dart开头的包排在最前面,
+ # - package开头的包排在相对引用包前面
+ # - exports列在单独模块
+ # - 每个模块内引用按字母顺序排序
+ - directives_ordering
+ # -------------------------格式化
+ # - 控制流中尽量使用大括号
+ - curly_braces_in_flow_control_structures
+ # -------------------------评论
+ # - 评论使用三斜杠标识
+ - slash_for_doc_comments
+ # - 评论中使用可引用范围内的变量
+ - comment_references
+ # -------------------------库使用
+ # - 避免引用包内的具体实现文件
+ - implementation_imports
+ # - 避免对lib/目录下的文件采用相对引用
+ - avoid_relative_lib_imports
+ #-------------------------NULL
+ # - 避免初始化变量为null
+ - avoid_init_to_null
+ # -------------------------字符串
+ # - 避免不需要的大括号
+ - unnecessary_brace_in_string_interps
+ # - 使用相邻字符串的方式连接字符串
+ - prefer_adjacent_string_concatenation
+ # -------------------------集合
+ # - 尽量使用显式类型的方式初始化集合
+ - prefer_collection_literals
+ # - 使用isEmpty和isNotE叩ty来判断是否为空,而不是通过length是否为0的方式
+ - prefer_is_empty
+ - prefer_is_not_empty
+ # -------------------------函数
+ # - 去除不必要的lambdas表达式
+ - unnecessary_lambdas
+ # - 函数默认值尽量使用=来赋值
+ - prefer_equal_for_default_values
+ # - 使用函数声明的方式将函数和变量做绑定
+ - prefer_function_declarations_over_variables
+ # -------------------------成员变量
+ # - 如无特殊作用,不用专门定义设置和获取方法
+ - unnecessary_getters_setters
+ # - 避免使用this方式调用变量
+ - unnecessary_this
+ # - 私有变量推荐定义成final
+ - prefer_final_fields
+ # - 可以考虑使用..这样方式,而不是返回this指针的方式来实现流式调用
+ - avoid_returning_this
+ # - 避免返回null
+ - avoid_returning_null
+ # -------------------------构造函数
+ # - 避免构造函数使用{}做空实现可以直接使用;
+ - empty_constructor_bodies
+ # - 推荐在构造函数中直接对成员变量进行赋值
+ - prefer_initializing_formals
+ # - 去掉new关键字
+ - unnecessary_new
+ # - 在const环境中,避免使用const关键字
+ - unnecessary_const
+ # -------------------------异常处理
+ # - 对捕获异常不处理的情况话,建议使用rethrow方式重新抛出而不是直接throw
+ - use_rethrow_when_possible
+ #-------------------------Mixin
+ # - 建议尽可能使用mixin机制
+ - prefer_mixin
+ # -------------------------类型
+ # - 未初始化变量,尽量提供类型
+ - prefer_typing_uninitialized_variables
+ # - 尽可能显式声明变量类型
+ - always_specify_types
+ # -------------------------参数
+ # - 避免使用True或者 false作为参数。应该换成更有语义的表达
+ - avoid_positional_boolean_parameters
+ # -------------------------质量
+ # - 如果重写了==同时也需要重写hashcode
+ - hash_and_equals
+ # - 非immutable1e类不要重写hashCode和=否则在集合中会出现bug
+ - avoid_equals_and_hash_code_on_mutable_classes
+ # - 在自定义==时,不要做null检查
+ - avoid_null_checks_in_equality_operators
+ # -------------------------Core集合融合部分
+ # - 避免空的else语句
+ - avoid_empty_else
+ # - 避免使用隐形类型传递
+ - avoid_shadowing_type_parameters
+ # - 避免类型做参数
+ - avoid_types_as_parameter_names
+ # - 避免await非future对象
+ - await_only_futures
+ # - 避免catch空实现
+ - empty_catches
+ # - 集合的 remove需要传递符合集合的类型的参数
+ - list_remove_unrelated_type
+ # - case中避免重复
+ - no_duplicate_case_values
+ # - deprecated函数或者变量需要注明相关信息
+ - provide_deprecation_message
+ # - 去掉不需要的重写注解
+ - unnecessary_overrides
+ # - 两个变量比较时,避免类型不一致
+ - unrelated_type_equality_checks
+ # - 避免赋值给void类型变量
+ - void_checks
+ # - 正则表达式合法性校验
+ - valid_regexps
+ # -------------------------Recommended 集合融合部分
+ # - 非空变量使用 require 关键字
+ - always_require_non_null_named_parameters
+ # - 对重写的方法和变量加 override注解
+ - annotate_overrides
+ # - 重写方法的参数不要改变参数名称
+ - avoid_renaming_method_parameters
+ # - 不要在void函数中返回null
+ - avoid_returning_null_for_void
+ # - 避免在单个函数调用中使用传递调用语法
+ - avoid_single_cascade_in_expression_statements
+ # - 避免在finally语句块中使用控制流语句
+ - control_flow_in_finally
+ # - 避免空语句
+ - empty_statements
+ # - 避免传递null给闭包参数
+ - null_closures
+ # - 避免重写类的field
+ - overridden_fields
+ # - 建议判空逻辑中建议使用??=语法
+ - prefer_conditional_assignment
+ # - 判断集合或者字符串的包含的逻辑使用contains而不是indexOf
+ - prefer_contains
+ # - 空判断尽量使用??操作符
+ - prefer_if_null_operators
+ # - 允许情况下,1ist使用内联的方式声明
+ - prefer_inlined_adds
+ # - 推荐使用is!操作符
+ - prefer_is_not_operator
+ # - 推荐使用?.操作符
+ - prefer_null_aware_operators
+ # - 类型定义尽可能使用void而不是null
+ - prefer_void_to_null
+ # - 避免递归调用 getter
+ - recursive_getters
+ # - 避免在空判断中使用null
+ - unnecessary_null_in_if_null_operators
+ # - 去掉不必要的反斜线
+ - unnecessary_string_escapes
+ # - 避免不必要的字符串引用逻辑
+ - unnecessary_string_interpolations
+ # -------------------------Flutter 集合融合部分
+ # - 避免生产环境使用print
+ - avoid_print
+ # - 去掉无用的container节点
+ - avoid_unnecessary_containers
+ # - 避免在flutter代码中引入web相关的库
+ - avoid_web_libraries_in_flutter
+ # - 在state create函数中不加入额外逻辑
+ - no_logic_in_create_state
+ # - 优先使用 const构造函数
+ - prefer_const_constructors
+ # - 在immutable类定义中使用 const构造函数
+ - prefer_const_constructors_in_immutables
+ # - 尽可能定义成const变量
+ - prefer_const_declarations
+ # - 在immutable类创建中尽量使用 const变量
+ - prefer_const_literals_to_create_immutables
+ # - 优先使用SizedBox而不是 Container
+ - sized_box_for_whitespace
+ # - 使用8位16进制整数标识颜色值
+ - use_full_hex_values_for_flutter_colors
+ # - 在构造函数中加入key参数
+ - use_key_in_widget_constructors
+ # -------------------------其他规则融合部分
+ # - 无用代码清理
+ - unnecessary_statements
+ # - 控制流语句分散到不同层
+ - always_put_control_body_on_new_line
+ # - required修饰变量排到变量列表前面
+ - always_put_required_named_parameters_first
+ #dart.async.StreamSubscription需要在恰当时机调用 cancel方法
+ - cancel_subscriptions
+ # - 倾向在初始化列表中增加 assert
+ - prefer_asserts_in_initializer_lists
+ # - 符合标准情况下加上final关键字
+ - prefer_final_locals
+ # - 构造函数排在变量之前
+ - sort_constructors_first
+ - sort_unnamed_constructors_first
+ # - 在比较之前先测试类型是否符合要求
+ - test_types_in_equals
+ # - 避免不必要的null判断
+ - unnecessary_null_aware_assignments
+ # - 去掉不必要的圆括号
+ - unnecessary_parenthesis
+ # - 避免不安全HTML的API
+ - unsafe_html
+ # - 避免魔鬼数值
+ - avoid_hard_coded_literals
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index afb5fd51..24086c3f 100755
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -22,7 +22,8 @@
-
+
+
diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json
index d6efba2c..630c677c 100755
--- a/images/lan/lan_en.json
+++ b/images/lan/lan_en.json
@@ -608,7 +608,7 @@
"卡详情": "Card details",
"请输入": "Please enter",
"关闭后,智能锁将设置为全天常开模式,直到手动关闭": "After closing, the smart lock will be set to all-day open mode until manually closed",
- "请输入小于1000的数字": "Please enter a number less than 1000",
+ "请输入小于或等于60的数字": "Please enter a number less than 60",
"操作成功": "Operation success",
"管理员密码相同,无需修改": "The administrator password is the same and does not need to be modified",
"修改密码": "Modify password",
@@ -816,6 +816,7 @@
"身份证号":"ID number",
"请输入真实姓名":"Please enter your real name",
"请输入身份证号":"Please enter your ID number",
+ "请输入身份证号和真实姓名":"Please enter your ID number and real name",
"点击返回设备配对":"Tap Back to device pairing",
"无法连接?尝试升级":"Can't connect?Upgrade attempted",
"固件升级提示":"Firmware upgrade prompt",
@@ -854,5 +855,6 @@
"门铃事件":"Doorbell event",
"视频事件":"Video event",
"请开启蓝牙":"Please turn on Bluetooth",
- "请选择有效日":"Please select the effective day"
+ "请选择有效日":"Please select the effective day",
+ "公司名字长度不能小于 6 ": "The length of the company name cannot be less than 6"
}
diff --git a/images/lan/lan_keys.json b/images/lan/lan_keys.json
index 52f94c2d..e470018b 100755
--- a/images/lan/lan_keys.json
+++ b/images/lan/lan_keys.json
@@ -633,7 +633,7 @@
"卡详情": "卡详情",
"请输入": "请输入",
"关闭后,智能锁将设置为全天常开模式,直到手动关闭": "关闭后,智能锁将设置为全天常开模式,直到手动关闭",
- "请输入小于1000的数字": "请输入小于1000的数字",
+ "请输入小于或等于60的数字": "请输入小于或等于60的数字",
"操作成功": "操作成功",
"管理员密码相同,无需修改": "管理员密码相同,无需修改",
"修改密码": "修改密码",
@@ -844,6 +844,7 @@
"身份证号":"身份证号",
"请输入真实姓名":"请输入真实姓名",
"请输入身份证号":"请输入身份证号",
+ "请输入身份证号和真实姓名":"请输入身份证号和真实姓名",
"点击返回设备配对":"点击返回设备配对",
"无法连接?尝试升级":"无法连接?尝试升级",
@@ -883,5 +884,6 @@
"门铃事件":"门铃事件",
"视频事件":"视频事件",
"请开启蓝牙":"请开启蓝牙",
- "请选择有效日":"请选择有效日"
+ "请选择有效日":"请选择有效日",
+ "公司名字长度不能小于 6 ": "公司名字长度不能小于 6 "
}
diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json
index 51476b7a..b83194c6 100755
--- a/images/lan/lan_zh.json
+++ b/images/lan/lan_zh.json
@@ -608,7 +608,7 @@
"卡详情": "卡详情",
"请输入": "请输入",
"关闭后,智能锁将设置为全天常开模式,直到手动关闭": "关闭后,智能锁将设置为全天常开模式,直到手动关闭",
- "请输入小于1000的数字": "请输入小于1000的数字",
+ "请输入小于或等于60的数字": "请输入小于或等于60的数字",
"操作成功": "操作成功",
"管理员密码相同,无需修改": "管理员密码相同,无需修改",
"修改密码": "修改密码",
@@ -753,7 +753,7 @@
"当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网": "当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网",
"胁迫指纹": "胁迫指纹",
"指纹列表": "指纹列表",
- "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网": "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网",
+ "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网": "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网。",
"打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。": "打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。",
"门未开时间": "门未开时间",
"添加和使用面容开锁时:": "添加和使用面容开锁时:",
@@ -815,6 +815,7 @@
"身份证号": "身份证号",
"请输入真实姓名": "请输入真实姓名",
"请输入身份证号": "请输入身份证号",
+ "请输入身份证号和真实姓名": "请输入身份证号和真实姓名",
"点击返回设备配对": "点击返回设备配对",
"无法连接?尝试升级": "无法连接?尝试升级",
"固件升级提示": "固件升级提示",
@@ -844,14 +845,15 @@
"操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。": "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。",
"如果是全自动锁,请使屏幕变亮": "如果是全自动锁,请使屏幕变亮",
"正在尝试闭锁……": "正在尝试闭锁……",
- "清空记录":"清空记录",
- "是否要删除操作记录?":"是否要删除操作记录?",
- "被删除的记录不能恢复":"被删除的记录不能恢复",
- "全部事件":"全部事件",
- "开锁事件":"开锁事件",
- "异常事件":"异常事件",
- "门铃事件":"门铃事件",
- "视频事件":"视频事件",
- "请开启蓝牙":"请开启蓝牙",
- "请选择有效日":"请选择有效日"
+ "清空记录": "清空记录",
+ "是否要删除操作记录?": "是否要删除操作记录?",
+ "被删除的记录不能恢复": "被删除的记录不能恢复",
+ "全部事件": "全部事件",
+ "开锁事件": "开锁事件",
+ "异常事件": "异常事件",
+ "门铃事件": "门铃事件",
+ "视频事件": "视频事件",
+ "请开启蓝牙": "请开启蓝牙",
+ "请选择有效日": "请选择有效日",
+ "公司名字长度不能小于 6 ": "公司名字长度不能小于 6 "
}
diff --git a/ios/Podfile.lock b/ios/Podfile.lock
index 1f76cd62..3ffb1e4d 100755
--- a/ios/Podfile.lock
+++ b/ios/Podfile.lock
@@ -36,6 +36,7 @@ PODS:
- Flutter
- auto_orientation (0.0.1):
- Flutter
+ - Bugly (2.6.1)
- camera_avfoundation (0.0.1):
- Flutter
- connectivity_plus (0.0.1):
@@ -81,6 +82,9 @@ PODS:
- Flutter (1.0.0)
- flutter_blue_plus (0.0.1):
- Flutter
+ - flutter_bugly_plugin (0.0.1):
+ - Bugly
+ - Flutter
- flutter_local_notifications (0.0.1):
- Flutter
- flutter_native_contact_picker (0.0.1):
@@ -170,6 +174,7 @@ DEPENDENCIES:
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- Flutter (from `Flutter`)
- flutter_blue_plus (from `.symlinks/plugins/flutter_blue_plus/ios`)
+ - flutter_bugly_plugin (from `.symlinks/plugins/flutter_bugly_plugin/ios`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- flutter_native_contact_picker (from `.symlinks/plugins/flutter_native_contact_picker/ios`)
- flutter_pcm_sound (from `.symlinks/plugins/flutter_pcm_sound/ios`)
@@ -205,6 +210,7 @@ SPEC REPOS:
- AMap3DMap
- AMapFoundation
- AMapLocation
+ - Bugly
- DKImagePickerController
- DKPhotoGallery
- GoogleMaps
@@ -248,6 +254,8 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_blue_plus:
:path: ".symlinks/plugins/flutter_blue_plus/ios"
+ flutter_bugly_plugin:
+ :path: ".symlinks/plugins/flutter_bugly_plugin/ios"
flutter_local_notifications:
:path: ".symlinks/plugins/flutter_local_notifications/ios"
flutter_native_contact_picker:
@@ -309,6 +317,7 @@ SPEC CHECKSUMS:
audio_session: 088d2483ebd1dc43f51d253d4a1c517d9a2e7207
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
auto_orientation: 102ed811a5938d52c86520ddd7ecd3a126b5d39d
+ Bugly: 217ac2ce5f0f2626d43dbaa4f70764c953a26a31
camera_avfoundation: 759172d1a77ae7be0de08fc104cfb79738b8a59e
connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d
device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed
@@ -318,12 +327,13 @@ SPEC CHECKSUMS:
file_picker: ce3938a0df3cc1ef404671531facef740d03f920
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_blue_plus: 4837da7d00cf5d441fdd6635b3a57f936778ea96
+ flutter_bugly_plugin: d2db6d6641938269fa538575126e8ff530ee02c7
flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
flutter_native_contact_picker: bd430ba0fbf82768bb50c2c52a69a65759a8f907
flutter_pcm_sound: de0572ca4f99091cc2abfcc31601b8a4ddd33c0e
flutter_voice_processor: 2b89b93d69b02227ae3fd58589ee0bcfa3ca2a82
fluttertoast: 9f2f8e81bb5ce18facb9748d7855bf5a756fe3db
- fluwx: daa284756ce53442b3d0417ceeda66e981906811
+ fluwx: c18fd6c16b03a2187cd07d6e48e32a7801962849
google_maps_flutter_ios: f135b968a67c05679e0a53538e900b5c174b0d99
GoogleMaps: 20d7b12be49a14287f797e88e0e31bc4156aaeb4
image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 4d5787d5..9266fd0f 100755
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -22,14 +22,59 @@
$(FLUTTER_BUILD_NAME)
CFBundleSignature
????
+ CFBundleURLTypes
+
+
+ CFBundleTypeRole
+ None
+ CFBundleURLIconFile
+
+ CFBundleURLName
+ com.sky.skysmartlock
+ CFBundleURLSchemes
+
+ skysmartlock
+
+
+
+
+
+ CFBundleTypeRole
+ Editor
+ CFBundleURLName
+ weixin
+ CFBundleURLSchemes
+
+ 123456
+
+
+
+ CFBundleTypeRole
+ Editor
+ CFBundleURLName
+ weixin
+ CFBundleURLSchemes
+
+ wxbe340095d2b8fd51
+
+
+
CFBundleVersion
$(FLUTTER_BUILD_NUMBER)
+ LSApplicationQueriesSchemes
+
+ weixin
+ weixinULAPI
+ weixinURLParamsAPI
+
LSRequiresIPhoneOS
NSAppTransportSecurity
NSAllowsArbitraryLoads
+ NSAllowsArbitraryLoadsInWebContent
+
NSExceptionDomains
jpush.cn
@@ -86,23 +131,6 @@
UIViewControllerBasedStatusBarAppearance
- CFBundleURLTypes
-
-
- CFBundleURLName
- com.sky.skysmartlock
- CFBundleURLSchemes
-
- skysmartlock
-
-
-
- CFBundleURLIconFile
-
- CFBundleTypeRole
- None
-
-
io.flutter.embedded_views_preview
diff --git a/lib/app.dart b/lib/app.dart
index a88fa173..f674b529 100755
--- a/lib/app.dart
+++ b/lib/app.dart
@@ -11,7 +11,6 @@ import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart';
import 'package:star_lock/tools/app_manager.dart';
import 'package:star_lock/tools/bindings/app_binding.dart';
import 'package:star_lock/tools/storage.dart';
-import 'package:star_lock/tools/xs_jPhush.dart';
import 'package:star_lock/translations/app_dept.dart';
import 'package:star_lock/translations/trans_lib.dart';
@@ -19,7 +18,6 @@ import 'package:star_lock/translations/trans_lib.dart';
import 'appRouters.dart';
import 'baseWidget.dart';
import 'tools/appRouteObserver.dart';
-import 'dart:io';
import 'tools/store_service.dart';
@@ -38,24 +36,25 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget {
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: const Size(585, 1265),
- builder: (w, a) => _initMaterialApp());
+ builder: (BuildContext w, Widget? a) => _initMaterialApp());
}
GetMaterialApp _initMaterialApp() => GetMaterialApp(
// enableLog: false,
title: F.navTitle,
- navigatorObservers: [AppRouteObserver().routeObserver],
+ navigatorObservers: [AppRouteObserver().routeObserver],
translations: TranslationMessage(),
supportedLocales: appDept.deptSupportedLocales,
- localizationsDelegates: const [
+ localizationsDelegates: const >[
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
- localeResolutionCallback: (locale, supportedLocales) {
+ localeResolutionCallback:
+ (Locale? locale, Iterable supportedLocales) {
if (!supportedLocales.contains(locale)) {
- int idx = appSupportedLocales.indexWhere(
- (element) => element.languageCode == locale!.languageCode);
+ final int idx = appSupportedLocales.indexWhere(
+ (Locale element) => element.languageCode == locale!.languageCode);
if (idx != -1) {
locale = appSupportedLocales[idx];
} else {
@@ -68,7 +67,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget {
},
locale: StoreService.to.getLanguageCode()!.isNotEmpty
? appDept.deptSupportedLocales
- .where((element) =>
+ .where((Locale element) =>
element.languageCode == StoreService.to.getLanguageCode())
.first
: Get.deviceLocale,
@@ -148,7 +147,7 @@ class _MyAppState extends State with WidgetsBindingObserver, BaseWidget {
}
Future getLoginStatus() async {
- final data = await Storage.getString(saveUserLoginData);
+ final String? data = await Storage.getString(saveUserLoginData);
if (data != null && data.isNotEmpty) {
return true;
}
diff --git a/lib/appRouters.dart b/lib/appRouters.dart
index f415e1aa..d2d4e3c3 100755
--- a/lib/appRouters.dart
+++ b/lib/appRouters.dart
@@ -42,7 +42,8 @@ import 'package:star_lock/mine/about/webviewShow_page.dart';
import 'package:star_lock/mine/mine/safeVerify/safeVerify_page.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_page.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoViewSafetyProblem/minePersonInfoViewSafetyProblem_page.dart';
-import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_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/administratorDetails/administratorDetails_page.dart';
import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart';
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockManage_page.dart';
@@ -373,7 +374,8 @@ abstract class Routers {
static const getDeviceListPage = '/getDeviceListPage'; //设备列表
static const getNameListPage = '/getNameListPage'; //姓名列表
static const authorityManagementPage = '/authorityManagementPage'; //批量授权
- static const massSendLockGroupListPage = '/massSendLockGroupListPage'; //群发锁分组列表
+ static const massSendLockGroupListPage =
+ '/massSendLockGroupListPage'; //群发锁分组列表
static const massSendReceiverPage = '/massSendReceiverPage'; //群发接收人
static const lockUserListPage = '/lockUserListPage'; //锁用户列表
static const administratorDetailsPage = '/administratorDetailsPage'; //管理员详情
@@ -447,6 +449,8 @@ abstract class Routers {
static const advancedFeaturesWebPage = '/advancedFeaturesWebPage'; // 高级功能
static const advancedFunctionRecordPage =
'/advancedFunctionRecordPage'; //高级功能购买记录
+ static const String administratorAssociationLockPage =
+ '/administratorAssociationLockPage'; //我的设置-授权管理员-关联锁
}
abstract class AppRouters {
@@ -1069,5 +1073,8 @@ abstract class AppRouters {
GetPage(
name: Routers.advancedFunctionRecordPage,
page: (() => const AdvancedFunctionRecordPage())),
+ GetPage(
+ name: Routers.administratorAssociationLockPage,
+ page: () => const AdministratorAssociationLockPage()),
];
}
diff --git a/lib/app_settings/app_settings.dart b/lib/app_settings/app_settings.dart
index 7998bf68..f03b8cf1 100755
--- a/lib/app_settings/app_settings.dart
+++ b/lib/app_settings/app_settings.dart
@@ -4,38 +4,42 @@ import 'dart:io';
import 'package:star_lock/mine/about/debug/debug_console.dart';
-
class AppLog {
static bool _printLog = false;
static bool _onlyError = false;
- static showLog({required bool printLog, bool? onlyError}){
+ static void showLog({required bool printLog, bool? onlyError}) {
_printLog = printLog;
_onlyError = onlyError ?? false;
}
- static log(String msg,{bool? error}){
+
+ static void log(String msg, {StackTrace? stackTrace, bool? error}) {
msg = '${DateTime.now().toIso8601String()} : $msg';
- DebugConsole.info(msg);
- if(!kDebugMode)return;
+ DebugConsole.info(msg, stackTrace: stackTrace, isErr: error ?? false);
+ if (!kDebugMode) {
+ return;
+ }
error = error ?? false;
// if(!_printLog)return;
// if(_onlyError && !error) return;
- if(error){
- msg = '----->>> $msg';
+ if (error) {
+ final bool stackTraceIsNull = stackTrace != null;
+ msg = '----->>> $msg ${stackTraceIsNull ? '\n$stackTrace' : ''}';
}
Get.log(msg);
}
}
class AppPlatform {
- static bool isIOS = Platform.isIOS;
- static bool isAndroid = Platform.isAndroid;
- static String platformString(){
+ static bool isIOS = Platform.isIOS;
+ static bool isAndroid = Platform.isAndroid;
+
+ static String platformString() {
String name = 'unknown';
- if(isIOS){
+ if (isIOS) {
name = 'iOS';
}
- if(isAndroid){
+ if (isAndroid) {
name = 'Android';
}
return name;
@@ -44,50 +48,59 @@ class AppPlatform {
static String _brand = 'unknown';
static int _sdkInt = 23;
- static void setBrandString(String brand){
+ static void setBrandString(String brand) {
_brand = brand;
}
- static String getBrandString()=>_brand;
- static void setSDKInt(int sdkInt){
+
+ static String getBrandString() => _brand;
+
+ static void setSDKInt(int sdkInt) {
_sdkInt = sdkInt;
}
- static bool isSamsung()=>_brand.toLowerCase().contains('samsung');
- static int getSdkIntValue()=>_sdkInt;
- static bool onlyCanNetUpgrade()=>isSamsung() && (getSdkIntValue() >= 29);
+ static bool isSamsung() => _brand.toLowerCase().contains('samsung');
+
+ static int getSdkIntValue() => _sdkInt;
+
+ static bool onlyCanNetUpgrade() => isSamsung() && (getSdkIntValue() >= 29);
}
class AppMowerCodes {
- static int idCodeLength(){
+ static int idCodeLength() {
int len = 19;
return len;
}
+
static int fenceNameLength = 8;
static int registerCodeLength = 4;
}
class AppDate {
static String dateString() {
- return '${year()}-${month().toString().padLeft(2,'0')}-${day().toString()
- .padLeft(2,'0')}';
+ return '${year()}-${month().toString().padLeft(2, '0')}-${day().toString().padLeft(2, '0')}';
}
static String calendarString() {
- String temp = '${year()}${month().toString().padLeft(2,'0')}${day().toString()
- .padLeft(2,'0')}${hour().toString().padLeft(2,'0')}${second()
- .toString().padLeft(2,'0')}';
+ String temp =
+ '${year()}${month().toString().padLeft(2, '0')}${day().toString().padLeft(2, '0')}${hour().toString().padLeft(2, '0')}${second().toString().padLeft(2, '0')}';
return temp;
}
- static int year()=>DateTime.now().year;
- static int month()=>DateTime.now().month;
- static int day()=>DateTime.now().day;
- static int hour()=>DateTime.now().hour;
- static int minute()=>DateTime.now().minute;
- static int second()=>DateTime.now().second;
- static int weekDay()=>DateTime.now().weekday;
- static int timeZeroOffset()=>DateTime.now().timeZoneOffset.inHours;
+ static int year() => DateTime.now().year;
+ static int month() => DateTime.now().month;
+
+ static int day() => DateTime.now().day;
+
+ static int hour() => DateTime.now().hour;
+
+ static int minute() => DateTime.now().minute;
+
+ static int second() => DateTime.now().second;
+
+ static int weekDay() => DateTime.now().weekday;
+
+ static int timeZeroOffset() => DateTime.now().timeZoneOffset.inHours;
}
//TODO:错误类型
@@ -99,9 +112,9 @@ enum ErrorType {
}
class AppErrorCode {
- static int errorCode(ErrorType type){
+ static int errorCode(ErrorType type) {
int code = 0;
- switch(type){
+ switch (type) {
case ErrorType.modeNotMatch:
code = 1;
break;
@@ -118,8 +131,3 @@ class AppErrorCode {
return code;
}
}
-
-
-
-
-
diff --git a/lib/blue/blue_manage.dart b/lib/blue/blue_manage.dart
index 223fe584..5ae2f0df 100755
--- a/lib/blue/blue_manage.dart
+++ b/lib/blue/blue_manage.dart
@@ -1,13 +1,9 @@
import 'dart:async';
import 'dart:io';
-import 'package:app_settings/app_settings.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_settings.dart';
-import 'package:star_lock/tools/showTipView.dart';
-import 'package:star_lock/widget/permission/permission_dialog.dart';
-import 'package:url_launcher/url_launcher.dart';
import 'io_tool/io_model.dart';
import 'io_tool/io_tool.dart';
@@ -21,39 +17,39 @@ typedef ConnectStateCallBack = Function(
typedef ScanDevicesCallBack = Function(List);
class BlueManage {
- final List scanDevices = [];
+
+ factory BlueManage() => shareManager()!;
+
+ BlueManage._init() {
+ _initBlue();
+ }
+ final List scanDevices = [];
// 用来写入的服务id
- final Guid _serviceIdConnect = Guid("fff0");
+ final Guid _serviceIdConnect = Guid('fff0');
// 用来写入的服务id
final Guid _serviceIdWrite = Guid('0000FFF0-0000-1000-8000-00805F9B34FB');
// 用来订阅的特征id
- final Guid _characteristicIdSubscription = Guid("fff1");
+ final Guid _characteristicIdSubscription = Guid('fff1');
// 用来写入的特征id
- final Guid _characteristicIdWrite = Guid("fff2");
+ final Guid _characteristicIdWrite = Guid('fff2');
// 监听发送事件
StreamSubscription? _sendStreamSubscription;
- // 监听蓝牙扫描的事件
- // StreamSubscription? _scanSubscription;
- // 监听蓝牙连接的事件
- // StreamSubscription? _currentConnectionStream;
-
- // StreamSubscription>? _scanResultsSubscription;
StreamSubscription? _connectionStateSubscription;
StreamSubscription? _mtuSubscription;
int? _mtuSize = 20;
// 当前连接设备的名字
- String connectDeviceName = "";
+ String connectDeviceName = '';
// 当前连接设备的mac地址
- String connectDeviceMacAddress = "";
+ String connectDeviceMacAddress = '';
// 当前连接的设备
BluetoothDevice? bluetoothConnectDevice;
@@ -68,11 +64,14 @@ class BlueManage {
BluetoothAdapterState? _adapterState = BluetoothAdapterState.unknown;
StreamSubscription? _adapterStateStateSubscription;
- static BlueManage? _manager;
+ // 听上报来的数据,参数来自前面扫描到的结果
+ List allData = [];
- BlueManage._init() {
- _initBlue();
- }
+ // 保存上一次的数据,用来判断是否收到重复的数据
+ List lastTimeData = [];
+ int? dataLen;
+
+ static BlueManage? _manager;
static BlueManage? shareManager() {
_manager ??= BlueManage._init();
@@ -80,20 +79,16 @@ class BlueManage {
return _manager;
}
- factory BlueManage() => shareManager()!;
-
BlueManage? get manager => shareManager();
void _initBlue() {
FlutterBluePlus.setLogLevel(LogLevel.error, color: true);
_initSendStreamSubscription();
_initAdapterStateStateSubscription();
- // _initListenscanResults();
- // _initListenConnectionState();
}
void _initGetMtuSubscription() {
- _mtuSubscription ??= bluetoothConnectDevice!.mtu.listen((value) {
+ _mtuSubscription ??= bluetoothConnectDevice!.mtu.listen((int value) {
_mtuSize = value - 3;
AppLog.log('_mtuSizeValue:$value mtuSize:$_mtuSize');
});
@@ -101,56 +96,17 @@ class BlueManage {
void _initAdapterStateStateSubscription() {
_adapterStateStateSubscription ??=
- FlutterBluePlus.adapterState.listen((state) {
+ FlutterBluePlus.adapterState.listen((BluetoothAdapterState state) {
_adapterState = state;
});
}
- // void _initListenscanResults() {
- // var subscription = FlutterBluePlus.scanResults.listen((results) {
- // scanDevices.clear();
- // for (var scanResult in results) {
- // // 判断名字为空的直接剔除
- // // if (scanResult.device.advName.isEmpty) {
- // // return;
- // // }
- // AppLog.log("scanResult.device.advName:${scanResult.device.advName}"
- // " scanResult.advertisementData.serviceUuids:${scanResult.advertisementData.serviceUuids}"
- // " rssi:${scanResult.rssi}");
- // if (((scanResult.advertisementData.serviceUuids.isNotEmpty ? scanResult.advertisementData.serviceUuids[0] : "").toString().contains("758824")) && (scanResult.rssi >= -100)) {
- // // 查询id相同的元素
- // final knownDeviceIndex = scanDevices.indexWhere((d) => d.advertisementData.advName == scanResult.advertisementData.advName);
- // // 不存在的时候返回-1
- // if (knownDeviceIndex >= 0) {
- // scanDevices[knownDeviceIndex] = scanResult;
- // } else {
- // scanDevices.add(scanResult);
- // }
- // }
- // }
- // EventBusManager().eventBusFir(scanDevices);
- // // FlutterBluePlus.stopScan();
- // }, onError: (e) {
- // AppLog.log("Scan Error:$e", );
- // });
- //
- // FlutterBluePlus.cancelWhenScanComplete(subscription);
-
- // FlutterBluePlus.isScanning.listen((state) {
- // if (state) {
- // prAppLog.logint('Scanning');
- // } else {
- // AppLog.log('Not scanning');
- // }
- // });
- // }
-
void _initListenConnectionState() {
_connectionStateSubscription?.cancel();
_connectionStateSubscription = null;
- _connectionStateSubscription =
- bluetoothConnectDevice!.connectionState.listen((state) async {
+ _connectionStateSubscription = bluetoothConnectDevice!.connectionState
+ .listen((BluetoothConnectionState state) async {
bluetoothConnectionState = state;
// AppLog.log("蓝牙连接状态:$state");
});
@@ -162,18 +118,18 @@ class BlueManage {
.on()
.listen((EventSendModel model) {
if (model.sendChannel == DataChannel.ble) {
- FlutterBluePlus.isSupported.then((isAvailable) async {
+ FlutterBluePlus.isSupported.then((bool isAvailable) async {
if (isAvailable) {
if (_adapterState == BluetoothAdapterState.on) {
// 蓝牙已开启,可以进行蓝牙操作
writeCharacteristicWithResponse(model.data);
} else {
try {} catch (e) {
- AppLog.log("蓝牙打开失败");
+ AppLog.log('蓝牙打开失败');
}
}
} else {
- AppLog.log("写入数据 蓝牙不可用,不能进行蓝牙操作");
+ AppLog.log('写入数据 蓝牙不可用,不能进行蓝牙操作');
}
});
}
@@ -183,31 +139,44 @@ class BlueManage {
/// 开始指定设备名称的扫描蓝牙设备
Future startScanSingle(String deviceName, int timeout,
ScanDevicesCallBack scanDevicesCallBack) async {
- FlutterBluePlus.isSupported.then((isAvailable) async {
+ final DateTime start = DateTime.now();
+ FlutterBluePlus.isSupported.then((bool isAvailable) async {
if (isAvailable) {
if (_adapterState == BluetoothAdapterState.on) {
try {
- FlutterBluePlus.startScan(timeout: Duration(seconds: timeout));
- Completer completer = Completer();
- var subscription = FlutterBluePlus.scanResults.listen((results) {
- // AppLog.log("startScanSingle扫描到的设备:$results");
- bool isExit = results.any((element) =>
+ //android 扫描比较慢,取样只要 8 分之一
+ final int divisor = Platform.isAndroid ? 3 : 1;
+ FlutterBluePlus.startScan(
+ continuousDivisor: divisor,
+ continuousUpdates: true,
+ // withServiceData:[ServiceDataFilter()],
+ withKeywords: [deviceName],
+ timeout: Duration(seconds: timeout));
+ final Completer completer = Completer();
+ final StreamSubscription> subscription =
+ FlutterBluePlus.scanResults.listen((List results) {
+ final bool isExit = results.any((ScanResult element) =>
(element.device.platformName == deviceName) ||
(element.advertisementData.advName == deviceName));
+ final int milliseconds = DateTime.now().millisecondsSinceEpoch -
+ start.millisecondsSinceEpoch;
+ AppLog.log(
+ '扫描到的设备数:${results.length} 是否查找到 $isExit 以查找$milliseconds毫秒');
if (isExit) {
- for (var scanResult in results) {
+ for (final ScanResult scanResult in results) {
if (((scanResult.advertisementData.serviceUuids.isNotEmpty
? scanResult.advertisementData.serviceUuids[0]
- : "")
+ : '')
.toString()
- .contains("758824")) &&
+ .contains('758824')) &&
(scanResult.rssi >= -100)) {
// 查询id相同的元素
- final knownDeviceIndex = scanDevices.indexWhere((d) =>
- (d.device.platformName ==
- scanResult.device.platformName) ||
- (d.advertisementData.advName ==
- scanResult.advertisementData.advName));
+ final int knownDeviceIndex = scanDevices.indexWhere(
+ (ScanResult d) =>
+ (d.device.platformName ==
+ scanResult.device.platformName) ||
+ (d.advertisementData.advName ==
+ scanResult.advertisementData.advName));
// 不存在的时候返回-1
if (knownDeviceIndex >= 0) {
scanDevices[knownDeviceIndex] = scanResult;
@@ -216,11 +185,12 @@ class BlueManage {
}
}
}
+
completer.complete();
}
}, onError: (e) {
AppLog.log(
- "扫描失败:$e",
+ '扫描失败:$e',
);
});
FlutterBluePlus.cancelWhenScanComplete(subscription);
@@ -228,7 +198,7 @@ class BlueManage {
scanDevicesCallBack(scanDevices);
subscription.cancel();
} catch (e) {
- AppLog.log("扫描失败");
+ AppLog.log('扫描失败');
}
} else {
try {
@@ -236,11 +206,11 @@ class BlueManage {
await FlutterBluePlus.turnOn();
}
} catch (e) {
- AppLog.log("蓝牙打开失败");
+ AppLog.log('蓝牙打开失败');
}
}
} else {
- AppLog.log("开始扫描 蓝牙不可用,不能进行蓝牙操作");
+ AppLog.log('开始扫描 蓝牙不可用,不能进行蓝牙操作');
}
});
}
@@ -248,34 +218,29 @@ class BlueManage {
/// 开始扫描蓝牙设备
Future startScan(int timeout, ScanDevicesCallBack scanDevicesCallBack,
{List? idList}) async {
- FlutterBluePlus.isSupported.then((isAvailable) async {
+ FlutterBluePlus.isSupported.then((bool isAvailable) async {
if (isAvailable) {
if (_adapterState == BluetoothAdapterState.on) {
try {
FlutterBluePlus.startScan(timeout: Duration(seconds: timeout));
-
- var subscription = FlutterBluePlus.scanResults.listen((results) {
+ final StreamSubscription> subscription =
+ FlutterBluePlus.scanResults.listen((List results) {
scanDevices.clear();
- for (var scanResult in results) {
+ for (final ScanResult scanResult in results) {
// 判断名字为空的直接剔除
- // if (scanResult.device.advName.isEmpty) {
- // return;
- // }
- // AppLog.log("scanResult.device.advName:${scanResult.device.advName}"
- // " scanResult.advertisementData.serviceUuids:${scanResult.advertisementData.serviceUuids}"
- // " rssi:${scanResult.rssi}");
if (((scanResult.advertisementData.serviceUuids.isNotEmpty
? scanResult.advertisementData.serviceUuids[0]
- : "")
+ : '')
.toString()
- .contains("758824")) &&
+ .contains('758824')) &&
(scanResult.rssi >= -100)) {
// 查询id相同的元素
- final knownDeviceIndex = scanDevices.indexWhere((d) =>
- (d.device.platformName ==
- scanResult.device.platformName) ||
- (d.advertisementData.advName ==
- scanResult.advertisementData.advName));
+ final int knownDeviceIndex = scanDevices.indexWhere(
+ (ScanResult d) =>
+ (d.device.platformName ==
+ scanResult.device.platformName) ||
+ (d.advertisementData.advName ==
+ scanResult.advertisementData.advName));
// 不存在的时候返回-1
if (knownDeviceIndex >= 0) {
scanDevices[knownDeviceIndex] = scanResult;
@@ -284,32 +249,16 @@ class BlueManage {
}
}
}
-
- // String listStr = scanDevices
- // .where((element) =>
- // element.advertisementData.advName == 'TMH_dc8f928369ed' ||
- // element.device.platformName == 'TMH_dc8f928369ed')
- // .map((e) => 'advName:${e.advertisementData.advName} '
- // 'serviceUuids:${e.advertisementData.serviceUuids} '
- // '是否被重置:${e.advertisementData.serviceUuids[0].toString()[31]}')
- // .join(',')
- // .toString();
- // if (listStr.trim() != '') {
- // AppLog.log('--->扫描到的设备 ${listStr} ');
- // }
-
scanDevicesCallBack(scanDevices);
- // EventBusManager().eventBusFir(scanDevices);
- // FlutterBluePlus.stopScan();
}, onError: (e) {
AppLog.log(
- "扫描失败:$e",
+ '扫描失败:$e',
);
});
FlutterBluePlus.cancelWhenScanComplete(subscription);
} catch (e) {
- AppLog.log("扫描失败");
+ AppLog.log('扫描失败');
}
} else {
try {
@@ -317,25 +266,27 @@ class BlueManage {
await FlutterBluePlus.turnOn();
}
} catch (e) {
- AppLog.log("蓝牙打开失败");
+ AppLog.log('蓝牙打开失败');
}
}
} else {
- AppLog.log("开始扫描 蓝牙不可用,不能进行蓝牙操作");
+ AppLog.log('开始扫描 蓝牙不可用,不能进行蓝牙操作');
}
});
}
/// 调用发送数据 List senderData,
- Future bludSendData(
+ Future blueSendData(
String deviceName, ConnectStateCallBack stateCallBack,
{bool isAddEquipment = false}) async {
- FlutterBluePlus.isSupported.then((isAvailable) async {
+ FlutterBluePlus.isSupported.then((bool isAvailable) async {
if (isAvailable) {
+ AppLog.log(
+ '蓝牙状态 系统蓝牙状态:$_adapterState 蓝牙连接状态:$bluetoothConnectionState');
if (_adapterState == BluetoothAdapterState.on) {
// 蓝牙已开启,可以进行蓝牙操作
if (bluetoothConnectionState != BluetoothConnectionState.connected) {
- _connect(deviceName, (state) {
+ _connect(deviceName, (BluetoothConnectionState state) {
stateCallBack(bluetoothConnectionState!);
}, isAddEquipment: isAddEquipment);
} else {
@@ -346,11 +297,11 @@ class BlueManage {
stateCallBack(BluetoothConnectionState.disconnected);
openBlue();
} catch (e) {
- AppLog.log("蓝牙打开失败");
+ AppLog.log('蓝牙打开失败');
}
}
} else {
- AppLog.log("开始扫描 蓝牙不可用,不能进行蓝牙操作");
+ AppLog.log('开始扫描 蓝牙不可用,不能进行蓝牙操作');
}
});
}
@@ -360,13 +311,11 @@ class BlueManage {
String deviceName, ConnectStateCallBack connectStateCallBack,
{bool isAddEquipment = false}) async {
connectDeviceName = deviceName;
- List devicesList = scanDevices;
+ final List devicesList = scanDevices;
- bool isExistDevice = scanDevices.any((element) =>
- element.device.platformName == connectDeviceName ||
- element.advertisementData.advName == connectDeviceName);
+ final bool isExistDevice = isExistScanDevices(connectDeviceName);
- if (isAddEquipment == false || isExistDevice == false) {
+ if (isAddEquipment == false && isExistDevice == false) {
//取消缓存直接使用,存在配对场景设备信息会更变
startScanSingle(deviceName, 10, (List scanDevices) {
_connectDevice(scanDevices, deviceName, connectStateCallBack,
@@ -378,12 +327,20 @@ class BlueManage {
}
}
+ //查找缓存里面是否有设备
+ bool isExistScanDevices(String connectDeviceName) {
+ final bool isExistDevice = scanDevices.any((ScanResult element) =>
+ element.device.platformName == connectDeviceName ||
+ element.advertisementData.advName == connectDeviceName);
+ return isExistDevice;
+ }
+
Future _connectDevice(List devicesList, String deviceName,
ConnectStateCallBack connectStateCallBack,
{bool isAddEquipment = false}) async {
// 判断数组列表里面是否有这个设备
// AppLog.log("devicesList:$devicesList");
- final knownDeviceIndex = devicesList.indexWhere((d) =>
+ final int knownDeviceIndex = devicesList.indexWhere((ScanResult d) =>
(d.device.platformName == deviceName) ||
(d.advertisementData.advName == deviceName));
@@ -402,25 +359,21 @@ class BlueManage {
_initGetMtuSubscription();
_initListenConnectionState();
}
- // AppLog.log("1 connectDeviceId:$connectDeviceMacAddress connectDeviceName:$connectDeviceName");
- // stopScan();
if (scanResult == null || connectDeviceMacAddress.isEmpty) {
- // connectStateCallBack(BluetoothConnectionState.disconnected!);
return;
}
-
// AppLog.log("调用了停止扫描的方法");
await stopScan();
- if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == "0") &&
+ if ((scanResult.advertisementData.serviceUuids[0].toString()[31] == '0') &&
isAddEquipment == false) {
connectStateCallBack(BluetoothConnectionState.disconnected);
- EasyLoading.showToast("该锁已被重置".tr, duration: 2000.milliseconds);
+ EasyLoading.showToast('该锁已被重置'.tr, duration: 2000.milliseconds);
return;
}
// 重连三次
- int maxAttempts = 3;
+ const int maxAttempts = 3;
int attempt = 0;
while (attempt < maxAttempts) {
try {
@@ -440,26 +393,18 @@ class BlueManage {
connectStateCallBack(BluetoothConnectionState.disconnected);
}
- // await bluetoothConnectDevice!.connect();
if (bluetoothConnectionState == BluetoothConnectionState.connected) {
try {
- bluetoothConnectDevice!.discoverServices().then((services) {
- for (BluetoothService service in services) {
- // AppLog.log("11111service.remoteId:${service.remoteId}"
- // " service.uuid:${service.uuid}"
- // " service.characteristics:${service.characteristics}"
- // " service.includedServices:${service.includedServices}");
+ bluetoothConnectDevice!
+ .discoverServices()
+ .then((List services) {
+ for (final BluetoothService service in services) {
if (service.uuid == _serviceIdConnect) {
- for (BluetoothCharacteristic characteristic
+ for (final BluetoothCharacteristic characteristic
in service.characteristics) {
- // Get.log("22222characteristic.remoteId:${characteristic.remoteId}"
- // " characteristic.uuid:${characteristic.uuid}"
- // " characteristic.secondaryServiceUuid:${characteristic.secondaryServiceUuid}"
- // " characteristic.characteristicUuid:${characteristic.characteristicUuid}");
if (characteristic.characteristicUuid ==
_characteristicIdSubscription) {
_subScribeToCharacteristic(characteristic);
- // AppLog.log('Discovering services finished');
bluetoothConnectionState = BluetoothConnectionState.connected;
connectStateCallBack(bluetoothConnectionState!);
}
@@ -477,47 +422,41 @@ class BlueManage {
}
}
- // 听上报来的数据,参数来自前面扫描到的结果
- var allData = [];
- // 保存上一次的数据,用来判断是否收到重复的数据
- var lastTimeData = [];
- int? dataLen;
- _subScribeToCharacteristic(BluetoothCharacteristic characteristic) async {
- final subscription = characteristic.onValueReceived.listen((data) {
- // AppLog.log("订阅获取的数据:$data");
+ Future _subScribeToCharacteristic(
+ BluetoothCharacteristic characteristic) async {
+ final StreamSubscription> subscription =
+ characteristic.onValueReceived.listen((List data) {
+ AppLog.log('订阅获取的数据: $data ');
if (data == lastTimeData || data.isEmpty) {
return;
} else {
lastTimeData = data;
}
- // code to handle incoming data
- // AppLog.log("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data");
- if ((data[0] == 0xEF) &&
- (data[1] == 0x01) &&
- (data[2] == 0xEE) &&
- (data[3] == 0x02)) {
+ final bool dataHeadCorrect = isDataHeadCorrect(data);
+ final bool allDataHeadCorrect = isDataHeadCorrect(allData);
+ if (dataHeadCorrect && allDataHeadCorrect) {
+ //缓存数据和新数据都有包头,直接放弃缓存数据
+ allData = [];
+ }
+ if (dataHeadCorrect) {
// 当包有头时
// 判断是否需要分包
dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度
- // AppLog.log("dataLen1111:$dataLen getDataLength:${data.length} data:$data");
if (dataLen! + 14 > data.length) {
// 当前包的长度小于实际的包时 分包添加 不解析
allData.addAll(data);
} else {
// 当前包的长度小于实际的包时 不分包 解析
allData.addAll(data);
- // AppLog.log("dataLen2222:$dataLen getDataLength:${data.length}");
CommandReciverManager.appDataReceive(allData);
// 发送完解析初始化数组
allData = [];
}
- } else {
+ } else if (allDataHeadCorrect) {
// 当包没有头时 是分包的包 直接添加
allData.addAll(data);
- // var len = allData[8] * 256 + allData[9];
- // AppLog.log("dataLen3333:$dataLen allData.length:${allData.length} allData:$allData");
if (((dataLen ?? 0) + 14) <= allData.length) {
// 当长度小于等于当前包的数据时 直接解析数据
CommandReciverManager.appDataReceive(allData);
@@ -526,100 +465,46 @@ class BlueManage {
}
}
});
-
-// cleanup: cancel subscription when disconnected
bluetoothConnectDevice!.cancelWhenDisconnected(subscription);
-
-// enable notifications
await characteristic.setNotifyValue(true);
+ }
- // characteristic.setNotifyValue(true).then((_) {
- // AppLog.log("启动对特性的通知。当特性的值发生变化时,设备会发送一个通知");
- // characteristic.lastValueStream.listen((data) {
- // AppLog.log("订阅获取的数据:$data");
- // // do something with new value
- // if(data == lastTimeData || data.isEmpty){
- // return;
- // }else{
- // lastTimeData = data;
- // }
- // // code to handle incoming data
- // // AppLog.log("subscribeToCharacteristic: deviceId = ${characteristic.deviceId} characteristicId =${characteristic.characteristicId}---上报来的数据data = $data");
- // if ((data[0] == 0xEF) && (data[1] == 0x01) && (data[2] == 0xEE) && (data[3] == 0x02)) {
- // // 当包有头时
- // // 判断是否需要分包
- // dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度
- // // AppLog.log("dataLen1111:$dataLen getDataLength:${data.length}");
- // if (dataLen! + 12 > data.length) {
- // // 当前包的长度小于实际的包时 分包添加 不解析
- // allData.addAll(data);
- // } else {
- // // 当前包的长度小于实际的包时 不分包 解析
- // allData.addAll(data);
- // // AppLog.log("dataLen2222:$dataLen getDataLength:${data.length}");
- // CommandReciverManager.appDataReceive(allData);
- // // 发送完解析初始化数组
- // allData = [];
- // }
- // } else {
- // // 当包没有头时 是分包的包 直接添加
- // allData.addAll(data);
- // // var len = allData[8] * 256 + allData[9];
- // // AppLog.log("dataLen3333:$dataLen");
- // if ((dataLen! + 14) <= allData.length) {
- // // AppLog.log("44444数据被解析了");
- // // 当长度小于等于当前包的数据时 直接解析数据
- // CommandReciverManager.appDataReceive(allData);
- // // 发送完解析初始化数组
- // allData = [];
- // }
- // }
- // });
- // });
+ //判断数据头是否正确
+ bool isDataHeadCorrect(List data) {
+ if (data.length < 4) {
+ return false;
+ }
+ //239, 1, 238, 2, 是数据包头
+ if ((data[0] == 0xEF) &&
+ (data[1] == 0x01) &&
+ (data[2] == 0xEE) &&
+ (data[3] == 0x02)) {
+ return true;
+ } else {
+ return false;
+ }
}
// 写入
Future writeCharacteristicWithResponse(List value) async {
- List services =
+ final List services =
await bluetoothConnectDevice!.discoverServices();
- for (BluetoothService service in services) {
- // AppLog.log("33333 service.remoteId:${service.remoteId}"
- // " service.uuid:${service.uuid}\n\n"
- // " service.characteristics:${service.characteristics}\n\n"
- // " service.includedServices:${service.includedServices}");
+ for (final BluetoothService service in services) {
if (service.uuid == _serviceIdConnect) {
- for (BluetoothCharacteristic characteristic
+ for (final BluetoothCharacteristic characteristic
in service.characteristics) {
- // AppLog.log("44444 characteristic.remoteId:${characteristic.remoteId}"
- // " characteristic.uuid:${characteristic.uuid}\n\n"
- // " characteristic.secondaryServiceUuid:${characteristic
- // .secondaryServiceUuid}\n\n"
- // " characteristic.characteristicUuid:${characteristic
- // .characteristicUuid}");
if (characteristic.characteristicUuid == _characteristicIdWrite) {
try {
- List valueList = value;
- List subData = splitList(valueList, _mtuSize!);
+ final List valueList = value;
+ final List subData = splitList(valueList, _mtuSize!);
// AppLog.log('writeCharacteristicWithResponse _mtuSize:$_mtuSize 得到的分割数据:$subData');
for (int i = 0; i < subData.length; i++) {
if (characteristic.properties.writeWithoutResponse) {
// 使用WRITE_NO_RESPONSE属性写入值
- await characteristic
- .write(subData[i], withoutResponse: true)
- .then((value) async {
- // await Future.delayed(const Duration(milliseconds: 1)).then((
- // value) async {
- // AppLog.log('分包发送成功了');
- // });
- });
+ await characteristic.write(subData[i], withoutResponse: true);
} else if (characteristic.properties.write) {
// 使用WRITE属性写入值
- await characteristic.write(subData[i]).then((value) async {
- // await Future.delayed(const Duration(milliseconds: 1)).then((
- // value) async {
- // AppLog.log('分包发送成功了');
- // });
- });
+ await characteristic.write(subData[i]);
} else {
// 特性不支持写入
throw Exception(
@@ -634,122 +519,45 @@ class BlueManage {
}
}
}
- // List services = await bluetoothConnectDevice!.discoverServices();
- // BluetoothCharacteristic characteristic = services
- // .firstWhere((service) => service.uuid == _serviceIdWrite)
- // .characteristics
- // .firstWhere((char) => char.uuid == _characteristicIdWrite);
- // try {
- // List valueList = value;
- // List subData = splitList(valueList, _mtuSize!);
- // AppLog.log('writeCharacteristicWithResponse 得到的分割数据:$subData');
- //
- // for (int i = 0; i < subData.length; i++) {
- // await characteristic.write(subData[i]).then((value) async {
- // await Future.delayed(const Duration(milliseconds: 1)).then((value) async {
- // AppLog.log('分包发送成功了');
- // });
- // });
- // }
- // } on Exception catch (e, s) {
- // AppLog.log('Error occurred when writing: $e');
- // AppLog.log(s);
- // rethrow;
- // }
}
- // 写入
- Future writeNull() async {
- List services =
- await bluetoothConnectDevice!.discoverServices();
- for (BluetoothService service in services) {
- if (service.uuid == _serviceIdConnect) {
- for (BluetoothCharacteristic characteristic
- in service.characteristics) {
- if (characteristic.characteristicUuid == _characteristicIdWrite) {
- try {
- List valueList = [1];
- AppLog.log('APP写入 writeNull ');
- await characteristic.write(valueList);
- } on Exception catch (e, s) {
- AppLog.log('APP写入失败 writeNull : $e $s');
- rethrow;
- }
- }
- }
- }
- }
- }
-
- // 读取
- // Future> _readCharacteristic(QualifiedCharacteristic characteristic) async {
- // try {
- // final result =
- // await _flutterReactiveBle!.readCharacteristic(characteristic);
- // AppLog.log("readListresult$result");
- // return result;
- // } on Exception catch (e, s) {
- // AppLog.log(
- // 'Error occurred when reading ${characteristic.characteristicId} : $e',
- // );
- // rethrow;
- // }
- // }
-
- // Future writeCharacteristicWithoutResponse(
- // QualifiedCharacteristic characteristic, List value) async {
- // try {
- // await _flutterReactiveBle!
- // .writeCharacteristicWithoutResponse(characteristic, value: value);
- // } on Exception catch (e, s) {
- // // ignore: avoid_print
- // AppLog.log(s);
- // rethrow;
- // }
- // }
-
// 停止扫描蓝牙设备
Future stopScan() async {
try {
await FlutterBluePlus.stopScan();
} catch (e) {
- AppLog.log("停止扫描失败");
+ AppLog.log('停止扫描失败');
}
}
// 断开连接
Future disconnect() async {
try {
- // if(bluetoothConnectDevice != null && bluetoothConnectDevice!.connectionState == BluetoothConnectionState.connected){
- connectDeviceMacAddress = "";
+ connectDeviceMacAddress = '';
if (bluetoothConnectionState == BluetoothConnectionState.connected) {
- // await writeNull();
- // await Future.delayed(const Duration(milliseconds: 1000));
//加快蓝牙断连
- await bluetoothConnectDevice!.disconnect(timeout: 2);
- AppLog.log("断开连接成功");
+ await bluetoothConnectDevice!.disconnect(timeout: 3);
+ AppLog.log('断开连接成功');
}
- // }
} on Exception catch (e, _) {
- AppLog.log("断开连接失败: $e");
+ AppLog.log('断开连接失败: $e');
} finally {
bluetoothConnectionState = BluetoothConnectionState.disconnected;
}
}
- openBlue() async {
+ Future openBlue() async {
if (Platform.isAndroid) {
await FlutterBluePlus.turnOn();
}
if (Platform.isIOS) {
- EasyLoading.showToast("请开启蓝牙".tr, duration: 2000.milliseconds);
+ EasyLoading.showToast('请开启蓝牙'.tr, duration: 2000.milliseconds);
}
}
- disposed() {
+ void disposed() {
_sendStreamSubscription?.cancel();
_mtuSubscription!.cancel();
- // _scanResultsSubscription!.cancel();
_adapterStateStateSubscription!.cancel();
_connectionStateSubscription!.cancel();
}
diff --git a/lib/blue/io_reply.dart b/lib/blue/io_reply.dart
index 56c93b70..adf8c457 100755
--- a/lib/blue/io_reply.dart
+++ b/lib/blue/io_reply.dart
@@ -6,6 +6,7 @@ import '../app_settings/app_settings.dart';
import 'io_type.dart';
abstract class Reply{
+ Reply.parseData(this.commandType, List dataDetail);
CommandType? commandType;
@@ -13,122 +14,121 @@ abstract class Reply{
int status = 0;
List data = [];
static String logTag= '锁 -> App,指令订阅类型 :';
- Reply.parseData(this.commandType, List dataDetail);
void errorWithStstus(int status){
switch(status){
case 0x00:
// 成功
- AppLog.log("$logTag ${commandType?.typeName} 0x00 成功");
+ AppLog.log('$logTag ${commandType?.typeName} 0x00 成功');
break;
case 0x01:
// 包格式错误
- AppLog.log("$logTag ${commandType!.typeName} 0x01 包格式错误");
- showErrorMessage("包格式错误");
+ AppLog.log('$logTag ${commandType!.typeName} 0x01 包格式错误');
+ showErrorMessage('包格式错误');
break;
case 0x02:
// 密码错误
- AppLog.log("$logTag ${commandType!.typeName} 0x02 密码错误");
- showErrorMessage("密码错误");
+ AppLog.log('$logTag ${commandType!.typeName} 0x02 密码错误');
+ showErrorMessage('密码错误');
break;
case 0x03:
// 网络中断
- AppLog.log("$logTag ${commandType!.typeName} 0x03 网络中断");
- showErrorMessage("网络中断");
+ AppLog.log('$logTag ${commandType!.typeName} 0x03 网络中断');
+ showErrorMessage('网络中断');
break;
case 0x04:
// 用户未登记
- AppLog.log("$logTag ${commandType!.typeName} 0x04 用户未登记");
- showErrorMessage("用户未登记");
+ AppLog.log('$logTag ${commandType!.typeName} 0x04 用户未登记');
+ showErrorMessage('用户未登记');
break;
case 0x05:
// 参数错误
- AppLog.log("$logTag ${commandType!.typeName} 0x05 参数错误");
- showErrorMessage("参数错误");
+ AppLog.log('$logTag ${commandType!.typeName} 0x05 参数错误');
+ showErrorMessage('参数错误');
break;
case 0x06:
// 需要鉴权
- AppLog.log("$logTag ${commandType!.typeName} 0x06 需要鉴权");
+ AppLog.log('$logTag ${commandType!.typeName} 0x06 需要鉴权');
// showErrorMessage("需要鉴权");
break;
case 0x07:
// 无权限
- AppLog.log("$logTag ${commandType!.typeName} 0x07 无权限");
+ AppLog.log('$logTag ${commandType!.typeName} 0x07 无权限');
// showErrorMessage("无权限");
break;
case 0x08:
// 应答超时
- AppLog.log("$logTag ${commandType!.typeName} 0x08 应答超时");
- showErrorMessage("应答超时");
+ AppLog.log('$logTag ${commandType!.typeName} 0x08 应答超时');
+ showErrorMessage('应答超时');
break;
case 0x09:
// 权限校验错误
- AppLog.log("$logTag ${commandType!.typeName} 0x09 权限校验错误");
- showErrorMessage("权限校验错误");
+ AppLog.log('$logTag ${commandType!.typeName} 0x09 权限校验错误');
+ showErrorMessage('权限校验错误');
break;
case 0x0a:
// 钥匙不存在
- showErrorMessage("钥匙不存在");
- AppLog.log("$logTag ${commandType!.typeName} 0x0a 钥匙不存在");
+ showErrorMessage('钥匙不存在');
+ AppLog.log('$logTag ${commandType!.typeName} 0x0a 钥匙不存在');
break;
case 0x0b:
// 钥匙过期
- showErrorMessage("钥匙过期");
- AppLog.log("$logTag ${commandType!.typeName} 0x0b 钥匙过期");
+ showErrorMessage('钥匙过期');
+ AppLog.log('$logTag ${commandType!.typeName} 0x0b 钥匙过期');
break;
case 0x0c:
// 钥匙数量已到上限
- showErrorMessage("钥匙数量已到上限");
- AppLog.log("$logTag ${commandType!.typeName} 0x0c 钥匙数量已到上限");
+ showErrorMessage('钥匙数量已到上限');
+ AppLog.log('$logTag ${commandType!.typeName} 0x0c 钥匙数量已到上限');
break;
case 0x0d:
// 钥匙无效
- showErrorMessage("钥匙无效");
- AppLog.log("$logTag ${commandType!.typeName} 0x0d 钥匙无效");
+ showErrorMessage('钥匙无效');
+ AppLog.log('$logTag ${commandType!.typeName} 0x0d 钥匙无效');
break;
case 0x0e:
// 钥匙已存在
- showErrorMessage("钥匙已存在");
- AppLog.log("$logTag ${commandType!.typeName} 0x0e 钥匙已存在");
+ showErrorMessage('钥匙已存在');
+ AppLog.log('$logTag ${commandType!.typeName} 0x0e 钥匙已存在');
break;
case 0x0f:
// 用户已存在
- AppLog.log("$logTag ${commandType!.typeName} 0x0f 用户已存在");
- showErrorMessage("用户已存在");
+ AppLog.log('$logTag ${commandType!.typeName} 0x0f 用户已存在');
+ showErrorMessage('用户已存在');
break;
case 0x10:
// 密码失效
- AppLog.log("$logTag ${commandType!.typeName} 0x11 密码失效");
- showErrorMessage("密码失效");
+ AppLog.log('$logTag ${commandType!.typeName} 0x11 密码失效');
+ showErrorMessage('密码失效');
break;
case 0x11:
// 无效指令
- AppLog.log("$logTag ${commandType!.typeName} 0x11 无效指令");
- showErrorMessage("无效指令");
+ AppLog.log('$logTag ${commandType!.typeName} 0x11 无效指令');
+ showErrorMessage('无效指令');
break;
case 0x12:
// 门锁时间异常
- AppLog.log("$logTag ${commandType!.typeName} 0x12 门锁时间异常");
- showErrorMessage("门锁时间异常");
+ AppLog.log('$logTag ${commandType!.typeName} 0x12 门锁时间异常');
+ showErrorMessage('门锁时间异常');
break;
case 0x15:
// APP(手机)未联网
- AppLog.log("$logTag ${commandType!.typeName} 0x15 APP(手机)未联网");
- showErrorMessage("APP(手机)未联网");
+ AppLog.log('$logTag ${commandType!.typeName} 0x15 APP(手机)未联网');
+ showErrorMessage('APP(手机)未联网');
break;
case 0x16:
// 正在开锁中...
- AppLog.log("$logTag ${commandType!.typeName} $status 正在开锁中...");
- showErrorMessage("正在开锁中...");
+ AppLog.log('$logTag ${commandType!.typeName} $status 正在开锁中...');
+ showErrorMessage('正在开锁中...');
break;
case 0xff:
// 异常,未知错误
- AppLog.log("$logTag ${commandType!.typeName} 0xff 异常,未知错误");
- showErrorMessage("异常,未知错误");
+ AppLog.log('$logTag ${commandType!.typeName} 0xff 异常,未知错误');
+ showErrorMessage('异常,未知错误');
break;
default:
//失败
- AppLog.log("$logTag ${commandType!.typeName} $status 蓝牙返回其他错误问题");
+ AppLog.log('$logTag ${commandType!.typeName} $status 蓝牙返回其他错误问题');
break;
}
}
diff --git a/lib/blue/io_sender.dart b/lib/blue/io_sender.dart
index 098f50a5..5270d56d 100755
--- a/lib/blue/io_sender.dart
+++ b/lib/blue/io_sender.dart
@@ -39,7 +39,7 @@ abstract class SenderProtocol extends IOData {
? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}");
}
- //TODO:拼装数据Ï
+ //TODO:拼装数据
List packageData() {
commandData = messageDetail();
List commandList = [];
diff --git a/lib/blue/reciver_data.dart b/lib/blue/reciver_data.dart
index 36f5a3c2..297c81a0 100755
--- a/lib/blue/reciver_data.dart
+++ b/lib/blue/reciver_data.dart
@@ -52,12 +52,12 @@ import 'io_tool/manager_event_bus.dart';
import 'sm4Encipher/sm4.dart';
class CommandReciverManager {
- static void appDataReceive(List data) async {
+ static Future appDataReceive(List data) async {
///解析数据
if (data.isEmpty) {
return;
}
- int dataSize = data.length;
+ final int dataSize = data.length;
// 当小于包头加起来13个字节
if (dataSize < 13) {
return;
@@ -67,20 +67,20 @@ class CommandReciverManager {
(data[1] == 0x01) &&
(data[2] == 0xEE) &&
(data[3] == 0x02)) {
- var tmpType = (data[7] & 0x0f); // 包标识
- // AppLog.log("temType:$tmpType");
+ final int tmpType = data[7] & 0x0f; // 包标识
+ // AppLog.log('temType:$tmpType');
- var dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度
- var oriLen = data[10] * 256 + data[11]; // 低16位用来指示数据加密前的原长度
+ final int dataLen = data[8] * 256 + data[9]; // 高16位用来指示后面数据块内容的长度
+ final int oriLen = data[10] * 256 + data[11]; // 低16位用来指示数据加密前的原长度
// AppLog.log("dataLen:$dataLen oriLen:$oriLen");
- List oriDataList = [];
+ List oriDataList = [];
switch (tmpType) {
case 0: //不加密
// for (var i = 0; i < oriLen ; i++) {
// oriDataList.add(data[12 + i]);
// }
oriDataList = data.sublist(12, 12 + dataLen);
- AppLog.log("不加密 :$oriDataList");
+ AppLog.log('不加密 :$oriDataList');
break;
case 1:
//AES128
@@ -88,7 +88,7 @@ class CommandReciverManager {
case 2:
// SM4(事先约定密钥)
// 获取的加密数组
- var getDataList = data.sublist(12, 12 + dataLen);
+ final List getDataList = data.sublist(12, 12 + dataLen);
// 解密
// String key = SM4.createHexKey(key: IoManager().getCurrentDeviceLockId);
@@ -96,39 +96,39 @@ class CommandReciverManager {
key: utf8.encode(BlueManage().connectDeviceName),
mode: SM4CryptoMode.ECB);
oriDataList = oriDataList.sublist(0, oriLen);
- AppLog.log("APP收到的解密后的数据:$oriDataList");
+ AppLog.log('APP收到的解密后的数据:$oriDataList');
break;
case 3:
//SM4(设备指定密钥)
// 获取的加密数组
- var getDataList = data.sublist(12, 12 + dataLen);
+ final List getDataList = data.sublist(12, 12 + dataLen);
- var res = await Storage.getStringList(saveBluePrivateKey);
- List getPrivateKeyList = changeStringListToIntList(res!);
+ final List? res = await Storage.getStringList(saveBluePrivateKey);
+ final List getPrivateKeyList = changeStringListToIntList(res!);
// 解密
oriDataList = SM4.decrypt(getDataList,
key: getPrivateKeyList, mode: SM4CryptoMode.ECB);
oriDataList = oriDataList.sublist(0, oriLen);
- AppLog.log("APP收到的解密后的数据:$oriDataList");
+ AppLog.log('APP收到的解密后的数据:$oriDataList data:$data');
break;
}
parseData(oriDataList).then((Reply? value) async {
EasyLoading.dismiss();
await EventBusManager().eventBusFir(value);
}).catchError((error) {
- AppLog.log("APP解析数据时发生错误: $error");
+ AppLog.log('APP解析数据时发生错误: $error');
});
}
}
static Future parseData(List data) async {
if (data.isNotEmpty) {
- var cmd = data[0] * 256 + data[1];
- CommandType commandType = ExtensionCommandType.getCommandType(cmd);
+ final int cmd = data[0] * 256 + data[1];
+ final CommandType commandType = ExtensionCommandType.getCommandType(cmd);
await IoManager().increaseCommandIndex();
// data.removeRange(0, 2);
- var reply;
+ Reply? reply;
switch (commandType) {
case CommandType.getLockPublicKey:
{
@@ -234,7 +234,7 @@ class CommandReciverManager {
case CommandType.generalExtendedCommond:
{
// 子命令类型
- int subType = data[3];
+ final int subType = data[3];
switch (subType) {
case 2:
{
@@ -467,5 +467,6 @@ class CommandReciverManager {
}
return reply;
}
+ return null;
}
}
diff --git a/lib/common/XSConstantMacro/XSConstantMacro.dart b/lib/common/XSConstantMacro/XSConstantMacro.dart
index a3d32886..e54e7b70 100755
--- a/lib/common/XSConstantMacro/XSConstantMacro.dart
+++ b/lib/common/XSConstantMacro/XSConstantMacro.dart
@@ -70,4 +70,13 @@ class XSConstantMacro {
static int catEyeWorkModeStayCapture = 2; //逗留抓拍模式
static int catEyeWorkModeRealTimeMonitoring = 3; //实时监控模式
static int catEyeWorkModeCustom = 4; //自定义模式
+
+ //管理员类型
+ static int userTypeSuperAdmin = 110301; //超级管理员
+ static int userTypeAuthorizedAdmin = 110302; //授权管理员
+
+
+ //电子钥匙类型
+ static int keyRightAdmin = 1; //管理钥匙
+ static int keyRightOrdinary = 2; //普通钥匙
}
diff --git a/lib/flavors.dart b/lib/flavors.dart
index 9d350755..2eb513d9 100755
--- a/lib/flavors.dart
+++ b/lib/flavors.dart
@@ -86,7 +86,7 @@ class F {
switch (appFlavor) {
case Flavor.local:
return 'https://ge.lock.star-lock.cn'; // 葛工
- // return 'http://192.168.1.15:8022'; // 谢工
+ // return 'http://192.168.1.15:8022'; // 谢工
case Flavor.dev:
return 'https://dev.lock.star-lock.cn';
case Flavor.pre:
@@ -95,7 +95,7 @@ class F {
return 'https://lock.skychip.top';
case Flavor.xhj:
return 'https://lock.xhjcn.ltd';
- // return 'https://pre.lock.star-lock.cn';
+ // return 'https://pre.lock.star-lock.cn';
default:
throw Exception('flavor[$name] apiPrefix not found');
}
@@ -125,4 +125,19 @@ class F {
throw Exception('flavor[$name] aMapKey not found');
}
}
+
+ // 是否是生产环境
+ static bool get isProductionEnv {
+ switch (appFlavor) {
+ case Flavor.local:
+ case Flavor.dev:
+ case Flavor.pre:
+ return false;
+ case Flavor.sky:
+ case Flavor.xhj:
+ return true;
+ default:
+ return false;
+ }
+ }
}
diff --git a/lib/login/login/starLock_login_logic.dart b/lib/login/login/starLock_login_logic.dart
index 8142990f..2e3cc55e 100755
--- a/lib/login/login/starLock_login_logic.dart
+++ b/lib/login/login/starLock_login_logic.dart
@@ -1,8 +1,12 @@
import 'dart:io';
import 'package:flutter/material.dart';
+import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart';
import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart';
+import 'package:star_lock/blue/blue_manage.dart';
+import 'package:star_lock/login/login/entity/LoginEntity.dart';
+import 'package:star_lock/mine/mine/starLockMine_state.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/xs_jPhush.dart';
@@ -14,34 +18,15 @@ import 'starLock_login_state.dart';
class StarLockLoginLogic extends BaseGetXController {
final StarLockLoginState state = StarLockLoginState();
- final stateMyLogic = Get.put(StarLockMineLogic()).state;
+ final StarLockMineState stateMyLogic = Get.put(StarLockMineLogic()).state;
int indexFocusNode = noneFocusNode;
static int noneFocusNode = 0;
static int emailOrPhoneFocusNode = 1;
static int pwdFocusNode = 2;
- @override
- void onInit() {
- super.onInit();
- // state.emailOrPhoneFocusNode.addListener(() {
- // if (state.emailOrPhoneFocusNode.hasFocus) {
- // indexFocusNode = emailOrPhoneFocusNode;
- // } else {
- // changeInputFocusNode();
- // }
- // });
- // state.pwdFocusNode.addListener(() {
- // if (state.pwdFocusNode.hasFocus) {
- // indexFocusNode = pwdFocusNode;
- // } else {
- // changeInputFocusNode();
- // }
- // });
- }
-
//检查焦点状态
void changeInputFocusNode() {
- Future.delayed(Duration(milliseconds: 100), () {
+ Future.delayed(const Duration(milliseconds: 100), () {
if (indexFocusNode == noneFocusNode) {
return;
}
@@ -53,9 +38,9 @@ class StarLockLoginLogic extends BaseGetXController {
});
}
- void login() async {
- var entity = await ApiRepository.to.login(
- loginType: "1",
+ Future login() async {
+ final LoginEntity entity = await ApiRepository.to.login(
+ loginType: '1',
password: state.pwd.value,
countryCode: state.countryCode.value,
username: state.emailOrPhone.value);
@@ -63,11 +48,10 @@ class StarLockLoginLogic extends BaseGetXController {
Storage.saveLoginData(entity.data);
Storage.setBool(saveIsVip, entity.data!.isVip == 0 ? false : true);
eventBus.fire(MineInfoChangeRefreshUI());
- // Get.back();
- // Get.toNamed(Routers.starLockMain);
XSJPushProvider().initJPushService();
XSJPushProvider().initLocalNotification(false);
- Get.offNamedUntil(Routers.starLockMain, (route) => false);
+ Get.offNamedUntil(Routers.starLockMain, (Route route) => false);
+ BlueManage().scanDevices.clear(); //清除设备缓存
}
}
diff --git a/lib/main.dart b/lib/main.dart
index 2d09e1a8..65a67850 100755
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,14 +1,19 @@
import 'dart:async';
+
+import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
+import 'package:flutter_bugly_plugin/flutter_bugly_plugin.dart';
+import 'package:get/get.dart';
import 'package:star_lock/flavors.dart';
-import 'package:star_lock/translations/trans_lib.dart';
-import 'app.dart';
+import 'package:star_lock/tools/bugly/bugly_tool.dart';
import 'package:star_lock/tools/device_info_service.dart';
import 'package:star_lock/tools/platform_info_services.dart';
+import 'package:star_lock/translations/trans_lib.dart';
+
+import 'app.dart';
import 'app_settings/app_settings.dart';
import 'tools/store_service.dart';
-import 'package:get/get.dart';
// 该文件不可作为编译入口,请查看 flavorizr.yaml 中的说明
FutureOr main() async {
@@ -19,20 +24,23 @@ FutureOr main() async {
// 设置国际化信息
await _initTranslation();
+ // bugly错误日志监控
+ await BuglyTool.init();
+
runApp(const MyApp());
if (AppPlatform.isAndroid) {
- SystemUiOverlayStyle systemUiOverlayStyle =
- const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
+ const SystemUiOverlayStyle systemUiOverlayStyle =
+ SystemUiOverlayStyle(statusBarColor: Colors.transparent);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
}
// 设置国际化信息
Future _initTranslation() async => TranslationLoader.loadTranslation(
- zhSource: "images/lan/lan_zh.json",
- enSource: "images/lan/lan_en.json",
- keySource: "images/lan/lan_keys.json",
+ zhSource: 'images/lan/lan_zh.json',
+ enSource: 'images/lan/lan_en.json',
+ keySource: 'images/lan/lan_keys.json',
);
// 设置包名服务设备信息
diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart
index a2e3a7d9..c0eb4073 100755
--- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart
+++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart
@@ -5,13 +5,17 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart';
import 'package:star_lock/appRouters.dart';
import 'package:star_lock/app_settings/app_settings.dart';
+import 'package:star_lock/login/login/entity/LoginEntity.dart';
+import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_entity.dart';
+import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart';
import 'package:star_lock/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart';
+import 'package:star_lock/tools/NativeInteractionTool.dart';
import 'package:star_lock/tools/dateTool.dart';
import 'package:star_lock/tools/showCupertinoAlertView.dart';
import '../../../../blue/blue_manage.dart';
-import '../../../../blue/io_reply.dart';
import '../../../../blue/io_protocol/io_transferPermissions.dart';
+import '../../../../blue/io_reply.dart';
import '../../../../blue/io_tool/io_tool.dart';
import '../../../../blue/io_tool/manager_event_bus.dart';
import '../../../../blue/sender_manage.dart';
@@ -26,18 +30,21 @@ import 'authorizedAdmin_state.dart';
class AuthorizedAdminLogic extends BaseGetXController {
final AuthorizedAdminState state = AuthorizedAdminState();
+ int? keyId;
+
// 监听设备返回的数据
late StreamSubscription _replySubscription;
+
void _initReplySubscription() {
_replySubscription =
- EventBusManager().eventBus!.on().listen((reply) async {
+ EventBusManager().eventBus!.on().listen((Reply reply) async {
// 转移权限
if (reply is TransferPermissionsReply) {
- var token = reply.data.sublist(2, 6);
- var saveStrList = changeIntListToStringList(token);
+ final List token = reply.data.sublist(2, 6);
+ final List saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList);
- int status = reply.data[6];
+ final int status = reply.data[6];
switch (status) {
case 0x00:
@@ -45,20 +52,24 @@ class AuthorizedAdminLogic extends BaseGetXController {
break;
case 0x06:
//无权限
- var privateKey = await Storage.getStringList(saveBluePrivateKey);
- List getPrivateKeyList =
+ final List? privateKey =
+ await Storage.getStringList(saveBluePrivateKey);
+ final List getPrivateKeyList =
changeStringListToIntList(privateKey!);
- var publicKey = await Storage.getStringList(saveBluePublicKey);
- List publicKeyDataList = changeStringListToIntList(publicKey!);
+ final List? publicKey =
+ await Storage.getStringList(saveBluePublicKey);
+ final List publicKeyDataList =
+ changeStringListToIntList(publicKey!);
- var token = await Storage.getStringList(saveBlueToken);
- List getTokenList = changeStringListToIntList(token!);
+ final List? token =
+ await Storage.getStringList(saveBlueToken);
+ final List getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderFactoryDataReset(
lockID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
- keyID: "1",
+ keyID: '1',
needAuthor: 1,
publicKey: publicKeyDataList,
privateKey: getPrivateKeyList,
@@ -73,24 +84,28 @@ class AuthorizedAdminLogic extends BaseGetXController {
// 转移权限
Future transferPermissionsAction() async {
- BlueManage().bludSendData(BlueManage().connectDeviceName,
+ BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState state) async {
if (state == BluetoothConnectionState.connected) {
- var privateKey = await Storage.getStringList(saveBluePrivateKey);
- List getPrivateKeyList = changeStringListToIntList(privateKey!);
+ final List? privateKey =
+ await Storage.getStringList(saveBluePrivateKey);
+ final List getPrivateKeyList =
+ changeStringListToIntList(privateKey!);
- var publicKey = await Storage.getStringList(saveBluePublicKey);
- List publicKeyDataList = changeStringListToIntList(publicKey!);
+ final List? publicKey =
+ await Storage.getStringList(saveBluePublicKey);
+ final List publicKeyDataList =
+ changeStringListToIntList(publicKey!);
- var token = await Storage.getStringList(saveBlueToken);
- List getTokenList = changeStringListToIntList(token!);
+ final List? token = await Storage.getStringList(saveBlueToken);
+ final List getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderTransferPermissions(
lockID: BlueManage().connectDeviceName,
authUserID: await Storage.getUid(),
- keyID: "1",
+ keyID: '1',
oldUserID: await Storage.getUid(),
- newUserID: "100002",
+ newUserID: '100002',
needAuthor: 1,
publicKey: publicKeyDataList,
privateKey: getPrivateKeyList,
@@ -102,40 +117,40 @@ class AuthorizedAdminLogic extends BaseGetXController {
//发送授权管理员列表请求
Future sendElectronicKeyRequest() async {
if (state.emailOrPhoneController.text.isEmpty) {
- showToast("请输入接收者账号");
+ showToast('请输入接收者账号');
return;
}
if (state.keyNameController.text.isEmpty) {
- showToast("请输入接收者姓名");
+ showToast('请输入接收者姓名');
return;
}
- var startDate = "0";
- var endDate = "0";
- var startTime = "0";
- var endTime = "0";
- AppLog.log("state.type.value:${state.seletType.value}");
- String getKeyType = "1";
+ String startDate = '0';
+ String endDate = '0';
+ String startTime = '0';
+ String endTime = '0';
+ AppLog.log('state.type.value:${state.seletType.value}');
+ String getKeyType = '1';
if (state.seletType.value == 0) {
- getKeyType = "2";
+ getKeyType = '2';
startDate =
DateTool().dateToTimestamp(state.beginDate.value, 1).toString();
endDate = DateTool().dateToTimestamp(state.endDate.value, 1).toString();
- startTime = "0";
- endTime = "0";
+ startTime = '0';
+ endTime = '0';
if (startDate.isEmpty) {
- showToast("请选择开始时间");
+ showToast('请选择开始时间');
return;
}
if (endDate.isEmpty) {
- showToast("请选择结束时间");
+ showToast('请选择结束时间');
return;
}
if (int.parse(startDate) >= int.parse(endDate)) {
- showToast("失效时间要大于生效时间");
+ showToast('失效时间要大于生效时间');
return;
}
}
@@ -143,12 +158,12 @@ class AuthorizedAdminLogic extends BaseGetXController {
//如果打开了实名认证,需要弹出输入身份证信息框
if (state.isAuthentication.value == true) {
if (state.realNameController.text.isEmpty) {
- showToast("请输入真实姓名".tr);
+ showToast('请输入真实姓名'.tr);
return;
}
if (state.idCardController.text.isEmpty) {
- showToast("请输入身份证号".tr);
+ showToast('请输入身份证号'.tr);
return;
}
//弹出身份证信息确认框
@@ -179,38 +194,39 @@ class AuthorizedAdminLogic extends BaseGetXController {
required String startDate,
required String startTime,
required String endTime}) async {
- var entity = await ApiRepository.to.sendElectronicKey(
- createUser: state.isCreateUser.value ? "1" : "0",
- countryCode: state.countryCode.value,
- usernameType: '1',
- endDate: int.parse(endDate),
- faceAuthentication: state.isAuthentication.value == true ? '1' : '2',
- isCameraEnable: '2',
- isRemoteUnlock: '2',
- keyNameForAdmin: state.keyNameController.text,
- keyRight: '1',
- keyType: getKeyType,
- lockId: CommonDataManage().currentKeyInfo.lockId!.toString(),
- operatorUid: '',
- receiverUsername: state.emailOrPhoneController.text,
- remarks: '',
- startDate: int.parse(startDate),
- weekDays: state.weekdaysList,
- startTime: int.parse(startTime),
- endTime: int.parse(endTime),
- isOnlyManageSelf: state.onlyManageYouCreatesUser.value ? 1 : 0,
- realName: state.isRequireAuth.value == true
- ? state.realNameController.text
- : "",
- idCardNumber: state.isRequireAuth.value == true
- ? state.idCardController.text
- : "");
+ final AuthorizedAdminSendEntity entity = await ApiRepository.to
+ .sendElectronicKey(
+ createUser: state.isCreateUser.value ? '1' : '0',
+ countryCode: state.countryCode.value,
+ usernameType: '1',
+ endDate: int.parse(endDate),
+ faceAuthentication:
+ state.isAuthentication.value == true ? '1' : '2',
+ isCameraEnable: '2',
+ isRemoteUnlock: '2',
+ keyNameForAdmin: state.keyNameController.text,
+ keyRight: '1',
+ keyType: getKeyType,
+ lockId: CommonDataManage().currentKeyInfo.lockId!.toString(),
+ operatorUid: '',
+ receiverUsername: state.emailOrPhoneController.text,
+ remarks: '',
+ startDate: int.parse(startDate),
+ weekDays: state.weekdaysList,
+ startTime: int.parse(startTime),
+ endTime: int.parse(endTime),
+ isOnlyManageSelf: state.onlyManageYouCreatesUser.value ? 1 : 0,
+ realName: state.isRequireAuth.value == true
+ ? state.realNameController.text
+ : '',
+ idCardNumber: state.isRequireAuth.value == true
+ ? state.idCardController.text
+ : '');
if (entity.errorCode!.codeIsSuccessful) {
state.isCreateUser.value = false;
state.isSendSuccess.value = true;
- // Toast.show(msg: "添加成功");
state.addUserId.value = entity.data!.receiverUser!.id.toString();
- // addUserConnectBlue(state.addUserId.value);
+ keyId = entity.data!.keyId;
eventBus.fire(AuthorizedAdminPageRefreshUI());
} else {
if (entity.errorCode == 425) {
@@ -218,16 +234,15 @@ class AuthorizedAdminLogic extends BaseGetXController {
state.isCreateUser.value = true;
ShowTipView().showIosTipWithContentDialog(
'${"是否发送授权管理员给未注册账号".tr}\n${state.emailOrPhoneController.text}',
- () {
- sendElectronicKeyRequest();
- });
+ sendElectronicKeyRequest);
}
}
}
//检测实名认证是否支持开启
Future keyCheckFace() async {
- AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace(
+ final AdvancedFunctionRecordEntity entity =
+ await ApiRepository.to.keyCheckFace(
lockId: CommonDataManage().currentKeyInfo.lockId ?? 0,
);
if (entity.errorCode!.codeIsSuccessful) {
@@ -240,7 +255,7 @@ class AuthorizedAdminLogic extends BaseGetXController {
titleStr: '实名认证为付费功能,请购买后再使用'.tr,
sureClick: () {
Get.toNamed(Routers.advancedFeaturesWebPage,
- arguments: {'isShop': false});
+ arguments: {'isShop': false});
});
} else if (entity.errorCode == 433) {
//需联系管理员购买
@@ -250,12 +265,12 @@ class AuthorizedAdminLogic extends BaseGetXController {
//标记房间为已入住 isOn:已入住: 1 空闲:2
Future updateRoomCheckIn() async {
- var entity = await ApiRepository.to.setRoomStatusData(
+ final LoginEntity entity = await ApiRepository.to.setRoomStatusData(
lockId: CommonDataManage().currentKeyInfo.lockId!,
roomStatus: 1,
);
if (entity.errorCode!.codeIsSuccessful) {
- showToast("标记成功");
+ showToast('标记成功');
}
}
@@ -279,6 +294,31 @@ class AuthorizedAdminLogic extends BaseGetXController {
return currentController;
}
+ //发送消息
+ Future sendMsg({required bool isPhone}) async {
+ if (keyId == null) {
+ return;
+ }
+ final NoticeTemplateEntity entity = await ApiRepository.to
+ .getNoticeTemplate(
+ lockId: CommonDataManage().currentKeyInfo.lockId!,
+ keyId: keyId!,
+ channelType: isPhone ? 1 : 2);
+ if (entity.errorCode!.codeIsSuccessful) {
+ final List- list =
+ entity.data!.list!.where((Item item) => item.isUse == 0).toList();
+ if (list.isNotEmpty) {
+ final Item item = list.first!;
+ final String template = item.template ?? '';
+ NativeInteractionTool().loadNativeShare(shareText: template);
+ } else {
+ showToast('获取模板失败 0x02');
+ }
+ } else {
+ showToast('获取模板失败 0x01');
+ }
+ }
+
@override
void onReady() {
// TODO: implement onReady
diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart
index 8eb565c0..d1e2bb3d 100755
--- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart
+++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart
@@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
+import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart';
import 'package:star_lock/tools/dateTool.dart';
import 'package:star_lock/tools/pickers/pickers.dart';
@@ -31,8 +32,8 @@ class AuthorizedAdminPage extends StatefulWidget {
class _AuthorizedAdminPageState extends State
with SingleTickerProviderStateMixin {
- final logic = Get.put(AuthorizedAdminLogic());
- final state = Get.find().state;
+ final AuthorizedAdminLogic logic = Get.put(AuthorizedAdminLogic());
+ final AuthorizedAdminState state = Get.find().state;
@override
void initState() {
@@ -60,7 +61,7 @@ class _AuthorizedAdminPageState extends State
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
- children: [
+ children: [
_tabBar(),
_pageWidget(),
],
@@ -78,7 +79,7 @@ class _AuthorizedAdminPageState extends State
// 限时
return SingleChildScrollView(
child: Column(
- children: [
+ children: [
keyInfoWidget(),
keyTimeWidget(),
keyOnlyManageWidget(),
@@ -92,7 +93,7 @@ class _AuthorizedAdminPageState extends State
// 永久
return SingleChildScrollView(
child: Column(
- children: [
+ children: [
keyInfoWidget(),
keyOnlyManageWidget(),
keyBottomWidget(
@@ -107,17 +108,17 @@ class _AuthorizedAdminPageState extends State
// 顶部钥匙信息widget
Widget keyInfoWidget() {
return Column(
- children: [
+ children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.receiver!.tr,
- rightTitle: "",
+ rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: getTFWidget(true,
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, 1)),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
- rightTitle: "",
+ rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
isHaveDirection: true,
@@ -128,7 +129,7 @@ class _AuthorizedAdminPageState extends State
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
),
action: () async {
- var result = await Navigator.pushNamed(
+ final Object? result = await Navigator.pushNamed(
context, Routers.selectCountryRegionPage);
if (result != null) {
result as Map;
@@ -140,7 +141,7 @@ class _AuthorizedAdminPageState extends State
),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
- rightTitle: "",
+ rightTitle: '',
isHaveRightWidget: true,
rightWidget: getTFWidget(
false, TranslationLoader.lanKeys!.enterYourName!.tr, 2)),
@@ -152,17 +153,18 @@ class _AuthorizedAdminPageState extends State
// 生效失效时间
Widget keyTimeWidget() {
return Column(
- children: [
+ children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
rightTitle: state.beginDate.value,
isHaveLine: true,
isHaveDirection: true,
action: () {
- PDuration selectDate =
+ final PDuration selectDate =
PDuration.parse(DateTime.tryParse(state.beginDate.value));
Pickers.showDatePicker(context,
- selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
+ selectDate: selectDate,
+ mode: DateMode.YMDHM, onConfirm: (PDuration p) {
setState(() {
state.beginDate.value = DateTool().getYMDHNDateString(p, 1);
});
@@ -173,10 +175,11 @@ class _AuthorizedAdminPageState extends State
rightTitle: state.endDate.value,
isHaveDirection: true,
action: () {
- PDuration selectDate =
+ final PDuration selectDate =
PDuration.parse(DateTime.tryParse(state.endDate.value));
Pickers.showDatePicker(context,
- selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
+ selectDate: selectDate,
+ mode: DateMode.YMDHM, onConfirm: (PDuration p) {
setState(() {
state.endDate.value = DateTool().getYMDHNDateString(p, 1);
});
@@ -190,14 +193,14 @@ class _AuthorizedAdminPageState extends State
// 实名认证
Widget keyOnlyManageWidget() {
return Column(
- children: [
+ children: [
CommonItem(
- leftTitel: "仅管理自己创建的用户",
- rightTitle: "",
+ leftTitel: '仅管理自己创建的用户',
+ rightTitle: '',
isHaveRightWidget: true,
isTipsImg: true,
tipsImgAction: () {
- ShowTipView().showSureAlertDialog("授权管理员只能查看和管理自己下发的钥匙、密码等权限");
+ ShowTipView().showSureAlertDialog('授权管理员只能查看和管理自己下发的钥匙、密码等权限');
},
rightWidget: SizedBox(
width: 60.w,
@@ -212,11 +215,11 @@ class _AuthorizedAdminPageState extends State
Widget keyBottomWidget(String tipStr) {
return Column(
- children: [
+ children: [
Container(
padding: EdgeInsets.all(20.w),
child: Row(
- children: [
+ children: [
Expanded(
child: Text(
tipStr,
@@ -233,26 +236,27 @@ class _AuthorizedAdminPageState extends State
SubmitBtn(
btnName: TranslationLoader.lanKeys!.send!.tr,
onClick: () async {
- var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
+ final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
//发送钥匙请求
logic.sendElectronicKeyRequest();
} else {
- logic.showToast("演示模式");
+ logic.showToast('演示模式');
}
}),
Container(
padding: EdgeInsets.only(right: 30.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
- children: [
+ children: [
TextButton(
onPressed: () async {
- var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
+ final bool? isDemoMode =
+ await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
Get.toNamed(Routers.volumeAuthorizationLockManagePage);
} else {
- logic.showToast("演示模式");
+ logic.showToast('演示模式');
}
},
child: Text(
@@ -270,16 +274,15 @@ class _AuthorizedAdminPageState extends State
// 实名认证
Widget keyRealNameWidget() {
return Column(
- children: [
+ children: [
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.realNameAuthentication!.tr,
- rightTitle: "",
+ rightTitle: '',
isTipsImg: true,
- isHaveLine:
- logic.state.isRequireAuth.value == true ? true : false,
+ isHaveLine: logic.state.isRequireAuth.value == true,
tipsImgAction: () {
ShowTipView().showSureAlertDialog(
- "人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。".tr);
+ '人脸实名认证指的是用户在使用手机APP开锁时,需要先进行本人人脸验证,验证通过才能开锁。'.tr);
},
isHaveRightWidget: true,
rightWidget: SizedBox(
@@ -289,7 +292,7 @@ class _AuthorizedAdminPageState extends State
visible: logic.state.isRequireAuth.value,
child: CommonItem(
leftTitel: '真实姓名'.tr,
- rightTitle: "",
+ rightTitle: '',
isHaveRightWidget: true,
isHaveLine: true,
rightWidget: getTFWidget(false, '请输入真实姓名'.tr, 3)))),
@@ -297,7 +300,7 @@ class _AuthorizedAdminPageState extends State
visible: logic.state.isRequireAuth.value,
child: CommonItem(
leftTitel: '身份证号'.tr,
- rightTitle: "",
+ rightTitle: '',
isHaveRightWidget: true,
rightWidget: getTFWidget(false, '请输入身份证号'.tr, 4)))),
],
@@ -307,13 +310,13 @@ class _AuthorizedAdminPageState extends State
// 发送电子钥匙成功
Widget sendElectronicKeySucceed() {
return Column(
- children: [
+ children: [
Container(
height: 250.h,
width: 1.sw,
color: Colors.white,
child: Column(
- children: [
+ children: [
SizedBox(
height: 30.h,
),
@@ -327,9 +330,9 @@ class _AuthorizedAdminPageState extends State
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
- children: [
+ children: [
Text(
- "发送成功",
+ '发送成功',
style: TextStyle(
fontSize: 26.sp,
color: Colors.black,
@@ -354,13 +357,12 @@ class _AuthorizedAdminPageState extends State
),
OutLineBtn(
btnName:
- state.emailOrPhoneController.text.contains("@") ? '邮件通知' : "短信通知",
+ state.emailOrPhoneController.text.contains('@') ? '邮件通知' : '短信通知',
onClick: () {
- if (state.emailOrPhoneController.text.contains("@")) {
+ if (state.emailOrPhoneController.text.contains('@')) {
Get.toNamed(Routers.sendEmailNotificationPage);
} else {
- NativeInteractionTool()
- .loadNativeShare(shareText: state.pwdShareStr);
+ logic.sendMsg(isPhone: true);
}
},
),
@@ -370,8 +372,8 @@ class _AuthorizedAdminPageState extends State
OutLineBtn(
btnName: '微信通知',
onClick: () {
- NativeInteractionTool()
- .loadNativeShare(shareText: state.pwdShareStr);
+ logic.sendMsg(
+ isPhone: state.emailOrPhoneController.text.contains('@'));
},
),
SizedBox(
@@ -387,7 +389,7 @@ class _AuthorizedAdminPageState extends State
height: 65.h,
width: 300.w,
child: Row(
- children: [
+ children: [
Expanded(
child: TextField(
//输入框一行
@@ -425,38 +427,37 @@ class _AuthorizedAdminPageState extends State
SizedBox(
width: 10.w,
),
- isHaveBtn
- ? Container(
- width: 30.w,
- height: 30.w,
- decoration: const BoxDecoration(
- color: Colors.white,
- image: DecorationImage(
- image: AssetImage('images/icon_addressBook.png'),
- fit: BoxFit.fill),
- ),
- alignment: Alignment.center,
- child: InkWell(
- onTap: () async {
- Contact? currentContact =
- await state.contactPicker.selectContact();
- setState(() {
- state.contact = currentContact!;
- if (currentContact.phoneNumbers!.isNotEmpty) {
- state.emailOrPhoneController.text = currentContact
- .phoneNumbers![0]
- .replaceAll(RegExp(r"\s+\b|\b\s"), "");
- }
-
- if (currentContact.fullName!.isNotEmpty) {
- state.keyNameController.text =
- currentContact.fullName!;
- }
- });
- },
- ),
- )
- : Container()
+ if (isHaveBtn)
+ Container(
+ width: 30.w,
+ height: 30.w,
+ decoration: const BoxDecoration(
+ color: Colors.white,
+ image: DecorationImage(
+ image: AssetImage('images/icon_addressBook.png'),
+ fit: BoxFit.fill),
+ ),
+ alignment: Alignment.center,
+ child: InkWell(
+ onTap: () async {
+ final Contact? currentContact =
+ await state.contactPicker.selectContact();
+ setState(() {
+ state.contact = currentContact!;
+ if (currentContact.phoneNumbers!.isNotEmpty) {
+ state.emailOrPhoneController.text = currentContact
+ .phoneNumbers![0]
+ .replaceAll(RegExp(r'\s+\b|\b\s'), '');
+ }
+ if (currentContact.fullName!.isNotEmpty) {
+ state.keyNameController.text = currentContact.fullName!;
+ }
+ });
+ },
+ ),
+ )
+ else
+ Container()
],
),
);
@@ -469,7 +470,7 @@ class _AuthorizedAdminPageState extends State
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.isAuthentication.value,
- onChanged: (value) {
+ onChanged: (bool value) {
setState(() {
if (logic.state.isAuthentication.value == false) {
logic.keyCheckFace();
@@ -489,7 +490,7 @@ class _AuthorizedAdminPageState extends State
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: state.onlyManageYouCreatesUser.value,
- onChanged: (value) {
+ onChanged: (bool value) {
setState(() {
state.onlyManageYouCreatesUser.value =
!state.onlyManageYouCreatesUser.value;
@@ -498,7 +499,7 @@ class _AuthorizedAdminPageState extends State
);
}
- Future _openModalBottomSheet() async {
+ void _openModalBottomSheet() {
showModalBottomSheet(
context: context,
shape: RoundedRectangleBorder(
@@ -506,7 +507,7 @@ class _AuthorizedAdminPageState extends State
constraints: BoxConstraints(maxHeight: 270.h),
builder: (BuildContext context) {
return Column(
- children: [
+ children: [
SizedBox(
width: ScreenUtil().screenWidth,
height: 180.h,
@@ -537,7 +538,7 @@ class _AuthorizedAdminPageState extends State
}
List initBottomSheetList() {
- List widgetList = [];
+ final List widgetList = [];
widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友', 0));
widgetList.add(buildCenter3('images/icon_message.png', '短信', 1));
@@ -557,7 +558,7 @@ class _AuthorizedAdminPageState extends State
EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
- children: [
+ children: [
Image.asset(
imageName,
width: 50.w,
@@ -579,7 +580,7 @@ class _AuthorizedAdminPageState extends State
}
//\n生效时间:${itemData.startDate}\n类型:永久\n锁名:${itemData.keyboardPwdName}
- _jumpSmartDeviceRoute(int itemIndex) {
+ dynamic _jumpSmartDeviceRoute(int itemIndex) {
Get.back();
switch (itemIndex) {
case 0:
@@ -613,8 +614,8 @@ class _AuthorizedAdminPageState extends State
TabBar _tabBar() {
return TabBar(
controller: state.tabController,
- tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(),
- onTap: (index) {
+ tabs: _itemTabs.map(_tab).toList(),
+ onTap: (int index) {
FocusScope.of(context).requestFocus(FocusNode());
},
isScrollable: true,
@@ -655,14 +656,14 @@ class _AuthorizedAdminPageState extends State
child: TabBarView(
controller: state.tabController,
children: _itemTabs
- .map((ItemView item) => Obx(() => indexChangeWidget()))
+ .map((ItemView item) => Obx(indexChangeWidget))
.toList()),
);
}
final List _itemTabs = [
- ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: "0"),
- ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: "1"),
+ ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: '0'),
+ ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: '1'),
];
}
diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart
index 0a350e43..36dceadf 100755
--- a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart
+++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_state.dart
@@ -15,25 +15,25 @@ class AuthorizedAdminState {
final FlutterContactPicker contactPicker = FlutterContactPicker();
late Contact contact;
- var isAuthentication = false.obs; //是否可以实名认证
- final onlyManageYouCreatesUser = false.obs; // 只能管理自己创建的用户
+ RxBool isAuthentication = false.obs; //是否可以实名认证
+ final RxBool onlyManageYouCreatesUser = false.obs; // 只能管理自己创建的用户
- var beginDate = DateTool()
+ RxString beginDate = DateTool()
.dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString())
.obs; //默认为当前时间 开始时间
- var endDate = DateTool()
+ RxString endDate = DateTool()
.dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString())
.obs; //默认为当前时间 结束时间
- var isSendSuccess = false.obs;
- var countryName = '中国'.obs;
- var countryCode = '86'.obs;
- var weekdaysList = [].obs;
- var isCreateUser = false.obs; //用户未注册时传1 已注册传0
+ RxBool isSendSuccess = false.obs;
+ RxString countryName = '中国'.obs;
+ RxString countryCode = '86'.obs;
+ RxList weekdaysList = [].obs;
+ RxBool isCreateUser = false.obs; //用户未注册时传1 已注册传0
- var seletType = 0.obs;
+ RxInt seletType = 0.obs;
String pwdShareStr = '您好,您的授权管理员生成成功';
- var addUserId = ''.obs;
- var isRequireAuth = false.obs; //是否需要实名认证的必填项
+ RxString addUserId = ''.obs;
+ RxBool isRequireAuth = false.obs; //是否需要实名认证的必填项
}
diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart
new file mode 100644
index 00000000..e876778b
--- /dev/null
+++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart
@@ -0,0 +1,71 @@
+class NoticeTemplateEntity {
+ NoticeTemplateEntity(
+ {this.errorCode, this.description, this.errorMsg, this.data});
+
+ NoticeTemplateEntity.fromJson(Map json) {
+ errorCode = json['errorCode'];
+ description = json['description'];
+ errorMsg = json['errorMsg'];
+ if (json['data'] is Map) {
+ data = Data.fromJson(json['data']);
+ }
+ }
+
+ int? errorCode;
+ String? description;
+ String? errorMsg;
+ Data? data;
+
+ Map toJson() {
+ final Map data = {};
+ data['errorCode'] = errorCode;
+ data['description'] = description;
+ data['errorMsg'] = errorMsg;
+ data['data'] = this.data;
+ return data;
+ }
+}
+
+class Data {
+ Data.fromJson(Map json) {
+ if (json['list'] is List) {
+ json['list'].forEach((dynamic element) {
+ list?.add(Item.fromJson(element));
+ });
+ }
+ }
+
+ List
- ? list = [];
+
+ Map toJson() {
+ final Map data = {};
+ data['list'] = list;
+ return data;
+ }
+}
+
+class Item {
+ Item.fromJson(Map json) {
+ type = json['type'];
+ name = json['name'];
+ template = json['template'];
+ isUse = json['isUse'];
+ fee = json['fee'];
+ }
+
+ String? type;
+ String? name;
+ String? template;
+ int? isUse;
+ int? fee;
+
+ Map toJson() {
+ final Map data = {};
+ data['type'] = type;
+ data['name'] = name;
+ data['template'] = template;
+ data['isUse'] = isUse;
+ data['fee'] = fee;
+ return data;
+ }
+}
diff --git a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart
index 752a1115..1fa9edf5 100755
--- a/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart
+++ b/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart
@@ -4,6 +4,7 @@ import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_logic.dart';
+import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_state.dart';
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
import 'package:star_lock/tools/noData.dart';
import 'package:star_lock/tools/storage.dart';
@@ -25,8 +26,8 @@ class AuthorizedAdminListPage extends StatefulWidget {
}
class _AuthorizedAdminListPageState extends State {
- final logic = Get.put(AuthorizedAdminListLogic());
- final state = Get.find().state;
+ final AuthorizedAdminListLogic logic = Get.put(AuthorizedAdminListLogic());
+ final AuthorizedAdminListState state = Get.find().state;
@override
void initState() {
@@ -37,7 +38,7 @@ class _AuthorizedAdminListPageState extends State {
Future mockRequest() async {
// 获取是否是演示模式 演示模式不获取接口
- var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
+ final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) {
logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value) {
setState(() {});
@@ -63,7 +64,7 @@ class _AuthorizedAdminListPageState extends State {
mockRequest();
},
child: Column(
- children: [
+ children: [
Expanded(child: _buildMainUI()),
SizedBox(
height: 20.h,
@@ -72,7 +73,7 @@ class _AuthorizedAdminListPageState extends State {
btnName: TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr,
onClick: () {
Navigator.pushNamed(context, Routers.authorizedAdminPage)
- .then((val) {
+ .then((Object? val) {
if (val != null) {
logic.pageNo = 1;
mockRequest();
@@ -89,14 +90,14 @@ class _AuthorizedAdminListPageState extends State {
}
Widget _buildMainUI() {
- return Obx(() => state.itemDataList.value.isEmpty
+ return Obx(() => state.itemDataList.isEmpty
? NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight - 90)
: SlidableAutoCloseBehavior(
child: ListView.separated(
- itemCount: state.itemDataList.value.length,
- itemBuilder: (c, index) {
- ElectronicKeyListItem indexEntity =
- state.itemDataList.value[index];
+ itemCount: state.itemDataList.length,
+ itemBuilder: (BuildContext c, int index) {
+ final ElectronicKeyListItem indexEntity =
+ state.itemDataList[index];
String useDateStr = ''; //使用期限
String keyStatus = ''; //钥匙状态
@@ -116,16 +117,16 @@ class _AuthorizedAdminListPageState extends State {
}
return Slidable(
- key: ValueKey(indexEntity.keyId),
+ key: ValueKey(indexEntity.keyId),
endActionPane: ActionPane(
extentRatio: 0.2,
motion: const ScrollMotion(),
- children: [
+ children: [
SlidableAction(
onPressed: (BuildContext context) {
ShowTipView()
.showDeleteAdministratorIsHaveAllDataDialog(
- '同时删除其发送的所有钥匙,钥匙删除后不能恢复', (isAllData) {
+ '同时删除其发送的所有钥匙,钥匙删除后不能恢复', (bool isAllData) {
logic.deleteKeyRequest(indexEntity.keyId.toString(),
isAllData ? 1 : 0);
});
@@ -145,9 +146,9 @@ class _AuthorizedAdminListPageState extends State {
isAdminKey, () {
Navigator.pushNamed(
context, Routers.electronicKeyDetailPage,
- arguments: {
- "itemData": indexEntity,
- }).then((val) {
+ arguments: {
+ 'itemData': indexEntity,
+ }).then((Object? val) {
if (val != null) {
logic.mockNetworkDataRequest();
setState(() {});
@@ -172,14 +173,14 @@ class _AuthorizedAdminListPageState extends State {
if (indexEntity.keyType == XSConstantMacro.keyTypeTime) {
//限期
- DateTime startDateStr =
+ final DateTime startDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!);
- DateTime endDateStr =
+ final DateTime endDateStr =
DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!);
useDateStr =
'${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}';
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) {
- useDateStr = "永久";
+ useDateStr = '永久';
}
return useDateStr;
}
@@ -192,7 +193,7 @@ class _AuthorizedAdminListPageState extends State {
color: Colors.white,
height: 100.h,
child: Row(
- children: [
+ children: [
SizedBox(width: 30.w),
Image.asset(
avatarURL,
@@ -203,13 +204,13 @@ class _AuthorizedAdminListPageState extends State {
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
- children: [
+ children: [
Row(
- children: [
+ children: [
SizedBox(
width: 1.sw - 110.w - 100.w,
child: Row(
- children: [
+ children: [
Flexible(
child: Text(receiveUser,
maxLines: 1,
@@ -231,7 +232,7 @@ class _AuthorizedAdminListPageState extends State {
SizedBox(height: 10.h),
Row(
mainAxisAlignment: MainAxisAlignment.start,
- children: [
+ children: [
Text(
useDate,
style: TextStyle(
diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart
index dffadaf6..0c4ab05b 100755
--- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart
+++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_logic.dart
@@ -1,10 +1,56 @@
+import 'dart:ffi';
-
+import 'package:flutter_easyloading/flutter_easyloading.dart';
+import 'package:get/get.dart';
+import 'package:star_lock/main/lockDetail/authorizedAdmin/authorizedAdmin/notice_template_entity.dart';
+import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart';
+import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
+import 'package:star_lock/tools/commonDataManage.dart';
import 'volumeAuthorizationLock_state.dart';
class VolumeAuthorizationLockLogic extends BaseGetXController {
- final state = VolumeAuthorizationLockState();
+ final VolumeAuthorizationLockState state = VolumeAuthorizationLockState();
-}
\ No newline at end of file
+ //发送批量授权管理员
+ Future addAuthorizedAdminRequest() async {
+ String getFailureDateTime = '0';
+ String getEffectiveDateTime = '0';
+ if (state.selectWidgetType.value == '1') {
+ getFailureDateTime =
+ state.failureDateTime.value.millisecondsSinceEpoch.toString();
+ getEffectiveDateTime =
+ state.effectiveDateTime.value.millisecondsSinceEpoch.toString();
+ }
+
+ if (state.lockIdList.isEmpty) {
+ showToast('请选择锁'.tr);
+ return;
+ }
+ final KeyDetailEntity entity = await ApiRepository.to.addAuthorizedAdmin(
+ createUser: state.isCreateUser.value ? '1' : '0',
+ endDate: getFailureDateTime,
+ isRemoteUnlock: '0',
+ keyGroupIdList: [],
+ lockIdList: state.lockIdList.value,
+ name: state.keyNameController.text,
+ startDate: getEffectiveDateTime,
+ userid: state.emailOrPhoneController.text,
+ countryCode: state.countryCode.value,
+ usernameType: '1',
+ isOnlyManageSelf: state.onlyManageYouCreatesUser.value == true ? 1 : 2,
+ );
+ if (entity.errorCode!.codeIsSuccessful) {
+ state.isSendSuccess.value = true;
+ } else {
+ EasyLoading.showToast('${entity.errorMsg}', duration: 2000.milliseconds);
+ if (entity.errorCode == 425) {
+ //用户未注册
+ state.isCreateUser.value = true;
+ addAuthorizedAdminRequest();
+ }
+ }
+ }
+
+}
diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart
index ca2ee4e9..cf0c27ed 100755
--- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart
+++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart
@@ -1,19 +1,16 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
-import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
-// import 'package:flutter_pickers/pickers.dart';
-// import 'package:flutter_pickers/time_picker/model/date_mode.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/app_settings/app_colors.dart';
-import 'package:star_lock/network/api_repository.dart';
-import 'package:star_lock/tools/baseGetXController.dart';
+import 'package:star_lock/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_state.dart';
import 'package:star_lock/tools/pickers/pickers.dart';
import 'package:star_lock/tools/pickers/time_picker/model/date_mode.dart';
import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
+import 'package:star_lock/tools/showTipView.dart';
import '../../../../appRouters.dart';
import '../../../../tools/commonItem.dart';
@@ -22,10 +19,9 @@ import '../../../../translations/trans_lib.dart';
import 'volumeAuthorizationLock_logic.dart';
class VolumeAuthorizationLockPage extends StatefulWidget {
- final String type;
-
- const VolumeAuthorizationLockPage({Key? key, required this.type})
+ const VolumeAuthorizationLockPage({required this.type, Key? key})
: super(key: key);
+ final String type;
@override
State createState() =>
@@ -33,53 +29,23 @@ class VolumeAuthorizationLockPage extends StatefulWidget {
}
//批量授权锁页面
-class _VolumeAuthorizationLockPageState extends State {
- final logic = Get.put(VolumeAuthorizationLockLogic());
- final state = Get.find().state;
-
- final FlutterContactPicker _contactPicker = FlutterContactPicker();
- final TextEditingController _emailOrPhoneController =
- TextEditingController(); //邮箱/手机号输入框
- final TextEditingController _keyNameController =
- TextEditingController(); //钥匙名输入框
- late Contact _contact;
- late List _lockIdList;
- late bool _isSendSuccess;
- late bool _isCreateUser; //是否需要创建用户
- late bool _isRemoteUnlock; //是否远程开锁
- var _selectEffectiveDate = ''; //生效时间
- var _selectFailureDate = ''; //失效时间
- late DateTime _effectiveDateTime;
- late DateTime _failureDateTime;
- String countryName = '中国';
- String countryCode = '86';
+class _VolumeAuthorizationLockPageState
+ extends State {
+ final VolumeAuthorizationLockLogic logic =
+ Get.put(VolumeAuthorizationLockLogic());
+ final VolumeAuthorizationLockState state =
+ Get.find().state;
@override
Widget build(BuildContext context) {
+ state.selectWidgetType.value = widget.type;
return SingleChildScrollView(
- child: indexChangeWidget(),
+ child: Obx(indexChangeWidget),
);
}
- @override
- void initState() {
- super.initState();
-
- _lockIdList = [];
- _isRemoteUnlock = false;
- _isSendSuccess = false;
- _isCreateUser = false;
- DateTime dateTime = DateTime.now();
- _effectiveDateTime = dateTime;
- _failureDateTime = dateTime;
- _selectEffectiveDate =
- '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
- _selectFailureDate =
- '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间
- }
-
Widget indexChangeWidget() {
- if (_isSendSuccess) {
+ if (state.isSendSuccess.value) {
return sendElectronicKeySucceed();
} else {
switch (int.parse(widget.type)) {
@@ -87,7 +53,7 @@ class _VolumeAuthorizationLockPageState extends State[
keyInfoWidget(),
remoteUnlockingWidget(),
SizedBox(
@@ -100,7 +66,7 @@ class _VolumeAuthorizationLockPageState extends State[
keyInfoWidget(),
keyTimeWidget(),
remoteUnlockingWidget(),
@@ -117,47 +83,47 @@ class _VolumeAuthorizationLockPageState extends State[
CommonItem(
leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr,
- rightTitle: "",
+ rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: getTFWidget(
true,
TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr,
- _emailOrPhoneController)),
+ state.emailOrPhoneController)),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.countryAndRegion!.tr,
- rightTitle: "",
+ rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
isHaveDirection: true,
rightWidget: Text(
- '$countryName +$countryCode',
+ '${state.countryName.value} +${state.countryCode.value}',
textAlign: TextAlign.end,
style:
TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
),
action: () async {
- var result = await Navigator.pushNamed(
+ final Object? result = await Navigator.pushNamed(
context, Routers.selectCountryRegionPage);
if (result != null) {
result as Map;
- countryCode = result['code'];
- countryName = result['countryName'];
- setState(() {});
+ state.countryCode.value = result['code'];
+ state.countryName.value = result['countryName'];
+ // setState(() {});
}
},
),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
- rightTitle: "",
+ rightTitle: '',
isHaveRightWidget: true,
rightWidget: getTFWidget(
false,
TranslationLoader.lanKeys!.pleaseEnter!.tr,
- _keyNameController)),
+ state.keyNameController)),
Container(height: 10.h),
],
);
@@ -166,36 +132,42 @@ class _VolumeAuthorizationLockPageState extends State[
CommonItem(
leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr,
- rightTitle: _selectEffectiveDate,
+ rightTitle: state.selectEffectiveDate.value,
isHaveLine: true,
isHaveDirection: true,
action: () {
- PDuration selectDate = PDuration.parse(_effectiveDateTime);
+ final PDuration selectDate =
+ PDuration.parse(state.effectiveDateTime.value);
Pickers.showDatePicker(context,
- selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
- setState(() {
- _selectEffectiveDate =
- '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
- _effectiveDateTime = DateTime.parse(_selectEffectiveDate);
- });
+ selectDate: selectDate,
+ mode: DateMode.YMDHM, onConfirm: (PDuration p) {
+ // setState(() {
+ state.selectEffectiveDate.value =
+ '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
+ state.effectiveDateTime.value =
+ DateTime.parse(state.selectEffectiveDate.value);
+ // });
});
}),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.failureTime!.tr,
- rightTitle: _selectFailureDate,
+ rightTitle: state.selectFailureDate.value,
isHaveDirection: true,
action: () {
- PDuration selectDate = PDuration.parse(_failureDateTime);
+ final PDuration selectDate =
+ PDuration.parse(state.failureDateTime.value);
Pickers.showDatePicker(context,
- selectDate: selectDate, mode: DateMode.YMDHM, onConfirm: (p) {
- setState(() {
- _selectFailureDate =
- '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
- _failureDateTime = DateTime.parse(_selectFailureDate);
- });
+ selectDate: selectDate,
+ mode: DateMode.YMDHM, onConfirm: (PDuration p) {
+ // setState(() {
+ state.selectFailureDate.value =
+ '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}';
+ state.failureDateTime.value =
+ DateTime.parse(state.selectFailureDate.value);
+ // });
});
}),
Container(height: 10.h),
@@ -206,33 +178,41 @@ class _VolumeAuthorizationLockPageState extends State[
CommonItem(
leftTitel: TranslationLoader.lanKeys!.lock!.tr,
- rightTitle: _lockIdList.isEmpty
+ rightTitle: state.lockIdList.isEmpty
? TranslationLoader.lanKeys!.pleaseSelect!.tr
- : _lockIdList.length.toString(),
+ : state.lockIdList.length.toString(),
isHaveDirection: true,
action: () {
- Navigator.pushNamed(context, Routers.massSendLockGroupListPage, arguments: {
- "keyLimits":"1"
- }).then((value) {
+ Navigator.pushNamed(context, Routers.massSendLockGroupListPage,
+ arguments: {'keyLimits': '1'})
+ .then((Object? value) {
//得到选中的锁ID列表
- if (value != null) {
- value as Map;
- _lockIdList = value['selectLockIdList'];
-
+ if (value is Map &&
+ value['selectLockIdList'] is List) {
+ state.lockIdList.clear();
+ value['selectLockIdList'].forEach((element) {
+ state.lockIdList.add(element);
+ });
setState(() {});
}
});
}),
Container(height: 10.h),
CommonItem(
- leftTitel: TranslationLoader.lanKeys!.remoteUnlockingAllowed!.tr,
- rightTitle: "",
+ leftTitel: '仅管理自己创建的用户',
+ rightTitle: '',
isHaveRightWidget: true,
- rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch()),
- action: () {}),
+ isTipsImg: true,
+ tipsImgAction: () {
+ ShowTipView().showSureAlertDialog('授权管理员只能查看和管理自己下发的钥匙、密码等权限');
+ },
+ rightWidget: SizedBox(
+ width: 60.w,
+ height: 50.h,
+ child: _onlyManageYouCreatesUserSwitch())),
Container(height: 10.h),
],
);
@@ -240,14 +220,14 @@ class _VolumeAuthorizationLockPageState extends State[
SubmitBtn(
btnName: TranslationLoader.lanKeys!.sure!.tr,
borderRadius: 20.w,
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
onClick: () {
- addAuthorizedAdminRequest();
+ logic.addAuthorizedAdminRequest();
}),
],
);
@@ -260,7 +240,7 @@ class _VolumeAuthorizationLockPageState extends State[
Expanded(
child: TextField(
controller: editController,
@@ -294,89 +274,51 @@ class _VolumeAuthorizationLockPageState extends State addAuthorizedAdminRequest() async {
- String getFailureDateTime = '0';
- String getEffectiveDateTime = '0';
- if (widget.type == '1') {
- getFailureDateTime = _failureDateTime.millisecondsSinceEpoch.toString();
- getEffectiveDateTime =
- _effectiveDateTime.millisecondsSinceEpoch.toString();
- }
-
- if (_lockIdList.isEmpty) {
- logic.showToast("请选择锁".tr);
- return;
- }
- var entity = await ApiRepository.to.addAuthorizedAdmin(
- createUser: _isCreateUser ? "1" : "0",
- endDate: getFailureDateTime,
- isRemoteUnlock: _isRemoteUnlock == true ? '1' : '2',
- keyGroupIdList: [],
- lockIdList: _lockIdList,
- name: _keyNameController.text,
- startDate: getEffectiveDateTime,
- userid: _emailOrPhoneController.text,
- countryCode: countryCode,
- usernameType: '1',
- );
- if (entity.errorCode!.codeIsSuccessful) {
- _isSendSuccess = true;
- setState(() {});
- } else {
- EasyLoading.showToast('${entity.errorMsg}', duration: 2000.milliseconds);
- if (entity.errorCode == 425) {
- //用户未注册
- _isCreateUser = true;
- addAuthorizedAdminRequest();
- }
- }
- }
-
// 发送电子钥匙成功
Widget sendElectronicKeySucceed() {
return Column(
- children: [
+ children: [
Container(
height: 250.h,
width: 1.sw,
color: Colors.white,
child: Column(
- children: [
+ children: [
SizedBox(
height: 30.h,
),
@@ -390,9 +332,9 @@ class _VolumeAuthorizationLockPageState extends State[
Text(
- "发送成功",
+ '发送成功',
style: TextStyle(
fontSize: 26.sp,
color: Colors.black,
@@ -409,51 +351,30 @@ class _VolumeAuthorizationLockPageState extends State lockIdList = [].obs;
+ RxBool isSendSuccess = false.obs;
+ RxBool isCreateUser = false.obs; //是否需要创建用户
+ RxBool sRemoteUnlock = false.obs; //是否远程开锁
+ RxBool onlyManageYouCreatesUser = false.obs; //只能管理您创建的用户
+ RxString selectEffectiveDate =
+ '${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day} ${DateTime.now().hour}:${DateTime.now().minute}'
+ .obs; //生效时间
+ RxString selectFailureDate = ''.obs; //失效时间
+ Rx effectiveDateTime = DateTime.now().obs;
+ Rx failureDateTime = DateTime.now().obs;
+ RxString countryName = '中国'.obs;
+ RxString countryCode = '86'.obs;
+ RxString selectWidgetType = '0'.obs;
+}
diff --git a/lib/main/lockDetail/card/addICCard/addICCard_logic.dart b/lib/main/lockDetail/card/addICCard/addICCard_logic.dart
index d35af8ef..f25dbe42 100755
--- a/lib/main/lockDetail/card/addICCard/addICCard_logic.dart
+++ b/lib/main/lockDetail/card/addICCard/addICCard_logic.dart
@@ -147,7 +147,7 @@ class AddICCardLogic extends BaseGetXController{
showBlueConnetctToastTimer(action: (){
Get.close(1);
});
- BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
+ BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){
cancelBlueConnetctToastTimer();
// var publicKey = await Storage.getStringList(saveBluePublicKey);
@@ -193,7 +193,7 @@ class AddICCardLogic extends BaseGetXController{
// 取消添加指纹
Future senderCancelAddCardCommand() async {
- BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
+ BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List getPrivateKeyList = changeStringListToIntList(privateKey!);
diff --git a/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart b/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart
index 91e9a92b..c4c4d51f 100755
--- a/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart
+++ b/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart
@@ -100,7 +100,7 @@ class CardDetailLogic extends BaseGetXController{
dismissEasyLoading();
state.sureBtnState.value = 0;
});
- BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
+ BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){
var signKey = await Storage.getStringList(saveBlueSignKey);
List signKeyDataList = changeStringListToIntList(signKey!);
diff --git a/lib/main/lockDetail/card/cardList/cardList_logic.dart b/lib/main/lockDetail/card/cardList/cardList_logic.dart
index c02dce71..b1eabbff 100755
--- a/lib/main/lockDetail/card/cardList/cardList_logic.dart
+++ b/lib/main/lockDetail/card/cardList/cardList_logic.dart
@@ -229,7 +229,7 @@ class CardListLogic extends BaseGetXController {
showBlueConnetctToastTimer(action: (){
dismissEasyLoading();
});
- BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
+ BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){
// var publicKey = await Storage.getStringList(saveBluePublicKey);
// List publicKeyDataList = changeStringListToIntList(publicKey!);
diff --git a/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart b/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart
index 55a98228..28f18489 100755
--- a/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart
+++ b/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart
@@ -105,7 +105,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
dismissEasyLoading();
state.sureBtnState.value = 0;
});
- BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
+ BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List getPrivateKeyList = changeStringListToIntList(privateKey!);
@@ -257,7 +257,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
dismissEasyLoading();
state.sureBtnState.value = 0;
});
- BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
+ BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){
// var publicKey = await Storage.getStringList(saveBluePublicKey);
// List publicKeyDataList = changeStringListToIntList(publicKey!);
@@ -313,7 +313,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{
dismissEasyLoading();
state.sureBtnState.value = 0;
});
- BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
+ BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){
var signKey = await Storage.getStringList(saveBlueSignKey);
diff --git a/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart b/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart
index 7fa54f98..3cde986b 100755
--- a/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart
+++ b/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart
@@ -107,7 +107,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
dismissEasyLoading();
state.sureBtnState.value = 0;
});
- BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
+ BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List getPrivateKeyList = changeStringListToIntList(privateKey!);
@@ -259,7 +259,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
dismissEasyLoading();
state.sureBtnState.value = 0;
});
- BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
+ BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){
// var publicKey = await Storage.getStringList(saveBluePublicKey);
// List publicKeyDataList = changeStringListToIntList(publicKey!);
@@ -315,7 +315,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{
dismissEasyLoading();
state.sureBtnState.value = 0;
});
- BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
+ BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected){
var signKey = await Storage.getStringList(saveBlueSignKey);
diff --git a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart
index cecd68b0..4cad5ecd 100755
--- a/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart
+++ b/lib/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_page.dart
@@ -1,7 +1,9 @@
import 'package:date_format/date_format.dart';
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/main/lockDetail/checkingIn/checkingInHolidays/checkingInAddHolidays/checkingInAddHolidays_state.dart';
import '../../../../../app_settings/app_colors.dart';
import '../../../../../tools/commonItem.dart';
@@ -20,8 +22,10 @@ class CheckingInAddHolidaysPage extends StatefulWidget {
}
class _CheckingInAddHolidaysPageState extends State {
- final logic = Get.put(CheckingInAddHolidaysLogic());
- final state = Get.find().state;
+ final CheckingInAddHolidaysLogic logic =
+ Get.put(CheckingInAddHolidaysLogic());
+ final CheckingInAddHolidaysState state =
+ Get.find().state;
@override
Widget build(BuildContext context) {
@@ -32,27 +36,31 @@ class _CheckingInAddHolidaysPageState extends State {
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Column(
- children: [
+ children: [
CommonItem(
leftTitel: TranslationLoader.lanKeys!.name!.tr,
- rightTitle: "",
+ rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
+ setHeight: false,
rightWidget: getTFWidget(
- "(${TranslationLoader.lanKeys!.mustFillIn!.tr})")),
+ '(${TranslationLoader.lanKeys!.mustFillIn!.tr})')),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.startDate!.tr,
- rightTitle: state.beginDate.value.isEmpty ? "(${TranslationLoader.lanKeys!.mustFillIn!.tr})" : state.beginDate.value,
+ rightTitle: state.beginDate.value.isEmpty
+ ? '(${TranslationLoader.lanKeys!.mustFillIn!.tr})'
+ : state.beginDate.value,
isHaveLine: true,
isHaveDirection: false,
action: () async {
await showDialog(
context: context,
- builder: (context) {
+ builder: (BuildContext context) {
return ShowCalendar(
datePickerMode: DatePickerMode.day,
- selectAction: (dateTime) {
- String beginDate = formatDate(dateTime, [yyyy,'-',mm,'-',dd]);
+ selectAction: (DateTime dateTime) {
+ final String beginDate = formatDate(
+ dateTime, [yyyy, '-', mm, '-', dd]);
state.beginDate.value = beginDate;
Get.back();
// Navigator.of(context).pop(true);
@@ -61,17 +69,20 @@ class _CheckingInAddHolidaysPageState extends State {
})),
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.endDate!.tr,
- rightTitle: state.endDate.value.isEmpty ? "(${TranslationLoader.lanKeys!.mustFillIn!.tr})" : state.endDate.value,
+ rightTitle: state.endDate.value.isEmpty
+ ? '(${TranslationLoader.lanKeys!.mustFillIn!.tr})'
+ : state.endDate.value,
isHaveLine: true,
isHaveDirection: false,
action: () async {
await showDialog(
context: context,
- builder: (context) {
+ builder: (BuildContext context) {
return ShowCalendar(
datePickerMode: DatePickerMode.day,
- selectAction: (dateTime) {
- String endDate = formatDate(dateTime, [yyyy,'-',mm,'-',dd]);
+ selectAction: (DateTime dateTime) {
+ final String endDate = formatDate(
+ dateTime,