Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] #185 link page share #189

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions core/designsystem/src/main/res/drawable/ic_read_after_24.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M7.985,19.87H16.016C17.636,19.87 18.472,19.019 18.472,17.392V10.649H12.822C11.88,10.649 11.428,10.197 11.428,9.255V3.545H7.985C6.373,3.545 5.529,4.396 5.529,6.031V17.392C5.529,19.019 6.373,19.87 7.985,19.87ZM12.965,9.549H18.396C18.351,9.203 18.103,8.879 17.711,8.479L13.59,4.306C13.213,3.922 12.874,3.665 12.528,3.62V9.112C12.535,9.406 12.679,9.549 12.965,9.549ZM9.078,13.986C8.754,13.986 8.52,13.753 8.52,13.451C8.52,13.15 8.754,12.917 9.078,12.917H14.946C15.255,12.917 15.496,13.15 15.496,13.451C15.496,13.753 15.255,13.986 14.946,13.986H9.078ZM9.078,16.811C8.754,16.811 8.52,16.578 8.52,16.277C8.52,15.975 8.754,15.742 9.078,15.742H14.946C15.255,15.742 15.496,15.975 15.496,16.277C15.496,16.578 15.255,16.811 14.946,16.811H9.078Z"
android:fillColor="#4C4C4C"/>
android:pathData="M15,13L11,17L9,15M19,9H16.2C15.08,9 14.52,9 14.092,8.782C13.715,8.59 13.41,8.284 13.218,7.908C13,7.48 13,6.92 13,5.8V3M19,17.8V9.325C19,8.836 19,8.592 18.944,8.362C18.895,8.157 18.815,7.962 18.705,7.783C18.581,7.582 18.409,7.409 18.063,7.063L14.938,3.937C14.592,3.591 14.419,3.418 14.217,3.295C14.038,3.185 13.843,3.104 13.639,3.055C13.409,3 13.164,3 12.675,3H8.2C7.08,3 6.52,3 6.092,3.218C5.715,3.41 5.41,3.716 5.218,4.092C5,4.52 5,5.08 5,6.2V17.8C5,18.92 5,19.48 5.218,19.908C5.41,20.284 5.715,20.59 6.092,20.782C6.52,21 7.08,21 8.2,21H15.8C16.92,21 17.48,21 17.908,20.782C18.284,20.59 18.59,20.284 18.782,19.908C19,19.48 19,18.92 19,17.8Z"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#F05A39"
android:strokeLineCap="round"/>
</vector>
13 changes: 13 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_read_before_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M15,13L11,17L9,15M19,9H16.2C15.08,9 14.52,9 14.092,8.782C13.715,8.59 13.41,8.284 13.218,7.908C13,7.48 13,6.92 13,5.8V3M19,17.8V9.325C19,8.836 19,8.592 18.944,8.362C18.895,8.157 18.815,7.962 18.705,7.783C18.581,7.582 18.409,7.409 18.063,7.063L14.938,3.937C14.592,3.591 14.419,3.418 14.217,3.295C14.038,3.185 13.843,3.104 13.639,3.055C13.409,3 13.164,3 12.675,3H8.2C7.08,3 6.52,3 6.092,3.218C5.715,3.41 5.41,3.716 5.218,4.092C5,4.52 5,5.08 5,6.2V17.8C5,18.92 5,19.48 5.218,19.908C5.41,20.284 5.715,20.59 6.092,20.782C6.52,21 7.08,21 8.2,21H15.8C16.92,21 17.48,21 17.908,20.782C18.284,20.59 18.59,20.284 18.782,19.908C19,19.48 19,18.92 19,17.8Z"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#CCCCCC"
android:strokeLineCap="round"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ClipChangeFragment :
getCategoryAll()
collectClipState(args)
initCloseButtonClickListener()
initNextButtonClickListener()
}

private fun getCategoryAll() {
Expand Down Expand Up @@ -76,21 +77,33 @@ class ClipChangeFragment :
list.onEach { it.isSelected = false }
list[index].isSelected = true
binding.btnClipChangeSelectNext.state = LinkMindButtonState.ENABLE
viewModel.updateSelectedCategoryState(toastId, newClipId, true)
} else {
list.onEach { it.isSelected = false }
binding.btnClipChangeSelectNext.state = LinkMindButtonState.DISABLE
viewModel.updateSelectedCategoryState(toastId, newClipId, false)
}

initNextButtonClickListener(toastId, newClipId)
}

private fun initNextButtonClickListener(toastId: Long, newClipId: Long) {
private fun initNextButtonClickListener() {
binding.btnClipChangeSelectNext.btnClick {
viewModel.patchLinkCategory(toastId = toastId, categoryId = newClipId)
collectSelectedCategoryState()
findNavController().popBackStack()
}
}

private fun collectSelectedCategoryState() {
viewModel.selectedCategory.flowWithLifecycle(viewLifeCycle).onEach { state ->
when (state) {
is UiState.Success -> {
viewModel.patchLinkCategory(toastId = state.data.first, categoryId = state.data.second)
}

else -> {}
}
}.launchIn(viewLifeCycleScope)
}

private fun initCloseButtonClickListener() {
binding.ivClipChangeClose.onThrottleClick {
findNavController().popBackStack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class ClipLinkViewModel @Inject constructor(
private val _categoryState = MutableStateFlow<UiState<List<Category>>>(UiState.Empty)
val categoryState: StateFlow<UiState<List<Category>>> = _categoryState.asStateFlow()

private val _selectedCategory = MutableStateFlow<UiState<Pair<Long, Long>>>(UiState.Empty)
val selectedCategory: StateFlow<UiState<Pair<Long, Long>>> = _selectedCategory.asStateFlow()

private val _patchLinkCategory = MutableStateFlow<UiState<Long>>(UiState.Empty)
val patchLinkCategory: StateFlow<UiState<Long>> = _patchLinkCategory.asStateFlow()

Expand Down Expand Up @@ -99,6 +102,13 @@ class ClipLinkViewModel @Inject constructor(
}
}

fun updateSelectedCategoryState(toastId: Long, newClipId: Long, isSelected: Boolean) = viewModelScope.launch {
when (isSelected) {
true -> _selectedCategory.emit(UiState.Success(Pair(toastId, newClipId)))
false -> _selectedCategory.emit(UiState.Empty)
}
}

fun initState() {
_linkState.value = UiState.Empty
_patchLinkCategory.value = UiState.Empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import dagger.hilt.android.AndroidEntryPoint
import designsystem.components.toast.linkMindSnackBar
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.clip.R
import org.sopt.clip.databinding.FragmentWebviewBinding
import org.sopt.ui.base.BindingFragment
import org.sopt.ui.context.hideKeyboard
Expand Down Expand Up @@ -71,7 +70,7 @@ class WebViewFragment : BindingFragment<FragmentWebviewBinding>({ FragmentWebvie
}

false -> {
binding.ivRead.setImageResource(R.drawable.ic_read_before_24)
binding.ivRead.setImageResource(org.sopt.mainfeature.R.drawable.ic_read_before_24)
if (isPatched) requireActivity().linkMindSnackBar(binding.clBottomBar, "์—ด๋žŒ ์ทจ์†Œ")
}
}
Expand All @@ -83,6 +82,7 @@ class WebViewFragment : BindingFragment<FragmentWebviewBinding>({ FragmentWebvie
// initReadBtnClickLister()
initNavigationBtnClickListener()
initBrowserBtnClickListener()
initShareBtnClickListener()
initEditorActionListener()
}

Expand Down Expand Up @@ -196,6 +196,17 @@ class WebViewFragment : BindingFragment<FragmentWebviewBinding>({ FragmentWebvie
}
}

private fun initShareBtnClickListener() {
binding.ivShared.onThrottleClick {
val toasterShareIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, args.site)
type = "text/plain"
}
startActivity(Intent.createChooser(toasterShareIntent, null))
}
}

private fun initBrowserBtnClickListener() {
binding.ivInternet.onThrottleClick {
val url = binding.wbClip.url
Expand Down
9 changes: 0 additions & 9 deletions feature/clip/src/main/res/drawable/ic_read_before_24.xml

This file was deleted.

9 changes: 9 additions & 0 deletions feature/clip/src/main/res/drawable/ic_share_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M18,15V18H6V15H4V18C4,19.1 4.9,20 6,20H18C19.1,20 20,19.1 20,18V15H18ZM7,9L8.41,10.41L11,7.83V16H13V7.83L15.59,10.41L17,9L12,4L7,9Z"
android:fillColor="#4C4C4C"/>
</vector>
13 changes: 12 additions & 1 deletion feature/clip/src/main/res/layout/fragment_webview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,22 @@
android:layout_height="wrap_content"
android:padding="8dp"
android:src="@drawable/ic_read_before_24"
app:layout_constraintEnd_toStartOf="@+id/iv_internet"
app:layout_constraintEnd_toStartOf="@+id/iv_shared"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/iv_next"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/iv_shared"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:src="@drawable/ic_share_24"
app:layout_constraintEnd_toStartOf="@+id/iv_internet"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/iv_read"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/iv_internet"
android:layout_width="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion feature/home/src/main/java/org/sopt/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>({ FragmentHomeBinding.
navigateToSetting()
navigateToSearch()
navigateToAllClip()
viewModel.checkMarketUpdateState()
}

private fun initView() {
Expand Down Expand Up @@ -89,7 +90,6 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>({ FragmentHomeBinding.
getRecentSavedClip()
getWeekBestLink()
getPopupListInfo()
checkMarketUpdateState()
}
}

Expand Down
3 changes: 2 additions & 1 deletion feature/home/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_arrow_black_svg"
android:paddingBottom="7dp"
android:paddingStart="40dp"
android:paddingEnd="26dp"
android:paddingVertical="7dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="@id/tv_home_user_clip_name"/>

Expand Down
Loading