|
|
@ -1,6 +1,8 @@
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:aku_community_manager/provider/app_provider.dart';
|
|
|
|
import 'package:aku_community_manager/style/app_style.dart';
|
|
|
|
import 'package:aku_community_manager/style/app_style.dart';
|
|
|
|
|
|
|
|
import 'package:aku_community_manager/tools/user_tool.dart';
|
|
|
|
import 'package:aku_community_manager/utils/weekdays_to_chinese.dart';
|
|
|
|
import 'package:aku_community_manager/utils/weekdays_to_chinese.dart';
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
@ -40,6 +42,7 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
|
|
|
|
_clockSetState = Timer.periodic(Duration(seconds: 1), (_timer) {
|
|
|
|
_clockSetState = Timer.periodic(Duration(seconds: 1), (_timer) {
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
UserTool.appProvider.initClock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
@ -77,26 +80,44 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
|
|
|
|
64.w.heightBox,
|
|
|
|
64.w.heightBox,
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
_buildCard(0),
|
|
|
|
_buildCard(0, time: UserTool.appProvider.clockInTime),
|
|
|
|
Spacer(),
|
|
|
|
Spacer(),
|
|
|
|
_buildCard(1)
|
|
|
|
_buildCard(1, time: UserTool.appProvider.clockOutTime)
|
|
|
|
], //上班打卡为‘type’0.下班打卡为1
|
|
|
|
], //上班打卡为‘type’0.下班打卡为1
|
|
|
|
),
|
|
|
|
),
|
|
|
|
150.w.heightBox,
|
|
|
|
150.w.heightBox,
|
|
|
|
_buildClock(),
|
|
|
|
_buildClock(),
|
|
|
|
65.w.heightBox,
|
|
|
|
65.w.heightBox,
|
|
|
|
'今日工时'.text.size(24.sp).bold.color(kTextSubColor).make(),
|
|
|
|
'今日工时'.text.size(24.sp).bold.color(kTextSubColor).make(),
|
|
|
|
'共10小时13分钟'.text.size(24.sp).bold.color(kTextSubColor).make(),
|
|
|
|
'共$getWorkHours'.text.size(24.sp).bold.color(kTextSubColor).make(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clockInOut() {
|
|
|
|
|
|
|
|
switch (UserTool.appProvider.clockStatus) {
|
|
|
|
|
|
|
|
case WORKCLOCK.NOTIN:
|
|
|
|
|
|
|
|
UserTool.appProvider.setClockInTime(DateTime.now());
|
|
|
|
|
|
|
|
BotToast.showText(text: '上班打卡成功');
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WORKCLOCK.IN:
|
|
|
|
|
|
|
|
UserTool.appProvider.setClockOutTime(DateTime.now());
|
|
|
|
|
|
|
|
BotToast.showText(text: '下班打卡成功');
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WORKCLOCK.OUT:
|
|
|
|
|
|
|
|
BotToast.showText(text: '今日已打卡');
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
BotToast.showText(text: '未知错误');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildClock() {
|
|
|
|
Widget _buildClock() {
|
|
|
|
return GestureDetector(
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
onTap: () {
|
|
|
|
canTap ? BotToast.showText(text: '打卡成功') : null;
|
|
|
|
canTap ? clockInOut() : null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
child: Container(
|
|
|
|
width: 400.w,
|
|
|
|
width: 400.w,
|
|
|
@ -126,7 +147,7 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildCard(int type, {String time}) {
|
|
|
|
Widget _buildCard(int type, {DateTime time}) {
|
|
|
|
return Container(
|
|
|
|
return Container(
|
|
|
|
width: 296.w,
|
|
|
|
width: 296.w,
|
|
|
|
height: 131.w,
|
|
|
|
height: 131.w,
|
|
|
@ -138,9 +159,10 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
|
|
|
|
child: Row(
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
time.isEmptyOrNull
|
|
|
|
time == null
|
|
|
|
? SizedBox()
|
|
|
|
? SizedBox()
|
|
|
|
: Container(
|
|
|
|
: Container(
|
|
|
|
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 14.w),
|
|
|
|
width: 22.w,
|
|
|
|
width: 22.w,
|
|
|
|
height: 22.w,
|
|
|
|
height: 22.w,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
decoration: BoxDecoration(
|
|
|
@ -158,7 +180,7 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: time.isEmptyOrNull
|
|
|
|
children: time == null
|
|
|
|
? [
|
|
|
|
? [
|
|
|
|
Center(
|
|
|
|
Center(
|
|
|
|
child: '未打卡'
|
|
|
|
child: '未打卡'
|
|
|
@ -176,7 +198,7 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
|
|
|
|
.color(kTextSubColor)
|
|
|
|
.color(kTextSubColor)
|
|
|
|
.make(),
|
|
|
|
.make(),
|
|
|
|
12.w.heightBox,
|
|
|
|
12.w.heightBox,
|
|
|
|
DateUtil.formatDateStr(time, format: 'HH:mm:ss')
|
|
|
|
DateUtil.formatDate(time, format: 'HH:mm:ss')
|
|
|
|
.text
|
|
|
|
.text
|
|
|
|
.size(32.sp)
|
|
|
|
.size(32.sp)
|
|
|
|
.bold
|
|
|
|
.bold
|
|
|
@ -189,4 +211,13 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String get getWorkHours {
|
|
|
|
|
|
|
|
int _time = UserTool.appProvider.clockInTime
|
|
|
|
|
|
|
|
.difference(UserTool.appProvider.clockOutTime)
|
|
|
|
|
|
|
|
.inMinutes;
|
|
|
|
|
|
|
|
int _hour = _time ~/ 60;
|
|
|
|
|
|
|
|
int _min = _time % 60;
|
|
|
|
|
|
|
|
return '$_hour小时$_min分钟';
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|