diff --git a/lib/bindings/dashboard.dart b/lib/bindings/dashboard.dart index d9936d5..97695ae 100644 --- a/lib/bindings/dashboard.dart +++ b/lib/bindings/dashboard.dart @@ -5,6 +5,6 @@ import 'package:how_much/controllers/helpers/nav_bar.dart'; class DashboardBindings extends Bindings { @override void dependencies() { - Get.put(NavigationController()); + Get.put(NavigationController(), permanent: true); } } diff --git a/lib/bindings/edit_assets.dart b/lib/bindings/edit_assets.dart index bed5bec..fd8ae0f 100644 --- a/lib/bindings/edit_assets.dart +++ b/lib/bindings/edit_assets.dart @@ -6,7 +6,7 @@ import 'package:how_much/controllers/add/new_category.dart'; class EditAssetsBindings extends Bindings { @override void dependencies() { - Get.put(AddNewAssetController()); - Get.put(AddNewCategoryController()); + Get.put(AddNewAssetController(), permanent: true); + Get.put(AddNewCategoryController(), permanent: true); } } diff --git a/lib/controllers/helpers/nav_bar.dart b/lib/controllers/helpers/nav_bar.dart index b2d426f..02c9646 100644 --- a/lib/controllers/helpers/nav_bar.dart +++ b/lib/controllers/helpers/nav_bar.dart @@ -13,8 +13,6 @@ class NavigationController extends GetxController { case 1: Get.toNamed('/settings'); break; - case 2: - break; } } } diff --git a/lib/controllers/login.dart b/lib/controllers/login.dart index 2a573ab..afda528 100644 --- a/lib/controllers/login.dart +++ b/lib/controllers/login.dart @@ -72,11 +72,11 @@ class LoginController extends GetxController { // initialize these controllers after successful login immediately // we need this for being able to map asset symbols to names - Get.put(AssetTableController()); + Get.put(AssetTableController(), permanent: true); // this is for snapshot controller to be able to fetch prices PriceTablesController priceTablesController = - Get.put(PriceTablesController()); + Get.put(PriceTablesController(), permanent: true); if (priceTablesController.loading.value) { // Wait until priceTableController.loading becomes false await priceTablesController.loading.stream @@ -85,7 +85,8 @@ class LoginController extends GetxController { // snapshots are needed for creating the report, and for the userAssets // this is also setting the `newUser` observable - SnapshotsController snapshotsController = Get.put(SnapshotsController()); + SnapshotsController snapshotsController = + Get.put(SnapshotsController(), permanent: true); if (snapshotsController.loading.value) { // Wait until snapshotsController.loading becomes false await snapshotsController.loading.stream @@ -93,7 +94,8 @@ class LoginController extends GetxController { } // this controls what will be displayed in the dashboard, along with the report - UserAssetsController userAssetsController = Get.put(UserAssetsController()); + UserAssetsController userAssetsController = + Get.put(UserAssetsController(), permanent: true); if (userAssetsController.loading.value) { // Wait until userAssetsController.loading becomes false await userAssetsController.loading.stream @@ -101,10 +103,11 @@ class LoginController extends GetxController { } // date controller will set the dates for Report Controller - Get.put(DateController()); + Get.put(DateController(), permanent: true); // we need report controller for both edit assets screen and for dashboard - ReportController reportController = Get.put(ReportController()); + ReportController reportController = + Get.put(ReportController(), permanent: true); if (reportController.loading.value) { // Wait until reportController.loading becomes false await reportController.loading.stream @@ -112,12 +115,12 @@ class LoginController extends GetxController { } // this lets us display the total amount in other currencies - Get.put(CurrencyController()); + Get.put(CurrencyController(), permanent: true); if (snapshotsController.newUser) { - Get.toNamed('/intro'); + Get.offAllNamed('/intro'); } else { - Get.toNamed('/dashboard'); + Get.offAllNamed('/dashboard'); } } diff --git a/lib/controllers/snapshots_controller.dart b/lib/controllers/snapshots_controller.dart index dcf7046..7e05984 100644 --- a/lib/controllers/snapshots_controller.dart +++ b/lib/controllers/snapshots_controller.dart @@ -38,7 +38,7 @@ class SnapshotsController extends GetxController { if (!foundSnapshots) { // couldn't find any local snapshot, fetch transactions from the server TransactionsController transactionsController = - Get.put(TransactionsController()); + Get.put(TransactionsController(), permanent: true); // if there are no transactions, it means we are dealing with a new user bool wereThereAnyTransactions = diff --git a/lib/presentation/pages/main/notifications.dart b/lib/presentation/pages/main/notifications.dart index 69ce3b0..bd8e24c 100644 --- a/lib/presentation/pages/main/notifications.dart +++ b/lib/presentation/pages/main/notifications.dart @@ -19,8 +19,7 @@ class NotificationsPage extends GetView { appBar: AppBar( leading: BackButton( onPressed: () { - navigationController.selectedIndex.value = 0; - Get.toNamed('/dashboard'); + navigationController.onItemTapped(0); }, ), title: const Text("Notifications"), diff --git a/lib/presentation/pages/main/settings.dart b/lib/presentation/pages/main/settings.dart index 5c8edb7..043fab2 100644 --- a/lib/presentation/pages/main/settings.dart +++ b/lib/presentation/pages/main/settings.dart @@ -18,8 +18,7 @@ class SettingsPage extends GetView { appBar: AppBar( leading: BackButton( onPressed: () { - navigationController.selectedIndex.value = 0; - Get.toNamed('/dashboard'); + navigationController.onItemTapped(0); }, ), title: const Text("Settings"), @@ -37,13 +36,13 @@ class SettingsPage extends GetView { return ListTile( leading: const Icon(Ionicons.information_circle_outline), title: const Text("About"), - onTap: () => Get.toNamed('about'), + onTap: () => Get.toNamed('/about'), ); } else if (index == 1) { return ListTile( leading: const Icon(Ionicons.help_circle_outline), title: const Text("FAQ"), - onTap: () => Get.toNamed('faq'), + onTap: () => Get.toNamed('/faq'), ); } else { return ListTile( diff --git a/lib/presentation/widgets/nav_bar/custom_fab.dart b/lib/presentation/widgets/nav_bar/custom_fab.dart index 1632654..847c593 100644 --- a/lib/presentation/widgets/nav_bar/custom_fab.dart +++ b/lib/presentation/widgets/nav_bar/custom_fab.dart @@ -18,7 +18,7 @@ class CustomFAB extends StatelessWidget { color: howBlack, ), onPressed: () { - Get.toNamed('edit_assets'); + Get.toNamed('/edit_assets'); }, ); } diff --git a/lib/presentation/widgets/nav_bar/discard_save.dart b/lib/presentation/widgets/nav_bar/discard_save.dart index 8a1f42c..9e7c9b8 100644 --- a/lib/presentation/widgets/nav_bar/discard_save.dart +++ b/lib/presentation/widgets/nav_bar/discard_save.dart @@ -40,7 +40,7 @@ class DiscardAndSave extends StatelessWidget { bool discardConfirmed = await showDiscardDialog(context); if (discardConfirmed) { userAssetsController.discardChanges(); - Get.toNamed('/dashboard'); + Get.offAllNamed('/dashboard'); } })), Obx(() => PrimaryButton( @@ -54,7 +54,7 @@ class DiscardAndSave extends StatelessWidget { loadingAnimation(); await userAssetsController.saveAssets(); Get.find().calculateAll(); - Get.toNamed('/dashboard'); + Get.offAllNamed('/dashboard'); } })) ]),