done landscape responsive of all screen
This commit is contained in:
parent
603e7ee7e5
commit
261cba9dcf
@ -282,17 +282,58 @@ class ExpenseList extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (expenseList.isEmpty && !Get.find<ExpenseController>().isLoading.value) {
|
final ExpenseController controller = Get.find<ExpenseController>();
|
||||||
return Center(child: MyText.bodyMedium('No expenses found.'));
|
|
||||||
|
return SafeArea(
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final bool isLandscape = constraints.maxWidth > constraints.maxHeight;
|
||||||
|
|
||||||
|
if (controller.isLoading.value && expenseList.isEmpty) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (expenseList.isEmpty) {
|
||||||
|
return const Center(
|
||||||
|
child: Text(
|
||||||
|
'No expenses found.',
|
||||||
|
style: TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// PORTRAIT MODE
|
||||||
|
if (!isLandscape) {
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
padding: const EdgeInsets.fromLTRB(12, 12, 12, 80),
|
padding: const EdgeInsets.fromLTRB(12, 12, 12, 80),
|
||||||
itemCount: expenseList.length,
|
itemCount: expenseList.length,
|
||||||
separatorBuilder: (_, __) =>
|
separatorBuilder: (_, __) =>
|
||||||
Divider(color: Colors.grey.shade300, height: 20),
|
Divider(color: Colors.grey.shade300, height: 20),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: _buildItem,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// LANDSCAPE → WRAP IN SCROLL FOR SAFETY
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: SizedBox(
|
||||||
|
height: constraints.maxHeight * 1.3,
|
||||||
|
child: ListView.separated(
|
||||||
|
padding: const EdgeInsets.fromLTRB(12, 12, 12, 80),
|
||||||
|
itemCount: expenseList.length,
|
||||||
|
separatorBuilder: (_, __) =>
|
||||||
|
Divider(color: Colors.grey.shade300, height: 20),
|
||||||
|
itemBuilder: _buildItem,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildItem(BuildContext context, int index) {
|
||||||
final expense = expenseList[index];
|
final expense = expenseList[index];
|
||||||
|
|
||||||
final formattedDate = DateTimeUtils.convertUtcToLocal(
|
final formattedDate = DateTimeUtils.convertUtcToLocal(
|
||||||
expense.transactionDate.toIso8601String(),
|
expense.transactionDate.toIso8601String(),
|
||||||
format: 'dd MMM yyyy',
|
format: 'dd MMM yyyy',
|
||||||
@ -303,9 +344,13 @@ class ExpenseList extends StatelessWidget {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await Get.to(
|
final result = await Get.to(
|
||||||
() => ExpenseDetailScreen(expenseId: expense.id),
|
() => ExpenseDetailScreen(expenseId: expense.id),
|
||||||
|
arguments: {'expense': expense},
|
||||||
);
|
);
|
||||||
|
if (result == true && onViewDetail != null) {
|
||||||
|
await onViewDetail!();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
@ -340,8 +385,8 @@ class ExpenseList extends StatelessWidget {
|
|||||||
MyText.bodySmall(formattedDate, fontWeight: 500),
|
MyText.bodySmall(formattedDate, fontWeight: 500),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding:
|
||||||
horizontal: 8, vertical: 4),
|
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Color(int.parse(
|
color: Color(int.parse(
|
||||||
'0xff${expense.status.color.substring(1)}'))
|
'0xff${expense.status.color.substring(1)}'))
|
||||||
@ -361,7 +406,5 @@ class ExpenseList extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -123,7 +123,6 @@ class _AttendanceFilterBottomSheetState
|
|||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
final List<Widget> widgets = [
|
final List<Widget> widgets = [
|
||||||
// 🔹 View Section
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 4),
|
padding: const EdgeInsets.only(bottom: 4),
|
||||||
child: Align(
|
child: Align(
|
||||||
@ -146,7 +145,6 @@ class _AttendanceFilterBottomSheetState
|
|||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
// 🔹 Organization filter
|
|
||||||
widgets.addAll([
|
widgets.addAll([
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Padding(
|
Padding(
|
||||||
@ -165,24 +163,6 @@ class _AttendanceFilterBottomSheetState
|
|||||||
color: Colors.grey.shade300,
|
color: Colors.grey.shade300,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: 100,
|
|
||||||
height: 14,
|
|
||||||
color: Colors.grey.shade400,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: 18,
|
|
||||||
height: 18,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.grey.shade400,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
} else if (widget.controller.organizations.isEmpty) {
|
} else if (widget.controller.organizations.isEmpty) {
|
||||||
return Center(
|
return Center(
|
||||||
@ -200,7 +180,6 @@ class _AttendanceFilterBottomSheetState
|
|||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 🔹 Date Range (only for Attendance Logs)
|
|
||||||
if (tempSelectedTab == 'attendanceLogs') {
|
if (tempSelectedTab == 'attendanceLogs') {
|
||||||
widgets.addAll([
|
widgets.addAll([
|
||||||
const Divider(),
|
const Divider(),
|
||||||
@ -211,16 +190,12 @@ class _AttendanceFilterBottomSheetState
|
|||||||
child: MyText.titleSmall("Date Range", fontWeight: 600),
|
child: MyText.titleSmall("Date Range", fontWeight: 600),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// ✅ Reusable DateRangePickerWidget
|
|
||||||
DateRangePickerWidget(
|
DateRangePickerWidget(
|
||||||
startDate: widget.controller.startDateAttendance,
|
startDate: widget.controller.startDateAttendance,
|
||||||
endDate: widget.controller.endDateAttendance,
|
endDate: widget.controller.endDateAttendance,
|
||||||
startLabel: "Start Date",
|
startLabel: "Start Date",
|
||||||
endLabel: "End Date",
|
endLabel: "End Date",
|
||||||
onDateRangeSelected: (start, end) {
|
onDateRangeSelected: (_, __) => setState(() {}),
|
||||||
// Optional: trigger UI updates if needed
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -232,19 +207,37 @@ class _AttendanceFilterBottomSheetState
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
|
||||||
child: BaseBottomSheet(
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final bool isLandscape = constraints.maxWidth > constraints.maxHeight;
|
||||||
|
|
||||||
|
return BaseBottomSheet(
|
||||||
title: "Attendance Filter",
|
title: "Attendance Filter",
|
||||||
submitText: "Apply",
|
submitText: "Apply",
|
||||||
onCancel: () => Navigator.pop(context),
|
onCancel: () => Navigator.pop(context),
|
||||||
onSubmit: () => Navigator.pop(context, {
|
onSubmit: () => Navigator.pop(context, {
|
||||||
'selectedTab': tempSelectedTab,
|
'selectedTab': tempSelectedTab,
|
||||||
'selectedOrganization': widget.controller.selectedOrganization?.id,
|
'selectedOrganization':
|
||||||
|
widget.controller.selectedOrganization?.id,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// ---------------- UPDATED RESPONSIVE CHILD ----------------
|
||||||
|
child: SizedBox(
|
||||||
|
height: isLandscape
|
||||||
|
? constraints.maxHeight // 🔥 Full screen in landscape
|
||||||
|
: constraints.maxHeight * 0.78, // normal in portrait
|
||||||
|
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.only(bottom: 24),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: buildMainFilters(),
|
children: buildMainFilters(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,12 +58,10 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
if (widget.isEdit && widget.existingData != null) {
|
if (widget.isEdit && widget.existingData != null) {
|
||||||
final data = widget.existingData!;
|
final data = widget.existingData!;
|
||||||
|
|
||||||
// Prefill text fields
|
|
||||||
controller.titleController.text = data["title"] ?? "";
|
controller.titleController.text = data["title"] ?? "";
|
||||||
controller.amountController.text = data["amount"]?.toString() ?? "";
|
controller.amountController.text = data["amount"]?.toString() ?? "";
|
||||||
controller.descriptionController.text = data["description"] ?? "";
|
controller.descriptionController.text = data["description"] ?? "";
|
||||||
|
|
||||||
// Prefill due date
|
|
||||||
if (data["dueDate"] != null && data["dueDate"].toString().isNotEmpty) {
|
if (data["dueDate"] != null && data["dueDate"].toString().isNotEmpty) {
|
||||||
DateTime? dueDate = DateTime.tryParse(data["dueDate"].toString());
|
DateTime? dueDate = DateTime.tryParse(data["dueDate"].toString());
|
||||||
if (dueDate != null) {
|
if (dueDate != null) {
|
||||||
@ -73,15 +71,14 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefill dropdowns & toggles
|
|
||||||
controller.selectedProject.value = {
|
controller.selectedProject.value = {
|
||||||
'id': data["projectId"],
|
'id': data["projectId"],
|
||||||
'name': data["projectName"],
|
'name': data["projectName"],
|
||||||
};
|
};
|
||||||
|
|
||||||
controller.selectedPayee.value = data["payee"] ?? "";
|
controller.selectedPayee.value = data["payee"] ?? "";
|
||||||
controller.isAdvancePayment.value = data["isAdvancePayment"] ?? false;
|
controller.isAdvancePayment.value = data["isAdvancePayment"] ?? false;
|
||||||
|
|
||||||
// Categories & currencies
|
|
||||||
everAll([controller.categories, controller.currencies], (_) {
|
everAll([controller.categories, controller.currencies], (_) {
|
||||||
controller.selectedCategory.value = controller.categories
|
controller.selectedCategory.value = controller.categories
|
||||||
.firstWhereOrNull((c) => c.id == data["expenseCategoryId"]);
|
.firstWhereOrNull((c) => c.id == data["expenseCategoryId"]);
|
||||||
@ -89,7 +86,6 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
.firstWhereOrNull((c) => c.id == data["currencyId"]);
|
.firstWhereOrNull((c) => c.id == data["currencyId"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attachments
|
|
||||||
final attachmentsData = data["attachments"];
|
final attachmentsData = data["attachments"];
|
||||||
if (attachmentsData != null &&
|
if (attachmentsData != null &&
|
||||||
attachmentsData is List &&
|
attachmentsData is List &&
|
||||||
@ -116,7 +112,8 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Obx(() => Form(
|
return Obx(() => SafeArea(
|
||||||
|
child: Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: BaseBottomSheet(
|
child: BaseBottomSheet(
|
||||||
title: widget.isEdit
|
title: widget.isEdit
|
||||||
@ -126,8 +123,10 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
onCancel: Get.back,
|
onCancel: Get.back,
|
||||||
submitText: "Save as Draft",
|
submitText: "Save as Draft",
|
||||||
onSubmit: () async {
|
onSubmit: () async {
|
||||||
if (_formKey.currentState!.validate() && _validateSelections()) {
|
if (_formKey.currentState!.validate() &&
|
||||||
|
_validateSelections()) {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
if (widget.isEdit && widget.existingData != null) {
|
if (widget.isEdit && widget.existingData != null) {
|
||||||
final requestId =
|
final requestId =
|
||||||
widget.existingData!['id']?.toString() ?? '';
|
widget.existingData!['id']?.toString() ?? '';
|
||||||
@ -144,7 +143,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
Get.back();
|
Get.back();
|
||||||
if (widget.onUpdated != null) widget.onUpdated!();
|
widget.onUpdated?.call();
|
||||||
|
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
title: "Success",
|
title: "Success",
|
||||||
@ -157,8 +156,10 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.only(bottom: 20),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
_buildDropdown(
|
_buildDropdown(
|
||||||
"Select Project",
|
"Select Project",
|
||||||
@ -168,7 +169,8 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
controller.globalProjects,
|
controller.globalProjects,
|
||||||
(p) => p['name'],
|
(p) => p['name'],
|
||||||
controller.selectProject,
|
controller.selectProject,
|
||||||
key: _projectDropdownKey),
|
key: _projectDropdownKey,
|
||||||
|
),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildDropdown(
|
_buildDropdown(
|
||||||
"Expense Category",
|
"Expense Category",
|
||||||
@ -178,14 +180,19 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
controller.categories,
|
controller.categories,
|
||||||
(c) => c.name,
|
(c) => c.name,
|
||||||
controller.selectCategory,
|
controller.selectCategory,
|
||||||
key: _categoryDropdownKey),
|
key: _categoryDropdownKey,
|
||||||
|
),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildTextField(
|
_buildTextField("Title", Icons.title_outlined,
|
||||||
"Title", Icons.title_outlined, controller.titleController,
|
controller.titleController,
|
||||||
hint: "Enter title", validator: Validators.requiredField),
|
hint: "Enter title",
|
||||||
|
validator: Validators.requiredField),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildRadio("Is Advance Payment", Icons.attach_money_outlined,
|
_buildRadio(
|
||||||
controller.isAdvancePayment, ["Yes", "No"]),
|
"Is Advance Payment",
|
||||||
|
Icons.attach_money_outlined,
|
||||||
|
controller.isAdvancePayment,
|
||||||
|
["Yes", "No"]),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildDueDateField(),
|
_buildDueDateField(),
|
||||||
_gap(),
|
_gap(),
|
||||||
@ -209,7 +216,8 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
controller.currencies,
|
controller.currencies,
|
||||||
(c) => c.currencyName,
|
(c) => c.currencyName,
|
||||||
controller.selectCurrency,
|
controller.selectCurrency,
|
||||||
key: _currencyDropdownKey),
|
key: _currencyDropdownKey,
|
||||||
|
),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildTextField("Description", Icons.description_outlined,
|
_buildTextField("Description", Icons.description_outlined,
|
||||||
controller.descriptionController,
|
controller.descriptionController,
|
||||||
@ -218,10 +226,12 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
validator: Validators.requiredField),
|
validator: Validators.requiredField),
|
||||||
_gap(),
|
_gap(),
|
||||||
_buildAttachmentsSection(),
|
_buildAttachmentsSection(),
|
||||||
|
MySpacing.height(30),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,6 +294,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
final i = entry.key;
|
final i = entry.key;
|
||||||
final label = entry.value;
|
final label = entry.value;
|
||||||
final value = i == 0;
|
final value = i == 0;
|
||||||
|
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: RadioListTile<bool>(
|
child: RadioListTile<bool>(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
@ -354,7 +365,6 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
|||||||
displayStringForOption: (option) => option,
|
displayStringForOption: (option) => option,
|
||||||
fieldViewBuilder:
|
fieldViewBuilder:
|
||||||
(context, fieldController, focusNode, onFieldSubmitted) {
|
(context, fieldController, focusNode, onFieldSubmitted) {
|
||||||
// Avoid updating during build
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (fieldController.text != controller.selectedPayee.value) {
|
if (fieldController.text != controller.selectedPayee.value) {
|
||||||
fieldController.text = controller.selectedPayee.value;
|
fieldController.text = controller.selectedPayee.value;
|
||||||
|
|||||||
@ -99,7 +99,8 @@ class _DirectoryMainScreenState extends State<DirectoryMainScreen>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Column(
|
body: SafeArea(
|
||||||
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
// ---------------- TabBar ----------------
|
// ---------------- TabBar ----------------
|
||||||
Container(
|
Container(
|
||||||
@ -116,8 +117,18 @@ class _DirectoryMainScreenState extends State<DirectoryMainScreen>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// ---------------- TabBarView ----------------
|
// ---------------- TabBarView + Scroll / Landscape Support ----------------
|
||||||
Expanded(
|
Expanded(
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final bool isLandscape =
|
||||||
|
constraints.maxWidth > constraints.maxHeight;
|
||||||
|
|
||||||
|
if (isLandscape) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
child: SizedBox(
|
||||||
|
height: constraints.maxHeight * 1.3,
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
children: [
|
children: [
|
||||||
@ -126,7 +137,22 @@ class _DirectoryMainScreenState extends State<DirectoryMainScreen>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Portrait
|
||||||
|
return TabBarView(
|
||||||
|
controller: _tabController,
|
||||||
|
children: [
|
||||||
|
DirectoryView(),
|
||||||
|
NotesView(),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,12 +49,16 @@ class _AdvancePaymentScreenState extends State<AdvancePaymentScreen>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(
|
backgroundColor: const Color(0xFFF5F5F5),
|
||||||
0xFFF5F5F5),
|
|
||||||
appBar: _buildAppBar(),
|
appBar: _buildAppBar(),
|
||||||
body: GestureDetector(
|
body: SafeArea(
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final bool isLandscape =
|
||||||
|
constraints.maxWidth > constraints.maxHeight;
|
||||||
|
|
||||||
|
return GestureDetector(
|
||||||
onTap: () => FocusScope.of(context).unfocus(),
|
onTap: () => FocusScope.of(context).unfocus(),
|
||||||
child: RefreshIndicator(
|
child: RefreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
@ -67,11 +71,13 @@ class _AdvancePaymentScreenState extends State<AdvancePaymentScreen>
|
|||||||
backgroundColor: contentTheme.primary,
|
backgroundColor: contentTheme.primary,
|
||||||
strokeWidth: 2.5,
|
strokeWidth: 2.5,
|
||||||
displacement: 60,
|
displacement: 60,
|
||||||
child: SingleChildScrollView(
|
|
||||||
|
// ---------------- PORTRAIT (UNCHANGED) ----------------
|
||||||
|
child: !isLandscape
|
||||||
|
? SingleChildScrollView(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
child: Container(
|
child: Container(
|
||||||
color:
|
color: const Color(0xFFF5F5F5),
|
||||||
const Color(0xFFF5F5F5),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
_buildSearchBar(),
|
_buildSearchBar(),
|
||||||
@ -81,9 +87,36 @@ class _AdvancePaymentScreenState extends State<AdvancePaymentScreen>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
// ---------------- LANDSCAPE (FIXED) ----------------
|
||||||
|
: SingleChildScrollView(
|
||||||
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
color: const Color(0xFFF5F5F5),
|
||||||
|
|
||||||
|
// ❗ Removed IntrinsicHeight
|
||||||
|
// ❗ Removed ConstrainedBox
|
||||||
|
// Dropdown can now open freely
|
||||||
|
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
_buildSearchBar(),
|
||||||
|
_buildEmployeeDropdown(
|
||||||
|
context), // now overlay works
|
||||||
|
_buildTopBalance(),
|
||||||
|
_buildPaymentList(),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -113,14 +113,21 @@ class _FinanceScreenState extends State<FinanceScreen>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: FadeTransition(
|
body: SafeArea(
|
||||||
|
child: FadeTransition(
|
||||||
opacity: _fadeAnimation,
|
opacity: _fadeAnimation,
|
||||||
child: Obx(() {
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final bool isLandscape =
|
||||||
|
constraints.maxWidth > constraints.maxHeight;
|
||||||
|
|
||||||
|
return Obx(() {
|
||||||
if (menuController.isLoading.value) {
|
if (menuController.isLoading.value) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menuController.hasError.value || menuController.menuItems.isEmpty) {
|
if (menuController.hasError.value ||
|
||||||
|
menuController.menuItems.isEmpty) {
|
||||||
return const Center(
|
return const Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Failed to load menus. Please try again later.",
|
"Failed to load menus. Please try again later.",
|
||||||
@ -149,6 +156,8 @@ class _FinanceScreenState extends State<FinanceScreen>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------- PORTRAIT MODE ----------------------
|
||||||
|
if (!isLandscape) {
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -163,7 +172,41 @@ class _FinanceScreenState extends State<FinanceScreen>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}
|
||||||
|
|
||||||
|
// ---------------------- LANDSCAPE MODE ----------------------
|
||||||
|
return SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_buildFinanceModulesCompact(financeMenus),
|
||||||
|
MySpacing.height(24),
|
||||||
|
|
||||||
|
// Wider charts behave better side-by-side or full width
|
||||||
|
SizedBox(
|
||||||
|
width: constraints.maxWidth,
|
||||||
|
child: ExpenseByStatusWidget(
|
||||||
|
controller: dashboardController),
|
||||||
|
),
|
||||||
|
MySpacing.height(24),
|
||||||
|
|
||||||
|
SizedBox(
|
||||||
|
width: constraints.maxWidth,
|
||||||
|
child: ExpenseTypeReportChart(),
|
||||||
|
),
|
||||||
|
MySpacing.height(24),
|
||||||
|
|
||||||
|
SizedBox(
|
||||||
|
width: constraints.maxWidth,
|
||||||
|
child: MonthlyExpenseDashboardChart(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -172,9 +215,12 @@ class _FinanceScreenState extends State<FinanceScreen>
|
|||||||
Widget _buildFinanceModulesCompact(List<MenuItem> financeMenus) {
|
Widget _buildFinanceModulesCompact(List<MenuItem> financeMenus) {
|
||||||
// Map menu IDs to icon + color
|
// Map menu IDs to icon + color
|
||||||
final Map<String, _FinanceCardMeta> financeCardMeta = {
|
final Map<String, _FinanceCardMeta> financeCardMeta = {
|
||||||
MenuItems.expenseReimbursement: _FinanceCardMeta(LucideIcons.badge_dollar_sign, contentTheme.info),
|
MenuItems.expenseReimbursement:
|
||||||
MenuItems.paymentRequests: _FinanceCardMeta(LucideIcons.receipt_text, contentTheme.primary),
|
_FinanceCardMeta(LucideIcons.badge_dollar_sign, contentTheme.info),
|
||||||
MenuItems.advancePaymentStatements: _FinanceCardMeta(LucideIcons.wallet, contentTheme.warning),
|
MenuItems.paymentRequests:
|
||||||
|
_FinanceCardMeta(LucideIcons.receipt_text, contentTheme.primary),
|
||||||
|
MenuItems.advancePaymentStatements:
|
||||||
|
_FinanceCardMeta(LucideIcons.wallet, contentTheme.warning),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Build the stat items using API-provided mobileLink
|
// Build the stat items using API-provided mobileLink
|
||||||
@ -198,14 +244,16 @@ Widget _buildFinanceModulesCompact(List<MenuItem> financeMenus) {
|
|||||||
return LayoutBuilder(builder: (context, constraints) {
|
return LayoutBuilder(builder: (context, constraints) {
|
||||||
// Determine number of columns dynamically
|
// Determine number of columns dynamically
|
||||||
int crossAxisCount = (constraints.maxWidth ~/ 80).clamp(2, 4);
|
int crossAxisCount = (constraints.maxWidth ~/ 80).clamp(2, 4);
|
||||||
double cardWidth = (constraints.maxWidth - (crossAxisCount - 1) * 6) / crossAxisCount;
|
double cardWidth =
|
||||||
|
(constraints.maxWidth - (crossAxisCount - 1) * 6) / crossAxisCount;
|
||||||
|
|
||||||
return Wrap(
|
return Wrap(
|
||||||
spacing: 6,
|
spacing: 6,
|
||||||
runSpacing: 6,
|
runSpacing: 6,
|
||||||
alignment: WrapAlignment.end,
|
alignment: WrapAlignment.end,
|
||||||
children: stats
|
children: stats
|
||||||
.map((stat) => _buildFinanceModuleCard(stat, projectSelected, cardWidth))
|
.map((stat) =>
|
||||||
|
_buildFinanceModuleCard(stat, projectSelected, cardWidth))
|
||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -99,8 +99,15 @@ class _PaymentRequestMainScreenState extends State<PaymentRequestMainScreen>
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
appBar: _buildAppBar(),
|
appBar: _buildAppBar(),
|
||||||
body: Column(
|
body: SafeArea(
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final bool isLandscape =
|
||||||
|
constraints.maxWidth > constraints.maxHeight;
|
||||||
|
|
||||||
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
|
// ---------------- TabBar ----------------
|
||||||
Container(
|
Container(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: TabBar(
|
child: TabBar(
|
||||||
@ -114,10 +121,35 @@ class _PaymentRequestMainScreenState extends State<PaymentRequestMainScreen>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// ---------------- Content Area ----------------
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Colors.grey[100],
|
color: Colors.grey[100],
|
||||||
|
child: isLandscape
|
||||||
|
? SingleChildScrollView(
|
||||||
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
child: SizedBox(
|
||||||
|
height: constraints.maxHeight * 1.3,
|
||||||
child: Column(
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_buildSearchBar(),
|
||||||
|
Expanded(
|
||||||
|
child: TabBarView(
|
||||||
|
controller: _tabController,
|
||||||
|
children: [
|
||||||
|
_buildPaymentRequestList(
|
||||||
|
isHistory: false),
|
||||||
|
_buildPaymentRequestList(
|
||||||
|
isHistory: true),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Column(
|
||||||
children: [
|
children: [
|
||||||
_buildSearchBar(),
|
_buildSearchBar(),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -134,6 +166,9 @@ class _PaymentRequestMainScreenState extends State<PaymentRequestMainScreen>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: Obx(() {
|
floatingActionButton: Obx(() {
|
||||||
if (permissionController.permissions.isEmpty) {
|
if (permissionController.permissions.isEmpty) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user