Skip to content

Commit

Permalink
Merge pull request #69 from TeamHous/feature/#68-tendency-result-to-v…
Browse files Browse the repository at this point in the history
…iewmodel

#68 [feat] 룸메이트 카드 성향결과 / 기능 구현
  • Loading branch information
KWY0218 authored Jul 18, 2022
2 parents 7b54a4e + 9015ed0 commit 5ae7853
Show file tree
Hide file tree
Showing 19 changed files with 118 additions and 94 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ android {
}

dependencies {
// Coil
implementation "io.coil-kt:coil:2.1.0"

// compose
implementation 'androidx.activity:activity-compose:1.5.0'
implementation 'androidx.compose.material:material:1.1.1'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:usesCleartextTraffic="true"
android:name=".App"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/hous/hous_aos/ui/profile/ResultData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package com.hous.hous_aos.ui.profile
data class ResultData(
val userName: String,
val typeName: String,
val typeColor: Int,
val typeColor: String,
val typeImg: String,
val typeOneComment: String,
val typeDesc: String,
val shape: Int,
val typeRulesTitle: String,
val typeRules: List<String>,
val good: Homie,
Expand Down
34 changes: 34 additions & 0 deletions app/src/main/java/com/hous/hous_aos/ui/profile/ResultViewModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.hous.hous_aos.ui.profile

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class ResultViewModel : ViewModel() {
private val _resultData = MutableLiveData(
ResultData(
userName = "이영주",
typeName = "룰 세터 육각이",
typeColor = "GREEN",
typeImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png",
typeOneComment = "한번 더 생각하고 배려하기",
typeDesc = "여러 생활영역에 대해 존중의 기준이\n" +
"대체로 높은 편이에요. 함께 생활하는\n" +
"룸메이트에 대해 미리 살펴보고 배려한다면\n" +
"더 편안한 공동생활이 이루어질 수 있을 거예요.",
typeRulesTitle = "오각이와 함께 정하면 좋은 Rule!",
typeRules = listOf(
"미사용 전자제품 코드 뽑아두기",
"외출 시 가스벨브,전등 확인하기",
),
good = ResultData.Homie(
typeName = "동글이",
typeImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png",
),
bad = ResultData.Homie(
typeName = "사각이",
typeImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png",
),
)
)
val resultData get() = _resultData
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,52 @@
package com.hous.hous_aos.ui.profile

import android.os.Bundle
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
import com.hous.hous_aos.R
import com.hous.hous_aos.databinding.ActivityTendencyResultBinding
import com.hous.hous_aos.util.setDrawable

class TendencyResultActivity : AppCompatActivity() {
private lateinit var binding: ActivityTendencyResultBinding
val viewModel: ResultViewModel by viewModels()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_tendency_result)
setContentView(binding.root)
init()
}

private fun init() {
binding.vm = viewModel
binding.lifecycleOwner = this

binding.tvEnd.setOnClickListener {
finish()
}

viewModel.resultData.observe(this) { data ->
if (data.good.typeName == "동글이") {
binding.tvGoodName.text = "행복한 동글이"
binding.clGood.backgroundTintList = this.getColorStateList(R.color.hous_yellow_bg)
}
if (data.bad.typeName == "사각이") {
binding.tvBadName.text = "불행한 사각이"
binding.clBad.backgroundTintList = this.getColorStateList(R.color.hous_blue_bg)
}
if (data.typeColor == "GREEN") {
binding.tvComment.setTextColor(ContextCompat.getColor(this, R.color.hous_green))
binding.tvRulesTitle.setTextColor(ContextCompat.getColor(this, R.color.hous_green))
binding.tvRulesTitle.backgroundTintList =
this.getColorStateList(R.color.hous_green_bg)
binding.clComment.backgroundTintList = this.getColorStateList(R.color.hous_green_bg)
binding.clRules.backgroundTintList = this.getColorStateList(R.color.hous_green_bg)
binding.ivShape1.setDrawable(R.drawable.ic_hexagon)
binding.ivShape2.setDrawable(R.drawable.ic_hexagon)
}
}
}
}
30 changes: 15 additions & 15 deletions app/src/main/java/com/hous/hous_aos/ui/profile/TendencyViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,119 +72,119 @@ data class TestUiState(
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 2,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 3,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 4,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 5,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 6,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 7,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 8,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 9,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 10,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 11,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 12,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 13,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 14,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
),
TypeTest(
_id = "",
testNum = 15,
question = "",
questionType = "",
answers = listOf("test1", "test2", "test3"),
questionImg = ""
questionImg = "https://team-hous.s3.ap-northeast-2.amazonaws.com/Type/test/type_test_1.png"
)
),
val answerHolder: List<Int> = listOf(0, 0, 0, 0, 0)
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/hous/hous_aos/util/BindingAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.annotation.Nullable
import androidx.cardview.widget.CardView
import androidx.core.view.isVisible
import androidx.databinding.BindingAdapter
import coil.load
import com.bumptech.glide.Glide

@BindingAdapter("app:visibility")
Expand Down Expand Up @@ -42,3 +43,9 @@ fun ImageView.setImage(imgUrl: String?) {
.into(this)
}
}

@BindingAdapter("setDrawable")
fun ImageView.showImg(drawable: String) {
load(drawable)
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/hous_blue_bg" />
<corners android:radius="15dp" />

</shape>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/hous_blue_bg" />
<corners android:radius="21dp" />

</shape>
7 changes: 0 additions & 7 deletions app/src/main/res/drawable/shape_green_bg_fill_15_rect.xml

This file was deleted.

7 changes: 0 additions & 7 deletions app/src/main/res/drawable/shape_green_bg_fill_21_rect.xml

This file was deleted.

7 changes: 0 additions & 7 deletions app/src/main/res/drawable/shape_purple_bg_fill_15_rect.xml

This file was deleted.

7 changes: 0 additions & 7 deletions app/src/main/res/drawable/shape_purple_bg_fill_21_rect.xml

This file was deleted.

3 changes: 1 addition & 2 deletions app/src/main/res/drawable/shape_red_bg_fill_15_rect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/hous_red_bg" />
<corners
android:radius="15dp" />
<corners android:radius="15dp" />
</shape>
7 changes: 0 additions & 7 deletions app/src/main/res/drawable/shape_red_bg_fill_21_rect.xml

This file was deleted.

7 changes: 0 additions & 7 deletions app/src/main/res/drawable/shape_yellow_bg_fill_15_rect.xml

This file was deleted.

7 changes: 0 additions & 7 deletions app/src/main/res/drawable/shape_yellow_bg_fill_21_rect.xml

This file was deleted.

Loading

0 comments on commit 5ae7853

Please sign in to comment.