Merge branch 'release' of https://gitee.com/starlock-cn/app-starlock into release
# Conflicts: # lib/main/lockMian/lockList/lockList_page.dart # lib/network/api.dart # lib/network/api_provider.dart # lib/network/api_repository.dart
This commit is contained in:
commit
a8c57cc5b0
@ -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
|
||||
|
||||
@ -22,7 +22,8 @@
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
|
||||
<!--允许写设备缓存,用于问题排查-->
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
|
||||
<!--允许写入扩展存储,用于写入缓存定位数据-->
|
||||
<!--允许读设备日志,用于问题排查-->
|
||||
<uses-permission android:name="android.permission.READ_LOGS" />
|
||||
|
||||
<!--相机-->
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
|
||||
@ -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"
|
||||
}
|
||||
|
||||
@ -633,7 +633,7 @@
|
||||
"卡详情": "卡详情",
|
||||
"请输入": "请输入",
|
||||
"关闭后,智能锁将设置为全天常开模式,直到手动关闭": "关闭后,智能锁将设置为全天常开模式,直到手动关闭",
|
||||
"请输入小于1000的数字": "请输入小于1000的数字",
|
||||
"请输入小于或等于60的数字": "请输入小于或等于60的数字",
|
||||
"操作成功": "操作成功",
|
||||
"管理员密码相同,无需修改": "管理员密码相同,无需修改",
|
||||
"修改密码": "修改密码",
|
||||
@ -844,6 +844,7 @@
|
||||
"身份证号":"身份证号",
|
||||
"请输入真实姓名":"请输入真实姓名",
|
||||
"请输入身份证号":"请输入身份证号",
|
||||
"请输入身份证号和真实姓名":"请输入身份证号和真实姓名",
|
||||
|
||||
"点击返回设备配对":"点击返回设备配对",
|
||||
"无法连接?尝试升级":"无法连接?尝试升级",
|
||||
@ -883,5 +884,6 @@
|
||||
"门铃事件":"门铃事件",
|
||||
"视频事件":"视频事件",
|
||||
"请开启蓝牙":"请开启蓝牙",
|
||||
"请选择有效日":"请选择有效日"
|
||||
"请选择有效日":"请选择有效日",
|
||||
"公司名字长度不能小于 6 ": "公司名字长度不能小于 6 "
|
||||
}
|
||||
|
||||
@ -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 "
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -22,14 +22,59 @@
|
||||
<string>$(FLUTTER_BUILD_NAME)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>None</string>
|
||||
<key>CFBundleURLIconFile</key>
|
||||
<string/>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>com.sky.skysmartlock</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>skysmartlock</string>
|
||||
<string/>
|
||||
<string/>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>weixin</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>123456</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>weixin</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>wxbe340095d2b8fd51</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
<string>weixin</string>
|
||||
<string>weixinULAPI</string>
|
||||
<string>weixinURLParamsAPI</string>
|
||||
</array>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
<key>NSAllowsArbitraryLoadsInWebContent</key>
|
||||
<true/>
|
||||
<key>NSExceptionDomains</key>
|
||||
<dict>
|
||||
<key>jpush.cn</key>
|
||||
@ -86,23 +131,6 @@
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>com.sky.skysmartlock</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>skysmartlock</string>
|
||||
<string></string>
|
||||
<string></string>
|
||||
</array>
|
||||
<key>CFBundleURLIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>None</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>io.flutter.embedded_views_preview</key>
|
||||
<true/>
|
||||
</dict>
|
||||
|
||||
19
lib/app.dart
19
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<MyApp> 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: <NavigatorObserver>[AppRouteObserver().routeObserver],
|
||||
translations: TranslationMessage(),
|
||||
supportedLocales: appDept.deptSupportedLocales,
|
||||
localizationsDelegates: const [
|
||||
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
],
|
||||
localeResolutionCallback: (locale, supportedLocales) {
|
||||
localeResolutionCallback:
|
||||
(Locale? locale, Iterable<Locale> 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<MyApp> 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<MyApp> with WidgetsBindingObserver, BaseWidget {
|
||||
}
|
||||
|
||||
Future<bool> getLoginStatus() async {
|
||||
final data = await Storage.getString(saveUserLoginData);
|
||||
final String? data = await Storage.getString(saveUserLoginData);
|
||||
if (data != null && data.isNotEmpty) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -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()),
|
||||
];
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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<ScanResult>);
|
||||
|
||||
class BlueManage {
|
||||
final List<ScanResult> scanDevices = [];
|
||||
|
||||
factory BlueManage() => shareManager()!;
|
||||
|
||||
BlueManage._init() {
|
||||
_initBlue();
|
||||
}
|
||||
final List<ScanResult> scanDevices = <ScanResult>[];
|
||||
|
||||
// 用来写入的服务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<EventSendModel>? _sendStreamSubscription;
|
||||
|
||||
// 监听蓝牙扫描的事件
|
||||
// StreamSubscription? _scanSubscription;
|
||||
// 监听蓝牙连接的事件
|
||||
// StreamSubscription<dynamic>? _currentConnectionStream;
|
||||
|
||||
// StreamSubscription<List<ScanResult>>? _scanResultsSubscription;
|
||||
StreamSubscription<BluetoothConnectionState>? _connectionStateSubscription;
|
||||
|
||||
StreamSubscription<int>? _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<BluetoothAdapterState>? _adapterStateStateSubscription;
|
||||
|
||||
static BlueManage? _manager;
|
||||
// 听上报来的数据,参数来自前面扫描到的结果
|
||||
List<int> allData = <int>[];
|
||||
|
||||
BlueManage._init() {
|
||||
_initBlue();
|
||||
}
|
||||
// 保存上一次的数据,用来判断是否收到重复的数据
|
||||
List<int> lastTimeData = <int>[];
|
||||
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<EventSendModel>()
|
||||
.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<void> 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<dynamic> completer = Completer<dynamic>();
|
||||
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: <String>[deviceName],
|
||||
timeout: Duration(seconds: timeout));
|
||||
final Completer<dynamic> completer = Completer<dynamic>();
|
||||
final StreamSubscription<List<ScanResult>> subscription =
|
||||
FlutterBluePlus.scanResults.listen((List<ScanResult> 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<void> startScan(int timeout, ScanDevicesCallBack scanDevicesCallBack,
|
||||
{List<Guid>? 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<List<ScanResult>> subscription =
|
||||
FlutterBluePlus.scanResults.listen((List<ScanResult> 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<void> bludSendData(
|
||||
Future<void> 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<ScanResult> devicesList = scanDevices;
|
||||
final List<ScanResult> 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<ScanResult> 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<void> _connectDevice(List<ScanResult> 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<BluetoothService> 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 = <int>[];
|
||||
|
||||
// 保存上一次的数据,用来判断是否收到重复的数据
|
||||
var lastTimeData = <int>[];
|
||||
int? dataLen;
|
||||
|
||||
_subScribeToCharacteristic(BluetoothCharacteristic characteristic) async {
|
||||
final subscription = characteristic.onValueReceived.listen((data) {
|
||||
// AppLog.log("订阅获取的数据:$data");
|
||||
Future<void> _subScribeToCharacteristic(
|
||||
BluetoothCharacteristic characteristic) async {
|
||||
final StreamSubscription<List<int>> subscription =
|
||||
characteristic.onValueReceived.listen((List<int> 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 = <int>[];
|
||||
}
|
||||
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 = <int>[];
|
||||
}
|
||||
} 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 = <int>[];
|
||||
// }
|
||||
// } 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 = <int>[];
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
//判断数据头是否正确
|
||||
bool isDataHeadCorrect(List<int> 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<void> writeCharacteristicWithResponse(List<int> value) async {
|
||||
List<BluetoothService> services =
|
||||
final List<BluetoothService> 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<int> valueList = value;
|
||||
List subData = splitList(valueList, _mtuSize!);
|
||||
final List<int> 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<BluetoothService> services = await bluetoothConnectDevice!.discoverServices();
|
||||
// BluetoothCharacteristic characteristic = services
|
||||
// .firstWhere((service) => service.uuid == _serviceIdWrite)
|
||||
// .characteristics
|
||||
// .firstWhere((char) => char.uuid == _characteristicIdWrite);
|
||||
// try {
|
||||
// List<int> 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<void> writeNull() async {
|
||||
List<BluetoothService> 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<int> valueList = [1];
|
||||
AppLog.log('APP写入 writeNull ');
|
||||
await characteristic.write(valueList);
|
||||
} on Exception catch (e, s) {
|
||||
AppLog.log('APP写入失败 writeNull : $e $s');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 读取
|
||||
// Future<List<int>> _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<void> writeCharacteristicWithoutResponse(
|
||||
// QualifiedCharacteristic characteristic, List<int> value) async {
|
||||
// try {
|
||||
// await _flutterReactiveBle!
|
||||
// .writeCharacteristicWithoutResponse(characteristic, value: value);
|
||||
// } on Exception catch (e, s) {
|
||||
// // ignore: avoid_print
|
||||
// AppLog.log(s);
|
||||
// rethrow;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 停止扫描蓝牙设备
|
||||
Future<void> stopScan() async {
|
||||
try {
|
||||
await FlutterBluePlus.stopScan();
|
||||
} catch (e) {
|
||||
AppLog.log("停止扫描失败");
|
||||
AppLog.log('停止扫描失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 断开连接
|
||||
Future<void> 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<void> 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();
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import '../app_settings/app_settings.dart';
|
||||
import 'io_type.dart';
|
||||
|
||||
abstract class Reply{
|
||||
Reply.parseData(this.commandType, List<int> dataDetail);
|
||||
|
||||
CommandType? commandType;
|
||||
|
||||
@ -13,122 +14,121 @@ abstract class Reply{
|
||||
int status = 0;
|
||||
List<int> data = [];
|
||||
static String logTag= '锁 -> App,指令订阅类型 :';
|
||||
Reply.parseData(this.commandType, List<int> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ abstract class SenderProtocol extends IOData {
|
||||
? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}");
|
||||
}
|
||||
|
||||
//TODO:拼装数据Ï
|
||||
//TODO:拼装数据
|
||||
List<int> packageData() {
|
||||
commandData = messageDetail();
|
||||
List<int> commandList = [];
|
||||
|
||||
@ -52,12 +52,12 @@ import 'io_tool/manager_event_bus.dart';
|
||||
import 'sm4Encipher/sm4.dart';
|
||||
|
||||
class CommandReciverManager {
|
||||
static void appDataReceive(List<int> data) async {
|
||||
static Future<void> appDataReceive(List<int> 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<int> oriDataList = [];
|
||||
List<int> oriDataList = <int>[];
|
||||
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<int> 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<int> getDataList = data.sublist(12, 12 + dataLen);
|
||||
|
||||
var res = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(res!);
|
||||
final List<String>? res = await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> 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<Reply?> parseData(List<int> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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; //普通钥匙
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<void>.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<void> 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(); //清除设备缓存
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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<void> main() async {
|
||||
@ -19,20 +24,23 @@ FutureOr<void> 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',
|
||||
);
|
||||
|
||||
// 设置包名服务设备信息
|
||||
|
||||
@ -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<Reply> _replySubscription;
|
||||
|
||||
void _initReplySubscription() {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
||||
// 转移权限
|
||||
if (reply is TransferPermissionsReply) {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
final List<int> token = reply.data.sublist(2, 6);
|
||||
final List<String> 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<int> getPrivateKeyList =
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
final List<String>? publicKey =
|
||||
await Storage.getStringList(saveBluePublicKey);
|
||||
final List<int> publicKeyDataList =
|
||||
changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
final List<String>? token =
|
||||
await Storage.getStringList(saveBlueToken);
|
||||
final List<int> 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<void> transferPermissionsAction() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
final List<String>? publicKey =
|
||||
await Storage.getStringList(saveBluePublicKey);
|
||||
final List<int> publicKeyDataList =
|
||||
changeStringListToIntList(publicKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> 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<void> 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<void> 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: <String, bool>{'isShop': false});
|
||||
});
|
||||
} else if (entity.errorCode == 433) {
|
||||
//需联系管理员购买
|
||||
@ -250,12 +265,12 @@ class AuthorizedAdminLogic extends BaseGetXController {
|
||||
|
||||
//标记房间为已入住 isOn:已入住: 1 空闲:2
|
||||
Future<void> 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<void> 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<Item?> 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
|
||||
|
||||
@ -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<AuthorizedAdminPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final logic = Get.put(AuthorizedAdminLogic());
|
||||
final state = Get.find<AuthorizedAdminLogic>().state;
|
||||
final AuthorizedAdminLogic logic = Get.put(AuthorizedAdminLogic());
|
||||
final AuthorizedAdminState state = Get.find<AuthorizedAdminLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -60,7 +61,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
_tabBar(),
|
||||
_pageWidget(),
|
||||
],
|
||||
@ -78,7 +79,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
// 限时
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
keyInfoWidget(),
|
||||
keyTimeWidget(),
|
||||
keyOnlyManageWidget(),
|
||||
@ -92,7 +93,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
// 永久
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
keyInfoWidget(),
|
||||
keyOnlyManageWidget(),
|
||||
keyBottomWidget(
|
||||
@ -107,17 +108,17 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
// 顶部钥匙信息widget
|
||||
Widget keyInfoWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
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<AuthorizedAdminPage>
|
||||
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<String, dynamic>;
|
||||
@ -140,7 +141,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
),
|
||||
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<AuthorizedAdminPage>
|
||||
// 生效失效时间
|
||||
Widget keyTimeWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
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<AuthorizedAdminPage>
|
||||
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<AuthorizedAdminPage>
|
||||
// 实名认证
|
||||
Widget keyOnlyManageWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
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<AuthorizedAdminPage>
|
||||
|
||||
Widget keyBottomWidget(String tipStr) {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.all(20.w),
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text(
|
||||
tipStr,
|
||||
@ -233,26 +236,27 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
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: <Widget>[
|
||||
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<AuthorizedAdminPage>
|
||||
// 实名认证
|
||||
Widget keyRealNameWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
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<AuthorizedAdminPage>
|
||||
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<AuthorizedAdminPage>
|
||||
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<AuthorizedAdminPage>
|
||||
// 发送电子钥匙成功
|
||||
Widget sendElectronicKeySucceed() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 250.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
@ -327,9 +330,9 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"发送成功",
|
||||
'发送成功',
|
||||
style: TextStyle(
|
||||
fontSize: 26.sp,
|
||||
color: Colors.black,
|
||||
@ -354,13 +357,12 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
),
|
||||
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<AuthorizedAdminPage>
|
||||
OutLineBtn(
|
||||
btnName: '微信通知',
|
||||
onClick: () {
|
||||
NativeInteractionTool()
|
||||
.loadNativeShare(shareText: state.pwdShareStr);
|
||||
logic.sendMsg(
|
||||
isPhone: state.emailOrPhoneController.text.contains('@'));
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
@ -387,7 +389,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
height: 65.h,
|
||||
width: 300.w,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
@ -425,38 +427,37 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
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<AuthorizedAdminPage>
|
||||
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<AuthorizedAdminPage>
|
||||
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<AuthorizedAdminPage>
|
||||
);
|
||||
}
|
||||
|
||||
Future _openModalBottomSheet() async {
|
||||
void _openModalBottomSheet() {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
shape: RoundedRectangleBorder(
|
||||
@ -506,7 +507,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
constraints: BoxConstraints(maxHeight: 270.h),
|
||||
builder: (BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: ScreenUtil().screenWidth,
|
||||
height: 180.h,
|
||||
@ -537,7 +538,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
}
|
||||
|
||||
List<Widget> initBottomSheetList() {
|
||||
List<Widget> widgetList = [];
|
||||
final List<Widget> widgetList = <Widget>[];
|
||||
|
||||
widgetList.add(buildCenter3('images/icon_wechat.png', '微信好友', 0));
|
||||
widgetList.add(buildCenter3('images/icon_message.png', '短信', 1));
|
||||
@ -557,7 +558,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
EdgeInsets.only(top: 20.w, bottom: 20.w, left: 10.w, right: 10.w),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
imageName,
|
||||
width: 50.w,
|
||||
@ -579,7 +580,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
|
||||
}
|
||||
|
||||
//\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<AuthorizedAdminPage>
|
||||
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<AuthorizedAdminPage>
|
||||
child: TabBarView(
|
||||
controller: state.tabController,
|
||||
children: _itemTabs
|
||||
.map((ItemView item) => Obx(() => indexChangeWidget()))
|
||||
.map((ItemView item) => Obx(indexChangeWidget))
|
||||
.toList()),
|
||||
);
|
||||
}
|
||||
|
||||
final List<ItemView> _itemTabs = <ItemView>[
|
||||
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'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -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; //是否需要实名认证的必填项
|
||||
}
|
||||
|
||||
@ -0,0 +1,71 @@
|
||||
class NoticeTemplateEntity {
|
||||
NoticeTemplateEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
|
||||
NoticeTemplateEntity.fromJson(Map<String, dynamic> 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<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['errorCode'] = errorCode;
|
||||
data['description'] = description;
|
||||
data['errorMsg'] = errorMsg;
|
||||
data['data'] = this.data;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
if (json['list'] is List) {
|
||||
json['list'].forEach((dynamic element) {
|
||||
list?.add(Item.fromJson(element));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
List<Item>? list = [];
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['list'] = list;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Item {
|
||||
Item.fromJson(Map<String, dynamic> 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<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['type'] = type;
|
||||
data['name'] = name;
|
||||
data['template'] = template;
|
||||
data['isUse'] = isUse;
|
||||
data['fee'] = fee;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -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<AuthorizedAdminListPage> {
|
||||
final logic = Get.put(AuthorizedAdminListLogic());
|
||||
final state = Get.find<AuthorizedAdminListLogic>().state;
|
||||
final AuthorizedAdminListLogic logic = Get.put(AuthorizedAdminListLogic());
|
||||
final AuthorizedAdminListState state = Get.find<AuthorizedAdminListLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -37,7 +38,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
|
||||
Future<void> 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<AuthorizedAdminListPage> {
|
||||
mockRequest();
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(child: _buildMainUI()),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
@ -72,7 +73,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
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<AuthorizedAdminListPage> {
|
||||
}
|
||||
|
||||
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<AuthorizedAdminListPage> {
|
||||
}
|
||||
|
||||
return Slidable(
|
||||
key: ValueKey(indexEntity.keyId),
|
||||
key: ValueKey<int?>(indexEntity.keyId),
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
children: <Widget>[
|
||||
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<AuthorizedAdminListPage> {
|
||||
isAdminKey, () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.electronicKeyDetailPage,
|
||||
arguments: {
|
||||
"itemData": indexEntity,
|
||||
}).then((val) {
|
||||
arguments: <String, ElectronicKeyListItem>{
|
||||
'itemData': indexEntity,
|
||||
}).then((Object? val) {
|
||||
if (val != null) {
|
||||
logic.mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
@ -172,14 +173,14 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
|
||||
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<AuthorizedAdminListPage> {
|
||||
color: Colors.white,
|
||||
height: 100.h,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(width: 30.w),
|
||||
Image.asset(
|
||||
avatarURL,
|
||||
@ -203,13 +204,13 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 1.sw - 110.w - 100.w,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: Text(receiveUser,
|
||||
maxLines: 1,
|
||||
@ -231,7 +232,7 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
|
||||
SizedBox(height: 10.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
useDate,
|
||||
style: TextStyle(
|
||||
|
||||
@ -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();
|
||||
|
||||
}
|
||||
//发送批量授权管理员
|
||||
Future<void> 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: <dynamic>[],
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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<VolumeAuthorizationLockPage> createState() =>
|
||||
@ -33,53 +29,23 @@ class VolumeAuthorizationLockPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
//批量授权锁页面
|
||||
class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPage> {
|
||||
final logic = Get.put(VolumeAuthorizationLockLogic());
|
||||
final state = Get.find<VolumeAuthorizationLockLogic>().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<VolumeAuthorizationLockPage> {
|
||||
final VolumeAuthorizationLockLogic logic =
|
||||
Get.put(VolumeAuthorizationLockLogic());
|
||||
final VolumeAuthorizationLockState state =
|
||||
Get.find<VolumeAuthorizationLockLogic>().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<VolumeAuthorizationLockPag
|
||||
{
|
||||
// 永久
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
keyInfoWidget(),
|
||||
remoteUnlockingWidget(),
|
||||
SizedBox(
|
||||
@ -100,7 +66,7 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
default:
|
||||
// 限时
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
keyInfoWidget(),
|
||||
keyTimeWidget(),
|
||||
remoteUnlockingWidget(),
|
||||
@ -117,47 +83,47 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
// 顶部钥匙信息widget
|
||||
Widget keyInfoWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
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<String, dynamic>;
|
||||
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<VolumeAuthorizationLockPag
|
||||
// 生效失效时间
|
||||
Widget keyTimeWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
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<VolumeAuthorizationLockPag
|
||||
// 远程开锁
|
||||
Widget remoteUnlockingWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
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: <String, String>{'keyLimits': '1'})
|
||||
.then((Object? value) {
|
||||
//得到选中的锁ID列表
|
||||
if (value != null) {
|
||||
value as Map<String, dynamic>;
|
||||
_lockIdList = value['selectLockIdList'];
|
||||
|
||||
if (value is Map<String, dynamic> &&
|
||||
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<VolumeAuthorizationLockPag
|
||||
|
||||
Widget keyBottomWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
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<VolumeAuthorizationLockPag
|
||||
height: 50.h,
|
||||
width: 300.w,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: editController,
|
||||
@ -294,89 +274,51 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
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 _contactPicker.selectContact();
|
||||
setState(() {
|
||||
if (currentContact!.phoneNumbers!.isNotEmpty) {
|
||||
_emailOrPhoneController.text = currentContact
|
||||
.phoneNumbers![0]
|
||||
.replaceAll(RegExp(r"\s+\b|\b\s"), "");
|
||||
}
|
||||
if (currentContact.fullName!.isNotEmpty) {
|
||||
_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(() {
|
||||
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()
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//发送批量授权管理员
|
||||
Future<void> 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: <Widget>[
|
||||
Container(
|
||||
height: 250.h,
|
||||
width: 1.sw,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
@ -390,9 +332,9 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"发送成功",
|
||||
'发送成功',
|
||||
style: TextStyle(
|
||||
fontSize: 26.sp,
|
||||
color: Colors.black,
|
||||
@ -409,51 +351,30 @@ class _VolumeAuthorizationLockPageState extends State<VolumeAuthorizationLockPag
|
||||
SubmitBtn(
|
||||
btnName: '完成'.tr,
|
||||
onClick: () {
|
||||
_isSendSuccess = false;
|
||||
state.isSendSuccess.value = false;
|
||||
Navigator.pop(context, true);
|
||||
}),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
OutLineBtn(
|
||||
btnName: '邮件通知',
|
||||
onClick: () {
|
||||
Navigator.pushNamed(context, Routers.sendEmailNotificationPage);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
OutLineBtn(
|
||||
btnName: '微信通知',
|
||||
onClick: () {},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
OutLineBtn(
|
||||
btnName: '标记为已入住',
|
||||
onClick: () {},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
CupertinoSwitch _switch() {
|
||||
//仅管理自己创建的用户
|
||||
CupertinoSwitch _onlyManageYouCreatesUserSwitch() {
|
||||
return CupertinoSwitch(
|
||||
activeColor: CupertinoColors.activeBlue,
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: _isRemoteUnlock,
|
||||
onChanged: (value) {
|
||||
value: state.onlyManageYouCreatesUser.value,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
_isRemoteUnlock = !_isRemoteUnlock;
|
||||
state.onlyManageYouCreatesUser.value =
|
||||
!state.onlyManageYouCreatesUser.value;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
String intToStr(int v) {
|
||||
return (v < 10) ? "0$v" : "$v";
|
||||
return (v < 10) ? '0$v' : '$v';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
|
||||
class VolumeAuthorizationLockState{
|
||||
|
||||
}
|
||||
class VolumeAuthorizationLockState {
|
||||
final FlutterContactPicker contactPicker = FlutterContactPicker();
|
||||
final TextEditingController emailOrPhoneController =
|
||||
TextEditingController(); //邮箱/手机号输入框
|
||||
final TextEditingController keyNameController =
|
||||
TextEditingController(); //钥匙名输入框
|
||||
late Contact contact;
|
||||
RxList<int> lockIdList = <int>[].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<DateTime> effectiveDateTime = DateTime.now().obs;
|
||||
Rx<DateTime> failureDateTime = DateTime.now().obs;
|
||||
RxString countryName = '中国'.obs;
|
||||
RxString countryCode = '86'.obs;
|
||||
RxString selectWidgetType = '0'.obs;
|
||||
}
|
||||
|
||||
@ -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<void> 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<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -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<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -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<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -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<int> 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<int> 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);
|
||||
|
||||
@ -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<int> 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<int> 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);
|
||||
|
||||
@ -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<CheckingInAddHolidaysPage> {
|
||||
final logic = Get.put(CheckingInAddHolidaysLogic());
|
||||
final state = Get.find<CheckingInAddHolidaysLogic>().state;
|
||||
final CheckingInAddHolidaysLogic logic =
|
||||
Get.put(CheckingInAddHolidaysLogic());
|
||||
final CheckingInAddHolidaysState state =
|
||||
Get.find<CheckingInAddHolidaysLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -32,27 +36,31 @@ class _CheckingInAddHolidaysPageState extends State<CheckingInAddHolidaysPage> {
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
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, <String>[yyyy, '-', mm, '-', dd]);
|
||||
state.beginDate.value = beginDate;
|
||||
Get.back();
|
||||
// Navigator.of(context).pop(true);
|
||||
@ -61,17 +69,20 @@ class _CheckingInAddHolidaysPageState extends State<CheckingInAddHolidaysPage> {
|
||||
})),
|
||||
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, <String>[yyyy, '-', mm, '-', dd]);
|
||||
state.endDate.value = endDate;
|
||||
Get.back();
|
||||
});
|
||||
@ -85,11 +96,12 @@ class _CheckingInAddHolidaysPageState extends State<CheckingInAddHolidaysPage> {
|
||||
action: () async {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
builder: (BuildContext context) {
|
||||
return ShowCalendar(
|
||||
datePickerMode: DatePickerMode.day,
|
||||
selectAction: (dateTime) {
|
||||
String makeUpWorkDate = formatDate(dateTime, [yyyy,'-',mm,'-',dd]);
|
||||
selectAction: (DateTime dateTime) {
|
||||
final String makeUpWorkDate = formatDate(
|
||||
dateTime, <String>[yyyy, '-', mm, '-', dd]);
|
||||
state.makeUpWorkDate.value = makeUpWorkDate;
|
||||
Get.back();
|
||||
});
|
||||
@ -112,30 +124,26 @@ class _CheckingInAddHolidaysPageState extends State<CheckingInAddHolidaysPage> {
|
||||
}
|
||||
|
||||
Widget getTFWidget(String tfStr) {
|
||||
return Container(
|
||||
height: 50.h,
|
||||
width: 300.w,
|
||||
// color: Colors.red,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.staffNameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
return Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
maxLines: 2,
|
||||
minLines: 1,
|
||||
controller: state.staffNameController,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(bottom: 3),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 22.sp, color: AppColors.darkGrayTextColor, height: 1),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
isCollapsed: true,
|
||||
),
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
LengthLimitingTextInputFormatter(30),
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -145,7 +153,7 @@ class _CheckingInAddHolidaysPageState extends State<CheckingInAddHolidaysPage> {
|
||||
return GestureDetector(
|
||||
onTap: () {},
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
'images/icon_round_unSelect.png',
|
||||
width: 40.w,
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/checkingIn/checkingInHolidays/checkingInSetHolidays/checkingInSetHolidays_state.dart';
|
||||
import 'package:star_lock/tools/noData.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/style/picker_style.dart';
|
||||
@ -25,8 +26,10 @@ class CheckingInSetHolidaysPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
final logic = Get.put(CheckingInSetHolidaysLogic());
|
||||
final state = Get.find<CheckingInSetHolidaysLogic>().state;
|
||||
final CheckingInSetHolidaysLogic logic =
|
||||
Get.put(CheckingInSetHolidaysLogic());
|
||||
final CheckingInSetHolidaysState state =
|
||||
Get.find<CheckingInSetHolidaysLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -37,12 +40,14 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
titleWidget: titleWidget(),
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
actionsList: <Widget>[
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
var data = await Get.toNamed(
|
||||
final dynamic data = await Get.toNamed(
|
||||
Routers.checkingInAddHolidaysPage,
|
||||
arguments: {"companyId": state.companyId.value});
|
||||
arguments: <String, String>{
|
||||
'companyId': state.companyId.value
|
||||
});
|
||||
if (data != null) {
|
||||
logic.editStaffLoadData();
|
||||
}
|
||||
@ -58,12 +63,12 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
],
|
||||
),
|
||||
body: Obx(() {
|
||||
return state.holidaysListData.value!.isNotEmpty
|
||||
return state.holidaysListData.isNotEmpty
|
||||
? ListView.builder(
|
||||
itemCount: state.holidaysListData.value!.length,
|
||||
itemBuilder: (c, index) {
|
||||
HolidaysMonthListData holidaysMonthListData =
|
||||
state.holidaysListData.value![index];
|
||||
itemCount: state.holidaysListData.length,
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final HolidaysMonthListData holidaysMonthListData =
|
||||
state.holidaysListData[index];
|
||||
return _checkingInListMouthItem(holidaysMonthListData);
|
||||
})
|
||||
: NoData();
|
||||
@ -71,34 +76,44 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
}
|
||||
|
||||
Widget _checkingInListMouthItem(HolidaysMonthListData holidaysMonthListData) {
|
||||
final double width = Get.width - 20.w * 2;
|
||||
final double l = width * 0.2;
|
||||
final double r = width * 0.8;
|
||||
return GestureDetector(
|
||||
child: Container(
|
||||
height: 140.h * holidaysMonthListData.listItem!.length + 20.w,
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: <Color>[
|
||||
colorWithMonth(int.parse(
|
||||
holidaysMonthListData.listItem![0].month.toString())),
|
||||
Colors.white
|
||||
],
|
||||
stops: const <double>[0.2, 0.2],
|
||||
),
|
||||
),
|
||||
margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w),
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: colorWithMonth(int.parse(
|
||||
holidaysMonthListData.listItem![0].month.toString())),
|
||||
width: 100.w,
|
||||
height: 140.h * holidaysMonthListData.listItem!.length,
|
||||
width: l,
|
||||
child: Center(
|
||||
child: Text(
|
||||
"${holidaysMonthListData.listItem![0].month}\n${TranslationLoader.lanKeys!.month!.tr}",
|
||||
'${holidaysMonthListData.listItem![0].month}\n${TranslationLoader.lanKeys!.month!.tr}',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 28.sp, color: Colors.white),
|
||||
))),
|
||||
SizedBox(
|
||||
height: 140.h * holidaysMonthListData.listItem!.length,
|
||||
width: 1.sw - 100.w - 20.w * 2,
|
||||
width: r,
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: holidaysMonthListData.listItem!.length,
|
||||
itemBuilder: (c, index) {
|
||||
ListItem listItem = holidaysMonthListData.listItem![index];
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final ListItem listItem =
|
||||
holidaysMonthListData.listItem![index];
|
||||
return _checkingInListItem(
|
||||
index,
|
||||
listItem.vacationName,
|
||||
DateTool().dateToYMDString(
|
||||
listItem.vacationStartDate.toString()),
|
||||
@ -107,10 +122,10 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
listItem.fillClassDate!.isNotEmpty
|
||||
? DateTool().dateToYMDString(
|
||||
listItem.fillClassDate.toString())
|
||||
: "", () async {
|
||||
var data = await Get.toNamed(
|
||||
: '', () async {
|
||||
final dynamic data = await Get.toNamed(
|
||||
Routers.checkingInDeletHolidaysPage,
|
||||
arguments: {"listItem": listItem});
|
||||
arguments: <String, ListItem>{'listItem': listItem});
|
||||
if (data != null) {
|
||||
logic.editStaffLoadData();
|
||||
}
|
||||
@ -123,83 +138,66 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _checkingInListItem(
|
||||
int index,
|
||||
String? lockTypeTitle,
|
||||
String? vacationStartDate,
|
||||
String? vacationEndDate,
|
||||
String? makeUpClass,
|
||||
Function() action) {
|
||||
Widget _checkingInListItem(String? lockTypeTitle, String? vacationStartDate,
|
||||
String? vacationEndDate, String? makeUpClass, Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
color: Colors.white,
|
||||
height: 140.h,
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
lockTypeTitle!,
|
||||
style: TextStyle(fontSize: 24.sp),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${TranslationLoader.lanKeys!.libertyDay!.tr}:$vacationStartDate - $vacationEndDate",
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${TranslationLoader.lanKeys!.coverDate!.tr}:$makeUpClass",
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
child: Container(
|
||||
padding:
|
||||
EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h, bottom: 10.h),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: AppColors.mainBackgroundColor, width: 1.h, // 设置边框宽度
|
||||
),
|
||||
),
|
||||
Container(color: AppColors.mainBackgroundColor, height: 1.h)
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
Characters(lockTypeTitle!).join('\u{200B}'),
|
||||
style: TextStyle(fontSize: 24.sp),
|
||||
),
|
||||
SizedBox(height: 10.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'${TranslationLoader.lanKeys!.libertyDay!.tr}:$vacationStartDate - $vacationEndDate',
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'${TranslationLoader.lanKeys!.coverDate!.tr}:$makeUpClass',
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget titleWidget() {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
showListType();
|
||||
},
|
||||
onTap: showListType,
|
||||
child: Obx(() => Container(
|
||||
width: 300.w,
|
||||
height: 50.h,
|
||||
color: AppColors.mainColor,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"${state.selectYear.value}${TranslationLoader.lanKeys!.year!.tr}",
|
||||
'${state.selectYear.value}${TranslationLoader.lanKeys!.year!.tr}',
|
||||
style: TextStyle(color: Colors.white, fontSize: 26.sp),
|
||||
),
|
||||
SizedBox(
|
||||
@ -226,9 +224,7 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
// 样式 详见下方样式
|
||||
pickerStyle: PickerStyle(
|
||||
cancelButton: GestureDetector(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
},
|
||||
onTap: Get.back,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.only(left: 22, right: 12),
|
||||
@ -237,9 +233,7 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
),
|
||||
),
|
||||
commitButton: GestureDetector(
|
||||
onTap: () {
|
||||
Get.back();
|
||||
},
|
||||
onTap: Get.back,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.only(left: 22, right: 12),
|
||||
@ -252,7 +246,7 @@ class _CheckingInSetHolidaysPageState extends State<CheckingInSetHolidaysPage> {
|
||||
selectDate: PDuration(year: 2023),
|
||||
minDate: PDuration(year: 1900),
|
||||
maxDate: PDuration(year: 2100),
|
||||
onConfirm: (p) {
|
||||
onConfirm: (PDuration p) {
|
||||
state.selectYear.value = p.year!;
|
||||
logic.editStaffLoadData();
|
||||
},
|
||||
|
||||
@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInListMonth_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/checkingIn/checkingInList/checkingInList_state.dart';
|
||||
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
@ -23,8 +25,8 @@ class CheckingInListPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CheckingInListPageState extends State<CheckingInListPage> {
|
||||
final logic = Get.put(CheckingInListLogic());
|
||||
final state = Get.find<CheckingInListLogic>().state;
|
||||
final CheckingInListLogic logic = Get.put(CheckingInListLogic());
|
||||
final CheckingInListState state = Get.find<CheckingInListLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -35,26 +37,34 @@ class _CheckingInListPageState extends State<CheckingInListPage> {
|
||||
titleWidget: titleWidget(),
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
(state.getKeyInfosData.value.keyRight == 1) ?
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
Get.toNamed(Routers.checkingInSetPage, arguments: {
|
||||
"getKeyInfosData": state.getKeyInfosData.value,
|
||||
});
|
||||
}else{
|
||||
// Get.toNamed(Routers.selectLockTypePage);
|
||||
logic.showToast("演示模式");
|
||||
}
|
||||
},
|
||||
child: Image.asset('images/main/icon_lockDetail_checkIn_set.png', width: 36.w, height: 36.w,)) : Container(),
|
||||
actionsList: <Widget>[
|
||||
if (state.getKeyInfosData.value.keyRight == 1)
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
final bool? isDemoMode =
|
||||
await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
Get.toNamed(Routers.checkingInSetPage,
|
||||
arguments: <String, LockListInfoItemEntity>{
|
||||
'getKeyInfosData': state.getKeyInfosData.value,
|
||||
});
|
||||
} else {
|
||||
// Get.toNamed(Routers.selectLockTypePage);
|
||||
logic.showToast('演示模式');
|
||||
}
|
||||
},
|
||||
child: Image.asset(
|
||||
'images/main/icon_lockDetail_checkIn_set.png',
|
||||
width: 36.w,
|
||||
height: 36.w,
|
||||
))
|
||||
else
|
||||
Container(),
|
||||
SizedBox(width: 30.w),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
topInfo(),
|
||||
SizedBox(height: 10.h),
|
||||
middleDayInfo(),
|
||||
@ -70,7 +80,7 @@ class _CheckingInListPageState extends State<CheckingInListPage> {
|
||||
// height: 280.h,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(height: 30.h),
|
||||
Obx(() => Container(
|
||||
width: 110.w,
|
||||
@ -80,32 +90,38 @@ class _CheckingInListPageState extends State<CheckingInListPage> {
|
||||
color: AppColors.mainColor,
|
||||
borderRadius: BorderRadius.circular(60.w),
|
||||
),
|
||||
child: Image.asset(getTopImg(), width: 120.w, height: 120.w)
|
||||
)),
|
||||
child: Image.asset(getTopImg(), width: 120.w, height: 120.w))),
|
||||
SizedBox(height: 10.h),
|
||||
Obx(() => Text(getTopTitle(), style: TextStyle(color: Colors.black, fontSize: 24.sp))),
|
||||
Obx(() => Text(getTopTitle(),
|
||||
style: TextStyle(color: Colors.black, fontSize: 24.sp))),
|
||||
SizedBox(height: 30.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
// SizedBox(width: 30.w,),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(width: 20.w,),
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 20.w,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
final bool? isDemoMode =
|
||||
await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
setState(() {
|
||||
state.isDay.value = true;
|
||||
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(state.checkListDateTimestamp.value);
|
||||
String beginDate = formatDate(dateTime, [mm,'-',dd]);
|
||||
final DateTime dateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
state.checkListDateTimestamp.value);
|
||||
final String beginDate =
|
||||
formatDate(dateTime, <String>[mm, '-', dd]);
|
||||
state.checkListDate.value = beginDate;
|
||||
logic.loadDataByType();
|
||||
});
|
||||
}else{
|
||||
} else {
|
||||
// Get.toNamed(Routers.selectLockTypePage);
|
||||
logic.showToast("演示模式");
|
||||
logic.showToast('演示模式');
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
@ -113,37 +129,47 @@ class _CheckingInListPageState extends State<CheckingInListPage> {
|
||||
// height: 100.h,
|
||||
color: Colors.white,
|
||||
child: Obx(() => Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text(TranslationLoader.lanKeys!.dailyCharts!.tr, style: TextStyle(color: state.isDay.value ? AppColors.mainColor : Colors.black, fontSize: 22.sp)),
|
||||
SizedBox(height: 10.h),
|
||||
Visibility(
|
||||
visible: state.isDay.value,
|
||||
child: Container(
|
||||
width: 20.w,
|
||||
height: 2.h,
|
||||
color: state.isDay.value ? AppColors.mainColor : Colors.black
|
||||
),
|
||||
)
|
||||
],
|
||||
)),
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
Text(TranslationLoader.lanKeys!.dailyCharts!.tr,
|
||||
style: TextStyle(
|
||||
color: state.isDay.value
|
||||
? AppColors.mainColor
|
||||
: Colors.black,
|
||||
fontSize: 22.sp)),
|
||||
SizedBox(height: 10.h),
|
||||
Visibility(
|
||||
visible: state.isDay.value,
|
||||
child: Container(
|
||||
width: 20.w,
|
||||
height: 2.h,
|
||||
color: state.isDay.value
|
||||
? AppColors.mainColor
|
||||
: Colors.black),
|
||||
)
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
// SizedBox(width: 20.w,),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
final bool? isDemoMode =
|
||||
await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
setState(() {
|
||||
state.isDay.value = false;
|
||||
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(state.checkListDateTimestamp.value);
|
||||
String beginDate = formatDate(dateTime, [mm]);
|
||||
final DateTime dateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
state.checkListDateTimestamp.value);
|
||||
final String beginDate =
|
||||
formatDate(dateTime, <String>[mm]);
|
||||
state.checkListDate.value = beginDate;
|
||||
logic.loadDataByType();
|
||||
});
|
||||
}else{
|
||||
} else {
|
||||
// Get.toNamed(Routers.selectLockTypePage);
|
||||
logic.showToast("演示模式");
|
||||
logic.showToast('演示模式');
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
@ -151,49 +177,76 @@ class _CheckingInListPageState extends State<CheckingInListPage> {
|
||||
// height: 100.h,
|
||||
color: Colors.white,
|
||||
child: Obx(() => Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text(TranslationLoader.lanKeys!.monthlyLeaderboard!.tr, style: TextStyle(color: !state.isDay.value ? AppColors.mainColor : Colors.black, fontSize: 22.sp)),
|
||||
SizedBox(height: 10.h),
|
||||
Visibility(
|
||||
visible: !state.isDay.value,
|
||||
child: Container(width: 20.w, height: 2.h, color: !state.isDay.value ? AppColors.mainColor : Colors.black))
|
||||
],
|
||||
)),
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
TranslationLoader
|
||||
.lanKeys!.monthlyLeaderboard!.tr,
|
||||
style: TextStyle(
|
||||
color: !state.isDay.value
|
||||
? AppColors.mainColor
|
||||
: Colors.black,
|
||||
fontSize: 22.sp)),
|
||||
SizedBox(height: 10.h),
|
||||
Visibility(
|
||||
visible: !state.isDay.value,
|
||||
child: Container(
|
||||
width: 20.w,
|
||||
height: 2.h,
|
||||
color: !state.isDay.value
|
||||
? AppColors.mainColor
|
||||
: Colors.black))
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
final bool? isDemoMode =
|
||||
await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
await showDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
builder: (BuildContext context) {
|
||||
return ShowCalendar(
|
||||
datePickerMode: DatePickerMode.day,
|
||||
selectAction: (dateTime) {
|
||||
selectAction: (DateTime dateTime) {
|
||||
setState(() {
|
||||
state.checkListDateTimestamp.value = dateTime.millisecondsSinceEpoch;
|
||||
String beginDate = formatDate(dateTime, state.isDay.value ? [mm,'-',dd] : [mm]);
|
||||
state.checkListDateTimestamp.value =
|
||||
dateTime.millisecondsSinceEpoch;
|
||||
final String beginDate = formatDate(
|
||||
dateTime,
|
||||
state.isDay.value
|
||||
? <String>[mm, '-', dd]
|
||||
: <String>[mm]);
|
||||
state.checkListDate.value = beginDate;
|
||||
logic.loadDataByType();
|
||||
Get.back();
|
||||
});
|
||||
});
|
||||
});
|
||||
}else{
|
||||
} else {
|
||||
// Get.toNamed(Routers.selectLockTypePage);
|
||||
logic.showToast("演示模式");
|
||||
logic.showToast('演示模式');
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(state.checkListDate.value, style: TextStyle(color: Colors.black, fontSize: 22.sp),),
|
||||
Image.asset('images/icon_grayPullDown.png', width: 50.w, height: 30.w,),
|
||||
SizedBox(width: 10.w,),
|
||||
children: <Widget>[
|
||||
Text(
|
||||
state.checkListDate.value,
|
||||
style: TextStyle(color: Colors.black, fontSize: 22.sp),
|
||||
),
|
||||
Image.asset(
|
||||
'images/icon_grayPullDown.png',
|
||||
width: 50.w,
|
||||
height: 30.w,
|
||||
),
|
||||
SizedBox(
|
||||
width: 10.w,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
@ -207,131 +260,174 @@ class _CheckingInListPageState extends State<CheckingInListPage> {
|
||||
|
||||
Widget middleDayInfo() {
|
||||
return Obx(() => Visibility(
|
||||
visible: state.isDay.value,
|
||||
child: Container(
|
||||
height: 80.h,
|
||||
color: Colors.white,
|
||||
margin: EdgeInsets.only(left: 15.h, right: 15.h, bottom: 10.h),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Column(
|
||||
visible: state.isDay.value,
|
||||
child: Container(
|
||||
height: 80.h,
|
||||
color: Colors.white,
|
||||
margin: EdgeInsets.only(left: 15.h, right: 15.h, bottom: 10.h),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
SizedBox(height: 5.h),
|
||||
Text(state.lateTimes.value, style: TextStyle(color: Colors.black, fontSize: 20.sp)),
|
||||
Text(TranslationLoader.lanKeys!.beLate!.tr, style: TextStyle(color: Colors.black, fontSize: 22.sp)),
|
||||
SizedBox(height: 5.h),
|
||||
children: <Widget>[
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
SizedBox(height: 5.h),
|
||||
Text(state.lateTimes.value,
|
||||
style: TextStyle(color: Colors.black, fontSize: 20.sp)),
|
||||
Text(TranslationLoader.lanKeys!.beLate!.tr,
|
||||
style: TextStyle(color: Colors.black, fontSize: 22.sp)),
|
||||
SizedBox(height: 5.h),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
SizedBox(height: 5.h),
|
||||
Text(state.earlyTimes.value,
|
||||
style: TextStyle(color: Colors.black, fontSize: 20.sp)),
|
||||
Text(TranslationLoader.lanKeys!.leaveEarly!.tr,
|
||||
style: TextStyle(color: Colors.black, fontSize: 22.sp)),
|
||||
SizedBox(height: 5.h),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
SizedBox(height: 5.h),
|
||||
Text(state.noPunchTimes.value,
|
||||
style: TextStyle(color: Colors.black, fontSize: 20.sp)),
|
||||
Text(TranslationLoader.lanKeys!.noCardPunched!.tr,
|
||||
style: TextStyle(color: Colors.black, fontSize: 22.sp)),
|
||||
SizedBox(height: 5.h),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
SizedBox(height: 5.h),
|
||||
Text(state.earlyTimes.value, style: TextStyle(color: Colors.black, fontSize: 20.sp)),
|
||||
Text(TranslationLoader.lanKeys!.leaveEarly!.tr, style: TextStyle(color: Colors.black, fontSize: 22.sp)),
|
||||
SizedBox(height: 5.h),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
SizedBox(height: 5.h),
|
||||
Text(state.noPunchTimes.value, style: TextStyle(color: Colors.black, fontSize: 20.sp)),
|
||||
Text(TranslationLoader.lanKeys!.noCardPunched!.tr, style: TextStyle(color: Colors.black, fontSize: 22.sp)),
|
||||
SizedBox(height: 5.h),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
Widget getBottomList(){
|
||||
if((state.isDay.value == true && (state.listType.value == "1")) || (state.isDay.value == true && (state.listType.value == "2"))){
|
||||
Widget getBottomList() {
|
||||
if ((state.isDay.value == true && (state.listType.value == '1')) ||
|
||||
(state.isDay.value == true && (state.listType.value == '2'))) {
|
||||
return bottomDayList();
|
||||
}else{
|
||||
} else {
|
||||
return bottomMonthList();
|
||||
}
|
||||
}
|
||||
|
||||
Widget bottomDayList() {
|
||||
return Obx(() => state.checkingInDayListData.value.isNotEmpty ? ListView.separated(
|
||||
itemCount: state.checkingInDayListData.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
AttendanceRecordDayList attendanceRecordList= state.checkingInDayListData.value[index];
|
||||
return _checkingInListItem(index, attendanceRecordList.headurl, attendanceRecordList.staffName, () {
|
||||
Get.toNamed(Routers.checkingInDetailPage, arguments: {
|
||||
// "getKeyInfosData": state.getKeyInfosData.value,
|
||||
"companyId": state.companyId.value,
|
||||
"staffId": attendanceRecordList.staffId,
|
||||
"staffName": attendanceRecordList.staffName,
|
||||
return Obx(() => state.checkingInDayListData.isNotEmpty
|
||||
? ListView.separated(
|
||||
itemCount: state.checkingInDayListData.length,
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final AttendanceRecordDayList attendanceRecordList =
|
||||
state.checkingInDayListData[index];
|
||||
return _checkingInListItem(
|
||||
index,
|
||||
attendanceRecordList.headurl,
|
||||
attendanceRecordList.staffName,
|
||||
attendanceRecordList.attendanceType, () {
|
||||
Get.toNamed(Routers.checkingInDetailPage,
|
||||
arguments: <String, Object?>{
|
||||
// "getKeyInfosData": state.getKeyInfosData.value,
|
||||
'companyId': state.companyId.value,
|
||||
'staffId': attendanceRecordList.staffId,
|
||||
'staffName': attendanceRecordList.staffName,
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return const Divider(height: 1, color: AppColors.greyLineColor);
|
||||
},
|
||||
) : NoData(noDataHeight: 1.sh - ScreenUtil().statusBarHeight*2 - 64.h - 280.h - 90.h,));
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(height: 1, color: AppColors.greyLineColor);
|
||||
},
|
||||
)
|
||||
: NoData(
|
||||
noDataHeight:
|
||||
1.sh - ScreenUtil().statusBarHeight * 2 - 64.h - 280.h - 90.h,
|
||||
));
|
||||
}
|
||||
|
||||
Widget bottomMonthList() {
|
||||
return Obx(() => state.checkingInMonthListData.value.isNotEmpty ? ListView.separated(
|
||||
itemCount: state.checkingInMonthListData.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
AttendanceRecordMonthList attendanceRecordList= state.checkingInMonthListData.value[index];
|
||||
return _checkingInListItem(index, attendanceRecordList.headurl, attendanceRecordList.staffName, () {
|
||||
Get.toNamed(Routers.checkingInDetailPage, arguments: {
|
||||
"companyId": state.companyId.value,
|
||||
"staffId": attendanceRecordList.staffId,
|
||||
"staffName": attendanceRecordList.staffName,
|
||||
});
|
||||
});
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return const Divider(height: 1, color: AppColors.greyLineColor);
|
||||
},
|
||||
) : NoData(noDataHeight: 1.sh - - ScreenUtil().statusBarHeight - 280.h - 90.h,));
|
||||
return Obx(() => state.checkingInMonthListData.isNotEmpty
|
||||
? ListView.separated(
|
||||
itemCount: state.checkingInMonthListData.length,
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final AttendanceRecordMonthList attendanceRecordList =
|
||||
state.checkingInMonthListData[index];
|
||||
return _checkingInListItem(
|
||||
index,
|
||||
attendanceRecordList.headurl,
|
||||
attendanceRecordList.staffName,
|
||||
attendanceRecordList.attendanceType, () {
|
||||
Get.toNamed(Routers.checkingInDetailPage,
|
||||
arguments: <String, Object?>{
|
||||
'companyId': state.companyId.value,
|
||||
'staffId': attendanceRecordList.staffId,
|
||||
'staffName': attendanceRecordList.staffName,
|
||||
});
|
||||
});
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(height: 1, color: AppColors.greyLineColor);
|
||||
},
|
||||
)
|
||||
: NoData(
|
||||
noDataHeight: 1.sh - -ScreenUtil().statusBarHeight - 280.h - 90.h,
|
||||
));
|
||||
}
|
||||
|
||||
Widget _checkingInListItem(int index, String? headUrl, String? name, Function() action) {
|
||||
Widget _checkingInListItem(
|
||||
int index, String? headUrl, String? name, int? type, Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
// height: 80.h,
|
||||
padding: EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h, bottom: 10.h),
|
||||
padding:
|
||||
EdgeInsets.only(left: 20.w, right: 20.w, top: 10.h, bottom: 10.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10.w),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 20.w,),
|
||||
Text("${index+1}", style: TextStyle(fontSize: 20.sp),),
|
||||
SizedBox(width: 20.w,),
|
||||
Image.asset('images/controls_user.png', width: 60.w, height: 60.w,),
|
||||
// Container(
|
||||
// width: 60.h,
|
||||
// height: 60.h,
|
||||
// decoration: BoxDecoration(
|
||||
// color: AppColors.mainColor,
|
||||
// border: Border.all(width: 1, color: AppColors.mainColor),
|
||||
// borderRadius: BorderRadius.circular(30.h),
|
||||
// ),
|
||||
// padding: EdgeInsets.all(10.w),
|
||||
// child: Image.asset(
|
||||
// 'images/controls_user.png',
|
||||
// width: 30.w,
|
||||
// height: 30.w,
|
||||
// color: Colors.white,
|
||||
// )),
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 20.w,
|
||||
),
|
||||
Text(
|
||||
'${index + 1}',
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
),
|
||||
SizedBox(
|
||||
width: 20.w,
|
||||
),
|
||||
if (headUrl == null || headUrl == '')
|
||||
Image.asset(
|
||||
getTypeIcon(type ?? 0),
|
||||
width: 60.w,
|
||||
height: 60.w,
|
||||
)
|
||||
else
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(100.w),
|
||||
child: Image.network(
|
||||
headUrl,
|
||||
width: 60.w,
|
||||
height: 60.w,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.w),
|
||||
Expanded(
|
||||
child: Text(name!, style: TextStyle(fontSize: 24.sp),),
|
||||
child: Text(
|
||||
name!,
|
||||
style: TextStyle(fontSize: 24.sp),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
Image.asset("images/icon_right_grey.png", width: 21.w, height: 21.w,),
|
||||
Image.asset(
|
||||
'images/icon_right_grey.png',
|
||||
width: 21.w,
|
||||
height: 21.w,
|
||||
),
|
||||
SizedBox(width: 20.h),
|
||||
],
|
||||
),
|
||||
@ -339,35 +435,71 @@ class _CheckingInListPageState extends State<CheckingInListPage> {
|
||||
);
|
||||
}
|
||||
|
||||
// 1APP 2密码 3卡 4指纹
|
||||
String getTypeIcon(int type) {
|
||||
String title = 'images/controls_user.png';
|
||||
switch (type) {
|
||||
case 1:
|
||||
// 蓝牙开锁
|
||||
title = 'images/controls_user.png';
|
||||
break;
|
||||
case 2:
|
||||
// 密码开锁
|
||||
title = 'images/icon_password.png';
|
||||
break;
|
||||
case 3:
|
||||
// ic卡
|
||||
title = 'images/icon_card.png';
|
||||
break;
|
||||
case 4:
|
||||
// 指纹开锁
|
||||
title = 'images/icon_fingerprint.png';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
Widget titleWidget() {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if(isDemoMode == false){
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
showListType();
|
||||
}else{
|
||||
} else {
|
||||
// Get.toNamed(Routers.selectLockTypePage);
|
||||
logic.showToast("演示模式");
|
||||
logic.showToast('演示模式');
|
||||
}
|
||||
},
|
||||
child: Obx(() => Container(
|
||||
// width: 200.w,
|
||||
// height: 60.h,
|
||||
color: AppColors.mainColor,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(state.listTypeStr.value, style: TextStyle(color: Colors.white, fontSize: 26.sp),),
|
||||
SizedBox(width: 5.w,),
|
||||
Image.asset('images/main/icon_lockDetail_checkIn_topTitle.png', width: 22.w, height: 16.w, fit: BoxFit.fill,)
|
||||
],
|
||||
),
|
||||
)),
|
||||
// width: 200.w,
|
||||
// height: 60.h,
|
||||
color: AppColors.mainColor,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
state.listTypeStr.value,
|
||||
style: TextStyle(color: Colors.white, fontSize: 26.sp),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5.w,
|
||||
),
|
||||
Image.asset(
|
||||
'images/main/icon_lockDetail_checkIn_topTitle.png',
|
||||
width: 22.w,
|
||||
height: 16.w,
|
||||
fit: BoxFit.fill,
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
void showListType() {
|
||||
var list = [
|
||||
final List<String> list = <String>[
|
||||
TranslationLoader.lanKeys!.earlyArrivalList!.tr,
|
||||
TranslationLoader.lanKeys!.lateList!.tr,
|
||||
TranslationLoader.lanKeys!.hardWorkingList!.tr
|
||||
@ -385,39 +517,39 @@ class _CheckingInListPageState extends State<CheckingInListPage> {
|
||||
//adapter: PickerAdapter(),
|
||||
data: list,
|
||||
//选择事件的回调
|
||||
clickCallBack: (int index, var str) {
|
||||
setState(() {
|
||||
state.listTypeStr.value = str.toString();
|
||||
state.isDay.value = true;
|
||||
if(index == 0){
|
||||
state.listType.value = "1";
|
||||
}else if(index == 1){
|
||||
state.listType.value = "2";
|
||||
}else if(index == 2){
|
||||
state.listType.value = "3";
|
||||
}
|
||||
logic.loadDataByType();
|
||||
});
|
||||
});
|
||||
clickCallBack: (int index, Object str) {
|
||||
setState(() {
|
||||
state.listTypeStr.value = str.toString();
|
||||
state.isDay.value = true;
|
||||
if (index == 0) {
|
||||
state.listType.value = '1';
|
||||
} else if (index == 1) {
|
||||
state.listType.value = '2';
|
||||
} else if (index == 2) {
|
||||
state.listType.value = '3';
|
||||
}
|
||||
logic.loadDataByType();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
String getTopImg(){
|
||||
if(state.listType.value == "1"){
|
||||
return "images/main/icon_lockDetail_checkInRanking_zd.png";
|
||||
}else if(state.listType.value == "2"){
|
||||
return "images/main/icon_lockDetail_checkInRanking_cd.png";
|
||||
}else{
|
||||
return "images/main/icon_lockDetail_checkInRanking_qf.png";
|
||||
String getTopImg() {
|
||||
if (state.listType.value == '1') {
|
||||
return 'images/main/icon_lockDetail_checkInRanking_zd.png';
|
||||
} else if (state.listType.value == '2') {
|
||||
return 'images/main/icon_lockDetail_checkInRanking_cd.png';
|
||||
} else {
|
||||
return 'images/main/icon_lockDetail_checkInRanking_qf.png';
|
||||
}
|
||||
}
|
||||
|
||||
String getTopTitle(){
|
||||
if(state.listType.value == "1"){
|
||||
return "无考勤记录";
|
||||
}else if(state.listType.value == "2"){
|
||||
return "大家干劲十足";
|
||||
}else{
|
||||
return "工作时长未出炉";
|
||||
String getTopTitle() {
|
||||
if (state.listType.value == '1') {
|
||||
return '无考勤记录';
|
||||
} else if (state.listType.value == '2') {
|
||||
return '大家干劲十足';
|
||||
} else {
|
||||
return '工作时长未出炉';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/checkingIn/checkingInSet/checkingInSet_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/lockSet/checkingInInfoData_entity.dart';
|
||||
|
||||
import '../../../../network/api_repository.dart';
|
||||
import '../../../../tools/baseGetXController.dart';
|
||||
@ -9,96 +11,94 @@ import '../../../../tools/dateTool.dart';
|
||||
import '../../../../tools/eventBusEventManage.dart';
|
||||
import 'checkingInSet_state.dart';
|
||||
|
||||
class CheckingInSetLogic extends BaseGetXController{
|
||||
class CheckingInSetLogic extends BaseGetXController {
|
||||
CheckingInSetState state = CheckingInSetState();
|
||||
|
||||
// 开启考勤获取是否有公司
|
||||
void openCheckingInData() async{
|
||||
var entity = await ApiRepository.to.openCheckingInData(
|
||||
lockId:state.getKeyInfosData.value.lockId.toString(),
|
||||
Future<void> openCheckingInData() async {
|
||||
final CheckingInInfoDataEntity entity = await ApiRepository.to.openCheckingInData(
|
||||
lockId: state.getKeyInfosData.value.lockId.toString(),
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.companyId.value = entity.data!.companyId.toString();
|
||||
getCheckInSetInfoData();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取获取考勤设置信息
|
||||
void getCheckInSetInfoData() async{
|
||||
var entity = await ApiRepository.to.getCheckInSetInfoData(
|
||||
Future<void> getCheckInSetInfoData() async {
|
||||
final CheckingInSetEntity entity = await ApiRepository.to.getCheckInSetInfoData(
|
||||
companyId: state.companyId.value,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.checkingInSetInfo.value = entity.data!;
|
||||
|
||||
state.beginTime.value = DateTool().dateToHNString(state.checkingInSetInfo.value.workStartTime.toString());
|
||||
state.endTime.value = DateTool().dateToHNString(state.checkingInSetInfo.value.workEndTime.toString());
|
||||
state.beginTimeTimestamp.value = state.checkingInSetInfo.value.workStartTime.toString();
|
||||
state.endTimeTimestamp.value = state.checkingInSetInfo.value.workEndTime.toString();
|
||||
state.beginTime.value = DateTool().dateToHNString(
|
||||
state.checkingInSetInfo.value.workStartTime.toString());
|
||||
state.endTime.value = DateTool()
|
||||
.dateToHNString(state.checkingInSetInfo.value.workEndTime.toString());
|
||||
state.beginTimeTimestamp.value =
|
||||
state.checkingInSetInfo.value.workStartTime.toString();
|
||||
state.endTimeTimestamp.value =
|
||||
state.checkingInSetInfo.value.workEndTime.toString();
|
||||
|
||||
state.weekDays.value = state.checkingInSetInfo.value.workDay!;
|
||||
state.weekDaysStr.value = state.weekDays.value.join(",");
|
||||
state.isCustom.value = (state.checkingInSetInfo.value.attendanceType! == 0) ? true : false;
|
||||
state.weekDaysStr.value = state.weekDays.join(',');
|
||||
state.isCustom.value = state.checkingInSetInfo.value.attendanceType! == 0;
|
||||
|
||||
state.staffNumber.value = state.checkingInSetInfo.value.staffNum!.toString();
|
||||
state.staffNumber.value =
|
||||
state.checkingInSetInfo.value.staffNum!.toString();
|
||||
state.companyName.value = state.checkingInSetInfo.value.companyName!;
|
||||
state.changeNameController.text = state.companyName.value;
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑考勤设置信息
|
||||
void editCheckInSetInfoData() async{
|
||||
var entity = await ApiRepository.to.editCheckInSetInfoData(
|
||||
Future<void> editCheckInSetInfoData() async {
|
||||
final LoginEntity entity = await ApiRepository.to.editCheckInSetInfoData(
|
||||
attendanceType: state.checkingInSetInfo.value.attendanceType.toString(),
|
||||
companyId: state.checkingInSetInfo.value.companyId.toString(),
|
||||
type: "1",
|
||||
type: '1',
|
||||
companyName: state.changeNameController.text,
|
||||
workEndTime: state.checkingInSetInfo.value.workEndTime.toString(),
|
||||
workStartTime: state.checkingInSetInfo.value.workStartTime.toString(),
|
||||
workDay:state.checkingInSetInfo.value.workDay!,
|
||||
workDay: state.checkingInSetInfo.value.workDay!,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.companyName.value = state.changeNameController.text;
|
||||
showToast("修改成功");
|
||||
showToast('修改成功');
|
||||
}
|
||||
}
|
||||
|
||||
// 删除公司
|
||||
void deletCompanyData() async{
|
||||
var entity = await ApiRepository.to.deletCompanyData(
|
||||
companyId:state.checkingInSetInfo.value.companyId!,
|
||||
Future<void> deletCompanyData() async {
|
||||
final CheckingInInfoDataEntity entity = await ApiRepository.to.deletCompanyData(
|
||||
companyId: state.checkingInSetInfo.value.companyId!,
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, "0"));
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
eventBus.fire(LockSetChangeSetRefreshLockDetailWithType(0, '0'));
|
||||
Get.close(2);
|
||||
}
|
||||
}
|
||||
|
||||
late StreamSubscription _teamEvent;
|
||||
|
||||
void _initLoadDataAction() {
|
||||
_teamEvent = eventBus.on<RefreshCheckInSetDataEvent>().listen((event) {
|
||||
_teamEvent = eventBus.on<RefreshCheckInSetDataEvent>().listen((RefreshCheckInSetDataEvent event) {
|
||||
getCheckInSetInfoData();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initLoadDataAction();
|
||||
openCheckingInData();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
_teamEvent.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import 'package:flutter/services.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/main/lockDetail/checkingIn/checkingInSet/checkingInSet_state.dart';
|
||||
|
||||
import '../../../../appRouters.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
@ -22,8 +23,8 @@ class CheckingInSetPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CheckingInSetPageState extends State<CheckingInSetPage> {
|
||||
final logic = Get.put(CheckingInSetLogic());
|
||||
final state = Get.find<CheckingInSetLogic>().state;
|
||||
final CheckingInSetLogic logic = Get.put(CheckingInSetLogic());
|
||||
final CheckingInSetState state = Get.find<CheckingInSetLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -31,17 +32,17 @@ class _CheckingInSetPageState extends State<CheckingInSetPage> {
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle:
|
||||
"${TranslationLoader.lanKeys!.checkingIn!.tr}${TranslationLoader.lanKeys!.set!.tr}",
|
||||
'${TranslationLoader.lanKeys!.checkingIn!.tr}${TranslationLoader.lanKeys!.set!.tr}',
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Obx(() => CommonItem(
|
||||
leftTitel:
|
||||
"公司名称".tr,
|
||||
// rightTitle: state.companyName.value ?? "",
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(),
|
||||
'公司名称'.tr,
|
||||
rightTitle: state.companyName.value ?? '',
|
||||
// isHaveRightWidget: true,
|
||||
// rightWidget: getTFWidget(),
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
@ -53,61 +54,55 @@ class _CheckingInSetPageState extends State<CheckingInSetPage> {
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.checkingInStaffManagePage, arguments: {
|
||||
"getKeyInfosData": state.getKeyInfosData.value,
|
||||
"companyId": state.companyId.value
|
||||
Get.toNamed(Routers.checkingInStaffManagePage, arguments: <String, Object>{
|
||||
'getKeyInfosData': state.getKeyInfosData.value,
|
||||
'companyId': state.companyId.value
|
||||
});
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel:
|
||||
"${TranslationLoader.lanKeys!.work!.tr}${TranslationLoader.lanKeys!.time!.tr}",
|
||||
rightTitle: (state.beginTime.value.isNotEmpty) ? "${state.beginTime.value} - ${state.endTime.value}" : "",
|
||||
rightTitle: (state.beginTime.value.isNotEmpty) ? '${state.beginTime.value} - ${state.endTime.value}' : '',
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
var data = await Get.toNamed(Routers.checkingInSetWorkTimePage, arguments: {
|
||||
var data = await Get.toNamed(Routers.checkingInSetWorkTimePage, arguments: <String, Object>{
|
||||
// "getKeyInfosData": state.getKeyInfosData.value,
|
||||
"companyId": state.companyId.value,
|
||||
"pushType": "2",
|
||||
"checkingInSetInfo": state.checkingInSetInfo.value,
|
||||
'companyId': state.companyId.value,
|
||||
'pushType': '2',
|
||||
'checkingInSetInfo': state.checkingInSetInfo.value,
|
||||
});
|
||||
if(data != null) {
|
||||
setState(() {
|
||||
// state.beginTime.value = data["beginTime"];
|
||||
// state.endTime.value = data["endTime"];
|
||||
// state.beginTimeTimestamp.value = data["beginTimeTimestamp"];
|
||||
// state.endTimeTimestamp.value = data["endTimeTimestamp"];
|
||||
logic.getCheckInSetInfoData();
|
||||
});
|
||||
setState(logic.getCheckInSetInfoData);
|
||||
}
|
||||
})),
|
||||
Obx(() => CommonItem(
|
||||
leftTitel:
|
||||
"${TranslationLoader.lanKeys!.workday!.tr}${TranslationLoader.lanKeys!.set!.tr}",
|
||||
rightTitle: state.isCustom.value == true ? state.weekDaysStr.value : (state.weekDaysStr.value.length == 5 ? "单休" : "双休"),
|
||||
rightTitle: state.isCustom.value == true ? state.weekDaysStr.value : (state.weekDaysStr.value.length == 5 ? '单休' : '双休'),
|
||||
isHaveLine: true,
|
||||
isHaveDirection: true,
|
||||
action: () async {
|
||||
var data = await Get.toNamed(Routers.checkingInSetWorkdaySet, arguments: {
|
||||
"getKeyInfosData": state.getKeyInfosData.value,
|
||||
"companyId": state.companyId.value,
|
||||
"pushType": "2",
|
||||
"checkingInSetInfo": state.checkingInSetInfo.value,
|
||||
var data = await Get.toNamed(Routers.checkingInSetWorkdaySet, arguments: <String, Object>{
|
||||
'getKeyInfosData': state.getKeyInfosData.value,
|
||||
'companyId': state.companyId.value,
|
||||
'pushType': '2',
|
||||
'checkingInSetInfo': state.checkingInSetInfo.value,
|
||||
});
|
||||
if(data != null) {
|
||||
state.isCustom.value = data["attendanceType"];
|
||||
state.weekDays.value = data["weekDays"];
|
||||
state.weekDaysStr.value = state.weekDays.value.join(",");
|
||||
state.isCustom.value = data['attendanceType'];
|
||||
state.weekDays.value = data['weekDays'];
|
||||
state.weekDaysStr.value = state.weekDays.join(',');
|
||||
}
|
||||
})),
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.holidays!.tr,
|
||||
rightTitle: "",
|
||||
rightTitle: '',
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Get.toNamed(Routers.checkingInSetHolidaysPage, arguments: {
|
||||
"companyId": state.companyId.value
|
||||
Get.toNamed(Routers.checkingInSetHolidaysPage, arguments: <String, String>{
|
||||
'companyId': state.companyId.value
|
||||
});
|
||||
}),
|
||||
SizedBox(
|
||||
@ -117,16 +112,14 @@ class _CheckingInSetPageState extends State<CheckingInSetPage> {
|
||||
visible: state.getKeyInfosData.value.isLockOwner == 1,
|
||||
child: SubmitBtn(
|
||||
btnName:
|
||||
"${TranslationLoader.lanKeys!.delete!.tr} ${TranslationLoader.lanKeys!.company!.tr}",
|
||||
'${TranslationLoader.lanKeys!.delete!.tr} ${TranslationLoader.lanKeys!.company!.tr}',
|
||||
borderRadius: 20.w,
|
||||
fontSize: 32.sp,
|
||||
isDelete: true,
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 20.w),
|
||||
padding: EdgeInsets.only(top: 20.w, bottom: 20.w),
|
||||
onClick: () {
|
||||
ShowTipView().showIosTipWithContentDialog("是否删除?".tr, () {
|
||||
logic.deletCompanyData();
|
||||
});
|
||||
ShowTipView().showIosTipWithContentDialog('是否删除?'.tr, logic.deletCompanyData);
|
||||
// showDeletCompanyAlertDialog(context);
|
||||
}),
|
||||
),
|
||||
@ -140,12 +133,19 @@ class _CheckingInSetPageState extends State<CheckingInSetPage> {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title: "修改公司名字".tr,
|
||||
tipTitle: "",
|
||||
title: '修改公司名字'.tr,
|
||||
tipTitle: '',
|
||||
controller: state.changeNameController,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
LengthLimitingTextInputFormatter(30),
|
||||
],
|
||||
sureClick: () {
|
||||
if(state.changeNameController.text.isEmpty){
|
||||
logic.showToast("请输入公司名字".tr);
|
||||
logic.showToast('请输入公司名字'.tr);
|
||||
return;
|
||||
}
|
||||
if(state.changeNameController.text.length <6){
|
||||
logic.showToast('公司名字长度不能小于 6 '.tr);
|
||||
return;
|
||||
}
|
||||
Get.back();
|
||||
@ -159,7 +159,7 @@ class _CheckingInSetPageState extends State<CheckingInSetPage> {
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getTFWidget() {
|
||||
state.nameController.text = state.companyName.value ?? "";
|
||||
state.nameController.text = state.companyName.value ?? '';
|
||||
return Container(
|
||||
// color: Colors.red,
|
||||
height: 65.h,
|
||||
@ -168,7 +168,7 @@ class _CheckingInSetPageState extends State<CheckingInSetPage> {
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
|
||||
@ -6,28 +6,28 @@ import '../../../lockMian/entity/lockListInfo_entity.dart';
|
||||
import 'checkingInSet_entity.dart';
|
||||
|
||||
class CheckingInSetState{
|
||||
final getKeyInfosData = LockListInfoItemEntity().obs;
|
||||
final companyId = "".obs;
|
||||
CheckingInSetState() {
|
||||
Map map = Get.arguments;
|
||||
getKeyInfosData.value = map['getKeyInfosData'];
|
||||
}
|
||||
final Rx<LockListInfoItemEntity> getKeyInfosData = LockListInfoItemEntity().obs;
|
||||
final RxString companyId = ''.obs;
|
||||
|
||||
var isCustom = false.obs;
|
||||
RxBool isCustom = false.obs;
|
||||
|
||||
var weekDays = <int>[].obs;// 工作天数
|
||||
var weekDaysStr = "".obs;// 拼接显示的字符串天数
|
||||
RxList<int> weekDays = <int>[].obs;// 工作天数
|
||||
RxString weekDaysStr = ''.obs;// 拼接显示的字符串天数
|
||||
|
||||
var beginTime = "".obs;// 开始时间
|
||||
var endTime = "".obs;// 结束时间
|
||||
var beginTimeTimestamp = "".obs;// 开始时间时间戳
|
||||
var endTimeTimestamp = "".obs;// 结束时间时间戳
|
||||
RxString beginTime = ''.obs;// 开始时间
|
||||
RxString endTime = ''.obs;// 结束时间
|
||||
RxString beginTimeTimestamp = ''.obs;// 开始时间时间戳
|
||||
RxString endTimeTimestamp = ''.obs;// 结束时间时间戳
|
||||
|
||||
var staffNumber = "".obs;// 员工数量
|
||||
var companyName = "".obs;// 公司名称
|
||||
RxString staffNumber = ''.obs;// 员工数量
|
||||
RxString companyName = ''.obs;// 公司名称
|
||||
|
||||
final TextEditingController changeNameController = TextEditingController();
|
||||
final TextEditingController nameController = TextEditingController();
|
||||
|
||||
final checkingInSetInfo = CheckingInSetInfo().obs;
|
||||
CheckingInSetState() {
|
||||
Map map = Get.arguments;
|
||||
getKeyInfosData.value = map["getKeyInfosData"];
|
||||
}
|
||||
final Rx<CheckingInSetInfo> checkingInSetInfo = CheckingInSetInfo().obs;
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.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/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../../network/api_repository.dart';
|
||||
import '../../../../../tools/eventBusEventManage.dart';
|
||||
@ -23,30 +23,30 @@ class CheckingInAddStaffLogic extends BaseGetXController {
|
||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||
_getNumberEvent = eventBus
|
||||
.on<ChickInAddStaffCardAndFingerprintBlockNumberEvent>()
|
||||
.listen((event) {
|
||||
.listen((ChickInAddStaffCardAndFingerprintBlockNumberEvent event) {
|
||||
state.attendanceWayNumber.value = event.number;
|
||||
isCanClickAction();
|
||||
});
|
||||
}
|
||||
|
||||
// 添加员工
|
||||
void addStaffLoadData() async {
|
||||
var usernameType = "1";
|
||||
if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) {
|
||||
usernameType = "2";
|
||||
Future<void> addStaffLoadData() async {
|
||||
String usernameType = '1';
|
||||
if (state.appUnHaveAccount.value && state.staffAccount.contains('@')) {
|
||||
usernameType = '2';
|
||||
}
|
||||
|
||||
// 当是app且没有钥匙时,直接把账号赋值给attendanceWayNumber
|
||||
if (state.appUnHaveAccount.value &&
|
||||
state.selectPrintingMethodType.value == "1") {
|
||||
state.selectPrintingMethodType.value == '1') {
|
||||
state.attendanceWayNumber.value = state.staffAccountController.text;
|
||||
}
|
||||
|
||||
var entity = await ApiRepository.to.addStaffData(
|
||||
final LoginEntity entity = await ApiRepository.to.addStaffData(
|
||||
attendanceType: state.selectPrintingMethodType.value,
|
||||
attendanceWay: state.attendanceWayNumber.value,
|
||||
companyId: state.companyId.value,
|
||||
have: state.appUnHaveAccount.value ? "2" : "1",
|
||||
have: state.appUnHaveAccount.value ? '2' : '1',
|
||||
staffName: state.staffNameController.text,
|
||||
countryCode: state.countryCode.value,
|
||||
usernameType: usernameType,
|
||||
@ -54,7 +54,7 @@ class CheckingInAddStaffLogic extends BaseGetXController {
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
eventBus.fire(RefreshCheckInSetDataEvent());
|
||||
eventBus.fire(RefreshCheckInListEvent());
|
||||
Get.back(result: "addScuess");
|
||||
Get.back(result: 'addScuess');
|
||||
} else if (entity.errorCode! == 425) {
|
||||
showToast(entity.errorMsg!);
|
||||
}
|
||||
@ -62,30 +62,35 @@ class CheckingInAddStaffLogic extends BaseGetXController {
|
||||
|
||||
// 考勤设置添加员工-选择钥匙 1为APP,2为密码,3为卡,4为指纹,返回数据中,
|
||||
// attendanceWay分别为用户名、密码、卡号、指纹号
|
||||
void addStaffSelectKey(KeyClickCallback kyClickCallback) async {
|
||||
var entity = await ApiRepository.to.addStaffSelectKeyData(
|
||||
Future<void> addStaffSelectKey(KeyClickCallback kyClickCallback) async {
|
||||
final CheckingInAddStaffSelectKeyEntity entity =
|
||||
await ApiRepository.to.addStaffSelectKeyData(
|
||||
companyId: state.companyId.value,
|
||||
type: state.selectPrintingMethodType.value,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.keyEntity.value = entity.data!;
|
||||
kyClickCallback(state.keyEntity.value);
|
||||
kyClickCallback(state.keyEntity);
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑员工
|
||||
void editStaffLoadData() async {
|
||||
var usernameType = "1";
|
||||
if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) {
|
||||
usernameType = "2";
|
||||
Future<void> editStaffLoadData() async {
|
||||
String usernameType = '1';
|
||||
if (state.appUnHaveAccount.value && state.staffAccount.contains('@')) {
|
||||
usernameType = '2';
|
||||
}
|
||||
// 当是app且没有钥匙时,直接把账号赋值给attendanceWayNumber
|
||||
if (state.appUnHaveAccount.value &&
|
||||
state.selectPrintingMethodType.value == '1') {
|
||||
state.attendanceWayNumber.value = state.staffAccountController.text;
|
||||
}
|
||||
|
||||
|
||||
var entity = await ApiRepository.to.editStaffData(
|
||||
final LoginEntity entity = await ApiRepository.to.editStaffData(
|
||||
attendanceType: state.selectPrintingMethodType.value,
|
||||
attendanceWay: state.attendanceWayNumber.value,
|
||||
staffId: state.staffListItemData.value.staffId.toString(),
|
||||
have: state.appUnHaveAccount.value ? "2" : "1",
|
||||
have: state.appUnHaveAccount.value ? '2' : '1',
|
||||
staffName: state.staffNameController.text,
|
||||
countryCode: state.countryCode.value,
|
||||
usernameType: usernameType,
|
||||
@ -99,13 +104,13 @@ class CheckingInAddStaffLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
//获取密码请求
|
||||
void getKeyboardPwdRequest() async {
|
||||
Future<void> getKeyboardPwdRequest() async {
|
||||
if (state.staffNameController.text.isEmpty) {
|
||||
showToast("请输入姓名");
|
||||
showToast('请输入姓名');
|
||||
return;
|
||||
}
|
||||
var entity = await ApiRepository.to.getPasswordKey(
|
||||
endDate: "0",
|
||||
final PasswordKeyEntity entity = await ApiRepository.to.getPasswordKey(
|
||||
endDate: '0',
|
||||
keyboardPwdName: state.staffNameController.text,
|
||||
keyboardPwdType: 2.toString(),
|
||||
lockId: state.getKeyInfosData.value.lockId.toString(),
|
||||
@ -136,7 +141,7 @@ class CheckingInAddStaffLogic extends BaseGetXController {
|
||||
|
||||
// 是否能点击
|
||||
void isCanClickAction() {
|
||||
if (state.selectPrintingMethodType.value == "1" &&
|
||||
if (state.selectPrintingMethodType.value == '1' &&
|
||||
state.appUnHaveAccount.value) {
|
||||
// 没有账号的时候直接判断姓名和账号是否为空
|
||||
state.isCanClick.value =
|
||||
@ -149,23 +154,15 @@ class CheckingInAddStaffLogic extends BaseGetXController {
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
_initLoadDataAction();
|
||||
|
||||
changeInput(state.staffNameController);
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
|
||||
_getNumberEvent!.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaffSelectKey_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart';
|
||||
import 'package:star_lock/tools/commonDataManage.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
import '../../../../../app_settings/app_colors.dart';
|
||||
@ -20,8 +24,9 @@ class CheckingInAddStaffPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
final logic = Get.put(CheckingInAddStaffLogic());
|
||||
final state = Get.find<CheckingInAddStaffLogic>().state;
|
||||
final CheckingInAddStaffLogic logic = Get.put(CheckingInAddStaffLogic());
|
||||
final CheckingInAddStaffState state =
|
||||
Get.find<CheckingInAddStaffLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -33,15 +38,15 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
// 姓名
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.name!.tr,
|
||||
rightTitle: "",
|
||||
rightTitle: '',
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(
|
||||
"${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.name!.tr}",
|
||||
'${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.name!.tr}',
|
||||
state.staffNameController)),
|
||||
// 选择打卡方式
|
||||
Obx(() => CommonItem(
|
||||
@ -50,35 +55,45 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
var list = ["APP", "密码".tr, "卡".tr, "指纹".tr];
|
||||
if(state.getKeyInfosData.value.lockName!.contains("T9A")){
|
||||
list.add("人脸".tr);
|
||||
final List<String> list = <String>[
|
||||
'APP',
|
||||
'密码'.tr,
|
||||
'卡'.tr,
|
||||
'指纹'.tr
|
||||
];
|
||||
|
||||
// if (state.getKeyInfosData.value.lockName!.contains('T9A')) {
|
||||
if (CommonDataManage().currentKeyInfo.lockFeature?.d3Face ==
|
||||
1) {
|
||||
list.add('人脸'.tr);
|
||||
}
|
||||
_showSelectClockInType(list, list, "1", "选择钥匙".tr);
|
||||
_showSelectClockInType(list, list, list, '1', '选择钥匙'.tr);
|
||||
})),
|
||||
SizedBox(height: 10.h),
|
||||
//员工是否有App、卡、钥匙、指纹必须显示
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: addStaffGetIfHaveKey(),
|
||||
rightTitle: "",
|
||||
rightTitle: '',
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: Row(
|
||||
children: [
|
||||
whetherTheEmployeeHasAKeyWidget("无".tr, state.appUnHaveAccount.value, () {
|
||||
children: <Widget>[
|
||||
whetherTheEmployeeHasAKeyWidget(
|
||||
'无'.tr, state.appUnHaveAccount.value, () {
|
||||
setState(() {
|
||||
state.appUnHaveAccount.value = true;
|
||||
state.attendanceWayNumber.value = "";
|
||||
state.attendanceWayNumber.value = '';
|
||||
logic.isCanClickAction();
|
||||
});
|
||||
}),
|
||||
SizedBox(
|
||||
width: 30.w,
|
||||
),
|
||||
whetherTheEmployeeHasAKeyWidget("有".tr, !state.appUnHaveAccount.value, () {
|
||||
whetherTheEmployeeHasAKeyWidget(
|
||||
'有'.tr, !state.appUnHaveAccount.value, () {
|
||||
setState(() {
|
||||
state.appUnHaveAccount.value = false;
|
||||
state.attendanceWayNumber.value = "";
|
||||
state.attendanceWayNumber.value = '';
|
||||
logic.isCanClickAction();
|
||||
});
|
||||
}),
|
||||
@ -86,12 +101,13 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
))),
|
||||
// 当选择App时且没有钥匙的时候 显示输入账号输入框和选择国家 其他隐藏
|
||||
Obx(() => Visibility(
|
||||
visible: (state.appUnHaveAccount.value && state.selectPrintingMethodType.value == "1") ? true : false,
|
||||
visible: state.appUnHaveAccount.value &&
|
||||
state.selectPrintingMethodType.value == '1',
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.accountNumber!.tr,
|
||||
rightTitle: "",
|
||||
rightTitle: '',
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: getTFWidget(
|
||||
@ -100,7 +116,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
CommonItem(
|
||||
leftTitel:
|
||||
TranslationLoader.lanKeys!.countryAndRegion!.tr,
|
||||
rightTitle: "",
|
||||
rightTitle: '',
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: true,
|
||||
isHaveDirection: true,
|
||||
@ -112,7 +128,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
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<String, dynamic>;
|
||||
@ -127,77 +143,88 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
)),
|
||||
// 当选择密码、卡、指纹时显示
|
||||
Obx(() => Visibility(
|
||||
visible: (state.selectPrintingMethodType.value != "1" && state.appUnHaveAccount.value) ? true : false,
|
||||
visible: state.selectPrintingMethodType.value != '1' &&
|
||||
state.appUnHaveAccount.value,
|
||||
child: CommonItem(
|
||||
leftTitel: addStaffGetKeyType(),
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: Row(
|
||||
children: [
|
||||
Obx(() => Text(state.attendanceWayNumber.value, style: TextStyle(fontSize: 24.sp))),
|
||||
children: <Widget>[
|
||||
Obx(() => Text(state.attendanceWayNumber.value,
|
||||
style: TextStyle(fontSize: 24.sp))),
|
||||
SizedBox(width: 30.w),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
switch (int.parse(state.selectPrintingMethodType.value)) {
|
||||
switch (int.parse(
|
||||
state.selectPrintingMethodType.value)) {
|
||||
case 2:
|
||||
// 获取密码
|
||||
// 获取密码
|
||||
logic.getKeyboardPwdRequest();
|
||||
break;
|
||||
case 3:
|
||||
// 卡
|
||||
// 卡
|
||||
if (state.staffNameController.text.isEmpty) {
|
||||
logic.showToast("请输入姓名".tr);
|
||||
logic.showToast('请输入姓名'.tr);
|
||||
return;
|
||||
}
|
||||
|
||||
var data = await Get.toNamed(
|
||||
final dynamic data = await Get.toNamed(
|
||||
Routers.addCardPage,
|
||||
arguments: {
|
||||
"lockId": state.getKeyInfosData.value.lockId,
|
||||
"fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
"fromTypeTwoStaffName": state.staffNameController.text
|
||||
arguments: <String, Object?>{
|
||||
'lockId':
|
||||
state.getKeyInfosData.value.lockId,
|
||||
'fromType': 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
'fromTypeTwoStaffName':
|
||||
state.staffNameController.text
|
||||
});
|
||||
if (data != null) {
|
||||
|
||||
}
|
||||
if (data != null) {}
|
||||
break;
|
||||
case 4:
|
||||
// 指纹
|
||||
// 指纹
|
||||
if (state.staffNameController.text.isEmpty) {
|
||||
logic.showToast("请输入姓名".tr);
|
||||
logic.showToast('请输入姓名'.tr);
|
||||
return;
|
||||
}
|
||||
|
||||
var data = await Get.toNamed(
|
||||
final data = await Get.toNamed(
|
||||
Routers.addFingerprintTypePage,
|
||||
arguments: {
|
||||
"lockId": state.getKeyInfosData.value.lockId,
|
||||
"fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
"fromTypeTwoStaffName": state.staffNameController.text
|
||||
arguments: <String, Object?>{
|
||||
'lockId':
|
||||
state.getKeyInfosData.value.lockId,
|
||||
'fromType': 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
'fromTypeTwoStaffName':
|
||||
state.staffNameController.text
|
||||
});
|
||||
if (data != null) {
|
||||
|
||||
}
|
||||
if (data != null) {}
|
||||
break;
|
||||
case 5:
|
||||
Get.toNamed(Routers.addFaceTypePage, arguments: {
|
||||
"lockId": state.getKeyInfosData.value.lockId,
|
||||
"fromType": 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
"fromTypeTwoStaffName": state.staffNameController.text
|
||||
});
|
||||
Get.toNamed(Routers.addFaceTypePage,
|
||||
arguments: <String, Object?>{
|
||||
'lockId':
|
||||
state.getKeyInfosData.value.lockId,
|
||||
'fromType': 2, // 1从添加钥匙列表进入 2从考勤添加员工入口进入
|
||||
'fromTypeTwoStaffName':
|
||||
state.staffNameController.text
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height: 40.h,
|
||||
padding: EdgeInsets.only(left: 25.w, right: 25.w, top: 2.h),
|
||||
padding: EdgeInsets.only(
|
||||
left: 25.w,
|
||||
right: 25.w,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.mainColor,
|
||||
borderRadius: BorderRadius.circular(20.h),
|
||||
),
|
||||
child: Text(addStaffSelectKeyType(), textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.white, fontSize: 22.sp)
|
||||
child: Center(
|
||||
child: Text(addStaffSelectKeyType(),
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 22.sp)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -205,25 +232,49 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
)),
|
||||
)),
|
||||
// 当选择钥匙类型为有时 必显示
|
||||
Obx(() => Visibility(
|
||||
visible: !state.appUnHaveAccount.value,
|
||||
child: CommonItem(
|
||||
leftTitel: addStaffGetKeyType(),
|
||||
rightTitle: state.attendanceWayNumber.value,
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
logic.addStaffSelectKey((v) {
|
||||
var showList = [];
|
||||
List numberList = [];
|
||||
for (var element in v) {
|
||||
showList.add("${element.staffName}-${element.attendanceWay}");
|
||||
numberList.add(element.attendanceWay);
|
||||
Obx(() {
|
||||
final bool isPass = state.selectPrintingMethodType.value == '2';
|
||||
String attendanceWayNumber = state.attendanceWayNumber.value;
|
||||
final String attendanceWayName = state.attendanceWayName.value;
|
||||
if (isPass) {
|
||||
attendanceWayNumber = showPass(attendanceWayNumber);
|
||||
}
|
||||
String rightTitle = attendanceWayNumber;
|
||||
if (attendanceWayName.trim() != '') {
|
||||
rightTitle = '$attendanceWayName - ' + rightTitle;
|
||||
}
|
||||
return Visibility(
|
||||
visible: !state.appUnHaveAccount.value,
|
||||
child: CommonItem(
|
||||
leftTitel: addStaffGetKeyType(),
|
||||
rightTitle: rightTitle,
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
logic.addStaffSelectKey(
|
||||
(List<CheckingInAddStaffKeyEntity> v) {
|
||||
final List<String> showList = <String>[];
|
||||
final List<String> nameList = <String>[];
|
||||
final List<String> numberList = <String>[];
|
||||
for (final CheckingInAddStaffKeyEntity element in v) {
|
||||
final bool isPass =
|
||||
state.selectPrintingMethodType.value == '2';
|
||||
String attendanceWay = element.attendanceWay ?? '';
|
||||
if (isPass) {
|
||||
attendanceWay = showPass(attendanceWay);
|
||||
}
|
||||
_showSelectClockInType(showList, numberList, "2", addStaffSelectKeySelectClockInType());
|
||||
});
|
||||
}),
|
||||
)),
|
||||
final String text =
|
||||
'${element.staffName} - $attendanceWay';
|
||||
showList.add(text);
|
||||
numberList.add(element.attendanceWay ?? '');
|
||||
nameList.add(element.staffName ?? '');
|
||||
}
|
||||
_showSelectClockInType(showList, numberList, nameList,
|
||||
'2', addStaffSelectKeySelectClockInType());
|
||||
});
|
||||
}),
|
||||
);
|
||||
}),
|
||||
SizedBox(height: 50.w),
|
||||
Obx(() => SubmitBtn(
|
||||
btnName: TranslationLoader.lanKeys!.sure!.tr,
|
||||
@ -231,25 +282,38 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
margin: EdgeInsets.only(left: 30.w, right: 30.w, top: 30.w),
|
||||
padding: EdgeInsets.only(top: 25.w, bottom: 25.w),
|
||||
isDisabled: state.isCanClick.value,
|
||||
onClick: state.isCanClick.value ? (){
|
||||
if (state.isAdd.value == "2") {
|
||||
logic.editStaffLoadData();
|
||||
} else {
|
||||
logic.addStaffLoadData();
|
||||
}
|
||||
}: null))
|
||||
onClick: state.isCanClick.value
|
||||
? () {
|
||||
if (state.isAdd.value == '2') {
|
||||
logic.editStaffLoadData();
|
||||
} else {
|
||||
logic.addStaffLoadData();
|
||||
}
|
||||
}
|
||||
: null))
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//显示密码
|
||||
String showPass(String text) {
|
||||
final int length = text.length;
|
||||
if (length > 4) {
|
||||
return text.substring(0, length - 4) + '****';
|
||||
} else if (length > 00) {
|
||||
return '****';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
Widget getTFWidget(String tfStr, TextEditingController tf) {
|
||||
return SizedBox(
|
||||
// height: 50.h,
|
||||
width: 300.w,
|
||||
// color: Colors.red,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextField(
|
||||
//输入框一行
|
||||
@ -258,11 +322,12 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
FilteringTextInputFormatter.deny('\n'),
|
||||
// LengthLimitingTextInputFormatter(30),
|
||||
],
|
||||
style: TextStyle(fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, color: AppColors.darkGrayTextColor),
|
||||
controller: tf,
|
||||
autofocus: false,
|
||||
textAlign: TextAlign.end,
|
||||
onChanged: (v) {
|
||||
onChanged: (String v) {
|
||||
logic.changeInput(tf);
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
@ -270,10 +335,18 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
// contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText: tfStr,
|
||||
hintStyle: TextStyle(fontSize: 22.sp),
|
||||
focusedBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
||||
disabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
||||
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
||||
border: const OutlineInputBorder(borderSide: BorderSide(width: 0, color: Colors.transparent)),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
disabledBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
border: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(width: 0, color: Colors.transparent)),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 0),
|
||||
),
|
||||
),
|
||||
@ -284,7 +357,8 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
}
|
||||
|
||||
// type 1 打卡方式 2选择钥匙
|
||||
void _showSelectClockInType(List showList, List numberList, String showBottomSheetToolType, String title) {
|
||||
void _showSelectClockInType(List<String> showList, List<String> numberList,
|
||||
List<String> nameList, String showBottomSheetToolType, String title) {
|
||||
ShowBottomSheetTool().showSingleRowPicker(
|
||||
//上下文
|
||||
context,
|
||||
@ -298,13 +372,15 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
//adapter: PickerAdapter(),
|
||||
data: showList,
|
||||
//选择事件的回调
|
||||
clickCallBack: (int index, var str) {
|
||||
clickCallBack: (int index, Object str) {
|
||||
setState(() {
|
||||
if (showBottomSheetToolType == "1") {
|
||||
if (showBottomSheetToolType == '1') {
|
||||
state.selectPrintingMethodType.value = (index + 1).toString();
|
||||
state.selectPrintingMethodStr.value = str.toString();
|
||||
state.attendanceWayNumber.value = "";
|
||||
state.attendanceWayName.value = '';
|
||||
state.attendanceWayNumber.value = '';
|
||||
} else {
|
||||
state.attendanceWayName.value = nameList[index].toString();
|
||||
state.attendanceWayNumber.value = numberList[index].toString();
|
||||
}
|
||||
logic.isCanClickAction();
|
||||
@ -312,16 +388,17 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
});
|
||||
}
|
||||
|
||||
Widget whetherTheEmployeeHasAKeyWidget(String title, bool appUnHaveAccount, Function() action) {
|
||||
Widget whetherTheEmployeeHasAKeyWidget(
|
||||
String title, bool appUnHaveAccount, Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
// width: 80.w,
|
||||
height: 65.w,
|
||||
padding: EdgeInsets.only(left:10.w, right: 10.w),
|
||||
padding: EdgeInsets.only(left: 10.w, right: 10.w),
|
||||
// color: Colors.red,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
appUnHaveAccount
|
||||
? 'images/icon_round_select.png'
|
||||
@ -345,7 +422,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
}
|
||||
|
||||
String addStaffGetIfHaveKey() {
|
||||
String title = "";
|
||||
String title = '';
|
||||
switch (int.parse(state.selectPrintingMethodType.value)) {
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.whetherTheEmployeeHasAKey!.tr;
|
||||
@ -360,14 +437,14 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
title = TranslationLoader.lanKeys!.whetherTheEmployeeHasFingerprint!.tr;
|
||||
break;
|
||||
case 4:
|
||||
title = "员工是否有人脸".tr;
|
||||
title = '员工是否有人脸'.tr;
|
||||
break;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
String addStaffGetKeyType() {
|
||||
String title = "";
|
||||
String title = '';
|
||||
switch (int.parse(state.selectPrintingMethodType.value)) {
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.accountNumber!.tr;
|
||||
@ -389,7 +466,7 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
}
|
||||
|
||||
String addStaffSelectKeyType() {
|
||||
String title = "";
|
||||
String title = '';
|
||||
switch (int.parse(state.selectPrintingMethodType.value)) {
|
||||
case 1:
|
||||
title = TranslationLoader.lanKeys!.getKey!.tr;
|
||||
@ -404,32 +481,31 @@ class _CheckingInAddStaffPageState extends State<CheckingInAddStaffPage> {
|
||||
title = TranslationLoader.lanKeys!.getFingerprint!.tr;
|
||||
break;
|
||||
case 5:
|
||||
title = "获取人脸".tr;
|
||||
title = '获取人脸'.tr;
|
||||
break;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
String addStaffSelectKeySelectClockInType() {
|
||||
String title = "";
|
||||
String title = '';
|
||||
switch (int.parse(state.selectPrintingMethodType.value)) {
|
||||
case 1:
|
||||
title = "选择钥匙".tr;
|
||||
title = '选择钥匙'.tr;
|
||||
break;
|
||||
case 2:
|
||||
title = "选择密码".tr;
|
||||
title = '选择密码'.tr;
|
||||
break;
|
||||
case 3:
|
||||
title = "选择卡".tr;
|
||||
title = '选择卡'.tr;
|
||||
break;
|
||||
case 4:
|
||||
title = "选择指纹".tr;
|
||||
title = '选择指纹'.tr;
|
||||
break;
|
||||
case 5:
|
||||
title = "选择人脸".tr;
|
||||
title = '选择人脸'.tr;
|
||||
break;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,59 +6,34 @@ import '../checkingInSetStaffList/checkingInStaffList_entity.dart';
|
||||
import 'checkingInAddStaffSelectKey_entity.dart';
|
||||
|
||||
class CheckingInAddStaffState {
|
||||
final getKeyInfosData = LockListInfoItemEntity().obs;
|
||||
final companyId = "".obs;
|
||||
final staffListItemData = CheckingInAddStaffListItemEntity().obs;
|
||||
|
||||
final TextEditingController staffNameController = TextEditingController();
|
||||
final TextEditingController staffAccountController = TextEditingController();
|
||||
|
||||
final selectPrintingMethodType = "1".obs; // 选择打卡类型 1APP 2密码 3卡 4指纹 5人脸
|
||||
final selectPrintingMethodStr = "APP".obs; // 选择打卡类型字符串
|
||||
|
||||
final countryName = "中国".tr.obs;
|
||||
final countryCode = "86".obs;
|
||||
|
||||
final appUnHaveAccount = true.obs; // 默认没有账号
|
||||
final keyEntity = <CheckingInAddStaffKeyEntity>[].obs; // 选择钥匙数据
|
||||
|
||||
final isAdd = "1".obs; // 1添加 2编辑
|
||||
final attendanceWayNumber = "".obs;
|
||||
final isCanClick = false.obs;
|
||||
var staffName = ''.obs;
|
||||
var staffAccount = ''.obs;
|
||||
|
||||
bool get staffNameIsNotEmpty => staffName.value.isNotEmpty;
|
||||
|
||||
bool get staffAccountIsNotEmpty => staffAccount.value.isNotEmpty;
|
||||
|
||||
bool get attendanceWayNumberIsNotEmpty =>
|
||||
attendanceWayNumber.value.isNotEmpty;
|
||||
|
||||
CheckingInAddStaffState() {
|
||||
Map map = Get.arguments;
|
||||
getKeyInfosData.value = map["getKeyInfosData"];
|
||||
companyId.value = map["companyId"];
|
||||
final Map<dynamic, dynamic> map = Get.arguments;
|
||||
getKeyInfosData.value = map['getKeyInfosData'];
|
||||
companyId.value = map['companyId'];
|
||||
|
||||
isAdd.value = map["isAdd"];
|
||||
if (isAdd.value == "2") {
|
||||
staffListItemData.value = map["staffListItem"];
|
||||
isAdd.value = map['isAdd'];
|
||||
if (isAdd.value == '2') {
|
||||
staffListItemData.value = map['staffListItem'];
|
||||
staffNameController.text = staffListItemData.value.staffName!;
|
||||
|
||||
selectPrintingMethodType.value =
|
||||
staffListItemData.value.attendanceType.toString();
|
||||
switch (staffListItemData.value.attendanceType) {
|
||||
case 1:
|
||||
selectPrintingMethodStr.value = "APP";
|
||||
selectPrintingMethodStr.value = 'APP';
|
||||
break;
|
||||
case 2:
|
||||
selectPrintingMethodStr.value = "密码".tr;
|
||||
selectPrintingMethodStr.value = '密码'.tr;
|
||||
break;
|
||||
case 3:
|
||||
selectPrintingMethodStr.value = "卡".tr;
|
||||
selectPrintingMethodStr.value = '卡'.tr;
|
||||
break;
|
||||
case 4:
|
||||
selectPrintingMethodStr.value = "指纹".tr;
|
||||
selectPrintingMethodStr.value = '指纹'.tr;
|
||||
break;
|
||||
case 5:
|
||||
selectPrintingMethodStr.value = '人脸'.tr;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -70,4 +45,37 @@ class CheckingInAddStaffState {
|
||||
}
|
||||
}
|
||||
}
|
||||
final Rx<LockListInfoItemEntity> getKeyInfosData =
|
||||
LockListInfoItemEntity().obs;
|
||||
final RxString companyId = ''.obs;
|
||||
final Rx<CheckingInAddStaffListItemEntity> staffListItemData =
|
||||
CheckingInAddStaffListItemEntity().obs;
|
||||
|
||||
final TextEditingController staffNameController = TextEditingController();
|
||||
final TextEditingController staffAccountController = TextEditingController();
|
||||
|
||||
final RxString selectPrintingMethodType =
|
||||
'1'.obs; // 选择打卡类型 1APP 2密码 3卡 4指纹 5人脸
|
||||
final RxString selectPrintingMethodStr = 'APP'.obs; // 选择打卡类型字符串
|
||||
|
||||
final RxString countryName = '中国'.tr.obs;
|
||||
final RxString countryCode = '86'.obs;
|
||||
|
||||
final RxBool appUnHaveAccount = true.obs; // 默认没有账号
|
||||
final RxList<CheckingInAddStaffKeyEntity> keyEntity =
|
||||
<CheckingInAddStaffKeyEntity>[].obs; // 选择钥匙数据
|
||||
|
||||
final RxString isAdd = '1'.obs; // 1添加 2编辑
|
||||
final RxString attendanceWayName = ''.obs;
|
||||
final RxString attendanceWayNumber = ''.obs;
|
||||
final RxBool isCanClick = false.obs;
|
||||
RxString staffName = ''.obs;
|
||||
RxString staffAccount = ''.obs;
|
||||
|
||||
bool get staffNameIsNotEmpty => staffName.value.isNotEmpty;
|
||||
|
||||
bool get staffAccountIsNotEmpty => staffAccount.value.isNotEmpty;
|
||||
|
||||
bool get attendanceWayNumberIsNotEmpty =>
|
||||
attendanceWayNumber.value.isNotEmpty;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_state.dart';
|
||||
import 'package:star_lock/tools/showTipView.dart';
|
||||
|
||||
import '../../../../../appRouters.dart';
|
||||
@ -23,8 +24,10 @@ class CheckingInStaffListPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
|
||||
final logic = Get.put(CheckingInStaffManageLogic());
|
||||
final state = Get.find<CheckingInStaffManageLogic>().state;
|
||||
final CheckingInStaffManageLogic logic =
|
||||
Get.put(CheckingInStaffManageLogic());
|
||||
final CheckingInStaffManageState state =
|
||||
Get.find<CheckingInStaffManageLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -34,15 +37,17 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
|
||||
barTitle: TranslationLoader.lanKeys!.staff!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
actionsList: <Widget>[
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
var data = await Get.toNamed(Routers.checkingInAddStaffPage, arguments: {
|
||||
"getKeyInfosData": state.getKeyInfosData.value,
|
||||
"companyId": state.companyId.value,
|
||||
"isAdd": "1",
|
||||
});
|
||||
if(data != null) {
|
||||
final dynamic data = await Get.toNamed(
|
||||
Routers.checkingInAddStaffPage,
|
||||
arguments: <String, Object>{
|
||||
'getKeyInfosData': state.getKeyInfosData.value,
|
||||
'companyId': state.companyId.value,
|
||||
'isAdd': '1',
|
||||
});
|
||||
if (data != null) {
|
||||
logic.getStaffList();
|
||||
}
|
||||
},
|
||||
@ -58,65 +63,76 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
|
||||
),
|
||||
body: Container(
|
||||
color: Colors.white,
|
||||
child: Obx(() => state.staffListData.value.isNotEmpty ?
|
||||
SlidableAutoCloseBehavior(
|
||||
child: ListView.separated(
|
||||
itemCount: state.staffListData.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
CheckingInAddStaffListItemEntity staffListItem = state.staffListData[index];
|
||||
return Slidable(
|
||||
key:ValueKey(staffListItem.staffId),
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context){
|
||||
// 1APP 2密码 3卡 4指纹 5人脸
|
||||
if(staffListItem.attendanceType == 1){
|
||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog('同时删除员工钥匙'.tr, (isAllData) {
|
||||
logic.deletStaff(staffListItem.staffId!, (isAllData ? 1 : 0));
|
||||
});
|
||||
}else{
|
||||
ShowTipView().showIosTipWithContentDialog("确定要删除员工吗?".tr, () {
|
||||
logic.deletStaff(staffListItem.staffId!, 0);
|
||||
});
|
||||
// showIosTipViewDialog(staffListItem.staffId!, context);
|
||||
}
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
label: '删除'.tr,
|
||||
padding: EdgeInsets.only(left: 5.w, right: 5.w),
|
||||
),
|
||||
],
|
||||
child: Obx(() => state.staffListData.isNotEmpty
|
||||
? SlidableAutoCloseBehavior(
|
||||
child: ListView.separated(
|
||||
itemCount: state.staffListData.length,
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final CheckingInAddStaffListItemEntity staffListItem =
|
||||
state.staffListData[index];
|
||||
return Slidable(
|
||||
key: ValueKey<int?>(staffListItem.staffId),
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: <Widget>[
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context) {
|
||||
// 1APP 2密码 3卡 4指纹 5人脸
|
||||
if (staffListItem.attendanceType == 1) {
|
||||
ShowTipView()
|
||||
.showDeleteAdministratorIsHaveAllDataDialog(
|
||||
'同时删除员工钥匙'.tr, (bool isAllData) {
|
||||
logic.deletStaff(staffListItem.staffId!,
|
||||
(isAllData ? 1 : 0));
|
||||
});
|
||||
} else {
|
||||
ShowTipView().showIosTipWithContentDialog(
|
||||
'确定要删除员工吗?'.tr, () {
|
||||
logic.deletStaff(staffListItem.staffId!, 0);
|
||||
});
|
||||
// showIosTipViewDialog(staffListItem.staffId!, context);
|
||||
}
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
foregroundColor: Colors.white,
|
||||
label: '删除'.tr,
|
||||
padding: EdgeInsets.only(left: 5.w, right: 5.w),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: _checkingInStaffManageItem(staffListItem, () {
|
||||
Get.toNamed(Routers.checkingInStaffDetailPage,
|
||||
arguments: <String, Object>{
|
||||
'staffListItem': staffListItem,
|
||||
'getKeyInfosData': state.getKeyInfosData.value,
|
||||
'companyId': state.companyId.value,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
// return _checkingInStaffManageItem(staffListItem, () {
|
||||
// Get.toNamed(Routers.checkingInStaffDetailPage, arguments: {
|
||||
// "staffListItem": staffListItem,
|
||||
// "getKeyInfosData": state.getKeyInfosData.value,
|
||||
// "companyId": state.companyId.value,
|
||||
// });
|
||||
// });
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
height: 1.h,
|
||||
indent: 20.w,
|
||||
color: AppColors.greyLineColor);
|
||||
},
|
||||
),
|
||||
child: _checkingInStaffManageItem(staffListItem, () {
|
||||
Get.toNamed(Routers.checkingInStaffDetailPage, arguments: {
|
||||
"staffListItem": staffListItem,
|
||||
"getKeyInfosData": state.getKeyInfosData.value,
|
||||
"companyId": state.companyId.value,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
// return _checkingInStaffManageItem(staffListItem, () {
|
||||
// Get.toNamed(Routers.checkingInStaffDetailPage, arguments: {
|
||||
// "staffListItem": staffListItem,
|
||||
// "getKeyInfosData": state.getKeyInfosData.value,
|
||||
// "companyId": state.companyId.value,
|
||||
// });
|
||||
// });
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return Divider(height: 1.h, indent: 20.w, color: AppColors.greyLineColor);
|
||||
},
|
||||
),
|
||||
) : NoData()),
|
||||
)
|
||||
: NoData()),
|
||||
));
|
||||
}
|
||||
|
||||
Widget _checkingInStaffManageItem(CheckingInAddStaffListItemEntity staffListItem, Function() action) {
|
||||
Widget _checkingInStaffManageItem(
|
||||
CheckingInAddStaffListItemEntity staffListItem, Function() action) {
|
||||
return GestureDetector(
|
||||
onTap: action,
|
||||
child: Container(
|
||||
@ -125,35 +141,53 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
|
||||
color: Colors.white,
|
||||
margin: EdgeInsets.only(right: 10.w, top: 10.h, bottom: 10.h),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 20.w,),
|
||||
// CustomNetworkImage(url: staffListItem.headurl!, width: 40.w , height: 40.w),
|
||||
Image.asset(getTypeIcon(staffListItem.attendanceType!), width: 60.w, height: 60.w),
|
||||
SizedBox(width: 20.w,),
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 20.w,
|
||||
),
|
||||
if (staffListItem.headurl == null || staffListItem.headurl == '')
|
||||
Image.asset(
|
||||
getTypeIcon(staffListItem.attendanceType!),
|
||||
width: 60.w,
|
||||
height: 60.w,
|
||||
)
|
||||
else
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(100.w),
|
||||
child: Image.network(
|
||||
staffListItem.headurl!,
|
||||
width: 60.w,
|
||||
height: 60.w,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 20.w,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 1.sw - 20.w - 60.w - 20.w - 30.w,
|
||||
child: Text(staffListItem.staffName!,
|
||||
// maxLines: 1,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 24.sp)
|
||||
)
|
||||
),
|
||||
style: TextStyle(fontSize: 24.sp))),
|
||||
Visibility(
|
||||
visible: staffListItem.cardStatus == 1 ? true : false,
|
||||
child: SizedBox(height: 5.h,)
|
||||
),
|
||||
visible: staffListItem.cardStatus == 1,
|
||||
child: SizedBox(
|
||||
height: 5.h,
|
||||
)),
|
||||
Visibility(
|
||||
visible: staffListItem.cardStatus == 1 ? true : false,
|
||||
visible: staffListItem.cardStatus == 1,
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(right: 5.w, left: 5.w),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5.w),
|
||||
color: AppColors.openPassageModeColor,
|
||||
),
|
||||
child: Text("打卡方式无效".tr, style: TextStyle(fontSize: 18.sp, color: AppColors.appBarIconColor)),
|
||||
child: Text('打卡方式无效'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp, color: AppColors.appBarIconColor)),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -169,19 +203,19 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
|
||||
String title = 'images/controls_user.png';
|
||||
switch (type) {
|
||||
case 1:
|
||||
// 蓝牙开锁
|
||||
// 蓝牙开锁
|
||||
title = 'images/controls_user.png';
|
||||
break;
|
||||
case 2:
|
||||
// 密码开锁
|
||||
// 密码开锁
|
||||
title = 'images/icon_password.png';
|
||||
break;
|
||||
case 3:
|
||||
// ic卡
|
||||
// ic卡
|
||||
title = 'images/icon_card.png';
|
||||
break;
|
||||
case 4:
|
||||
// 指纹开锁
|
||||
// 指纹开锁
|
||||
title = 'images/icon_fingerprint.png';
|
||||
break;
|
||||
default:
|
||||
@ -190,23 +224,22 @@ class _CheckingInStaffListPageState extends State<CheckingInStaffListPage> {
|
||||
return title;
|
||||
}
|
||||
|
||||
// void showIosTipViewDialog(int staffId, BuildContext context) {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return ShowIosTipView(
|
||||
// title: "提示",
|
||||
// tipTitle: "确定要删除员工吗?",
|
||||
// sureClick: () async {
|
||||
// Get.back();
|
||||
// logic.deletStaff(staffId, 0);
|
||||
// },
|
||||
// cancelClick: () {
|
||||
// Get.back();
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
// void showIosTipViewDialog(int staffId, BuildContext context) {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return ShowIosTipView(
|
||||
// title: "提示",
|
||||
// tipTitle: "确定要删除员工吗?",
|
||||
// sureClick: () async {
|
||||
// Get.back();
|
||||
// logic.deletStaff(staffId, 0);
|
||||
// },
|
||||
// cancelClick: () {
|
||||
// Get.back();
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ class DoorLockLogLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionStateState) async {
|
||||
if (connectionStateState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
|
||||
@ -25,17 +25,17 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
//修改钥匙名称请求
|
||||
Future<void> modifyKeyNameRequest() async {
|
||||
if (state.changeNameController.text.isEmpty) {
|
||||
showToast("请输入钥匙名称".tr);
|
||||
showToast('请输入钥匙名称'.tr);
|
||||
return;
|
||||
}
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.modifyKeyNameForAdmin(state.itemData.value.keyId.toString(),
|
||||
state.changeNameController.text, '');
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.itemData.value.keyName = state.changeNameController.text;
|
||||
state.keyName.value = state.itemData.value.keyName!;
|
||||
Get.back();
|
||||
showToast("修改成功".tr, something: () {
|
||||
showToast('修改成功'.tr, something: () {
|
||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
});
|
||||
@ -44,19 +44,21 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
|
||||
//编辑电子钥匙有效期请求 updateType 1:仅管理自己创建的用户 2:远程开锁
|
||||
Future<void> updateKeyDateRequest(int updateType) async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to.updateKeyDate(
|
||||
keyId: state.itemData.value.keyId.toString(),
|
||||
lockId: state.itemData.value.lockId.toString(),
|
||||
endDate: state.endDate.value.toString(),
|
||||
startDate: state.starDate.value.toString(),
|
||||
weekDays: state.itemData.value.weekDays!,
|
||||
keyType: state.itemData.value.keyType!,
|
||||
startTime: int.parse(state.starTime.value),
|
||||
endTime: int.parse(state.endTime.value),
|
||||
isOnlyManageSelf: state.onlyManageYouCreatesUser.value == true ? 1 : 0,
|
||||
remoteEnable: state.isRemoteUnlock.value == true ? 1 : 2);
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.updateKeyDate(
|
||||
keyId: state.itemData.value.keyId.toString(),
|
||||
lockId: state.itemData.value.lockId.toString(),
|
||||
endDate: state.endDate.value.toString(),
|
||||
startDate: state.starDate.value.toString(),
|
||||
weekDays: state.itemData.value.weekDays!,
|
||||
keyType: state.itemData.value.keyType!,
|
||||
startTime: int.parse(state.starTime.value),
|
||||
endTime: int.parse(state.endTime.value),
|
||||
isOnlyManageSelf:
|
||||
state.onlyManageYouCreatesUser.value == true ? 1 : 0,
|
||||
remoteEnable: state.isRemoteUnlock.value == true ? 1 : 2);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("修改成功".tr, something: () {
|
||||
showToast('修改成功'.tr, something: () {
|
||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
});
|
||||
@ -65,11 +67,12 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
|
||||
//删除电子钥匙名称请求
|
||||
Future<void> deleteKeyRequest(int includeUnderlings) async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to.deleteElectronicKey(
|
||||
keyId: state.itemData.value.keyId.toString(),
|
||||
includeUnderlings: includeUnderlings);
|
||||
final ElectronicKeyListEntity entity = await ApiRepository.to
|
||||
.deleteElectronicKey(
|
||||
keyId: state.itemData.value.keyId.toString(),
|
||||
includeUnderlings: includeUnderlings);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("删除成功".tr, something: () {
|
||||
showToast('删除成功'.tr, something: () {
|
||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
Get.back();
|
||||
@ -79,11 +82,12 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
|
||||
//设置授权管理员
|
||||
Future<void> setAdministrator() async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to.setAdministrator(
|
||||
final ElectronicKeyListEntity entity =
|
||||
await ApiRepository.to.setAdministrator(
|
||||
keyId: state.itemData.value.keyId.toString(),
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("设置成功".tr, something: () {
|
||||
showToast('设置成功'.tr, something: () {
|
||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
Get.back();
|
||||
@ -93,11 +97,12 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
|
||||
//取消授权管理员
|
||||
Future<void> cancelAdministrator() async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to.cancelAdministrator(
|
||||
final ElectronicKeyListEntity entity =
|
||||
await ApiRepository.to.cancelAdministrator(
|
||||
keyId: state.itemData.value.keyId.toString(),
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("设置成功".tr, something: () {
|
||||
showToast('设置成功'.tr, something: () {
|
||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
Get.back();
|
||||
@ -107,11 +112,11 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
|
||||
//冻结
|
||||
Future<void> freezeKey(int includeUnderlings) async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to.freezeKey(
|
||||
final ElectronicKeyListEntity entity = await ApiRepository.to.freezeKey(
|
||||
keyId: state.itemData.value.keyId.toString(),
|
||||
includeUnderlings: includeUnderlings);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("设置成功".tr, something: () {
|
||||
showToast('设置成功'.tr, something: () {
|
||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
Get.back();
|
||||
@ -121,11 +126,11 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
|
||||
//取消冻结
|
||||
Future<void> cancelFreeze(int includeUnderlings) async {
|
||||
ElectronicKeyListEntity entity = await ApiRepository.to.cancelFreeze(
|
||||
final ElectronicKeyListEntity entity = await ApiRepository.to.cancelFreeze(
|
||||
keyId: state.itemData.value.keyId.toString(),
|
||||
includeUnderlings: includeUnderlings);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("设置成功".tr, something: () {
|
||||
showToast('设置成功'.tr, something: () {
|
||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
Get.back();
|
||||
@ -137,14 +142,15 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
Future<void> checkRealNameStatus(int realNameAuthStatus) async {
|
||||
//打开实名认证 必须输入身份证号和真实姓名
|
||||
if (realNameAuthStatus == 1) {
|
||||
AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace(
|
||||
final AdvancedFunctionRecordEntity entity =
|
||||
await ApiRepository.to.keyCheckFace(
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId ?? 0,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if (state.getRealName.value.isEmpty ||
|
||||
state.getIDCardNumber.value.isEmpty) {
|
||||
ShowCupertinoAlertView()
|
||||
.showOpenAuthWithIDCardInfoAlert((idCard, realName) {
|
||||
ShowCupertinoAlertView().showOpenAuthWithIDCardInfoAlert(
|
||||
(String? idCard, String? realName) {
|
||||
state.getIDCardNumber.value = idCard ?? '';
|
||||
state.getRealName.value = realName ?? '';
|
||||
updateRealNameInfoWithAuthStatus(realNameAuthStatus);
|
||||
@ -158,7 +164,7 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
titleStr: '实名认证为付费功能,请购买后再使用'.tr,
|
||||
sureClick: () {
|
||||
Get.toNamed(Routers.advancedFeaturesWebPage,
|
||||
arguments: {'isShop': false});
|
||||
arguments: <String, bool>{'isShop': false});
|
||||
});
|
||||
} else if (entity.errorCode == 433) {
|
||||
//需联系管理员购买
|
||||
@ -171,16 +177,17 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
|
||||
//更新钥匙实名认证信息--实名认证状态
|
||||
Future<void> updateRealNameInfoWithAuthStatus(int realNameAuthStatus) async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to.updateRealNameInfo(
|
||||
lockId: state.itemData.value.lockId ?? 0,
|
||||
keyId: state.itemData.value.keyId ?? 0,
|
||||
uid: state.itemData.value.uid ?? 0,
|
||||
faceAuthentication: realNameAuthStatus,
|
||||
realName: state.getRealName.value,
|
||||
idCardNumber: state.getIDCardNumber.value);
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.updateRealNameInfo(
|
||||
lockId: state.itemData.value.lockId ?? 0,
|
||||
keyId: state.itemData.value.keyId ?? 0,
|
||||
uid: state.itemData.value.uid ?? 0,
|
||||
faceAuthentication: realNameAuthStatus,
|
||||
realName: state.getRealName.value,
|
||||
idCardNumber: state.getIDCardNumber.value);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.isRealNameAuth.value = !state.isRealNameAuth.value;
|
||||
showToast("修改成功".tr, something: () {
|
||||
showToast('修改成功'.tr, something: () {
|
||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
});
|
||||
@ -192,25 +199,26 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
switch (alertEnum) {
|
||||
case ShowAlertEnum.realName:
|
||||
if (state.changeRealNameController.text.isEmpty) {
|
||||
showToast("请输入真实姓名".tr);
|
||||
showToast('请输入真实姓名'.tr);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case ShowAlertEnum.idCardNumber:
|
||||
if (state.changeIDCardController.text.isEmpty) {
|
||||
showToast("请输入身份证号".tr);
|
||||
showToast('请输入身份证号'.tr);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to.updateRealNameInfo(
|
||||
lockId: state.itemData.value.lockId ?? 0,
|
||||
keyId: state.itemData.value.keyId ?? 0,
|
||||
uid: state.itemData.value.uid ?? 0,
|
||||
faceAuthentication: state.isRealNameAuth.value ? 1 : 2,
|
||||
realName: state.changeRealNameController.text,
|
||||
idCardNumber: state.changeIDCardController.text);
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.updateRealNameInfo(
|
||||
lockId: state.itemData.value.lockId ?? 0,
|
||||
keyId: state.itemData.value.keyId ?? 0,
|
||||
uid: state.itemData.value.uid ?? 0,
|
||||
faceAuthentication: state.isRealNameAuth.value ? 1 : 2,
|
||||
realName: state.changeRealNameController.text,
|
||||
idCardNumber: state.changeIDCardController.text);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if (alertEnum == ShowAlertEnum.realName) {
|
||||
state.itemData.value.userIdCard!.realName =
|
||||
@ -222,7 +230,7 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
state.getIDCardNumber.value =
|
||||
state.itemData.value.userIdCard!.idCardNumber!;
|
||||
}
|
||||
showToast("修改成功".tr, something: () {
|
||||
showToast('修改成功'.tr, something: () {
|
||||
eventBus.fire(ElectronicKeyListRefreshUI());
|
||||
eventBus.fire(AuthorizedAdminPageRefreshUI());
|
||||
});
|
||||
@ -232,44 +240,56 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
String getKeyTypeShowDateTime() {
|
||||
String useDateStr = '';
|
||||
if (state.keyType.value == 1) {
|
||||
useDateStr = "永久".tr;
|
||||
useDateStr = '永久'.tr;
|
||||
} else if (state.keyType.value == 2) {
|
||||
useDateStr =
|
||||
"${DateTool().dateToYMDHNString(state.starDate.value)}\n${DateTool().dateToYMDHNString(state.endDate.value)}";
|
||||
'${DateTool().dateToYMDHNString(state.starDate.value)}\n${DateTool().dateToYMDHNString(state.endDate.value)}';
|
||||
} else if (state.keyType.value == 3) {
|
||||
useDateStr = "单次".tr;
|
||||
useDateStr = '单次'.tr;
|
||||
} else if (state.keyType.value == 4) {
|
||||
useDateStr =
|
||||
"${DateTool().dateToYMDString(state.starDate.value)}\n${DateTool().dateToYMDString(state.endDate.value)}";
|
||||
'${DateTool().dateToYMDString(state.starDate.value)}\n${DateTool().dateToYMDString(state.endDate.value)}';
|
||||
}
|
||||
return useDateStr;
|
||||
}
|
||||
|
||||
Future openModalBottomSheet(BuildContext context) async {
|
||||
var textList = <String>[];
|
||||
if (state.itemData.value.keyRight == 1) {
|
||||
Future<void> openModalBottomSheet(BuildContext context) async {
|
||||
List<String> textList = <String>[];
|
||||
final bool isAdminKey = state.itemData.value.keyRight == 1;
|
||||
final bool isLockOwner = CommonDataManage().currentKeyInfo.isLockOwner == 1;
|
||||
if (isAdminKey) {
|
||||
// 授权管理员
|
||||
textList = [
|
||||
state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen ? '取消冻结'.tr : "冻结".tr,
|
||||
"取消授权".tr
|
||||
textList = <String>[
|
||||
if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen)
|
||||
'取消冻结'.tr
|
||||
else
|
||||
'冻结'.tr,
|
||||
if (isLockOwner) '取消授权'.tr
|
||||
];
|
||||
} else if (CommonDataManage().currentKeyInfo.isLockOwner == 1) {
|
||||
} else if (isLockOwner) {
|
||||
// 锁拥有者
|
||||
if (state.keyType.value == 1 || state.keyType.value == 2) {
|
||||
textList = [
|
||||
state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen ? '取消冻结'.tr : "冻结".tr,
|
||||
state.itemData.value.keyRight == 1 ? '取消授权'.tr : '授权'.tr
|
||||
textList = <String>[
|
||||
if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen)
|
||||
'取消冻结'.tr
|
||||
else
|
||||
'冻结'.tr,
|
||||
if (state.itemData.value.keyRight == 1) '取消授权'.tr else '授权'.tr
|
||||
];
|
||||
} else if (state.keyType.value == 4) {
|
||||
textList = [
|
||||
state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen
|
||||
? '取消冻结'.tr
|
||||
: "冻结".tr
|
||||
textList = <String>[
|
||||
if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen)
|
||||
'取消冻结'.tr
|
||||
else
|
||||
'冻结'.tr
|
||||
];
|
||||
}
|
||||
}else{
|
||||
textList = [
|
||||
state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen ? '取消冻结'.tr : "冻结".tr,
|
||||
} else {
|
||||
textList = <String>[
|
||||
if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen)
|
||||
'取消冻结'.tr
|
||||
else
|
||||
'冻结'.tr,
|
||||
];
|
||||
}
|
||||
showModalBottomSheet(
|
||||
@ -280,20 +300,21 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
return AlertBottomWidget(
|
||||
topTitle: '',
|
||||
items: textList,
|
||||
chooseCallback: (value) {
|
||||
int index = value;
|
||||
chooseCallback: (int value) {
|
||||
final int index = value;
|
||||
if (index == 0) {
|
||||
if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen) {
|
||||
if (state.itemData.value.keyStatus ==
|
||||
XSConstantMacro.keyStatusFrozen) {
|
||||
// 取消冻结
|
||||
if (state.itemData.value.keyRight == 1) {
|
||||
// 管理员
|
||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog(
|
||||
'同时解冻其发送的钥匙'.tr, (isAllData) {
|
||||
'同时解冻其发送的钥匙'.tr, (bool isAllData) {
|
||||
cancelFreeze(isAllData ? 1 : 0);
|
||||
});
|
||||
} else {
|
||||
ShowTipView()
|
||||
.showIosTipWithContentDialog("取消冻结会在用户APP连网后生效".tr, () {
|
||||
.showIosTipWithContentDialog('取消冻结会在用户APP连网后生效'.tr, () {
|
||||
cancelFreeze(0);
|
||||
});
|
||||
}
|
||||
@ -301,12 +322,12 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
if (state.itemData.value.keyRight == 1) {
|
||||
// 管理员
|
||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog(
|
||||
'同时冻结其发送的钥匙'.tr, (isAllData) {
|
||||
'同时冻结其发送的钥匙'.tr, (bool isAllData) {
|
||||
freezeKey(isAllData ? 1 : 0);
|
||||
});
|
||||
} else {
|
||||
ShowTipView()
|
||||
.showIosTipWithContentDialog("冻结会在用户APP连网后生效".tr, () {
|
||||
.showIosTipWithContentDialog('冻结会在用户APP连网后生效'.tr, () {
|
||||
freezeKey(0);
|
||||
});
|
||||
}
|
||||
@ -315,15 +336,11 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
// 取消/授权管理员
|
||||
if (state.itemData.value.keyRight == 1) {
|
||||
// 管理员
|
||||
ShowTipView()
|
||||
.showIosTipWithContentDialog("取消授权会在用户APP连网后生效".tr, () {
|
||||
cancelAdministrator();
|
||||
});
|
||||
ShowTipView().showIosTipWithContentDialog(
|
||||
'取消授权会在用户APP连网后生效'.tr, cancelAdministrator);
|
||||
} else {
|
||||
ShowTipView().showIosTipWithContentDialog(
|
||||
"授权用户拥有管理员的大部分权限,比如发送钥匙、发送密码".tr, () {
|
||||
setAdministrator();
|
||||
});
|
||||
'授权用户拥有管理员的大部分权限,比如发送钥匙、发送密码'.tr, setAdministrator);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -331,16 +348,16 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
});
|
||||
}
|
||||
|
||||
deletKeyLogic() {
|
||||
void deletKeyLogic() {
|
||||
if (state.itemData.value.keyRight == 1) {
|
||||
// 授权管理员
|
||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog(
|
||||
'同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (isAllData) {
|
||||
'同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool isAllData) {
|
||||
deleteKeyRequest(isAllData ? 1 : 0);
|
||||
});
|
||||
} else {
|
||||
// 普通用户
|
||||
ShowTipView().showIosTipWithContentDialog("删除钥匙会在用户APP连网后生效".tr, () {
|
||||
ShowTipView().showIosTipWithContentDialog('删除钥匙会在用户APP连网后生效'.tr, () {
|
||||
deleteKeyRequest(0);
|
||||
});
|
||||
}
|
||||
@ -363,16 +380,17 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
return currentController;
|
||||
}
|
||||
|
||||
noModificationAllowedDuringFreeze() {
|
||||
void noModificationAllowedDuringFreeze() {
|
||||
if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen) {
|
||||
showToast("冻结状态下不允许修改钥匙权限".tr);
|
||||
showToast('冻结状态下不允许修改钥匙权限'.tr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//检测实名认证是否支持开启
|
||||
Future<void> keyCheckFace() async {
|
||||
AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace(
|
||||
final AdvancedFunctionRecordEntity entity =
|
||||
await ApiRepository.to.keyCheckFace(
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId ?? 0,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
@ -385,7 +403,7 @@ class ElectronicKeyDetailLogic extends BaseGetXController {
|
||||
titleStr: '实名认证为付费功能,请购买后再使用'.tr,
|
||||
sureClick: () {
|
||||
Get.toNamed(Routers.advancedFeaturesWebPage,
|
||||
arguments: {'isShop': false});
|
||||
arguments: <String, bool>{'isShop': false});
|
||||
});
|
||||
} else if (entity.errorCode == 433) {
|
||||
//需联系管理员购买
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import 'package:date_format/date_format.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@ -5,6 +5,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/electronicKey/electronicKeyList/electronicKeyList_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_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';
|
||||
@ -26,8 +27,8 @@ class ElectronicKeyListPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
final logic = Get.put(ElectronicKeyListLogic());
|
||||
final state = Get.find<ElectronicKeyListLogic>().state;
|
||||
final ElectronicKeyListLogic logic = Get.put(ElectronicKeyListLogic());
|
||||
final ElectronicKeyListState state = Get.find<ElectronicKeyListLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -38,7 +39,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
|
||||
Future<void> mockRequest() async {
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
logic.mockNetworkDataRequest().then((ElectronicKeyListEntity value) {
|
||||
setState(() {});
|
||||
@ -54,7 +55,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
barTitle: TranslationLoader.lanKeys!.electronicKey!.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
actionsList: [
|
||||
actionsList: <Widget>[
|
||||
TextButton(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.reset!.tr,
|
||||
@ -62,13 +63,11 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
),
|
||||
onPressed: () async {
|
||||
// 获取是否是演示模式 演示模式不获取接口
|
||||
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
final bool? isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
|
||||
if (isDemoMode == false) {
|
||||
ShowTipView().showIosTipWithContentDialog("该锁的电子钥匙都将被删除".tr, (){
|
||||
logic.resetElectronicKeyListRequest();
|
||||
});
|
||||
ShowTipView().showIosTipWithContentDialog('该锁的电子钥匙都将被删除'.tr, logic.resetElectronicKeyListRequest);
|
||||
} else {
|
||||
logic.showToast("演示模式".tr);
|
||||
logic.showToast('演示模式'.tr);
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -83,7 +82,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
mockRequest();
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
// _searchWidget(),
|
||||
KeySearchWidget(
|
||||
editingController: state.searchController,
|
||||
@ -102,7 +101,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
AddBottomWhiteBtn(
|
||||
btnName: TranslationLoader.lanKeys!.sendKey!.tr,
|
||||
onClick: () {
|
||||
Navigator.pushNamed(context, Routers.sendElectronicKeyPage).then((val) {
|
||||
Navigator.pushNamed(context, Routers.sendElectronicKeyPage).then((Object? val) {
|
||||
if (val != null) {
|
||||
logic.pageNo = 1;
|
||||
mockRequest();
|
||||
@ -130,7 +129,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
child: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
itemCount: state.itemDataList.value.length,
|
||||
itemBuilder: (c, index) {
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
ElectronicKeyListItem indexEntity = state.itemDataList.value[index];
|
||||
String useDateStr = ''; //使用期限
|
||||
String keyStatus = ''; //钥匙状态
|
||||
@ -154,7 +153,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context) {
|
||||
logic.deletKeyLogic(indexEntity);
|
||||
@ -175,9 +174,9 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
indexEntity.remoteEnable == 1 ? true : false, () {
|
||||
Navigator.pushNamed(
|
||||
context, Routers.electronicKeyDetailPage,
|
||||
arguments: {
|
||||
"itemData": indexEntity,
|
||||
}).then((val) {
|
||||
arguments: <String, ElectronicKeyListItem>{
|
||||
'itemData': indexEntity,
|
||||
}).then((Object? val) {
|
||||
if (val != null) {
|
||||
logic.mockNetworkDataRequest();
|
||||
setState(() {});
|
||||
@ -214,7 +213,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} ${"永久".tr}';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) {
|
||||
//单次
|
||||
useDateStr = "单次".tr;
|
||||
useDateStr = '单次'.tr;
|
||||
useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} ${"单次".tr}';
|
||||
} else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) {
|
||||
//循环
|
||||
@ -232,7 +231,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
color: Colors.white,
|
||||
height: 90.h,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(width: 30.w),
|
||||
Image.asset(
|
||||
avatarURL,
|
||||
@ -243,14 +242,14 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 1.sw - 110.w - 34.w - 60.w,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: Text(receiveUser,
|
||||
maxLines: 1,
|
||||
@ -290,7 +289,7 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
|
||||
SizedBox(height: 10.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
useDate,
|
||||
style: TextStyle(
|
||||
|
||||
@ -125,7 +125,7 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"发送成功".tr,
|
||||
'发送成功'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.sp,
|
||||
color: Colors.black,
|
||||
@ -201,9 +201,10 @@ class _MassSendElectronicKeyPageState extends State<MassSendElectronicKeyPage> {
|
||||
: state.lockIdList.length.toString(),
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.massSendLockGroupListPage, arguments:{
|
||||
"keyLimits":"2",
|
||||
}).then((value) {
|
||||
Navigator.pushNamed(context, Routers.massSendLockGroupListPage,
|
||||
arguments: {
|
||||
'keyLimits': '2',
|
||||
}).then((Object? value) {
|
||||
//得到选中的锁ID列表
|
||||
if (value != null) {
|
||||
value as Map<String, dynamic>;
|
||||
|
||||
@ -6,27 +6,26 @@ import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/ma
|
||||
typedef _CallBack = void Function(int selectIndex, String selectLockId);
|
||||
|
||||
class massSendLockGroupCell extends StatelessWidget {
|
||||
massSendLockGroupCell(int index,
|
||||
{required this.currentIndex,
|
||||
required this.lockListByGroup,
|
||||
required this.selectLockAction,
|
||||
required this.isVip,
|
||||
Key? key})
|
||||
: super(key: key);
|
||||
final int currentIndex;
|
||||
List lockListByGroup;
|
||||
final _CallBack selectLockAction;
|
||||
bool isVip;
|
||||
|
||||
massSendLockGroupCell(int index,
|
||||
{Key? key,
|
||||
required this.currentIndex,
|
||||
required this.lockListByGroup,
|
||||
required this.selectLockAction,
|
||||
required this.isVip})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.separated(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount: lockListByGroup.length,
|
||||
itemBuilder: (_, itemIndex) {
|
||||
LockListItem itemData = lockListByGroup[itemIndex];
|
||||
itemBuilder: (_, int itemIndex) {
|
||||
final LockListItem itemData = lockListByGroup[itemIndex];
|
||||
return _itemBuilder(itemData, itemIndex);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
@ -68,8 +67,8 @@ class massSendLockGroupCell extends StatelessWidget {
|
||||
)),
|
||||
Image.asset(
|
||||
itemData.isChecked
|
||||
? "images/icon_round_select.png"
|
||||
: "images/icon_round_unSelect.png",
|
||||
? 'images/icon_round_select.png'
|
||||
: 'images/icon_round_unSelect.png',
|
||||
width: 30.w,
|
||||
height: 30.w,
|
||||
color: !isVip ? Colors.grey : AppColors.mainColor,
|
||||
|
||||
@ -9,7 +9,7 @@ class MassSendLockGroupListLogic extends BaseGetXController {
|
||||
|
||||
//分组列表请求
|
||||
Future<void> mockNetworkDataRequest() async {
|
||||
MassSendLockGroupListEntity entity =
|
||||
final MassSendLockGroupListEntity entity =
|
||||
await ApiRepository.to.lockGroupList(state.keyLimits);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
if (entity.data != null) {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupCell.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_state.dart';
|
||||
import 'package:star_lock/tools/ExpandedListView.dart';
|
||||
import 'package:star_lock/tools/showCupertinoAlertView.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
@ -21,8 +21,10 @@ class MassSendLockGroupListPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MassSendLockGroupListPageState extends State<MassSendLockGroupListPage> {
|
||||
final logic = Get.put(MassSendLockGroupListLogic());
|
||||
final state = Get.find<MassSendLockGroupListLogic>().state;
|
||||
final MassSendLockGroupListLogic logic =
|
||||
Get.put(MassSendLockGroupListLogic());
|
||||
final MassSendLockGroupListState state =
|
||||
Get.find<MassSendLockGroupListLogic>().state;
|
||||
|
||||
@override
|
||||
initState() {
|
||||
@ -77,7 +79,7 @@ class _MassSendLockGroupListPageState extends State<MassSendLockGroupListPage> {
|
||||
child: SubmitBtn(
|
||||
btnName: '确定'.tr,
|
||||
onClick: () {
|
||||
Map<String, dynamic> resultMap = {};
|
||||
final Map<String, dynamic> resultMap = {};
|
||||
resultMap['selectLockIdList'] =
|
||||
state.selectLockIdList.value;
|
||||
Navigator.pop(context, resultMap);
|
||||
@ -94,12 +96,12 @@ class _MassSendLockGroupListPageState extends State<MassSendLockGroupListPage> {
|
||||
Widget _buildListView(BuildContext context, List itemList) {
|
||||
return ListView.separated(
|
||||
itemCount: itemList.length,
|
||||
itemBuilder: (context, index) {
|
||||
GroupListItem itemData = itemList[index];
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final GroupListItem itemData = itemList[index];
|
||||
return _buildLockExpandedList(context, index, itemData);
|
||||
},
|
||||
shrinkWrap: true,
|
||||
separatorBuilder: (context, index) {
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
|
||||
@ -6,6 +6,7 @@ import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/view/sendElectronicKeyView_state.dart';
|
||||
import 'package:star_lock/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/tools/regularExpression.dart';
|
||||
import 'package:star_lock/tools/showCupertinoAlertView.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/commonDataManage.dart';
|
||||
@ -139,7 +140,9 @@ class SendElectronicKeyViewLogic extends BaseGetXController {
|
||||
var entity = await ApiRepository.to.sendElectronicKey(
|
||||
createUser: state.isCreateUser == true ? "1" : "0",
|
||||
countryCode: state.countryCode,
|
||||
usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true
|
||||
usernameType: RegularExpression()
|
||||
.isPhoneNumber(state.emailOrPhoneController.text) ==
|
||||
true
|
||||
? '1'
|
||||
: '2',
|
||||
endDate: int.parse(endDate),
|
||||
@ -184,7 +187,8 @@ class SendElectronicKeyViewLogic extends BaseGetXController {
|
||||
|
||||
//检测实名认证是否支持开启
|
||||
Future<void> keyCheckFace() async {
|
||||
AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace(
|
||||
final AdvancedFunctionRecordEntity entity =
|
||||
await ApiRepository.to.keyCheckFace(
|
||||
lockId: CommonDataManage().currentKeyInfo.lockId ?? 0,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
@ -205,19 +209,6 @@ class SendElectronicKeyViewLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
bool isPhoneNumber(String input) {
|
||||
// 手机号正则表达式,这里简化为11位数字
|
||||
final RegExp phoneRegExp = RegExp(r'^\d{11}$');
|
||||
return phoneRegExp.hasMatch(input);
|
||||
}
|
||||
|
||||
bool isEmail(String input) {
|
||||
// 邮箱正则表达式,这里简化为常见格式
|
||||
final RegExp emailRegExp =
|
||||
RegExp(r'^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$');
|
||||
return emailRegExp.hasMatch(input);
|
||||
}
|
||||
|
||||
TextEditingController getCurrentController(int lineIndex) {
|
||||
TextEditingController currentController = TextEditingController();
|
||||
switch (lineIndex) {
|
||||
|
||||
@ -186,7 +186,7 @@ class AddFaceLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
Get.close(1);
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
cancelBlueConnetctToastTimer();
|
||||
@ -231,7 +231,7 @@ class AddFaceLogic extends BaseGetXController {
|
||||
|
||||
// 取消添加指纹
|
||||
Future<void> senderCancelAddFaceCommand() 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<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -97,7 +97,7 @@ class FaceDetailLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
|
||||
@ -256,7 +256,7 @@ class FaceListLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
|
||||
|
||||
@ -185,7 +185,7 @@ class AddFingerprintLogic 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){
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -227,7 +227,7 @@ class AddFingerprintLogic extends BaseGetXController {
|
||||
|
||||
// 取消添加指纹
|
||||
Future<void> senderCancelAddFingerprintCommand() 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<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -98,7 +98,7 @@ class FingerprintDetailLogic 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<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -189,7 +189,7 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
}
|
||||
// 获取指纹状态
|
||||
Future<void> senderQueryingFingerprintStatus() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,(BluetoothConnectionState state) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -217,7 +217,7 @@ class FingerprintListLogic extends BaseGetXController{
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -248,7 +248,7 @@ class FingerprintListLogic 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<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||
|
||||
@ -90,7 +90,7 @@ class IrisDetailLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
|
||||
@ -189,7 +189,7 @@ class IrisListLogic extends BaseGetXController {
|
||||
|
||||
// 获取人脸状态
|
||||
Future<void> senderQueryingFaceStatus() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -218,7 +218,7 @@ class IrisListLogic extends BaseGetXController {
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -250,7 +250,7 @@ class IrisListLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/scheduler.dart';
|
||||
@ -7,6 +6,8 @@ import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart';
|
||||
|
||||
import 'package:star_lock/widget/permission/permission_dialog.dart';
|
||||
|
||||
@ -35,7 +36,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
// 监听设备返回的数据
|
||||
void initReplySubscription() {
|
||||
state.replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
||||
// 开门
|
||||
if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) {
|
||||
_replyOpenLock(reply);
|
||||
@ -51,48 +52,52 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
// 开门数据解析
|
||||
Future<void> _replyOpenLock(Reply reply) async {
|
||||
int status = reply.data[6];
|
||||
final int status = reply.data[6];
|
||||
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
// _showFullScreenOverlay(Get.context!);
|
||||
cancelBlueConnetctToastTimer();
|
||||
|
||||
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.closedUnlockSuccessfulTimer?.cancel();
|
||||
// 如果没有点击关闭弹窗,3秒后自动关闭
|
||||
state.closedUnlockSuccessfulTimer = Timer.periodic(3.seconds, (timer) {
|
||||
state.closedUnlockSuccessfulTimer =
|
||||
Timer.periodic(3.seconds, (Timer timer) {
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
timer.cancel();
|
||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||
});
|
||||
|
||||
// 电量
|
||||
int power = reply.data[7];
|
||||
final int power = reply.data[7];
|
||||
state.electricQuantity.value = power;
|
||||
|
||||
// 备用电量
|
||||
if (state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1) {
|
||||
int powerStandby = reply.data[9];
|
||||
final int powerStandby = reply.data[9];
|
||||
state.electricQuantityStandby.value = powerStandby;
|
||||
}
|
||||
// 更新电量
|
||||
uploadElectricQuantityRequest();
|
||||
|
||||
//锁数据更新
|
||||
getLockRecordLastUploadDataTime();
|
||||
resetOpenDoorState();
|
||||
state.animationController!.stop();
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
final List<String>? signKey =
|
||||
await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var tokenData = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(tokenData);
|
||||
final List<int> tokenData = reply.data.sublist(2, 6);
|
||||
final List<String> saveStrList = changeIntListToStringList(tokenData);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
IoSenderManage.senderOpenLock(
|
||||
@ -110,69 +115,56 @@ class LockDetailLogic extends BaseGetXController {
|
||||
case 0x16:
|
||||
// 正在开锁中...
|
||||
resetOpenDoorState();
|
||||
showToast("正在开锁中...".tr, something: () {
|
||||
showToast('正在开锁中...'.tr, something: () {
|
||||
cancelBlueConnetctToastTimer();
|
||||
});
|
||||
break;
|
||||
case 0x0d:
|
||||
// 钥匙无效
|
||||
showToast('钥匙无效'.tr);
|
||||
// state.animationController!.stop();
|
||||
resetOpenDoorState();
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
openDoorError();
|
||||
break;
|
||||
case 0x0b:
|
||||
// 钥匙无效
|
||||
showToast('钥匙过期'.tr);
|
||||
resetOpenDoorState();
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
openDoorError();
|
||||
break;
|
||||
case 0x0a:
|
||||
// 钥匙不存在
|
||||
showToast("钥匙不存在");
|
||||
resetOpenDoorState();
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
showToast('钥匙不存在');
|
||||
openDoorError();
|
||||
break;
|
||||
case 0x0c:
|
||||
// 钥匙数量已到上限
|
||||
showToast("钥匙数量已到上限");
|
||||
resetOpenDoorState();
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
showToast('钥匙数量已到上限');
|
||||
openDoorError();
|
||||
break;
|
||||
case 0x0e:
|
||||
// 钥匙已存在
|
||||
showToast("钥匙已存在");
|
||||
resetOpenDoorState();
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
showToast('钥匙已存在');
|
||||
openDoorError();
|
||||
break;
|
||||
case 0x0f:
|
||||
// 用户已存在
|
||||
showToast("用户已存在");
|
||||
resetOpenDoorState();
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
showToast('用户已存在');
|
||||
openDoorError();
|
||||
break;
|
||||
default:
|
||||
//失败
|
||||
AppLog.log("开锁失败");
|
||||
// state.animationController!.stop();
|
||||
resetOpenDoorState();
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
AppLog.log('开锁失败');
|
||||
openDoorError();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//开门指令失败
|
||||
void openDoorError() {
|
||||
resetOpenDoorState();
|
||||
state.animationController!.stop();
|
||||
cancelBlueConnetctToastTimer();
|
||||
BlueManage().disconnect();
|
||||
}
|
||||
|
||||
//清除开锁动画以及状态
|
||||
void closeLuckStatus() {
|
||||
state.openLockBtnState.value = 0;
|
||||
@ -183,11 +175,11 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
// 根据时间查解析数据
|
||||
Future<void> _replyReferEventRecordTime(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
final int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
int dataLength = (reply.data[5] << 8) + reply.data[6];
|
||||
final int dataLength = (reply.data[5] << 8) + reply.data[6];
|
||||
// AppLog.log("dataLength:$dataLength");
|
||||
if (dataLength > 0) {
|
||||
reply.data.removeRange(0, 7);
|
||||
@ -195,32 +187,32 @@ class LockDetailLogic extends BaseGetXController {
|
||||
if (reply.data.length < 17) {
|
||||
return;
|
||||
}
|
||||
var getList = splitList(reply.data, 17);
|
||||
final List<List<int>> getList = splitList(reply.data, 17);
|
||||
// AppLog.log("getList:$getList");
|
||||
var uploadList = [];
|
||||
final List uploadList = [];
|
||||
for (int i = 0; i < getList.length; i++) {
|
||||
var indexList = getList[i];
|
||||
final List<int> indexList = getList[i];
|
||||
// AppLog.log("indexList:$indexList");
|
||||
var indexMap = {};
|
||||
indexMap["type"] = indexList[0].toString();
|
||||
final Map indexMap = {};
|
||||
indexMap['type'] = indexList[0].toString();
|
||||
int operateDate = 0;
|
||||
if (indexList[0] == 2) {
|
||||
var passwordData = reply.data.sublist(7, 17);
|
||||
var password = utf8String(passwordData);
|
||||
indexMap["user"] = password.toString();
|
||||
final List<int> passwordData = reply.data.sublist(7, 17);
|
||||
final String password = utf8String(passwordData);
|
||||
indexMap['user'] = password.toString();
|
||||
} else {
|
||||
int userNo = (indexList[1] * 256) + indexList[2];
|
||||
indexMap["user"] = userNo.toString();
|
||||
final int userNo = (indexList[1] * 256) + indexList[2];
|
||||
indexMap['user'] = userNo.toString();
|
||||
}
|
||||
|
||||
indexMap["success"] = "1";
|
||||
indexMap['success'] = '1';
|
||||
|
||||
int time = ((0xff & indexList[(3)]) << 24 |
|
||||
final int time = ((0xff & indexList[(3)]) << 24 |
|
||||
(0xff & indexList[4]) << 16 |
|
||||
(0xff & indexList[5]) << 8 |
|
||||
(0xFF & indexList[6]));
|
||||
operateDate = time * 1000;
|
||||
indexMap["date"] = "$operateDate";
|
||||
indexMap['date'] = '$operateDate';
|
||||
uploadList.add(indexMap);
|
||||
|
||||
if (i == getList.length - 1) {
|
||||
@ -253,20 +245,21 @@ class LockDetailLogic extends BaseGetXController {
|
||||
Future<void> openDoorAction() async {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
resetOpenDoorState();
|
||||
// BlueManage().stopScan();
|
||||
closeLuckStatus();
|
||||
BlueManage().disconnect();
|
||||
});
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
final List<String>? signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
final List<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
BlueManage()
|
||||
.bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
||||
.blueSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
IoSenderManage.senderOpenLock(
|
||||
@ -293,24 +286,28 @@ class LockDetailLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 查询事件记录(时间查询)
|
||||
Future<void> senderReferEventRecordTime() async {
|
||||
void senderReferEventRecordTime() {
|
||||
showBlueConnetctToastTimer(
|
||||
isShowBlueConnetctToast: false,
|
||||
outTimer: 10,
|
||||
action: () {
|
||||
closeLuckStatus();
|
||||
BlueManage().disconnect();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
final List<String>? publicKey =
|
||||
await Storage.getStringList(saveBluePublicKey);
|
||||
final List<int> getPublicKeyList =
|
||||
changeStringListToIntList(publicKey!);
|
||||
|
||||
IoSenderManage.senderReferEventRecordTimeCommand(
|
||||
keyID: BlueManage().connectDeviceName,
|
||||
@ -329,7 +326,8 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
// 从服务器获取锁的时间 开锁时传入
|
||||
void getServerDatetime() async {
|
||||
var entity = await ApiRepository.to.getServerDatetimeData();
|
||||
final GetServerDatetimeEntity entity =
|
||||
await ApiRepository.to.getServerDatetimeData();
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.differentialTime = entity.data!.date! ~/ 1000 -
|
||||
DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
@ -344,17 +342,17 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
// 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口
|
||||
void getLockNetToken() async {
|
||||
LockNetTokenEntity entity = await ApiRepository.to
|
||||
final LockNetTokenEntity entity = await ApiRepository.to
|
||||
.getLockNetToken(lockId: state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.lockNetToken = entity.data!.token!.toString();
|
||||
AppLog.log("从服务器获取联网token:${state.lockNetToken}");
|
||||
AppLog.log('从服务器获取联网token:${state.lockNetToken}');
|
||||
openDoorAction();
|
||||
} else {
|
||||
showToast("网络访问失败,请检查网络是否正常".tr, something: () {
|
||||
showToast('网络访问失败,请检查网络是否正常'.tr, something: () {
|
||||
resetOpenDoorState();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.lockNetToken = "0";
|
||||
state.lockNetToken = '0';
|
||||
openDoorAction();
|
||||
});
|
||||
}
|
||||
@ -362,7 +360,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
//电量更新请求
|
||||
Future<void> uploadElectricQuantityRequest() async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.uploadElectricQuantity(
|
||||
electricQuantity: state.electricQuantity.value.toString(),
|
||||
electricQuantityStandby:
|
||||
@ -371,15 +369,15 @@ class LockDetailLogic extends BaseGetXController {
|
||||
isUnShowLoading: true);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
eventBus.fire(RefreshLockListInfoDataEvent(isUnShowLoading: true));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 查询锁记录最后时间
|
||||
void getLockRecordLastUploadDataTime() async {
|
||||
LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to
|
||||
.getLockRecordLastUploadDataTime(
|
||||
final LockOperatingRecordGetLastRecordTimeEntity entity =
|
||||
await ApiRepository.to.getLockRecordLastUploadDataTime(
|
||||
lockId: state.keyInfos.value.lockId.toString());
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.operateDate = entity.data!.operateDate! ~/ 1000;
|
||||
@ -388,14 +386,14 @@ class LockDetailLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
// 操作记录上传
|
||||
void lockRecordUploadData(List list) async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
Future<void> lockRecordUploadData(List list) async {
|
||||
final KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.lockRecordUploadData(
|
||||
lockId: state.keyInfos.value.lockId.toString(), records: list);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
// mockNetworkDataRequest();
|
||||
AppLog.log(
|
||||
"state.keyInfos.value.keyType:${state.keyInfos.value.keyType}");
|
||||
'state.keyInfos.value.keyType:${state.keyInfos.value.keyType}');
|
||||
if (state.keyInfos.value.keyType == XSConstantMacro.keyTypeOnce) {
|
||||
// 单次删除
|
||||
deletKeyData();
|
||||
@ -405,10 +403,11 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
// 普通用户或者授权管理员删除钥匙
|
||||
void deletKeyData() async {
|
||||
var entity = await ApiRepository.to.deleteElectronicKey(
|
||||
keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0);
|
||||
final ElectronicKeyListEntity entity = await ApiRepository.to
|
||||
.deleteElectronicKey(
|
||||
keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
BlueManage().connectDeviceMacAddress = '';
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
});
|
||||
@ -422,7 +421,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
state.lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent =
|
||||
eventBus
|
||||
.on<LockSetChangeSetRefreshLockDetailWithType>()
|
||||
.listen((event) {
|
||||
.listen((LockSetChangeSetRefreshLockDetailWithType event) {
|
||||
if (event.type == 0) {
|
||||
// 0考勤
|
||||
state.isAttendance.value = int.parse(event.setResult);
|
||||
@ -433,7 +432,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
state.isOpenLockNeedOnline.value = int.parse(event.setResult);
|
||||
state.keyInfos.value.lockSetting!.appUnlockOnline =
|
||||
int.parse(event.setResult);
|
||||
state.lockNetToken = ""; // 改变开锁时是否联网状态的时候清空token
|
||||
state.lockNetToken = ''; // 改变开锁时是否联网状态的时候清空token
|
||||
} else if (event.type == 2) {
|
||||
// 2 常开模式
|
||||
state.isOpenPassageMode.value = int.parse(event.setResult);
|
||||
@ -458,7 +457,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
String getKeyStatusTextAndShow() {
|
||||
String text = "";
|
||||
String text = '';
|
||||
if (state.keyInfos.value.keyStatus ==
|
||||
XSConstantMacro.keyStatusWaitIneffective ||
|
||||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen ||
|
||||
@ -469,7 +468,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
"${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}";
|
||||
} else {
|
||||
text = state.isOpenPassageMode.value == 1
|
||||
? "常开模式启动!长按闭锁".tr
|
||||
? '常开模式启动!长按闭锁'.tr
|
||||
: TranslationLoader.lanKeys!.clickUnlockAndHoldDownClose!.tr;
|
||||
}
|
||||
return text;
|
||||
@ -477,9 +476,9 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
String getCurrentFormattedTime() {
|
||||
// 获取当前时间
|
||||
DateTime now = DateTime.now();
|
||||
final DateTime now = DateTime.now();
|
||||
// 格式化日期和时间
|
||||
String formattedTime = DateFormat('MM/dd HH:mm').format(now);
|
||||
final String formattedTime = DateFormat('MM/dd HH:mm').format(now);
|
||||
return formattedTime;
|
||||
}
|
||||
|
||||
@ -498,5 +497,17 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
await PermissionDialog.request(Permission.location);
|
||||
await PermissionDialog.requestBluetooth();
|
||||
|
||||
final String connectDeviceName =
|
||||
state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
|
||||
if (!BlueManage().isExistScanDevices(connectDeviceName)) {
|
||||
BlueManage().startScanSingle(
|
||||
connectDeviceName, 15, (List<ScanResult> p0) => null);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_list_page.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_state.dart';
|
||||
import 'package:star_lock/tools/aliyunRealNameAuth/aliyunRealNameAuthHandle.dart';
|
||||
import 'package:star_lock/tools/showCupertinoAlertView.dart';
|
||||
import 'package:star_lock/tools/showTipView.dart';
|
||||
@ -44,8 +45,8 @@ class LockDetailPage extends StatefulWidget {
|
||||
class _LockDetailPageState extends State<LockDetailPage>
|
||||
with TickerProviderStateMixin, RouteAware {
|
||||
// with RouteAware
|
||||
final logic = Get.put(LockDetailLogic());
|
||||
final state = Get.find<LockDetailLogic>().state;
|
||||
final LockDetailLogic logic = Get.put(LockDetailLogic());
|
||||
final LockDetailState state = Get.find<LockDetailLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -75,8 +76,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
|
||||
void _initRefreshLockDetailInfoDataEventAction() {
|
||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||
_lockRefreshLockDetailInfoDataEvent =
|
||||
eventBus.on<RefreshLockDetailInfoDataEvent>().listen((event) {
|
||||
_lockRefreshLockDetailInfoDataEvent = eventBus
|
||||
.on<RefreshLockDetailInfoDataEvent>()
|
||||
.listen((RefreshLockDetailInfoDataEvent event) {
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
@ -114,26 +116,28 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
BlueManage().connectDeviceName =
|
||||
state.keyInfos.value.bluetooth!.bluetoothDeviceName!;
|
||||
|
||||
List<int> publicKeyData =
|
||||
final List<int> publicKeyData =
|
||||
state.keyInfos.value.bluetooth!.publicKey!.cast<int>();
|
||||
var saveStrList = changeIntListToStringList(publicKeyData);
|
||||
final List<String> saveStrList = changeIntListToStringList(publicKeyData);
|
||||
Storage.setStringList(saveBluePublicKey, saveStrList);
|
||||
|
||||
// 私钥
|
||||
List<int> privateKeyData =
|
||||
final List<int> privateKeyData =
|
||||
state.keyInfos.value.bluetooth!.privateKey!.cast<int>();
|
||||
var savePrivateKeyList = changeIntListToStringList(privateKeyData);
|
||||
final List<String> savePrivateKeyList =
|
||||
changeIntListToStringList(privateKeyData);
|
||||
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
|
||||
|
||||
// signKey
|
||||
List<int> signKeyData =
|
||||
final List<int> signKeyData =
|
||||
state.keyInfos.value.bluetooth!.signKey!.cast<int>();
|
||||
var saveSignKeyList = changeIntListToStringList(signKeyData);
|
||||
final List<String> saveSignKeyList = changeIntListToStringList(signKeyData);
|
||||
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
||||
|
||||
bool ifHaveKey = await Storage.ifHaveKey(saveBlueToken);
|
||||
final bool ifHaveKey = await Storage.ifHaveKey(saveBlueToken);
|
||||
if (!ifHaveKey) {
|
||||
var saveTokenList = changeIntListToStringList([0, 0, 0, 0]);
|
||||
final List<String> saveTokenList =
|
||||
changeIntListToStringList(<int>[0, 0, 0, 0]);
|
||||
Storage.setStringList(saveBlueToken, saveTokenList);
|
||||
}
|
||||
}
|
||||
@ -141,7 +145,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
loadData();
|
||||
return F.sw(defaultCall: () => skWidget(), xhjCall: () => xhjWidget());
|
||||
return F.sw(defaultCall: skWidget, xhjCall: xhjWidget);
|
||||
}
|
||||
|
||||
//鑫泓佳布局
|
||||
@ -150,9 +154,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
backgroundColor: Colors.white,
|
||||
body: Obx(() {
|
||||
return Stack(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 35.h,
|
||||
),
|
||||
@ -193,7 +197,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16.r),
|
||||
boxShadow: [
|
||||
boxShadow: <BoxShadow>[
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.15),
|
||||
offset: const Offset(0, 0),
|
||||
@ -202,7 +206,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
),
|
||||
]),
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
img,
|
||||
width: 32.r,
|
||||
@ -236,7 +240,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(20.r),
|
||||
boxShadow: [
|
||||
boxShadow: <BoxShadow>[
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.15),
|
||||
offset: const Offset(0, 0),
|
||||
@ -247,19 +251,15 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: state.openDoorBtnisUneable.value == true
|
||||
? () {
|
||||
isNeedRealNameAuthThenOpenLock();
|
||||
}
|
||||
? isNeedRealNameAuthThenOpenLock
|
||||
: null,
|
||||
onLongPressStart: state.openDoorBtnisUneable.value == true
|
||||
? (details) {
|
||||
setState(() {
|
||||
startUnLock();
|
||||
});
|
||||
? (LongPressStartDetails details) {
|
||||
setState(startUnLock);
|
||||
}
|
||||
: null,
|
||||
child: Container(
|
||||
@ -268,7 +268,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(100.w),
|
||||
boxShadow: [
|
||||
boxShadow: <BoxShadow>[
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
offset: const Offset(0, 0),
|
||||
@ -279,42 +279,44 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
margin: EdgeInsets.only(left: 35.w, bottom: 15.h),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.center,
|
||||
children: [
|
||||
state.openDoorBtnisUneable.value == false
|
||||
? Icon(
|
||||
Icons.bluetooth_searching,
|
||||
size: 48.r,
|
||||
color: AppColors.mainColor,
|
||||
)
|
||||
: Image.asset(
|
||||
state.isOpenPassageMode.value == 1
|
||||
? 'images/icon_lock_err.png'
|
||||
: 'images/icon_lock_fill.png',
|
||||
width: 38.r,
|
||||
height: 38.r,
|
||||
color: AppColors.mainColor,
|
||||
),
|
||||
state.openDoorBtnisUneable.value == false
|
||||
? Positioned(
|
||||
child: Icon(
|
||||
Icons.bluetooth_searching,
|
||||
size: 96.r,
|
||||
),
|
||||
)
|
||||
: state.openLockBtnState.value == 1
|
||||
? xhjBuildRotationTransition(
|
||||
width: 88.r,
|
||||
height: 88.r,
|
||||
)
|
||||
: Positioned(
|
||||
child: Image.asset(
|
||||
'images/icon_circle_dotted.png',
|
||||
width: 88.r,
|
||||
height: 88.r,
|
||||
color: state.isOpenPassageMode.value == 1
|
||||
? Colors.red
|
||||
: AppColors.mainColor,
|
||||
)),
|
||||
children: <Widget>[
|
||||
if (state.openDoorBtnisUneable.value == false)
|
||||
Icon(
|
||||
Icons.bluetooth_searching,
|
||||
size: 48.r,
|
||||
color: AppColors.mainColor,
|
||||
)
|
||||
else
|
||||
Image.asset(
|
||||
state.isOpenPassageMode.value == 1
|
||||
? 'images/icon_lock_err.png'
|
||||
: 'images/icon_lock_fill.png',
|
||||
width: 38.r,
|
||||
height: 38.r,
|
||||
color: AppColors.mainColor,
|
||||
),
|
||||
if (state.openDoorBtnisUneable.value == false)
|
||||
Positioned(
|
||||
child: Icon(
|
||||
Icons.bluetooth_searching,
|
||||
size: 96.r,
|
||||
),
|
||||
)
|
||||
else
|
||||
state.openLockBtnState.value == 1
|
||||
? xhjBuildRotationTransition(
|
||||
width: 88.r,
|
||||
height: 88.r,
|
||||
)
|
||||
: Positioned(
|
||||
child: Image.asset(
|
||||
'images/icon_circle_dotted.png',
|
||||
width: 88.r,
|
||||
height: 88.r,
|
||||
color: state.isOpenPassageMode.value == 1
|
||||
? Colors.red
|
||||
: AppColors.mainColor,
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -323,10 +325,10 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
padding: EdgeInsets.only(left: 15.w, right: 00.w, bottom: 15.h),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
TranslationLoader
|
||||
.lanKeys!.clickUnlockAndHoldDownClose!.tr,
|
||||
@ -341,16 +343,16 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
showElectricIcon(state.electricQuantity.value),
|
||||
width: 30.w,
|
||||
height: 24.w),
|
||||
SizedBox(width: 2.w),
|
||||
Text("${state.electricQuantity.value}%",
|
||||
Text('${state.electricQuantity.value}%',
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.darkGrayTextColor)),
|
||||
@ -368,13 +370,13 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
showElectricIcon(state.electricQuantity.value),
|
||||
width: 30.w,
|
||||
height: 24.w),
|
||||
SizedBox(width: 2.w),
|
||||
Text("--%",
|
||||
Text('--%',
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.darkGrayTextColor)),
|
||||
@ -400,32 +402,30 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
//斯凯布局
|
||||
Widget skWidget() {
|
||||
return ListView(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Visibility(
|
||||
visible:
|
||||
((state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime ||
|
||||
state.keyInfos.value.keyType ==
|
||||
XSConstantMacro.keyTypeLoop) && // 限时、循环
|
||||
(DateTool().compareTimeGetDaysFromNow(
|
||||
state.keyInfos.value.endDate!) <=
|
||||
15 &&
|
||||
DateTool().compareTimeGetDaysFromNow(
|
||||
state.keyInfos.value.endDate!) >=
|
||||
0) && // 0到30天
|
||||
(state.keyInfos.value.keyStatus ==
|
||||
XSConstantMacro.keyStatusNormalUse ||
|
||||
state.keyInfos.value.keyStatus ==
|
||||
XSConstantMacro.keyStatusWaitReceive) // 正常使用、待接收
|
||||
)
|
||||
? true
|
||||
: false,
|
||||
(state.keyInfos.value.keyType == XSConstantMacro.keyTypeTime ||
|
||||
state.keyInfos.value.keyType ==
|
||||
XSConstantMacro.keyTypeLoop) && // 限时、循环
|
||||
(DateTool().compareTimeGetDaysFromNow(
|
||||
state.keyInfos.value.endDate!) <=
|
||||
15 &&
|
||||
DateTool().compareTimeGetDaysFromNow(
|
||||
state.keyInfos.value.endDate!) >=
|
||||
0) && // 0到30天
|
||||
(state.keyInfos.value.keyStatus ==
|
||||
XSConstantMacro.keyStatusNormalUse ||
|
||||
state.keyInfos.value.keyStatus ==
|
||||
XSConstantMacro.keyStatusWaitReceive) // 正常使用、待接收
|
||||
,
|
||||
child: Container(
|
||||
// height: 30.h,
|
||||
color: const Color(0xFFFBEFD4),
|
||||
padding: EdgeInsets.only(top: 8.h, bottom: 8.h),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"${"钥匙将在".tr}${DateTool().compareTimeGetDaysFromNow(state.keyInfos.value.endDate!)}${"天后失效".tr}",
|
||||
style: TextStyle(
|
||||
@ -434,26 +434,26 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
),
|
||||
),
|
||||
),
|
||||
Stack(children: [
|
||||
Stack(children: <Widget>[
|
||||
Container(
|
||||
width: 1.sw,
|
||||
height: 1.sh - ScreenUtil().statusBarHeight,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
topWidget(),
|
||||
SizedBox(
|
||||
height: 10.h,
|
||||
),
|
||||
Obx(() => buildPageIndicator()),
|
||||
Obx(buildPageIndicator),
|
||||
Expanded(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(left: 10.w, right: 10.w, top: 30.h),
|
||||
child: PageView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
controller: state.pageController,
|
||||
children: [
|
||||
Obx(() => bottomWidget()),
|
||||
children: <Widget>[
|
||||
Obx(bottomWidget),
|
||||
attachmentWidget(),
|
||||
],
|
||||
),
|
||||
@ -476,7 +476,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
|
||||
Widget topWidget() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
F.sw(
|
||||
defaultCall: () => SizedBox(height: 50.h),
|
||||
xhjCall: () => Padding(
|
||||
@ -490,7 +490,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
),
|
||||
),
|
||||
Stack(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Center(
|
||||
child: Text(
|
||||
state.lockAlias.value,
|
||||
@ -504,7 +504,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
Positioned(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
ShowTipView().showSureAlertDialog(
|
||||
@ -512,7 +512,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
FlavorsImg(
|
||||
child: Image.asset(
|
||||
showElectricIcon(state.electricQuantity.value),
|
||||
@ -520,7 +520,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
height: 24.w),
|
||||
),
|
||||
SizedBox(width: 2.w),
|
||||
Text("${state.electricQuantity.value}%",
|
||||
Text('${state.electricQuantity.value}%',
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.darkGrayTextColor)),
|
||||
@ -542,7 +542,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
1,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
FlavorsImg(
|
||||
child: Image.asset(
|
||||
showElectricIcon(
|
||||
@ -551,7 +551,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
height: 24.w),
|
||||
),
|
||||
SizedBox(width: 2.w),
|
||||
Text("${state.electricQuantityStandby.value}%",
|
||||
Text('${state.electricQuantityStandby.value}%',
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.darkGrayTextColor)),
|
||||
@ -580,23 +580,19 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
color: Colors.white,
|
||||
height: 330.w,
|
||||
child: Stack(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Center(
|
||||
child: GestureDetector(
|
||||
onTap: state.openDoorBtnisUneable.value == true
|
||||
? () {
|
||||
isNeedRealNameAuthThenOpenLock();
|
||||
}
|
||||
? isNeedRealNameAuthThenOpenLock
|
||||
: null,
|
||||
onLongPressStart: state.openDoorBtnisUneable.value == true
|
||||
? (details) {
|
||||
setState(() {
|
||||
startUnLock();
|
||||
});
|
||||
? (LongPressStartDetails details) {
|
||||
setState(startUnLock);
|
||||
}
|
||||
: null,
|
||||
child: Stack(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
FlavorsImg(
|
||||
child: Image.asset(
|
||||
state.openDoorBtnisUneable.value == false
|
||||
@ -609,31 +605,32 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
// color: AppColors.primaryTopColor,
|
||||
),
|
||||
),
|
||||
state.openDoorBtnisUneable.value == false
|
||||
? Positioned(
|
||||
child: FlavorsImg(
|
||||
if (state.openDoorBtnisUneable.value == false)
|
||||
Positioned(
|
||||
child: FlavorsImg(
|
||||
child: Image.asset(
|
||||
'images/main/icon_main_openLockBtn_grey.png',
|
||||
width: 330.w,
|
||||
height: 330.w,
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
state.openLockBtnState.value == 1
|
||||
? buildRotationTransition(
|
||||
width: 330.w,
|
||||
height: 330.w,
|
||||
)
|
||||
: Positioned(
|
||||
child: FlavorsImg(
|
||||
child: Image.asset(
|
||||
'images/main/icon_main_openLockBtn_grey.png',
|
||||
state.isOpenPassageMode.value == 1
|
||||
? 'images/main/icon_main_normallyOpenMode_circle.png'
|
||||
: 'images/main/icon_main_openLockBtn_circle.png',
|
||||
width: 330.w,
|
||||
height: 330.w,
|
||||
),
|
||||
),
|
||||
)
|
||||
: state.openLockBtnState.value == 1
|
||||
? buildRotationTransition(
|
||||
width: 330.w,
|
||||
height: 330.w,
|
||||
)
|
||||
: Positioned(
|
||||
child: FlavorsImg(
|
||||
child: Image.asset(
|
||||
state.isOpenPassageMode.value == 1
|
||||
? 'images/main/icon_main_normallyOpenMode_circle.png'
|
||||
: 'images/main/icon_main_openLockBtn_circle.png',
|
||||
width: 330.w,
|
||||
height: 330.w,
|
||||
),
|
||||
)),
|
||||
)),
|
||||
],
|
||||
),
|
||||
)),
|
||||
@ -641,9 +638,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
right: 90.w,
|
||||
bottom: 1,
|
||||
child: Obx(() => Visibility(
|
||||
visible: state.keyInfos.value.lockSetting!.remoteUnlock == 1
|
||||
? true
|
||||
: false,
|
||||
visible:
|
||||
state.keyInfos.value.lockSetting!.remoteUnlock == 1,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
ShowCupertinoAlertView().isToRemoteUnLockAlert(
|
||||
@ -672,7 +668,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
logic.getKeyStatusTextAndShow(),
|
||||
style: TextStyle(
|
||||
@ -685,9 +681,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
F.sw(
|
||||
defaultCall: () => adminInfoView(),
|
||||
xhjCall: () => const SizedBox()),
|
||||
F.sw(defaultCall: adminInfoView, xhjCall: () => const SizedBox()),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
@ -707,7 +701,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
mainAxisAlignment:
|
||||
center ? MainAxisAlignment.center : MainAxisAlignment.start,
|
||||
mainAxisSize: max ? MainAxisSize.max : MainAxisSize.min,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
'images/icon_electronicKey_admin.png',
|
||||
width: 24.w,
|
||||
@ -742,7 +736,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
? AppColors.mainColor
|
||||
: AppColors.btnDisableColor),
|
||||
),
|
||||
if (add) ...[
|
||||
if (add) ...<Widget>[
|
||||
const Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
@ -752,7 +746,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
FlavorsImg(
|
||||
child: Image.asset(
|
||||
'images/mine/icon_mine_main_addLock.png',
|
||||
@ -823,7 +817,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
Widget buildPageIndicator() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(2, (index) {
|
||||
children: List.generate(2, (int index) {
|
||||
return Container(
|
||||
width: 10.0.w,
|
||||
height: 10.0.w,
|
||||
@ -855,7 +849,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
|
||||
// 配件配置
|
||||
List<Widget> getAttachmentWidget() {
|
||||
var showWidgetArr = <Widget>[];
|
||||
final List<Widget> showWidgetArr = <Widget>[];
|
||||
// 无线键盘
|
||||
// if (state.isAttendance.value == 1) {
|
||||
// showWidgetArr.add(bottomItem(
|
||||
@ -911,7 +905,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
|
||||
// 普通用户
|
||||
List<Widget> getNormalWidget() {
|
||||
List<Widget> showWidgetArr = <Widget>[];
|
||||
final List<Widget> showWidgetArr = <Widget>[];
|
||||
// 考勤
|
||||
if (state.isAttendance.value == 1) {
|
||||
showWidgetArr.add(bottomItem(
|
||||
@ -928,15 +922,17 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
TranslationLoader.lanKeys!.operatingRecord!.tr,
|
||||
state.bottomBtnisEable.value, () {
|
||||
Get.toNamed(Routers.doorLockLogPage,
|
||||
arguments: {"keyInfo": state.keyInfos.value});
|
||||
arguments: <String, LockListInfoItemEntity>{
|
||||
'keyInfo': state.keyInfos.value
|
||||
});
|
||||
}));
|
||||
|
||||
// 设置
|
||||
showWidgetArr.add(bottomItem('images/main/icon_main_set.png',
|
||||
TranslationLoader.lanKeys!.set!.tr, true, () {
|
||||
Get.toNamed(Routers.lockSetPage, arguments: {
|
||||
"lockId": state.keyInfos.value.lockId,
|
||||
"isOnlyOneData": state.isOnlyOneData
|
||||
Get.toNamed(Routers.lockSetPage, arguments: <String, Object?>{
|
||||
'lockId': state.keyInfos.value.lockId,
|
||||
'isOnlyOneData': state.isOnlyOneData
|
||||
});
|
||||
}));
|
||||
|
||||
@ -945,7 +941,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
|
||||
// 授权管理员、超级管理员字段
|
||||
List<Widget> getAllWidget() {
|
||||
var showWidgetArr = <Widget>[];
|
||||
final List<Widget> showWidgetArr = <Widget>[];
|
||||
// 考勤
|
||||
if (state.isAttendance.value == 1) {
|
||||
showWidgetArr.add(bottomItem(
|
||||
@ -971,7 +967,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
TranslationLoader.lanKeys!.password!.tr,
|
||||
state.bottomBtnisEable.value, () {
|
||||
Get.toNamed(Routers.passwordKeyListPage,
|
||||
arguments: {"keyInfo": state.keyInfos.value});
|
||||
arguments: <String, LockListInfoItemEntity>{
|
||||
'keyInfo': state.keyInfos.value
|
||||
});
|
||||
}));
|
||||
|
||||
// ic卡
|
||||
@ -980,8 +978,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
'images/main/icon_main_icCard.png',
|
||||
TranslationLoader.lanKeys!.card!.tr,
|
||||
state.bottomBtnisEable.value, () {
|
||||
Get.toNamed(Routers.cardListPage, arguments: {
|
||||
"lockId": state.keyInfos.value.lockId,
|
||||
Get.toNamed(Routers.cardListPage, arguments: <String, int?>{
|
||||
'lockId': state.keyInfos.value.lockId,
|
||||
});
|
||||
}));
|
||||
}
|
||||
@ -992,8 +990,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
'images/main/icon_main_fingerprint.png',
|
||||
TranslationLoader.lanKeys!.fingerprint!.tr,
|
||||
state.bottomBtnisEable.value, () {
|
||||
Get.toNamed(Routers.fingerprintListPage, arguments: {
|
||||
"lockId": state.keyInfos.value.lockId,
|
||||
Get.toNamed(Routers.fingerprintListPage, arguments: <String, int?>{
|
||||
'lockId': state.keyInfos.value.lockId,
|
||||
});
|
||||
}));
|
||||
}
|
||||
@ -1015,8 +1013,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
'images/main/icon_face.png',
|
||||
TranslationLoader.lanKeys!.humanFace!.tr,
|
||||
state.bottomBtnisEable.value, () {
|
||||
Get.toNamed(Routers.faceListPage, arguments: {
|
||||
"lockId": state.keyInfos.value.lockId,
|
||||
Get.toNamed(Routers.faceListPage, arguments: <String, int?>{
|
||||
'lockId': state.keyInfos.value.lockId,
|
||||
});
|
||||
}),
|
||||
);
|
||||
@ -1027,8 +1025,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
bottomItem(
|
||||
'images/main/icon_iris.png', '虹膜'.tr, state.bottomBtnisEable.value,
|
||||
() {
|
||||
Get.toNamed(Routers.irisListPage, arguments: {
|
||||
"lockId": state.keyInfos.value.lockId,
|
||||
Get.toNamed(Routers.irisListPage, arguments: <String, int?>{
|
||||
'lockId': state.keyInfos.value.lockId,
|
||||
});
|
||||
}),
|
||||
);
|
||||
@ -1039,8 +1037,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
bottomItem(
|
||||
'images/main/icon_palm.png', '手掌'.tr, state.bottomBtnisEable.value,
|
||||
() {
|
||||
Get.toNamed(Routers.palmListPage, arguments: {
|
||||
"lockId": state.keyInfos.value.lockId,
|
||||
Get.toNamed(Routers.palmListPage, arguments: <String, int?>{
|
||||
'lockId': state.keyInfos.value.lockId,
|
||||
});
|
||||
}),
|
||||
);
|
||||
@ -1053,9 +1051,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
'images/main/icon_catEyes.png',
|
||||
TranslationLoader.lanKeys!.monitoring!.tr,
|
||||
state.bottomBtnisEable.value, () {
|
||||
Get.toNamed(Routers.realTimePicturePage, arguments: {
|
||||
"lockName": state.keyInfos.value.lockName,
|
||||
"isMonitoring": true
|
||||
Get.toNamed(Routers.realTimePicturePage, arguments: <String, Object?>{
|
||||
'lockName': state.keyInfos.value.lockName,
|
||||
'isMonitoring': true
|
||||
});
|
||||
}),
|
||||
);
|
||||
@ -1068,11 +1066,13 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
TranslationLoader.lanKeys!.authorizedAdmin!.tr,
|
||||
state.bottomBtnisEable.value, () {
|
||||
Get.toNamed(Routers.authorizedAdminListPage,
|
||||
arguments: {"keyInfo": state.keyInfos.value});
|
||||
arguments: <String, LockListInfoItemEntity>{
|
||||
'keyInfo': state.keyInfos.value
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
var endWiddget = <Widget>[];
|
||||
final List<Widget> endWiddget = <Widget>[];
|
||||
endWiddget.add(
|
||||
// 操作记录
|
||||
bottomItem(
|
||||
@ -1082,7 +1082,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
// Get.toNamed(Routers.lockOperatingRecordPage,
|
||||
// arguments: {"keyInfo": state.keyInfos.value});
|
||||
Get.toNamed(Routers.doorLockLogPage,
|
||||
arguments: {"keyInfo": state.keyInfos.value});
|
||||
arguments: <String, LockListInfoItemEntity>{
|
||||
'keyInfo': state.keyInfos.value
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
@ -1092,8 +1094,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
'images/main/icon_lockDetail_videoLog.png',
|
||||
TranslationLoader.lanKeys!.videoLog!.tr,
|
||||
state.bottomBtnisEable.value, () {
|
||||
Get.toNamed(Routers.videoLogPage, arguments: {
|
||||
"lockId": state.keyInfos.value.lockId,
|
||||
Get.toNamed(Routers.videoLogPage, arguments: <String, int?>{
|
||||
'lockId': state.keyInfos.value.lockId,
|
||||
});
|
||||
}));
|
||||
}
|
||||
@ -1103,8 +1105,8 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
'images/main/icon_lockDetail_messageReminding.png',
|
||||
TranslationLoader.lanKeys!.messageReminding!.tr,
|
||||
state.bottomBtnisEable.value, () {
|
||||
Get.toNamed(Routers.msgNotificationPage, arguments: {
|
||||
"lockId": state.keyInfos.value.lockId,
|
||||
Get.toNamed(Routers.msgNotificationPage, arguments: <String, int?>{
|
||||
'lockId': state.keyInfos.value.lockId,
|
||||
});
|
||||
}),
|
||||
);
|
||||
@ -1114,9 +1116,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
bottomItem('images/main/icon_main_set.png',
|
||||
TranslationLoader.lanKeys!.set!.tr, true, () {
|
||||
// logic.clickItemBtnAction(10);
|
||||
Get.toNamed(Routers.lockSetPage, arguments: {
|
||||
"lockId": state.keyInfos.value.lockId,
|
||||
"isOnlyOneData": state.isOnlyOneData,
|
||||
Get.toNamed(Routers.lockSetPage, arguments: <String, Object?>{
|
||||
'lockId': state.keyInfos.value.lockId,
|
||||
'isOnlyOneData': state.isOnlyOneData,
|
||||
});
|
||||
}),
|
||||
);
|
||||
@ -1126,12 +1128,12 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
|
||||
Widget bottomItem(
|
||||
String iconUrl, String name, bool bottomBtnisEable, Function() onClick) {
|
||||
Widget child = F.sw(
|
||||
final Widget child = F.sw(
|
||||
defaultCall: () => Container(
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 42.w,
|
||||
height: 42.h,
|
||||
@ -1164,7 +1166,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
padding: EdgeInsets.symmetric(vertical: 15.h, horizontal: 15.w),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 42.w,
|
||||
height: 42.h,
|
||||
@ -1195,19 +1197,19 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
onTap: bottomBtnisEable
|
||||
? onClick
|
||||
: () {
|
||||
logic.showToast("请在锁旁边完成第一次开锁".tr);
|
||||
logic.showToast('请在锁旁边完成第一次开锁'.tr);
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
listeningAnimations() async {
|
||||
await Future.delayed(Duration.zero, () {
|
||||
Future<void> listeningAnimations() async {
|
||||
await Future<void>.delayed(Duration.zero, () {
|
||||
state.animationController = AnimationController(
|
||||
duration: const Duration(seconds: 1), vsync: this);
|
||||
state.animationController!.repeat();
|
||||
//动画开始、结束、向前移动或向后移动时会调用StatusListener
|
||||
state.animationController!.addStatusListener((status) {
|
||||
state.animationController!.addStatusListener((AnimationStatus status) {
|
||||
if (status == AnimationStatus.completed) {
|
||||
state.animationController!.reset();
|
||||
state.animationController!.forward();
|
||||
@ -1237,7 +1239,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
Widget _unlockSuccessWidget() {
|
||||
return Center(
|
||||
child: Stack(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
state.iSOpenLock.value == true
|
||||
? 'images/main/unlocked_bg.png'
|
||||
@ -1247,10 +1249,11 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
),
|
||||
Positioned(
|
||||
top: 180.h,
|
||||
left: 55.w,
|
||||
width: 358.w,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
state.keyInfos.value.lockAlias!,
|
||||
style: TextStyle(
|
||||
@ -1289,9 +1292,9 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
|
||||
String getCurrentFormattedTime() {
|
||||
// 获取当前时间
|
||||
DateTime now = DateTime.now();
|
||||
final DateTime now = DateTime.now();
|
||||
// 格式化日期和时间
|
||||
String formattedTime = DateFormat('MM/dd HH:mm').format(now);
|
||||
final String formattedTime = DateFormat('MM/dd HH:mm').format(now);
|
||||
return formattedTime;
|
||||
}
|
||||
|
||||
@ -1303,65 +1306,57 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
DateTool().compareTimeIsOvertime(state.nextAuthTime.value) == true) {
|
||||
AliyunRealNameAuthProvider(
|
||||
getLockInfo: state.keyInfos.value,
|
||||
onCertifyResultWithTime: ((bool isSuccess, int getNextAuthTime) {
|
||||
onCertifyResultWithTime: (bool isSuccess, int getNextAuthTime) {
|
||||
state.nextAuthTime.value = getNextAuthTime;
|
||||
if (isSuccess) {
|
||||
// 认证成功,去开锁
|
||||
setState(() {
|
||||
startOpenLock();
|
||||
});
|
||||
setState(startOpenLock);
|
||||
}
|
||||
})).initAliyunRealNameAuth();
|
||||
}).initAliyunRealNameAuth();
|
||||
} else {
|
||||
//无需认证,直接开锁
|
||||
setState(() {
|
||||
startOpenLock();
|
||||
});
|
||||
setState(startOpenLock);
|
||||
}
|
||||
}
|
||||
|
||||
startOpenLock() {
|
||||
void startOpenLock() {
|
||||
if (state.openLockBtnState.value == 1) {
|
||||
return;
|
||||
}
|
||||
state.iSOpenLock.value = true;
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
state.openLockBtnState.value = 1;
|
||||
state.animationController!.forward();
|
||||
|
||||
AppLog.log("点击开锁");
|
||||
AppLog.log('点击开锁');
|
||||
if (state.isOpenLockNeedOnline.value == 0) {
|
||||
// 不需要联网
|
||||
state.openDoorModel = 0;
|
||||
AppLog.log("点击开锁 state.openDoorModel = 0 不需要联网");
|
||||
AppLog.log('点击开锁 state.openDoorModel = 0 不需要联网');
|
||||
logic.openDoorAction();
|
||||
} else {
|
||||
// 需要联网
|
||||
state.openDoorModel = 2;
|
||||
AppLog.log("点击开锁 state.openDoorModel = 2 需要联网");
|
||||
AppLog.log('点击开锁 state.openDoorModel = 2 需要联网');
|
||||
logic.getLockNetToken();
|
||||
}
|
||||
}
|
||||
|
||||
startUnLock() {
|
||||
void startUnLock() {
|
||||
if (state.openLockBtnState.value == 1) {
|
||||
return;
|
||||
}
|
||||
state.iSOpenLock.value = false;
|
||||
state.iSClosedUnlockSuccessfulPopup.value = false;
|
||||
state.openLockBtnState.value = 1;
|
||||
state.animationController!.forward();
|
||||
|
||||
EasyLoading.showToast("正在尝试闭锁……".tr, duration: 2000.milliseconds);
|
||||
AppLog.log("长按闭锁");
|
||||
EasyLoading.showToast('正在尝试闭锁……'.tr, duration: 2000.milliseconds);
|
||||
AppLog.log('长按闭锁');
|
||||
if (state.isOpenLockNeedOnline.value == 0) {
|
||||
// 不需要联网
|
||||
AppLog.log("长按闭锁 state.openDoorModel = 32 不需要联网");
|
||||
AppLog.log('长按闭锁 state.openDoorModel = 32 不需要联网');
|
||||
state.openDoorModel = 32;
|
||||
logic.openDoorAction();
|
||||
} else {
|
||||
// 需要联网
|
||||
AppLog.log("长按闭锁 state.openDoorModel = 34 需要联网");
|
||||
AppLog.log('长按闭锁 state.openDoorModel = 34 需要联网');
|
||||
state.openDoorModel = 34;
|
||||
logic.getLockNetToken();
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ class LockOperatingRecordLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async {
|
||||
if (connectionStateState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_protocol/io_setSupportFunctionsWithParameters.dart';
|
||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../blue/io_reply.dart';
|
||||
@ -15,47 +16,50 @@ import '../../../../tools/eventBusEventManage.dart';
|
||||
import '../../../../tools/storage.dart';
|
||||
import 'automaticBlocking_state.dart';
|
||||
|
||||
class AutomaticBlockingLogic extends BaseGetXController{
|
||||
class AutomaticBlockingLogic extends BaseGetXController {
|
||||
final AutomaticBlockingState state = AutomaticBlockingState();
|
||||
|
||||
void setAutoUnLock() async{
|
||||
Future<void> setAutoUnLock() async {
|
||||
String autoTime;
|
||||
if(state.isOpen.value == false){
|
||||
autoTime = "0";
|
||||
}else{
|
||||
if(state.isCustomLockTime.value == true){
|
||||
if (state.isOpen.value == false) {
|
||||
autoTime = '0';
|
||||
} else {
|
||||
if (state.isCustomLockTime.value == true) {
|
||||
autoTime = state.timeController.text;
|
||||
if(int.parse(autoTime) >= 1000){
|
||||
showToast("请输入小于1000的数字".tr);
|
||||
if (int.parse(autoTime) > 60) {
|
||||
showToast('请输入小于或等于60的数字'.tr);
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
autoTime = state.autoLockTime.value;
|
||||
}
|
||||
}
|
||||
|
||||
var entity = await ApiRepository.to.setAutoUnlock(
|
||||
lockId: state.lockSetInfoData.value.lockId!,
|
||||
autoLock:state.isOpen.value == true ? 1 : 0,
|
||||
autoLockSecond: int.parse(autoTime),
|
||||
final LoginEntity entity = await ApiRepository.to.setAutoUnlock(
|
||||
lockId: state.lockSetInfoData.value.lockId!,
|
||||
autoLock: state.isOpen.value == true ? 1 : 0,
|
||||
autoLockSecond: int.parse(autoTime),
|
||||
);
|
||||
if(entity.errorCode!.codeIsSuccessful){
|
||||
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.autoLockTime.value = autoTime;
|
||||
state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond = int.parse(state.autoLockTime.value);
|
||||
showToast("操作成功".tr, something: (){
|
||||
state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond =
|
||||
int.parse(state.autoLockTime.value);
|
||||
showToast('操作成功'.tr, something: () {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
eventBus
|
||||
.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value));
|
||||
Get.back();
|
||||
});
|
||||
}, maskType: EasyLoadingMaskType.clear);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取解析后的数据
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
|
||||
if(reply is SetSupportFunctionsWithParametersReply) {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) {
|
||||
if (reply is SetSupportFunctionsWithParametersReply) {
|
||||
_replySetSupportFunctionsWithParameters(reply);
|
||||
}
|
||||
|
||||
@ -86,10 +90,10 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
|
||||
// 设置自动落锁数据解析
|
||||
Future<void> _replySetSupportFunctionsWithParameters(Reply reply) async {
|
||||
int status = reply.data[2];
|
||||
switch(status){
|
||||
final int status = reply.data[2];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
//成功
|
||||
state.sureBtnState.value = 0;
|
||||
cancelBlueConnetctToastTimer();
|
||||
dismissEasyLoading();
|
||||
@ -106,34 +110,39 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendAutoLock() async {
|
||||
if(state.sureBtnState.value == 1){
|
||||
if (state.sureBtnState.value == 1) {
|
||||
return;
|
||||
}
|
||||
state.sureBtnState.value = 1;
|
||||
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
final List<String>? privateKey =
|
||||
await Storage.getStringList(saveBluePrivateKey);
|
||||
final List<int> getPrivateKeyList =
|
||||
changeStringListToIntList(privateKey!);
|
||||
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||
final List<String>? publicKey =
|
||||
await Storage.getStringList(saveBluePublicKey);
|
||||
final List<int> getPublicKeyList =
|
||||
changeStringListToIntList(publicKey!);
|
||||
|
||||
String autoTime;
|
||||
if(state.isOpen.value == false){
|
||||
autoTime = "0";
|
||||
}else{
|
||||
if(state.isCustomLockTime.value == true){
|
||||
if (state.isOpen.value == false) {
|
||||
autoTime = '0';
|
||||
} else {
|
||||
if (state.isCustomLockTime.value == true) {
|
||||
autoTime = state.timeController.text;
|
||||
}else{
|
||||
} else {
|
||||
autoTime = state.autoLockTime.value;
|
||||
}
|
||||
}
|
||||
@ -142,7 +151,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
userID: await Storage.getUid(),
|
||||
featureBit: 29,
|
||||
featureParaLength: 2,
|
||||
featureData: [int.parse(autoTime)],
|
||||
featureData: <int>[int.parse(autoTime)],
|
||||
token: getTokenList,
|
||||
needAuthor: 1,
|
||||
publicKey: getPublicKeyList,
|
||||
@ -151,7 +160,7 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
state.sureBtnState.value = 0;
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showBlueConnetctToast();
|
||||
}
|
||||
}
|
||||
@ -159,36 +168,42 @@ class AutomaticBlockingLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
void ifCanNext() {
|
||||
if(((state.isOpen.value != (state.lockSetInfoData.value.lockSettingInfo!.autoLock! == 1 ? true : false)) &&
|
||||
(state.autoLockTime.value != state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond!.toString()) &&
|
||||
(state.isJustForShow.value == false)) || ((state.isOpen.value = true) && (state.lockSetInfoData.value.lockSettingInfo!.autoLock! == 1) &&
|
||||
(state.autoLockTime.value != state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond!.toString()) &&
|
||||
(state.isJustForShow.value == false))){
|
||||
final int autoLock = state.lockSetInfoData.value.lockSettingInfo!.autoLock!;
|
||||
final String autoLockSecond =
|
||||
state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond!.toString();
|
||||
final bool openLock = autoLock == 1;
|
||||
final bool isNotJustForShow = state.isJustForShow.value == false;
|
||||
final bool isEditAutoLockSecond =
|
||||
state.autoLockTime.value != autoLockSecond;
|
||||
|
||||
if (!isNotJustForShow) {
|
||||
//普通用户
|
||||
state.canNext.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.isOpen.value != openLock || isEditAutoLockSecond) {
|
||||
state.canNext.value = true;
|
||||
}else{
|
||||
} else {
|
||||
state.canNext.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
Storage.getAutomaticLockOffTime()
|
||||
.then((String value) => state.timeController.text = value);
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
|
||||
// _readSupportFunctionsWithParameters();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
@ -4,9 +4,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/lockSet/automaticBlocking/automaticBlocking_state.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
|
||||
import '../../../../app_settings/app_colors.dart';
|
||||
import '../../../../blue/blue_manage.dart';
|
||||
import '../../../../tools/appRouteObserver.dart';
|
||||
import '../../../../tools/commonItem.dart';
|
||||
import '../../../../tools/showBottomSheetTool.dart';
|
||||
@ -22,9 +23,10 @@ class AutomaticBlockingPage extends StatefulWidget {
|
||||
State<AutomaticBlockingPage> createState() => _AutomaticBlockingPageState();
|
||||
}
|
||||
|
||||
class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> with RouteAware {
|
||||
final logic = Get.put(AutomaticBlockingLogic());
|
||||
final state = Get.find<AutomaticBlockingLogic>().state;
|
||||
class _AutomaticBlockingPageState extends State<AutomaticBlockingPage>
|
||||
with RouteAware {
|
||||
final AutomaticBlockingLogic logic = Get.put(AutomaticBlockingLogic());
|
||||
final AutomaticBlockingState state = Get.find<AutomaticBlockingLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -33,85 +35,90 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> with Rout
|
||||
appBar: TitleAppBar(
|
||||
barTitle: TranslationLoader.lanKeys!.automaticBlocking!.tr,
|
||||
haveBack: true,
|
||||
actionsList: [
|
||||
actionsList: <Widget>[
|
||||
Obx(() => TextButton(
|
||||
onPressed: state.canNext.value == false ? null :() {
|
||||
// if(state.isJustForShow.value == true){
|
||||
// return;
|
||||
// }
|
||||
// if(state.isCustomLockTime.value == true && state.timeController.text.isEmpty){
|
||||
// logic.showToast("请输入自定义时间");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(state.isOpen.value == false){
|
||||
ShowTipView().showIosTipWithContentDialog('关闭后,智能锁将设置为全天常开模式,直到手动关闭'.tr, (){
|
||||
logic.sendAutoLock();
|
||||
});
|
||||
}else{
|
||||
logic.sendAutoLock();
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
state.canNext.value == false ? "" : TranslationLoader.lanKeys!.save!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
)),
|
||||
onPressed: state.canNext.value == false
|
||||
? null
|
||||
: () {
|
||||
if (state.isOpen.value == false) {
|
||||
ShowTipView().showIosTipWithContentDialog(
|
||||
'关闭后,智能锁将设置为全天常开模式,直到手动关闭'.tr,
|
||||
logic.sendAutoLock);
|
||||
} else {
|
||||
logic.sendAutoLock();
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
state.canNext.value == false
|
||||
? ''
|
||||
: TranslationLoader.lanKeys!.save!.tr,
|
||||
style: TextStyle(color: Colors.white, fontSize: 24.sp),
|
||||
),
|
||||
)),
|
||||
],
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: ListView(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.automaticBlocking!.tr,
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, height: 50.h, child: _switch())),),
|
||||
children: <Widget>[
|
||||
Obx(
|
||||
() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.automaticBlocking!.tr,
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget:
|
||||
SizedBox(width: 60.w, height: 50.h, child: _switch())),
|
||||
),
|
||||
Visibility(
|
||||
visible: state.isOpen.value == true ? true : false,
|
||||
visible: state.isOpen.value == true,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(height: 10.h,),
|
||||
Builder(builder: (context) {
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 10.h,
|
||||
),
|
||||
Builder(builder: (BuildContext context) {
|
||||
return Obx(() => CommonItem(
|
||||
leftTitel: TranslationLoader.lanKeys!.delayTime!.tr,
|
||||
rightTitle: state.isCustomLockTime.value == true ? "自定义".tr : (state.autoLockTime.value.isNotEmpty && state.autoLockTime.value != "0") ? "${state.autoLockTime}s" : "",
|
||||
rightTitle: state.isCustomLockTime.value == true
|
||||
? '自定义'.tr
|
||||
: (state.autoLockTime.value.isNotEmpty &&
|
||||
state.autoLockTime.value != '0')
|
||||
? '${state.autoLockTime}s'
|
||||
: '',
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
if(state.isJustForShow.value == true){
|
||||
if (state.isJustForShow.value == true) {
|
||||
return;
|
||||
}
|
||||
var list = [
|
||||
"5",
|
||||
"10",
|
||||
"15",
|
||||
"30",
|
||||
"60",
|
||||
final List<String> list = <String>[
|
||||
'5',
|
||||
'10',
|
||||
'15',
|
||||
'30',
|
||||
'60',
|
||||
TranslationLoader.lanKeys!.custom!.tr
|
||||
];
|
||||
ShowBottomSheetTool().showSingleRowPicker(
|
||||
//上下文
|
||||
//上下文
|
||||
context,
|
||||
//默认的索引
|
||||
normalIndex: 0,
|
||||
title: TranslationLoader.lanKeys!.time!.tr,
|
||||
cancelTitle: TranslationLoader.lanKeys!.cancel!.tr,
|
||||
cancelTitle:
|
||||
TranslationLoader.lanKeys!.cancel!.tr,
|
||||
sureTitle: TranslationLoader.lanKeys!.sure!.tr,
|
||||
//要显示的列表
|
||||
//可自定义数据适配器
|
||||
//adapter: PickerAdapter(),
|
||||
data: list,
|
||||
//选择事件的回调
|
||||
clickCallBack: (int index, var str) {
|
||||
if(index != 5){
|
||||
state.isCustomLockTime.value = false;
|
||||
state.autoLockTime.value = str.toString();
|
||||
}else{
|
||||
state.isCustomLockTime.value = true;
|
||||
}
|
||||
logic.ifCanNext();
|
||||
});
|
||||
clickCallBack: (int index, Object str) {
|
||||
if (index != 5) {
|
||||
state.isCustomLockTime.value = false;
|
||||
state.autoLockTime.value = str.toString();
|
||||
Storage.saveAutomaticLockOffTime(str.toString());
|
||||
} else {
|
||||
state.isCustomLockTime.value = true;
|
||||
}
|
||||
logic.ifCanNext();
|
||||
});
|
||||
}));
|
||||
}),
|
||||
Container(height: 10.h),
|
||||
@ -122,37 +129,37 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> with Rout
|
||||
padding: EdgeInsets.only(
|
||||
left: 30.w, top: 10.w, right: 30.w, bottom: 10.w),
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.time!.tr}(S)",
|
||||
'${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.time!.tr}(S)',
|
||||
style: TextStyle(fontSize: 24.sp),
|
||||
),
|
||||
],
|
||||
),
|
||||
Obx(() => TextField(
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.timeController,
|
||||
keyboardType: TextInputType.number,
|
||||
autofocus: false,
|
||||
readOnly: state.isJustForShow.value == true ? true : false,
|
||||
onChanged: (value) {
|
||||
state.autoLockTime.value = value;
|
||||
logic.ifCanNext();
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding:
|
||||
const EdgeInsets.only(top: 12.0, bottom: 8.0),
|
||||
hintText:
|
||||
"${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.time!.tr}(S)",
|
||||
hintStyle: TextStyle(fontSize: 24.sp),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
),
|
||||
)),
|
||||
//输入框一行
|
||||
maxLines: 1,
|
||||
controller: state.timeController,
|
||||
keyboardType: TextInputType.number,
|
||||
autofocus: false,
|
||||
readOnly: state.isJustForShow.value == true,
|
||||
onChanged: (String value) {
|
||||
state.autoLockTime.value = value;
|
||||
logic.ifCanNext();
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
top: 12.0, bottom: 8.0),
|
||||
hintText:
|
||||
'${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.time!.tr}(S)',
|
||||
hintStyle: TextStyle(fontSize: 24.sp),
|
||||
//不需要输入框下划线
|
||||
border: InputBorder.none,
|
||||
),
|
||||
)),
|
||||
Container(
|
||||
height: 0.5.h,
|
||||
color: Colors.grey,
|
||||
@ -167,7 +174,7 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> with Rout
|
||||
padding: EdgeInsets.all(30.w),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text(
|
||||
TranslationLoader.lanKeys!.automaticBlockingTip!.tr,
|
||||
@ -186,21 +193,19 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> with Rout
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isOpen.value,
|
||||
onChanged: state.isJustForShow.value == true ? null : (value){
|
||||
setState(() {
|
||||
state.isOpen.value = value;
|
||||
if(state.isOpen.value == false){
|
||||
state.autoLockTime.value = "";
|
||||
}
|
||||
logic.ifCanNext();
|
||||
});
|
||||
},
|
||||
onChanged: state.isJustForShow.value == true
|
||||
? null
|
||||
: (bool value) {
|
||||
setState(() {
|
||||
state.isOpen.value = value;
|
||||
logic.ifCanNext();
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
// TODO: implement didChangeDependencies
|
||||
super.didChangeDependencies();
|
||||
|
||||
/// 路由订阅
|
||||
@ -209,7 +214,6 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> with Rout
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
/// 取消路由订阅
|
||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||
super.dispose();
|
||||
@ -227,7 +231,9 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> with Rout
|
||||
void didPop() {
|
||||
super.didPop();
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
if (EasyLoading.isShow) {
|
||||
EasyLoading.dismiss(animation: true);
|
||||
}
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
@ -244,9 +250,10 @@ class _AutomaticBlockingPageState extends State<AutomaticBlockingPage> with Rout
|
||||
void didPushNext() {
|
||||
super.didPushNext();
|
||||
logic.cancelBlueConnetctToastTimer();
|
||||
if (EasyLoading.isShow) EasyLoading.dismiss(animation: true);
|
||||
if (EasyLoading.isShow) {
|
||||
EasyLoading.dismiss(animation: true);
|
||||
}
|
||||
state.ifCurrentScreen.value = false;
|
||||
state.sureBtnState.value = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ class AdminOpenLockPasswordLogic 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<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -50,7 +50,7 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
dismissEasyLoading();
|
||||
|
||||
@ -99,7 +99,7 @@ class BurglarAlarmLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -136,7 +136,7 @@ class ConfiguringWifiLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected){
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -113,7 +113,7 @@ class WifiListLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected){
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
@ -80,7 +80,7 @@ class LockEscalationLogic extends BaseGetXController {
|
||||
|
||||
//蓝牙操作 ota 升级
|
||||
void blueOTAUpgrade(Map data, List<int> token) {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
|
||||
@ -245,7 +245,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
showDeletAlertTipDialog();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -306,7 +306,7 @@ class LockSetLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -103,7 +103,7 @@ class LockSoundSetLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -103,7 +103,7 @@ class LockTimeLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -84,7 +84,7 @@ class MotorPowerLogic extends BaseGetXController {
|
||||
|
||||
// 读取支持功能-带参数
|
||||
Future<void> _readSupportFunctionsNoParameters() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
@ -110,7 +110,7 @@ class MotorPowerLogic extends BaseGetXController {
|
||||
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendOpenDoorDirection() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -120,7 +120,7 @@ class NormallyOpenModeLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -86,7 +86,7 @@ class OpenDoorDirectionLogic extends BaseGetXController {
|
||||
// 设置支持功能(带参数)
|
||||
Future<void> sendOpenDoorDirection() async {
|
||||
showEasyLoading();
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
dismissEasyLoading();
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
|
||||
@ -109,7 +109,7 @@ class RemoteUnlockingLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
|
||||
@ -98,7 +98,7 @@ class ResetButtonLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||
|
||||
@ -289,7 +289,7 @@ class UploadDataLogic extends BaseGetXController{
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
@ -334,7 +334,7 @@ class UploadDataLogic extends BaseGetXController{
|
||||
state.indexCount.value = 0;
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
@ -380,7 +380,7 @@ class UploadDataLogic extends BaseGetXController{
|
||||
state.indexCount.value = 0;
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
@ -426,7 +426,7 @@ class UploadDataLogic extends BaseGetXController{
|
||||
state.indexCount.value = 0;
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
@ -473,7 +473,7 @@ class UploadDataLogic extends BaseGetXController{
|
||||
state.indexCount.value = 0;
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/addFamily/addFamily_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart';
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
@ -13,29 +10,44 @@ class AddFamilyLogic extends BaseGetXController {
|
||||
final AddFamilyState state = AddFamilyState();
|
||||
|
||||
//添加开门通知
|
||||
void addLockNoticeSetting() async {
|
||||
var entity = await ApiRepository.to.addLockNoticeSetting(
|
||||
Future<void> addLockNoticeSetting() async {
|
||||
final Map<String, Object?> settingValue = <String, Object?>{
|
||||
'openDoorId': state.lockUserKeys.value.currentOpenDoorID,
|
||||
'openDoorType': state.lockUserKeys.value.currentKeyType,
|
||||
'remark': state.lockUserKeys.value.currentKeyName ?? '',
|
||||
'noticeWay': getNoticeWayList(),
|
||||
};
|
||||
|
||||
final MsgNotificationEntity entity =
|
||||
await ApiRepository.to.addLockNoticeSetting(
|
||||
lockId: state.getLockId.value,
|
||||
noticeType: 10,
|
||||
settingValue: {
|
||||
'openDoorId': state.lockUserKeys.value.currentOpenDoorID,
|
||||
'openDoorType': state.lockUserKeys.value.currentKeyType,
|
||||
'remark': state.lockUserKeys.value.currentKeyName ?? '',
|
||||
'noticeWay': [
|
||||
{'type': 'mail', 'accounts': getEmailAndSMSAccountList(true)},
|
||||
{'type': 'sms', 'accounts': getEmailAndSMSAccountList(false)}
|
||||
]
|
||||
},
|
||||
settingValue: settingValue,
|
||||
);
|
||||
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast('添加成功'.tr);
|
||||
Get.back(result: true);
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, Object>> getNoticeWayList() {
|
||||
return <Map<String, Object>>[
|
||||
<String, Object>{
|
||||
'type': 'mail',
|
||||
'accounts': getEmailAndSMSAccountList(true)
|
||||
},
|
||||
<String, Object>{
|
||||
'type': 'sms',
|
||||
'accounts': getEmailAndSMSAccountList(false)
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
//更新开门通知
|
||||
void updateLockNoticeSetting() async {
|
||||
var entity = await ApiRepository.to.updateLockNoticeSettingAccount(
|
||||
Future<void> updateLockNoticeSetting() async {
|
||||
final OpenDoorNotifyEntity entity =
|
||||
await ApiRepository.to.updateLockNoticeSettingAccount(
|
||||
lockNoticeSettingAccountId: state.familyData.value.id!,
|
||||
settingValue: {
|
||||
'openDoorId': state.familyData.value.settingValue!.openDoorId!,
|
||||
@ -52,8 +64,9 @@ class AddFamilyLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
//删除开门通知
|
||||
void deleteLockNoticeSetting() async {
|
||||
var entity = await ApiRepository.to.deleteLockNoticeSettingAccount(
|
||||
Future<void> deleteLockNoticeSetting() async {
|
||||
final OpenDoorNotifyEntity entity =
|
||||
await ApiRepository.to.deleteLockNoticeSettingAccount(
|
||||
lockNoticeSettingAccountId: state.familyData.value.id!,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
@ -64,14 +77,14 @@ class AddFamilyLogic extends BaseGetXController {
|
||||
|
||||
//获取到家人信息的请求数组
|
||||
List getEmailAndSMSAccountList(bool isEmail) {
|
||||
List list = [];
|
||||
final List list = [];
|
||||
List accountList = [];
|
||||
isEmail
|
||||
? accountList = state.emailReceiverList.value
|
||||
: accountList = state.phoneReceiverList.value;
|
||||
for (int i = 0; i < accountList.length; i++) {
|
||||
MsgNoticeModeData item = accountList[i];
|
||||
Map map = {};
|
||||
final MsgNoticeModeData item = accountList[i];
|
||||
final Map map = {};
|
||||
map['countryCode'] = isEmail ? 0 : item.countryCode;
|
||||
map['account'] = isEmail ? item.receiveEmail : item.receivePhone;
|
||||
list.add(map);
|
||||
@ -83,9 +96,9 @@ class AddFamilyLogic extends BaseGetXController {
|
||||
String emailListStr = '';
|
||||
if (val['emailReceiverList'] != null) {
|
||||
state.emailReceiverList.value = val['emailReceiverList'];
|
||||
List emailReceiverList = state.emailReceiverList.value;
|
||||
final List emailReceiverList = state.emailReceiverList.value;
|
||||
for (int i = 0; i < emailReceiverList.length; i++) {
|
||||
MsgNoticeModeData item = emailReceiverList[i];
|
||||
final MsgNoticeModeData item = emailReceiverList[i];
|
||||
emailListStr += item.receiveEmail;
|
||||
// 检查是否为最后一个元素
|
||||
if (i < emailReceiverList.length - 1) {
|
||||
@ -101,9 +114,9 @@ class AddFamilyLogic extends BaseGetXController {
|
||||
|
||||
if (val['phoneReceiverList'] != null) {
|
||||
state.phoneReceiverList.value = val['phoneReceiverList'];
|
||||
List phoneReceiverList = state.phoneReceiverList.value;
|
||||
final List phoneReceiverList = state.phoneReceiverList.value;
|
||||
for (int i = 0; i < phoneReceiverList.length; i++) {
|
||||
MsgNoticeModeData item = phoneReceiverList[i];
|
||||
final MsgNoticeModeData item = phoneReceiverList[i];
|
||||
phoneListStr += item.receivePhone;
|
||||
// 检查是否为最后一个元素
|
||||
if (i < phoneReceiverList.length - 1) {
|
||||
@ -116,19 +129,19 @@ class AddFamilyLogic extends BaseGetXController {
|
||||
|
||||
//检查按钮是否可用
|
||||
bool checkBtnDisable() {
|
||||
if ((state.emailListStr.value.isEmpty ||
|
||||
state.phontListStr.value.isEmpty) ||
|
||||
state.lockUserKeys.value.currentKeyTypeStr!.isEmpty ||
|
||||
state.lockUserKeys.value.currentKeyName!.isEmpty) {
|
||||
final String? keyTypeStr = state.lockUserKeys.value.currentKeyTypeStr;
|
||||
final String? keyName = state.lockUserKeys.value.currentKeyName;
|
||||
|
||||
if (keyTypeStr == null || keyName == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
return keyTypeStr.isNotEmpty && keyName.isNotEmpty;
|
||||
}
|
||||
|
||||
//当前钥匙类型 1:电子钥匙 2:密码钥匙 3:指纹钥匙 4:卡钥匙 5:人脸钥匙
|
||||
String getKeyTypeStr() {
|
||||
int keyType = state.familyData.value.settingValue!.openDoorType!;
|
||||
final int keyType = state.familyData.value.settingValue!.openDoorType!;
|
||||
switch (keyType) {
|
||||
case 1:
|
||||
return '电子钥匙';
|
||||
@ -147,34 +160,32 @@ class AddFamilyLogic extends BaseGetXController {
|
||||
|
||||
//根据列表返回值得到邮箱、手机列表
|
||||
Map<String, List<MsgNoticeModeData>> getAccountsMap() {
|
||||
List<MsgNoticeModeData> mailAccounts = [];
|
||||
List<MsgNoticeModeData> smsAccounts = [];
|
||||
final List<MsgNoticeModeData> mailAccounts = <MsgNoticeModeData>[];
|
||||
final List<MsgNoticeModeData> smsAccounts = <MsgNoticeModeData>[];
|
||||
|
||||
if (state.familyData.value.settingValue != null) {
|
||||
for (NoticeWay item
|
||||
in state.familyData.value.settingValue!.noticeWayList!) {
|
||||
if (item.type == 'mail' && item.accounts != null) {
|
||||
for (Accounts account in item.accounts!) {
|
||||
if (account.account != null) {
|
||||
MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData();
|
||||
msgNoticeModeData.receiveEmail = account.account!;
|
||||
mailAccounts.add(msgNoticeModeData);
|
||||
}
|
||||
state.familyData.value.settingValue?.noticeWayList
|
||||
?.forEach((NoticeWay item) {
|
||||
if (item.type == 'mail') {
|
||||
item.accounts?.forEach((Accounts account) {
|
||||
if (account.account != null) {
|
||||
final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData();
|
||||
msgNoticeModeData.receiveEmail = account.account!;
|
||||
mailAccounts.add(msgNoticeModeData);
|
||||
}
|
||||
} else if (item.type == 'sms' && item.accounts != null) {
|
||||
for (Accounts account in item.accounts!) {
|
||||
if (account.account != null && account.countryCode != null) {
|
||||
MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData();
|
||||
msgNoticeModeData.receivePhone = account.account!;
|
||||
msgNoticeModeData.countryCode = account.countryCode!;
|
||||
smsAccounts.add(msgNoticeModeData);
|
||||
}
|
||||
});
|
||||
} else if (item.type == 'sms') {
|
||||
item.accounts?.forEach((Accounts account) {
|
||||
if (account.account != null && account.countryCode != null) {
|
||||
final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData();
|
||||
msgNoticeModeData.receivePhone = account.account!;
|
||||
msgNoticeModeData.countryCode = account.countryCode!;
|
||||
smsAccounts.add(msgNoticeModeData);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
return <String, List<MsgNoticeModeData>>{
|
||||
'emailReceiverList': mailAccounts,
|
||||
'phoneReceiverList': smsAccounts,
|
||||
};
|
||||
|
||||
@ -4,8 +4,10 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/addFamily/addFamily_logic.dart';
|
||||
import 'package:star_lock/tools/showCupertinoAlertView.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/addFamily/addFamily_state.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart';
|
||||
import 'package:star_lock/tools/commonItem.dart';
|
||||
import 'package:star_lock/tools/showCupertinoAlertView.dart';
|
||||
import 'package:star_lock/tools/showTFView.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
@ -22,8 +24,8 @@ class AddFamilyPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AddFamilyPageState extends State<AddFamilyPage> {
|
||||
final logic = Get.put(AddFamilyLogic());
|
||||
final state = Get.find<AddFamilyLogic>().state;
|
||||
final AddFamilyLogic logic = Get.put(AddFamilyLogic());
|
||||
final AddFamilyState state = Get.find<AddFamilyLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -36,7 +38,7 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(30.w),
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: '开门方式'.tr,
|
||||
rightTitle: state.isDetail.value
|
||||
@ -46,9 +48,9 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
//锁用户
|
||||
Get.toNamed(Routers.lockUserPage,
|
||||
arguments: {'getLockId': state.getLockId.value})
|
||||
?.then((val) {
|
||||
Get.toNamed(Routers.lockUserPage, arguments: <String, int>{
|
||||
'getLockId': state.getLockId.value
|
||||
})?.then((val) {
|
||||
if (val != null) {
|
||||
state.lockUserKeys.value = val;
|
||||
}
|
||||
@ -73,8 +75,9 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(Routers.notificationModePage,
|
||||
arguments: {'familyData': state.familyData.value})
|
||||
?.then((val) {
|
||||
arguments: <String, DataList>{
|
||||
'familyData': state.familyData.value
|
||||
})?.then((val) {
|
||||
if (val != null) {
|
||||
state.emailListStr.value = logic.getEmailListStr(val);
|
||||
state.phontListStr.value = logic.getPhoneListStr(val);
|
||||
@ -85,10 +88,10 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
|
||||
color: Colors.white,
|
||||
margin: EdgeInsets.only(bottom: 10.h),
|
||||
child: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
CommonItem(
|
||||
leftTitel: '提醒方式'.tr,
|
||||
rightTitle: "",
|
||||
rightTitle: '',
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: false,
|
||||
isHaveDirection: true,
|
||||
@ -117,7 +120,7 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
|
||||
: logic.checkBtnDisable(),
|
||||
isDelete: state.isDetail.value,
|
||||
onClick: () async {
|
||||
var isVip = await Storage.getBool(saveIsVip);
|
||||
final bool? isVip = await Storage.getBool(saveIsVip);
|
||||
if (isVip == true) {
|
||||
if (state.isDetail.value) {
|
||||
logic.deleteLockNoticeSetting();
|
||||
@ -148,7 +151,7 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
|
||||
borderRadius: BorderRadius.circular(6.0.w),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
notifyTitle,
|
||||
style: TextStyle(color: Colors.black, fontSize: 20.sp),
|
||||
@ -173,8 +176,8 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
|
||||
builder: (BuildContext context) {
|
||||
return ShowTFView(
|
||||
title:
|
||||
"${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}",
|
||||
tipTitle: "请输入".tr,
|
||||
'${TranslationLoader.lanKeys!.amend!.tr}${TranslationLoader.lanKeys!.name!.tr}',
|
||||
tipTitle: '请输入'.tr,
|
||||
controller: state.changeNameController,
|
||||
sureClick: () {
|
||||
//发送编辑钥匙名称请求
|
||||
@ -194,13 +197,13 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
|
||||
|
||||
// 接受者信息输入框
|
||||
Widget getFamilyWidget(String tfStr) {
|
||||
TextEditingController emailController = TextEditingController();
|
||||
final TextEditingController emailController = TextEditingController();
|
||||
emailController.text = state.lockUserKeys.value.currentKeyName ?? '';
|
||||
return SizedBox(
|
||||
height: 50.h,
|
||||
width: 360.w,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: emailController,
|
||||
@ -231,7 +234,7 @@ class _AddFamilyPageState extends State<AddFamilyPage> {
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
|
||||
onChanged: (value) {
|
||||
onChanged: (String value) {
|
||||
state.lockUserKeys.value.currentKeyName = value;
|
||||
state.lockUserKeys.refresh();
|
||||
},
|
||||
|
||||
@ -5,9 +5,9 @@ import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNo
|
||||
|
||||
class AddFamilyState {
|
||||
final TextEditingController changeNameController = TextEditingController();
|
||||
var getLockId = 0.obs;
|
||||
var lockUserKeys = LockUserListKeys().obs;
|
||||
var emailReceiverList = [].obs;
|
||||
RxInt getLockId = 0.obs;
|
||||
Rx<LockUserListKeys> lockUserKeys = LockUserListKeys().obs;
|
||||
RxList emailReceiverList = [].obs;
|
||||
var phoneReceiverList = [].obs;
|
||||
var emailListStr = ''.obs;
|
||||
var phontListStr = ''.obs;
|
||||
|
||||
@ -9,8 +9,9 @@ class CoerceFingerprintListLogic extends BaseGetXController {
|
||||
final CoerceFingerprintListState state = CoerceFingerprintListState();
|
||||
|
||||
// 锁用户列表
|
||||
void getCoercedFingerprintList() async {
|
||||
var entity = await ApiRepository.to.getCoercedFingerprintList(
|
||||
Future<void> getCoercedFingerprintList() async {
|
||||
final CoerceFingerprintListEntity entity =
|
||||
await ApiRepository.to.getCoercedFingerprintList(
|
||||
lockId: state.getLockId.value,
|
||||
pageNo: state.pageNum.value,
|
||||
pageSize: state.pageSize.value,
|
||||
@ -24,15 +25,15 @@ class CoerceFingerprintListLogic extends BaseGetXController {
|
||||
//获取指纹有效期
|
||||
String getfingerprintUseDateStr(
|
||||
CoerceFingerprintItemData fingerprintItemData) {
|
||||
var keyDateTypeStr = ""; // 永久:1;限时2,单次3,循环:4
|
||||
var keyDateTypeStr = ''; // 永久:1;限时2,单次3,循环:4
|
||||
if (fingerprintItemData.fingerprintType! == 1) {
|
||||
keyDateTypeStr = "永久".tr;
|
||||
keyDateTypeStr = '永久'.tr;
|
||||
} else if (fingerprintItemData.fingerprintType! == 2) {
|
||||
keyDateTypeStr =
|
||||
"${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时";
|
||||
'${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时';
|
||||
} else if (fingerprintItemData.fingerprintType! == 4) {
|
||||
keyDateTypeStr =
|
||||
"${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环";
|
||||
'${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环';
|
||||
}
|
||||
return keyDateTypeStr;
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_entity.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_state.dart';
|
||||
import 'package:star_lock/tools/keySearchWidget.dart';
|
||||
|
||||
import '../../../../../../app_settings/app_colors.dart';
|
||||
@ -18,8 +19,10 @@ class CoerceFingerprintListPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _CoerceFingerprintListPageState extends State<CoerceFingerprintListPage> {
|
||||
final logic = Get.put(CoerceFingerprintListLogic());
|
||||
final state = Get.find<CoerceFingerprintListLogic>().state;
|
||||
final CoerceFingerprintListLogic logic =
|
||||
Get.put(CoerceFingerprintListLogic());
|
||||
final CoerceFingerprintListState state =
|
||||
Get.find<CoerceFingerprintListLogic>().state;
|
||||
|
||||
@override
|
||||
initState() {
|
||||
@ -37,7 +40,7 @@ class _CoerceFingerprintListPageState extends State<CoerceFingerprintListPage> {
|
||||
backgroundColor: AppColors.mainColor,
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
KeySearchWidget(
|
||||
editingController: state.searchController,
|
||||
onSubmittedAction: () {
|
||||
@ -48,7 +51,7 @@ class _CoerceFingerprintListPageState extends State<CoerceFingerprintListPage> {
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Expanded(child: Obx(() => _buildMainUI())),
|
||||
Expanded(child: Obx(_buildMainUI)),
|
||||
SubmitBtn(
|
||||
btnName: '确定'.tr,
|
||||
onClick: () {
|
||||
@ -68,7 +71,7 @@ class _CoerceFingerprintListPageState extends State<CoerceFingerprintListPage> {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
itemCount: state.fingerprintList.length,
|
||||
itemBuilder: (c, index) {
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
return _electronicKeyItem(state.fingerprintList[index], index);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
@ -85,7 +88,7 @@ class _CoerceFingerprintListPageState extends State<CoerceFingerprintListPage> {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
for (int i = 0; i < state.fingerprintList.value.length; i++) {
|
||||
CoerceFingerprintItemData item = state.fingerprintList.value[i];
|
||||
final CoerceFingerprintItemData item = state.fingerprintList.value[i];
|
||||
if (selectIndex == i) {
|
||||
item.isCurrentSelect = true;
|
||||
} else {
|
||||
@ -100,7 +103,7 @@ class _CoerceFingerprintListPageState extends State<CoerceFingerprintListPage> {
|
||||
color: Colors.white,
|
||||
height: 90.h,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 30.w,
|
||||
),
|
||||
@ -115,9 +118,9 @@ class _CoerceFingerprintListPageState extends State<CoerceFingerprintListPage> {
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
itemData.fingerprintName ?? '',
|
||||
style: TextStyle(
|
||||
@ -133,7 +136,7 @@ class _CoerceFingerprintListPageState extends State<CoerceFingerprintListPage> {
|
||||
SizedBox(height: 10.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
logic.getfingerprintUseDateStr(itemData),
|
||||
style: TextStyle(
|
||||
|
||||
@ -9,12 +9,13 @@ import 'nDaysUnopened_state.dart';
|
||||
class NDaysUnopenedLogic extends BaseGetXController {
|
||||
NDaysUnopenedState state = NDaysUnopenedState();
|
||||
|
||||
void lockNoticeSettingAccountList() async {
|
||||
var entity = await ApiRepository.to.updateNdaysNotCloseDoorNoticeSetting(
|
||||
lockId: state.getLockId.value,
|
||||
dayNotOpenDoorState: state.isUnOpenNotice.value == true ? 1 : 0,
|
||||
dayNotOpenDoorValue: state.unOpenDoorTime.value,
|
||||
dayNotOpenDoorNoticeWayList: [
|
||||
Future<void> lockNoticeSettingAccountList() async {
|
||||
final OpenDoorNotifyEntity entity = await ApiRepository.to
|
||||
.updateNdaysNotCloseDoorNoticeSetting(
|
||||
lockId: state.getLockId.value,
|
||||
dayNotOpenDoorState: state.isUnOpenNotice.value == true ? 1 : 0,
|
||||
dayNotOpenDoorValue: state.unOpenDoorTime.value,
|
||||
dayNotOpenDoorNoticeWayList: [
|
||||
{'type': 'mail', 'accounts': getEmailAndSMSAccountList(true)},
|
||||
{'type': 'sms', 'accounts': getEmailAndSMSAccountList(false)}
|
||||
]);
|
||||
@ -26,14 +27,14 @@ class NDaysUnopenedLogic extends BaseGetXController {
|
||||
|
||||
//获取到家人信息的请求数组
|
||||
List getEmailAndSMSAccountList(bool isEmail) {
|
||||
List list = [];
|
||||
final List list = [];
|
||||
List accountList = [];
|
||||
isEmail
|
||||
? accountList = state.emailReceiverList.value
|
||||
: accountList = state.phoneReceiverList.value;
|
||||
for (int i = 0; i < accountList.length; i++) {
|
||||
MsgNoticeModeData item = accountList[i];
|
||||
Map map = {};
|
||||
final MsgNoticeModeData item = accountList[i];
|
||||
final Map map = {};
|
||||
map['countryCode'] = isEmail ? 0 : item.countryCode;
|
||||
map['account'] = isEmail ? item.receiveEmail : item.receivePhone;
|
||||
list.add(map);
|
||||
@ -45,9 +46,9 @@ class NDaysUnopenedLogic extends BaseGetXController {
|
||||
String emailListStr = '';
|
||||
if (val['emailReceiverList'] != null) {
|
||||
state.emailReceiverList.value = val['emailReceiverList'];
|
||||
List emailReceiverList = state.emailReceiverList.value;
|
||||
final List emailReceiverList = state.emailReceiverList.value;
|
||||
for (int i = 0; i < emailReceiverList.length; i++) {
|
||||
MsgNoticeModeData item = emailReceiverList[i];
|
||||
final MsgNoticeModeData item = emailReceiverList[i];
|
||||
emailListStr += item.receiveEmail;
|
||||
// 检查是否为最后一个元素
|
||||
if (i < emailReceiverList.length - 1) {
|
||||
@ -63,9 +64,9 @@ class NDaysUnopenedLogic extends BaseGetXController {
|
||||
|
||||
if (val['phoneReceiverList'] != null) {
|
||||
state.phoneReceiverList.value = val['phoneReceiverList'];
|
||||
List phoneReceiverList = state.phoneReceiverList.value;
|
||||
final List phoneReceiverList = state.phoneReceiverList.value;
|
||||
for (int i = 0; i < phoneReceiverList.length; i++) {
|
||||
MsgNoticeModeData item = phoneReceiverList[i];
|
||||
final MsgNoticeModeData item = phoneReceiverList[i];
|
||||
phoneListStr += item.receivePhone;
|
||||
// 检查是否为最后一个元素
|
||||
if (i < phoneReceiverList.length - 1) {
|
||||
@ -78,24 +79,24 @@ class NDaysUnopenedLogic extends BaseGetXController {
|
||||
|
||||
//根据列表返回值得到邮箱、手机列表
|
||||
Map<String, List<MsgNoticeModeData>> getAccountsMap() {
|
||||
List<MsgNoticeModeData> mailAccounts = [];
|
||||
List<MsgNoticeModeData> smsAccounts = [];
|
||||
final List<MsgNoticeModeData> mailAccounts = [];
|
||||
final List<MsgNoticeModeData> smsAccounts = [];
|
||||
|
||||
if (state.msgNoticeInfo.value.dayNotOpenDoorNoticeWayList != null) {
|
||||
for (NoticeWay item
|
||||
for (final NoticeWay item
|
||||
in state.msgNoticeInfo.value.dayNotOpenDoorNoticeWayList!) {
|
||||
if (item.type == 'mail' && item.accounts != null) {
|
||||
for (Accounts account in item.accounts!) {
|
||||
for (final Accounts account in item.accounts!) {
|
||||
if (account.account != null) {
|
||||
MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData();
|
||||
final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData();
|
||||
msgNoticeModeData.receiveEmail = account.account!;
|
||||
mailAccounts.add(msgNoticeModeData);
|
||||
}
|
||||
}
|
||||
} else if (item.type == 'sms' && item.accounts != null) {
|
||||
for (Accounts account in item.accounts!) {
|
||||
for (final Accounts account in item.accounts!) {
|
||||
if (account.account != null && account.countryCode != null) {
|
||||
MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData();
|
||||
final MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData();
|
||||
msgNoticeModeData.receivePhone = account.account!;
|
||||
msgNoticeModeData.countryCode = account.countryCode!;
|
||||
smsAccounts.add(msgNoticeModeData);
|
||||
|
||||
@ -3,11 +3,13 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.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/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart';
|
||||
import 'package:star_lock/tools/showCupertinoAlertView.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart';
|
||||
import 'package:star_lock/tools/commonItem.dart';
|
||||
import 'package:star_lock/tools/pickers/pickers.dart';
|
||||
import 'package:star_lock/tools/pickers/style/default_style.dart';
|
||||
import 'package:star_lock/tools/showCupertinoAlertView.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
|
||||
@ -23,147 +25,138 @@ class NDaysUnopenedPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _NDaysUnopenedPageState extends State<NDaysUnopenedPage> {
|
||||
final logic = Get.put(NDaysUnopenedLogic());
|
||||
final state = Get.find<NDaysUnopenedLogic>().state;
|
||||
final NDaysUnopenedLogic logic = Get.put(NDaysUnopenedLogic());
|
||||
final NDaysUnopenedState state = Get.find<NDaysUnopenedLogic>().state;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.mainBackgroundColor,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: 'N天未开门'.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: ListView(
|
||||
barTitle: 'N天未开门'.tr,
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.all(30.w),
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text(
|
||||
"经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网".tr,
|
||||
style: TextStyle(
|
||||
fontSize: 20.sp, color: AppColors.darkGrayTextColor),
|
||||
)),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
CommonItem(
|
||||
'经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 20.sp, color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 20.h),
|
||||
CommonItem(
|
||||
leftTitel: 'N天未开门提醒'.tr,
|
||||
rightTitle: '',
|
||||
isHaveLine: true,
|
||||
isHaveDirection: false,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: _unOpenDoorSwitch(),
|
||||
action: () {}),
|
||||
_buildOpenNoticeWidget(),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 20.h,
|
||||
)),
|
||||
SubmitBtn(
|
||||
btnName: '保存'.tr,
|
||||
onClick: () async {
|
||||
var isVip = await Storage.getBool(saveIsVip);
|
||||
if (isVip == false) {
|
||||
ShowCupertinoAlertView().advancedFeatureAlert();
|
||||
} else {
|
||||
logic.lockNoticeSettingAccountList();
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 60.h,
|
||||
)
|
||||
],
|
||||
rightWidget: Obx(_unOpenDoorSwitch),
|
||||
),
|
||||
Obx(_buildOpenNoticeWidget),
|
||||
Expanded(child: Container()),
|
||||
SubmitBtn(
|
||||
btnName: '保存'.tr,
|
||||
onClick: () async {
|
||||
final bool? isVip = await Storage.getBool(saveIsVip);
|
||||
if (isVip == false) {
|
||||
ShowCupertinoAlertView().advancedFeatureAlert();
|
||||
} else {
|
||||
logic.lockNoticeSettingAccountList();
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(height: 60.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildOpenNoticeWidget() {
|
||||
return Visibility(
|
||||
visible: state.isUnOpenNotice.value,
|
||||
child: Column(
|
||||
children: [
|
||||
Obx(() => CommonItem(
|
||||
leftTitel: '门未开时间'.tr,
|
||||
rightTitle: '${state.unOpenDoorTime.value}${'天'.tr}',
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
_openBottomItemSheet(context, state.unopenDoorTimeList);
|
||||
},
|
||||
)),
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(Routers.notificationModePage,
|
||||
arguments: {'msgNoticeInfo': state.msgNoticeInfo.value})
|
||||
?.then((val) {
|
||||
if (val != null) {
|
||||
state.emailListStr.value = logic.getEmailListStr(val);
|
||||
state.phontListStr.value = logic.getPhoneListStr(val);
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
margin: EdgeInsets.only(bottom: 10.h),
|
||||
child: Column(
|
||||
children: [
|
||||
CommonItem(
|
||||
leftTitel: '提醒方式'.tr,
|
||||
rightTitle: "",
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: false,
|
||||
isHaveDirection: true,
|
||||
),
|
||||
_buildNotifyContain('APP推送'.tr, '管理员'.tr),
|
||||
Obx(() => state.emailListStr.value.isNotEmpty
|
||||
? _buildNotifyContain(
|
||||
'邮件提醒'.tr, state.emailListStr.value)
|
||||
: Container()),
|
||||
Obx(() => state.phontListStr.value.isNotEmpty
|
||||
? _buildNotifyContain(
|
||||
'短信提醒'.tr, state.phontListStr.value)
|
||||
: Container()),
|
||||
],
|
||||
),
|
||||
visible: state.isUnOpenNotice.value,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
CommonItem(
|
||||
leftTitel: '门未开时间'.tr,
|
||||
rightTitle: '${state.unOpenDoorTime.value}天',
|
||||
isHaveLine: true,
|
||||
isHaveRightWidget: false,
|
||||
isHaveDirection: true,
|
||||
action: () {
|
||||
_openBottomItemSheet(context, state.unopenDoorTimeList);
|
||||
},
|
||||
),
|
||||
SizedBox(height: 20.h),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(Routers.notificationModePage,
|
||||
arguments: <String, MsgNoticeData>{
|
||||
'msgNoticeInfo': state.msgNoticeInfo.value
|
||||
})?.then((val) {
|
||||
if (val != null) {
|
||||
state.emailListStr.value = logic.getEmailListStr(val);
|
||||
state.phontListStr.value = logic.getPhoneListStr(val);
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
margin: EdgeInsets.only(bottom: 10.h),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
CommonItem(
|
||||
leftTitel: '提醒方式'.tr,
|
||||
rightTitle: '',
|
||||
isHaveLine: false,
|
||||
isHaveRightWidget: false,
|
||||
isHaveDirection: true,
|
||||
),
|
||||
_buildNotifyContain('APP推送'.tr, '管理员'.tr),
|
||||
if (state.emailListStr.value.isNotEmpty)
|
||||
_buildNotifyContain('邮件提醒'.tr, state.emailListStr.value),
|
||||
if (state.phontListStr.value.isNotEmpty)
|
||||
_buildNotifyContain('短信提醒'.tr, state.phontListStr.value),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNotifyContain(String notifyTitle, String notifyContent) {
|
||||
return Container(
|
||||
padding:
|
||||
EdgeInsets.only(left: 10.w, right: 10.w, top: 12.h, bottom: 12.h),
|
||||
margin: EdgeInsets.only(bottom: 20.h, top: 10.h, left: 20.w, right: 20.w),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 12.h),
|
||||
margin: EdgeInsets.symmetric(vertical: 10.h, horizontal: 20.w),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.mainBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(6.0.w),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
notifyTitle,
|
||||
style: TextStyle(color: Colors.black, fontSize: 20.sp),
|
||||
),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
width: 20.w,
|
||||
)),
|
||||
Text(notifyContent,
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
color: AppColors.placeholderTextColor, fontSize: 20.sp)),
|
||||
Expanded(child: Container()),
|
||||
Text(
|
||||
notifyContent,
|
||||
textAlign: TextAlign.end,
|
||||
style: TextStyle(
|
||||
color: AppColors.placeholderTextColor, fontSize: 20.sp),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -175,23 +168,22 @@ class _NDaysUnopenedPageState extends State<NDaysUnopenedPage> {
|
||||
trackColor: CupertinoColors.systemGrey5,
|
||||
thumbColor: CupertinoColors.white,
|
||||
value: state.isUnOpenNotice.value,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
state.isUnOpenNotice.value = value;
|
||||
if (!state.isUnOpenNotice.value) {
|
||||
state.msgNoticeInfo.value = MsgNoticeData();
|
||||
}
|
||||
});
|
||||
onChanged: (bool value) {
|
||||
state.isUnOpenNotice.value = value;
|
||||
if (!state.isUnOpenNotice.value) {
|
||||
state.msgNoticeInfo.value = MsgNoticeData();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
//底部选择pickerView
|
||||
_openBottomItemSheet(BuildContext context, List dataList) {
|
||||
// 底部选择pickerView
|
||||
void _openBottomItemSheet(BuildContext context, List dataList) {
|
||||
Pickers.showSinglePicker(context,
|
||||
data: dataList,
|
||||
pickerStyle: DefaultPickerStyle(), onConfirm: (p, position) {
|
||||
state.unOpenDoorTime.value = p;
|
||||
}, onChanged: (p, position) {});
|
||||
pickerStyle: DefaultPickerStyle(), onConfirm: (p, int position) {
|
||||
state.unOpenDoorTime.value =
|
||||
int.parse(state.unopenDoorTimeList[position].replaceAll('天', ''));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,25 +4,25 @@ import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotific
|
||||
|
||||
class NDaysUnopenedState {
|
||||
final List unopenDoorTimeList = [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
'1天',
|
||||
'2天',
|
||||
'3天',
|
||||
'4天',
|
||||
'5天',
|
||||
'6天',
|
||||
'7天',
|
||||
'8天',
|
||||
'9天',
|
||||
'10天',
|
||||
'11天',
|
||||
'12天',
|
||||
'13天',
|
||||
'14天',
|
||||
'15天',
|
||||
];
|
||||
|
||||
var isUnOpenNotice = false.obs; // 是否N天未开门提醒
|
||||
var unOpenDoorTime = 1.obs; // 未开门时间
|
||||
var unOpenDoorTime = 3.obs; // 未开门时间
|
||||
|
||||
var getLockId = 0.obs;
|
||||
var lockUserKeys = LockUserListKeys().obs;
|
||||
@ -43,7 +43,9 @@ class NDaysUnopenedState {
|
||||
msgNoticeInfo.value = map['lockSetInfoData'];
|
||||
isUnOpenNotice.value =
|
||||
msgNoticeInfo.value.dayNotOpenDoorState == 1 ? true : false;
|
||||
unOpenDoorTime.value = msgNoticeInfo.value.dayNotOpenDoorValue!;
|
||||
if (msgNoticeInfo.value.dayNotOpenDoorValue != 0) {
|
||||
unOpenDoorTime.value = msgNoticeInfo.value.dayNotOpenDoorValue!;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,9 @@ import 'package:get/get.dart';
|
||||
import 'package:star_lock/appRouters.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_logic.dart';
|
||||
import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_state.dart';
|
||||
import 'package:star_lock/tools/commonItem.dart';
|
||||
import 'package:star_lock/tools/regularExpression.dart';
|
||||
import 'package:star_lock/tools/submitBtn.dart';
|
||||
import 'package:star_lock/translations/trans_lib.dart';
|
||||
|
||||
@ -20,8 +22,8 @@ class NotificationModePage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _NotificationModePageState extends State<NotificationModePage> {
|
||||
final logic = Get.put(NotificationModeLogic());
|
||||
final state = Get.find<NotificationModeLogic>().state;
|
||||
final NotificationModeLogic logic = Get.put(NotificationModeLogic());
|
||||
final NotificationModeState state = Get.find<NotificationModeLogic>().state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -43,7 +45,7 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
|
||||
Widget _buildMainView() {
|
||||
return Column(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
CommonItem(
|
||||
leftTitel: 'APP推送'.tr,
|
||||
rightTitle: '管理员'.tr,
|
||||
@ -66,7 +68,7 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
SubmitBtn(
|
||||
btnName: '确定'.tr,
|
||||
onClick: () {
|
||||
Get.back(result: {
|
||||
Get.back(result: <String, List>{
|
||||
'emailReceiverList': state.emailReceiverList.value,
|
||||
'phoneReceiverList': state.phoneReceiverList.value
|
||||
});
|
||||
@ -135,9 +137,9 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
height: 62.h,
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
onTap: (() {
|
||||
onTap: () {
|
||||
if (isEmail) {
|
||||
state.emailReceiverList.value.removeAt(index);
|
||||
state.emailReceiverList.refresh();
|
||||
@ -145,7 +147,7 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
state.phoneReceiverList.value.removeAt(index);
|
||||
state.phoneReceiverList.refresh();
|
||||
}
|
||||
}),
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
child: Image.asset(
|
||||
@ -163,39 +165,40 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
style: TextStyle(fontSize: 22.sp),
|
||||
),
|
||||
Expanded(child: SizedBox(width: 10.w)),
|
||||
!isEmail
|
||||
? GestureDetector(
|
||||
child: Container(
|
||||
width: 90.w,
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Obx(() => Text(
|
||||
'+${state.countryCode}',
|
||||
style: TextStyle(
|
||||
color: AppColors.darkGrayTextColor,
|
||||
fontSize: 20.sp),
|
||||
)),
|
||||
Image.asset(
|
||||
'images/icon_grayPullDown.png',
|
||||
width: 20.w,
|
||||
height: 20.w,
|
||||
),
|
||||
],
|
||||
if (!isEmail)
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
width: 90.w,
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Obx(() => Text(
|
||||
'+${state.countryCode}',
|
||||
style: TextStyle(
|
||||
color: AppColors.darkGrayTextColor,
|
||||
fontSize: 20.sp),
|
||||
)),
|
||||
Image.asset(
|
||||
'images/icon_grayPullDown.png',
|
||||
width: 20.w,
|
||||
height: 20.w,
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
var result =
|
||||
await Get.toNamed(Routers.selectCountryRegionPage);
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
}
|
||||
},
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
final result =
|
||||
await Get.toNamed(Routers.selectCountryRegionPage);
|
||||
if (result != null) {
|
||||
result as Map<String, dynamic>;
|
||||
state.countryCode.value = result['code'];
|
||||
state.countryName.value = result['countryName'];
|
||||
}
|
||||
},
|
||||
)
|
||||
else
|
||||
Container(),
|
||||
getReceiverTFWidget(isEmail ? '请输入Email'.tr : '请输入手机号'.tr, index,
|
||||
isEmail: isEmail)
|
||||
],
|
||||
@ -206,7 +209,7 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
// 接受者信息输入框
|
||||
Widget getReceiverTFWidget(String tfStr, int lineIndex,
|
||||
{required bool isEmail}) {
|
||||
MsgNoticeModeData msgData = isEmail
|
||||
final MsgNoticeModeData msgData = isEmail
|
||||
? state.emailReceiverList.value[lineIndex]
|
||||
: state.phoneReceiverList.value[lineIndex];
|
||||
msgData.countryCode = state.countryCode.value;
|
||||
@ -216,7 +219,7 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
height: 65.h,
|
||||
width: 200.w,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: msgData.receiverTF,
|
||||
@ -247,7 +250,7 @@ class _NotificationModePageState extends State<NotificationModePage> {
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
|
||||
onChanged: (value) {
|
||||
onChanged: (String value) {
|
||||
if (isEmail) {
|
||||
msgData.receiveEmail = value;
|
||||
state.emailReceiverList.value[lineIndex] = msgData;
|
||||
|
||||
@ -89,7 +89,7 @@ class PalmDetailLogic extends BaseGetXController {
|
||||
dismissEasyLoading();
|
||||
state.sureBtnState.value = 0;
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||
|
||||
@ -185,7 +185,7 @@ class PalmListLogic extends BaseGetXController {
|
||||
|
||||
// 获取人脸状态
|
||||
Future<void> senderQueryingFaceStatus() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -214,7 +214,7 @@ class PalmListLogic extends BaseGetXController {
|
||||
|
||||
// 查询用户、指纹、密码、卡片数量(用于判断是否同步)
|
||||
Future<void> senderCheckingUserInfoCount() async {
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState state) async {
|
||||
if (state == BluetoothConnectionState.connected) {
|
||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||
@ -246,7 +246,7 @@ class PalmListLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: () {
|
||||
dismissEasyLoading();
|
||||
});
|
||||
BlueManage().bludSendData(BlueManage().connectDeviceName,
|
||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||
(BluetoothConnectionState deviceConnectionState) async {
|
||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||
var signKey = await Storage.getStringList(saveBlueSignKey);
|
||||
|
||||
@ -127,7 +127,7 @@ class PasswordKeyDetailLogic 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<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -121,7 +121,7 @@ class PasswordKeyDetailChangeDateLogic 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<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -128,7 +128,7 @@ class PasswordKeyListLogic extends BaseGetXController {
|
||||
showBlueConnetctToastTimer(action: (){
|
||||
dismissEasyLoading();
|
||||
});
|
||||
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<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
@ -177,7 +177,7 @@ class PasswordKeyListLogic 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<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -342,7 +342,7 @@ class PasswordKeyPerpetualLogic 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<int> signKeyDataList = changeStringListToIntList(signKey!);
|
||||
|
||||
@ -252,6 +252,11 @@ class LockListInfoItemEntity {
|
||||
data['hasGateway'] = hasGateway;
|
||||
return data;
|
||||
}
|
||||
|
||||
//是否是锁拥有者 也代表是超级管理员
|
||||
bool isLockOwnerBool(){
|
||||
return isLockOwner== 1;
|
||||
}
|
||||
}
|
||||
|
||||
class Bluetooth {
|
||||
|
||||
@ -4,7 +4,6 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/blue/io_type.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
|
||||
import '../../../blue/blue_manage.dart';
|
||||
@ -23,26 +22,44 @@ import '../../../translations/trans_lib.dart';
|
||||
import '../entity/lockListInfo_entity.dart';
|
||||
import 'lockList_state.dart';
|
||||
|
||||
class LockListLogic extends BaseGetXController{
|
||||
class LockListLogic extends BaseGetXController {
|
||||
LockListLogic(this.entity){
|
||||
}
|
||||
|
||||
LockListState state = LockListState();
|
||||
List<GroupList> groupDataList = <GroupList>[];
|
||||
LockListInfoGroupEntity? entity;
|
||||
|
||||
//设置数据
|
||||
void setLockListInfoGroupEntity(LockListInfoGroupEntity entity) {
|
||||
this.entity = entity;
|
||||
if (entity.pageNo == 1) {
|
||||
groupDataList = <GroupList>[];
|
||||
}
|
||||
groupDataList.addAll(entity.groupList!);
|
||||
update();
|
||||
}
|
||||
|
||||
// 监听蓝牙协议返回结果
|
||||
late StreamSubscription<Reply> _replySubscription;
|
||||
|
||||
void _initReplySubscription() {
|
||||
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
||||
_replySubscription =
|
||||
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
||||
// 恢复出厂设置
|
||||
if ((reply is FactoryDataResetReply) && (state.ifCurrentScreen.value == true)) {
|
||||
if ((reply is FactoryDataResetReply) &&
|
||||
(state.ifCurrentScreen.value == true)) {
|
||||
_replyFactoryDataResetKey(reply);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _replyFactoryDataResetKey(Reply reply) async {
|
||||
var token = reply.data.sublist(2, 6);
|
||||
var saveStrList = changeIntListToStringList(token);
|
||||
final List<int> token = reply.data.sublist(2, 6);
|
||||
final List<String> saveStrList = changeIntListToStringList(token);
|
||||
Storage.setStringList(saveBlueToken, saveStrList);
|
||||
|
||||
int status = reply.data[6];
|
||||
final int status = reply.data[6];
|
||||
switch (status) {
|
||||
case 0x00:
|
||||
//成功
|
||||
@ -52,22 +69,24 @@ class LockListLogic extends BaseGetXController{
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
var token = await Storage.getStringList(saveBlueToken);
|
||||
List<int> getTokenList = changeStringListToIntList(token!);
|
||||
final List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||
final List<int> getTokenList = changeStringListToIntList(token!);
|
||||
|
||||
IoSenderManage.senderFactoryDataReset(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
keyID: "1",
|
||||
keyID: '1',
|
||||
needAuthor: 1,
|
||||
publicKey: state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(),
|
||||
privateKey: state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(),
|
||||
publicKey:
|
||||
state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(),
|
||||
privateKey:
|
||||
state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(),
|
||||
token: getTokenList);
|
||||
break;
|
||||
case 0x07:
|
||||
//无权限
|
||||
dismissEasyLoading();
|
||||
showToast("用户无权限");
|
||||
showToast('用户无权限');
|
||||
break;
|
||||
case 0x09:
|
||||
// 权限校验错误
|
||||
@ -82,62 +101,63 @@ class LockListLogic extends BaseGetXController{
|
||||
}
|
||||
}
|
||||
|
||||
String showElectricIcon (int electricnumber){
|
||||
if(electricnumber >= 100){
|
||||
String showElectricIcon(int electricnumber) {
|
||||
if (electricnumber >= 100) {
|
||||
return 'images/main/icon_lockElectricLevel_5.png';
|
||||
}else if((electricnumber > 50) && (electricnumber < 100)){
|
||||
} else if ((electricnumber > 50) && (electricnumber < 100)) {
|
||||
return 'images/main/icon_lockElectricLevel_4.png';
|
||||
}else if((electricnumber > 25) && (electricnumber <= 50)){
|
||||
} else if ((electricnumber > 25) && (electricnumber <= 50)) {
|
||||
return 'images/main/icon_lockElectricLevel_3.png';
|
||||
}else if((electricnumber > 5) && (electricnumber <= 25)){
|
||||
} else if ((electricnumber > 5) && (electricnumber <= 25)) {
|
||||
return 'images/main/icon_lockElectricLevel_2.png';
|
||||
}else if(electricnumber <= 5){
|
||||
} else if (electricnumber <= 5) {
|
||||
return 'images/main/icon_lockElectricLevel_1.png';
|
||||
}
|
||||
return 'images/main/icon_lockElectricLevel_5.png';
|
||||
}
|
||||
|
||||
String getKeyEffective(LockListInfoItemEntity keyInfo){
|
||||
String getKeyEffective(LockListInfoItemEntity keyInfo) {
|
||||
// 当是限时、循环的时候
|
||||
if(keyInfo.keyType == XSConstantMacro.keyTypeTime || keyInfo.keyType == XSConstantMacro.keyTypeLoop){
|
||||
if (keyInfo.keyType == XSConstantMacro.keyTypeTime ||
|
||||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) {
|
||||
// 当是正常使用跟待接收状态的时候
|
||||
if(keyInfo.keyStatus == XSConstantMacro.keyStatusNormalUse || keyInfo.keyStatus == XSConstantMacro.keyStatusWaitReceive) {
|
||||
if (keyInfo.keyStatus == XSConstantMacro.keyStatusNormalUse ||
|
||||
keyInfo.keyStatus == XSConstantMacro.keyStatusWaitReceive) {
|
||||
return "${"余".tr}${DateTool().compareTimeGetDaysFromNow(keyInfo.endDate!)}${"天".tr}";
|
||||
} else {
|
||||
return XSConstantMacro.getKeyStatusStr(keyInfo.keyStatus!);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
/// 以下为删除逻辑
|
||||
deleyLockLogicOfRoles(){
|
||||
/// 以下为删除逻辑
|
||||
void deleyLockLogicOfRoles() {
|
||||
if (state.lockListInfoItemEntity.isLockOwner == 1) {
|
||||
// 超级管理员必须通过连接蓝牙删除
|
||||
ShowTipView().showIosTipWithContentDialog("删除锁后,所有信息都会一起删除,确定删除锁吗?".tr, (){
|
||||
ShowTipView().showIosTipWithContentDialog('删除锁后,所有信息都会一起删除,确定删除锁吗?'.tr,
|
||||
() {
|
||||
// 删除锁
|
||||
ShowTipView().showTFViewAlertDialog(state.passwordTF, "请输入登录密码".tr, "请输入登录密码".tr, (){
|
||||
checkLoginPassword();
|
||||
});
|
||||
ShowTipView().showTFViewAlertDialog(
|
||||
state.passwordTF, '请输入登录密码'.tr, '请输入登录密码'.tr, checkLoginPassword);
|
||||
});
|
||||
} else if (state.lockListInfoItemEntity.keyRight == 1){
|
||||
} else if (state.lockListInfoItemEntity.keyRight == 1) {
|
||||
// 授权管理员弹框提示
|
||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog("同时删除其发送的所有钥匙,钥匙删除后不能恢复".tr, (a){
|
||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog(
|
||||
'同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool a) {
|
||||
// 授权管理员删除
|
||||
state.deleteAdministratorIsHaveAllData.value = a;
|
||||
deletKeyData();
|
||||
});
|
||||
} else{
|
||||
} else {
|
||||
// 普通用户直接删除
|
||||
ShowTipView().showIosTipWithContentDialog("是否删除钥匙?".tr, (){
|
||||
deletKeyData();
|
||||
});
|
||||
ShowTipView().showIosTipWithContentDialog('是否删除钥匙?'.tr, deletKeyData);
|
||||
}
|
||||
}
|
||||
|
||||
// 查询账户密码
|
||||
void checkLoginPassword() async {
|
||||
var entity = await ApiRepository.to.checkLoginPassword(
|
||||
Future<void> checkLoginPassword() async {
|
||||
final LockListInfoEntity entity = await ApiRepository.to.checkLoginPassword(
|
||||
password: state.passwordTF.text,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
@ -147,12 +167,12 @@ class LockListLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
// 当是锁拥有者的时候,删除锁
|
||||
void deletLockInfoData() async {
|
||||
var entity = await ApiRepository.to.deletOwnerLockData(
|
||||
Future<void> deletLockInfoData() async {
|
||||
final LockListInfoEntity entity = await ApiRepository.to.deletOwnerLockData(
|
||||
lockId: state.lockListInfoItemEntity.lockId!,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
BlueManage().connectDeviceMacAddress = '';
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
});
|
||||
@ -160,14 +180,14 @@ class LockListLogic extends BaseGetXController{
|
||||
}
|
||||
|
||||
// 普通用户或者授权管理员删除钥匙
|
||||
void deletKeyData() async {
|
||||
var entity = await ApiRepository.to.deletOwnerKeyData(
|
||||
Future<void> deletKeyData() async {
|
||||
final LockListInfoEntity entity = await ApiRepository.to.deletOwnerKeyData(
|
||||
lockId: state.lockListInfoItemEntity.lockId.toString(),
|
||||
keyId: state.lockListInfoItemEntity.keyId.toString(),
|
||||
includeUnderlings: state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0
|
||||
);
|
||||
includeUnderlings:
|
||||
state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
BlueManage().connectDeviceMacAddress = "";
|
||||
BlueManage().connectDeviceMacAddress = '';
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
});
|
||||
@ -177,62 +197,74 @@ class LockListLogic extends BaseGetXController{
|
||||
// 恢复出厂设置
|
||||
Future<void> factoryDataResetAction() async {
|
||||
showEasyLoading();
|
||||
showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: (){
|
||||
dismissEasyLoading();
|
||||
showDeletAlertTipDialog();
|
||||
});
|
||||
BlueManage().bludSendData(state.lockListInfoItemEntity.lockName!, (BluetoothConnectionState connectionState) async {
|
||||
showBlueConnetctToastTimer(
|
||||
isShowBlueConnetctToast: false,
|
||||
action: () {
|
||||
dismissEasyLoading();
|
||||
showDeletAlertTipDialog();
|
||||
});
|
||||
BlueManage().blueSendData(state.lockListInfoItemEntity.lockName!,
|
||||
(BluetoothConnectionState connectionState) async {
|
||||
if (connectionState == BluetoothConnectionState.connected) {
|
||||
List<int> publicKeyData = state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>();
|
||||
var saveStrList = changeIntListToStringList(publicKeyData);
|
||||
final List<int> publicKeyData =
|
||||
state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>();
|
||||
final List<String> saveStrList =
|
||||
changeIntListToStringList(publicKeyData);
|
||||
Storage.setStringList(saveBluePublicKey, saveStrList);
|
||||
|
||||
// 私钥
|
||||
List<int> privateKeyData = state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>();
|
||||
var savePrivateKeyList = changeIntListToStringList(privateKeyData);
|
||||
final List<int> privateKeyData =
|
||||
state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>();
|
||||
final List<String> savePrivateKeyList =
|
||||
changeIntListToStringList(privateKeyData);
|
||||
Storage.setStringList(saveBluePrivateKey, savePrivateKeyList);
|
||||
|
||||
// signKey
|
||||
List<int> signKeyData = state.lockListInfoItemEntity.bluetooth!.signKey!.cast<int>();
|
||||
var saveSignKeyList = changeIntListToStringList(signKeyData);
|
||||
final List<int> signKeyData =
|
||||
state.lockListInfoItemEntity.bluetooth!.signKey!.cast<int>();
|
||||
final List<String> saveSignKeyList =
|
||||
changeIntListToStringList(signKeyData);
|
||||
Storage.setStringList(saveBlueSignKey, saveSignKeyList);
|
||||
|
||||
var saveTokenList = changeIntListToStringList([0, 0, 0, 0]);
|
||||
final List<String> saveTokenList =
|
||||
changeIntListToStringList(<int>[0, 0, 0, 0]);
|
||||
Storage.setStringList(saveBlueToken, saveTokenList);
|
||||
|
||||
IoSenderManage.senderFactoryDataReset(
|
||||
lockID: BlueManage().connectDeviceName,
|
||||
userID: await Storage.getUid(),
|
||||
keyID: "1",
|
||||
keyID: '1',
|
||||
needAuthor: 1,
|
||||
publicKey: state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(),
|
||||
privateKey: state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(),
|
||||
token: [0,0,0,0]);
|
||||
publicKey:
|
||||
state.lockListInfoItemEntity.bluetooth!.publicKey!.cast<int>(),
|
||||
privateKey:
|
||||
state.lockListInfoItemEntity.bluetooth!.privateKey!.cast<int>(),
|
||||
token: <int>[0, 0, 0, 0]);
|
||||
} else if (connectionState == BluetoothConnectionState.disconnected) {
|
||||
dismissEasyLoading();
|
||||
cancelBlueConnetctToastTimer();
|
||||
if(state.ifCurrentScreen.value == true){
|
||||
if (state.ifCurrentScreen.value == true) {
|
||||
showDeletAlertTipDialog();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void showDeletAlertTipDialog({String? showContent = ""}) {
|
||||
void showDeletAlertTipDialog({String? showContent = ''}) {
|
||||
// bool isContains = BlueManage().connectDeviceName!.contains("T9A");
|
||||
var content = showContent!.isEmpty ? "${"删除设备失败,请确保在设备附近,设备未被连接,设备已打开".tr}${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮".tr : ""}" : showContent;
|
||||
final String content = showContent!.isEmpty
|
||||
? "${"删除设备失败,请确保在设备附近,设备未被连接,设备已打开".tr}${BlueManage().connectDeviceName.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮".tr : ""}"
|
||||
: showContent;
|
||||
showCupertinoDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
builder: (BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text("提示".tr),
|
||||
title: Text('提示'.tr),
|
||||
content: Text(content),
|
||||
actions: [
|
||||
actions: <Widget>[
|
||||
CupertinoDialogAction(
|
||||
child: Text(TranslationLoader.lanKeys!.sure!.tr),
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
onPressed: Get.back,
|
||||
),
|
||||
],
|
||||
);
|
||||
@ -242,23 +274,18 @@ class LockListLogic extends BaseGetXController{
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
super.onReady();
|
||||
|
||||
_initReplySubscription();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
// TODO: implement onInit
|
||||
super.onInit();
|
||||
setLockListInfoGroupEntity(entity!);
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
|
||||
_replySubscription.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/main/lockMian/lockList/lockList_state.dart';
|
||||
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
@ -14,50 +15,53 @@ import 'lockListGroup_view.dart';
|
||||
import 'lockList_logic.dart';
|
||||
|
||||
class LockListPage extends StatefulWidget {
|
||||
final LockListInfoGroupEntity lockListInfoGroupEntity;
|
||||
|
||||
const LockListPage({Key? key, required this.lockListInfoGroupEntity})
|
||||
const LockListPage({required this.lockListInfoGroupEntity, Key? key})
|
||||
: super(key: key);
|
||||
final LockListInfoGroupEntity lockListInfoGroupEntity;
|
||||
|
||||
@override
|
||||
State<LockListPage> createState() => _LockListPageState();
|
||||
}
|
||||
|
||||
class _LockListPageState extends State<LockListPage> with RouteAware {
|
||||
final logic = Get.put(LockListLogic());
|
||||
final state = Get.find<LockListLogic>().state;
|
||||
late LockListLogic logic;
|
||||
late LockListState state;
|
||||
|
||||
var groupDataList = <GroupList>[];
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
logic = Get.put(LockListLogic(widget.lockListInfoGroupEntity));
|
||||
state = Get.find<LockListLogic>().state;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.lockListInfoGroupEntity.pageNo == 1) {
|
||||
groupDataList = <GroupList>[];
|
||||
}
|
||||
groupDataList.addAll(
|
||||
widget.lockListInfoGroupEntity.groupList as Iterable<GroupList>);
|
||||
|
||||
return Scaffold(
|
||||
body: ListView.separated(
|
||||
itemCount: groupDataList.length,
|
||||
itemBuilder: (context, index) {
|
||||
GroupList itemData = groupDataList[index];
|
||||
return _buildLockExpandedList(context, index, itemData);
|
||||
},
|
||||
shrinkWrap: true,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
separatorBuilder: (context, index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
}),
|
||||
);
|
||||
return GetBuilder<LockListLogic>(builder: (LockListLogic logic) {
|
||||
return Scaffold(
|
||||
body: ListView.separated(
|
||||
itemCount: logic.groupDataList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final GroupList itemData = logic.groupDataList[index];
|
||||
return _buildLockExpandedList(context, index, itemData);
|
||||
},
|
||||
shrinkWrap: true,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
//设备多层级列表
|
||||
Widget _buildLockExpandedList(context, index, GroupList itemData) {
|
||||
List lockItemList = itemData.lockList ?? [];
|
||||
Widget _buildLockExpandedList(
|
||||
BuildContext context, int index, GroupList itemData) {
|
||||
final List<LockListInfoItemEntity> lockItemList =
|
||||
itemData.lockList ?? <LockListInfoItemEntity>[];
|
||||
return LockListGroupView(
|
||||
onTap: () {
|
||||
//是否选中组
|
||||
@ -65,28 +69,28 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
|
||||
} else {}
|
||||
setState(() {});
|
||||
},
|
||||
typeImgList: const [],
|
||||
typeImgList: const <dynamic>[],
|
||||
groupItem: itemData,
|
||||
child: ListView.separated(
|
||||
itemCount: lockItemList.length,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
separatorBuilder: (context, index) {
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(height: 1, color: AppColors.greyLineColor);
|
||||
},
|
||||
itemBuilder: (c, index) {
|
||||
LockListInfoItemEntity keyInfo = lockItemList[index];
|
||||
itemBuilder: (BuildContext c, int index) {
|
||||
final LockListInfoItemEntity keyInfo = lockItemList[index];
|
||||
bool isLast = false;
|
||||
if (lockItemList.length == index + 1) {
|
||||
isLast = true;
|
||||
}
|
||||
|
||||
return Slidable(
|
||||
key: ValueKey(keyInfo.keyId),
|
||||
key: ValueKey<int?>(keyInfo.keyId),
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context) {
|
||||
state.lockListInfoItemEntity = keyInfo;
|
||||
@ -104,26 +108,27 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
|
||||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
|
||||
(keyInfo.keyStatus ==
|
||||
XSConstantMacro.keyStatusWaitIneffective)) {
|
||||
logic.showToast("您的钥匙未生效".tr);
|
||||
logic.showToast('您的钥匙未生效'.tr);
|
||||
return;
|
||||
}
|
||||
if ((keyInfo.keyType == XSConstantMacro.keyTypeTime ||
|
||||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
|
||||
(keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen)) {
|
||||
logic.showToast("您的钥匙已冻结".tr);
|
||||
logic.showToast('您的钥匙已冻结'.tr);
|
||||
return;
|
||||
}
|
||||
if ((keyInfo.keyType == XSConstantMacro.keyTypeTime ||
|
||||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
|
||||
(keyInfo.keyStatus == XSConstantMacro.keyStatusExpired)) {
|
||||
logic.showToast("您的钥匙已过期".tr);
|
||||
logic.showToast('您的钥匙已过期'.tr);
|
||||
return;
|
||||
}
|
||||
Get.toNamed(Routers.lockDetailMainPage, arguments: {
|
||||
// "lockMainEntity": widget.lockMainEntity,
|
||||
"keyInfo": keyInfo,
|
||||
"isOnlyOneData": false,
|
||||
});
|
||||
Get.toNamed(Routers.lockDetailMainPage,
|
||||
arguments: <String, Object>{
|
||||
// "lockMainEntity": widget.lockMainEntity,
|
||||
'keyInfo': keyInfo,
|
||||
'isOnlyOneData': false,
|
||||
});
|
||||
}),
|
||||
);
|
||||
}),
|
||||
@ -152,18 +157,18 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
|
||||
),
|
||||
child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 20.h,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(width: 30.w),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
keyInfo.lockAlias!,
|
||||
style: TextStyle(
|
||||
@ -184,7 +189,7 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
|
||||
),
|
||||
SizedBox(width: 2.w),
|
||||
Text(
|
||||
"${keyInfo.electricQuantity!}%",
|
||||
'${keyInfo.electricQuantity!}%',
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
@ -193,9 +198,9 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
|
||||
),
|
||||
SizedBox(height: 5.h),
|
||||
Visibility(
|
||||
visible: keyInfo.passageMode == 1 ? true : false,
|
||||
visible: keyInfo.passageMode == 1,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(width: 30.w),
|
||||
Container(
|
||||
padding: EdgeInsets.only(right: 5.w, left: 5.w),
|
||||
@ -203,7 +208,7 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
|
||||
borderRadius: BorderRadius.circular(5.w),
|
||||
color: AppColors.openPassageModeColor,
|
||||
),
|
||||
child: Text("常开模式开启".tr,
|
||||
child: Text('常开模式开启'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.appBarIconColor)),
|
||||
@ -212,12 +217,12 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
|
||||
)),
|
||||
SizedBox(height: 5.h),
|
||||
Visibility(
|
||||
visible: keyInfo.lockSetting!.remoteUnlock == 1 ? true : false,
|
||||
visible: keyInfo.lockSetting!.remoteUnlock == 1,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(width: 30.w),
|
||||
Text(
|
||||
"远程开锁".tr,
|
||||
'远程开锁'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp, color: AppColors.darkGrayTextColor),
|
||||
),
|
||||
@ -225,19 +230,15 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
|
||||
)),
|
||||
SizedBox(height: 20.h),
|
||||
Visibility(
|
||||
visible: ((keyInfo.keyType == XSConstantMacro.keyTypeTime ||
|
||||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
|
||||
(keyInfo.keyStatus ==
|
||||
XSConstantMacro.keyStatusWaitIneffective ||
|
||||
keyInfo.keyStatus ==
|
||||
XSConstantMacro.keyStatusFrozen ||
|
||||
keyInfo.keyStatus ==
|
||||
XSConstantMacro.keyStatusExpired))
|
||||
? true
|
||||
: false,
|
||||
visible: (keyInfo.keyType == XSConstantMacro.keyTypeTime ||
|
||||
keyInfo.keyType == XSConstantMacro.keyTypeLoop) &&
|
||||
(keyInfo.keyStatus ==
|
||||
XSConstantMacro.keyStatusWaitIneffective ||
|
||||
keyInfo.keyStatus == XSConstantMacro.keyStatusFrozen ||
|
||||
keyInfo.keyStatus == XSConstantMacro.keyStatusExpired),
|
||||
// visible: true,
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(width: 30.w),
|
||||
Container(
|
||||
padding: EdgeInsets.only(right: 5.w, left: 5.w),
|
||||
@ -257,7 +258,7 @@ class _LockListPageState extends State<LockListPage> with RouteAware {
|
||||
)),
|
||||
SizedBox(height: 5.h),
|
||||
Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SizedBox(width: 30.w),
|
||||
Text(
|
||||
"${logic.getUseKeyTypeStr(keyInfo.startDate, keyInfo.endDate, keyInfo.keyType)}/${keyInfo.isLockOwner == 1 ? '超级管理员'.tr : (keyInfo.keyRight == 1 ? "授权管理员".tr : "普通用户".tr)}",
|
||||
|
||||
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
import 'package:star_lock/main/lockMian/lockList/lockList_state.dart';
|
||||
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
@ -14,87 +14,90 @@ import 'lockListGroup_view.dart';
|
||||
import 'lockList_logic.dart';
|
||||
|
||||
class LockListXHJPage extends StatefulWidget {
|
||||
final LockListInfoGroupEntity lockListInfoGroupEntity;
|
||||
|
||||
const LockListXHJPage({Key? key, required this.lockListInfoGroupEntity})
|
||||
const LockListXHJPage({required this.lockListInfoGroupEntity, Key? key})
|
||||
: super(key: key);
|
||||
final LockListInfoGroupEntity lockListInfoGroupEntity;
|
||||
|
||||
@override
|
||||
State<LockListXHJPage> createState() => _LockListXHJPageState();
|
||||
}
|
||||
|
||||
class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
final logic = Get.put(LockListLogic());
|
||||
final state = Get.find<LockListLogic>().state;
|
||||
late LockListLogic logic;
|
||||
late LockListState state;
|
||||
|
||||
var groupDataList = <GroupList>[];
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
logic = Get.put(LockListLogic(widget.lockListInfoGroupEntity));
|
||||
state = Get.find<LockListLogic>().state;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.lockListInfoGroupEntity.pageNo == 1) {
|
||||
groupDataList = <GroupList>[];
|
||||
}
|
||||
groupDataList.addAll(
|
||||
widget.lockListInfoGroupEntity.groupList as Iterable<GroupList>);
|
||||
return SafeArea(
|
||||
bottom: false,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Get.toNamed(Routers.selectLockTypePage);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.add_circle,
|
||||
size: 48.w,
|
||||
color: AppColors.mainColor,
|
||||
)),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 45.w),
|
||||
child: Text(
|
||||
'常用程序'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: AppColors.blackColor,
|
||||
fontWeight: FontWeight.w600,
|
||||
return GetBuilder<LockListLogic>(builder: (LockListLogic logic) {
|
||||
return SafeArea(
|
||||
bottom: false,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Get.toNamed(Routers.selectLockTypePage);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.add_circle,
|
||||
size: 48.w,
|
||||
color: AppColors.mainColor,
|
||||
)),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 45.w),
|
||||
child: Text(
|
||||
'常用程序'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: AppColors.blackColor,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
itemCount: groupDataList.length,
|
||||
itemBuilder: (context, index) {
|
||||
GroupList itemData = groupDataList[index];
|
||||
return _buildLockExpandedList(context, index, itemData);
|
||||
},
|
||||
shrinkWrap: true,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
separatorBuilder: (context, index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
itemCount: logic.groupDataList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final GroupList itemData = logic.groupDataList[index];
|
||||
return _buildLockExpandedList(context, index, itemData);
|
||||
},
|
||||
shrinkWrap: true,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1,
|
||||
color: AppColors.greyLineColor,
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
//设备多层级列表
|
||||
Widget _buildLockExpandedList(context, index, GroupList itemData) {
|
||||
List lockItemList = itemData.lockList ?? [];
|
||||
final List<LockListInfoItemEntity> lockItemList =
|
||||
itemData.lockList ?? <LockListInfoItemEntity>[];
|
||||
return LockListGroupView(
|
||||
onTap: () {
|
||||
setState(() {});
|
||||
},
|
||||
textStyle: TextStyle(fontSize: 28.sp, fontWeight: FontWeight.w600),
|
||||
backgroundColor: Colors.transparent,
|
||||
typeImgList: const [],
|
||||
typeImgList: const <dynamic>[],
|
||||
groupItem: itemData,
|
||||
child: GridView.extent(
|
||||
padding: EdgeInsets.symmetric(vertical: 15.h, horizontal: 15.w),
|
||||
@ -109,9 +112,9 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
}
|
||||
|
||||
List<Widget> forItems(List lockItemList) {
|
||||
List<Widget> list = [];
|
||||
final List<Widget> list = <Widget>[];
|
||||
for (int i = 0, j = 0; i < lockItemList.length; i++, j++) {
|
||||
LockListInfoItemEntity keyInfo = lockItemList[i];
|
||||
final LockListInfoItemEntity keyInfo = lockItemList[i];
|
||||
bool isLast = false;
|
||||
if (lockItemList.length == i + 1) {
|
||||
isLast = true;
|
||||
@ -121,7 +124,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: 0.2,
|
||||
motion: const ScrollMotion(),
|
||||
children: [
|
||||
children: <Widget>[
|
||||
SlidableAction(
|
||||
onPressed: (BuildContext context) {
|
||||
state.lockListInfoItemEntity = keyInfo;
|
||||
@ -153,7 +156,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
logic.showToast("您的钥匙已过期".tr);
|
||||
return;
|
||||
}
|
||||
Get.toNamed(Routers.lockDetailMainPage, arguments: {
|
||||
Get.toNamed(Routers.lockDetailMainPage, arguments: <String, Object>{
|
||||
"keyInfo": keyInfo,
|
||||
"isOnlyOneData": false,
|
||||
});
|
||||
@ -189,9 +192,9 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Image.asset(
|
||||
'images/icon_lock_circle.png',
|
||||
width: 32.r,
|
||||
@ -218,7 +221,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 5.h),
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(right: 5.w, left: 5.w),
|
||||
decoration: BoxDecoration(
|
||||
@ -239,7 +242,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 5.h),
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"远程开锁".tr,
|
||||
style: TextStyle(
|
||||
@ -263,7 +266,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 20.h),
|
||||
child: Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(right: 5.w, left: 5.w),
|
||||
decoration: BoxDecoration(
|
||||
@ -284,7 +287,7 @@ class _LockListXHJPageState extends State<LockListXHJPage> with RouteAware {
|
||||
)),
|
||||
SizedBox(height: 5.h),
|
||||
Row(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text(
|
||||
keyInfo.isLockOwner == 1
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/main/lockMian/lockList/lockList_logic.dart';
|
||||
|
||||
import '../../../app_settings/app_settings.dart';
|
||||
import '../../../blue/blue_manage.dart';
|
||||
@ -15,10 +15,12 @@ import 'lockMain_state.dart';
|
||||
class LockMainLogic extends BaseGetXController {
|
||||
final LockMainState state = LockMainState();
|
||||
|
||||
Future<LockListInfoEntity> getStarLockInfo() async {
|
||||
Future<LockListInfoEntity> getStarLockInfo(
|
||||
{bool isUnShowLoading = false}) async {
|
||||
LockListInfoEntity entity = await ApiRepository.to.getStarLockListInfo(
|
||||
pageNo: pageNo,
|
||||
pageSize: 50,
|
||||
isUnShowLoading: isUnShowLoading,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
loadMainDataLogic(entity.data!);
|
||||
@ -34,11 +36,11 @@ class LockMainLogic extends BaseGetXController {
|
||||
return entity;
|
||||
}
|
||||
|
||||
Future<void> loadMainDataLogic(LockListInfoGroupEntity entity){
|
||||
void loadMainDataLogic(LockListInfoGroupEntity entity) {
|
||||
if (entity.groupList!.isEmpty) {
|
||||
state.dataLength.value = 0;
|
||||
} else if (entity.groupList!.length == 1) {
|
||||
GroupList groupList = entity.groupList![0];
|
||||
final GroupList groupList = entity.groupList![0];
|
||||
if (groupList.lockList!.length > 1) {
|
||||
state.dataLength.value = 2;
|
||||
} else {
|
||||
@ -48,7 +50,11 @@ class LockMainLogic extends BaseGetXController {
|
||||
state.dataLength.value = 2;
|
||||
}
|
||||
state.lockListInfoGroupEntity.value = entity;
|
||||
return Future.value();
|
||||
//检测控制器是否存在
|
||||
if (Get.isRegistered<LockListLogic>()) {
|
||||
//设置控制器数据并刷新
|
||||
Get.find<LockListLogic>().setLockListInfoGroupEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/// 获取联网类型
|
||||
@ -80,7 +86,8 @@ class LockMainLogic extends BaseGetXController {
|
||||
connectListener() async {
|
||||
Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
|
||||
AppLog.log("设置网络切换监听:$result");
|
||||
if (state.networkConnectionStatus.value == 0 && result != ConnectivityResult.none) {
|
||||
if (state.networkConnectionStatus.value == 0 &&
|
||||
result != ConnectivityResult.none) {
|
||||
// 从无网络到有网络
|
||||
state.networkConnectionStatus.value = 1;
|
||||
getStarLockInfo();
|
||||
|
||||
@ -37,14 +37,15 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
final logic = Get.put(LockMainLogic());
|
||||
final state = Get.find<LockMainLogic>().state;
|
||||
|
||||
Future<void> getHttpData({bool clearScanDevices = false}) async {
|
||||
Future<void> getHttpData(
|
||||
{bool clearScanDevices = false, bool isUnShowLoading = false}) async {
|
||||
LockListInfoGroupEntity? lockListInfoGroupEntity =
|
||||
await Storage.getLockMainListData();
|
||||
if (lockListInfoGroupEntity != null) {
|
||||
var localLockListInfoGroupEntity = lockListInfoGroupEntity;
|
||||
await logic.loadMainDataLogic(localLockListInfoGroupEntity);
|
||||
logic.loadMainDataLogic(localLockListInfoGroupEntity);
|
||||
}
|
||||
await logic.getStarLockInfo();
|
||||
await logic.getStarLockInfo(isUnShowLoading: isUnShowLoading);
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
if (clearScanDevices) {
|
||||
BlueManage().scanDevices.clear();
|
||||
@ -237,7 +238,9 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
|
||||
void _initLoadDataAction() {
|
||||
_teamEvent = eventBus.on<RefreshLockListInfoDataEvent>().listen((event) {
|
||||
logic.pageNo = 1;
|
||||
getHttpData(clearScanDevices: event.clearScanDevices);
|
||||
getHttpData(
|
||||
clearScanDevices: event.clearScanDevices,
|
||||
isUnShowLoading: event.isUnShowLoading);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user