-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from ST10204902/profile-setup-implementation
implemented profile setup
- Loading branch information
Showing
14 changed files
with
148 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ava/za/co/varsitycollege/st10204902/purrsonaltrainer/adapters/SwipableComponentAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package za.co.varsitycollege.st10204902.purrsonaltrainer.adapters | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import za.co.varsitycollege.st10204902.purrsonaltrainer.R | ||
|
||
class SwipableComponentAdapter( | ||
private val itemList: List<Int>, // Assuming using drawable resource IDs | ||
private val onItemPressed: (Int) -> Unit // Callback for when an avatar is selected | ||
) : RecyclerView.Adapter<SwipableComponentAdapter.AvatarViewHolder>() { | ||
|
||
inner class AvatarViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
private val avatarImageView: ImageView = itemView.findViewById(R.id.swipable_item_image) | ||
|
||
fun bind(avatarResId: Int) { | ||
avatarImageView.setImageResource(avatarResId) | ||
itemView.setOnClickListener { | ||
onItemPressed(avatarResId) | ||
} | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AvatarViewHolder { | ||
val view = LayoutInflater.from(parent.context) | ||
.inflate(R.layout.item_swipable_component, parent, false) | ||
return AvatarViewHolder(view) | ||
} | ||
|
||
override fun onBindViewHolder(holder: AvatarViewHolder, position: Int) { | ||
holder.bind(itemList[position]) | ||
} | ||
|
||
override fun getItemCount(): Int = itemList.size | ||
} |
39 changes: 39 additions & 0 deletions
39
...ain/java/za/co/varsitycollege/st10204902/purrsonaltrainer/components/SwipeSelectorView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package za.co.varsitycollege.st10204902.purrsonaltrainer.components | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import android.widget.FrameLayout | ||
import androidx.viewpager2.widget.ViewPager2 | ||
import za.co.varsitycollege.st10204902.purrsonaltrainer.R | ||
import za.co.varsitycollege.st10204902.purrsonaltrainer.adapters.SwipableComponentAdapter | ||
|
||
class SwipeSelectorView @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0 | ||
) : FrameLayout(context, attrs, defStyleAttr) { | ||
|
||
private val viewPager: ViewPager2 | ||
private var adapter: SwipableComponentAdapter? = null | ||
|
||
init { | ||
// Inflate the layout | ||
val view = LayoutInflater.from(context) | ||
.inflate(R.layout.component_swipable_selector, this, true) | ||
viewPager = view.findViewById(R.id.viewPager) | ||
} | ||
|
||
fun setItems(avatarList: List<Int>, onAvatarSelected: (Int) -> Unit) { | ||
adapter = SwipableComponentAdapter(avatarList, onAvatarSelected) | ||
viewPager.adapter = adapter | ||
} | ||
|
||
fun getCurrentItemPosition(): Int { | ||
return viewPager.currentItem | ||
} | ||
|
||
fun setCurrentItemPosition(position: Int, smoothScroll: Boolean = true) { | ||
viewPager.setCurrentItem(position, smoothScroll) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/src/main/java/za/co/varsitycollege/st10204902/purrsonaltrainer/services/CatAvatarList.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package za.co.varsitycollege.st10204902.purrsonaltrainer.services | ||
|
||
import za.co.varsitycollege.st10204902.purrsonaltrainer.R | ||
|
||
// Add Cat Avatars Here | ||
val CatAvatarList = listOf( | ||
R.drawable.cat_placeholder, | ||
R.drawable.cat_placeholder | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/swipeableSelectorRoot" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<androidx.viewpager2.widget.ViewPager2 | ||
android:id="@+id/viewPager" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> | ||
|
||
<ImageView | ||
android:layout_width="70dp" | ||
android:layout_height="70dp" | ||
android:src="@drawable/swipe_arrow_left" | ||
android:layout_gravity="center_vertical|start"/> | ||
|
||
<ImageView | ||
android:layout_width="70dp" | ||
android:layout_height="70dp" | ||
android:src="@drawable/swipe_arrow_right" | ||
android:layout_gravity="center_vertical|end"/> | ||
</FrameLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_weight="1"> | ||
|
||
<ImageView | ||
android:id="@+id/swipable_item_image" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:scaleType="centerInside" /> | ||
</FrameLayout> |