diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8038018..81aef05 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -53,6 +53,10 @@ dependencies { // Retrofit implementation("com.squareup.retrofit2:retrofit:2.9.0") implementation("com.squareup.retrofit2:converter-gson:2.9.0") + implementation("com.squareup.okhttp3:logging-interceptor:4.9.1") + // Paging + implementation("androidx.paging:paging-runtime:3.1.1") + // LiveData and ViewModel implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0") implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0") @@ -63,6 +67,8 @@ dependencies { implementation("com.tbuonomo:dotsindicator:5.0") implementation("androidx.legacy:legacy-support-v4:1.0.0") implementation("androidx.activity:activity:1.9.0") + // Image fetch + implementation("com.github.bumptech.glide:glide:4.16.0") testImplementation("junit:junit:4.13.2") diff --git a/app/src/main/java/com/modarb/android/network/ApiService.kt b/app/src/main/java/com/modarb/android/network/ApiService.kt index 99c0935..725745d 100644 --- a/app/src/main/java/com/modarb/android/network/ApiService.kt +++ b/app/src/main/java/com/modarb/android/network/ApiService.kt @@ -3,6 +3,7 @@ package com.modarb.android.network import com.modarb.android.network.models.BaseResponse import com.modarb.android.ui.home.ui.home.domain.models.HomePageResponse import com.modarb.android.ui.home.ui.plan.domain.models.PlanPageResponse +import com.modarb.android.ui.home.ui.plan.domain.models.allExercises.ExercisesResponse import com.modarb.android.ui.home.ui.plan.domain.models.customworkout.CustomWorkoutResponse import com.modarb.android.ui.onboarding.models.LoginResponse import com.modarb.android.ui.onboarding.models.RequestModels.LoginRequest @@ -14,6 +15,7 @@ import retrofit2.http.Header import retrofit2.http.PATCH import retrofit2.http.POST import retrofit2.http.Path +import retrofit2.http.Query interface ApiService { @POST("/api/v1/user/auth/login") @@ -55,5 +57,22 @@ interface ApiService { ): Response + // Exercises Selection APIs + @GET("api/v1/user/exercises/") + suspend fun getExercises( + @Header("Authorization") token: String, + @Query("filterName") filter: String, + @Query("skip") skip: Int, + @Query("limit") limit: Int + ): Response + + @GET("api/v1/user/exercises/search") + suspend fun getExercisesSearch( + @Header("Authorization") token: String, + @Query("searchTerm") search: String, + @Query("filter") filter: String + ): Response + + } diff --git a/app/src/main/java/com/modarb/android/network/RetrofitService.kt b/app/src/main/java/com/modarb/android/network/RetrofitService.kt index fec9cff..8d087a5 100644 --- a/app/src/main/java/com/modarb/android/network/RetrofitService.kt +++ b/app/src/main/java/com/modarb/android/network/RetrofitService.kt @@ -1,13 +1,16 @@ package com.modarb.android.network import com.google.gson.Gson +import okhttp3.OkHttpClient +import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Response import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory + object RetrofitService { - private var BASE_URL = "http://10.0.2.2:4000/" + private var BASE_URL = "https://moahmedwafy-modarb-be.hf.space/" inline fun handleRequest( response: Response, onSuccess: (T) -> Unit, onError: (T?) -> Unit ) { @@ -39,11 +42,21 @@ object RetrofitService { } fun createService(): ApiService { - if (!NetworkHelper.isEmulator()) { - BASE_URL = "http://192.168.1.9:4000/" - } +// if (!NetworkHelper.isEmulator()) { +// BASE_URL = "http://192.168.1.9:4000/" +// } + + val logging = HttpLoggingInterceptor() + logging.setLevel(HttpLoggingInterceptor.Level.BODY) + + + // Create an OkHttpClient and attach the logging interceptor + val client: OkHttpClient = OkHttpClient.Builder() + .addInterceptor(logging) + .build() + try { - return Retrofit.Builder().baseUrl(BASE_URL) + return Retrofit.Builder().baseUrl(BASE_URL).client(client) .addConverterFactory(GsonConverterFactory.create()).build() .create(ApiService::class.java) } catch (e: Exception) { diff --git a/app/src/main/java/com/modarb/android/ui/helpers/ViewUtils.kt b/app/src/main/java/com/modarb/android/ui/helpers/ViewUtils.kt new file mode 100644 index 0000000..6beddc8 --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/helpers/ViewUtils.kt @@ -0,0 +1,15 @@ +package com.modarb.android.ui.helpers + +import android.content.Context +import android.widget.ImageView +import com.bumptech.glide.Glide + +object ViewUtils { + + + fun loadImage(context: Context, imageUrl: String, imageView: ImageView) { + Glide.with(context).asBitmap().load(imageUrl).into(imageView) + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/helpers/WorkoutData.kt b/app/src/main/java/com/modarb/android/ui/helpers/WorkoutData.kt similarity index 76% rename from app/src/main/java/com/modarb/android/ui/home/helpers/WorkoutData.kt rename to app/src/main/java/com/modarb/android/ui/helpers/WorkoutData.kt index 3e9f14f..d4a541b 100644 --- a/app/src/main/java/com/modarb/android/ui/home/helpers/WorkoutData.kt +++ b/app/src/main/java/com/modarb/android/ui/helpers/WorkoutData.kt @@ -1,8 +1,9 @@ -package com.modarb.android.ui.home.helpers +package com.modarb.android.ui.helpers import com.modarb.android.ui.home.ui.plan.domain.models.Day import com.modarb.android.ui.home.ui.plan.domain.models.Exercise import com.modarb.android.ui.home.ui.plan.domain.models.Week +import com.modarb.android.ui.home.ui.plan.domain.models.allExercises.Data object WorkoutData { @@ -12,7 +13,7 @@ object WorkoutData { lateinit var weekList: List lateinit var selectedExercise: Exercise var selectedExerciseNumber: Int = 1 - + var selectedCustomExercisesList: MutableList = mutableListOf() fun getWeekDaysCount(): Int { return weekList[currentWeekPosition].days.size @@ -66,6 +67,28 @@ object WorkoutData { } + fun getBodyParts(): Array { + return arrayOf( + "All", + "waist", + "upper legs", + "upper arms", + "lower legs", + "chest", + "lower arms", + "back", + "neck", + "shoulders", + "cardio" + ) + } + + fun getSelectedCustomExercises(): List { + return selectedCustomExercisesList + } + + + // TODO handle getting reps after fixing the api // fun getTotalExerciseReps(exercise: List): String { // var totalReps = 0 diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/home/HomeFragment.kt b/app/src/main/java/com/modarb/android/ui/home/ui/home/HomeFragment.kt index 0f67ad3..76db6b9 100644 --- a/app/src/main/java/com/modarb/android/ui/home/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/modarb/android/ui/home/ui/home/HomeFragment.kt @@ -16,8 +16,8 @@ import com.modarb.android.R import com.modarb.android.databinding.FragmentHomeBinding import com.modarb.android.network.ApiResult import com.modarb.android.network.NetworkHelper +import com.modarb.android.ui.helpers.WorkoutData import com.modarb.android.ui.home.HomeActivity -import com.modarb.android.ui.home.helpers.WorkoutData import com.modarb.android.ui.home.ui.home.domain.models.HomePageResponse import com.modarb.android.ui.home.ui.home.presentation.HomeViewModel import com.modarb.android.ui.home.ui.plan.domain.models.PlanPageResponse diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/ExercisesPagingSource.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/ExercisesPagingSource.kt new file mode 100644 index 0000000..bd4195b --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/ExercisesPagingSource.kt @@ -0,0 +1,35 @@ +package com.modarb.android.ui.home.ui.plan + +import androidx.paging.PagingSource +import androidx.paging.PagingState +import com.modarb.android.network.ApiService +import com.modarb.android.ui.home.ui.plan.domain.models.allExercises.Data + +class ExercisesPagingSource( + private val apiService: ApiService, + private val token: String, + private val filter: String, +) : PagingSource() { + + override suspend fun load(params: LoadParams): LoadResult { + val page = params.key ?: 0 + try { + val response = apiService.getExercises(token, filter, page, params.loadSize) + return LoadResult.Page( + data = response.body()!!.data, + prevKey = if (page == 0) null else page - 1, + nextKey = if (response.body()!!.data.isEmpty()) null else page + 1 + ) + } catch (e: Exception) { + return LoadResult.Error(e) + } + } + + + override fun getRefreshKey(state: PagingState): Int? { + return state.anchorPosition?.let { anchorPosition -> + state.closestPageToPosition(anchorPosition)?.prevKey?.plus(1) + ?: state.closestPageToPosition(anchorPosition)?.nextKey?.minus(1) + } + } +} diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/LoadingStateListener.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/LoadingStateListener.kt new file mode 100644 index 0000000..7fa9ad4 --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/LoadingStateListener.kt @@ -0,0 +1,6 @@ +package com.modarb.android.ui.home.ui.plan + +interface LoadingStateListener { + fun onLoadingStarted() + fun onLoadingFinished() +} diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/adapters/CustomWorkoutTemplateAdapter.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/adapters/CustomWorkoutTemplateAdapter.kt index 0c496cc..aa6fae6 100644 --- a/app/src/main/java/com/modarb/android/ui/home/ui/plan/adapters/CustomWorkoutTemplateAdapter.kt +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/adapters/CustomWorkoutTemplateAdapter.kt @@ -7,7 +7,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.modarb.android.databinding.ItemCustomworkoutTemplateBinding import com.modarb.android.network.NetworkHelper -import com.modarb.android.ui.home.helpers.WorkoutData +import com.modarb.android.ui.helpers.WorkoutData import com.modarb.android.ui.home.ui.plan.domain.models.customworkout.Data class CustomWorkoutTemplateAdapter( diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/adapters/ExercisesAddAdapter.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/adapters/ExercisesAddAdapter.kt index 98f4e9b..6a4c1f4 100644 --- a/app/src/main/java/com/modarb/android/ui/home/ui/plan/adapters/ExercisesAddAdapter.kt +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/adapters/ExercisesAddAdapter.kt @@ -1,62 +1,107 @@ -package com.modarb.android.ui.home.ui.plan.adapters - +import android.content.Context import android.util.Log import android.view.LayoutInflater import android.view.ViewGroup +import androidx.lifecycle.LifecycleOwner +import androidx.paging.PagingData +import androidx.paging.PagingDataAdapter +import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import com.modarb.android.databinding.ItemExerciseSelectionDetailsBinding -import com.modarb.android.ui.workout.domain.models.WorkoutModel +import com.modarb.android.ui.home.ui.plan.domain.models.allExercises.Data -class ExercisesAddAdapter(private val itemList: List) : - RecyclerView.Adapter() { +class ExercisesAddAdapter(private var context: Context, private val isAdd: Boolean) : + PagingDataAdapter(DIFF_CALLBACK) { - private val selectedItems = mutableListOf() + private var selectedItems: HashMap = HashMap() inner class ViewHolder(private val binding: ItemExerciseSelectionDetailsBinding) : RecyclerView.ViewHolder(binding.root) { - fun bind(item: WorkoutModel) { - val isSelected = selectedItems.contains(item.id) - binding.root.isActivated = isSelected - binding.overlay.visibility = if (isSelected) ViewGroup.VISIBLE else ViewGroup.INVISIBLE - binding.checkMark.visibility = - if (isSelected) ViewGroup.VISIBLE else ViewGroup.INVISIBLE + fun bind(item: Data?) { + item?.let { data -> + // TODO uncomment this + //ViewUtils.loadImage(context,data.coverImage,binding.exerciseImage) + + binding.exerciseTitle.text = data.name + binding.exerciseDesc.text = data.benefits + + if (isAdd) { + val isSelected = selectedItems.contains(data.id) + binding.root.isActivated = isSelected + binding.overlay.visibility = + if (isSelected) ViewGroup.VISIBLE else ViewGroup.INVISIBLE + binding.checkMark.visibility = + if (isSelected) ViewGroup.VISIBLE else ViewGroup.INVISIBLE + + binding.root.setOnClickListener { + toggleSelection(data.id, adapterPosition) + } + } - binding.root.setOnClickListener { - toggleSelection(item.id, adapterPosition) - Log.d("selected", getSelectedItems().toString()) } } } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val binding = ItemExerciseSelectionDetailsBinding.inflate( - LayoutInflater.from(parent.context), - parent, - false + LayoutInflater.from(parent.context), parent, false ) return ViewHolder(binding) } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val item = itemList[position] - holder.bind(item) + holder.bind(getItem(position)) } - override fun getItemCount(): Int { - return itemList.size - } - - private fun toggleSelection(itemId: Int, position: Int) { + private fun toggleSelection(itemId: String, position: Int) { if (selectedItems.contains(itemId)) { selectedItems.remove(itemId) + } else { - selectedItems.add(itemId) + selectedItems[itemId] = getItem(position)!! } + getSelectedItems() notifyItemChanged(position) } - fun getSelectedItems(): List { - return selectedItems.toList() + private fun getSelectedItems() { + Log.d("selectedItems", selectedItems.toString()) + } + + fun updateData(lifecycleOwner: LifecycleOwner, newData: List) { + submitData(lifecycleOwner.lifecycle, PagingData.from(newData)) + } + + fun clearData(lifecycleOwner: LifecycleOwner) { + submitData(lifecycleOwner.lifecycle, PagingData.empty()) + } + + fun clearSelectedData() { + selectedItems.clear() + notifyDataSetChanged() + } + + fun getSelectedData(): List { + val selectedDataList = mutableListOf() + + for ((_, value) in selectedItems) { + selectedDataList.add(value) + } + + return selectedDataList + } + + + companion object { + private val DIFF_CALLBACK = object : DiffUtil.ItemCallback() { + override fun areItemsTheSame(oldItem: Data, newItem: Data): Boolean { + return oldItem.id == newItem.id + } + + override fun areContentsTheSame(oldItem: Data, newItem: Data): Boolean { + return oldItem == newItem + } + } } } diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/adapters/MyPlanViewPagerAdapter.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/adapters/MyPlanViewPagerAdapter.kt index 4c2dfd2..41722ef 100644 --- a/app/src/main/java/com/modarb/android/ui/home/ui/plan/adapters/MyPlanViewPagerAdapter.kt +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/adapters/MyPlanViewPagerAdapter.kt @@ -11,7 +11,7 @@ import androidx.recyclerview.widget.RecyclerView import com.modarb.android.R import com.modarb.android.databinding.CustomWorkoutViewBinding import com.modarb.android.databinding.MyPlanViewBinding -import com.modarb.android.ui.home.helpers.WorkoutData +import com.modarb.android.ui.helpers.WorkoutData import com.modarb.android.ui.home.ui.plan.domain.models.Data import com.modarb.android.ui.home.ui.plan.domain.models.PlanPageResponse import com.modarb.android.ui.home.ui.plan.domain.models.customworkout.CustomWorkoutResponse diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/data/PlanRepositoryImp.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/data/PlanRepositoryImp.kt index cac0a95..1e8a16a 100644 --- a/app/src/main/java/com/modarb/android/ui/home/ui/plan/data/PlanRepositoryImp.kt +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/data/PlanRepositoryImp.kt @@ -1,10 +1,17 @@ package com.modarb.android.ui.home.ui.plan.data +import androidx.paging.Pager +import androidx.paging.PagingConfig +import androidx.paging.PagingData import com.modarb.android.network.ApiResult import com.modarb.android.network.ApiService +import com.modarb.android.ui.home.ui.plan.ExercisesPagingSource import com.modarb.android.ui.home.ui.plan.domain.MyPlanRepository import com.modarb.android.ui.home.ui.plan.domain.models.PlanPageResponse +import com.modarb.android.ui.home.ui.plan.domain.models.allExercises.Data +import com.modarb.android.ui.home.ui.plan.domain.models.allExercises.ExercisesResponse import com.modarb.android.ui.home.ui.plan.domain.models.customworkout.CustomWorkoutResponse +import kotlinx.coroutines.flow.Flow class PlanRepositoryImp(private val apiService: ApiService) : MyPlanRepository { @@ -42,5 +49,52 @@ class PlanRepositoryImp(private val apiService: ApiService) : MyPlanRepository { } } + override suspend fun getExercises( + token: String, + filter: String, + page: Int, + limit: Int + ): ApiResult { + return try { + val response = apiService.getExercises(token, filter, page, limit) + if (response.isSuccessful) { + response.body()?.let { + ApiResult.Success(it) + } ?: ApiResult.Failure(Throwable("Response body is null")) + } else { + ApiResult.Error(response.body() as ExercisesResponse) + + } + } catch (e: Exception) { + ApiResult.Failure(e) + } + } + + override suspend fun getSearchExercises( + token: String, searchTerm: String, filter: String + ): ApiResult { + return try { + val response = apiService.getExercisesSearch(token, searchTerm, filter) + if (response.isSuccessful) { + response.body()?.let { + ApiResult.Success(it) + } ?: ApiResult.Failure(Throwable("Response body is null")) + } else { + ApiResult.Error(response.body() as ExercisesResponse) + + } + } catch (e: Exception) { + ApiResult.Failure(e) + } + } + + fun getExercisesPagingData(token: String, filter: String): Flow> { + return Pager( + config = PagingConfig(pageSize = 20, enablePlaceholders = false), + pagingSourceFactory = { ExercisesPagingSource(apiService, token, filter) } + ).flow + } + + } diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/MyPlanRepository.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/MyPlanRepository.kt index efbb89d..6b68207 100644 --- a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/MyPlanRepository.kt +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/MyPlanRepository.kt @@ -2,10 +2,27 @@ package com.modarb.android.ui.home.ui.plan.domain import com.modarb.android.network.ApiResult import com.modarb.android.ui.home.ui.plan.domain.models.PlanPageResponse +import com.modarb.android.ui.home.ui.plan.domain.models.allExercises.ExercisesResponse import com.modarb.android.ui.home.ui.plan.domain.models.customworkout.CustomWorkoutResponse interface MyPlanRepository { suspend fun getMyPlanPage(workoutId: String, token: String): ApiResult suspend fun getCustomWorkouts(token: String): ApiResult + + suspend fun getExercises( + token: String, + filter: String, + page: Int, + limit: Int + ): ApiResult + + suspend fun getSearchExercises( + token: String, + searchTerm: String, + filter: String + ): ApiResult + + + } \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Data.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Data.kt new file mode 100644 index 0000000..9dd8306 --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Data.kt @@ -0,0 +1,18 @@ +package com.modarb.android.ui.home.ui.plan.domain.models.allExercises + +data class Data( + val benefits: String, + val category: String, + val coverImage: String, + val duration: Int, + val equipments: List, + val exerciseType: String, + val expectedDurationRange: ExpectedDurationRange, + val id: String, + val instructions: String, + val media: Media, + val name: String, + val reps: Int, + val sets: Int, + val targetMuscles: TargetMuscles +) \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Equipment.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Equipment.kt new file mode 100644 index 0000000..13e1677 --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Equipment.kt @@ -0,0 +1,8 @@ +package com.modarb.android.ui.home.ui.plan.domain.models.allExercises + +data class Equipment( + val __v: Int, + val _id: String, + val image: String, + val name: String +) \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/ExercisesResponse.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/ExercisesResponse.kt new file mode 100644 index 0000000..568ef6a --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/ExercisesResponse.kt @@ -0,0 +1,8 @@ +package com.modarb.android.ui.home.ui.plan.domain.models.allExercises + +import com.modarb.android.network.models.BaseResponse + +data class ExercisesResponse( + val `data`: List, + val meta: Meta, +) : BaseResponse() \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/ExpectedDurationRange.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/ExpectedDurationRange.kt new file mode 100644 index 0000000..f0e43b4 --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/ExpectedDurationRange.kt @@ -0,0 +1,6 @@ +package com.modarb.android.ui.home.ui.plan.domain.models.allExercises + +data class ExpectedDurationRange( + val max: Int, + val min: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Media.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Media.kt new file mode 100644 index 0000000..97b2491 --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Media.kt @@ -0,0 +1,6 @@ +package com.modarb.android.ui.home.ui.plan.domain.models.allExercises + +data class Media( + val type: String, + val url: String +) \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Meta.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Meta.kt new file mode 100644 index 0000000..3a35f69 --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Meta.kt @@ -0,0 +1,7 @@ +package com.modarb.android.ui.home.ui.plan.domain.models.allExercises + +data class Meta( + val page: Int, + val perPage: Int, + val total: Int +) \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Primary.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Primary.kt new file mode 100644 index 0000000..cc21fc8 --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Primary.kt @@ -0,0 +1,8 @@ +package com.modarb.android.ui.home.ui.plan.domain.models.allExercises + +data class Primary( + val __v: Int, + val _id: String, + val image: String, + val name: String +) \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Secondry.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Secondry.kt new file mode 100644 index 0000000..96cbd9e --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/Secondry.kt @@ -0,0 +1,8 @@ +package com.modarb.android.ui.home.ui.plan.domain.models.allExercises + +data class Secondry( + val __v: Int, + val _id: String, + val image: String, + val name: String +) \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/TargetMuscles.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/TargetMuscles.kt new file mode 100644 index 0000000..262ebde --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/models/allExercises/TargetMuscles.kt @@ -0,0 +1,6 @@ +package com.modarb.android.ui.home.ui.plan.domain.models.allExercises + +data class TargetMuscles( + val primary: Primary, + val secondary: Secondry +) \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/usecase/GetExercisesUseCase.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/usecase/GetExercisesUseCase.kt new file mode 100644 index 0000000..d6b1874 --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/usecase/GetExercisesUseCase.kt @@ -0,0 +1,16 @@ +package com.modarb.android.ui.home.ui.plan.domain.usecase + +import com.modarb.android.network.ApiResult +import com.modarb.android.ui.home.ui.plan.domain.MyPlanRepository +import com.modarb.android.ui.home.ui.plan.domain.models.allExercises.ExercisesResponse + +class GetExercisesUseCase(private val planRepository: MyPlanRepository) { + suspend fun invoke( + token: String, + filter: String, + page: Int, + limit: Int + ): ApiResult { + return planRepository.getExercises(token, filter, page, limit) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/usecase/SearchExercisesUseCase.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/usecase/SearchExercisesUseCase.kt new file mode 100644 index 0000000..3268e8b --- /dev/null +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/domain/usecase/SearchExercisesUseCase.kt @@ -0,0 +1,13 @@ +package com.modarb.android.ui.home.ui.plan.domain.usecase + +import com.modarb.android.network.ApiResult +import com.modarb.android.ui.home.ui.plan.domain.MyPlanRepository +import com.modarb.android.ui.home.ui.plan.domain.models.allExercises.ExercisesResponse + +class SearchExercisesUseCase(private val planRepository: MyPlanRepository) { + suspend fun invoke( + token: String, searchTerm: String, filter: String + ): ApiResult { + return planRepository.getSearchExercises(token, searchTerm, filter) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/fragments/MyPlanFragment.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/fragments/MyPlanFragment.kt index 423ca98..35c89fd 100644 --- a/app/src/main/java/com/modarb/android/ui/home/ui/plan/fragments/MyPlanFragment.kt +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/fragments/MyPlanFragment.kt @@ -1,14 +1,21 @@ package com.modarb.android.ui.home.ui.plan.fragments +import ExercisesAddAdapter import android.annotation.SuppressLint import android.os.Bundle +import android.text.Editable +import android.text.TextWatcher import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.WindowManager +import android.widget.AdapterView import android.widget.ArrayAdapter +import android.widget.Button +import android.widget.EditText import android.widget.ImageButton +import android.widget.ProgressBar import android.widget.Spinner import android.widget.Toast import androidx.fragment.app.Fragment @@ -19,17 +26,18 @@ import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog +import com.modarb.android.R import com.modarb.android.databinding.FragmentMyPlanBinding import com.modarb.android.network.ApiResult -import com.modarb.android.ui.home.helpers.WorkoutData -import com.modarb.android.ui.home.ui.plan.adapters.ExercisesAddAdapter +import com.modarb.android.ui.helpers.WorkoutData import com.modarb.android.ui.home.ui.plan.adapters.MyPlanViewPagerAdapter import com.modarb.android.ui.home.ui.plan.adapters.ViewPager2ViewHeightAnimator import com.modarb.android.ui.home.ui.plan.domain.models.PlanPageResponse +import com.modarb.android.ui.home.ui.plan.domain.models.allExercises.ExercisesResponse import com.modarb.android.ui.home.ui.plan.domain.models.customworkout.CustomWorkoutResponse import com.modarb.android.ui.home.ui.plan.persentation.PlanViewModel import com.modarb.android.ui.onboarding.utils.UserPref.UserPrefUtil -import com.modarb.android.ui.workout.domain.models.WorkoutModel +import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch @@ -39,6 +47,13 @@ class MyPlanFragment : Fragment() { private lateinit var selectExerciseBottomSheet: BottomSheetDialog private val planViewModel: PlanViewModel by viewModels() private lateinit var binding: FragmentMyPlanBinding + private lateinit var exercisesAdapter: ExercisesAddAdapter + private lateinit var currentSelectedAdapter: ExercisesAddAdapter + + private lateinit var exercisesData: ExercisesResponse + private var selectedFilter: String = "" + private lateinit var progressBar: ProgressBar + private lateinit var currentSelectedRecyclerView: RecyclerView @SuppressLint("NotifyDataSetChanged") @@ -51,14 +66,15 @@ class MyPlanFragment : Fragment() { binding = FragmentMyPlanBinding.inflate(inflater, container, false) val root: View = binding.root - binding.toggleButtonGroup.check(com.modarb.android.R.id.myPlanBtn) + binding.toggleButtonGroup.check(R.id.myPlanBtn) observeData() initBottomSheet() handleAddCustomWorkout() - initSelectBottomSheet() getCustomWorkouts() observeCombinedResponses() + exercisesAdapter = ExercisesAddAdapter(requireContext(), true) + initSelectBottomSheet() Log.e("workoutID", WorkoutData.workoutId) return root @@ -68,16 +84,6 @@ class MyPlanFragment : Fragment() { private fun observeData() { binding.progress.progressOverlay.visibility = View.VISIBLE -// lifecycleScope.launch { -// planViewModel.planResponse.collect { -// when (it) { -// is ApiResult.Error<*> -> handlePlanError(it as PlanPageResponse) -// is ApiResult.Failure -> handlePlanFail(it.exception) -// else -> {} -// } -// } -// } - planViewModel.getPlanPage( WorkoutData.workoutId, "Bearer " + UserPrefUtil.getUserData(requireContext())!!.token ) @@ -139,13 +145,54 @@ class MyPlanFragment : Fragment() { planViewModel.getCustomWorkouts("Bearer ${UserPrefUtil.getUserData(requireContext())?.token}") } + private fun getSearchResultData(search: String) { + planViewModel.searchExercise( + "Bearer ${UserPrefUtil.getUserData(requireContext())?.token}", search, selectedFilter + ) + + lifecycleScope.launch { + planViewModel.getExercise.collect { + when (it) { + is ApiResult.Success<*> -> handleSearchResult(it.data as ExercisesResponse) + is ApiResult.Failure -> handlePlanFail(it.exception) + else -> {} + } + } + } + } + + private fun handleSearchResult(exercisesResponse: ExercisesResponse) { + if (exercisesResponse.data.isEmpty()) return + exercisesData = exercisesResponse + exercisesAdapter.updateData(this, exercisesData.data) + //Log.d("Search Data", exercisesResponse.data[0].name) + } + + private fun getExercises() { + val token = "Bearer ${UserPrefUtil.getUserData(requireContext())?.token}" + + progressBar.visibility = View.VISIBLE + lifecycleScope.launch { + planViewModel.getPaginatedExercises(token, selectedFilter).collectLatest { pagingData -> + exercisesAdapter.submitData(pagingData) + } + } +// +// lifecycleScope.launch { +// planViewModel.isLoading.collect { isLoading -> +// progressBar.visibility = if (isLoading) View.VISIBLE else View.GONE +// } +// } + + } private fun initBottomSheet() { bottomSheet = BottomSheetDialog(requireContext()) - bottomSheet.setContentView(com.modarb.android.R.layout.add_excersice_view) + bottomSheet.setContentView(R.layout.add_excersice_view) val closeBtn: ImageButton? = bottomSheet.findViewById(com.modarb.android.R.id.closeBtn) - val addExercise: View? = bottomSheet.findViewById(com.modarb.android.R.id.addExerciseView) + val addExercise: View? = bottomSheet.findViewById(R.id.addExerciseView) + currentSelectedRecyclerView = bottomSheet.findViewById(R.id.recyclerView)!! bottomSheet.behavior.state = BottomSheetBehavior.STATE_EXPANDED bottomSheet.setOnShowListener { @@ -163,6 +210,8 @@ class MyPlanFragment : Fragment() { } closeBtn?.setOnClickListener { + exercisesAdapter.clearSelectedData() + currentSelectedAdapter.clearData(this) bottomSheet.hide() } @@ -172,19 +221,28 @@ class MyPlanFragment : Fragment() { } } + private fun showSelectedExercise(recyclerView: RecyclerView) { + currentSelectedAdapter = ExercisesAddAdapter(requireContext(), false) + recyclerView.layoutManager = LinearLayoutManager(context) + recyclerView.adapter = currentSelectedAdapter + currentSelectedAdapter.updateData(this, exercisesAdapter.getSelectedData()) + } + private fun initSelectBottomSheet() { - // TODO refactor this shit + selectExerciseBottomSheet = BottomSheetDialog(requireContext()) - selectExerciseBottomSheet.setContentView(com.modarb.android.R.layout.select_exersice_view) + selectExerciseBottomSheet.setContentView(R.layout.select_exersice_view) val closeBtn: ImageButton? = selectExerciseBottomSheet.findViewById(com.modarb.android.R.id.closeBtn) + val addButton: Button = selectExerciseBottomSheet.findViewById(R.id.addBtn)!! val recyclerView: RecyclerView? = selectExerciseBottomSheet.findViewById(com.modarb.android.R.id.recyclerView) + progressBar = selectExerciseBottomSheet.findViewById(R.id.progress)!! - val spinner: Spinner? = - selectExerciseBottomSheet.findViewById(com.modarb.android.R.id.typeSpinner) + val searchEditText: EditText? = selectExerciseBottomSheet.findViewById(R.id.searchEditText) + val spinner: Spinner? = selectExerciseBottomSheet.findViewById(R.id.typeSpinner) selectExerciseBottomSheet.behavior.state = BottomSheetBehavior.STATE_EXPANDED selectExerciseBottomSheet.setOnShowListener { @@ -201,28 +259,83 @@ class MyPlanFragment : Fragment() { } } + // TODO handle clear when swipe down closeBtn?.setOnClickListener { selectExerciseBottomSheet.hide() } + addButton.setOnClickListener { + showSelectedExercise(currentSelectedRecyclerView) + selectExerciseBottomSheet.hide() + } + + initBottomSheetRecycle(recyclerView!!) + initBottomSheetSpinner(spinner!!) + handleSearch(searchEditText!!) + handleOnClickOnSpinner(spinner) + + } + + private fun initBottomSheetSpinner(spinner: Spinner) { + val spinnerAdapter = ArrayAdapter( + requireContext(), R.layout.custom_spinner_item, WorkoutData.getBodyParts() + ) + spinner.adapter = spinnerAdapter - recyclerView!!.layoutManager = LinearLayoutManager(context) + spinner.setSelection(0) + } - val data = mutableListOf() + private fun handleOnClickOnSpinner(spinner: Spinner) { + spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { + override fun onItemSelected( + parent: AdapterView<*>?, view: View?, position: Int, id: Long + ) { + val selectedItem = parent?.getItemAtPosition(position).toString() + selectedFilter = selectedItem + if (selectedFilter == "All") selectedFilter = "" + exercisesAdapter.clearData(this@MyPlanFragment) + getExercises() + } - for (i in 0..3) { - data.add(WorkoutModel(1, "test", "test", "test", i + 1)) + override fun onNothingSelected(parent: AdapterView<*>?) { + } } - val adapter = ExercisesAddAdapter(data) - recyclerView.adapter = adapter - val items = arrayOf("All", "Body", "Chest") + } - val spinnerAdapter = ArrayAdapter( - requireContext(), com.modarb.android.R.layout.custom_spinner_item, items - ) - spinner!!.setSelection(0) + private fun initBottomSheetRecycle(recyclerView: RecyclerView) { + recyclerView.layoutManager = LinearLayoutManager(context) + recyclerView.adapter = exercisesAdapter + } + + + private fun handleSearch(searchEditText: EditText) { + searchEditText.addTextChangedListener(object : TextWatcher { + override fun afterTextChanged(s: Editable) { + val searchTerm = searchEditText.text.trim().toString() + Log.d("searchTermLen", searchTerm.length.toString()) + if (searchTerm.isEmpty()) { + getExercises() + } else { + getSearchResultData(searchTerm) + } + + } + + override fun beforeTextChanged( + s: CharSequence, start: Int, count: Int, after: Int + ) { + + + } + + override fun onTextChanged( + s: CharSequence, start: Int, before: Int, count: Int + ) { + + + } + }) - spinner.adapter = spinnerAdapter } private fun initViewPager( @@ -239,8 +352,8 @@ class MyPlanFragment : Fragment() { binding.toggleButtonGroup.addOnButtonCheckedListener { _, checkedId, isChecked -> if (isChecked) { when (checkedId) { - com.modarb.android.R.id.myPlanBtn -> viewPager2.viewPager2!!.currentItem = 0 - com.modarb.android.R.id.customWorkOut -> viewPager2.viewPager2!!.currentItem = 1 + R.id.myPlanBtn -> viewPager2.viewPager2!!.currentItem = 0 + R.id.customWorkOut -> viewPager2.viewPager2!!.currentItem = 1 } } } @@ -250,8 +363,8 @@ class MyPlanFragment : Fragment() { override fun onPageSelected(position: Int) { binding.toggleButtonGroup.check( when (position) { - 0 -> com.modarb.android.R.id.myPlanBtn - 1 -> com.modarb.android.R.id.customWorkOut + 0 -> R.id.myPlanBtn + 1 -> R.id.customWorkOut else -> View.NO_ID } ) diff --git a/app/src/main/java/com/modarb/android/ui/home/ui/plan/persentation/PlanViewModel.kt b/app/src/main/java/com/modarb/android/ui/home/ui/plan/persentation/PlanViewModel.kt index 1c00d0e..1f1d1ff 100644 --- a/app/src/main/java/com/modarb/android/ui/home/ui/plan/persentation/PlanViewModel.kt +++ b/app/src/main/java/com/modarb/android/ui/home/ui/plan/persentation/PlanViewModel.kt @@ -2,13 +2,18 @@ package com.modarb.android.ui.home.ui.plan.persentation import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import androidx.paging.PagingData +import androidx.paging.cachedIn import com.modarb.android.network.ApiResult import com.modarb.android.network.RetrofitService import com.modarb.android.ui.home.ui.plan.data.PlanRepositoryImp import com.modarb.android.ui.home.ui.plan.domain.models.PlanPageResponse +import com.modarb.android.ui.home.ui.plan.domain.models.allExercises.ExercisesResponse import com.modarb.android.ui.home.ui.plan.domain.models.customworkout.CustomWorkoutResponse import com.modarb.android.ui.home.ui.plan.domain.usecase.GetCustomWorkoutUseCase import com.modarb.android.ui.home.ui.plan.domain.usecase.PlanPageUseCase +import com.modarb.android.ui.home.ui.plan.domain.usecase.SearchExercisesUseCase +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine @@ -21,7 +26,9 @@ class PlanViewModel : ViewModel() { private var myPlanRepository = PlanRepositoryImp(apiService) private var myPlanPageUseCase = PlanPageUseCase(myPlanRepository) private var getCustomWorkoutUseCase = GetCustomWorkoutUseCase(myPlanRepository) + private var searchExercisesUseCase = SearchExercisesUseCase(myPlanRepository) +// private var getExercisesUseCase = GetExercisesUseCase(myPlanRepository) private val _planPageResponse = MutableStateFlow?>(null) val planResponse: StateFlow?> get() = _planPageResponse @@ -29,6 +36,9 @@ class PlanViewModel : ViewModel() { private var _customWorkoutsResponse = MutableStateFlow?>(null) val customWorkoutResponse: StateFlow?> get() = _customWorkoutsResponse + private var _getAllExercises = MutableStateFlow?>(null) + val getExercise: StateFlow?> get() = _getAllExercises + private val _combinedResponses = MutableStateFlow?, ApiResult?>>(null to null) @@ -57,4 +67,26 @@ class PlanViewModel : ViewModel() { _customWorkoutsResponse.value = response } } + fun getPaginatedExercises( + token: String, + filter: String + ): Flow> { + return myPlanRepository.getExercisesPagingData(token, filter).cachedIn(viewModelScope) + } + +// fun getAllExercises(token: String, filter: String,page: Int, limit: Int) { +// viewModelScope.launch { +// val response = getExercisesUseCase.invoke(token,filter,page,limit) +// _getAllExercises.value = response +// } +// } + + fun searchExercise(token: String, search: String, filter: String) { + viewModelScope.launch { + val response = searchExercisesUseCase.invoke(token, search, filter) + _getAllExercises.value = response + } + } + + } \ No newline at end of file diff --git a/app/src/main/java/com/modarb/android/ui/workout/activities/ExerciseInfoActivity.kt b/app/src/main/java/com/modarb/android/ui/workout/activities/ExerciseInfoActivity.kt index 8744d1b..ef6a64c 100644 --- a/app/src/main/java/com/modarb/android/ui/workout/activities/ExerciseInfoActivity.kt +++ b/app/src/main/java/com/modarb/android/ui/workout/activities/ExerciseInfoActivity.kt @@ -8,7 +8,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.viewpager2.widget.ViewPager2 import com.modarb.android.R import com.modarb.android.databinding.ActivityExerciseInfoBinding -import com.modarb.android.ui.home.helpers.WorkoutData +import com.modarb.android.ui.helpers.WorkoutData import com.modarb.android.ui.workout.adapters.ExerciseInfoViewPagerAdapter class ExerciseInfoActivity : AppCompatActivity() { diff --git a/app/src/main/java/com/modarb/android/ui/workout/activities/TodayWorkoutActivity.kt b/app/src/main/java/com/modarb/android/ui/workout/activities/TodayWorkoutActivity.kt index 7684a6b..ff55be7 100644 --- a/app/src/main/java/com/modarb/android/ui/workout/activities/TodayWorkoutActivity.kt +++ b/app/src/main/java/com/modarb/android/ui/workout/activities/TodayWorkoutActivity.kt @@ -8,7 +8,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.LinearLayoutManager import com.modarb.android.R import com.modarb.android.databinding.ActivityTodayWorkoutBinding -import com.modarb.android.ui.home.helpers.WorkoutData +import com.modarb.android.ui.helpers.WorkoutData import com.modarb.android.ui.workout.adapters.WorkoutAdapter class TodayWorkoutActivity : AppCompatActivity() { diff --git a/app/src/main/java/com/modarb/android/ui/workout/activities/WeeklyWorkoutActivity.kt b/app/src/main/java/com/modarb/android/ui/workout/activities/WeeklyWorkoutActivity.kt index 839d59c..a4b8fd8 100644 --- a/app/src/main/java/com/modarb/android/ui/workout/activities/WeeklyWorkoutActivity.kt +++ b/app/src/main/java/com/modarb/android/ui/workout/activities/WeeklyWorkoutActivity.kt @@ -6,7 +6,7 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.LinearLayoutManager import com.modarb.android.databinding.ActivityWeeklyWorkoutBinding -import com.modarb.android.ui.home.helpers.WorkoutData +import com.modarb.android.ui.helpers.WorkoutData import com.modarb.android.ui.home.ui.plan.domain.models.Day import com.modarb.android.ui.workout.adapters.DaysTimeLineAdapter import com.modarb.android.ui.workout.adapters.WorkoutAdapter diff --git a/app/src/main/java/com/modarb/android/ui/workout/activities/WorkoutActivity.kt b/app/src/main/java/com/modarb/android/ui/workout/activities/WorkoutActivity.kt index 68f6ea0..7624f76 100644 --- a/app/src/main/java/com/modarb/android/ui/workout/activities/WorkoutActivity.kt +++ b/app/src/main/java/com/modarb/android/ui/workout/activities/WorkoutActivity.kt @@ -13,7 +13,7 @@ import com.modarb.android.R import com.modarb.android.databinding.ActivityWorkoutBinding import com.modarb.android.network.ApiResult import com.modarb.android.network.models.BaseResponse -import com.modarb.android.ui.home.helpers.WorkoutData +import com.modarb.android.ui.helpers.WorkoutData import com.modarb.android.ui.onboarding.utils.UserPref.UserPrefUtil import com.modarb.android.ui.workout.ExerciseListener import com.modarb.android.ui.workout.adapters.ExercisePagerAdapter diff --git a/app/src/main/java/com/modarb/android/ui/workout/adapters/ExerciseInfoViewPagerAdapter.kt b/app/src/main/java/com/modarb/android/ui/workout/adapters/ExerciseInfoViewPagerAdapter.kt index b2215f2..ef00339 100644 --- a/app/src/main/java/com/modarb/android/ui/workout/adapters/ExerciseInfoViewPagerAdapter.kt +++ b/app/src/main/java/com/modarb/android/ui/workout/adapters/ExerciseInfoViewPagerAdapter.kt @@ -8,7 +8,7 @@ import android.widget.TextView import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.modarb.android.R -import com.modarb.android.ui.home.helpers.WorkoutData +import com.modarb.android.ui.helpers.WorkoutData import com.modarb.android.ui.home.ui.plan.domain.models.Exercise class ExerciseInfoViewPagerAdapter(private val context: Context, selectedExercise: Exercise) : diff --git a/app/src/main/java/com/modarb/android/ui/workout/adapters/ExercisePagerAdapter.kt b/app/src/main/java/com/modarb/android/ui/workout/adapters/ExercisePagerAdapter.kt index 2cc247d..844dd3b 100644 --- a/app/src/main/java/com/modarb/android/ui/workout/adapters/ExercisePagerAdapter.kt +++ b/app/src/main/java/com/modarb/android/ui/workout/adapters/ExercisePagerAdapter.kt @@ -10,7 +10,7 @@ import android.view.ViewGroup import android.widget.TextView import androidx.viewpager.widget.PagerAdapter import com.modarb.android.databinding.ItemExerciseBinding -import com.modarb.android.ui.home.helpers.WorkoutData +import com.modarb.android.ui.helpers.WorkoutData import com.modarb.android.ui.workout.ExerciseListener class ExercisePagerAdapter(private val context: Context, private var listener: ExerciseListener) : diff --git a/app/src/main/java/com/modarb/android/ui/workout/adapters/TrainingWeeksAdapter.kt b/app/src/main/java/com/modarb/android/ui/workout/adapters/TrainingWeeksAdapter.kt index 3734210..ae0ac9d 100644 --- a/app/src/main/java/com/modarb/android/ui/workout/adapters/TrainingWeeksAdapter.kt +++ b/app/src/main/java/com/modarb/android/ui/workout/adapters/TrainingWeeksAdapter.kt @@ -10,7 +10,7 @@ import androidx.recyclerview.widget.RecyclerView import com.github.vipulasri.timelineview.TimelineView import com.modarb.android.R import com.modarb.android.databinding.ItemTimelineBinding -import com.modarb.android.ui.home.helpers.WorkoutData +import com.modarb.android.ui.helpers.WorkoutData import com.modarb.android.ui.home.ui.plan.domain.models.Day import com.modarb.android.ui.home.ui.plan.domain.models.Week import com.modarb.android.ui.workout.activities.WeeklyWorkoutActivity diff --git a/app/src/main/java/com/modarb/android/ui/workout/adapters/WorkoutAdapter.kt b/app/src/main/java/com/modarb/android/ui/workout/adapters/WorkoutAdapter.kt index 38ec551..142666c 100644 --- a/app/src/main/java/com/modarb/android/ui/workout/adapters/WorkoutAdapter.kt +++ b/app/src/main/java/com/modarb/android/ui/workout/adapters/WorkoutAdapter.kt @@ -9,7 +9,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.modarb.android.R import com.modarb.android.databinding.ItemWorkoutDetailsBinding -import com.modarb.android.ui.home.helpers.WorkoutData +import com.modarb.android.ui.helpers.WorkoutData import com.modarb.android.ui.home.ui.plan.domain.models.Day import com.modarb.android.ui.workout.activities.ExerciseInfoActivity diff --git a/app/src/main/res/layout/add_excersice_view.xml b/app/src/main/res/layout/add_excersice_view.xml index 476a861..e12b333 100644 --- a/app/src/main/res/layout/add_excersice_view.xml +++ b/app/src/main/res/layout/add_excersice_view.xml @@ -58,12 +58,27 @@ + \ No newline at end of file diff --git a/app/src/main/res/layout/item_exercise_selection_details.xml b/app/src/main/res/layout/item_exercise_selection_details.xml index 161e0c3..aedd000 100644 --- a/app/src/main/res/layout/item_exercise_selection_details.xml +++ b/app/src/main/res/layout/item_exercise_selection_details.xml @@ -40,8 +40,6 @@ android:layout_marginTop="8dp" android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.0" @@ -57,7 +55,7 @@ android:gravity="start" android:text="@string/workoutTitle" android:textColor="@color/white_500" - android:textSize="20sp" + android:textSize="16sp" app:layout_constraintBottom_toBottomOf="@+id/exerciseImage" app:layout_constraintEnd_toStartOf="@+id/checkMark" app:layout_constraintHorizontal_bias="0.114" diff --git a/app/src/main/res/layout/select_exersice_view.xml b/app/src/main/res/layout/select_exersice_view.xml index 578ab05..8563e50 100644 --- a/app/src/main/res/layout/select_exersice_view.xml +++ b/app/src/main/res/layout/select_exersice_view.xml @@ -68,8 +68,9 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 82bbbbf..3576b7a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -200,5 +200,6 @@ Secondary: Complete the exercise first Timed exercise + Save as template \ No newline at end of file