From 3be297c0d3b86f2f5f54e4f69f8d2fe2a054225d Mon Sep 17 00:00:00 2001 From: dankito Date: Sun, 27 Sep 2020 00:32:18 +0200 Subject: [PATCH] Implemented showing fetch all transactions view at top and by clicking on 'x' button showing it at bottom (TODO on Android: show at bottom) --- .../banking/ui/android/home/HomeFragment.kt | 39 +++- .../src/main/res/layout/fragment_home.xml | 73 +++++++- .../src/main/res/values/dimens.xml | 2 + .../dialogs/AccountTransactionsDialog.swift | 166 +++++++++++------- 4 files changed, 200 insertions(+), 80 deletions(-) diff --git a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt index 76d83f52..f026c736 100644 --- a/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt +++ b/ui/BankingAndroidApp/src/main/java/net/dankito/banking/ui/android/home/HomeFragment.kt @@ -52,6 +52,8 @@ class HomeFragment : Fragment() { private var accountsForWhichNotAllTransactionsHaveBeenFetched = listOf() + private var showTopFetchAllTransactionsView = true // TODO: read from db + private val transactionAdapter: AccountTransactionAdapter @@ -92,10 +94,18 @@ class HomeFragment : Fragment() { registerForContextMenu(rcyvwAccountTransactions) // this is actually bad, splits code as context menu is created in AccountTransactionAdapter - rootView.btnFetchAllTransactions.setOnClickListener { + rootView.btnTopFetchAllTransactions.setOnClickListener { fetchAllTransactions() } + rootView.btnBottomFetchAllTransactions.setOnClickListener { + fetchAllTransactions() + } + + rootView.btnHideTopFetchAllTransactionsView.setOnClickListener { + hideTopFetchAllTransactionsView() + } + rootView.btnRetrieveTransactions.setOnClickListener { fetchTransactions() } rootView.btnAddAccount.setOnClickListener { presenter.showAddAccountDialog() } @@ -286,16 +296,31 @@ class HomeFragment : Fragment() { private fun setFetchAllTransactionsView() { accountsForWhichNotAllTransactionsHaveBeenFetched = presenter.selectedAccountsForWhichNotAllTransactionsHaveBeenFetched + val showFetchAllTransactionsView = accountsForWhichNotAllTransactionsHaveBeenFetched.isNotEmpty() + || presenter.selectedAccountsTransactionRetrievalState == TransactionsRetrievalState.RetrievedTransactions - val hideFetchAllTransactionsView = accountsForWhichNotAllTransactionsHaveBeenFetched.isEmpty() - || presenter.selectedAccountsTransactionRetrievalState != TransactionsRetrievalState.RetrievedTransactions - - if (hideFetchAllTransactionsView) { - lytFetchAllTransactions.visibility = View.GONE + if (showFetchAllTransactionsView && showTopFetchAllTransactionsView) { + lytTopFetchAllTransactions.visibility = View.VISIBLE } else { - lytFetchAllTransactions.visibility = View.VISIBLE + lytTopFetchAllTransactions.visibility = View.GONE } + + if (showFetchAllTransactionsView && showTopFetchAllTransactionsView == false) { + // TODO: implement CoordinatorLayout to show lytBottomFetchAllTransactions below rcyvwAccountTransactions +// lytBottomFetchAllTransactions.visibility = View.VISIBLE + } + else { + lytBottomFetchAllTransactions.visibility = View.GONE + } + } + + private fun hideTopFetchAllTransactionsView() { + // TODO: persist + + showTopFetchAllTransactionsView = false + + setFetchAllTransactionsView() } diff --git a/ui/BankingAndroidApp/src/main/res/layout/fragment_home.xml b/ui/BankingAndroidApp/src/main/res/layout/fragment_home.xml index 0192a21d..c2763ad8 100644 --- a/ui/BankingAndroidApp/src/main/res/layout/fragment_home.xml +++ b/ui/BankingAndroidApp/src/main/res/layout/fragment_home.xml @@ -57,9 +57,17 @@ - + +