1,新增下拉组件

2,门锁日志页面优化完善
This commit is contained in:
Daisy 2024-01-26 16:19:01 +08:00
parent c58ff3a827
commit 60614a53b1
7 changed files with 226 additions and 38 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -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,
),
),
],
),
),
],
),

View File

@ -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() {

View File

@ -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"; //

View File

@ -51,7 +51,7 @@ class Header extends StatelessWidget {
'今天',
style: TextStyle(
color: Colors.black,
fontSize: 22.sp,
fontSize: 24.sp,
fontWeight: FontWeight.w600),
),
),

View File

@ -0,0 +1,14 @@
///
class DropDownItem {
//
String itemTitle = '';
//
dynamic itemValue;
//
bool isCheked = false;
DropDownItem(
{required this.itemTitle,
required this.itemValue,
required this.isCheked});
}

View 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();
// },
)
],
);
}
}