From d8ae39a07deb8afc8858920cec84e2126818e889 Mon Sep 17 00:00:00 2001 From: dagdo03 Date: Tue, 25 Jun 2024 00:12:57 +0700 Subject: [PATCH 01/23] solve seatClass --- .../data/datasource/home/HomeDataSource.kt | 9 +++++ .../datasource/home/HomeDataSourceImpl.kt | 25 ++++++++++++ .../flight_ticket/FlightTicketRepository.kt | 9 +++++ .../FlightTicketRepositoryImpl.kt | 14 +++++++ .../network/model/home/flight/PriceRange.kt | 1 + .../network/services/SkyFlyApiService.kt | 7 +++- .../main/java/com/kom/skyfly/di/AppModules.kt | 2 + .../skyfly/presentation/home/HomeFragment.kt | 16 +++++++- .../home/search/viewitems/Items.kt | 1 - .../search_result/SearchResultViewModel.kt | 10 +++++ .../home/seatclass/SeatClassFragment.kt | 38 +++++++++++++++++-- .../skyfly/presentation/main/MainActivity.kt | 2 +- .../main/res/layout/fragment_seat_class.xml | 3 +- .../res/layout/layout_item_seatclass_card.xml | 2 +- 14 files changed, 129 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/kom/skyfly/data/datasource/home/HomeDataSource.kt b/app/src/main/java/com/kom/skyfly/data/datasource/home/HomeDataSource.kt index bffb893..5a5ff6c 100644 --- a/app/src/main/java/com/kom/skyfly/data/datasource/home/HomeDataSource.kt +++ b/app/src/main/java/com/kom/skyfly/data/datasource/home/HomeDataSource.kt @@ -1,5 +1,6 @@ package com.kom.skyfly.data.datasource.home +import com.kom.skyfly.data.model.home.seat_class.SeatClassHome import com.kom.skyfly.data.source.network.model.home.airport.AirportResponse import com.kom.skyfly.data.source.network.model.home.flight.FlightResponse import com.kom.skyfly.data.source.network.model.home.flight_detail.FlightDetailResponse @@ -14,10 +15,18 @@ interface HomeDataSource { arrivalAirport: String, departureDate: String, seatClass: String, + limit: Int? = 20, + returnDate: String?, + arrivalDate: String? = null, + adult: Int? = 1, + children: Int? = 0, + baby: Int? = 0, ): FlightResponse suspend fun getDetailFlight( id: String, seatClass: String, ): FlightDetailResponse + + fun getSeatClassData(): List } diff --git a/app/src/main/java/com/kom/skyfly/data/datasource/home/HomeDataSourceImpl.kt b/app/src/main/java/com/kom/skyfly/data/datasource/home/HomeDataSourceImpl.kt index ad503f7..26b0d26 100644 --- a/app/src/main/java/com/kom/skyfly/data/datasource/home/HomeDataSourceImpl.kt +++ b/app/src/main/java/com/kom/skyfly/data/datasource/home/HomeDataSourceImpl.kt @@ -1,5 +1,6 @@ package com.kom.skyfly.data.datasource.home +import com.kom.skyfly.data.model.home.seat_class.SeatClassHome import com.kom.skyfly.data.source.network.model.home.airport.AirportResponse import com.kom.skyfly.data.source.network.model.home.flight.FlightResponse import com.kom.skyfly.data.source.network.model.home.flight_detail.FlightDetailResponse @@ -12,6 +13,20 @@ class HomeDataSourceImpl( return service.getAllAirports() } + override fun getSeatClassData(): List { + return mutableListOf( + SeatClassHome( + seatClassName = "ECONOMY", + ), + SeatClassHome( + seatClassName = "BUSINESS", + ), + SeatClassHome( + seatClassName = "FIRST CLASS", + ), + ) + } + override suspend fun getAllFlight( search: String?, page: Int, @@ -19,14 +34,24 @@ class HomeDataSourceImpl( arrivalAirport: String, departureDate: String, seatClass: String, + limit: Int?, + returnDate: String?, + arrivalDate: String?, + adult: Int?, + children: Int?, + baby: Int?, ): FlightResponse { return service.getAllFlights( search = search, page = page, departureAirport = departureAirport, arrivalAirport = arrivalAirport, + returnDate = returnDate, departureDate = departureDate, seatClass = seatClass, + adult = adult, + children = children, + baby = baby, ) } diff --git a/app/src/main/java/com/kom/skyfly/data/repository/home/flight_ticket/FlightTicketRepository.kt b/app/src/main/java/com/kom/skyfly/data/repository/home/flight_ticket/FlightTicketRepository.kt index b6c9000..c3852aa 100644 --- a/app/src/main/java/com/kom/skyfly/data/repository/home/flight_ticket/FlightTicketRepository.kt +++ b/app/src/main/java/com/kom/skyfly/data/repository/home/flight_ticket/FlightTicketRepository.kt @@ -2,6 +2,7 @@ package com.kom.skyfly.data.repository.home.flight_ticket import com.kom.skyfly.data.model.home.flight.FlightTicket import com.kom.skyfly.data.model.home.flight_detail.FlightDetailTicket +import com.kom.skyfly.data.model.home.seat_class.SeatClassHome import com.kom.skyfly.utils.ResultWrapper import kotlinx.coroutines.flow.Flow @@ -13,10 +14,18 @@ interface FlightTicketRepository { arrivalAirport: String, departureDate: String, seatClass: String, + limit: Int? = 20, + returnDate: String? = null, + arrivalDate: String? = null, + adult: Int? = 1, + children: Int? = 0, + baby: Int? = 0, ): Flow>> fun getDetailTicket( id: String, seatClass: String, ): Flow> + + fun getSeatClassTicket(): List } diff --git a/app/src/main/java/com/kom/skyfly/data/repository/home/flight_ticket/FlightTicketRepositoryImpl.kt b/app/src/main/java/com/kom/skyfly/data/repository/home/flight_ticket/FlightTicketRepositoryImpl.kt index 73c55a5..c53b99a 100644 --- a/app/src/main/java/com/kom/skyfly/data/repository/home/flight_ticket/FlightTicketRepositoryImpl.kt +++ b/app/src/main/java/com/kom/skyfly/data/repository/home/flight_ticket/FlightTicketRepositoryImpl.kt @@ -5,6 +5,7 @@ import com.kom.skyfly.data.mapper.home.toFlightDetailTicket import com.kom.skyfly.data.mapper.home.toFlightTickets import com.kom.skyfly.data.model.home.flight.FlightTicket import com.kom.skyfly.data.model.home.flight_detail.FlightDetailTicket +import com.kom.skyfly.data.model.home.seat_class.SeatClassHome import com.kom.skyfly.utils.ResultWrapper import com.kom.skyfly.utils.proceedFlow import kotlinx.coroutines.flow.Flow @@ -19,18 +20,31 @@ class FlightTicketRepositoryImpl( arrivalAirport: String, departureDate: String, seatClass: String, + limit: Int?, + returnDate: String?, + arrivalDate: String?, + adult: Int?, + children: Int?, + baby: Int?, ): Flow>> { return proceedFlow { dataSource.getAllFlight( page = page, departureAirport = departureAirport, + limit = limit, arrivalAirport = arrivalAirport, departureDate = departureDate, seatClass = seatClass, + returnDate = returnDate, + adult = adult, + baby = baby, + children = children, ).data.toFlightTickets() } } + override fun getSeatClassTicket(): List = dataSource.getSeatClassData() + override fun getDetailTicket( id: String, seatClass: String, diff --git a/app/src/main/java/com/kom/skyfly/data/source/network/model/home/flight/PriceRange.kt b/app/src/main/java/com/kom/skyfly/data/source/network/model/home/flight/PriceRange.kt index ce7fb67..72046ae 100644 --- a/app/src/main/java/com/kom/skyfly/data/source/network/model/home/flight/PriceRange.kt +++ b/app/src/main/java/com/kom/skyfly/data/source/network/model/home/flight/PriceRange.kt @@ -10,4 +10,5 @@ data class PriceRange( val economyClass: Price, @SerializedName("BUSINESS") val businessClass: Price, + val name: String? = "Business", ) diff --git a/app/src/main/java/com/kom/skyfly/data/source/network/services/SkyFlyApiService.kt b/app/src/main/java/com/kom/skyfly/data/source/network/services/SkyFlyApiService.kt index 8d90f5e..78a8f21 100644 --- a/app/src/main/java/com/kom/skyfly/data/source/network/services/SkyFlyApiService.kt +++ b/app/src/main/java/com/kom/skyfly/data/source/network/services/SkyFlyApiService.kt @@ -73,11 +73,16 @@ interface SkyFlyApiService { suspend fun getAllFlights( @Query("search") search: String? = null, @Query("page") page: Int, + @Query("limit") limit: Int? = 20, @Query("departureAirport") departureAirport: String, @Query("arrivalAirport") arrivalAirport: String, @Query("departureDate") departureDate: String, + @Query("returnDate") returnDate: String?, @Query("arrivalDate") arrivalDate: String? = null, - @Query("seatClass") seatClass: String, + @Query("seatClass") seatClass: String?, + @Query("adult") adult: Int? = 1, + @Query("children") children: Int? = 0, + @Query("baby") baby: Int? = 0, ): FlightResponse @GET("api/v1/flights/{id}") diff --git a/app/src/main/java/com/kom/skyfly/di/AppModules.kt b/app/src/main/java/com/kom/skyfly/di/AppModules.kt index 9d1f0ee..0015207 100644 --- a/app/src/main/java/com/kom/skyfly/di/AppModules.kt +++ b/app/src/main/java/com/kom/skyfly/di/AppModules.kt @@ -66,6 +66,7 @@ import com.kom.skyfly.presentation.home.HomeViewModel import com.kom.skyfly.presentation.home.detail_home.DetailHomeViewModel import com.kom.skyfly.presentation.home.search.SearchViewModel import com.kom.skyfly.presentation.home.search_result.SearchResultViewModel +import com.kom.skyfly.presentation.home.seatclass.SeatClassViewModel import com.kom.skyfly.presentation.login.LoginViewModel import com.kom.skyfly.presentation.main.MainViewModel import com.kom.skyfly.presentation.notification.NotificationViewModel @@ -145,6 +146,7 @@ object AppModules { viewModelOf(::AccountViewModel) viewModelOf(::NotificationViewModel) viewModelOf(::HistoryViewModel) + viewModelOf(::SeatClassViewModel) viewModelOf(::DetailHomeViewModel) viewModelOf(::SearchFlightHistoryViewModel) viewModelOf(::BaseViewModel) diff --git a/app/src/main/java/com/kom/skyfly/presentation/home/HomeFragment.kt b/app/src/main/java/com/kom/skyfly/presentation/home/HomeFragment.kt index edfdaf7..21e98cf 100644 --- a/app/src/main/java/com/kom/skyfly/presentation/home/HomeFragment.kt +++ b/app/src/main/java/com/kom/skyfly/presentation/home/HomeFragment.kt @@ -1,5 +1,6 @@ package com.kom.skyfly.presentation.home +import android.annotation.SuppressLint import android.content.Intent import android.os.Bundle import android.view.LayoutInflater @@ -16,6 +17,7 @@ import com.kom.skyfly.presentation.home.calendar.HomeCalendarFragment import com.kom.skyfly.presentation.home.passenger.PassengerFragment import com.kom.skyfly.presentation.home.search.SearchFragment import com.kom.skyfly.presentation.home.search_result.SearchResultActivity +import com.kom.skyfly.presentation.home.seatclass.SeatClassFragment import com.kom.skyfly.presentation.main.MainViewModel import com.kom.skyfly.utils.NoInternetException import com.kom.skyfly.utils.proceedWhen @@ -57,6 +59,7 @@ class HomeFragment : Fragment() { getDestinationFavoriteData() } + @SuppressLint("SetTextI18n") private fun observeDataDestination() { sharedViewModel.sourceDestination.observe(viewLifecycleOwner) { destination -> destination?.let { @@ -81,7 +84,7 @@ class HomeFragment : Fragment() { } sharedViewModel.passengerCountLiveData.observe(viewLifecycleOwner) { totalPassenger -> totalPassenger?.let { - binding.tvPassengers.text = it.toString() + binding.tvPassengers.text = "$it Passengers" } } } @@ -134,6 +137,9 @@ class HomeFragment : Fragment() { binding.btnSearchFlight.setOnClickListener { val departureAirport = binding.layoutSelectDestination.tvStartFrom.text val arrivalAirport = binding.layoutSelectDestination.tvEndDestination.text + val babyCount = sharedViewModel.passengerBabyCountLiveData + val adultCount = sharedViewModel.passengerAdultCountLiveData + val childCount = sharedViewModel.passengerChildCountLiveData val departureTime = convertDateFormat(binding.tvDeparture.text.toString()) val intent = @@ -141,6 +147,10 @@ class HomeFragment : Fragment() { putExtra("EXTRA_DEPARTURE_AIRPORT", departureAirport) putExtra("EXTRA_ARRIVAL_AIRPORT", arrivalAirport) putExtra("EXTRA_DEPARTURE_TIME", departureTime) + putExtra("EXTRA_BABY_COUNT", babyCount.value) + putExtra("EXTRA_ADULT_COUNT", adultCount.value) + putExtra("EXTRA_CHILD_COUNT", childCount.value) + } startActivity(intent) } @@ -151,6 +161,10 @@ class HomeFragment : Fragment() { source = dest dest = temp } + binding.tvSeats.setOnClickListener { + val seatClassBottomSheet = SeatClassFragment() + seatClassBottomSheet.show(parentFragmentManager, seatClassBottomSheet.tag) + } } private fun getDestinationFavoriteData() { diff --git a/app/src/main/java/com/kom/skyfly/presentation/home/search/viewitems/Items.kt b/app/src/main/java/com/kom/skyfly/presentation/home/search/viewitems/Items.kt index 5029fe3..6d93b9a 100644 --- a/app/src/main/java/com/kom/skyfly/presentation/home/search/viewitems/Items.kt +++ b/app/src/main/java/com/kom/skyfly/presentation/home/search/viewitems/Items.kt @@ -24,7 +24,6 @@ class Items( } } - override fun getLayout(): Int = R.layout.layout_item_airport_search override fun initializeViewBinding(view: View): LayoutItemAirportSearchBinding { diff --git a/app/src/main/java/com/kom/skyfly/presentation/home/search_result/SearchResultViewModel.kt b/app/src/main/java/com/kom/skyfly/presentation/home/search_result/SearchResultViewModel.kt index ea01519..0ef0e2b 100644 --- a/app/src/main/java/com/kom/skyfly/presentation/home/search_result/SearchResultViewModel.kt +++ b/app/src/main/java/com/kom/skyfly/presentation/home/search_result/SearchResultViewModel.kt @@ -16,6 +16,11 @@ class SearchResultViewModel( arrivalAirport: String, departureDate: String, seatClass: String, + limit: Int? = 20, + arrivalDate: String? = null, + adult: Int? = 1, + children: Int? = 0, + baby: Int? = 0, ) = flightRepository.getAllTicket( search = search, page = page, @@ -23,5 +28,10 @@ class SearchResultViewModel( arrivalAirport = arrivalAirport, departureDate = departureDate, seatClass = seatClass, + limit = limit, + arrivalDate = arrivalDate, + adult = adult, + children = children, + baby = baby, ).asLiveData(Dispatchers.IO) } diff --git a/app/src/main/java/com/kom/skyfly/presentation/home/seatclass/SeatClassFragment.kt b/app/src/main/java/com/kom/skyfly/presentation/home/seatclass/SeatClassFragment.kt index f140791..c0713c6 100644 --- a/app/src/main/java/com/kom/skyfly/presentation/home/seatclass/SeatClassFragment.kt +++ b/app/src/main/java/com/kom/skyfly/presentation/home/seatclass/SeatClassFragment.kt @@ -4,12 +4,21 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.bottomsheet.BottomSheetDialogFragment -import com.kom.skyfly.R +import com.kom.skyfly.data.model.home.seat_class.SeatClassHome import com.kom.skyfly.databinding.FragmentSeatClassBinding +import com.kom.skyfly.presentation.home.seatclass.adapter.SeatClassAdapter +import org.koin.androidx.viewmodel.ext.android.viewModel class SeatClassFragment : BottomSheetDialogFragment() { private lateinit var binding: FragmentSeatClassBinding + private val seatClassViewModel: SeatClassViewModel by viewModel() + + private val adapter: SeatClassAdapter by lazy { + SeatClassAdapter { + } + } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -19,8 +28,29 @@ class SeatClassFragment : BottomSheetDialogFragment() { inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?, - ): View? { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_seat_class, container, false) + ): View { + binding = FragmentSeatClassBinding.inflate(layoutInflater, container, false) + return binding.root + } + + override fun onViewCreated( + view: View, + savedInstanceState: Bundle?, + ) { + super.onViewCreated(view, savedInstanceState) + setupBinding(seatClassViewModel.getSeatClass()) + setOnClickListener() + } + + private fun setupBinding(data: List) { + binding.rvSeatclassCategories.apply { + layoutManager = + LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false) + adapter = this@SeatClassFragment.adapter + } + adapter.submitData(data) + } + + private fun setOnClickListener() { } } diff --git a/app/src/main/java/com/kom/skyfly/presentation/main/MainActivity.kt b/app/src/main/java/com/kom/skyfly/presentation/main/MainActivity.kt index 06a0410..3fc8c5b 100644 --- a/app/src/main/java/com/kom/skyfly/presentation/main/MainActivity.kt +++ b/app/src/main/java/com/kom/skyfly/presentation/main/MainActivity.kt @@ -32,7 +32,7 @@ class MainActivity : BaseActivity() { super.onCreate(savedInstanceState) setContentView(binding.root) setBottomNavbar() - navigate() +// navigate() } private fun setBottomNavbar() { diff --git a/app/src/main/res/layout/fragment_seat_class.xml b/app/src/main/res/layout/fragment_seat_class.xml index 6b97867..6dd6314 100644 --- a/app/src/main/res/layout/fragment_seat_class.xml +++ b/app/src/main/res/layout/fragment_seat_class.xml @@ -32,9 +32,10 @@ android:layout_marginTop="8dp" android:id="@+id/rv_seatclass_categories" android:layout_width="match_parent" - android:layout_height="0dp" + android:layout_height="match_parent" app:layout_constraintTop_toBottomOf="@id/v_fragment_select_seatclass" app:layout_constraintStart_toStartOf="parent" + android:orientation="vertical" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toTopOf="@id/btn_seatclass_save" tools:listitem="@layout/layout_item_seatclass_card"/> diff --git a/app/src/main/res/layout/layout_item_seatclass_card.xml b/app/src/main/res/layout/layout_item_seatclass_card.xml index 27409f6..e80a734 100644 --- a/app/src/main/res/layout/layout_item_seatclass_card.xml +++ b/app/src/main/res/layout/layout_item_seatclass_card.xml @@ -29,7 +29,7 @@ android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@id/tv_seatclass_title" app:layout_constraintStart_toStartOf="@id/tv_seatclass_title" - tools:text="IDR 4.950.000" + android:text="IDR 4.950.000" android:textSize="16sp" android:layout_marginTop="4dp"/> Date: Tue, 25 Jun 2024 00:13:51 +0700 Subject: [PATCH 02/23] solve seatClass --- .../model/home/seat_class/SeatClassHome.kt | 8 +++ .../home/seatclass/SeatClassViewModel.kt | 8 +++ .../seatclass/adapter/SeatClassAdapter.kt | 66 +++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 app/src/main/java/com/kom/skyfly/data/model/home/seat_class/SeatClassHome.kt create mode 100644 app/src/main/java/com/kom/skyfly/presentation/home/seatclass/SeatClassViewModel.kt create mode 100644 app/src/main/java/com/kom/skyfly/presentation/home/seatclass/adapter/SeatClassAdapter.kt diff --git a/app/src/main/java/com/kom/skyfly/data/model/home/seat_class/SeatClassHome.kt b/app/src/main/java/com/kom/skyfly/data/model/home/seat_class/SeatClassHome.kt new file mode 100644 index 0000000..8aac0c4 --- /dev/null +++ b/app/src/main/java/com/kom/skyfly/data/model/home/seat_class/SeatClassHome.kt @@ -0,0 +1,8 @@ +package com.kom.skyfly.data.model.home.seat_class + +import java.util.UUID + +data class SeatClassHome( + val id: String = UUID.randomUUID().toString(), + val seatClassName: String, +) diff --git a/app/src/main/java/com/kom/skyfly/presentation/home/seatclass/SeatClassViewModel.kt b/app/src/main/java/com/kom/skyfly/presentation/home/seatclass/SeatClassViewModel.kt new file mode 100644 index 0000000..816f5f7 --- /dev/null +++ b/app/src/main/java/com/kom/skyfly/presentation/home/seatclass/SeatClassViewModel.kt @@ -0,0 +1,8 @@ +package com.kom.skyfly.presentation.home.seatclass + +import androidx.lifecycle.ViewModel +import com.kom.skyfly.data.repository.home.flight_ticket.FlightTicketRepository + +class SeatClassViewModel(private val repo: FlightTicketRepository) : ViewModel() { + fun getSeatClass() = repo.getSeatClassTicket() +} diff --git a/app/src/main/java/com/kom/skyfly/presentation/home/seatclass/adapter/SeatClassAdapter.kt b/app/src/main/java/com/kom/skyfly/presentation/home/seatclass/adapter/SeatClassAdapter.kt new file mode 100644 index 0000000..7950a43 --- /dev/null +++ b/app/src/main/java/com/kom/skyfly/presentation/home/seatclass/adapter/SeatClassAdapter.kt @@ -0,0 +1,66 @@ +package com.kom.skyfly.presentation.home.seatclass.adapter + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.AsyncListDiffer +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.RecyclerView +import com.kom.skyfly.data.model.home.seat_class.SeatClassHome +import com.kom.skyfly.databinding.LayoutItemSeatclassCardBinding + +class SeatClassAdapter(private val itemClick: (SeatClassHome) -> Unit) : + RecyclerView.Adapter() { + private val dataDiffer = + AsyncListDiffer( + this, + object : DiffUtil.ItemCallback() { + override fun areItemsTheSame( + oldItem: SeatClassHome, + newItem: SeatClassHome, + ): Boolean { + return oldItem.id == newItem.id + } + + override fun areContentsTheSame( + oldItem: SeatClassHome, + newItem: SeatClassHome, + ): Boolean { + return oldItem.hashCode() == newItem.hashCode() + } + }, + ) + + fun submitData(data: List) { + dataDiffer.submitList(data) + } + + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int, + ): ItemSeatClassViewHolder { + val binding = + LayoutItemSeatclassCardBinding.inflate(LayoutInflater.from(parent.context), parent, false) + return ItemSeatClassViewHolder(binding, itemClick) + } + + override fun onBindViewHolder( + holder: ItemSeatClassViewHolder, + position: Int, + ) { + holder.bindView(dataDiffer.currentList[position]) + } + + override fun getItemCount(): Int = dataDiffer.currentList.size + + class ItemSeatClassViewHolder( + private val binding: LayoutItemSeatclassCardBinding, + val itemClick: (SeatClassHome) -> Unit, + ) : RecyclerView.ViewHolder(binding.root) { + fun bindView(item: SeatClassHome) { + with(item) { + binding.tvSeatclassTitle.text = item.seatClassName + itemView.setOnClickListener { itemClick(this) } + } + } + } +} From 8b9b7c551bc4caa016902222e1dd145fa2074d46 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jun 2024 04:19:43 +0700 Subject: [PATCH 03/23] feat: progress intent detail --- .../com/kom/skyfly/presentation/home/HomeFragment.kt | 1 - .../home/detail_home/DetailHomeActivity.kt | 8 ++++++++ .../home/search_result/SearchResultActivity.kt | 9 +++++++++ app/src/main/res/layout/activity_detail_home.xml | 11 ++++++++++- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/kom/skyfly/presentation/home/HomeFragment.kt b/app/src/main/java/com/kom/skyfly/presentation/home/HomeFragment.kt index 21e98cf..5291848 100644 --- a/app/src/main/java/com/kom/skyfly/presentation/home/HomeFragment.kt +++ b/app/src/main/java/com/kom/skyfly/presentation/home/HomeFragment.kt @@ -150,7 +150,6 @@ class HomeFragment : Fragment() { putExtra("EXTRA_BABY_COUNT", babyCount.value) putExtra("EXTRA_ADULT_COUNT", adultCount.value) putExtra("EXTRA_CHILD_COUNT", childCount.value) - } startActivity(intent) } diff --git a/app/src/main/java/com/kom/skyfly/presentation/home/detail_home/DetailHomeActivity.kt b/app/src/main/java/com/kom/skyfly/presentation/home/detail_home/DetailHomeActivity.kt index a98f177..7c0a084 100644 --- a/app/src/main/java/com/kom/skyfly/presentation/home/detail_home/DetailHomeActivity.kt +++ b/app/src/main/java/com/kom/skyfly/presentation/home/detail_home/DetailHomeActivity.kt @@ -1,11 +1,13 @@ package com.kom.skyfly.presentation.home.detail_home import android.annotation.SuppressLint +import android.content.Intent import android.os.Bundle import android.util.Log import androidx.appcompat.app.AppCompatActivity import com.kom.skyfly.data.model.home.flight_detail.FlightDetailTicket import com.kom.skyfly.databinding.ActivityDetailHomeBinding +import com.kom.skyfly.presentation.checkout.bookersbiodata.BookersBiodataActivity import com.kom.skyfly.utils.proceedWhen import org.koin.androidx.viewmodel.ext.android.viewModel @@ -66,5 +68,11 @@ class DetailHomeActivity : AppCompatActivity() { binding.headerDetailTicketHome.ivBackBtnDetailTicketHome.setOnClickListener { finish() } + binding.btnSelectTicket.setOnClickListener{ + val intent = Intent(this,BookersBiodataActivity::class.java).apply { + + } + + } } } diff --git a/app/src/main/java/com/kom/skyfly/presentation/home/search_result/SearchResultActivity.kt b/app/src/main/java/com/kom/skyfly/presentation/home/search_result/SearchResultActivity.kt index 017c83a..b356a8c 100644 --- a/app/src/main/java/com/kom/skyfly/presentation/home/search_result/SearchResultActivity.kt +++ b/app/src/main/java/com/kom/skyfly/presentation/home/search_result/SearchResultActivity.kt @@ -38,6 +38,9 @@ class SearchResultActivity : AppCompatActivity() { private var departureAirport: String? = null private var arrivalAirport: String? = null private var departureTime: String? = null + private var adultCount: Int? = null + private var childrenCount: Int? = null + private var babyCount: Int? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -46,6 +49,9 @@ class SearchResultActivity : AppCompatActivity() { departureAirport = intent.getStringExtra("EXTRA_DEPARTURE_AIRPORT") arrivalAirport = intent.getStringExtra("EXTRA_ARRIVAL_AIRPORT") departureTime = intent.getStringExtra("EXTRA_DEPARTURE_TIME") + adultCount = intent.getIntExtra("EXTRA_ADULT_COUNT", 0) + childrenCount = intent.getIntExtra("EXTRA_CHILD_COUNT", 0) + babyCount = intent.getIntExtra("EXTRA_BABY_COUNT", 0) setOnClickListener() setupBinding() getCalendarData() @@ -78,6 +84,9 @@ class SearchResultActivity : AppCompatActivity() { departureAirport = departureAirport!!, departureDate = date, seatClass = "ECONOMY", + adult = adultCount, + children = childrenCount, + baby = babyCount, ).observe(this) { response -> response.proceedWhen( doOnSuccess = { diff --git a/app/src/main/res/layout/activity_detail_home.xml b/app/src/main/res/layout/activity_detail_home.xml index f41b139..7106096 100644 --- a/app/src/main/res/layout/activity_detail_home.xml +++ b/app/src/main/res/layout/activity_detail_home.xml @@ -21,7 +21,7 @@ + android:padding="16dp"> +