增加下拉刷新功能

This commit is contained in:
GYJ
2024-11-27 16:31:20 +08:00
parent c6957c182f
commit 938a5df35f
4 changed files with 76 additions and 17 deletions

View File

@@ -3,6 +3,7 @@ import 'package:cashier_reserve/common/channel/call_log_model.dart';
import 'package:cashier_reserve/common/print/print.dart';
import 'package:cashier_reserve/data_model/reserve/reserve_log_model.dart';
import 'package:cashier_reserve/home/reserve_view_model.dart';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/cupertino.dart';
class ReserveLeftContentView extends StatelessWidget {
@@ -10,9 +11,7 @@ class ReserveLeftContentView extends StatelessWidget {
final double inputItemHeight = 36;
final ReserveViewModel provider;
const ReserveLeftContentView(
{super.key,
required this.provider});
const ReserveLeftContentView({super.key, required this.provider});
@override
Widget build(BuildContext context) {
@@ -75,11 +74,17 @@ class ReserveLeftContentView extends StatelessWidget {
Expanded(
child: SizedBox(
width: contentWidth,
child: ListView.builder(
itemCount: provider.callLogs?.length ?? 0,
itemBuilder: (context, index) {
return _buildCallRecordItem(context, provider.callLogs?[index]);
child: EasyRefresh(
onRefresh: () async {
provider.loadCallLog();
yjPrint("onRefresh");
},
child: ListView.builder(
itemCount: provider.callLogs?.length ?? 0,
itemBuilder: (context, index) {
return _buildCallRecordItem(context, provider.callLogs?[index]);
},
),
),
)),
Container(
@@ -122,7 +127,8 @@ class ReserveLeftContentView extends StatelessWidget {
/// _buildCallRecordItem 通话记录item
Widget _buildCallRecordItem(BuildContext context, CallLogModel? model) {
ReserveLogModel? reserveLogModel = provider.getReserveLogModel(model?.number ?? "");
ReserveLogModel? reserveLogModel =
provider.getReserveLogModel(model?.number ?? "");
return Container(
padding: const EdgeInsets.fromLTRB(15, 15, 15, 5),
child: Column(
@@ -168,16 +174,16 @@ class ReserveLeftContentView extends StatelessWidget {
),
Text(
"已消费${reserveLogModel?.consumeOrders ?? '0'}",
style:
const TextStyle(color: Color(0xff333333), fontSize: 14),
style: const TextStyle(
color: Color(0xff333333), fontSize: 14),
),
const SizedBox(
width: 15,
),
Text(
"已撤${reserveLogModel?.cancelOrders ?? '0'}",
style:
const TextStyle(color: Color(0xff333333), fontSize: 14),
style: const TextStyle(
color: Color(0xff333333), fontSize: 14),
),
],
),
@@ -713,7 +719,9 @@ class ReserveLeftContentView extends StatelessWidget {
],
),
),
const SizedBox(width: 10,),
const SizedBox(
width: 10,
),
SizedBox(
height: inputItemHeight,
width: itemWidth,
@@ -727,7 +735,10 @@ class ReserveLeftContentView extends StatelessWidget {
provider.updateBookingStandard(value ?? "table");
},
),
const Text('元/桌', style: TextStyle(fontSize: 12, color: Color(0xff666666)),),
const Text(
'元/桌',
style: TextStyle(fontSize: 12, color: Color(0xff666666)),
),
Radio<String>(
value: "person",
groupValue: provider.bookingStandardType,
@@ -735,7 +746,10 @@ class ReserveLeftContentView extends StatelessWidget {
provider.updateBookingStandard(value ?? "person");
},
),
const Text('元/人', style: TextStyle(fontSize: 12, color: Color(0xff666666)),),
const Text(
'元/人',
style: TextStyle(fontSize: 12, color: Color(0xff666666)),
),
],
),
)
@@ -787,7 +801,8 @@ class ReserveLeftContentView extends StatelessWidget {
);
}
Widget _buildBookingActionBtn(BuildContext context, String title, Function() onTap) {
Widget _buildBookingActionBtn(
BuildContext context, String title, Function() onTap) {
return InkWell(
onTap: onTap,
child: Container(
@@ -796,7 +811,10 @@ class ReserveLeftContentView extends StatelessWidget {
color: Colors.blue,
),
padding: const EdgeInsets.fromLTRB(20, 5, 20, 5),
child: Text(title, style: const TextStyle(color: Colors.white, fontSize: 14),),
child: Text(
title,
style: const TextStyle(color: Colors.white, fontSize: 14),
),
),
);
}