-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-contributors
- Loading branch information
Showing
6 changed files
with
133 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
.../main/java/com/kylecorry/trail_sense/tools/field_guide/ui/CreateFieldGuidePageFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.kylecorry.trail_sense.tools.field_guide.ui | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import com.kylecorry.andromeda.fragments.BoundFragment | ||
import com.kylecorry.andromeda.fragments.inBackground | ||
import com.kylecorry.trail_sense.databinding.FragmentCreateFieldGuidePageBinding | ||
import com.kylecorry.trail_sense.shared.CustomUiUtils | ||
import com.kylecorry.trail_sense.shared.withId | ||
import com.kylecorry.trail_sense.tools.field_guide.domain.FieldGuidePage | ||
import com.kylecorry.trail_sense.tools.field_guide.domain.FieldGuidePageTag | ||
import com.kylecorry.trail_sense.tools.field_guide.infrastructure.FieldGuideRepo | ||
|
||
class CreateFieldGuidePageFragment : BoundFragment<FragmentCreateFieldGuidePageBinding>() { | ||
|
||
private var existingPage by state<FieldGuidePage?>(null) | ||
private var tags by state<List<FieldGuidePageTag>>(emptyList()) | ||
private val repo by lazy { FieldGuideRepo.getInstance(requireContext()) } | ||
|
||
override fun generateBinding( | ||
layoutInflater: LayoutInflater, | ||
container: ViewGroup? | ||
): FragmentCreateFieldGuidePageBinding { | ||
return FragmentCreateFieldGuidePageBinding.inflate(layoutInflater, container, false) | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
arguments?.let { | ||
val pageId = it.getLong(ARG_PAGE_ID, 0L) | ||
if (pageId != 0L) { | ||
inBackground { | ||
existingPage = repo.getPage(pageId) | ||
} | ||
} | ||
|
||
val tag = it.getLong(ARG_CLASSIFICATION_ID, 0L) | ||
.takeIf { id -> id != 0L } | ||
?.let { id -> FieldGuidePageTag.entries.withId(id) } | ||
|
||
if (tag != null) { | ||
tags += listOf(tag) | ||
} | ||
} | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
CustomUiUtils.setButtonState(binding.createFieldGuidePageTitle.rightButton, true) | ||
} | ||
|
||
companion object { | ||
private const val ARG_PAGE_ID = "page_id" | ||
private const val ARG_CLASSIFICATION_ID = "classification_id" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
app/src/main/res/layout/fragment_create_field_guide_page.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<com.kylecorry.andromeda.views.toolbar.Toolbar | ||
android:id="@+id/create_field_guide_page_title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:rightButtonIcon="@drawable/ic_add" | ||
app:showSubtitle="false" | ||
tools:title="Test Name" /> | ||
|
||
<ScrollView | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:layout_weight="1" /> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
android:layout_height="match_parent"> | ||
|
||
<com.kylecorry.trail_sense.shared.views.SearchView | ||
android:id="@+id/search" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" /> | ||
android:padding="16dp" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<com.kylecorry.andromeda.views.list.AndromedaListView | ||
android:id="@+id/list" | ||
style="@style/AppTheme.ListViewWithFab" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
</LinearLayout> | ||
android:layout_height="0dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/search" /> | ||
|
||
<com.google.android.material.floatingactionbutton.FloatingActionButton | ||
android:id="@+id/add_btn" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="16dp" | ||
android:layout_marginBottom="@dimen/default_bottom_margin" | ||
android:clickable="true" | ||
android:focusable="true" | ||
android:src="@drawable/ic_add" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters