添加 考勤申请页面

添加 日期选择器
hmxc
张萌 4 years ago
parent 1637228100
commit 41dc11a8a6

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/style/app_style.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:common_utils/common_utils.dart'; import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -19,6 +20,19 @@ class ClockInOutMainPage extends StatefulWidget {
class _ClockInOutMainPageState extends State<ClockInOutMainPage> { class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
EasyRefreshController _refreshController; EasyRefreshController _refreshController;
Timer _clockSetState; 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 @override
void initState() { void initState() {
super.initState(); super.initState();
@ -80,7 +94,11 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
} }
Widget _buildClock() { Widget _buildClock() {
return Container( return GestureDetector(
onTap: () {
canTap ? BotToast.showText(text: '打卡成功') : null;
},
child: Container(
width: 400.w, width: 400.w,
height: 400.w, height: 400.w,
alignment: Alignment.center, alignment: Alignment.center,
@ -104,6 +122,7 @@ class _ClockInOutMainPageState extends State<ClockInOutMainPage> {
.make() .make()
], ],
), ),
).material(),
); );
} }

@ -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_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/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/common/aku_scaffold.dart';
import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.dart'; import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
class ClockInOutPage extends StatefulWidget { class ClockInOutPage extends StatefulWidget {
ClockInOutPage({Key key}) : super(key: key); ClockInOutPage({Key key}) : super(key: key);
@ -32,6 +36,17 @@ class _ClockInOutPageState extends State<ClockInOutPage>
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AkuScaffold( return AkuScaffold(
title: '考勤管理', 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( appBarBottom: PreferredSize(
child: AkuTabBar(controller: _tabController, tabs: _tabs), child: AkuTabBar(controller: _tabController, tabs: _tabs),
preferredSize: Size.fromHeight(88.w), preferredSize: Size.fromHeight(88.w),

@ -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<WorkApplyPage> {
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<TextInputFormatter> 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,
),
),
],
),
);
}
}

@ -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<BeeCustomPicker> {
@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,
);
}
}

@ -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<DateTime> 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<DateTime> 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(),
);
}
}
Loading…
Cancel
Save