From 7809713adc4aa5981601d2ad47bbadea0d712168 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Thu, 16 Nov 2023 13:54:10 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat=20:=20upload=5Fnavigation,=20fragment?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/AndroidManifest.xml | 5 ++--- .../main/res/navigation/catchytape_navigation.xml | 3 ++- .../ohdodok/catchytape/feature/home/HomeFragment.kt | 13 +++++++++++++ .../home/src/main/res/layout/fragment_home.xml | 1 + .../src/main/res/navigation/upload_navigation.xml | 10 +++++++--- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 85dfe12..9a387bd 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + @@ -12,7 +11,7 @@ android:supportsRtl="true" android:theme="@style/Theme.CatchyTape"> diff --git a/android/app/src/main/res/navigation/catchytape_navigation.xml b/android/app/src/main/res/navigation/catchytape_navigation.xml index 342d242..dc9a4e9 100644 --- a/android/app/src/main/res/navigation/catchytape_navigation.xml +++ b/android/app/src/main/res/navigation/catchytape_navigation.xml @@ -2,9 +2,10 @@ + app:startDestination="@id/home_nav_graph"> + \ No newline at end of file diff --git a/android/feature/home/src/main/java/com/ohdodok/catchytape/feature/home/HomeFragment.kt b/android/feature/home/src/main/java/com/ohdodok/catchytape/feature/home/HomeFragment.kt index e6810b0..2fff1b5 100644 --- a/android/feature/home/src/main/java/com/ohdodok/catchytape/feature/home/HomeFragment.kt +++ b/android/feature/home/src/main/java/com/ohdodok/catchytape/feature/home/HomeFragment.kt @@ -2,11 +2,15 @@ package com.ohdodok.catchytape.feature.home import android.os.Bundle import android.view.View +import androidx.core.net.toUri import androidx.fragment.app.viewModels +import androidx.navigation.NavDeepLinkRequest +import androidx.navigation.fragment.findNavController import com.ohdodok.catchytape.core.ui.BaseFragment import com.ohdodok.catchytape.feature.home.databinding.FragmentHomeBinding import dagger.hilt.android.AndroidEntryPoint + @AndroidEntryPoint class HomeFragment : BaseFragment(R.layout.fragment_home) { private val viewModel: HomeViewModel by viewModels() @@ -15,5 +19,14 @@ class HomeFragment : BaseFragment(R.layout.fragment_home) { super.onViewCreated(view, savedInstanceState) binding.viewModel = viewModel binding.rvRecentlyAddedSong.adapter = MusicHorizontalAdapter() + + + + binding.ibUpload.setOnClickListener { + val request = NavDeepLinkRequest.Builder + .fromUri("android-app://com.ohdodok.catchytape/upload_fragment".toUri()) + .build() + findNavController().navigate(request) + } } } \ No newline at end of file diff --git a/android/feature/home/src/main/res/layout/fragment_home.xml b/android/feature/home/src/main/res/layout/fragment_home.xml index a35aacb..96dcdef 100644 --- a/android/feature/home/src/main/res/layout/fragment_home.xml +++ b/android/feature/home/src/main/res/layout/fragment_home.xml @@ -25,6 +25,7 @@ app:title="@string/home" /> + app:startDestination="@id/upload_fragment"> + tools:layout="@layout/fragment_upload"> + + + + \ No newline at end of file From b70fc4d37d883c0b8470c7f6a98bca635754ed42 Mon Sep 17 00:00:00 2001 From: 2taezeat Date: Thu, 16 Nov 2023 19:11:30 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat=20:=20UploadFragment=20UI=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A0=20=EB=B0=8F=20application=20logic=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gradle/plugin/AndroidLibraryPlugin.kt | 1 + .../catchytape/core/ui/BindingAdapter.kt | 33 ++++++++++++++++ .../ui/src/main/res/drawable/ic_cancel.xml | 5 +++ .../core/ui/src/main/res/values/arrays.xml | 1 + .../feature/upload/UploadViewModel.kt | 9 +++++ .../src/main/res/layout/fragment_upload.xml | 39 ++++++++----------- 6 files changed, 65 insertions(+), 23 deletions(-) create mode 100644 android/core/ui/src/main/java/com/ohdodok/catchytape/core/ui/BindingAdapter.kt create mode 100644 android/core/ui/src/main/res/drawable/ic_cancel.xml diff --git a/android/build-logic/src/main/kotlin/gradle/plugin/AndroidLibraryPlugin.kt b/android/build-logic/src/main/kotlin/gradle/plugin/AndroidLibraryPlugin.kt index 3b11b44..f41b047 100644 --- a/android/build-logic/src/main/kotlin/gradle/plugin/AndroidLibraryPlugin.kt +++ b/android/build-logic/src/main/kotlin/gradle/plugin/AndroidLibraryPlugin.kt @@ -15,6 +15,7 @@ internal class AndroidLibraryPlugin : Plugin { with(pluginManager) { apply("com.android.library") apply("org.jetbrains.kotlin.android") + apply("kotlin-kapt") } extensions.configure { diff --git a/android/core/ui/src/main/java/com/ohdodok/catchytape/core/ui/BindingAdapter.kt b/android/core/ui/src/main/java/com/ohdodok/catchytape/core/ui/BindingAdapter.kt new file mode 100644 index 0000000..142808d --- /dev/null +++ b/android/core/ui/src/main/java/com/ohdodok/catchytape/core/ui/BindingAdapter.kt @@ -0,0 +1,33 @@ +package com.ohdodok.catchytape.core.ui + +import android.widget.AutoCompleteTextView +import android.widget.TextView +import androidx.databinding.BindingAdapter +import androidx.navigation.findNavController +import com.google.android.material.appbar.MaterialToolbar + + +@BindingAdapter("pop_back_stack") +fun MaterialToolbar.bindBack(dummy: Any?) { + setNavigationOnClickListener { + findNavController().popBackStack() + } +} + + +@BindingAdapter("music_title", "genre_position") +fun TextView.bindChangeEnable(musicTitle: String, genrePosition: Int) { + if (musicTitle.isEmpty() || genrePosition == 0) { + setTextColor(resources.getColor(R.color.on_surface_variant, context.theme)) + isEnabled = false + } else { + setTextColor(resources.getColor(R.color.on_surface, context.theme)) + isEnabled = true + } +} + + +@BindingAdapter("change_selected_position") +fun AutoCompleteTextView.bindPosition(onChange: (Int) -> Unit) { + setOnItemClickListener { _, _, position, _ -> onChange(position) } +} \ No newline at end of file diff --git a/android/core/ui/src/main/res/drawable/ic_cancel.xml b/android/core/ui/src/main/res/drawable/ic_cancel.xml new file mode 100644 index 0000000..9cebae5 --- /dev/null +++ b/android/core/ui/src/main/res/drawable/ic_cancel.xml @@ -0,0 +1,5 @@ + + + diff --git a/android/core/ui/src/main/res/values/arrays.xml b/android/core/ui/src/main/res/values/arrays.xml index 8bfda18..02cfab3 100644 --- a/android/core/ui/src/main/res/values/arrays.xml +++ b/android/core/ui/src/main/res/values/arrays.xml @@ -1,6 +1,7 @@ + 장르를 선택해 주세요. genre1 genre2 genre3 diff --git a/android/feature/upload/src/main/java/com/ohdodok/catchytape/feature/upload/UploadViewModel.kt b/android/feature/upload/src/main/java/com/ohdodok/catchytape/feature/upload/UploadViewModel.kt index 8bea415..11fbef2 100644 --- a/android/feature/upload/src/main/java/com/ohdodok/catchytape/feature/upload/UploadViewModel.kt +++ b/android/feature/upload/src/main/java/com/ohdodok/catchytape/feature/upload/UploadViewModel.kt @@ -1,7 +1,16 @@ package com.ohdodok.catchytape.feature.upload import androidx.lifecycle.ViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asStateFlow class UploadViewModel : ViewModel() { + val uploadMusicTitle = MutableStateFlow("") + + private val _uploadMusicGenrePosition = MutableStateFlow(0) + val uploadMusicGenrePosition = _uploadMusicGenrePosition.asStateFlow() + + + val onChangePosition: (Int) -> Unit = { position: Int -> _uploadMusicGenrePosition.value = position } } \ No newline at end of file diff --git a/android/feature/upload/src/main/res/layout/fragment_upload.xml b/android/feature/upload/src/main/res/layout/fragment_upload.xml index 48e734e..6a46607 100644 --- a/android/feature/upload/src/main/res/layout/fragment_upload.xml +++ b/android/feature/upload/src/main/res/layout/fragment_upload.xml @@ -16,24 +16,28 @@ -