Skip to content

Commit

Permalink
[feat] #299 최저가 비교 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Haeeul committed Feb 20, 2024
1 parent 34f9fbd commit 2d7698e
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 9 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ScentsNoteAndroid"
android:usesCleartextTraffic="true"
tools:replace="android:allowBackup,android:theme">

<meta-data
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.scentsnote.android.ui.detail

import android.content.Context
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.webkit.WebViewClient
import androidx.activity.OnBackPressedCallback
import com.scentsnote.android.R
import com.scentsnote.android.databinding.FragmentLowestPriceBinding
import com.scentsnote.android.utils.extension.closeSelfWithAnimation
import com.scentsnote.android.utils.extension.setOnSafeClickListener

class LowestPriceFragment : Fragment() {
private var _binding: FragmentLowestPriceBinding? = null
private val binding get() = _binding!!

private lateinit var onBackPressedCallback: OnBackPressedCallback

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
super.onCreateView(inflater, container, savedInstanceState)
_binding = FragmentLowestPriceBinding.inflate(inflater)
return binding.root
}

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

initView()
}

override fun onAttach(context: Context) {
super.onAttach(context)

onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
closeSelfWithAnimation()
}
}
requireActivity().onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
}

override fun onDetach() {
super.onDetach()
onBackPressedCallback.remove()
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}

private fun initView(){
binding.toolbarLowestPrice.apply {
toolbar = R.drawable.icon_btn_cancel
toolbartxt = "가격 비교"

toolbarBtn.setOnSafeClickListener {
closeSelfWithAnimation()
}
}

binding.wvLowestPrice.apply {
webViewClient = WebViewClient()
loadUrl("https://www.naver.com/")
}
}

companion object {
fun newInstance(): LowestPriceFragment = LowestPriceFragment()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ class PerfumeDetailActivity :
}

}

binding.btnLowestPrice.setOnSafeClickListener {
supportFragmentManager.beginTransaction()
.setCustomAnimations(
R.anim.slide_up,
R.anim.slide_down,
R.anim.slide_up,
R.anim.slide_down
)
.add(R.id.fc_detail, LowestPriceFragment.newInstance())
.commitAllowingStateLoss()
}
}

override fun onBackPressed() {
Expand Down
Binary file added app/src/main/res/drawable-hdpi/btn_price_more.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/btn_price_more.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/btn_price_more.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxxhdpi/btn_price_more.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="1dp" android:color="@color/primary_black"/>
</shape>
Binary file added app/src/main/res/drawable/btn_price_more.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/detail_star_active.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 48 additions & 9 deletions app/src/main/res/layout/activity_perfume_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:background="@color/white"
app:layout_constraintBottom_toBottomOf="@+id/tab_perfume_detail"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/indicator_perfume_detail"
android:background="@color/white" />
app:layout_constraintTop_toBottomOf="@+id/indicator_perfume_detail" />

<TextView
android:id="@+id/act_perfume_detail_tv_brand"
Expand Down Expand Up @@ -144,21 +144,20 @@
android:id="@+id/tab_perfume_detail"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="32dp"
android:layout_marginTop="12dp"
android:background="@drawable/tab_back"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rb_perfume_detail"
app:layout_constraintTop_toBottomOf="@+id/btn_lowest_price"
app:tabGravity="fill"
app:tabIndicatorColor="@color/primary_black"
app:tabIndicatorGravity="bottom"
app:tabIndicatorHeight="4dp"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabMaxWidth="0dp"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/primary_black"
app:tabTextAppearance="@style/Theme.ScentsNote.Tab"
app:tabTextColor="@color/dark_gray_7d">
</com.google.android.material.tabs.TabLayout>
app:tabTextColor="@color/dark_gray_7d" />

<com.scentsnote.android.ui.detail.MeasuredViewPager
android:id="@+id/vp_perfume_detail"
Expand All @@ -167,7 +166,41 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tab_perfume_detail"></com.scentsnote.android.ui.detail.MeasuredViewPager>
app:layout_constraintTop_toBottomOf="@+id/tab_perfume_detail" />

<ImageView
android:id="@+id/btn_lowest_price"
android:layout_width="0dp"
android:layout_height="42dp"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="16dp"
android:background="@drawable/border_dark_gray_7d_line_square_2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rb_perfume_detail" />

<TextView
android:id="@+id/textView39"
style="@style/NotoSans.Regular"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="가격 비교하기"
android:textSize="14dp"
app:layout_constraintBottom_toBottomOf="@+id/btn_lowest_price"
app:layout_constraintEnd_toEndOf="@+id/btn_lowest_price"
app:layout_constraintStart_toStartOf="@+id/btn_lowest_price"
app:layout_constraintTop_toTopOf="@+id/btn_lowest_price" />

<ImageView
android:id="@+id/imageView58"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
app:layout_constraintBottom_toBottomOf="@+id/textView39"
app:layout_constraintStart_toEndOf="@+id/textView39"
app:layout_constraintTop_toTopOf="@+id/textView39"
app:srcCompat="@drawable/btn_price_more" />

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down Expand Up @@ -257,5 +290,11 @@
app:layout_constraintTop_toTopOf="@+id/act_perfume_detail_iv_write" />
</androidx.constraintlayout.widget.ConstraintLayout>

<FrameLayout
android:id="@+id/fc_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="10dp" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
29 changes: 29 additions & 0 deletions app/src/main/res/layout/fragment_lowest_price.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<layout 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">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.detail.LowestPriceFragment">

<include
android:id="@+id/toolbar_lowest_price"
layout="@layout/toolbar_txt_with_btn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<WebView
android:id="@+id/wv_lowest_price"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar_lowest_price" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
9 changes: 9 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--font-->
<style name="NotoSans.Regular" parent="Widget.AppCompat.TextView">
<item name="fontFamily">@font/notosans_regular</item>
<item name="android:includeFontPadding">false</item>
<item name="android:textSize">12dp</item>
<item name="android:textColor">@color/black_text</item>
</style>

<style name="MainBottomNavigation.Inactive" parent="Widget.Design.BottomNavigationView">
<item name="fontFamily">@font/notosans_regular</item>
Expand All @@ -15,6 +22,7 @@
<item name="android:textColor">@color/primary_black</item>
</style>

<!--chip-->
<style name="KeywordChipStyle" parent="Base.Widget.MaterialComponents.Chip">
<item name="chipCornerRadius">14dp</item>
<item name="chipBackgroundColor">@color/point_beige</item>
Expand Down Expand Up @@ -64,6 +72,7 @@
<item name="android:textSize">14dp</item>
</style>

<!--button-->
<style name="SelectTextBox">
<item name="android:background">@drawable/border_gray_cd_line_square</item>
<item name="android:fontFamily">@font/notosans_regular</item>
Expand Down

0 comments on commit 2d7698e

Please sign in to comment.