1,新增下拉组件
2,门锁日志页面优化完善
This commit is contained in:
parent
c58ff3a827
commit
60614a53b1
BIN
star_lock/images/main/icon_lockLog_play.png
Normal file
BIN
star_lock/images/main/icon_lockLog_play.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
@ -1,8 +1,10 @@
|
||||
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/main/lockDetail/doorLockLog/doorLockLog_logic.dart';
|
||||
import 'package:star_lock/tools/advancedCalendar/src/widget.dart';
|
||||
import 'package:star_lock/tools/menuItem/xsDropDownWidget.dart';
|
||||
import 'package:timelines/timelines.dart';
|
||||
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
@ -122,35 +124,18 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> {
|
||||
|
||||
//事件下拉框组件
|
||||
Widget eventDropDownWidget() {
|
||||
return Row(children: [
|
||||
SizedBox(
|
||||
width: 50.w,
|
||||
return Container(
|
||||
margin: EdgeInsets.only(top: 20.h, left: 30.w, bottom: 20.h),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Obx(() => XSDropDownWidget(
|
||||
items: state.getDropDownItemList,
|
||||
value: state.dropdownValue.value,
|
||||
valueChanged: (value) {})),
|
||||
],
|
||||
),
|
||||
Obx(() => DropdownButton<String>(
|
||||
value: state.dropdownValue.value,
|
||||
icon: const Icon(Icons.arrow_drop_down),
|
||||
iconSize: 40,
|
||||
elevation: 12,
|
||||
style: TextStyle(
|
||||
fontSize: 26.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w600),
|
||||
iconEnabledColor: Colors.grey,
|
||||
underline: Container(
|
||||
height: 0,
|
||||
),
|
||||
onChanged: (newValue) {
|
||||
state.dropdownValue.value = newValue!;
|
||||
},
|
||||
items: state.dropDownItemList.obs
|
||||
.map<DropdownMenuItem<String>>((item) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: item,
|
||||
child: Text(item),
|
||||
);
|
||||
}).toList(),
|
||||
))
|
||||
]);
|
||||
);
|
||||
}
|
||||
|
||||
//时间轴组件
|
||||
@ -175,11 +160,31 @@ class _DoorLockLogPageState extends State<DoorLockLogPage> {
|
||||
color: Colors.black,
|
||||
fontSize: 24.sp,
|
||||
fontWeight: FontWeight.w600)),
|
||||
Image(
|
||||
image: const AssetImage(
|
||||
'images/main/icon_lockDetail_monitoringvoiceFrist.png'),
|
||||
width: 260.w,
|
||||
height: 260.h,
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(Routers.videoLogDetailPage);
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
Image(
|
||||
image: const AssetImage(
|
||||
'images/main/icon_lockDetail_monitoringvoiceFrist.png'),
|
||||
width: 260.w,
|
||||
height: 260.h,
|
||||
),
|
||||
//在图片上添加一个三角视频图标
|
||||
Positioned(
|
||||
top: 200.h,
|
||||
left: 10.w,
|
||||
child: Image(
|
||||
image: const AssetImage(
|
||||
'images/main/icon_lockLog_play.png'),
|
||||
width: 24.w,
|
||||
height: 20.w,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/tools/advancedCalendar/src/controller.dart';
|
||||
import 'package:star_lock/tools/menuItem/dropDownItem.dart';
|
||||
|
||||
import '../../lockMian/entity/lockListInfo_entity.dart';
|
||||
import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart';
|
||||
@ -14,8 +16,14 @@ class DoorLockLogState {
|
||||
DateTime(2024, 10, 10),
|
||||
];
|
||||
var dropdownValue = '全部事件'.obs;
|
||||
final List dropDownItemList =
|
||||
['全部事件', '门锁异常', '有人出现', '有人按门铃', '一次性密码开门'].obs;
|
||||
List<DropDownItem> getDropDownItemList = [
|
||||
DropDownItem(itemTitle: "全部事件", itemValue: '0', isCheked: false),
|
||||
DropDownItem(itemTitle: "开锁事件", itemValue: '1', isCheked: false),
|
||||
DropDownItem(itemTitle: "异常事件", itemValue: '2', isCheked: false),
|
||||
DropDownItem(itemTitle: "门锁事件", itemValue: '3', isCheked: false),
|
||||
DropDownItem(itemTitle: "视频事件", itemValue: '4', isCheked: false),
|
||||
];
|
||||
|
||||
var currentStep = 0.obs;
|
||||
|
||||
DoorLockLogState() {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
abstract class Api {
|
||||
// static String baseAddress = "https://pre.lock.star-lock.cn"; //预发布环境
|
||||
static String baseAddress = "https://dev.lock.star-lock.cn"; //联调环境
|
||||
static String baseAddress = "https://pre.lock.star-lock.cn"; //预发布环境
|
||||
// static String baseAddress = "https://dev.lock.star-lock.cn"; //联调环境
|
||||
// static String baseAddress = "http://192.168.1.15:8022"; //谢总本地
|
||||
// static String baseAddress = "https://ge.lock.star-lock.cn"; //葛工开发环境地址
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ class Header extends StatelessWidget {
|
||||
'今天',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 22.sp,
|
||||
fontSize: 24.sp,
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
|
||||
14
star_lock/lib/tools/menuItem/dropDownItem.dart
Normal file
14
star_lock/lib/tools/menuItem/dropDownItem.dart
Normal file
@ -0,0 +1,14 @@
|
||||
/// 通用菜单项
|
||||
class DropDownItem {
|
||||
// 显示的文本
|
||||
String itemTitle = '';
|
||||
// 选中的值
|
||||
dynamic itemValue;
|
||||
// 是否选中
|
||||
bool isCheked = false;
|
||||
|
||||
DropDownItem(
|
||||
{required this.itemTitle,
|
||||
required this.itemValue,
|
||||
required this.isCheked});
|
||||
}
|
||||
161
star_lock/lib/tools/menuItem/xsDropDownWidget.dart
Normal file
161
star_lock/lib/tools/menuItem/xsDropDownWidget.dart
Normal file
@ -0,0 +1,161 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/tools/menuItem/dropDownItem.dart';
|
||||
|
||||
/// @author baorant
|
||||
/// @创建时间:2024/4/11
|
||||
/// 下拉菜单按钮组件
|
||||
class XSDropDownWidget extends StatefulWidget {
|
||||
// 显示的菜单项
|
||||
List<DropDownItem> items = [];
|
||||
// 当前选中的值
|
||||
final dynamic value;
|
||||
// 选择框前的标题
|
||||
final String? title;
|
||||
// 提示语
|
||||
final String tooltip;
|
||||
// 选中数据的回调事件
|
||||
final ValueChanged<dynamic>? valueChanged;
|
||||
XSDropDownWidget(
|
||||
{Key? key,
|
||||
required this.items,
|
||||
this.value,
|
||||
this.valueChanged,
|
||||
this.title,
|
||||
this.tooltip = "点击选择"})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<XSDropDownWidget> createState() => _XSDropDownWidgetState();
|
||||
}
|
||||
|
||||
class _XSDropDownWidgetState extends State<XSDropDownWidget> {
|
||||
String label = '请选择';
|
||||
// 是否展开下拉按钮
|
||||
bool isExpand = false;
|
||||
// 当前的值
|
||||
dynamic currentValue;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
currentValue = widget.value;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
/// 根据当前的value处理当前文本显示
|
||||
void initTitle() {
|
||||
if (currentValue != null) {
|
||||
// 有值查值
|
||||
for (DropDownItem item in widget.items) {
|
||||
if (item.itemValue == currentValue) {
|
||||
label = item.itemTitle;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 没值默认取第一个
|
||||
if (widget.items.isNotEmpty) {
|
||||
label = widget.items[0].itemTitle;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
initTitle();
|
||||
return Wrap(
|
||||
children: [
|
||||
if (widget.title != null)
|
||||
Text(widget.title!,
|
||||
style: TextStyle(
|
||||
fontSize: 26.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w600,
|
||||
)),
|
||||
PopupMenuButton<String>(
|
||||
color: Colors.white,
|
||||
// initialValue: currentValue,
|
||||
tooltip: widget.tooltip,
|
||||
offset: const Offset(0, 30),
|
||||
enableFeedback: true,
|
||||
child: Listener(
|
||||
// 使用listener事件能够继续传递
|
||||
onPointerDown: (event) {
|
||||
setState(() {
|
||||
isExpand = !isExpand;
|
||||
});
|
||||
},
|
||||
child: Wrap(
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 24.sp,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
isExpand
|
||||
? const Icon(Icons.arrow_drop_up)
|
||||
: const Icon(Icons.arrow_drop_down)
|
||||
],
|
||||
),
|
||||
),
|
||||
onSelected: (value) {
|
||||
widget.valueChanged?.call(value);
|
||||
setState(() {
|
||||
currentValue = value;
|
||||
isExpand = !isExpand;
|
||||
});
|
||||
},
|
||||
onCanceled: () {
|
||||
// 取消展开
|
||||
setState(() {
|
||||
isExpand = false;
|
||||
});
|
||||
},
|
||||
itemBuilder: (context) {
|
||||
return widget.items.map((item) {
|
||||
return PopupMenuItem<String>(
|
||||
value: item.itemValue,
|
||||
child: Container(
|
||||
margin:
|
||||
EdgeInsets.only(left: 0.w, right: 0, top: 0, bottom: 0),
|
||||
color: item.itemValue == currentValue
|
||||
? AppColors.mainColor
|
||||
: null, // 设置选中项背景色为蓝色
|
||||
child: Text(
|
||||
item.itemTitle,
|
||||
style: TextStyle(
|
||||
color: item.itemValue == currentValue
|
||||
? Colors.white
|
||||
: Colors.black, // 设置选中项文字颜色为白色
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
},
|
||||
// itemBuilder: (context) {
|
||||
// return widget.items
|
||||
// .map(
|
||||
// (item) => item.itemValue == currentValue
|
||||
// ? PopupMenuItem<String>(
|
||||
// value: item.itemValue,
|
||||
// child: Text(
|
||||
// item.itemTitle,
|
||||
// style: TextStyle(color: AppColors.mainColor),
|
||||
// ),
|
||||
// )
|
||||
// : PopupMenuItem<String>(
|
||||
// value: item.itemValue,
|
||||
// child: Text(item.itemTitle),
|
||||
// ),
|
||||
// )
|
||||
// .toList();
|
||||
// },
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user