Skip to content

feat: search nearby locations - #835

Merged
HashEngineering merged 8 commits into
feature-explore-dashfrom
feature-search-nearby-locations
Dec 15, 2021
Merged

HashEngineering merged 8 commits into
feature-explore-dashfrom
feature-search-nearby-locations

Conversation

@ClaudeHangui

@ClaudeHangui ClaudeHangui commented Dec 10, 2021 •

Copy link
Copy Markdown
Contributor

This task is all about displaying the list of nearby locations on the map. Most of the AC's required have already been done in a previous story

Issue being fixed or feature implemented

  • hide the map result if user filter by state
  • provide the ability to the user to re-center the map (via a button) to their current location if they pan the map

Related PR's and Dependencies

Screenshots / Videos

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

@ClaudeHangui
ClaudeHangui changed the base branch from master to feature-explore-dash December 10, 2021 21:46
@ClaudeHangui
ClaudeHangui requested a review from Syn-McJ December 10, 2021 21:47

@Syn-McJ Syn-McJ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks behavior of the bottom sheet somewhat, please review the requested changes.



open class OffsetDialogFragment<T: ViewGroup> : BottomSheetDialogFragment() {
open class OffsetDialogFragment<T: ViewGroup> : BaseBottomSheetDialogFragment() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change won't make much sense once we move from having a viewModel in the dialogs to dismissing them by enumerating all fragments as I've suggested. OffsetDialogFragment and BaseBottomSheetDialogFragment have different logic for handling height and there isn't anything else they share, and so this relationship is invalid. OffsetDialogFragment is intended as a replacement for the BaseBottomSheetDialogFragment for cases where the new design of bottom dialog is used.

Therefore, I would prefer if we add viewModel and the dismissing logic to OffsetDialogFragment directly for now instead of deriving it from BaseBottomSheetDialogFragment.

bottomSheet.isDraggable = false
bottomSheet.state = BottomSheetBehavior.STATE_EXPANDED
bottomSheetWasExpanded = true
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this creates some problems. First of all, resolveAppliedFilters method is only for setting up the bottom panel that shows what filters are applied, it shouldn't contain any other logic (maybe we should rename this method if its purpose isn't clear).

Second, there are numerous other places in the SearchFragment that change isDraggable and state and those places will ignore territory and this snippet completely.

The way I think this should be set up is we should have a single method that checks all conditions for the bottom sheet draggable status (similar to the shouldShowFiltersPanel method). Then, all assignments like bottomSheet.isDraggable = should use this method instead of a direct assignment. Conditions that should be checked are:

  • is location enabled
  • is online filter mode
  • screen state

Similar method can be added for the bottomSheet.state. There, apart from the above-mentioned conditions merchant type should also be checked, since the sheet is always expanded for Online merchants.

Changes in the territory can continue to be observed through appliedFilters, or you can add a livedata for territory and observe it directly.

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="8dp"/>
<solid android:color="@color/dash_white"/>
</shape> No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This resource already exists in the wallet module, perhaps it's better to move it to the common instead of duplicating. Or you can use rounded_background with a theme, the purpose of rounded_background is to avoid creating multiple rounded background resources but instead use just one with different themes.

android:viewportHeight="20" android:viewportWidth="20"
android:width="20dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#008DE4" android:pathData="M10.0007,6.6666C8.159,6.6666 6.6673,8.1582 6.6673,9.9999C6.6673,11.8416 8.159,13.3333 10.0007,13.3333C11.8423,13.3333 13.334,11.8416 13.334,9.9999C13.334,8.1582 11.8423,6.6666 10.0007,6.6666ZM17.4506,9.1666C17.0673,5.6916 14.309,2.9332 10.834,2.5499V0.8333H9.1673V2.5499C5.6923,2.9332 2.934,5.6916 2.5506,9.1666H0.834V10.8333H2.5506C2.934,14.3083 5.6923,17.0666 9.1673,17.4499V19.1666H10.834V17.4499C14.309,17.0666 17.0673,14.3083 17.4506,10.8333H19.1673V9.1666H17.4506ZM10.0007,15.8333C6.7757,15.8333 4.1673,13.2249 4.1673,9.9999C4.1673,6.7749 6.7757,4.1666 10.0007,4.1666C13.2256,4.1666 15.834,6.7749 15.834,9.9999C15.834,13.2249 13.2256,15.8333 10.0007,15.8333Z"/>
</vector>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This icon is already added as ic_current_location, you can reuse that instead by applying a blue tint to it.

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/round_corners_bgd_white"
android:src="@drawable/ic_compass"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can reuse ic_current_location instead with app:tint

- delete duplicate round_corners_bgd_white.xml drawable
- make round_corners_white_bg.xml available to all modules
- centralize workflow to set/change bottom sheet behaviors in SearchFragment.kt
- update workflow to change bottom sheet behavior for selected territory
import org.dash.wallet.common.R
import org.dash.wallet.common.UserInteractionAwareCallback

@AndroidEntryPoint

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndroidEntryPoint-annotated classes cannot have type parameters
So we had to get the LockScreenViewModel using the provider

}

private fun applyFilters() {
viewModel.selectedTerritory = selectedTerritory

@ClaudeHangui ClaudeHangui Dec 15, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to define a custom setter to update the territory

@ClaudeHangui

Copy link
Copy Markdown
Contributor Author

@Syn-McJ I took upon your suggestion to update my work:

  • a method to define the state of the bottom sheet
  • a method to define whether the bottom sheet should be draggable or not
  • I made the choice of observing the territory on its own rather than relying appliedFilters .

@Syn-McJ Syn-McJ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good

val currentUserLocation = _currentUserLocation.asLiveData()

private val _selectedTerritory = MutableStateFlow("")
var selectedTerritory: String

@ClaudeHangui ClaudeHangui Dec 15, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We needed to observe the changes in the territory on it's own, and since it's value is updated in FiltersDialog class, we needed to define a custom setter for it

@HashEngineering HashEngineering left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@HashEngineering
HashEngineering merged commit 4b049f1 into feature-explore-dash Dec 15, 2021
@HashEngineering
HashEngineering deleted the feature-search-nearby-locations branch May 19, 2022 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants