-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '6/rough_ui' of https://github.com/hometerview/Android i…
…nto 6/mypage_fragment � Conflicts: � app/src/main/AndroidManifest.xml � app/src/main/res/values/styles.xml
- Loading branch information
Showing
59 changed files
with
2,511 additions
and
25 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
9 changes: 0 additions & 9 deletions
9
app/src/main/java/com/ftw/hometerview/bindingadapter/RatingBarBindingAdapter.kt
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
app/src/main/java/com/ftw/hometerview/di/ui/CreateReviewFragmentViewModelModule.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,48 @@ | ||
package com.ftw.hometerview.di.ui | ||
|
||
import com.ftw.domain.usecase.address.GetAddressUseCase | ||
import com.ftw.hometerview.dispatcher.Dispatcher | ||
import com.ftw.hometerview.ui.review.first.CreateReviewFirstStepInputAddressViewModel | ||
import com.ftw.hometerview.ui.review.first.CreateReviewFirstStepSelectFloorViewModel | ||
import com.ftw.hometerview.ui.review.second.CreateReviewSecondStepReviewViewModel | ||
import com.ftw.hometerview.ui.review.third.CreateReviewThirdStepSearchCompanyViewModel | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.components.FragmentComponent | ||
import dagger.hilt.android.scopes.FragmentScoped | ||
|
||
@Module | ||
@InstallIn(FragmentComponent::class) | ||
class CreateReviewFragmentViewModelModule { | ||
|
||
@Provides | ||
@FragmentScoped | ||
fun provideCreateReviewFirstStepInputAddressViewModel( | ||
dispatcher: Dispatcher, | ||
getAddressUseCase: GetAddressUseCase | ||
): CreateReviewFirstStepInputAddressViewModel { | ||
return CreateReviewFirstStepInputAddressViewModel( | ||
dispatcher, | ||
getAddressUseCase | ||
) | ||
} | ||
|
||
@Provides | ||
@FragmentScoped | ||
fun provideCreateReviewFirstStepSelectFloorViewModel(): CreateReviewFirstStepSelectFloorViewModel { | ||
return CreateReviewFirstStepSelectFloorViewModel() | ||
} | ||
|
||
@Provides | ||
@FragmentScoped | ||
fun provideCreateReviewSecondStepReviewViewModel(): CreateReviewSecondStepReviewViewModel { | ||
return CreateReviewSecondStepReviewViewModel() | ||
} | ||
|
||
@Provides | ||
@FragmentScoped | ||
fun provideCreateReviewThirdStepReviewViewModel(): CreateReviewThirdStepSearchCompanyViewModel { | ||
return CreateReviewThirdStepSearchCompanyViewModel() | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/ftw/hometerview/di/usecase/AddressUseCaseModule.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,20 @@ | ||
package com.ftw.hometerview.di.usecase | ||
|
||
import com.ftw.domain.usecase.address.GetAddressUseCase | ||
import com.ftw.domain.usecase.address.GetAddressUseCaseImpl | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
class AddressUseCaseModule { | ||
|
||
@Provides | ||
@Singleton | ||
fun provideGetAddressUseCase(): GetAddressUseCase { | ||
return GetAddressUseCaseImpl() | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/ftw/hometerview/extension/ActivityExtension.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,34 @@ | ||
package com.ftw.hometerview.extension | ||
|
||
import androidx.annotation.LayoutRes | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.FragmentActivity | ||
|
||
fun FragmentActivity.replaceFragment( | ||
@LayoutRes layoutId: Int, | ||
fragment: Fragment, | ||
addToBackStack: Boolean | ||
) { | ||
supportFragmentManager.beginTransaction() | ||
.run { | ||
replace(layoutId, fragment) | ||
if (addToBackStack) addToBackStack(null) | ||
commitAllowingStateLoss() | ||
} | ||
} | ||
|
||
fun FragmentActivity.addFragment( | ||
@LayoutRes layoutId: Int, | ||
fragment: Fragment, | ||
addToBackStack: Boolean | ||
) { | ||
supportFragmentManager.beginTransaction().run { | ||
supportFragmentManager.findFragmentById(layoutId)?.let { found -> | ||
hide(found) | ||
} | ||
|
||
add(layoutId, fragment) | ||
if (addToBackStack) addToBackStack(null) | ||
commitAllowingStateLoss() | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/ftw/hometerview/extension/FragmentExtension.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,10 @@ | ||
package com.ftw.hometerview.extension | ||
|
||
import android.content.Context | ||
import android.view.inputmethod.InputMethodManager | ||
import androidx.fragment.app.Fragment | ||
|
||
fun Fragment.hideKeyboard() { | ||
(context?.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager) | ||
?.hideSoftInputFromWindow(view?.windowToken, 0) | ||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/ftw/hometerview/ui/bindingadapter/RatingBarBindingAdapter.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,23 @@ | ||
package com.ftw.hometerview.ui.bindingadapter | ||
|
||
import android.widget.RatingBar | ||
import androidx.databinding.BindingAdapter | ||
import androidx.databinding.InverseBindingAdapter | ||
import androidx.databinding.InverseBindingListener | ||
|
||
@BindingAdapter("android:rating") | ||
fun setRating(ratingBar: RatingBar, rating: Float) { | ||
ratingBar.rating = rating | ||
} | ||
|
||
@InverseBindingAdapter(attribute = "android:rating", event = "ratingBarRatingChanged") | ||
fun getRating(ratingBar: RatingBar): Float { | ||
return ratingBar.rating | ||
} | ||
|
||
@BindingAdapter("ratingBarRatingChanged") | ||
fun setRatingChanged(ratingBar: RatingBar, attrChanged: InverseBindingListener) { | ||
ratingBar.setOnRatingBarChangeListener { _, _, _ -> | ||
attrChanged.onChange() | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/ftw/hometerview/ui/bindingadapter/TextViewBindingAdapter.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,22 @@ | ||
package com.ftw.hometerview.ui.bindingadapter | ||
|
||
import android.widget.TextView | ||
import androidx.core.widget.doAfterTextChanged | ||
import androidx.databinding.BindingAdapter | ||
import androidx.databinding.InverseBindingAdapter | ||
import androidx.databinding.InverseBindingListener | ||
|
||
@BindingAdapter("android:text") | ||
fun setText(textView: TextView, text: String?) { | ||
textView.text = text | ||
} | ||
|
||
@InverseBindingAdapter(attribute = "android:text", event = "textViewTextAttrChanged") | ||
fun getText(textView: TextView): String { | ||
return textView.text?.toString() ?: "" | ||
} | ||
|
||
@BindingAdapter("textViewTextAttrChanged") | ||
fun setTextViewAttrChangedListener(textView: TextView, attrChange: InverseBindingListener) { | ||
textView.doAfterTextChanged { attrChange.onChange() } | ||
} |
102 changes: 102 additions & 0 deletions
102
app/src/main/java/com/ftw/hometerview/ui/bottomsheet/TextListBottomSheet.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,102 @@ | ||
package com.ftw.hometerview.ui.bottomsheet | ||
|
||
import android.os.Bundle | ||
import android.os.Parcelable | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.core.os.bundleOf | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.fragment.app.DialogFragment | ||
import com.ftw.hometerview.BR | ||
import com.ftw.hometerview.R | ||
import com.ftw.hometerview.adapter.DataBindingRecyclerAdapter | ||
import com.ftw.hometerview.adapter.RecyclerItem | ||
import com.ftw.hometerview.databinding.BottomSheetTextListBinding | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
import kotlinx.parcelize.Parcelize | ||
|
||
class TextListBottomSheet : BottomSheetDialogFragment() { | ||
companion object { | ||
private const val ARGUMENT_KEY = "TEXT_LIST_BOTTOM_SHEET_ARGUMENT_KEY" | ||
fun newInstance(items: List<String>): TextListBottomSheet { | ||
return TextListBottomSheet().apply { | ||
arguments = bundleOf(ARGUMENT_KEY to Argument(items)) | ||
} | ||
} | ||
} | ||
|
||
interface Listener { | ||
fun onClickFromTextListBottomSheet(text: String) | ||
} | ||
|
||
private var _binding: BottomSheetTextListBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
private val adapter = DataBindingRecyclerAdapter() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setStyle(DialogFragment.STYLE_NORMAL, R.style.BottomSheetDialogTheme) | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
_binding = DataBindingUtil.inflate( | ||
inflater, | ||
R.layout.bottom_sheet_text_list, | ||
container, | ||
false | ||
) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
arguments?.getParcelable<Argument>(ARGUMENT_KEY)?.also { argument -> | ||
initList(argument.items) | ||
} ?: dismissAllowingStateLoss() | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
|
||
private fun initList(items: List<String>) { | ||
binding.list.adapter = adapter | ||
adapter.submitList( | ||
items.map { text -> | ||
RecyclerItem( | ||
data = Item( | ||
text = text, | ||
onClick = { | ||
(activity as? Listener)?.onClickFromTextListBottomSheet(text) | ||
?: (parentFragment as? Listener)?.onClickFromTextListBottomSheet(text) | ||
dismissAllowingStateLoss() | ||
} | ||
), | ||
layoutId = R.layout.list_item_bottom_sheet_text, | ||
variableId = BR.item | ||
) | ||
} | ||
) | ||
} | ||
|
||
data class Item( | ||
val text: String, | ||
val onClick: () -> Unit | ||
) { | ||
fun onClick() { | ||
onClick.invoke() | ||
} | ||
} | ||
|
||
@Parcelize | ||
data class Argument( | ||
val items: List<String> | ||
) : Parcelable | ||
} |
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/ftw/hometerview/ui/model/ParcelableReview.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,36 @@ | ||
package com.ftw.hometerview.ui.model | ||
|
||
import android.os.Parcelable | ||
import com.ftw.domain.entity.BuildingType | ||
import com.ftw.domain.entity.Review | ||
import kotlinx.parcelize.Parcelize | ||
import java.util.Date | ||
|
||
@Parcelize | ||
data class ParcelableReview( | ||
val buildingId: Long, | ||
val buildingName: String, | ||
val buildingType: BuildingType, | ||
val buildingAddress: String, | ||
val rating: Int, | ||
val summary: String, | ||
val officeLocation: String, | ||
val advantage: String, | ||
val disadvantage: String, | ||
val favorite: Boolean, | ||
val leftAt: Date | ||
) : Parcelable | ||
|
||
fun Review.toParcelable() = ParcelableReview( | ||
buildingId, | ||
buildingName, | ||
buildingType, | ||
buildingAddress, | ||
rating, | ||
summary, | ||
officeLocation, | ||
advantage, | ||
disadvantage, | ||
favorite, | ||
leftAt | ||
) |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/ftw/hometerview/ui/model/ParcelableSearchCompanyResult.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,20 @@ | ||
package com.ftw.hometerview.ui.model | ||
|
||
import android.os.Parcelable | ||
import com.ftw.domain.entity.SearchCompanyResult | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
data class ParcelableSearchCompanyResult( | ||
val company: String, | ||
val address: String, | ||
val destination: String | ||
) : Parcelable | ||
|
||
fun SearchCompanyResult.toParcelable(): ParcelableSearchCompanyResult { | ||
return ParcelableSearchCompanyResult( | ||
company, | ||
address, | ||
destination | ||
) | ||
} |
Oops, something went wrong.