Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

#119 アプリ起動フローの整備 #138

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package jp.co.yumemi.android.code_check.pages.launcher

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import jp.co.yumemi.android.code_check.atoms.LoadingOverlay
import kotlinx.coroutines.launch

/**
* アプリ起動画面
*/
class LauncherFragment : Fragment() {

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
) = LoadingOverlay(inflater.context).apply {
layoutParams = LayoutParams(MATCH_PARENT, MATCH_PARENT)
}

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

viewLifecycleOwner.lifecycleScope.launch {
val action = LauncherFragmentDirections.navGoSearch()
findNavController().navigate(action)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ class SearchFragment : Fragment(R.layout.page_search) {
binding = PageSearchBinding.bind(view)

// region 表示設定
binding?.pageSearchHeader?.setupWith(findNavController())
binding?.pageSearchHeader?.apply {
setupWith(findNavController())

// Note: この画面では遷移元に戻ることが出来ないので無効化
navigationIcon = null
}

binding?.pageSearchBoxLayout?.setEndIconOnClickListener {
binding?.apply {
Expand Down
14 changes: 13 additions & 1 deletion app/src/main/res/navigation/nav_graph_entry_point.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph_entry_point"
app:startDestination="@id/page_search">
app:startDestination="@id/page_launcher">

<!-- 結果通知ダイアログの表示 -->
<action
Expand Down Expand Up @@ -49,6 +49,18 @@
android:label="@string/page_detail_title"
tools:layout="@layout/page_detail" />

<fragment
android:id="@+id/page_launcher"
android:name="jp.co.yumemi.android.code_check.pages.launcher.LauncherFragment"
android:label="@string/page_launcher_title">

<action
android:id="@+id/nav_go_search"
app:destination="@id/page_search"
app:popUpTo="@id/nav_graph_entry_point"
app:popUpToInclusive="true" />
</fragment>

<fragment
android:id="@+id/page_search"
android:name="jp.co.yumemi.android.code_check.pages.search.SearchFragment"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/page_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="page_launcher_title">起動画面</string>
</resources>