Skip to content

Commit

Permalink
#5 [FEAT] : set action on each fragment's btn click listener
Browse files Browse the repository at this point in the history
  • Loading branch information
MinwooP committed Dec 16, 2021
1 parent ef22c5b commit 1d7ca73
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 136 deletions.
16 changes: 8 additions & 8 deletions week1/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
android:theme="@style/Theme.Week1">
<activity
android:name=".ui.OnBoardingActivity"
android:exported="false" />
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.SignUpActivity"
android:exported="true" />
Expand All @@ -22,13 +28,7 @@
android:exported="true" />
<activity
android:name=".ui.SignInActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
android:exported="true"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,30 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import com.example.week1.R
import com.example.week1.databinding.FragmentOnBoardingFisrtBinding

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
* A simple [Fragment] subclass.
* Use the [OnBoardingFisrtFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class OnBoardingFisrtFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}
private var _binding: FragmentOnBoardingFisrtBinding? = null
private val binding get() = _binding ?: error("Binding이 초기화 되지 않았습니다.")

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_on_boarding_fisrt, container, false)
): View {
_binding = FragmentOnBoardingFisrtBinding.inflate(layoutInflater, container, false)

binding.btnToSecondOnBoarding.setOnClickListener{
findNavController().navigate(R.id.action_onBoardingFisrtFragment_to_onBoardingSecondFragment)
}
return binding.root
}

companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment OnBoardingFisrtFragment.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
OnBoardingFisrtFragment().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,28 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import com.example.week1.R
import com.example.week1.databinding.FragmentOnBoardingLastBinding

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
* A simple [Fragment] subclass.
* Use the [OnBoardingLastFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class OnBoardingLastFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}
private var _binding: FragmentOnBoardingLastBinding? = null
private val binding get() = _binding ?: error("Binding이 초기화 되지 않았습니다.")

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_on_boarding_last, container, false)
): View {
_binding = FragmentOnBoardingLastBinding.inflate(layoutInflater, container, false)

binding.btnStartSignIn.setOnClickListener{
}
return binding.root
}

companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment OnBoardingLastFragment.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
OnBoardingLastFragment().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,29 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import com.example.week1.R
import com.example.week1.databinding.FragmentOnBoardingSecondBinding

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
* A simple [Fragment] subclass.
* Use the [OnBoardingSecondFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class OnBoardingSecondFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}
private var _binding: FragmentOnBoardingSecondBinding? = null
private val binding get() = _binding ?: error("Binding이 초기화 되지 않았습니다.")

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_on_boarding_second, container, false)
): View {
_binding = FragmentOnBoardingSecondBinding.inflate(layoutInflater, container, false)

binding.btnToLastOnBoarding.setOnClickListener{
findNavController().navigate(R.id.action_onBoardingSecondFragment_to_onBoardingLastFragment)
}
return binding.root
}

companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment OnBoardingSecondFragment.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
OnBoardingSecondFragment().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:layout_marginTop="200dp"
android:src="@drawable/ic_miniuns"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:id="@+id/tv_on_boarding_goodtime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:layout_marginTop="300dp"
android:text="SOPTHub에서 즐거운 시간\n 보내시길 바랍니다 !"
android:textAlignment="center"
android:textColor="#F658A6"
Expand Down
29 changes: 27 additions & 2 deletions week1/app/src/main/res/navigation/nav_onboarding.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/nav_onboarding">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_onboarding"
app:startDestination="@id/onBoardingFisrtFragment">

<fragment
android:id="@+id/onBoardingFisrtFragment"
android:name="com.example.week1.ui.OnBoardingFisrtFragment"
android:label="fragment_on_boarding_fisrt"
tools:layout="@layout/fragment_on_boarding_fisrt" >
<action
android:id="@+id/action_onBoardingFisrtFragment_to_onBoardingSecondFragment"
app:destination="@id/onBoardingSecondFragment" />
</fragment>
<fragment
android:id="@+id/onBoardingSecondFragment"
android:name="com.example.week1.ui.OnBoardingSecondFragment"
android:label="fragment_on_boarding_second"
tools:layout="@layout/fragment_on_boarding_second" >
<action
android:id="@+id/action_onBoardingSecondFragment_to_onBoardingLastFragment"
app:destination="@id/onBoardingLastFragment" />
</fragment>
<fragment
android:id="@+id/onBoardingLastFragment"
android:name="com.example.week1.ui.OnBoardingLastFragment"
android:label="fragment_on_boarding_last"
tools:layout="@layout/fragment_on_boarding_last" />
</navigation>

0 comments on commit 1d7ca73

Please sign in to comment.