done landscape responsive of all screen

This commit is contained in:
Manish 2025-11-18 10:50:50 +05:30
parent d05e26bc87
commit c94efac1de
7 changed files with 606 additions and 422 deletions

View File

@ -282,17 +282,58 @@ class ExpenseList extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (expenseList.isEmpty && !Get.find<ExpenseController>().isLoading.value) {
return Center(child: MyText.bodyMedium('No expenses found.'));
final ExpenseController controller = Get.find<ExpenseController>();
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(
padding: const EdgeInsets.fromLTRB(12, 12, 12, 80),
itemCount: expenseList.length,
separatorBuilder: (_, __) =>
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 formattedDate = DateTimeUtils.convertUtcToLocal(
expense.transactionDate.toIso8601String(),
format: 'dd MMM yyyy',
@ -344,8 +385,8 @@ class ExpenseList extends StatelessWidget {
MyText.bodySmall(formattedDate, fontWeight: 500),
const Spacer(),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 4),
padding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Color(int.parse(
'0xff${expense.status.color.substring(1)}'))
@ -365,7 +406,5 @@ class ExpenseList extends StatelessWidget {
),
),
);
},
);
}
}

View File

@ -123,7 +123,6 @@ class _AttendanceFilterBottomSheetState
}).toList();
final List<Widget> widgets = [
// 🔹 View Section
Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Align(
@ -146,7 +145,6 @@ class _AttendanceFilterBottomSheetState
}),
];
// 🔹 Organization filter
widgets.addAll([
const Divider(),
Padding(
@ -165,24 +163,6 @@ class _AttendanceFilterBottomSheetState
color: Colors.grey.shade300,
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) {
return Center(
@ -200,7 +180,6 @@ class _AttendanceFilterBottomSheetState
}),
]);
// 🔹 Date Range (only for Attendance Logs)
if (tempSelectedTab == 'attendanceLogs') {
widgets.addAll([
const Divider(),
@ -211,16 +190,12 @@ class _AttendanceFilterBottomSheetState
child: MyText.titleSmall("Date Range", fontWeight: 600),
),
),
// Reusable DateRangePickerWidget
DateRangePickerWidget(
startDate: widget.controller.startDateAttendance,
endDate: widget.controller.endDateAttendance,
startLabel: "Start Date",
endLabel: "End Date",
onDateRangeSelected: (start, end) {
// Optional: trigger UI updates if needed
setState(() {});
},
onDateRangeSelected: (_, __) => setState(() {}),
),
]);
}
@ -232,19 +207,37 @@ class _AttendanceFilterBottomSheetState
Widget build(BuildContext context) {
return ClipRRect(
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",
submitText: "Apply",
onCancel: () => Navigator.pop(context),
onSubmit: () => Navigator.pop(context, {
'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(
crossAxisAlignment: CrossAxisAlignment.start,
children: buildMainFilters(),
),
),
),
);
},
),
);
}
}

View File

@ -58,12 +58,10 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
if (widget.isEdit && widget.existingData != null) {
final data = widget.existingData!;
// Prefill text fields
controller.titleController.text = data["title"] ?? "";
controller.amountController.text = data["amount"]?.toString() ?? "";
controller.descriptionController.text = data["description"] ?? "";
// Prefill due date
if (data["dueDate"] != null && data["dueDate"].toString().isNotEmpty) {
DateTime? dueDate = DateTime.tryParse(data["dueDate"].toString());
if (dueDate != null) {
@ -73,15 +71,14 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
}
}
// Prefill dropdowns & toggles
controller.selectedProject.value = {
'id': data["projectId"],
'name': data["projectName"],
};
controller.selectedPayee.value = data["payee"] ?? "";
controller.isAdvancePayment.value = data["isAdvancePayment"] ?? false;
// Categories & currencies
everAll([controller.categories, controller.currencies], (_) {
controller.selectedCategory.value = controller.categories
.firstWhereOrNull((c) => c.id == data["expenseCategoryId"]);
@ -89,7 +86,6 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
.firstWhereOrNull((c) => c.id == data["currencyId"]);
});
// Attachments
final attachmentsData = data["attachments"];
if (attachmentsData != null &&
attachmentsData is List &&
@ -116,7 +112,8 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
@override
Widget build(BuildContext context) {
return Obx(() => Form(
return Obx(() => SafeArea(
child: Form(
key: _formKey,
child: BaseBottomSheet(
title: widget.isEdit
@ -126,8 +123,10 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
onCancel: Get.back,
submitText: "Save as Draft",
onSubmit: () async {
if (_formKey.currentState!.validate() && _validateSelections()) {
if (_formKey.currentState!.validate() &&
_validateSelections()) {
bool success = false;
if (widget.isEdit && widget.existingData != null) {
final requestId =
widget.existingData!['id']?.toString() ?? '';
@ -144,7 +143,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
if (success) {
Get.back();
if (widget.onUpdated != null) widget.onUpdated!();
widget.onUpdated?.call();
showAppSnackbar(
title: "Success",
@ -157,8 +156,10 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
}
},
child: SingleChildScrollView(
padding: const EdgeInsets.only(bottom: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
_buildDropdown(
"Select Project",
@ -168,7 +169,8 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
controller.globalProjects,
(p) => p['name'],
controller.selectProject,
key: _projectDropdownKey),
key: _projectDropdownKey,
),
_gap(),
_buildDropdown(
"Expense Category",
@ -178,14 +180,19 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
controller.categories,
(c) => c.name,
controller.selectCategory,
key: _categoryDropdownKey),
key: _categoryDropdownKey,
),
_gap(),
_buildTextField(
"Title", Icons.title_outlined, controller.titleController,
hint: "Enter title", validator: Validators.requiredField),
_buildTextField("Title", Icons.title_outlined,
controller.titleController,
hint: "Enter title",
validator: Validators.requiredField),
_gap(),
_buildRadio("Is Advance Payment", Icons.attach_money_outlined,
controller.isAdvancePayment, ["Yes", "No"]),
_buildRadio(
"Is Advance Payment",
Icons.attach_money_outlined,
controller.isAdvancePayment,
["Yes", "No"]),
_gap(),
_buildDueDateField(),
_gap(),
@ -209,7 +216,8 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
controller.currencies,
(c) => c.currencyName,
controller.selectCurrency,
key: _currencyDropdownKey),
key: _currencyDropdownKey,
),
_gap(),
_buildTextField("Description", Icons.description_outlined,
controller.descriptionController,
@ -218,10 +226,12 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
validator: Validators.requiredField),
_gap(),
_buildAttachmentsSection(),
MySpacing.height(30),
],
),
),
),
),
));
}
@ -284,6 +294,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
final i = entry.key;
final label = entry.value;
final value = i == 0;
return Expanded(
child: RadioListTile<bool>(
contentPadding: EdgeInsets.zero,
@ -354,7 +365,6 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
displayStringForOption: (option) => option,
fieldViewBuilder:
(context, fieldController, focusNode, onFieldSubmitted) {
// Avoid updating during build
WidgetsBinding.instance.addPostFrameCallback((_) {
if (fieldController.text != controller.selectedPayee.value) {
fieldController.text = controller.selectedPayee.value;

View File

@ -99,7 +99,8 @@ class _DirectoryMainScreenState extends State<DirectoryMainScreen>
),
),
),
body: Column(
body: SafeArea(
child: Column(
children: [
// ---------------- TabBar ----------------
Container(
@ -116,8 +117,18 @@ class _DirectoryMainScreenState extends State<DirectoryMainScreen>
),
),
// ---------------- TabBarView ----------------
// ---------------- TabBarView + Scroll / Landscape Support ----------------
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(
controller: _tabController,
children: [
@ -126,7 +137,22 @@ class _DirectoryMainScreenState extends State<DirectoryMainScreen>
],
),
),
);
}
// Portrait
return TabBarView(
controller: _tabController,
children: [
DirectoryView(),
NotesView(),
],
);
},
),
),
],
),
),
);
}

View File

@ -49,12 +49,16 @@ class _AdvancePaymentScreenState extends State<AdvancePaymentScreen>
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(
0xFFF5F5F5),
backgroundColor: const Color(0xFFF5F5F5),
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(),
child: RefreshIndicator(
onRefresh: () async {
@ -67,11 +71,13 @@ class _AdvancePaymentScreenState extends State<AdvancePaymentScreen>
backgroundColor: contentTheme.primary,
strokeWidth: 2.5,
displacement: 60,
child: SingleChildScrollView(
// ---------------- PORTRAIT (UNCHANGED) ----------------
child: !isLandscape
? SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Container(
color:
const Color(0xFFF5F5F5),
color: const Color(0xFFF5F5F5),
child: Column(
children: [
_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(),
],
),
),
),
),
);
},
),
),
);
}

View File

@ -113,14 +113,21 @@ class _FinanceScreenState extends State<FinanceScreen>
),
),
),
body: FadeTransition(
body: SafeArea(
child: FadeTransition(
opacity: _fadeAnimation,
child: Obx(() {
child: LayoutBuilder(
builder: (context, constraints) {
final bool isLandscape =
constraints.maxWidth > constraints.maxHeight;
return Obx(() {
if (menuController.isLoading.value) {
return const Center(child: CircularProgressIndicator());
}
if (menuController.hasError.value || menuController.menuItems.isEmpty) {
if (menuController.hasError.value ||
menuController.menuItems.isEmpty) {
return const Center(
child: Text(
"Failed to load menus. Please try again later.",
@ -149,6 +156,8 @@ class _FinanceScreenState extends State<FinanceScreen>
);
}
// ---------------------- PORTRAIT MODE ----------------------
if (!isLandscape) {
return SingleChildScrollView(
padding: const EdgeInsets.all(16),
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) {
// Map menu IDs to icon + color
final Map<String, _FinanceCardMeta> financeCardMeta = {
MenuItems.expenseReimbursement: _FinanceCardMeta(LucideIcons.badge_dollar_sign, contentTheme.info),
MenuItems.paymentRequests: _FinanceCardMeta(LucideIcons.receipt_text, contentTheme.primary),
MenuItems.advancePaymentStatements: _FinanceCardMeta(LucideIcons.wallet, contentTheme.warning),
MenuItems.expenseReimbursement:
_FinanceCardMeta(LucideIcons.badge_dollar_sign, contentTheme.info),
MenuItems.paymentRequests:
_FinanceCardMeta(LucideIcons.receipt_text, contentTheme.primary),
MenuItems.advancePaymentStatements:
_FinanceCardMeta(LucideIcons.wallet, contentTheme.warning),
};
// Build the stat items using API-provided mobileLink
@ -198,14 +244,16 @@ Widget _buildFinanceModulesCompact(List<MenuItem> financeMenus) {
return LayoutBuilder(builder: (context, constraints) {
// Determine number of columns dynamically
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(
spacing: 6,
runSpacing: 6,
alignment: WrapAlignment.end,
children: stats
.map((stat) => _buildFinanceModuleCard(stat, projectSelected, cardWidth))
.map((stat) =>
_buildFinanceModuleCard(stat, projectSelected, cardWidth))
.toList(),
);
});

View File

@ -88,8 +88,15 @@ class _PaymentRequestMainScreenState extends State<PaymentRequestMainScreen>
return Scaffold(
backgroundColor: Colors.white,
appBar: _buildAppBar(),
body: Column(
body: SafeArea(
child: LayoutBuilder(
builder: (context, constraints) {
final bool isLandscape =
constraints.maxWidth > constraints.maxHeight;
return Column(
children: [
// ---------------- TabBar ----------------
Container(
color: Colors.white,
child: TabBar(
@ -103,10 +110,35 @@ class _PaymentRequestMainScreenState extends State<PaymentRequestMainScreen>
],
),
),
// ---------------- Content Area ----------------
Expanded(
child: Container(
color: Colors.grey[100],
child: isLandscape
? SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: SizedBox(
height: constraints.maxHeight * 1.3,
child: Column(
children: [
_buildSearchBar(),
Expanded(
child: TabBarView(
controller: _tabController,
children: [
_buildPaymentRequestList(
isHistory: false),
_buildPaymentRequestList(
isHistory: true),
],
),
),
],
),
),
)
: Column(
children: [
_buildSearchBar(),
Expanded(
@ -123,6 +155,9 @@ class _PaymentRequestMainScreenState extends State<PaymentRequestMainScreen>
),
),
],
);
},
),
),
floatingActionButton: Obx(() {
if (permissionController.permissions.isEmpty) {