Project management related changes
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../projects/presentation/project_hub_screen.dart';
|
||||
import '../../projects/presentation/projects_screen.dart';
|
||||
import '../../projects/providers/project_mode_provider.dart';
|
||||
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:lucide_icons/lucide_icons.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@@ -150,6 +154,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
final walletsState = ref.watch(walletProvider);
|
||||
final invoicesState = ref.watch(invoicesProvider);
|
||||
final customersState = ref.watch(customersProvider);
|
||||
final isProjectMode = ref.watch(projectModeProvider);
|
||||
final isBusinessMode = ref.watch(businessModeProvider);
|
||||
final allTransactions = transState.value ?? [];
|
||||
|
||||
@@ -157,18 +162,21 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
final startDate = range.start;
|
||||
final endDate = range.end;
|
||||
|
||||
String title;
|
||||
if (_currentIndex == 0) {
|
||||
title = 'Dashboard';
|
||||
} else if (isBusinessMode) {
|
||||
if (_currentIndex == 1) title = 'Business Hub';
|
||||
else if (_currentIndex == 2) title = 'Statistics';
|
||||
else if (_currentIndex == 3) title = 'My Accounts';
|
||||
else title = 'Budgets';
|
||||
} else {
|
||||
if (_currentIndex == 1) title = 'Statistics';
|
||||
else if (_currentIndex == 2) title = 'My Accounts';
|
||||
else title = 'Budgets';
|
||||
String title = 'Dashboard';
|
||||
int logicalIndex = _currentIndex;
|
||||
if (logicalIndex == 0) title = 'Dashboard';
|
||||
else {
|
||||
if (isProjectMode) {
|
||||
if (logicalIndex == 1) title = 'Projects';
|
||||
logicalIndex--;
|
||||
}
|
||||
if (isBusinessMode) {
|
||||
if (logicalIndex == 1) title = 'Business Hub';
|
||||
logicalIndex--;
|
||||
}
|
||||
if (logicalIndex == 1) title = 'Statistics';
|
||||
else if (logicalIndex == 2) title = 'My Accounts';
|
||||
else if (logicalIndex == 3) title = 'Budgets';
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
@@ -400,11 +408,9 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
return IndexedStack(
|
||||
index: _currentIndex,
|
||||
children: [
|
||||
// ---------------- HOME TAB ----------------
|
||||
RefreshIndicator(
|
||||
final List<Widget> screens = [];
|
||||
|
||||
screens.add(RefreshIndicator(
|
||||
onRefresh: _onRefresh,
|
||||
child: SingleChildScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
@@ -624,13 +630,17 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
// ---------------- BUSINESS TAB ----------------
|
||||
if (isBusinessMode) const BusinessHubScreen(),
|
||||
if (isProjectMode) {
|
||||
screens.add(const ProjectHubScreen());
|
||||
}
|
||||
|
||||
// ---------------- STATS TAB ----------------
|
||||
StatisticsTab(
|
||||
if (isBusinessMode) {
|
||||
screens.add(const BusinessHubScreen());
|
||||
}
|
||||
|
||||
screens.add(StatisticsTab(
|
||||
transactions: transactions,
|
||||
wallets: safeWallets,
|
||||
categories: categoriesState.value ?? [],
|
||||
@@ -643,47 +653,64 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
},
|
||||
onPickCustomDateRange: _pickCustomDateRange,
|
||||
onRefresh: _onRefresh,
|
||||
),
|
||||
|
||||
// ---------------- WALLETS TAB ----------------
|
||||
const AccountsScreen(),
|
||||
|
||||
// ---------------- BUDGETS TAB ----------------
|
||||
const BudgetScreen(),
|
||||
],
|
||||
));
|
||||
screens.add(const AccountsScreen());
|
||||
screens.add(const BudgetScreen());
|
||||
|
||||
int safeIndex = _currentIndex;
|
||||
if (safeIndex >= screens.length) safeIndex = screens.length - 1;
|
||||
|
||||
return IndexedStack(
|
||||
index: safeIndex,
|
||||
children: screens,
|
||||
);
|
||||
},
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: isBusinessMode
|
||||
? (_currentIndex >= 3 ? _currentIndex + 1 : _currentIndex)
|
||||
: (_currentIndex >= 2 ? _currentIndex + 1 : _currentIndex),
|
||||
type: BottomNavigationBarType.fixed,
|
||||
onTap: (index) {
|
||||
final addIndex = isBusinessMode ? 3 : 2;
|
||||
if (index == addIndex) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (_) => const AddTransactionScreen()));
|
||||
} else {
|
||||
setState(() {
|
||||
_currentIndex = index > addIndex ? index - 1 : index;
|
||||
});
|
||||
}
|
||||
},
|
||||
selectedItemColor: Theme.of(context).colorScheme.primary,
|
||||
unselectedItemColor: Colors.grey,
|
||||
showSelectedLabels: true,
|
||||
showUnselectedLabels: true,
|
||||
items: [
|
||||
const BottomNavigationBarItem(icon: Icon(LucideIcons.home), label: 'Home'),
|
||||
if (isBusinessMode)
|
||||
const BottomNavigationBarItem(icon: Icon(LucideIcons.briefcase), label: 'Business'),
|
||||
const BottomNavigationBarItem(icon: Icon(LucideIcons.pieChart), label: 'Stats'),
|
||||
const BottomNavigationBarItem(icon: Icon(LucideIcons.plusCircle), label: 'Add'),
|
||||
const BottomNavigationBarItem(icon: Icon(LucideIcons.wallet), label: 'Wallets'),
|
||||
const BottomNavigationBarItem(icon: Icon(LucideIcons.target), label: 'Budgets'),
|
||||
],
|
||||
),
|
||||
);
|
||||
bottomNavigationBar: Builder(
|
||||
builder: (context) {
|
||||
final isProjectMode = ref.watch(projectModeProvider);
|
||||
final isBusinessMode = ref.watch(businessModeProvider);
|
||||
final List<BottomNavigationBarItem> navItems = [];
|
||||
navItems.add(const BottomNavigationBarItem(icon: Icon(LucideIcons.home), label: 'Home'));
|
||||
if (isProjectMode) navItems.add(const BottomNavigationBarItem(icon: Icon(LucideIcons.trello), label: 'Projects'));
|
||||
if (isBusinessMode) navItems.add(const BottomNavigationBarItem(icon: Icon(LucideIcons.briefcase), label: 'Business'));
|
||||
navItems.add(const BottomNavigationBarItem(icon: Icon(LucideIcons.pieChart), label: 'Stats'));
|
||||
navItems.add(const BottomNavigationBarItem(icon: Icon(LucideIcons.plusCircle), label: 'Add'));
|
||||
navItems.add(const BottomNavigationBarItem(icon: Icon(LucideIcons.wallet), label: 'Wallets'));
|
||||
navItems.add(const BottomNavigationBarItem(icon: Icon(LucideIcons.target), label: 'Budgets'));
|
||||
|
||||
int safeIndex = _currentIndex;
|
||||
// Adjust _currentIndex for the display of bottom nav bar because of 'Add' button
|
||||
int addIdx = 1;
|
||||
if (isProjectMode) addIdx++;
|
||||
if (isBusinessMode) addIdx++;
|
||||
addIdx++; // For Stats
|
||||
|
||||
int displayIndex = _currentIndex;
|
||||
if (_currentIndex >= addIdx) displayIndex++;
|
||||
|
||||
if (displayIndex >= navItems.length) displayIndex = navItems.length - 1;
|
||||
|
||||
return BottomNavigationBar(
|
||||
currentIndex: displayIndex,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
onTap: (index) {
|
||||
if (index == addIdx) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (_) => const AddTransactionScreen()));
|
||||
} else {
|
||||
setState(() {
|
||||
_currentIndex = index > addIdx ? index - 1 : index;
|
||||
});
|
||||
}
|
||||
},
|
||||
selectedItemColor: Theme.of(context).colorScheme.primary,
|
||||
unselectedItemColor: Colors.grey,
|
||||
showSelectedLabels: true,
|
||||
showUnselectedLabels: true,
|
||||
items: navItems,
|
||||
);
|
||||
}
|
||||
), );
|
||||
}
|
||||
|
||||
Widget _buildSummaryCard(BuildContext context, String title, double amount, Color color, IconData icon, {VoidCallback? onTap}) {
|
||||
|
||||
Reference in New Issue
Block a user