From 41dc11a8a6c5013ae27ddc9b5e13f79fc4f2cbda Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Sun, 23 May 2021 20:13:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E8=80=83=E5=8B=A4?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E9=A1=B5=E9=9D=A2=20=E6=B7=BB=E5=8A=A0=20?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E9=80=89=E6=8B=A9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clock_in_out/clock_in_out_main_page.dart | 67 ++++-- .../clock_in_out/clock_in_out_page.dart | 15 ++ .../clock_in_out/work_apply_page.dart | 218 ++++++++++++++++++ lib/ui/widgets/common/bee_custom_picker.dart | 43 ++++ lib/ui/widgets/common/bee_date_picker.dart | 74 ++++++ 5 files changed, 393 insertions(+), 24 deletions(-) create mode 100644 lib/ui/manage_pages/clock_in_out/work_apply_page.dart create mode 100644 lib/ui/widgets/common/bee_custom_picker.dart create mode 100644 lib/ui/widgets/common/bee_date_picker.dart diff --git a/lib/ui/manage_pages/clock_in_out/clock_in_out_main_page.dart b/lib/ui/manage_pages/clock_in_out/clock_in_out_main_page.dart index 8af87fe..9461f86 100644 --- a/lib/ui/manage_pages/clock_in_out/clock_in_out_main_page.dart +++ b/lib/ui/manage_pages/clock_in_out/clock_in_out_main_page.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/utils/weekdays_to_chinese.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -19,6 +20,19 @@ class ClockInOutMainPage extends StatefulWidget { class _ClockInOutMainPageState extends State { EasyRefreshController _refreshController; Timer _clockSetState; + DateTime _lastPressed; + bool get canTap { + if (_lastPressed == null || + DateTime.now().difference(_lastPressed) > Duration(seconds: 15)) { + //两次点击间隔超过15秒重新计算 + _lastPressed = DateTime.now(); + return true; + } + + BotToast.showText(text: '15s内不可再次打卡'); + return false; + } + @override void initState() { super.initState(); @@ -80,30 +94,35 @@ class _ClockInOutMainPageState extends State { } Widget _buildClock() { - return Container( - width: 400.w, - height: 400.w, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(200.w), - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [Color(0xFF50EAA0), Color(0xFF2EA9A2)]), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - '打卡'.text.size(56.sp).color(Colors.white).bold.make(), - 20.w.heightBox, - DateUtil.formatDate(DateTime.now(), format: 'HH:mm:ss') - .text - .size(36.sp) - .color(Color(0x99FFFFFF)) - .bold - .make() - ], - ), + return GestureDetector( + onTap: () { + canTap ? BotToast.showText(text: '打卡成功') : null; + }, + child: Container( + width: 400.w, + height: 400.w, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(200.w), + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [Color(0xFF50EAA0), Color(0xFF2EA9A2)]), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + '打卡'.text.size(56.sp).color(Colors.white).bold.make(), + 20.w.heightBox, + DateUtil.formatDate(DateTime.now(), format: 'HH:mm:ss') + .text + .size(36.sp) + .color(Color(0x99FFFFFF)) + .bold + .make() + ], + ), + ).material(), ); } diff --git a/lib/ui/manage_pages/clock_in_out/clock_in_out_page.dart b/lib/ui/manage_pages/clock_in_out/clock_in_out_page.dart index fbba5e9..db0fb89 100644 --- a/lib/ui/manage_pages/clock_in_out/clock_in_out_page.dart +++ b/lib/ui/manage_pages/clock_in_out/clock_in_out_page.dart @@ -1,9 +1,13 @@ +import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/ui/manage_pages/clock_in_out/clock_in_out_main_page.dart'; import 'package:aku_community_manager/ui/manage_pages/clock_in_out/clock_in_out_view.dart'; +import 'package:aku_community_manager/ui/manage_pages/clock_in_out/work_apply_page.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; class ClockInOutPage extends StatefulWidget { ClockInOutPage({Key key}) : super(key: key); @@ -32,6 +36,17 @@ class _ClockInOutPageState extends State Widget build(BuildContext context) { return AkuScaffold( title: '考勤管理', + actions: [ + Center( + child: Padding( + padding: EdgeInsets.symmetric(vertical: 24.w,horizontal: 32.w), + child: InkWell(child: '工作申请'.text.size(30.sp).color(kTextPrimaryColor).make(),onTap: (){ + Get.to(()=>WorkApplyPage()); + },), + ), + ), + + ], appBarBottom: PreferredSize( child: AkuTabBar(controller: _tabController, tabs: _tabs), preferredSize: Size.fromHeight(88.w), diff --git a/lib/ui/manage_pages/clock_in_out/work_apply_page.dart b/lib/ui/manage_pages/clock_in_out/work_apply_page.dart new file mode 100644 index 0000000..9067543 --- /dev/null +++ b/lib/ui/manage_pages/clock_in_out/work_apply_page.dart @@ -0,0 +1,218 @@ +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/aku_divider.dart'; +import 'package:aku_community_manager/ui/widgets/app_widgets/aku_single_check_button.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_community_manager/ui/widgets/common/bee_date_picker.dart'; +import 'package:aku_community_manager/ui/widgets/inner/aku_bottom_button.dart'; +import 'package:common_utils/common_utils.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class WorkApplyPage extends StatefulWidget { + WorkApplyPage({Key key}) : super(key: key); + + @override + _WorkApplyPageState createState() => _WorkApplyPageState(); +} + +class _WorkApplyPageState extends State { + int _type = 1; //请假为1 加班为2 + + TextEditingController _nameController; + TextEditingController _positionController; + TextEditingController _phoneController; + DateTime _beginTime ; + DateTime _endTime ; + + @override + void initState() { + super.initState(); + _nameController = TextEditingController(); + _positionController = TextEditingController(); + _phoneController = TextEditingController(); + } + + @override + void dispose() { + _nameController?.dispose(); + _positionController?.dispose(); + _phoneController?.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return AkuScaffold( + title: '填写申请', + backgroundColor: Colors.white, + body: ListView( + padding: EdgeInsets.all(32.w), + children: [ + _headType(), + _inputRowTile('姓名', _nameController), + _inputRowTile('职位', _positionController), + _inputRowTile('联系方式', _phoneController), + _timePick(), + ], + ), + bottom: AkuBottomButton( + title: '确认提交', + onTap: () {}, + ), + ); + } + + Widget _headType() { + return Container( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '申请类型'.text.size(32.sp).color(kTextPrimaryColor).make(), + 40.w.heightBox, + Row( + children: [ + AkuSingleCheckButton( + text: '请假', + value: 1, + gropValue: _type, + onPressed: () { + _type = 1; + setState(() {}); + }, + ), + 20.w.widthBox, + AkuSingleCheckButton( + text: '加班', + value: 2, + gropValue: _type, + onPressed: () { + _type = 2; + setState(() {}); + }, + ) + ], + ) + ], + ), + ); + } + + Widget _timePick() { + return Container( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 40.w.heightBox, + '申请时间'.text.size(32.sp).color(kTextPrimaryColor).bold.make(), + 40.w.heightBox, + Row( + children: [ + MaterialButton( + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + height: 120.w, + onPressed: () async { + DateTime date = await BeeDatePicker.pick( + DateTime.now(), + mode: CupertinoDatePickerMode.dateAndTime, + min: DateTime.now().subtract(Duration(seconds: 1)), + max: DateTime.now().add(Duration(days: 30)), + ); + if (date != null) { + _beginTime = date; + setState(() {}); + } + }, + child: Text( + _beginTime == null + ? '请选择开始时间' + : DateUtil.formatDate( + _beginTime, + format: 'yyyy-MM-dd HH:mm', + ), + style: TextStyle( + color: kTextSubColor, + ), + ), + ).expand(), + Icon(Icons.arrow_forward), + MaterialButton( + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + height: 120.w, + onPressed: () async { + DateTime date = await BeeDatePicker.pick( + _beginTime == null ? DateTime.now() : _beginTime, + min: _beginTime == null + ? DateTime.now().subtract(Duration(seconds: 1)) + : _beginTime, + max: _beginTime == null + ? DateTime.now().add(Duration(days: 1)) + : (_beginTime).add(Duration(days: 1)), + mode: CupertinoDatePickerMode.dateAndTime, + ); + if (date != null) { + _endTime = date; + setState(() {}); + } + }, + child: Text( + _endTime == null + ? '请选择结束时间' + : DateUtil.formatDate( + _endTime, + format: 'yyyy-MM-dd HH:mm', + ), + style: TextStyle( + color: kTextSubColor, + ), + ), + ).expand(), + ], + ), + 16.w.heightBox, + AkuDivider.horizontal(), + ], + ), + ); + } + + Widget _inputRowTile(String title, TextEditingController controller, + {String hintText, List formatters}) { + return Container( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 40.w.heightBox, + title.text.size(28.sp).color(kTextPrimaryColor).make(), + 32.w.heightBox, + TextField( + inputFormatters: formatters, + textAlign: TextAlign.start, + onChanged: (value) { + controller.text = value; + setState(() {}); + }, + decoration: InputDecoration( + hintText: hintText ?? '', + isDense: true, + contentPadding: EdgeInsets.zero, + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide(color: Color(0xFFE8E8E8), width: 2.w), + ), + ), + style: TextStyle( + fontSize: 36.sp, + fontWeight: FontWeight.bold, + color: kTextPrimaryColor, + ), + ), + ], + ), + ); + } +} diff --git a/lib/ui/widgets/common/bee_custom_picker.dart b/lib/ui/widgets/common/bee_custom_picker.dart new file mode 100644 index 0000000..ef22dbb --- /dev/null +++ b/lib/ui/widgets/common/bee_custom_picker.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; + +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class BeeCustomPicker extends StatefulWidget { + final Widget body; + final VoidCallback onPressed; + BeeCustomPicker({Key key, this.body,@required this.onPressed}) : super(key: key); + + @override + _BeeCustomPickerState createState() => _BeeCustomPickerState(); +} + +class _BeeCustomPickerState extends State { + @override + Widget build(BuildContext context) { + return SizedBox( + child: Material( + borderRadius: BorderRadius.vertical(top: Radius.circular(10)), + child: Column( + children: [ + SizedBox( + height: 48, + child: NavigationToolbar( + leading: TextButton( + onPressed: Get.back, + child: '取消'.text.black.make(), + ), + trailing: TextButton( + onPressed: widget.onPressed, + child: '确定'.text.black.make(), + ), + ), + ), + widget.body??Container(), + ], + ), + ), + height: Get.height / 3, + ); + } +} diff --git a/lib/ui/widgets/common/bee_date_picker.dart b/lib/ui/widgets/common/bee_date_picker.dart new file mode 100644 index 0000000..6f74884 --- /dev/null +++ b/lib/ui/widgets/common/bee_date_picker.dart @@ -0,0 +1,74 @@ +import 'package:aku_community_manager/ui/widgets/common/bee_custom_picker.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'package:get/get.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class BeeDatePicker { + static Future pick( + DateTime initDate, { + CupertinoDatePickerMode mode = CupertinoDatePickerMode.date, + DateTime min, + DateTime max, + }) async { + return await Get.bottomSheet(_BeeDatePicker( + date: initDate, + mode: mode, + min: min ?? DateTime.now().subtract(Duration(days: 1)), + max: max??DateTime.now().subtract(Duration(days: 10)), + )); + } + + static Future timePicker(DateTime initDate) async { + return await Get.bottomSheet(_BeeDatePicker( + date: initDate, + min: initDate, + max: initDate.add(Duration(days: 7)), + mode: CupertinoDatePickerMode.dateAndTime, + )); + } +} + +class _BeeDatePicker extends StatefulWidget { + final DateTime date; + final bool use24H; + final DateTime max; + final DateTime min; + final CupertinoDatePickerMode mode; + _BeeDatePicker({ + Key key, + @required this.date, + this.use24H = false, + this.max, + this.min, + this.mode, + }) : super(key: key); + + @override + __BeeDatePickerState createState() => __BeeDatePickerState(); +} + +class __BeeDatePickerState extends State<_BeeDatePicker> { + DateTime _date = DateTime.now(); + @override + void initState() { + super.initState(); + _date = widget.date; + } + + @override + Widget build(BuildContext context) { + return BeeCustomPicker( + onPressed: () => Get.back(result: _date), + body: CupertinoDatePicker( + use24hFormat: widget.use24H, + maximumDate: widget.max, + minimumDate: widget.min, + initialDateTime: _date, + onDateTimeChanged: (date) => _date = date, + mode: widget.mode ?? CupertinoDatePickerMode.date, + ).expand(), + ); + } +}