diff --git a/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt b/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt index 6a6440c8..13774262 100644 --- a/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt +++ b/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt @@ -2,6 +2,7 @@ package org.sopt.pingle.util.context import android.app.Activity import android.content.Context +import android.content.Intent import android.view.View import android.view.inputmethod.InputMethodManager import android.widget.Toast @@ -9,6 +10,8 @@ import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import androidx.annotation.StringRes import androidx.core.content.ContextCompat +import org.sopt.pingle.presentation.ui.common.WebViewActivity +import org.sopt.pingle.presentation.ui.common.WebViewActivity.Companion.WEB_VIEW_LINK fun Context.showToast(message: String, isShort: Boolean = true) { val duration = if (isShort) Toast.LENGTH_SHORT else Toast.LENGTH_LONG @@ -25,3 +28,7 @@ fun Context.stringOf(@StringRes resId: Int) = getString(resId) fun Context.colorOf(@ColorRes resId: Int) = ContextCompat.getColor(this, resId) fun Context.drawableOf(@DrawableRes resId: Int) = ContextCompat.getDrawable(this, resId) + +fun Context.navigateToWebView(link: String) = Intent(this, WebViewActivity::class.java).apply { + putExtra(WEB_VIEW_LINK, link) +} diff --git a/app/src/main/java/org/sopt/pingle/util/fragment/FragmentExt.kt b/app/src/main/java/org/sopt/pingle/util/fragment/FragmentExt.kt index bca86575..c07deab7 100644 --- a/app/src/main/java/org/sopt/pingle/util/fragment/FragmentExt.kt +++ b/app/src/main/java/org/sopt/pingle/util/fragment/FragmentExt.kt @@ -1,11 +1,13 @@ package org.sopt.pingle.util.fragment +import android.content.Intent import android.widget.Toast import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import androidx.annotation.StringRes import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment +import org.sopt.pingle.presentation.ui.common.WebViewActivity fun Fragment.showToast(message: String, isShort: Boolean = true) { val duration = if (isShort) Toast.LENGTH_SHORT else Toast.LENGTH_LONG @@ -18,3 +20,8 @@ fun Fragment.colorOf(@ColorRes resId: Int) = ContextCompat.getColor(requireConte fun Fragment.drawableOf(@DrawableRes resId: Int) = ContextCompat.getDrawable(requireContext(), resId) + +fun Fragment.navigateToWebView(link: String) = + Intent(requireContext(), WebViewActivity::class.java).apply { + putExtra(WebViewActivity.WEB_VIEW_LINK, link) + }