-
Notifications
You must be signed in to change notification settings - Fork 18
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
Develop #24
base: develop
Are you sure you want to change the base?
Develop #24
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.wellnesscity.health | ||
|
||
data class IntroSlide( | ||
val title: String, | ||
val description: String, | ||
val icon: Int | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.wellnesscity.health | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
|
||
class IntroSliderAdapter(private val introSlides: List<IntroSlide>) | ||
: RecyclerView.Adapter<IntroSliderAdapter.IntroSlideViewHolder>(){ | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): IntroSlideViewHolder { | ||
return IntroSlideViewHolder( | ||
LayoutInflater.from(parent.context).inflate( | ||
R.layout.slide_item_container, | ||
parent, | ||
false | ||
) | ||
) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return introSlides.size | ||
} | ||
|
||
override fun onBindViewHolder(holder: IntroSlideViewHolder, position: Int) { | ||
holder.bind(introSlides[position]) | ||
} | ||
|
||
inner class IntroSlideViewHolder(view: View) : RecyclerView.ViewHolder(view) { | ||
|
||
private val textTitle = view.findViewById<TextView>(R.id.textTitle) | ||
private val textDescription = view.findViewById<TextView>(R.id.textDescription) | ||
private val imageIcon = view.findViewById<ImageView>(R.id.imageSlideIcon) | ||
|
||
fun bind(introSlide: IntroSlide) { | ||
textTitle.text = introSlide.title | ||
textDescription.text = introSlide.description | ||
imageIcon.setImageResource(introSlide.icon) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package com.wellnesscity.health | ||
|
||
import android.content.Intent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT | ||
import android.widget.ImageView | ||
import android.widget.LinearLayout | ||
import androidx.core.content.ContextCompat | ||
import androidx.core.view.get | ||
import androidx.viewpager2.widget.ViewPager2 | ||
import kotlinx.android.synthetic.main.onboarding_screen.* | ||
|
||
class OnboardingActivity : AppCompatActivity() { | ||
|
||
private val introSliderAdapter = IntroSliderAdapter( | ||
listOf( | ||
IntroSlide( | ||
"Health Tips / Advice", | ||
"Discover tips and advice to help you to help maintain transform and main your health", | ||
R.drawable.ic_bro | ||
), | ||
IntroSlide( | ||
"Diet Tips / Advice", | ||
"Find out basics of health diet and good nutrition, Start eating well and keep a balanced diet", | ||
R.drawable.ic_amico | ||
), | ||
IntroSlide( | ||
"Covid 19 Symptoms/Prevention tips", | ||
"Get regular Reminders of Covid19 prevention tips ensuring you stay safe", | ||
R.drawable.ic_pana | ||
) | ||
) | ||
) | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.onboarding_screen) | ||
introSliderViewPager.adapter = introSliderAdapter | ||
setupIndicators() | ||
setCurrentIndicator(0) | ||
introSliderViewPager.registerOnPageChangeCallback(object : | ||
ViewPager2.OnPageChangeCallback() { | ||
|
||
override fun onPageSelected(position: Int) { | ||
super.onPageSelected(position) | ||
setCurrentIndicator(position) | ||
} | ||
}) | ||
buttonNext.setOnClickListener { | ||
if(introSliderViewPager.currentItem + 1 < introSliderAdapter.itemCount) { | ||
introSliderViewPager.currentItem += 1 | ||
} else { | ||
Intent(applicationContext, MainActivity::class.java).also { | ||
startActivity(it) | ||
finish() | ||
} | ||
} | ||
} | ||
textSkipIntro.setOnClickListener { | ||
Intent (applicationContext, MainActivity::class.java).also { | ||
startActivity(it) | ||
finish() | ||
} | ||
} | ||
} | ||
|
||
private fun setupIndicators() { | ||
val indicators = arrayOfNulls<ImageView>(introSliderAdapter.itemCount) | ||
val layoutParams: LinearLayout.LayoutParams = | ||
LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) | ||
layoutParams.setMargins(8,0,8,0) | ||
for(i in indicators.indices) { | ||
indicators[i] = ImageView(applicationContext) | ||
indicators[i].apply { | ||
this?.setImageDrawable( | ||
ContextCompat.getDrawable( | ||
applicationContext, | ||
R.drawable.indicator_inactive | ||
) | ||
) | ||
this?.layoutParams = layoutParams | ||
} | ||
indicatorsContainer.addView(indicators[i]) | ||
} | ||
|
||
} | ||
|
||
private fun setCurrentIndicator(index: Int){ | ||
val childCount = indicatorsContainer.childCount | ||
for (i in 0 until childCount) { | ||
val imageView = indicatorsContainer[i] as ImageView | ||
if (i == index){ | ||
imageView.setImageDrawable( | ||
ContextCompat.getDrawable( | ||
applicationContext, | ||
R.drawable.indicator_active | ||
) | ||
) | ||
} else { | ||
imageView.setImageDrawable( | ||
ContextCompat.getDrawable( | ||
applicationContext, | ||
R.drawable.indicator_inactive | ||
) | ||
) | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.wellnesscity.health | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
|
||
class OnboardingFragment : Fragment() { | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
// Inflate the layout for this fragment | ||
return inflater.inflate(R.layout.fragment_onboarding, container, false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are using viewbinding instead |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.wellnesscity.health | ||
|
||
import android.content.Intent | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import android.os.Handler | ||
|
||
class SplashScreenActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.splash_screen) | ||
|
||
supportActionBar?.hide() | ||
|
||
Handler().postDelayed({ | ||
val intent = Intent (this@SplashScreenActivity, OnboardingActivity::class.java) | ||
startActivity(intent) | ||
finish() | ||
}, 3000) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.wellnesscity.health | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.os.Handler | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.navigation.NavController | ||
import androidx.navigation.Navigation | ||
|
||
class SplashScreenFragment : Fragment() { | ||
|
||
var navController : NavController? = null | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
// Inflate the layout for this fragment | ||
return inflater.inflate(R.layout.fragment_splash_screen, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
navController = Navigation.findNavController(view) | ||
|
||
// supportActionBar?.hide() | ||
|
||
Handler().postDelayed({ | ||
navController!!.navigate(R.id.action_splashScreenFragment_to_onboardingFragment) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, 3000) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should move to the project level gradle