Skip to content

Commit

Permalink
Elevate titles
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Dec 18, 2022
1 parent bddd237 commit 0c920c3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ class DestinationDetailFragment : NavigationFragment.SubFragment() {
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_destination_detail, container, false)
val title = view.findViewById<TextView>(R.id.title)
val content = view.findViewById<TextView>(R.id.description)
val button = view.findViewById<Button>(R.id.action_button)

title.text = item?.name ?: ""
content.text = item?.description ?: ""

button.setOnClickListener { this.onButtonClick() }
Expand All @@ -64,6 +62,12 @@ class DestinationDetailFragment : NavigationFragment.SubFragment() {
return view
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

title = item?.name ?: ""
}

private fun onButtonClick() {
val destination = item ?: return
listener?.onGoToDestination(destination)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.view.ViewGroup
import android.widget.TextView
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
import androidx.core.view.updatePadding
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
Expand Down Expand Up @@ -60,6 +61,8 @@ class InfoFragment : NavigationFragment.SubFragment() {
@Inject
lateinit var appCore: AppCore

private lateinit var objectName: String

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand All @@ -79,13 +82,24 @@ class InfoFragment : NavigationFragment.SubFragment() {
titleLabel = view.findViewById(R.id.title)
contentLabel = view.findViewById(R.id.content)
linkView = view.findViewById(R.id.link_preview)
titleLabel.text = appCore.simulation.universe.getNameForSelection(selection)
objectName = appCore.simulation.universe.getNameForSelection(selection)
if (embeddedInNavigation)
titleLabel.isVisible = false
else
titleLabel.text = objectName
contentLabel.text = appCore.getOverviewForSelection(selection)

reload(true)
return view
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

if (embeddedInNavigation)
title = objectName
}

override fun onAttach(context: Context) {
super.onAttach(context)
if (context is Listener) {
Expand Down
23 changes: 5 additions & 18 deletions app/src/main/res/layout/fragment_destination_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,11 @@
android:clipToPadding="false"
android:paddingTop="@dimen/common_page_medium_margin_vertical"
android:layout_height="0dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/common_page_medium_gap_vertical"
style="@style/HeadlineLabel"/>

<TextView
android:id="@+id/description"
style="@style/BodyLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:id="@+id/description"
style="@style/BodyLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</androidx.core.widget.NestedScrollView>

<Space
Expand Down

0 comments on commit 0c920c3

Please sign in to comment.