|
|
|
|
@ -6,9 +6,30 @@ import android.view.View |
|
|
|
|
import android.view.ViewGroup |
|
|
|
|
import kotlinx.android.synthetic.main.fragment_screen_slide_page.* |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ScreenSlidePageFragment(var iconResId: Int, var titleResId: Int, var descriptionResId: Int) : BaseFragment() { |
|
|
|
|
class ScreenSlidePageFragment : BaseFragment() { |
|
|
|
|
|
|
|
|
|
private enum class BundleKey(var key: String) { |
|
|
|
|
ICON("icon"), |
|
|
|
|
TITLE("title"), |
|
|
|
|
DESCRIPTION("description") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
fun newInstance(iconResId: Int, titleResId: Int, descriptionResId: Int): ScreenSlidePageFragment { |
|
|
|
|
val f = ScreenSlidePageFragment() |
|
|
|
|
val bundle = Bundle() |
|
|
|
|
bundle.putInt(BundleKey.ICON.key, iconResId) |
|
|
|
|
bundle.putInt(BundleKey.TITLE.key, titleResId) |
|
|
|
|
bundle.putInt(BundleKey.DESCRIPTION.key, descriptionResId) |
|
|
|
|
f.arguments = bundle |
|
|
|
|
return f |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onCreateView( |
|
|
|
|
inflater: LayoutInflater, |
|
|
|
|
@ -19,9 +40,11 @@ class ScreenSlidePageFragment(var iconResId: Int, var titleResId: Int, var descr |
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
|
super.onViewCreated(view, savedInstanceState) |
|
|
|
|
|
|
|
|
|
this.icon.setImageResource(this.iconResId) |
|
|
|
|
this.title.text = requireContext().getString(this.titleResId) |
|
|
|
|
this.description.text = requireContext().getString(this.descriptionResId) |
|
|
|
|
val bundle = arguments ?: throw PAIllegalStateException("No bundle found") |
|
|
|
|
|
|
|
|
|
this.icon.setImageResource(bundle.getInt(BundleKey.ICON.key)) |
|
|
|
|
this.title.text = requireContext().getString(bundle.getInt(BundleKey.TITLE.key)) |
|
|
|
|
this.description.text = requireContext().getString(bundle.getInt(BundleKey.DESCRIPTION.key)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -31,7 +54,6 @@ class ScreenSlidePageFragment(var iconResId: Int, var titleResId: Int, var descr |
|
|
|
|
view?.findViewById<View>(R.id.title)?.translationX = position |
|
|
|
|
view?.findViewById<View>(R.id.icon)?.translationX = position |
|
|
|
|
view?.findViewById<View>(R.id.description)?.translationX = position * 2f |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|