Merge pull request 'Vaibhav_Enhancement-#419' (#35) from Vaibhav_Enhancement-#419 into main
Reviewed-on: #35
This commit is contained in:
commit
22a94a023e
@ -6,51 +6,65 @@ import 'package:marco/helpers/widgets/my_form_validator.dart';
|
|||||||
import 'package:marco/helpers/widgets/my_validators.dart';
|
import 'package:marco/helpers/widgets/my_validators.dart';
|
||||||
|
|
||||||
class LoginController extends MyController {
|
class LoginController extends MyController {
|
||||||
MyFormValidator basicValidator = MyFormValidator();
|
// Form validator
|
||||||
|
final MyFormValidator basicValidator = MyFormValidator();
|
||||||
|
|
||||||
bool showPassword = false, isChecked = false;
|
// UI states
|
||||||
RxBool isLoading = false.obs; // Add reactive loading state
|
final RxBool isLoading = false.obs;
|
||||||
|
final RxBool showPassword = false.obs;
|
||||||
|
final RxBool isChecked = false.obs;
|
||||||
|
|
||||||
|
// Dummy credentials
|
||||||
final String _dummyEmail = "admin@marcoaiot.com";
|
final String _dummyEmail = "admin@marcoaiot.com";
|
||||||
final String _dummyPassword = "User@123";
|
final String _dummyPassword = "User@123";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
basicValidator.addField('username', required: true, label: "User_Name", validators: [MyEmailValidator()], controller: TextEditingController(text: _dummyEmail));
|
|
||||||
basicValidator.addField('password', required: true, label: "Password", validators: [MyLengthValidator(min: 6, max: 10)], controller: TextEditingController(text: _dummyPassword));
|
|
||||||
super.onInit();
|
super.onInit();
|
||||||
|
|
||||||
|
basicValidator.addField(
|
||||||
|
'username',
|
||||||
|
required: true,
|
||||||
|
label: "User_Name",
|
||||||
|
validators: [MyEmailValidator()],
|
||||||
|
controller: TextEditingController(text: _dummyEmail),
|
||||||
|
);
|
||||||
|
|
||||||
|
basicValidator.addField(
|
||||||
|
'password',
|
||||||
|
required: true,
|
||||||
|
label: "Password",
|
||||||
|
validators: [MyLengthValidator(min: 6, max: 10)],
|
||||||
|
controller: TextEditingController(text: _dummyPassword),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onChangeCheckBox(bool? value) {
|
void onChangeCheckBox(bool? value) {
|
||||||
isChecked = value ?? isChecked;
|
isChecked.value = value ?? isChecked.value;
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onChangeShowPassword() {
|
void onChangeShowPassword() {
|
||||||
showPassword = !showPassword;
|
showPassword.toggle();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onLogin() async {
|
Future<void> onLogin() async {
|
||||||
if (basicValidator.validateForm()) {
|
if (!basicValidator.validateForm()) return;
|
||||||
// Set loading to true
|
|
||||||
isLoading.value = true;
|
|
||||||
update();
|
|
||||||
|
|
||||||
var errors = await AuthService.loginUser(basicValidator.getData());
|
isLoading.value = true;
|
||||||
if (errors != null) {
|
|
||||||
basicValidator.addErrors(errors);
|
|
||||||
basicValidator.validateForm();
|
|
||||||
basicValidator.clearErrors();
|
|
||||||
} else {
|
|
||||||
String nextUrl = Uri.parse(ModalRoute.of(Get.context!)?.settings.name ?? "").queryParameters['next'] ?? "/home";
|
|
||||||
Get.toNamed(nextUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set loading to false after the API call is complete
|
final errors = await AuthService.loginUser(basicValidator.getData());
|
||||||
isLoading.value = false;
|
|
||||||
update();
|
if (errors != null) {
|
||||||
|
basicValidator.addErrors(errors);
|
||||||
|
basicValidator.validateForm();
|
||||||
|
basicValidator.clearErrors();
|
||||||
|
} else {
|
||||||
|
final currentRoute = ModalRoute.of(Get.context!)?.settings.name ?? "";
|
||||||
|
final nextUrl = Uri.parse(currentRoute).queryParameters['next'] ?? "/home";
|
||||||
|
Get.toNamed(nextUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void goToForgotPassword() {
|
void goToForgotPassword() {
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import 'package:intl/intl.dart';
|
|||||||
import 'package:marco/helpers/widgets/my_text.dart';
|
import 'package:marco/helpers/widgets/my_text.dart';
|
||||||
import 'package:marco/helpers/utils/permission_constants.dart';
|
import 'package:marco/helpers/utils/permission_constants.dart';
|
||||||
|
|
||||||
class AttendanceFilterBottomSheet extends StatelessWidget {
|
class AttendanceFilterBottomSheet extends StatefulWidget {
|
||||||
final AttendanceController controller;
|
final AttendanceController controller;
|
||||||
final PermissionController permissionController;
|
final PermissionController permissionController;
|
||||||
final String selectedTab;
|
final String selectedTab;
|
||||||
@ -17,35 +17,93 @@ class AttendanceFilterBottomSheet extends StatelessWidget {
|
|||||||
required this.selectedTab,
|
required this.selectedTab,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_AttendanceFilterBottomSheetState createState() =>
|
||||||
|
_AttendanceFilterBottomSheetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AttendanceFilterBottomSheetState
|
||||||
|
extends State<AttendanceFilterBottomSheet> {
|
||||||
|
late String? tempSelectedProjectId;
|
||||||
|
late String tempSelectedTab;
|
||||||
|
bool showProjectList = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
tempSelectedProjectId = widget.controller.selectedProjectId;
|
||||||
|
tempSelectedTab = widget.selectedTab;
|
||||||
|
}
|
||||||
|
|
||||||
String getLabelText() {
|
String getLabelText() {
|
||||||
final startDate = controller.startDateAttendance;
|
final startDate = widget.controller.startDateAttendance;
|
||||||
final endDate = controller.endDateAttendance;
|
final endDate = widget.controller.endDateAttendance;
|
||||||
if (startDate != null && endDate != null) {
|
if (startDate != null && endDate != null) {
|
||||||
final start = DateFormat('dd MM yyyy').format(startDate);
|
final start = DateFormat('dd/MM/yyyy').format(startDate);
|
||||||
final end = DateFormat('dd MM yyyy').format(endDate);
|
final end = DateFormat('dd/MM/yyyy').format(endDate);
|
||||||
return "$start - $end";
|
return "$start - $end";
|
||||||
}
|
}
|
||||||
return "Date Range";
|
return "Date Range";
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
List<Widget> buildProjectList() {
|
||||||
Widget build(BuildContext context) {
|
final accessibleProjects = widget.controller.projects
|
||||||
String? tempSelectedProjectId = controller.selectedProjectId;
|
|
||||||
String tempSelectedTab = selectedTab;
|
|
||||||
bool showProjectList = false;
|
|
||||||
|
|
||||||
final accessibleProjects = controller.projects
|
|
||||||
.where((project) =>
|
.where((project) =>
|
||||||
permissionController.isUserAssignedToProject(project.id.toString()))
|
widget.permissionController.isUserAssignedToProject(
|
||||||
|
project.id.toString()))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
bool hasRegularizationPermission =
|
if (accessibleProjects.isEmpty) {
|
||||||
permissionController.hasPermission(Permissions.regularizeAttendance);
|
return [
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.all(12.0),
|
||||||
|
child: Center(child: Text('No Projects Assigned')),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return accessibleProjects.map((project) {
|
||||||
|
final isSelected = tempSelectedProjectId == project.id.toString();
|
||||||
|
return ListTile(
|
||||||
|
dense: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
title: Text(project.name),
|
||||||
|
trailing: isSelected ? const Icon(Icons.check) : null,
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
tempSelectedProjectId = project.id.toString();
|
||||||
|
showProjectList = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> buildMainFilters() {
|
||||||
|
final accessibleProjects = widget.controller.projects
|
||||||
|
.where((project) =>
|
||||||
|
widget.permissionController.isUserAssignedToProject(
|
||||||
|
project.id.toString()))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
final selectedProject = accessibleProjects.isNotEmpty
|
||||||
|
? accessibleProjects.firstWhere(
|
||||||
|
(p) => p.id.toString() == tempSelectedProjectId,
|
||||||
|
orElse: () => accessibleProjects[0],
|
||||||
|
)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
final selectedProjectName = selectedProject?.name ?? "Select Project";
|
||||||
|
|
||||||
|
final hasRegularizationPermission = widget.permissionController
|
||||||
|
.hasPermission(Permissions.regularizeAttendance);
|
||||||
|
|
||||||
final viewOptions = [
|
final viewOptions = [
|
||||||
{'label': 'Today\'s Attendance', 'value': 'todaysAttendance'},
|
{'label': 'Today\'s Attendance', 'value': 'todaysAttendance'},
|
||||||
{'label': 'Attendance Logs', 'value': 'attendanceLogs'},
|
{'label': 'Attendance Logs', 'value': 'attendanceLogs'},
|
||||||
{'label': 'Regularization Requests', 'value': 'regularizationRequests'},
|
{'label': 'Regularization Requests', 'value': 'regularizationRequests'},
|
||||||
];
|
];
|
||||||
|
|
||||||
final filteredViewOptions = viewOptions.where((item) {
|
final filteredViewOptions = viewOptions.where((item) {
|
||||||
if (item['value'] == 'regularizationRequests') {
|
if (item['value'] == 'regularizationRequests') {
|
||||||
return hasRegularizationPermission;
|
return hasRegularizationPermission;
|
||||||
@ -53,190 +111,152 @@ class AttendanceFilterBottomSheet extends StatelessWidget {
|
|||||||
return true;
|
return true;
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
return StatefulBuilder(builder: (context, setState) {
|
List<Widget> widgets = [
|
||||||
List<Widget> filterWidgets;
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: MyText.titleSmall(
|
||||||
|
"Project",
|
||||||
|
fontWeight: 600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
title: Text(selectedProjectName),
|
||||||
|
trailing: const Icon(Icons.arrow_drop_down),
|
||||||
|
onTap: () => setState(() => showProjectList = true),
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: MyText.titleSmall(
|
||||||
|
"View",
|
||||||
|
fontWeight: 600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
...filteredViewOptions.map((item) {
|
||||||
|
return RadioListTile<String>(
|
||||||
|
dense: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
|
title: Text(item['label']!),
|
||||||
|
value: item['value']!,
|
||||||
|
groupValue: tempSelectedTab,
|
||||||
|
onChanged: (value) => setState(() => tempSelectedTab = value!),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
];
|
||||||
|
|
||||||
if (showProjectList) {
|
if (tempSelectedTab == 'attendanceLogs') {
|
||||||
filterWidgets = accessibleProjects.isEmpty
|
widgets.addAll([
|
||||||
? [
|
const Divider(),
|
||||||
const Padding(
|
Padding(
|
||||||
padding: EdgeInsets.all(12.0),
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
||||||
child: Center(child: Text('No Projects Assigned')),
|
child: Align(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: MyText.titleSmall(
|
||||||
|
"Date Range",
|
||||||
|
fontWeight: 600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
onTap: () => widget.controller.selectDateRangeForAttendance(
|
||||||
|
context,
|
||||||
|
widget.controller,
|
||||||
|
),
|
||||||
|
child: Ink(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
border: Border.all(color: Colors.grey.shade400),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.date_range, color: Colors.black87),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
getLabelText(),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
color: Colors.black87,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Icon(Icons.arrow_drop_down, color: Colors.black87),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return widgets;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
// Drag handle
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 12, bottom: 8),
|
||||||
|
child: Center(
|
||||||
|
child: Container(
|
||||||
|
width: 40,
|
||||||
|
height: 4,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[400],
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
]
|
|
||||||
: accessibleProjects.map((project) {
|
|
||||||
final isSelected =
|
|
||||||
tempSelectedProjectId == project.id.toString();
|
|
||||||
return ListTile(
|
|
||||||
dense: true,
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
|
||||||
title: Text(project.name),
|
|
||||||
trailing: isSelected ? const Icon(Icons.check) : null,
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
tempSelectedProjectId = project.id.toString();
|
|
||||||
showProjectList = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
} else {
|
|
||||||
final selectedProject = accessibleProjects.isNotEmpty
|
|
||||||
? accessibleProjects.firstWhere(
|
|
||||||
(p) => p.id.toString() == tempSelectedProjectId,
|
|
||||||
orElse: () => accessibleProjects[0],
|
|
||||||
)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
final selectedProjectName = selectedProject?.name ?? "Select Project";
|
|
||||||
|
|
||||||
filterWidgets = [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: MyText.titleSmall(
|
|
||||||
"Project",
|
|
||||||
fontWeight: 600,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (showProjectList) ...buildProjectList() else ...buildMainFilters(),
|
||||||
ListTile(
|
|
||||||
dense: true,
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
|
||||||
title: Text(selectedProjectName),
|
|
||||||
trailing: const Icon(Icons.arrow_drop_down),
|
|
||||||
onTap: () => setState(() => showProjectList = true),
|
|
||||||
),
|
|
||||||
const Divider(),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: MyText.titleSmall(
|
|
||||||
"View",
|
|
||||||
fontWeight: 600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
...filteredViewOptions.map((item) {
|
|
||||||
return RadioListTile<String>(
|
|
||||||
dense: true,
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 12),
|
|
||||||
title: Text(item['label']!),
|
|
||||||
value: item['value']!,
|
|
||||||
groupValue: tempSelectedTab,
|
|
||||||
onChanged: (value) => setState(() => tempSelectedTab = value!),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
];
|
|
||||||
|
|
||||||
if (tempSelectedTab == 'attendanceLogs') {
|
|
||||||
filterWidgets.addAll([
|
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
child: Align(
|
child: SizedBox(
|
||||||
alignment: Alignment.centerLeft,
|
width: double.infinity,
|
||||||
child: MyText.titleSmall(
|
child: ElevatedButton(
|
||||||
"Date Range",
|
style: ElevatedButton.styleFrom(
|
||||||
fontWeight: 600,
|
backgroundColor: const Color.fromARGB(255, 95, 132, 255),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Text('Apply Filter'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context, {
|
||||||
|
'projectId': tempSelectedProjectId,
|
||||||
|
'selectedTab': tempSelectedTab,
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
],
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
||||||
child: InkWell(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
onTap: () => controller.selectDateRangeForAttendance(
|
|
||||||
context,
|
|
||||||
controller,
|
|
||||||
),
|
|
||||||
child: Ink(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: const Color.fromARGB(255, 255, 255, 255),
|
|
||||||
border: Border.all(color: Colors.grey.shade400),
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(Icons.date_range,
|
|
||||||
color: const Color.fromARGB(255, 9, 9, 9)),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
getLabelText(),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color: Colors.black87,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Icon(Icons.arrow_drop_down,
|
|
||||||
color: Color.fromARGB(255, 0, 0, 0)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
bottom: MediaQuery.of(context).viewInsets.bottom,
|
|
||||||
),
|
),
|
||||||
child: SingleChildScrollView(
|
),
|
||||||
child: Column(
|
);
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 12, bottom: 8),
|
|
||||||
child: Center(
|
|
||||||
child: Container(
|
|
||||||
width: 40,
|
|
||||||
height: 4,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.grey[400],
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
...filterWidgets,
|
|
||||||
const Divider(),
|
|
||||||
Padding(
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
||||||
child: SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
child: ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: const Color.fromARGB(255, 95, 132, 255),
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: const Text('Apply Filter'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context, {
|
|
||||||
'projectId': tempSelectedProjectId,
|
|
||||||
'selectedTab': tempSelectedTab,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,11 +20,11 @@ class LoginScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LoginScreenState extends State<LoginScreen> with UIMixin {
|
class _LoginScreenState extends State<LoginScreen> with UIMixin {
|
||||||
late LoginController controller;
|
late final LoginController controller;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
controller = Get.put(LoginController());
|
controller = Get.put(LoginController(), tag: 'login_controller');
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,204 +32,211 @@ class _LoginScreenState extends State<LoginScreen> with UIMixin {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AuthLayout(
|
return AuthLayout(
|
||||||
child: GetBuilder<LoginController>(
|
child: GetBuilder<LoginController>(
|
||||||
init: controller,
|
|
||||||
tag: 'login_controller',
|
tag: 'login_controller',
|
||||||
builder: (controller) {
|
builder: (_) {
|
||||||
return Obx(() {
|
return Obx(() {
|
||||||
return controller.isLoading.value
|
if (controller.isLoading.value) {
|
||||||
? Center(child: CircularProgressIndicator()) // Show loading spinner when isLoading is true
|
return const Center(child: CircularProgressIndicator());
|
||||||
: Form(
|
}
|
||||||
key: controller.basicValidator.formKey,
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
padding: MySpacing.xy(2, 40),
|
|
||||||
child: Container(
|
|
||||||
width: double.infinity,
|
|
||||||
padding: MySpacing.all(24),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: theme.colorScheme.primary.withOpacity(0.02),
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
border: Border.all(
|
|
||||||
color: contentTheme.primary.withOpacity(0.5),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
/// Logo
|
|
||||||
Center(
|
|
||||||
child: Image.asset(
|
|
||||||
Images.logoDark,
|
|
||||||
height: 120,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
MySpacing.height(20),
|
|
||||||
|
|
||||||
/// Welcome Text
|
return Form(
|
||||||
Center(
|
key: controller.basicValidator.formKey,
|
||||||
child: MyText.bodyLarge("Welcome Back!", fontWeight: 600),
|
child: SingleChildScrollView(
|
||||||
),
|
padding: MySpacing.xy(2, 40),
|
||||||
MySpacing.height(4),
|
child: Container(
|
||||||
Center(
|
width: double.infinity,
|
||||||
child: MyText.bodySmall("Please sign in to continue."),
|
padding: MySpacing.all(24),
|
||||||
),
|
decoration: BoxDecoration(
|
||||||
MySpacing.height(20),
|
color: theme.colorScheme.primary.withOpacity(0.02),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
/// Email Field
|
border: Border.all(
|
||||||
MyText.bodySmall("Email Address", fontWeight: 600),
|
color: contentTheme.primary.withOpacity(0.5),
|
||||||
MySpacing.height(8),
|
),
|
||||||
Material(
|
),
|
||||||
elevation: 2,
|
child: Column(
|
||||||
shadowColor: contentTheme.secondary.withAlpha(30),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
borderRadius: BorderRadius.circular(12),
|
children: [
|
||||||
child: TextFormField(
|
/// Logo
|
||||||
validator:
|
Center(
|
||||||
controller.basicValidator.getValidation('username'),
|
child: Image.asset(
|
||||||
controller:
|
Images.logoDark,
|
||||||
controller.basicValidator.getController('username'),
|
height: 120,
|
||||||
keyboardType: TextInputType.emailAddress,
|
fit: BoxFit.contain,
|
||||||
style: MyTextStyle.labelMedium(),
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: "Enter your email",
|
|
||||||
hintStyle: MyTextStyle.bodySmall(xMuted: true),
|
|
||||||
filled: true,
|
|
||||||
fillColor: theme.cardColor,
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
borderSide: BorderSide.none,
|
|
||||||
),
|
|
||||||
prefixIcon: const Icon(LucideIcons.mail, size: 18),
|
|
||||||
contentPadding: MySpacing.xy(12, 16),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
MySpacing.height(16),
|
|
||||||
|
|
||||||
/// Password Field Label
|
|
||||||
MyText.bodySmall("Password", fontWeight: 600),
|
|
||||||
MySpacing.height(8),
|
|
||||||
Material(
|
|
||||||
elevation: 2,
|
|
||||||
shadowColor: contentTheme.secondary.withAlpha(25),
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
child: TextFormField(
|
|
||||||
validator:
|
|
||||||
controller.basicValidator.getValidation('password'),
|
|
||||||
controller:
|
|
||||||
controller.basicValidator.getController('password'),
|
|
||||||
keyboardType: TextInputType.visiblePassword,
|
|
||||||
obscureText: !controller.showPassword,
|
|
||||||
style: MyTextStyle.labelMedium(),
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: "Enter your password",
|
|
||||||
hintStyle: MyTextStyle.bodySmall(xMuted: true),
|
|
||||||
filled: true,
|
|
||||||
fillColor: theme.cardColor,
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
borderSide: BorderSide.none,
|
|
||||||
),
|
|
||||||
prefixIcon: const Icon(LucideIcons.lock, size: 18),
|
|
||||||
suffixIcon: InkWell(
|
|
||||||
onTap: controller.onChangeShowPassword,
|
|
||||||
child: Icon(
|
|
||||||
controller.showPassword
|
|
||||||
? LucideIcons.eye
|
|
||||||
: LucideIcons.eye_off,
|
|
||||||
size: 18,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
contentPadding: MySpacing.all(3),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
MySpacing.height(16),
|
|
||||||
|
|
||||||
/// Remember Me + Forgot Password
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
InkWell(
|
|
||||||
onTap: () => controller
|
|
||||||
.onChangeCheckBox(!controller.isChecked),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Checkbox(
|
|
||||||
onChanged: controller.onChangeCheckBox,
|
|
||||||
value: controller.isChecked,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
fillColor: WidgetStatePropertyAll(
|
|
||||||
contentTheme.secondary),
|
|
||||||
checkColor: contentTheme.onPrimary,
|
|
||||||
visualDensity: getCompactDensity,
|
|
||||||
materialTapTargetSize:
|
|
||||||
MaterialTapTargetSize.shrinkWrap,
|
|
||||||
),
|
|
||||||
MySpacing.width(8),
|
|
||||||
MyText.bodySmall("Remember Me"),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
MyButton.text(
|
|
||||||
onPressed: controller.goToForgotPassword,
|
|
||||||
elevation: 0,
|
|
||||||
padding: MySpacing.xy(8, 0),
|
|
||||||
splashColor: contentTheme.secondary.withAlpha(36),
|
|
||||||
child: MyText.bodySmall(
|
|
||||||
'Forgot password?',
|
|
||||||
fontWeight: 600,
|
|
||||||
color: contentTheme.secondary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
MySpacing.height(28),
|
|
||||||
|
|
||||||
/// Login Button
|
|
||||||
Center(
|
|
||||||
child: MyButton.rounded(
|
|
||||||
onPressed: controller.onLogin,
|
|
||||||
elevation: 2,
|
|
||||||
padding: MySpacing.xy(24, 16),
|
|
||||||
borderRadiusAll: 16,
|
|
||||||
backgroundColor: Colors.blueAccent,
|
|
||||||
child: MyText.labelMedium(
|
|
||||||
'Login',
|
|
||||||
fontWeight: 600,
|
|
||||||
color: contentTheme.onPrimary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
MySpacing.height(16),
|
|
||||||
|
|
||||||
/// Register Link
|
|
||||||
Center(
|
|
||||||
child: MyButton.text(
|
|
||||||
onPressed: () {
|
|
||||||
OrganizationFormBottomSheet.show(context);
|
|
||||||
},
|
|
||||||
elevation: 0,
|
|
||||||
padding: MySpacing.xy(12, 8),
|
|
||||||
splashColor:
|
|
||||||
contentTheme.secondary.withAlpha(30),
|
|
||||||
child: MyText.bodySmall(
|
|
||||||
"Request a Demo",
|
|
||||||
color: contentTheme.secondary,
|
|
||||||
fontWeight: 600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
MySpacing.height(20),
|
||||||
);
|
|
||||||
|
/// Welcome
|
||||||
|
Center(child: MyText.bodyLarge("Welcome Back!", fontWeight: 600)),
|
||||||
|
MySpacing.height(4),
|
||||||
|
Center(child: MyText.bodySmall("Please sign in to continue.")),
|
||||||
|
MySpacing.height(20),
|
||||||
|
|
||||||
|
/// Email
|
||||||
|
MyText.bodySmall("Email Address", fontWeight: 600),
|
||||||
|
MySpacing.height(8),
|
||||||
|
_buildInputField(
|
||||||
|
controller.basicValidator.getController('username')!,
|
||||||
|
controller.basicValidator.getValidation('username'),
|
||||||
|
hintText: "Enter your email",
|
||||||
|
icon: LucideIcons.mail,
|
||||||
|
keyboardType: TextInputType.emailAddress,
|
||||||
|
),
|
||||||
|
MySpacing.height(16),
|
||||||
|
|
||||||
|
/// Password
|
||||||
|
MyText.bodySmall("Password", fontWeight: 600),
|
||||||
|
MySpacing.height(8),
|
||||||
|
Obx(() {
|
||||||
|
return _buildInputField(
|
||||||
|
controller.basicValidator.getController('password')!,
|
||||||
|
controller.basicValidator.getValidation('password'),
|
||||||
|
hintText: "Enter your password",
|
||||||
|
icon: LucideIcons.lock,
|
||||||
|
obscureText: !controller.showPassword.value,
|
||||||
|
suffix: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
controller.showPassword.value
|
||||||
|
? LucideIcons.eye
|
||||||
|
: LucideIcons.eye_off,
|
||||||
|
size: 18,
|
||||||
|
),
|
||||||
|
onPressed: controller.onChangeShowPassword,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
MySpacing.height(16),
|
||||||
|
|
||||||
|
/// Remember me + Forgot password
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Obx(() {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () =>
|
||||||
|
controller.onChangeCheckBox(!controller.isChecked.value),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Checkbox(
|
||||||
|
value: controller.isChecked.value,
|
||||||
|
onChanged: controller.onChangeCheckBox,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
fillColor: MaterialStateProperty
|
||||||
|
.resolveWith<Color>(
|
||||||
|
(Set<WidgetState> states) {
|
||||||
|
if (states
|
||||||
|
.contains(WidgetState.selected)) {
|
||||||
|
return Colors.blueAccent;
|
||||||
|
}
|
||||||
|
return Colors
|
||||||
|
.white;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
checkColor: contentTheme.onPrimary,
|
||||||
|
visualDensity: getCompactDensity,
|
||||||
|
materialTapTargetSize:
|
||||||
|
MaterialTapTargetSize.shrinkWrap,
|
||||||
|
),
|
||||||
|
MySpacing.width(8),
|
||||||
|
MyText.bodySmall("Remember Me"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
MyButton.text(
|
||||||
|
onPressed: controller.goToForgotPassword,
|
||||||
|
elevation: 0,
|
||||||
|
padding: MySpacing.xy(8, 0),
|
||||||
|
splashColor: contentTheme.secondary.withAlpha(36),
|
||||||
|
child: MyText.bodySmall(
|
||||||
|
'Forgot password?',
|
||||||
|
fontWeight: 600,
|
||||||
|
color: contentTheme.secondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
MySpacing.height(28),
|
||||||
|
|
||||||
|
/// Login button
|
||||||
|
Center(
|
||||||
|
child: MyButton.rounded(
|
||||||
|
onPressed: controller.onLogin,
|
||||||
|
elevation: 2,
|
||||||
|
padding: MySpacing.xy(24, 16),
|
||||||
|
borderRadiusAll: 16,
|
||||||
|
backgroundColor: Colors.blueAccent,
|
||||||
|
child: MyText.labelMedium(
|
||||||
|
'Login',
|
||||||
|
fontWeight: 600,
|
||||||
|
color: contentTheme.onPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
MySpacing.height(16),
|
||||||
|
|
||||||
|
/// Request demo
|
||||||
|
Center(
|
||||||
|
child: MyButton.text(
|
||||||
|
onPressed: () {
|
||||||
|
OrganizationFormBottomSheet.show(context);
|
||||||
|
},
|
||||||
|
elevation: 0,
|
||||||
|
padding: MySpacing.xy(12, 8),
|
||||||
|
splashColor: contentTheme.secondary.withAlpha(30),
|
||||||
|
child: MyText.bodySmall(
|
||||||
|
"Request a Demo",
|
||||||
|
color: contentTheme.secondary,
|
||||||
|
fontWeight: 600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildInputField(
|
||||||
|
TextEditingController controller,
|
||||||
|
FormFieldValidator<String>? validator, {
|
||||||
|
required String hintText,
|
||||||
|
required IconData icon,
|
||||||
|
TextInputType keyboardType = TextInputType.text,
|
||||||
|
bool obscureText = false,
|
||||||
|
Widget? suffix,
|
||||||
|
}) {
|
||||||
|
return Material(
|
||||||
|
elevation: 2,
|
||||||
|
shadowColor: contentTheme.secondary.withAlpha(30),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: controller,
|
||||||
|
validator: validator,
|
||||||
|
obscureText: obscureText,
|
||||||
|
keyboardType: keyboardType,
|
||||||
|
style: MyTextStyle.labelMedium(),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: hintText,
|
||||||
|
hintStyle: MyTextStyle.bodySmall(xMuted: true),
|
||||||
|
filled: true,
|
||||||
|
fillColor: theme.cardColor,
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(2),
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
),
|
||||||
|
prefixIcon: Icon(icon, size: 18),
|
||||||
|
suffixIcon: suffix,
|
||||||
|
contentPadding: MySpacing.xy(12, 16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -147,22 +147,29 @@ class _OrganizationFormState extends State<_OrganizationForm> {
|
|||||||
'Please select industry',
|
'Please select industry',
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Row(
|
GestureDetector(
|
||||||
children: [
|
onTap: () => setState(() => _agreed = !_agreed),
|
||||||
Checkbox(
|
child: Row(
|
||||||
value: _agreed,
|
children: [
|
||||||
onChanged: (val) => setState(() => _agreed = val ?? false),
|
Checkbox(
|
||||||
fillColor: MaterialStateProperty.all(Colors.white),
|
value: _agreed,
|
||||||
checkColor: Colors.white,
|
onChanged: (val) => setState(() => _agreed = val ?? false),
|
||||||
side: MaterialStateBorderSide.resolveWith(
|
fillColor: MaterialStateProperty.resolveWith((states) {
|
||||||
(states) =>
|
if (states.contains(MaterialState.selected)) {
|
||||||
BorderSide(color: Colors.blueAccent, width: 2),
|
return Colors.blueAccent;
|
||||||
),
|
}
|
||||||
),
|
return Colors.white;
|
||||||
const Expanded(
|
}),
|
||||||
child: Text('I agree to privacy policy & terms')),
|
checkColor: Colors.white,
|
||||||
],
|
side: const BorderSide(color: Colors.blueAccent, width: 2),
|
||||||
),
|
),
|
||||||
|
const Expanded(
|
||||||
|
child: Text('I agree to privacy policy & terms'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
|
|||||||
@ -255,12 +255,12 @@ class Layout extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
MyButton(
|
MyButton(
|
||||||
onPressed: () => {},
|
onPressed:null,
|
||||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
borderRadiusAll: AppStyle.buttonRadius.medium,
|
borderRadiusAll: AppStyle.buttonRadius.medium,
|
||||||
padding: MySpacing.xy(8, 4),
|
padding: MySpacing.xy(8, 4),
|
||||||
splashColor: contentTheme.onBackground.withAlpha(20),
|
splashColor: contentTheme.onBackground.withAlpha(20),
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: const Color.fromARGB(0, 220, 218, 218),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
@ -279,11 +279,11 @@ class Layout extends StatelessWidget {
|
|||||||
MySpacing.height(4),
|
MySpacing.height(4),
|
||||||
MyButton(
|
MyButton(
|
||||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
onPressed: () => {},
|
onPressed:null,
|
||||||
borderRadiusAll: AppStyle.buttonRadius.medium,
|
borderRadiusAll: AppStyle.buttonRadius.medium,
|
||||||
padding: MySpacing.xy(8, 4),
|
padding: MySpacing.xy(8, 4),
|
||||||
splashColor: contentTheme.onBackground.withAlpha(20),
|
splashColor: contentTheme.onBackground.withAlpha(20),
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: const Color.fromARGB(0, 220, 218, 218),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user