-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…-상세-페이지-로직-구현 [AN] feat(#337): 스터디 신청 페이지전체 스터디 상세 페이지 로직 구현
- Loading branch information
Showing
18 changed files
with
355 additions
and
50 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
android/gitudy/data/src/main/java/com/takseha/data/dto/mystudy/Commit.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,32 @@ | ||
package com.takseha.data.dto.mystudy | ||
|
||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class Commit( | ||
@SerializedName("commit_date") | ||
val commitDate: String, | ||
@SerializedName("commit_sha") | ||
val commitSha: String, | ||
@SerializedName("id") | ||
val id: Int, | ||
@SerializedName("like_count") | ||
val likeCount: LikeCount, | ||
@SerializedName("message") | ||
val message: String, | ||
@SerializedName("rejection-reason") | ||
val rejectionReason: String, | ||
@SerializedName("status") | ||
val status: String, | ||
@SerializedName("study_info_id") | ||
val studyInfoId: Int, | ||
@SerializedName("study_todo_id") | ||
val studyTodoId: Int, | ||
@SerializedName("user_id") | ||
val userId: Int | ||
) | ||
|
||
data class LikeCount( | ||
@SerializedName("like_count") | ||
val likeCount: Int | ||
) |
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
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
90 changes: 90 additions & 0 deletions
90
.../gitudy/presentation/src/main/java/com/takseha/presentation/ui/feed/StudyApplyActivity.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 |
---|---|---|
@@ -1,12 +1,102 @@ | ||
package com.takseha.presentation.ui.feed | ||
|
||
import android.graphics.Color | ||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import androidx.activity.viewModels | ||
import androidx.lifecycle.lifecycleScope | ||
import com.takseha.data.dto.feed.StudyPeriod | ||
import com.takseha.data.dto.feed.StudyStatus | ||
import com.takseha.data.dto.mystudy.MyStudyInfo | ||
import com.takseha.presentation.R | ||
import com.takseha.presentation.databinding.ActivityStudyApplyBinding | ||
import com.takseha.presentation.viewmodel.feed.StudyApplyViewModel | ||
import kotlinx.coroutines.flow.collectLatest | ||
import kotlinx.coroutines.launch | ||
import kotlin.math.abs | ||
|
||
|
||
class StudyApplyActivity : AppCompatActivity() { | ||
private lateinit var binding: ActivityStudyApplyBinding | ||
private val viewModel: StudyApplyViewModel by viewModels() | ||
|
||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_study_apply) | ||
setBinding() | ||
|
||
val studyInfoId = intent.getIntExtra("studyInfoId", 0) | ||
val studyImgColor = | ||
if (intent.getStringExtra("studyImgColor") == "") "#000000" else intent.getStringExtra("studyImgColor") | ||
|
||
window.statusBarColor = Color.parseColor(studyImgColor) | ||
|
||
viewModel.getStudyInfo(studyInfoId) | ||
|
||
lifecycleScope.launch { | ||
viewModel.uiState.collectLatest { | ||
setMyStudyInfo(studyInfoId, studyImgColor!!, it.studyInfo) | ||
} | ||
} | ||
|
||
with(binding) { | ||
backBtn.setOnClickListener { | ||
finish() | ||
} | ||
studyEnterBtn.setOnClickListener { | ||
|
||
} | ||
studyLinkCopyBtn.setOnClickListener { | ||
|
||
} | ||
} | ||
} | ||
|
||
private fun setMyStudyInfo(studyInfoId: Int, studyImgColor: String, myStudyInfo: MyStudyInfo) { | ||
with(binding) { | ||
studyBackgroundImg.setBackgroundColor(Color.parseColor(studyImgColor)) | ||
studyName.text = myStudyInfo.topic | ||
studyDetail.text = myStudyInfo.info | ||
studyRuleText.text = setCommitRule(myStudyInfo.periodType) | ||
isStudyOpenText.text = setStudyStatus(myStudyInfo.status) | ||
studyRankText.text = getString( | ||
R.string.study_team_rank, studyInfoId * 10 + 2, | ||
if (studyInfoId - 10 > 0) studyInfoId - 10 else abs(studyInfoId - 10) + 2 | ||
) | ||
teamRankFullText.text = getString( | ||
R.string.study_team_rank_full, | ||
if (studyInfoId - 10 > 0) studyInfoId - 10 else abs(studyInfoId - 10) + 2, | ||
if (myStudyInfo.lastCommitDay == null) "없음" else myStudyInfo.lastCommitDay | ||
) | ||
studyGithubLinkText.text = myStudyInfo.githubLinkInfo.branchName | ||
studyMemberCntText.text = String.format( | ||
getString(R.string.feed_member_number), | ||
myStudyInfo.currentMember, | ||
myStudyInfo.maximumMember | ||
) | ||
} | ||
} | ||
|
||
private fun setCommitRule(periodType: StudyPeriod): String { | ||
when (periodType) { | ||
StudyPeriod.STUDY_PERIOD_EVERYDAY -> return baseContext.getString(R.string.feed_rule_everyday) | ||
StudyPeriod.STUDY_PERIOD_WEEK -> return baseContext.getString(R.string.feed_rule_week) | ||
StudyPeriod.STUDY_PERIOD_NONE -> return baseContext.getString(R.string.feed_rule_free) | ||
} | ||
} | ||
|
||
private fun setStudyStatus(status: StudyStatus): String { | ||
when (status) { | ||
StudyStatus.STUDY_PRIVATE -> return baseContext.getString(R.string.study_lock) | ||
StudyStatus.STUDY_PUBLIC -> return baseContext.getString(R.string.study_unlock) | ||
StudyStatus.STUDY_DELETED -> return baseContext.getString(R.string.study_deleted) | ||
} | ||
} | ||
|
||
private fun setBinding() { | ||
binding = ActivityStudyApplyBinding.inflate(layoutInflater) | ||
val view = binding.root | ||
setContentView(view) | ||
} | ||
} |
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
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
Oops, something went wrong.