package com.adealink.weparty.commonui.widget

import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.text.style.ReplacementSpan

class SpaceSpan(private val width: Int, color: Int = Color.TRANSPARENT) : ReplacementSpan() {
    private val paint = Paint()
    override fun getSize(
        paint: Paint, text: CharSequence,
        start: Int,
        end: Int,
        fm: Paint.FontMetricsInt?
    ): Int {
        return width
    }

    override fun draw(
        canvas: Canvas, text: CharSequence,
        start: Int,
        end: Int,
        x: Float, top: Int, y: Int, bottom: Int,
        paint: Paint
    ) {
        canvas.drawRect(x, top.toFloat(), x + width, bottom.toFloat(), this.paint)
    }

    init {
        paint.color = color
        paint.style = Paint.Style.FILL
    }
}
