Skip to content

Commit

Permalink
Show community description, if available
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed Feb 17, 2024
1 parent 0553688 commit 48f23b6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## [Unreleased]

- Show community meetup locations
- Show community description, if available
- Add area issues screen
- Change default location to Curacao
- Zoom to current location
Expand Down
27 changes: 24 additions & 3 deletions app/src/main/kotlin/area/AreaAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import icons.iconTypeface
import map.enableDarkModeIfNecessary
import map.showPolygons
import okhttp3.HttpUrl
import org.btcmap.databinding.ItemAreaDescriptionBinding
import org.btcmap.databinding.ItemAreaElementBinding
import org.btcmap.databinding.ItemContactBinding
import org.btcmap.databinding.ItemIssuesBinding
Expand All @@ -24,6 +25,7 @@ class AreaAdapter(
override fun getItemViewType(position: Int): Int {
return when (getItem(position)) {
is Item.Map -> VIEW_TYPE_MAP
is Item.Description -> VIEW_TYPE_DESCRIPTION
is Item.Contact -> VIEW_TYPE_CONTACT
is Item.Issues -> VIEW_TYPE_ISSUES
is Item.Element -> VIEW_TYPE_ELEMENT
Expand All @@ -43,6 +45,14 @@ class AreaAdapter(
)
}

VIEW_TYPE_DESCRIPTION -> {
ItemAreaDescriptionBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false,
)
}

VIEW_TYPE_CONTACT -> {
ItemContactBinding.inflate(
LayoutInflater.from(parent.context),
Expand Down Expand Up @@ -89,6 +99,10 @@ class AreaAdapter(
val paddingPx: Int,
) : Item()

data class Description(
val text: String,
) : Item()

data class Contact(
val website: HttpUrl?,
val twitter: HttpUrl?,
Expand Down Expand Up @@ -128,6 +142,12 @@ class AreaAdapter(
binding.root.setOnClickListener { listener.onMapClick() }
}

if (item is Item.Description && binding is ItemAreaDescriptionBinding) {
binding.apply {
text.text = item.text
}
}

if (item is Item.Contact && binding is ItemContactBinding) {
binding.apply {
website.isVisible = item.website != null
Expand Down Expand Up @@ -218,8 +238,9 @@ class AreaAdapter(

companion object {
const val VIEW_TYPE_MAP = 0
const val VIEW_TYPE_CONTACT = 1
const val VIEW_TYPE_ISSUES = 2
const val VIEW_TYPE_ELEMENT = 3
const val VIEW_TYPE_DESCRIPTION = 1
const val VIEW_TYPE_CONTACT = 2
const val VIEW_TYPE_ISSUES = 3
const val VIEW_TYPE_ELEMENT = 4
}
}
5 changes: 5 additions & 0 deletions app/src/main/kotlin/area/AreaModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ class AreaModel(

val items = buildList {
add(map)

if (area.tags.has("description")) {
add(AreaAdapter.Item.Description(area.tags.getString("description")))
}

add(contact)

if (issuesCount > 0) {
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/layout/item_area_description.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:paddingHorizontal="16dp">

<TextView
android:id="@+id/text"
style="?attr/textAppearanceSubtitle1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
tools:text="Join our meetups every Sunday at 18:00" />

</LinearLayout>

0 comments on commit 48f23b6

Please sign in to comment.