Skip to content

Commit

Permalink
[feature/#4] icon추가 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
papajj06 committed Jul 6, 2022
1 parent 75fd32a commit b783a97
Showing 3 changed files with 98 additions and 9 deletions.
26 changes: 26 additions & 0 deletions app/src/main/java/com/teampome/pome/FriendPageIconFactory.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.teampome.pome

import android.content.Context
import androidx.lifecycle.LifecycleOwner
import com.skydoves.balloon.ArrowOrientation
import com.skydoves.balloon.Balloon
import com.skydoves.balloon.BalloonAnimation

class FriendPageIconFactory : Balloon.Factory() {
override fun create(context: Context, lifecycle: LifecycleOwner?): Balloon {
return Balloon.Builder(context)
.setWidthRatio(0.8f)
.setHeight(50)
.setWidth(400)
.setIsVisibleArrow(false)
.setArrowOrientation(ArrowOrientation.LEFT)
.setCornerRadius(8f)
.setAlpha(0.9f)
.setTextIsHtml(true)
.setLayout(R.layout.item_icon_list)
.setBackgroundColorResource(R.color.white)
.setBalloonAnimation(BalloonAnimation.CIRCULAR)
.setLifecycleOwner(lifecycle)
.build()
}
}
25 changes: 23 additions & 2 deletions app/src/main/java/com/teampome/pome/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -2,12 +2,33 @@ package com.teampome.pome

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.ImageView
import com.skydoves.balloon.*
import com.teampome.pome.databinding.ActivityMainBinding
import timber.log.Timber

class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
private val iconBalloon by balloon<FriendPageIconFactory>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
Timber.d("example")
iconClickEvent()

}

private fun iconClickEvent() {
binding.ivIcon.setOnClickListener {
iconBalloon.showAlignBottom(it)
}
val button: ImageView =
iconBalloon.getContentView().findViewById(R.id.iv_first)
button.setOnClickListener {
binding.ivIcon.setImageResource(R.drawable.ic_what_mint)
iconBalloon.dismiss()
}

}
}
}
56 changes: 49 additions & 7 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -6,13 +6,55 @@
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_marginHorizontal="20dp"
android:layout_marginTop="30dp"
android:background="@drawable/background"
app:layout_constraintTop_toTopOf="parent">


<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="이름"
android:textSize="15sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:id="@+id/tv_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="50,000원"
android:textSize="20sp"
android:layout_marginTop="15dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_name"
/>

<TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="출근길에는 커피가 필수지"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_price"
android:layout_marginTop="15dp"
/>
<ImageView
android:id="@+id/iv_icon"
android:layout_width="30dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="1"
android:src="@drawable/ic_launcher_background"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_content"
android:layout_marginTop="15dp"
/>

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit b783a97

Please sign in to comment.