- Added a floating action button to the Layout widget for better accessibility. - Updated the left bar navigation items for clarity and consistency. - Introduced Daily Progress Report and Daily Task Planning screens with comprehensive UI. - Implemented filtering and refreshing functionalities in task planning. - Improved user experience with better spacing and layout adjustments. - Updated pubspec.yaml to include new dependencies for image handling and path management.
246 lines
9.9 KiB
Dart
246 lines
9.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:marco/controller/dashboard/add_employee_controller.dart';
|
|
import 'package:marco/helpers/theme/app_theme.dart';
|
|
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
|
|
import 'package:marco/helpers/widgets/my_button.dart';
|
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
|
import 'package:marco/helpers/widgets/my_text.dart';
|
|
import 'package:marco/helpers/widgets/my_text_style.dart';
|
|
import 'package:marco/controller/dashboard/employees_screen_controller.dart';
|
|
class AddEmployeeBottomSheet extends StatefulWidget {
|
|
@override
|
|
_AddEmployeeBottomSheetState createState() => _AddEmployeeBottomSheetState();
|
|
}
|
|
|
|
class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
|
with UIMixin {
|
|
final AddEmployeeController controller = Get.put(AddEmployeeController());
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
|
|
return GetBuilder<AddEmployeeController>(
|
|
init: controller,
|
|
builder: (_) {
|
|
return SingleChildScrollView(
|
|
padding: MediaQuery.of(context).viewInsets,
|
|
child: Container(
|
|
padding:
|
|
const EdgeInsets.only(top: 12, left: 24, right: 24, bottom: 24),
|
|
decoration: BoxDecoration(
|
|
color: theme.cardColor,
|
|
borderRadius:
|
|
const BorderRadius.vertical(top: Radius.circular(24)),
|
|
boxShadow: const [
|
|
BoxShadow(
|
|
color: Colors.black26,
|
|
blurRadius: 10,
|
|
spreadRadius: 1,
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Drag handle bar
|
|
Center(
|
|
child: Container(
|
|
width: 40,
|
|
height: 4,
|
|
margin: const EdgeInsets.only(bottom: 12),
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey.shade400,
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
MyText.titleMedium(
|
|
"Add Employee",
|
|
fontWeight: 600,
|
|
fontSize: 18,
|
|
),
|
|
],
|
|
),
|
|
MySpacing.height(24),
|
|
|
|
Form(
|
|
key: controller.basicValidator.formKey,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildLabel("First Name"),
|
|
MySpacing.height(8),
|
|
_buildTextField(
|
|
hint: "eg: John",
|
|
controller: controller.basicValidator
|
|
.getController('first_name')!,
|
|
validator: controller.basicValidator
|
|
.getValidation('first_name'),
|
|
keyboardType: TextInputType.name,
|
|
),
|
|
MySpacing.height(24),
|
|
|
|
_buildLabel("Last Name"),
|
|
MySpacing.height(8),
|
|
_buildTextField(
|
|
hint: "eg: Doe",
|
|
controller: controller.basicValidator
|
|
.getController('last_name')!,
|
|
validator: controller.basicValidator
|
|
.getValidation('last_name'),
|
|
keyboardType: TextInputType.name,
|
|
),
|
|
MySpacing.height(24),
|
|
|
|
_buildLabel("Phone Number"),
|
|
MySpacing.height(8),
|
|
_buildTextField(
|
|
hint: "eg: +91 9876543210",
|
|
controller: controller.basicValidator
|
|
.getController('phone_number')!,
|
|
validator: controller.basicValidator
|
|
.getValidation('phone_number'),
|
|
keyboardType: TextInputType.phone,
|
|
),
|
|
MySpacing.height(24),
|
|
|
|
_buildLabel("Select Gender"),
|
|
MySpacing.height(8),
|
|
DropdownButtonFormField<Gender>(
|
|
value: controller.selectedGender,
|
|
dropdownColor: contentTheme.background,
|
|
isDense: true,
|
|
menuMaxHeight: 200,
|
|
decoration: _inputDecoration("Select Gender"),
|
|
icon: const Icon(Icons.expand_more, size: 20),
|
|
items: Gender.values
|
|
.map(
|
|
(gender) => DropdownMenuItem<Gender>(
|
|
value: gender,
|
|
child: MyText.labelMedium(
|
|
gender.name.capitalizeFirst!),
|
|
),
|
|
)
|
|
.toList(),
|
|
onChanged: controller.onGenderSelected,
|
|
),
|
|
MySpacing.height(24),
|
|
|
|
_buildLabel("Select Role"),
|
|
MySpacing.height(8),
|
|
DropdownButtonFormField<String>(
|
|
value: controller.selectedRoleId,
|
|
dropdownColor: contentTheme.background,
|
|
isDense: true,
|
|
decoration: _inputDecoration("Select Role"),
|
|
icon: const Icon(Icons.expand_more, size: 20),
|
|
items: controller.roles
|
|
.map(
|
|
(role) => DropdownMenuItem<String>(
|
|
value: role['id'],
|
|
child: Text(role['name']),
|
|
),
|
|
)
|
|
.toList(),
|
|
onChanged: controller.onRoleSelected,
|
|
),
|
|
MySpacing.height(24),
|
|
|
|
// Buttons row
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
MyButton.text(
|
|
onPressed: () => Navigator.pop(context),
|
|
padding: MySpacing.xy(20, 16),
|
|
child: MyText.bodySmall("Cancel"),
|
|
),
|
|
MySpacing.width(12),
|
|
MyButton(
|
|
onPressed: () async {
|
|
if (controller.basicValidator.validateForm()) {
|
|
final success =
|
|
await controller.createEmployees();
|
|
if (success) {
|
|
// Call refresh logic here via callback or GetX
|
|
final employeeController =
|
|
Get.find<EmployeesScreenController>();
|
|
final projectId =
|
|
employeeController.selectedProjectId;
|
|
if (projectId == null) {
|
|
await employeeController
|
|
.fetchAllEmployees();
|
|
} else {
|
|
await employeeController
|
|
.fetchEmployeesByProject(projectId);
|
|
}
|
|
employeeController
|
|
.update(['employee_screen_controller']);
|
|
|
|
// Optionally clear form
|
|
controller.basicValidator.getController("first_name")?.clear();
|
|
controller.basicValidator.getController("last_name")?.clear();
|
|
controller.basicValidator.getController("phone_number")?.clear();
|
|
|
|
controller.selectedGender = null;
|
|
controller.selectedRoleId = null;
|
|
controller.update();
|
|
}
|
|
}
|
|
},
|
|
elevation: 0,
|
|
padding: MySpacing.xy(20, 16),
|
|
backgroundColor: Colors.blueAccent,
|
|
borderRadiusAll: AppStyle.buttonRadius.medium,
|
|
child: MyText.bodySmall("Save",
|
|
color: contentTheme.onPrimary),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _buildLabel(String text) => MyText.labelMedium(text);
|
|
|
|
Widget _buildTextField({
|
|
required TextEditingController controller,
|
|
required String? Function(String?)? validator,
|
|
required String hint,
|
|
TextInputType keyboardType = TextInputType.text,
|
|
}) {
|
|
return TextFormField(
|
|
controller: controller,
|
|
validator: validator,
|
|
keyboardType: keyboardType,
|
|
decoration: _inputDecoration(hint),
|
|
);
|
|
}
|
|
|
|
InputDecoration _inputDecoration(String hint) {
|
|
return InputDecoration(
|
|
hintText: hint,
|
|
hintStyle: MyTextStyle.bodySmall(xMuted: true),
|
|
border: outlineInputBorder,
|
|
enabledBorder: outlineInputBorder,
|
|
focusedBorder: focusedInputBorder,
|
|
contentPadding: MySpacing.all(16),
|
|
isCollapsed: true,
|
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
|
);
|
|
}
|
|
}
|