Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into feat/#758
Browse files Browse the repository at this point in the history
# Conflicts:
#	android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt
#	android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/schooldetail/SchoolDetailFragment.kt
#	android/festago/presentation/src/main/res/layout/fragment_school_detail.xml
  • Loading branch information
re4rk committed Mar 5, 2024
2 parents 924436c + 19faf78 commit 5bebc61
Show file tree
Hide file tree
Showing 148 changed files with 5,003 additions and 760 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.festago.festago.presentation.ui.home.festivallist.festival.FestivalLi
import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalFilterUiState
import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalListUiState
import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalTabUiState
import com.festago.festago.presentation.ui.schooldetail.SchoolDetailFragment
import com.festago.festago.presentation.util.repeatOnStarted
import com.festago.festago.presentation.util.setOnApplyWindowInsetsCompatListener
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -125,19 +126,27 @@ class FestivalListFragment : Fragment() {
}

private fun handleSuccess(uiState: FestivalListUiState.Success) {
festivalListAdapter.submitList(
listOf(
uiState.popularFestivals,
FestivalTabUiState {
val festivalFilter = when (it) {
0 -> FestivalFilterUiState.PROGRESS
1 -> FestivalFilterUiState.PLANNED
else -> FestivalFilterUiState.PROGRESS
}
vm.loadFestivals(festivalFilter)
},
) + uiState.festivals,
val items = uiState.getItems()
festivalListAdapter.submitList(items)
}

private fun FestivalListUiState.Success.getItems(): List<Any> {
val items = mutableListOf<Any>()
if (popularFestivalUiState.festivals.isNotEmpty()) {
items.add(popularFestivalUiState)
}
items.add(
FestivalTabUiState {
val festivalFilter = when (it) {
0 -> FestivalFilterUiState.PROGRESS
1 -> FestivalFilterUiState.PLANNED
else -> FestivalFilterUiState.PROGRESS
}
vm.loadFestivals(festivalFilter)
},
)
items.addAll(festivals)
return items.toList()
}

private fun showSchoolDetail() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class FestivalListViewModel @Inject constructor(
_uiState.value = FestivalListUiState.Success(
PopularFestivalUiState(
title = popularFestivals.title,
popularFestivals = popularFestivals.festivals.map { it.toUiState() },
festivals = popularFestivals.festivals.map { it.toUiState() },
),
festivals = festivalsPage.festivals.map { it.toUiState() },
isLastPage = festivalsPage.isLastPage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ class FestivalListPopularViewHolder(val binding: ItemFestivalListPopularBinding)
init {
TabLayoutMediator(
binding.tlDotIndicator,
binding.vpPopularFestivalForeground,
) { tab, position -> }.attach()
binding.vpPopularFestivalBackground,
) { tab, position ->
tab.view.isClickable = false
}.attach()
}

fun bind(popularFestivalUiState: PopularFestivalUiState) {
binding.tvPopularFestivalTitle.text = popularFestivalUiState.title
popularFestivalViewPager.submitList(popularFestivalUiState.popularFestivals)
popularFestivalViewPager.submitList(popularFestivalUiState.festivals)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalIte
import kotlin.math.abs

class PopularFestivalViewPagerAdapter(
foregroundViewPager: ViewPager2,
private val foregroundViewPager: ViewPager2,
backgroundViewPager: ViewPager2,
private val onPopularFestivalSelected: (FestivalItemUiState) -> Unit,
) {
Expand All @@ -24,22 +24,23 @@ class PopularFestivalViewPagerAdapter(
foregroundViewPager.adapter = foregroundAdapter
backgroundViewPager.adapter = backgroundAdapter

setTargetItemOnPageSelected(viewpager = foregroundViewPager, target = backgroundViewPager)
setTargetItemOnPageSelected(viewPager = foregroundViewPager, target = backgroundViewPager)
narrowSpaceViewPager(viewPager = foregroundViewPager)
setOffscreenPagesLimit(foregroundViewPager, PAGE_LIMIT)
setOffscreenPagesLimit(backgroundViewPager, PAGE_LIMIT)
backgroundViewPager.isUserInputEnabled = false
}

private fun setTargetItemOnPageSelected(viewpager: ViewPager2, target: ViewPager2) {
private fun setTargetItemOnPageSelected(viewPager: ViewPager2, target: ViewPager2) {
val onPageChangeCallback = object : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
target.setCurrentItem(position, false)
onPopularFestivalSelected(popularFestivals[position])
val itemIndex = position % popularFestivals.size
target.setCurrentItem(itemIndex, false)
onPopularFestivalSelected(popularFestivals[itemIndex])
}
}
viewpager.registerOnPageChangeCallback(onPageChangeCallback)
viewPager.registerOnPageChangeCallback(onPageChangeCallback)
}

private fun narrowSpaceViewPager(viewPager: ViewPager2) {
Expand Down Expand Up @@ -85,10 +86,20 @@ class PopularFestivalViewPagerAdapter(
}

fun submitList(festivals: List<FestivalItemUiState>) {
val lastFestivals = popularFestivals.toList()
popularFestivals.clear()
popularFestivals.addAll(festivals)
foregroundAdapter.submitList(festivals)
backgroundAdapter.submitList(festivals)

if (lastFestivals != festivals) {
initItemPosition()
}
}

private fun initItemPosition() {
val initialPosition = Int.MAX_VALUE / 2 - (Int.MAX_VALUE / 2 % popularFestivals.size)
foregroundViewPager.setCurrentItem(initialPosition, false)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
package com.festago.festago.presentation.ui.home.festivallist.popularfestival.foreground

import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalItemUiState

class PopularFestivalForegroundAdapter :
ListAdapter<FestivalItemUiState, PopularFestivalForegroundViewHolder>(diffUtil) {
class PopularFestivalForegroundAdapter(festivals: List<FestivalItemUiState> = listOf()) :
RecyclerView.Adapter<PopularFestivalForegroundViewHolder>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PopularFestivalForegroundViewHolder {
private val _festivals = festivals.toMutableList()

override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int,
): PopularFestivalForegroundViewHolder {
return PopularFestivalForegroundViewHolder.of(parent)
}

override fun onBindViewHolder(holder: PopularFestivalForegroundViewHolder, position: Int) {
holder.bind(getItem(position))
holder.bind(_festivals[position % _festivals.size])
}

companion object {
val diffUtil = object : DiffUtil.ItemCallback<FestivalItemUiState>() {
override fun areItemsTheSame(
oldItem: FestivalItemUiState,
newItem: FestivalItemUiState,
): Boolean {
return oldItem.id == newItem.id
}
override fun getItemCount(): Int = Int.MAX_VALUE

override fun areContentsTheSame(
oldItem: FestivalItemUiState,
newItem: FestivalItemUiState,
): Boolean {
return oldItem == newItem
}
fun submitList(festivals: List<FestivalItemUiState>) {
if (_festivals.toList() == festivals) {
return
}
_festivals.clear()
_festivals.addAll(festivals)
notifyDataSetChanged()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sealed interface FestivalListUiState {
object Loading : FestivalListUiState

data class Success(
val popularFestivals: PopularFestivalUiState,
val popularFestivalUiState: PopularFestivalUiState,
val festivals: List<FestivalItemUiState>,
val isLastPage: Boolean,
) : FestivalListUiState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package com.festago.festago.presentation.ui.home.festivallist.uistate

data class PopularFestivalUiState(
val title: String,
val popularFestivals: List<FestivalItemUiState>,
val festivals: List<FestivalItemUiState>,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.festago.festago.presentation.ui.schooldetail

import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -9,12 +11,14 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.navArgs
import com.festago.festago.presentation.databinding.FragmentSchoolDetailBinding
import com.festago.festago.presentation.databinding.ItemMediaBinding
import com.festago.festago.presentation.ui.schooldetail.uistate.SchoolDetailUiState
import com.festago.festago.presentation.util.repeatOnStarted
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class SchoolDetailFragment : Fragment() {

private var _binding: FragmentSchoolDetailBinding? = null
private val binding get() = _binding!!

Expand Down Expand Up @@ -75,13 +79,22 @@ class SchoolDetailFragment : Fragment() {
binding.ivSchoolBackground.setColorFilter(Color.parseColor("#66000000"))
adapter.submitList(uiState.festivals)
binding.llcSchoolSocialMedia.removeAllViews()
uiState.schoolInfo.socialMedia.forEach { sm ->
binding.llcSchoolSocialMedia.addView(
SocialMediaView(requireActivity(), null, sm.logoUrl, sm.url),
)

uiState.schoolInfo.socialMedia.forEach { media ->
with(ItemMediaBinding.inflate(layoutInflater, binding.llcSchoolSocialMedia, false)) {
imageUrl = media.logoUrl
ivImage.setOnClickListener { startBrowser(media.url) }
binding.llcSchoolSocialMedia.addView(ivImage)
}
}
}

private fun startBrowser(url: String) {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(url)
startActivity(intent)
}

override fun onDestroyView() {
_binding = null
super.onDestroyView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
visibility="@{uiState.shouldShowSuccess}"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="232dp"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@id/clSchoolInfo"
tools:layout_editor_absoluteX="45dp"
tools:listitem="@layout/item_festival_list_festival" />

Expand Down Expand Up @@ -118,10 +117,11 @@
android:id="@+id/hsvSchoolSocialMedia"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginVertical="8dp"
android:layout_marginStart="-8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:scrollbars="none"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@id/md_divider"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/tvSchoolName"
app:layout_constraintTop_toBottomOf="@id/tvSchoolName"
Expand All @@ -134,17 +134,6 @@
android:orientation="horizontal" />
</HorizontalScrollView>

<LinearLayout
android:id="@+id/llSocialMedia"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@id/tvSchoolName"
app:layout_constraintTop_toBottomOf="@id/tvSchoolName" />

<com.google.android.material.divider.MaterialDivider
android:id="@+id/md_divider"
android:layout_width="match_parent"
Expand Down
3 changes: 3 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ out/

### QUERYDSL ###
/src/main/generated/

### APPLICATION PROPERTIES ###
src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.festago.admin.application;

import com.festago.admin.dto.AdminFestivalV1Response;
import com.festago.admin.repository.AdminFestivalV1QueryDslRepository;
import com.festago.common.querydsl.SearchCondition;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class AdminFestivalV1QueryService {

private final AdminFestivalV1QueryDslRepository adminFestivalV1QueryDslRepository;

public Page<AdminFestivalV1Response> findAll(SearchCondition searchCondition) {
return adminFestivalV1QueryDslRepository.findAll(searchCondition);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.festago.school.application;
package com.festago.admin.application;

import com.festago.admin.dto.AdminSchoolV1Response;
import com.festago.admin.repository.AdminSchoolV1QueryDslRepository;
import com.festago.common.exception.ErrorCode;
import com.festago.common.exception.NotFoundException;
import com.festago.common.querydsl.SearchCondition;
import com.festago.school.presentation.v1.dto.SchoolV1Response;
import com.festago.school.repository.SchoolV1QueryDslRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
Expand All @@ -13,15 +13,15 @@
@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class SchoolV1QueryService {
public class AdminSchoolV1QueryService {

private final SchoolV1QueryDslRepository schoolQueryDslRepository;
private final AdminSchoolV1QueryDslRepository schoolQueryDslRepository;

public Page<SchoolV1Response> findAll(SearchCondition searchCondition) {
public Page<AdminSchoolV1Response> findAll(SearchCondition searchCondition) {
return schoolQueryDslRepository.findAll(searchCondition);
}

public SchoolV1Response findById(Long schoolId) {
public AdminSchoolV1Response findById(Long schoolId) {
return schoolQueryDslRepository.findById(schoolId)
.orElseThrow(() -> new NotFoundException(ErrorCode.SCHOOL_NOT_FOUND));
}
Expand Down
5 changes: 3 additions & 2 deletions backend/src/main/java/com/festago/admin/domain/Admin.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Admin extends BaseTimeEntity {

public static final String ROOT_ADMIN_NAME = "admin";
private static final int MIN_USERNAME_LENGTH = 4;
private static final int MAX_USERNAME_LENGTH = 20;
private static final int MIN_PASSWORD_LENGTH = 4;
Expand Down Expand Up @@ -60,14 +61,14 @@ private void validate(String username, String password) {

private void validateUsername(String username) {
String fieldName = "username";
Validator.hasBlank(username, fieldName);
Validator.notBlank(username, fieldName);
Validator.minLength(username, MIN_USERNAME_LENGTH, fieldName);
Validator.maxLength(username, MAX_USERNAME_LENGTH, fieldName);
}

private void validatePassword(String password) {
String fieldName = "password";
Validator.hasBlank(password, fieldName);
Validator.notBlank(password, fieldName);
Validator.minLength(password, MIN_PASSWORD_LENGTH, fieldName);
Validator.maxLength(password, MAX_PASSWORD_LENGTH, fieldName);
}
Expand Down
Loading

0 comments on commit 5bebc61

Please sign in to comment.