feat: add project name support in CustomAppBar and related screens for improved context
This commit is contained in:
parent
5c53a3f4be
commit
e9075dcdf5
@ -6,11 +6,13 @@ import 'package:on_field_work/helpers/widgets/my_text.dart';
|
|||||||
|
|
||||||
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
final String title;
|
final String title;
|
||||||
|
final String? projectName;
|
||||||
final VoidCallback? onBackPressed;
|
final VoidCallback? onBackPressed;
|
||||||
|
|
||||||
const CustomAppBar({
|
const CustomAppBar({
|
||||||
super.key,
|
super.key,
|
||||||
required this.title,
|
required this.title,
|
||||||
|
this.projectName,
|
||||||
this.onBackPressed,
|
this.onBackPressed,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -51,21 +53,26 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
|
|
||||||
MySpacing.height(2),
|
MySpacing.height(2),
|
||||||
|
|
||||||
// PROJECT NAME ROW (copied exactly)
|
// PROJECT NAME ROW
|
||||||
GetBuilder<ProjectController>(
|
GetBuilder<ProjectController>(
|
||||||
builder: (projectController) {
|
builder: (projectController) {
|
||||||
final projectName =
|
// NEW LOGIC — simple and safe
|
||||||
|
final displayProjectName =
|
||||||
|
projectName ??
|
||||||
projectController.selectedProject?.name ??
|
projectController.selectedProject?.name ??
|
||||||
'Select Project';
|
'Select Project';
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.work_outline,
|
const Icon(
|
||||||
size: 14, color: Colors.grey),
|
Icons.work_outline,
|
||||||
|
size: 14,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
MySpacing.width(4),
|
MySpacing.width(4),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: MyText.bodySmall(
|
child: MyText.bodySmall(
|
||||||
projectName,
|
displayProjectName,
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
color: Colors.grey[700],
|
color: Colors.grey[700],
|
||||||
|
|||||||
@ -13,8 +13,9 @@ import 'package:on_field_work/helpers/utils/permission_constants.dart';
|
|||||||
|
|
||||||
class JobsTab extends StatefulWidget {
|
class JobsTab extends StatefulWidget {
|
||||||
final ScrollController scrollController;
|
final ScrollController scrollController;
|
||||||
|
final String projectName;
|
||||||
|
|
||||||
const JobsTab({super.key, required this.scrollController});
|
const JobsTab({super.key, required this.scrollController, required this.projectName});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_JobsTabState createState() => _JobsTabState();
|
_JobsTabState createState() => _JobsTabState();
|
||||||
@ -165,11 +166,11 @@ class _JobsTabState extends State<JobsTab> {
|
|||||||
children: [
|
children: [
|
||||||
AbsorbPointer(
|
AbsorbPointer(
|
||||||
absorbing: controller.showArchivedJobs
|
absorbing: controller.showArchivedJobs
|
||||||
.value, // Disable interactions if archived
|
.value,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!controller.showArchivedJobs.value) {
|
if (!controller.showArchivedJobs.value) {
|
||||||
Get.to(() => JobDetailsScreen(jobId: job.id));
|
Get.to(() => JobDetailsScreen(jobId: job.id , projectName : widget.projectName));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Card(
|
child: Card(
|
||||||
|
|||||||
@ -15,8 +15,9 @@ import 'package:on_field_work/view/service_project/jobs_tab.dart';
|
|||||||
|
|
||||||
class ServiceProjectDetailsScreen extends StatefulWidget {
|
class ServiceProjectDetailsScreen extends StatefulWidget {
|
||||||
final String projectId;
|
final String projectId;
|
||||||
|
final String? projectName;
|
||||||
|
|
||||||
const ServiceProjectDetailsScreen({super.key, required this.projectId});
|
const ServiceProjectDetailsScreen({super.key, required this.projectId , this.projectName});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ServiceProjectDetailsScreen> createState() =>
|
State<ServiceProjectDetailsScreen> createState() =>
|
||||||
@ -415,6 +416,7 @@ class _ServiceProjectDetailsScreenState
|
|||||||
backgroundColor: const Color(0xFFF5F5F5),
|
backgroundColor: const Color(0xFFF5F5F5),
|
||||||
appBar: CustomAppBar(
|
appBar: CustomAppBar(
|
||||||
title: "Service Project Details",
|
title: "Service Project Details",
|
||||||
|
projectName: widget.projectName,
|
||||||
onBackPressed: () => Get.toNamed('/dashboard/service-projects'),
|
onBackPressed: () => Get.toNamed('/dashboard/service-projects'),
|
||||||
),
|
),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
@ -455,7 +457,7 @@ class _ServiceProjectDetailsScreenState
|
|||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
children: [
|
children: [
|
||||||
_buildProfileTab(),
|
_buildProfileTab(),
|
||||||
JobsTab(scrollController: _jobScrollController),
|
JobsTab(scrollController: _jobScrollController, projectName: widget.projectName ?? '',),
|
||||||
_buildTeamsTab(),
|
_buildTeamsTab(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -21,7 +21,8 @@ import 'package:on_field_work/helpers/widgets/my_snackbar.dart';
|
|||||||
|
|
||||||
class JobDetailsScreen extends StatefulWidget {
|
class JobDetailsScreen extends StatefulWidget {
|
||||||
final String jobId;
|
final String jobId;
|
||||||
const JobDetailsScreen({super.key, required this.jobId});
|
final String? projectName;
|
||||||
|
const JobDetailsScreen({super.key, required this.jobId, this.projectName});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<JobDetailsScreen> createState() => _JobDetailsScreenState();
|
State<JobDetailsScreen> createState() => _JobDetailsScreenState();
|
||||||
@ -752,11 +753,14 @@ class _JobDetailsScreenState extends State<JobDetailsScreen> with UIMixin {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final projectName = widget.projectName;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFF5F5F5),
|
backgroundColor: const Color(0xFFF5F5F5),
|
||||||
appBar: CustomAppBar(
|
appBar: CustomAppBar(
|
||||||
title: "Service Project Job Details",
|
title: "Job Details Screen",
|
||||||
onBackPressed: () => Get.back()),
|
onBackPressed: () => Get.back(),
|
||||||
|
projectName: projectName,
|
||||||
|
),
|
||||||
floatingActionButton: Obx(() => FloatingActionButton.extended(
|
floatingActionButton: Obx(() => FloatingActionButton.extended(
|
||||||
onPressed:
|
onPressed:
|
||||||
isEditing.value ? _editJob : () => isEditing.value = true,
|
isEditing.value ? _editJob : () => isEditing.value = true,
|
||||||
|
|||||||
@ -50,7 +50,10 @@ class _ServiceProjectScreenState extends State<ServiceProjectScreen>
|
|||||||
borderRadius: BorderRadius.circular(14),
|
borderRadius: BorderRadius.circular(14),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Navigate to ServiceProjectDetailsScreen
|
// Navigate to ServiceProjectDetailsScreen
|
||||||
Get.to(() => ServiceProjectDetailsScreen(projectId: project.id));
|
Get.to(() => ServiceProjectDetailsScreen(
|
||||||
|
projectId: project.id,
|
||||||
|
projectName: project.name,
|
||||||
|
));
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 14),
|
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 14),
|
||||||
@ -196,6 +199,7 @@ class _ServiceProjectScreenState extends State<ServiceProjectScreen>
|
|||||||
backgroundColor: const Color(0xFFF5F5F5),
|
backgroundColor: const Color(0xFFF5F5F5),
|
||||||
appBar: CustomAppBar(
|
appBar: CustomAppBar(
|
||||||
title: "Service Projects",
|
title: "Service Projects",
|
||||||
|
projectName: 'All Service Projects',
|
||||||
onBackPressed: () => Get.toNamed('/dashboard'),
|
onBackPressed: () => Get.toNamed('/dashboard'),
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user