refactor: Replace MyButton with OutlinedButton and ElevatedButton in various bottom sheets for improved UI consistency
This commit is contained in:
parent
2c79d3eec8
commit
8f87161d74
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:marco/controller/task_planing/daily_task_planing_controller.dart';
|
import 'package:marco/controller/task_planing/daily_task_planing_controller.dart';
|
||||||
import 'package:marco/helpers/widgets/my_button.dart';
|
|
||||||
import 'package:marco/helpers/widgets/my_text.dart';
|
import 'package:marco/helpers/widgets/my_text.dart';
|
||||||
import 'package:marco/helpers/widgets/my_spacing.dart';
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
||||||
import 'package:marco/helpers/widgets/my_snackbar.dart';
|
import 'package:marco/helpers/widgets/my_snackbar.dart';
|
||||||
@ -197,16 +196,34 @@ class _AssignTaskBottomSheetState extends State<AssignTaskBottomSheet> {
|
|||||||
),
|
),
|
||||||
MySpacing.height(24),
|
MySpacing.height(24),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
MyButton(
|
OutlinedButton.icon(
|
||||||
|
onPressed: () => Get.back(),
|
||||||
|
icon: const Icon(Icons.close, color: Colors.red),
|
||||||
|
label: MyText.bodyMedium("Cancel", color: Colors.red),
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
side: const BorderSide(color: Colors.red),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 20, vertical: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ElevatedButton.icon(
|
||||||
onPressed: _onAssignTaskPressed,
|
onPressed: _onAssignTaskPressed,
|
||||||
backgroundColor: const Color.fromARGB(255, 95, 132, 255),
|
icon: const Icon(Icons.check_circle_outline,
|
||||||
child: Row(
|
color: Colors.white),
|
||||||
mainAxisSize: MainAxisSize.min,
|
label:
|
||||||
children: [
|
|
||||||
MyText.bodyMedium("Assign Task", color: Colors.white),
|
MyText.bodyMedium("Assign Task", color: Colors.white),
|
||||||
],
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.indigo,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 28, vertical: 14),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:marco/controller/task_planing/report_task_controller.dart';
|
import 'package:marco/controller/task_planing/report_task_controller.dart';
|
||||||
import 'package:marco/helpers/theme/app_theme.dart';
|
|
||||||
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
|
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
|
||||||
import 'package:marco/helpers/widgets/my_button.dart';
|
import 'package:marco/helpers/widgets/my_button.dart';
|
||||||
import 'package:marco/helpers/widgets/my_spacing.dart';
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
||||||
@ -342,9 +341,6 @@ class _CommentTaskBottomSheetState extends State<CommentTaskBottomSheet>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
isLoading: controller.isLoading,
|
isLoading: controller.isLoading,
|
||||||
splashColor: contentTheme.secondary.withAlpha(25),
|
|
||||||
backgroundColor: Colors.blueAccent,
|
|
||||||
loadingIndicatorColor: contentTheme.onPrimary,
|
|
||||||
),
|
),
|
||||||
MySpacing.height(10),
|
MySpacing.height(10),
|
||||||
if ((widget.taskData['taskComments'] as List<dynamic>?)
|
if ((widget.taskData['taskComments'] as List<dynamic>?)
|
||||||
@ -526,43 +522,46 @@ class _CommentTaskBottomSheetState extends State<CommentTaskBottomSheet>
|
|||||||
required VoidCallback onCancel,
|
required VoidCallback onCancel,
|
||||||
required Future<void> Function() onSubmit,
|
required Future<void> Function() onSubmit,
|
||||||
required RxBool isLoading,
|
required RxBool isLoading,
|
||||||
required Color splashColor,
|
|
||||||
required Color backgroundColor,
|
|
||||||
required Color loadingIndicatorColor,
|
|
||||||
double? buttonHeight,
|
double? buttonHeight,
|
||||||
}) {
|
}) {
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
MyButton.text(
|
OutlinedButton.icon(
|
||||||
onPressed: onCancel,
|
onPressed: onCancel,
|
||||||
padding: MySpacing.xy(20, 16),
|
icon: const Icon(Icons.close, color: Colors.red),
|
||||||
splashColor: splashColor,
|
label: MyText.bodyMedium("Cancel", color: Colors.red),
|
||||||
child: MyText.bodySmall('Cancel'),
|
style: OutlinedButton.styleFrom(
|
||||||
|
side: const BorderSide(color: Colors.red),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
MySpacing.width(12),
|
|
||||||
Obx(() {
|
Obx(() {
|
||||||
return MyButton(
|
return ElevatedButton.icon(
|
||||||
onPressed: isLoading.value ? null : onSubmit,
|
onPressed: isLoading.value ? null : () => onSubmit(),
|
||||||
elevation: 0,
|
icon: isLoading.value
|
||||||
padding: MySpacing.xy(20, 16),
|
? const SizedBox(
|
||||||
backgroundColor: backgroundColor,
|
width: 16,
|
||||||
borderRadiusAll: AppStyle.buttonRadius.medium,
|
height: 16,
|
||||||
child: isLoading.value
|
|
||||||
? SizedBox(
|
|
||||||
width: buttonHeight ?? 16,
|
|
||||||
height: buttonHeight ?? 16,
|
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(
|
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||||||
loadingIndicatorColor,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: MyText.bodySmall(
|
: const Icon(Icons.check_circle_outline, color: Colors.white),
|
||||||
'Comment',
|
label: isLoading.value
|
||||||
color: loadingIndicatorColor,
|
? const SizedBox()
|
||||||
),
|
: MyText.bodyMedium("Comment", color: Colors.white),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.indigo,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 28, vertical: 14),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -488,10 +488,8 @@ class _ReportActionBottomSheetState extends State<ReportActionBottomSheet>
|
|||||||
widget.taskData['plannedWork'] ??
|
widget.taskData['plannedWork'] ??
|
||||||
'0') ??
|
'0') ??
|
||||||
0,
|
0,
|
||||||
activityId:
|
activityId: widget.activityId,
|
||||||
widget.activityId,
|
workAreaId: widget.workAreaId,
|
||||||
workAreaId:
|
|
||||||
widget.workAreaId,
|
|
||||||
onSubmit: () {
|
onSubmit: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
@ -502,9 +500,6 @@ class _ReportActionBottomSheetState extends State<ReportActionBottomSheet>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
isLoading: controller.isLoading,
|
isLoading: controller.isLoading,
|
||||||
splashColor: contentTheme.secondary.withAlpha(25),
|
|
||||||
backgroundColor: Colors.blueAccent,
|
|
||||||
loadingIndicatorColor: contentTheme.onPrimary,
|
|
||||||
),
|
),
|
||||||
|
|
||||||
MySpacing.height(10),
|
MySpacing.height(10),
|
||||||
@ -687,43 +682,46 @@ class _ReportActionBottomSheetState extends State<ReportActionBottomSheet>
|
|||||||
required VoidCallback onCancel,
|
required VoidCallback onCancel,
|
||||||
required Future<void> Function() onSubmit,
|
required Future<void> Function() onSubmit,
|
||||||
required RxBool isLoading,
|
required RxBool isLoading,
|
||||||
required Color splashColor,
|
|
||||||
required Color backgroundColor,
|
|
||||||
required Color loadingIndicatorColor,
|
|
||||||
double? buttonHeight,
|
double? buttonHeight,
|
||||||
}) {
|
}) {
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
MyButton.text(
|
OutlinedButton.icon(
|
||||||
onPressed: onCancel,
|
onPressed: onCancel,
|
||||||
padding: MySpacing.xy(20, 16),
|
icon: const Icon(Icons.close, color: Colors.red),
|
||||||
splashColor: splashColor,
|
label: MyText.bodyMedium("Cancel", color: Colors.red),
|
||||||
child: MyText.bodySmall('Cancel'),
|
style: OutlinedButton.styleFrom(
|
||||||
|
side: const BorderSide(color: Colors.red),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
MySpacing.width(12),
|
|
||||||
Obx(() {
|
Obx(() {
|
||||||
return MyButton(
|
return ElevatedButton.icon(
|
||||||
onPressed: isLoading.value ? null : onSubmit,
|
onPressed: isLoading.value ? null : () => onSubmit(),
|
||||||
elevation: 0,
|
icon: isLoading.value
|
||||||
padding: MySpacing.xy(20, 16),
|
? const SizedBox(
|
||||||
backgroundColor: backgroundColor,
|
width: 16,
|
||||||
borderRadiusAll: AppStyle.buttonRadius.medium,
|
height: 16,
|
||||||
child: isLoading.value
|
|
||||||
? SizedBox(
|
|
||||||
width: buttonHeight ?? 16,
|
|
||||||
height: buttonHeight ?? 16,
|
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(
|
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||||||
loadingIndicatorColor,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: MyText.bodySmall(
|
: const Icon(Icons.send),
|
||||||
'Submit Report',
|
label: isLoading.value
|
||||||
color: loadingIndicatorColor,
|
? const SizedBox()
|
||||||
),
|
: MyText.bodyMedium("Submit", color: Colors.white),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.indigo,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 28, vertical: 14),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:marco/controller/task_planing/report_task_controller.dart';
|
import 'package:marco/controller/task_planing/report_task_controller.dart';
|
||||||
import 'package:marco/helpers/theme/app_theme.dart';
|
|
||||||
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
|
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
|
||||||
import 'package:marco/helpers/widgets/my_button.dart';
|
import 'package:marco/helpers/widgets/my_button.dart';
|
||||||
import 'package:marco/helpers/widgets/my_spacing.dart';
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
||||||
@ -347,58 +346,86 @@ class _ReportTaskBottomSheetState extends State<ReportTaskBottomSheet>
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
MyButton.text(
|
OutlinedButton.icon(
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
padding: MySpacing.xy(20, 16),
|
icon: const Icon(Icons.close, color: Colors.red),
|
||||||
splashColor: contentTheme.secondary.withAlpha(25),
|
label: MyText.bodyMedium("Cancel",
|
||||||
child: MyText.bodySmall('Cancel'),
|
color: Colors.red, fontWeight: 600),
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
side: const BorderSide(color: Colors.red),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 20, vertical: 14),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
MySpacing.width(12),
|
Obx(() {
|
||||||
Obx(() {
|
final isLoading = controller.reportStatus.value ==
|
||||||
final isLoading = controller.reportStatus.value == ApiStatus.loading;
|
ApiStatus.loading;
|
||||||
|
|
||||||
return MyButton(
|
|
||||||
onPressed: isLoading
|
|
||||||
? null
|
|
||||||
: () async {
|
|
||||||
if (controller.basicValidator.validateForm()) {
|
|
||||||
final success = await controller.reportTask(
|
|
||||||
projectId: controller.basicValidator.getController('task_id')?.text ?? '',
|
|
||||||
comment: controller.basicValidator.getController('comment')?.text ?? '',
|
|
||||||
completedTask: int.tryParse(
|
|
||||||
controller.basicValidator.getController('completed_work')?.text ?? '') ??
|
|
||||||
0,
|
|
||||||
checklist: [],
|
|
||||||
reportedDate: DateTime.now(),
|
|
||||||
images: controller.selectedImages,
|
|
||||||
);
|
|
||||||
if (success && widget.onReportSuccess != null) {
|
|
||||||
widget.onReportSuccess!();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
elevation: 0,
|
|
||||||
padding: MySpacing.xy(20, 16),
|
|
||||||
backgroundColor: Colors.blueAccent,
|
|
||||||
borderRadiusAll: AppStyle.buttonRadius.medium,
|
|
||||||
child: isLoading
|
|
||||||
? const SizedBox(
|
|
||||||
height: 16,
|
|
||||||
width: 16,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
strokeWidth: 2,
|
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: MyText.bodySmall(
|
|
||||||
'Report',
|
|
||||||
color: contentTheme.onPrimary,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
|
|
||||||
|
return ElevatedButton.icon(
|
||||||
|
onPressed: isLoading
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
if (controller.basicValidator
|
||||||
|
.validateForm()) {
|
||||||
|
final success =
|
||||||
|
await controller.reportTask(
|
||||||
|
projectId: controller.basicValidator
|
||||||
|
.getController('task_id')
|
||||||
|
?.text ??
|
||||||
|
'',
|
||||||
|
comment: controller.basicValidator
|
||||||
|
.getController('comment')
|
||||||
|
?.text ??
|
||||||
|
'',
|
||||||
|
completedTask: int.tryParse(
|
||||||
|
controller.basicValidator
|
||||||
|
.getController(
|
||||||
|
'completed_work')
|
||||||
|
?.text ??
|
||||||
|
'') ??
|
||||||
|
0,
|
||||||
|
checklist: [],
|
||||||
|
reportedDate: DateTime.now(),
|
||||||
|
images: controller.selectedImages,
|
||||||
|
);
|
||||||
|
if (success &&
|
||||||
|
widget.onReportSuccess != null) {
|
||||||
|
widget.onReportSuccess!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon: isLoading
|
||||||
|
? const SizedBox(
|
||||||
|
height: 16,
|
||||||
|
width: 16,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
valueColor:
|
||||||
|
AlwaysStoppedAnimation<Color>(
|
||||||
|
Colors.white),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const Icon(Icons.check_circle_outline,
|
||||||
|
color: Colors.white, size: 18),
|
||||||
|
label: isLoading
|
||||||
|
? const SizedBox.shrink()
|
||||||
|
: MyText.bodyMedium("Report",
|
||||||
|
color: Colors.white, fontWeight: 600),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.indigo,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 28, vertical: 14),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -13,7 +13,8 @@ class AddEmployeeBottomSheet extends StatefulWidget {
|
|||||||
State<AddEmployeeBottomSheet> createState() => _AddEmployeeBottomSheetState();
|
State<AddEmployeeBottomSheet> createState() => _AddEmployeeBottomSheetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UIMixin {
|
class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet>
|
||||||
|
with UIMixin {
|
||||||
final AddEmployeeController _controller = Get.put(AddEmployeeController());
|
final AddEmployeeController _controller = Get.put(AddEmployeeController());
|
||||||
|
|
||||||
late TextEditingController genderController;
|
late TextEditingController genderController;
|
||||||
@ -27,7 +28,8 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
RelativeRect _popupMenuPosition(BuildContext context) {
|
RelativeRect _popupMenuPosition(BuildContext context) {
|
||||||
final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
|
final RenderBox overlay =
|
||||||
|
Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||||
return RelativeRect.fromLTRB(100, 300, overlay.size.width - 100, 0);
|
return RelativeRect.fromLTRB(100, 300, overlay.size.width - 100, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,8 +137,14 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: theme.cardColor,
|
color: theme.cardColor,
|
||||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
|
borderRadius:
|
||||||
boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 12, offset: Offset(0, -2))],
|
const BorderRadius.vertical(top: Radius.circular(24)),
|
||||||
|
boxShadow: const [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black12,
|
||||||
|
blurRadius: 12,
|
||||||
|
offset: Offset(0, -2))
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(20, 16, 20, 32),
|
padding: const EdgeInsets.fromLTRB(20, 16, 20, 32),
|
||||||
@ -153,7 +161,8 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
MySpacing.height(12),
|
MySpacing.height(12),
|
||||||
Text("Add Employee", style: MyTextStyle.titleLarge(fontWeight: 700)),
|
Text("Add Employee",
|
||||||
|
style: MyTextStyle.titleLarge(fontWeight: 700)),
|
||||||
MySpacing.height(24),
|
MySpacing.height(24),
|
||||||
Form(
|
Form(
|
||||||
key: _controller.basicValidator.formKey,
|
key: _controller.basicValidator.formKey,
|
||||||
@ -166,16 +175,20 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
label: "First Name",
|
label: "First Name",
|
||||||
hint: "e.g., John",
|
hint: "e.g., John",
|
||||||
icon: Icons.person,
|
icon: Icons.person,
|
||||||
controller: _controller.basicValidator.getController('first_name')!,
|
controller: _controller.basicValidator
|
||||||
validator: _controller.basicValidator.getValidation('first_name'),
|
.getController('first_name')!,
|
||||||
|
validator: _controller.basicValidator
|
||||||
|
.getValidation('first_name'),
|
||||||
),
|
),
|
||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
_inputWithIcon(
|
_inputWithIcon(
|
||||||
label: "Last Name",
|
label: "Last Name",
|
||||||
hint: "e.g., Doe",
|
hint: "e.g., Doe",
|
||||||
icon: Icons.person_outline,
|
icon: Icons.person_outline,
|
||||||
controller: _controller.basicValidator.getController('last_name')!,
|
controller: _controller.basicValidator
|
||||||
validator: _controller.basicValidator.getValidation('last_name'),
|
.getController('last_name')!,
|
||||||
|
validator: _controller.basicValidator
|
||||||
|
.getValidation('last_name'),
|
||||||
),
|
),
|
||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
_sectionLabel("Contact Details"),
|
_sectionLabel("Contact Details"),
|
||||||
@ -185,7 +198,8 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 12, vertical: 14),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: Colors.grey.shade300),
|
border: Border.all(color: Colors.grey.shade300),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
@ -193,7 +207,8 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
),
|
),
|
||||||
child: PopupMenuButton<Map<String, String>>(
|
child: PopupMenuButton<Map<String, String>>(
|
||||||
onSelected: (country) {
|
onSelected: (country) {
|
||||||
_controller.selectedCountryCode = country['code']!;
|
_controller.selectedCountryCode =
|
||||||
|
country['code']!;
|
||||||
_controller.update();
|
_controller.update();
|
||||||
},
|
},
|
||||||
itemBuilder: (context) => [
|
itemBuilder: (context) => [
|
||||||
@ -204,11 +219,14 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
height: 200,
|
height: 200,
|
||||||
width: 100,
|
width: 100,
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: _controller.countries.map((country) {
|
children: _controller.countries
|
||||||
|
.map((country) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
dense: true,
|
dense: true,
|
||||||
title: Text("${country['name']} (${country['code']})"),
|
title: Text(
|
||||||
onTap: () => Navigator.pop(context, country),
|
"${country['name']} (${country['code']})"),
|
||||||
|
onTap: () =>
|
||||||
|
Navigator.pop(context, country),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
@ -226,31 +244,42 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
MySpacing.width(12),
|
MySpacing.width(12),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: _controller.basicValidator.getController('phone_number'),
|
controller: _controller.basicValidator
|
||||||
|
.getController('phone_number'),
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value == null || value.trim().isEmpty) {
|
if (value == null || value.trim().isEmpty) {
|
||||||
return "Phone number is required";
|
return "Phone number is required";
|
||||||
}
|
}
|
||||||
|
|
||||||
final digitsOnly = value.trim();
|
final digitsOnly = value.trim();
|
||||||
final minLength = _controller.minDigitsPerCountry[_controller.selectedCountryCode] ?? 7;
|
final minLength = _controller
|
||||||
final maxLength = _controller.maxDigitsPerCountry[_controller.selectedCountryCode] ?? 15;
|
.minDigitsPerCountry[
|
||||||
|
_controller.selectedCountryCode] ??
|
||||||
|
7;
|
||||||
|
final maxLength = _controller
|
||||||
|
.maxDigitsPerCountry[
|
||||||
|
_controller.selectedCountryCode] ??
|
||||||
|
15;
|
||||||
|
|
||||||
if (!RegExp(r'^[0-9]+$').hasMatch(digitsOnly)) {
|
if (!RegExp(r'^[0-9]+$')
|
||||||
|
.hasMatch(digitsOnly)) {
|
||||||
return "Only digits allowed";
|
return "Only digits allowed";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (digitsOnly.length < minLength || digitsOnly.length > maxLength) {
|
if (digitsOnly.length < minLength ||
|
||||||
|
digitsOnly.length > maxLength) {
|
||||||
return "Between $minLength–$maxLength digits";
|
return "Between $minLength–$maxLength digits";
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
keyboardType: TextInputType.phone,
|
keyboardType: TextInputType.phone,
|
||||||
decoration: _inputDecoration("e.g., 9876543210").copyWith(
|
decoration: _inputDecoration("e.g., 9876543210")
|
||||||
|
.copyWith(
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: const Icon(Icons.contacts),
|
icon: const Icon(Icons.contacts),
|
||||||
onPressed: () => _controller.pickContact(context),
|
onPressed: () =>
|
||||||
|
_controller.pickContact(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -268,9 +297,11 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
controller: TextEditingController(
|
controller: TextEditingController(
|
||||||
text: _controller.selectedGender?.name.capitalizeFirst,
|
text: _controller
|
||||||
|
.selectedGender?.name.capitalizeFirst,
|
||||||
),
|
),
|
||||||
decoration: _inputDecoration("Select Gender").copyWith(
|
decoration:
|
||||||
|
_inputDecoration("Select Gender").copyWith(
|
||||||
suffixIcon: const Icon(Icons.expand_more),
|
suffixIcon: const Icon(Icons.expand_more),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -286,10 +317,14 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
readOnly: true,
|
readOnly: true,
|
||||||
controller: TextEditingController(
|
controller: TextEditingController(
|
||||||
text: _controller.roles.firstWhereOrNull(
|
text: _controller.roles.firstWhereOrNull(
|
||||||
(role) => role['id'] == _controller.selectedRoleId,
|
(role) =>
|
||||||
)?['name'] ?? "",
|
role['id'] ==
|
||||||
|
_controller.selectedRoleId,
|
||||||
|
)?['name'] ??
|
||||||
|
"",
|
||||||
),
|
),
|
||||||
decoration: _inputDecoration("Select Role").copyWith(
|
decoration:
|
||||||
|
_inputDecoration("Select Role").copyWith(
|
||||||
suffixIcon: const Icon(Icons.expand_more),
|
suffixIcon: const Icon(Icons.expand_more),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -301,11 +336,16 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: OutlinedButton.icon(
|
child: OutlinedButton.icon(
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.pop(context),
|
||||||
icon: const Icon(Icons.close, size: 18),
|
icon:
|
||||||
label: MyText.bodyMedium("Cancel", fontWeight: 600),
|
const Icon(Icons.close, color: Colors.red),
|
||||||
|
label: MyText.bodyMedium("Cancel",
|
||||||
|
color: Colors.red, fontWeight: 600),
|
||||||
style: OutlinedButton.styleFrom(
|
style: OutlinedButton.styleFrom(
|
||||||
side: const BorderSide(color: Colors.grey),
|
side: const BorderSide(color: Colors.red),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12)),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 20, vertical: 14),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -313,23 +353,36 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (_controller.basicValidator.validateForm()) {
|
if (_controller.basicValidator
|
||||||
final success = await _controller.createEmployees();
|
.validateForm()) {
|
||||||
|
final success =
|
||||||
|
await _controller.createEmployees();
|
||||||
if (success) {
|
if (success) {
|
||||||
final employeeController = Get.find<EmployeesScreenController>();
|
final employeeController =
|
||||||
final projectId = employeeController.selectedProjectId;
|
Get.find<EmployeesScreenController>();
|
||||||
|
final projectId =
|
||||||
|
employeeController.selectedProjectId;
|
||||||
|
|
||||||
if (projectId == null) {
|
if (projectId == null) {
|
||||||
await employeeController.fetchAllEmployees();
|
await employeeController
|
||||||
|
.fetchAllEmployees();
|
||||||
} else {
|
} else {
|
||||||
await employeeController.fetchEmployeesByProject(projectId);
|
await employeeController
|
||||||
|
.fetchEmployeesByProject(projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
employeeController.update(['employee_screen_controller']);
|
employeeController.update(
|
||||||
|
['employee_screen_controller']);
|
||||||
|
|
||||||
_controller.basicValidator.getController("first_name")?.clear();
|
_controller.basicValidator
|
||||||
_controller.basicValidator.getController("last_name")?.clear();
|
.getController("first_name")
|
||||||
_controller.basicValidator.getController("phone_number")?.clear();
|
?.clear();
|
||||||
|
_controller.basicValidator
|
||||||
|
.getController("last_name")
|
||||||
|
?.clear();
|
||||||
|
_controller.basicValidator
|
||||||
|
.getController("phone_number")
|
||||||
|
?.clear();
|
||||||
_controller.selectedGender = null;
|
_controller.selectedGender = null;
|
||||||
_controller.selectedRoleId = null;
|
_controller.selectedRoleId = null;
|
||||||
_controller.update();
|
_controller.update();
|
||||||
@ -338,11 +391,16 @@ class _AddEmployeeBottomSheetState extends State<AddEmployeeBottomSheet> with UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.check, size: 18),
|
icon: const Icon(Icons.check_circle_outline,
|
||||||
label: MyText.bodyMedium("Save", color: Colors.white, fontWeight: 600),
|
color: Colors.white),
|
||||||
|
label: MyText.bodyMedium("Save",
|
||||||
|
color: Colors.white, fontWeight: 600),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.blueAccent,
|
backgroundColor: Colors.indigo,
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12)),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 28, vertical: 14),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -187,28 +187,48 @@ class _OrganizationFormState extends State<_OrganizationForm> with UIMixin {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
SizedBox(
|
Row(
|
||||||
width: double.infinity,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
child: ElevatedButton(
|
children: [
|
||||||
style: ElevatedButton.styleFrom(
|
OutlinedButton.icon(
|
||||||
backgroundColor: contentTheme.brandRed,
|
onPressed: () => Navigator.pop(context),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
icon: const Icon(Icons.arrow_back, color: Colors.red),
|
||||||
shape: RoundedRectangleBorder(
|
label: MyText.bodyMedium("Back", color: Colors.red),
|
||||||
borderRadius: BorderRadius.circular(10),
|
style: OutlinedButton.styleFrom(
|
||||||
|
side: const BorderSide(color: Colors.red),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 20, vertical: 14),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: _loading ? null : _submitForm,
|
ElevatedButton.icon(
|
||||||
child: _loading
|
onPressed: _loading ? null : _submitForm,
|
||||||
? const SizedBox(
|
icon: _loading
|
||||||
width: 22,
|
? const SizedBox(
|
||||||
height: 22,
|
width: 18,
|
||||||
child: CircularProgressIndicator(
|
height: 18,
|
||||||
color: Colors.white,
|
child: CircularProgressIndicator(
|
||||||
strokeWidth: 2,
|
color: Colors.white,
|
||||||
),
|
strokeWidth: 2,
|
||||||
)
|
),
|
||||||
: MyText.labelLarge('Submit', color: Colors.white),
|
)
|
||||||
),
|
: const Icon(Icons.check_circle_outline,
|
||||||
|
color: Colors.white),
|
||||||
|
label: _loading
|
||||||
|
? const SizedBox.shrink()
|
||||||
|
: MyText.bodyMedium("Submit", color: Colors.white),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.indigo,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 28, vertical: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Center(
|
Center(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user