tabbar
This commit is contained in:
parent
d12e3dea84
commit
c93cc46da1
|
|
@ -0,0 +1,150 @@
|
||||||
|
import 'package:cashier_reserve/common/base/ui.dart';
|
||||||
|
import 'package:cashier_reserve/common/channel/call_log_model.dart';
|
||||||
|
import 'package:cashier_reserve/home/reserve_view_model.dart';
|
||||||
|
|
||||||
|
class ReserveLeftContentView extends StatelessWidget {
|
||||||
|
final ReserveViewModel provider;
|
||||||
|
const ReserveLeftContentView({super.key, required this.provider});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: SizedBox(
|
||||||
|
width: 430,
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: provider.callLogs?.length ?? 0,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return _buildCallRecordItem(context, provider.callLogs?[index]);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.fromLTRB(20, 10, 20, 15),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {},
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
color: const Color(0xff318AFE),
|
||||||
|
),
|
||||||
|
width: 300,
|
||||||
|
height: 36,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Image.asset(
|
||||||
|
'images/reserve/create.png',
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
"创建订单",
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 14),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// _buildCallRecordItem 通话记录item
|
||||||
|
Widget _buildCallRecordItem(BuildContext context, CallLogModel? model) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.fromLTRB(15, 15, 15, 5),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Image.asset(
|
||||||
|
(model?.type ?? 0) == 3
|
||||||
|
? "images/reserve/phone_fail.png"
|
||||||
|
: "images/reserve/phone_suc.png",
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
model?.time ?? "",
|
||||||
|
style:
|
||||||
|
const TextStyle(color: Color(0xff999999), fontSize: 12),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
model?.name ?? "未知电话",
|
||||||
|
style:
|
||||||
|
const TextStyle(color: Color(0xff333333), fontSize: 14),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
model?.number ?? "",
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Color(0xff333333), fontSize: 14),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 15,
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
"已消费0单",
|
||||||
|
style:
|
||||||
|
TextStyle(color: Color(0xff333333), fontSize: 14),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 15,
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
"已撤0单",
|
||||||
|
style:
|
||||||
|
TextStyle(color: Color(0xff333333), fontSize: 14),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Expanded(child: SizedBox()),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {},
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
border:
|
||||||
|
Border.all(color: const Color(0xff318AFE), width: 1),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.fromLTRB(20, 7, 20, 7),
|
||||||
|
child: const Text(
|
||||||
|
"处理",
|
||||||
|
style: TextStyle(color: Color(0xff318AFE), fontSize: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: 1,
|
||||||
|
color: const Color(0xffededed),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
import 'package:cashier_reserve/common/base/ui.dart';
|
||||||
|
import 'package:cashier_reserve/common/print/print.dart';
|
||||||
|
import 'package:cashier_reserve/home/reserve_view_model.dart';
|
||||||
|
|
||||||
|
class ReserveRightContentView extends StatelessWidget {
|
||||||
|
final ReserveViewModel provider;
|
||||||
|
final TabController? tabController;
|
||||||
|
|
||||||
|
const ReserveRightContentView(
|
||||||
|
{super.key, required this.provider, this.tabController});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_buildTabBar(context),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildTabBar(BuildContext context) {
|
||||||
|
if ((provider.tableAreaList?.length ?? 0) == 0) {
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
|
||||||
|
return TabBar(
|
||||||
|
tabs:
|
||||||
|
provider.tableAreaList!.map((e) => Tab(text: e?.name ?? '')).toList(),
|
||||||
|
controller: tabController,
|
||||||
|
isScrollable: true,
|
||||||
|
labelColor: Colors.blue,
|
||||||
|
unselectedLabelColor: Colors.grey,
|
||||||
|
indicatorColor: Colors.blue,
|
||||||
|
indicatorSize: TabBarIndicatorSize.label,
|
||||||
|
indicatorWeight: 2,
|
||||||
|
labelPadding: const EdgeInsets.only(left: 10, right: 10),
|
||||||
|
onTap: (index) {
|
||||||
|
yjPrint("tab index: $index");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,21 +1,34 @@
|
||||||
import 'package:cashier_reserve/common/base/ui.dart';
|
import 'package:cashier_reserve/common/base/ui.dart';
|
||||||
import 'package:cashier_reserve/common/base/ui_model.dart';
|
import 'package:cashier_reserve/common/base/ui_model.dart';
|
||||||
import 'package:cashier_reserve/common/channel/call_log_model.dart';
|
|
||||||
import 'package:cashier_reserve/common/print/print.dart';
|
import 'package:cashier_reserve/common/print/print.dart';
|
||||||
|
import 'package:cashier_reserve/home/reserve_left_content_view.dart';
|
||||||
|
import 'package:cashier_reserve/home/reserve_right_content_view.dart';
|
||||||
import 'package:cashier_reserve/home/reserve_view_model.dart';
|
import 'package:cashier_reserve/home/reserve_view_model.dart';
|
||||||
|
|
||||||
import '../common/base/provider.dart';
|
import '../common/base/provider.dart';
|
||||||
|
|
||||||
class ReserveView extends BaseUI {
|
class ReserveView extends BaseUI with TickerProviderStateMixin {
|
||||||
|
TabController? tabController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
tabController?.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget buildBody(BuildContext context) {
|
Widget buildBody(BuildContext context) {
|
||||||
ReserveViewModel provider =
|
ReserveViewModel provider =
|
||||||
getProvider(context, listen: false) as ReserveViewModel;
|
getProvider(context, listen: false) as ReserveViewModel;
|
||||||
return Column(
|
|
||||||
children: [
|
return SizedBox(
|
||||||
_buildTopDateBar(context, provider),
|
width: double.infinity,
|
||||||
Expanded(child: _buildContentView(context, provider)),
|
child: Column(
|
||||||
],
|
children: [
|
||||||
|
_buildTopDateBar(context, provider),
|
||||||
|
Expanded(child: _buildContentView(context, provider)),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,160 +114,31 @@ class ReserveView extends BaseUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildContentView(BuildContext context, ReserveViewModel provider) {
|
Widget _buildContentView(BuildContext context, ReserveViewModel provider) {
|
||||||
|
if ((provider.tableAreaList?.length ?? 0) > 0) {
|
||||||
|
if (tabController == null) {
|
||||||
|
tabController =
|
||||||
|
TabController(vsync: this, length: provider.tableAreaList!.length);
|
||||||
|
} else {
|
||||||
|
if (tabController!.length != provider.tableAreaList!.length) {
|
||||||
|
tabController!.dispose();
|
||||||
|
tabController = TabController(
|
||||||
|
vsync: this, length: provider.tableAreaList!.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
_buildLeftContent(context, provider),
|
ReserveLeftContentView(provider: provider),
|
||||||
Expanded(child: _buildRightContent(context, provider)),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildLeftContent(BuildContext context, ReserveViewModel provider) {
|
|
||||||
yjPrint("callLogs length: ${provider.callLogs?.length}");
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SizedBox(
|
child: ReserveRightContentView(
|
||||||
width: 430,
|
provider: provider,
|
||||||
child: ListView.builder(
|
tabController: tabController,
|
||||||
itemCount: provider.callLogs?.length ?? 0,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return _buildCallRecordItem(context, provider.callLogs?[index]);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
)),
|
),
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.fromLTRB(20, 10, 20, 15),
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () {},
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(5),
|
|
||||||
color: const Color(0xff318AFE),
|
|
||||||
),
|
|
||||||
width: 300,
|
|
||||||
height: 36,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Image.asset(
|
|
||||||
'images/reserve/create.png',
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
"创建订单",
|
|
||||||
style: TextStyle(color: Colors.white, fontSize: 14),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildRightContent(BuildContext context, ReserveViewModel provider) {
|
|
||||||
return Container();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// _buildCallRecordItem 通话记录item
|
|
||||||
Widget _buildCallRecordItem(BuildContext context, CallLogModel? model) {
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.fromLTRB(15, 15, 15, 5),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Image.asset(
|
|
||||||
(model?.type ?? 0) == 3
|
|
||||||
? "images/reserve/phone_fail.png"
|
|
||||||
: "images/reserve/phone_suc.png",
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 2),
|
|
||||||
Text(
|
|
||||||
model?.time ?? "",
|
|
||||||
style:
|
|
||||||
const TextStyle(color: Color(0xff999999), fontSize: 12),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
model?.name ?? "未知电话",
|
|
||||||
style:
|
|
||||||
const TextStyle(color: Color(0xff333333), fontSize: 14),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 5),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
model?.number ?? "",
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Color(0xff333333), fontSize: 14),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 15,
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
"已消费0单",
|
|
||||||
style:
|
|
||||||
TextStyle(color: Color(0xff333333), fontSize: 14),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 15,
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
"已撤0单",
|
|
||||||
style:
|
|
||||||
TextStyle(color: Color(0xff333333), fontSize: 14),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const Expanded(child: SizedBox()),
|
|
||||||
InkWell(
|
|
||||||
onTap: () {},
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(5),
|
|
||||||
border:
|
|
||||||
Border.all(color: const Color(0xff318AFE), width: 1),
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.fromLTRB(20, 7, 20, 7),
|
|
||||||
child: const Text(
|
|
||||||
"处理",
|
|
||||||
style: TextStyle(color: Color(0xff318AFE), fontSize: 14),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
height: 1,
|
|
||||||
color: const Color(0xffededed),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildDateItem(BuildContext context, ReserveViewModel provider) {
|
Widget _buildDateItem(BuildContext context, ReserveViewModel provider) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
|
import 'package:cashier_reserve/common/base/ui.dart';
|
||||||
import 'package:cashier_reserve/common/base/ui_model.dart';
|
import 'package:cashier_reserve/common/base/ui_model.dart';
|
||||||
import 'package:cashier_reserve/common/channel/call_log_model.dart';
|
import 'package:cashier_reserve/common/channel/call_log_model.dart';
|
||||||
import 'package:cashier_reserve/common/channel/channel_manager.dart';
|
import 'package:cashier_reserve/common/channel/channel_manager.dart';
|
||||||
import 'package:cashier_reserve/common/manager/event_manager.dart';
|
import 'package:cashier_reserve/common/manager/event_manager.dart';
|
||||||
import 'package:cashier_reserve/common/print/print.dart';
|
import 'package:cashier_reserve/datas/reserve/table_area_model.dart';
|
||||||
import 'package:cashier_reserve/model/reserve_model.dart';
|
import 'package:cashier_reserve/model/reserve_model.dart';
|
||||||
|
|
||||||
class ReserveViewModel extends BaseUIModel {
|
class ReserveViewModel extends BaseUIModel {
|
||||||
Map<int, String> weekdayMap = {
|
Map<int, String> weekdayMap = {
|
||||||
1: "星期一",
|
1: "星期一",
|
||||||
2: "星期二",
|
2: "星期二",
|
||||||
|
|
@ -22,6 +23,9 @@ class ReserveViewModel extends BaseUIModel {
|
||||||
2: "后",
|
2: "后",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
List<TableAreaModel?>? _tableAreaList;
|
||||||
|
List<TableAreaModel?>? get tableAreaList => _tableAreaList;
|
||||||
|
|
||||||
List<CallLogModel?>? callLogs = [];
|
List<CallLogModel?>? callLogs = [];
|
||||||
|
|
||||||
ReserveViewModel() {
|
ReserveViewModel() {
|
||||||
|
|
@ -39,6 +43,7 @@ class ReserveViewModel extends BaseUIModel {
|
||||||
loadTableAreaList();
|
loadTableAreaList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loadCallLog() {
|
void loadCallLog() {
|
||||||
ChannelManager.getCallLog("getCallLog");
|
ChannelManager.getCallLog("getCallLog");
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +51,8 @@ class ReserveViewModel extends BaseUIModel {
|
||||||
void loadTableAreaList() async {
|
void loadTableAreaList() async {
|
||||||
final r = await ReserveModel.getShopTableAreaList();
|
final r = await ReserveModel.getShopTableAreaList();
|
||||||
|
|
||||||
yjPrint(r);
|
_tableAreaList = r;
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getCurrentDate() {
|
String getCurrentDate() {
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,12 @@ class MyApp extends StatelessWidget {
|
||||||
// 添加通用的Flutter本地化委托
|
// 添加通用的Flutter本地化委托
|
||||||
GlobalWidgetsLocalizations.delegate,
|
GlobalWidgetsLocalizations.delegate,
|
||||||
],
|
],
|
||||||
title: 'Flutter Demo',
|
title: '订餐系统',
|
||||||
supportedLocales: Platform.isIOS ? ios : an,
|
supportedLocales: Platform.isIOS ? ios : an,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
platform: TargetPlatform.iOS,
|
platform: TargetPlatform.iOS,
|
||||||
|
useMaterial3: false,
|
||||||
),
|
),
|
||||||
home: const RootView(),
|
home: const RootView(),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue