Don't showing an overlay anymore but button to fetch all transactions directly above transactions list

This commit is contained in:
dankito 2020-09-23 19:16:33 +02:00
parent 06c5f58d4c
commit 5ded582c78
5 changed files with 100 additions and 183 deletions

View File

@ -53,8 +53,6 @@ class HomeFragment : Fragment() {
private var accountsForWhichNotAllTransactionsHaveBeenFetched = listOf<TypedBankAccount>()
private var doNotShowFetchAllTransactionsOverlay = false
private val transactionAdapter: AccountTransactionAdapter
@ -99,11 +97,6 @@ class HomeFragment : Fragment() {
fetchAllTransactions()
}
rootView.btnHideFetchAllTransactionsOverlay.setOnClickListener {
doNotShowFetchAllTransactionsOverlay = true
setFetchAllTransactionsView()
}
rootView.btnRetrieveTransactions.setOnClickListener { fetchTransactions() }
rootView.btnAddAccount.setOnClickListener { presenter.showAddAccountDialog() }
@ -275,7 +268,7 @@ class HomeFragment : Fragment() {
btnRetrieveTransactions.visibility = if (TransactionsCannotBeRetrievedStates.contains(transactionsRetrievalState)) View.GONE else View.VISIBLE
btnAddAccount.visibility = if (noAccountsAddedYet) View.VISIBLE else View.GONE
var messageArgs = mutableListOf<String>()
val messageArgs = mutableListOf<String>()
val transactionsRetrievalStateMessageId = when (transactionsRetrievalState) {
TransactionsRetrievalState.AccountTypeNotSupported -> R.string.fragment_home_transactions_retrieval_state_account_type_not_supported
TransactionsRetrievalState.AccountDoesNotSupportFetchingTransactions -> R.string.fragment_home_transactions_retrieval_state_account_does_not_support_retrieving_transactions
@ -294,19 +287,14 @@ class HomeFragment : Fragment() {
private fun setFetchAllTransactionsView() {
accountsForWhichNotAllTransactionsHaveBeenFetched = presenter.selectedAccountsForWhichNotAllTransactionsHaveBeenFetched
var floatingActionMenuBottomMarginResourceId = R.dimen.fab_margin_bottom_without_toolbar
val hideFetchAllTransactionsView = accountsForWhichNotAllTransactionsHaveBeenFetched.isEmpty()
|| presenter.selectedAccountsTransactionRetrievalState != TransactionsRetrievalState.RetrievedTransactions
if (doNotShowFetchAllTransactionsOverlay || accountsForWhichNotAllTransactionsHaveBeenFetched.isEmpty()
|| presenter.selectedAccountsTransactionRetrievalState != TransactionsRetrievalState.RetrievedTransactions) {
lytFetchAllTransactionsOverlay.visibility = View.GONE
if (hideFetchAllTransactionsView) {
lytFetchAllTransactions.visibility = View.GONE
}
else {
lytFetchAllTransactionsOverlay.visibility = View.VISIBLE
floatingActionMenuBottomMarginResourceId = R.dimen.fab_margin_bottom_with_fetch_all_transactions_overlay
}
(requireActivity().findViewById<View>(R.id.floatingActionMenu).layoutParams as? ViewGroup.MarginLayoutParams)?.let { params ->
params.bottomMargin = requireContext().getDimension(floatingActionMenuBottomMarginResourceId)
lytFetchAllTransactions.visibility = View.VISIBLE
}
}

View File

@ -12,22 +12,23 @@
app:layout_constraintTop_toTopOf="parent"
>
<RelativeLayout
<LinearLayout
android:id="@+id/lytTransactionsTopBar"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/fragment_account_transaction_margin_start_and_end"
android:layout_marginEnd="@dimen/fragment_account_transaction_margin_start_and_end"
android:layout_alignParentTop="true"
android:layout_above="@+id/lytFetchAllTransactionsOverlay"
>
<RelativeLayout
android:id="@+id/lytTransactionsSummary"
android:layout_width="match_parent"
android:layout_height="@dimen/fragment_account_transaction_transactions_summary_height"
android:layout_alignParentTop="true"
android:layout_marginTop="4dp"
android:layout_marginLeft="@dimen/fragment_account_transaction_margin_start_and_end"
android:layout_marginStart="@dimen/fragment_account_transaction_margin_start_and_end"
android:layout_marginRight="@dimen/fragment_account_transaction_margin_start_and_end"
android:layout_marginEnd="@dimen/fragment_account_transaction_margin_start_and_end"
>
<TextView
@ -56,113 +57,93 @@
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rcyvwAccountTransactions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/lytTransactionsSummary"
android:layout_alignParentBottom="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<LinearLayout
android:orientation="vertical"
android:id="@+id/lytNoTransactionsFetched"
android:id="@+id/lytFetchAllTransactions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_height="@dimen/fragment_account_transaction_fetch_all_transactions_layout_height"
android:gravity="center"
android:visibility="gone"
android:background="@color/formSectionDivideColor"
>
<TextView
android:id="@+id/txtNoTransactionsFetchedMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textAlignment="gravity"
style="@style/TextAppearance.AppCompat.Medium"
/>
<Button
android:id="@+id/btnRetrieveTransactions"
android:id="@+id/btnFetchAllTransactions"
android:layout_width="match_parent"
android:layout_height="@dimen/fragment_account_transaction_fetch_transactions_button_height"
android:layout_marginTop="@dimen/fragment_account_transaction_fetch_transactions_button_margin_top"
android:gravity="center"
android:textAlignment="gravity"
android:layout_height="@dimen/fragment_account_transaction_fetch_all_transactions_button_height"
android:gravity="center_horizontal"
android:textAlignment="center"
style="?android:attr/buttonBarButtonStyle"
android:textSize="@dimen/textAppearanceMediumTextSize"
android:textAllCaps="false"
android:textColor="@color/linkColor"
android:text="@string/fragment_home_fetch_transactions"
android:text="@string/fragment_home_fetch_all_account_transactions"
/>
</LinearLayout>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rcyvwAccountTransactions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/lytTransactionsTopBar"
android:layout_alignParentBottom="true"
android:layout_marginLeft="@dimen/fragment_account_transaction_margin_start_and_end"
android:layout_marginStart="@dimen/fragment_account_transaction_margin_start_and_end"
android:layout_marginRight="@dimen/fragment_account_transaction_margin_start_and_end"
android:layout_marginEnd="@dimen/fragment_account_transaction_margin_start_and_end"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<LinearLayout
android:orientation="vertical"
android:id="@+id/lytNoTransactionsFetched"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:gravity="center"
android:visibility="gone"
>
<TextView
android:id="@+id/txtNoTransactionsFetchedMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textAlignment="gravity"
style="@style/TextAppearance.AppCompat.Medium"
/>
<Button
android:id="@+id/btnAddAccount"
android:id="@+id/btnRetrieveTransactions"
android:layout_width="match_parent"
android:layout_height="@dimen/fragment_account_transaction_fetch_transactions_button_height"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="@dimen/fragment_account_transaction_fetch_transactions_button_margin_top"
android:gravity="center"
android:textAlignment="gravity"
style="?android:attr/buttonBarButtonStyle"
android:textSize="@dimen/textAppearanceMediumTextSize"
android:textColor="@color/linkColor"
android:text="@string/add_account"
android:visibility="gone"
android:text="@string/fragment_home_fetch_transactions"
/>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="@+id/lytFetchAllTransactionsOverlay"
<Button
android:id="@+id/btnAddAccount"
android:layout_width="match_parent"
android:layout_height="@dimen/fragment_account_transaction_fetch_all_transactions_overlay_height"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_height="@dimen/fragment_account_transaction_fetch_transactions_button_height"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:background="@color/snackbarBackground"
android:gravity="center"
android:textAlignment="gravity"
style="?android:attr/buttonBarButtonStyle"
android:textSize="@dimen/textAppearanceMediumTextSize"
android:textColor="@color/linkColor"
android:text="@string/add_account"
android:visibility="gone"
>
<Button
android:id="@+id/btnFetchAllTransactions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@+id/btnHideFetchAllTransactionsOverlay"
android:layout_toStartOf="@+id/btnHideFetchAllTransactionsOverlay"
android:layout_alignParentBottom="true"
android:gravity="center"
style="?android:attr/buttonBarButtonStyle"
android:textColor="@color/linkColor"
android:text="@string/fragment_home_fetch_all_account_transactions"
/>
<ImageButton
android:id="@+id/btnHideFetchAllTransactionsOverlay"
android:layout_width="@dimen/fragment_account_transaction_button_close_fetch_all_transactions_overlay_size"
android:layout_height="@dimen/fragment_account_transaction_button_close_fetch_all_transactions_overlay_size"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="@dimen/fragment_account_transaction_button_close_fetch_all_transactions_overlay_margin_end"
android:layout_marginEnd="@dimen/fragment_account_transaction_button_close_fetch_all_transactions_overlay_margin_end"
android:background="@null"
android:tint="#FFFFFF"
app:srcCompat="@drawable/ic_baseline_close_24"
/>
</RelativeLayout>
/>
</RelativeLayout>

View File

@ -16,10 +16,8 @@
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/lytAmountAndDate"
android:layout_toStartOf="@+id/lytAmountAndDate"
android:layout_marginLeft="@dimen/list_item_account_transaction_transaction_text_margin_left_and_right"
android:layout_marginStart="@dimen/list_item_account_transaction_transaction_text_margin_left_and_right"
android:layout_marginRight="@dimen/list_item_account_transaction_transaction_text_margin_left_and_right"
android:layout_marginEnd="@dimen/list_item_account_transaction_transaction_text_margin_left_and_right"
android:layout_marginRight="@dimen/list_item_account_transaction_transaction_text_margin_end"
android:layout_marginEnd="@dimen/list_item_account_transaction_transaction_text_margin_end"
android:gravity="center_vertical"
>

View File

@ -15,7 +15,6 @@
<dimen name="fab_margin">16dp</dimen>
<dimen name="fab_margin_bottom_without_toolbar">16dp</dimen>
<dimen name="fab_margin_bottom_with_toolbar">42dp</dimen>
<dimen name="fab_margin_bottom_with_fetch_all_transactions_overlay">64dp</dimen>
<dimen name="form_padding">12dp</dimen>
<dimen name="form_section_height">60dp</dimen>
@ -30,9 +29,8 @@
<dimen name="fragment_account_transaction_fetch_transactions_button_height">40dp</dimen>
<dimen name="fragment_account_transaction_fetch_transactions_button_margin_top">18dp</dimen>
<dimen name="fragment_account_transaction_add_account_button_height">40dp</dimen>
<dimen name="fragment_account_transaction_fetch_all_transactions_overlay_height">48dp</dimen>
<dimen name="fragment_account_transaction_button_close_fetch_all_transactions_overlay_size">20dp</dimen>
<dimen name="fragment_account_transaction_button_close_fetch_all_transactions_overlay_margin_end">6dp</dimen>
<dimen name="fragment_account_transaction_fetch_all_transactions_layout_height">48dp</dimen>
<dimen name="fragment_account_transaction_fetch_all_transactions_button_height">40dp</dimen>
<dimen name="list_item_account_transaction_height">74dp</dimen>
<dimen name="list_item_account_transaction_padding">0dp</dimen>
@ -45,7 +43,7 @@
<dimen name="list_item_account_transaction_amount_width">70dp</dimen>
<dimen name="list_item_account_transaction_date_margin_top">2dp</dimen>
<dimen name="list_item_account_transaction_date_margin_bottom">0dp</dimen>
<dimen name="list_item_account_transaction_transaction_text_margin_left_and_right">4dp</dimen>
<dimen name="list_item_account_transaction_transaction_text_margin_end">4dp</dimen>
<dimen name="dialog_add_account_padding">4dp</dimen>
<dimen name="dialog_add_account_label_height">24dp</dimen>

View File

@ -4,8 +4,6 @@ import BankingUiSwift
struct AccountTransactionsDialog: View {
static private let DoNotShowFetchAllTransactionsOverlayForUserDefaultsKeyPrefix = "DoNotShowFetchAllTransactionsOverlayFor_"
static private let RetrievedTransactionsPeriodDateFormat = DateFormatter()
@ -14,17 +12,13 @@ struct AccountTransactionsDialog: View {
private let showBankIcons: Bool
@State private var haveTransactionsBeenRetrievedForSelectedAccounts = true
@State private var haveAllTransactionsBeenFetched: Bool = false
@State private var showTransactionsList = true
@State private var noTransactionsFetchedMessage: LocalizedStringKey = ""
@State private var showFetchTransactionsButton = true
@State private var showFetchAllTransactionsOverlay: Bool = false
@State private var showFetchAllTransactionsView: Bool = false
@State private var accountsForWhichNotAllTransactionsHaveBeenFetched: [IBankAccount] = []
@ -88,14 +82,30 @@ struct AccountTransactionsDialog: View {
HStack {
Text("\(String(self.filteredTransactions.count)) transactions")
.styleAsDetail()
Spacer()
AmountLabel(amount: self.balanceOfFilteredTransactions)
}
}
}
if showFetchAllTransactionsView {
Section {
HStack(alignment: .center) {
Spacer()
fetchAllTransactionsButton
Spacer()
}
.padding(.horizontal, 6)
}
.frame(maxWidth: .infinity, minHeight: 44) // has to have at least a height of 44 (iOS 14; iOS 13: 40), otherwise a white line at bottom gets displayed
.systemGroupedBackground() // TODO: extract with below .removeSectionBackground() (or create View?)
.listRowInsets(EdgeInsets()) // TODO: extract remove list insets
}
if showTransactionsList {
Section {
ForEach(filteredTransactions, id: \.technicalId) { transaction in
@ -114,49 +124,8 @@ struct AccountTransactionsDialog: View {
}
}
}
if haveAllTransactionsBeenFetched == false && showFetchAllTransactionsOverlay == false && haveTransactionsBeenRetrievedForSelectedAccounts {
Section {
HStack {
Spacer()
fetchAllTransactionsButton
Spacer()
}
}
.frame(maxWidth: .infinity, minHeight: 40)
.systemGroupedBackground()
.listRowInsets(EdgeInsets())
}
}
.systemGroupedBackground()
if showFetchAllTransactionsOverlay {
VStack {
Spacer()
HStack(alignment: .center) {
Button(action: { self.doNotShowFetchAllTransactionsOverlayAnymore() }) {
Text("x")
.bold()
}
Spacer()
fetchAllTransactionsButton
Spacer()
}
.padding(.horizontal, 6)
Spacer()
}
.frame(height: 40)
.padding(0)
.systemGroupedBackground()
.overlay(Divider(color: Color.gray), alignment: .top)
}
}
.executeMutatingMethod {
self.setInitialValues()
@ -177,14 +146,13 @@ struct AccountTransactionsDialog: View {
private func setTransactionsView() {
let transactionsRetrievalState = presenter.selectedAccountsTransactionRetrievalState
self.haveTransactionsBeenRetrievedForSelectedAccounts = transactionsRetrievalState == .retrievedtransactions
let haveTransactionsForSelectedAccountsBeenRetrieved = transactionsRetrievalState == .retrievedtransactions
self.accountsForWhichNotAllTransactionsHaveBeenFetched = presenter.selectedAccountsForWhichNotAllTransactionsHaveBeenFetched
self.haveAllTransactionsBeenFetched = self.accountsForWhichNotAllTransactionsHaveBeenFetched.isEmpty
self.showFetchAllTransactionsOverlay = shouldShowFetchAllTransactionsOverlay && haveTransactionsBeenRetrievedForSelectedAccounts
self.showFetchAllTransactionsView = shouldShowFetchAllTransactionsView && haveTransactionsForSelectedAccountsBeenRetrieved
self.showTransactionsList = haveTransactionsBeenRetrievedForSelectedAccounts
self.showTransactionsList = haveTransactionsForSelectedAccountsBeenRetrieved
self.noTransactionsFetchedMessage = getNoTransactionsFetchedMessage(transactionsRetrievalState)
self.showFetchTransactionsButton = transactionsRetrievalState != .accountdoesnotsupportfetchingtransactions && transactionsRetrievalState != .accounttypenotsupported
@ -280,24 +248,8 @@ struct AccountTransactionsDialog: View {
}
private func doNotShowFetchAllTransactionsOverlayAnymore() {
for account in accountsForWhichNotAllTransactionsHaveBeenFetched {
UserDefaults.standard.set(true, forKey: Self.DoNotShowFetchAllTransactionsOverlayForUserDefaultsKeyPrefix + account.technicalId)
}
showFetchAllTransactionsOverlay = false
}
private var shouldShowFetchAllTransactionsOverlay: Bool {
if accountsForWhichNotAllTransactionsHaveBeenFetched.isNotEmpty {
var copy = accountsForWhichNotAllTransactionsHaveBeenFetched
copy.removeAll { UserDefaults.standard.bool(forKey: Self.DoNotShowFetchAllTransactionsOverlayForUserDefaultsKeyPrefix + $0.technicalId, defaultValue: false) }
return copy.isNotEmpty
}
return false
private var shouldShowFetchAllTransactionsView: Bool {
return accountsForWhichNotAllTransactionsHaveBeenFetched.isNotEmpty
}
}