package com.isidroid.ui.maps.map_algorithm

import android.content.Context
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.graphics.RectF
import android.graphics.Typeface
import android.graphics.drawable.Drawable
import android.text.TextPaint
import androidx.core.content.ContextCompat
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.model.BitmapDescriptor
import com.google.android.gms.maps.model.BitmapDescriptorFactory
import com.google.android.gms.maps.model.MarkerOptions
import com.google.maps.android.clustering.Cluster
import com.google.maps.android.clustering.ClusterItem
import com.google.maps.android.clustering.ClusterManager
import com.google.maps.android.clustering.view.DefaultClusterRenderer
import com.isidroid.ui.maps.R
import com.isidroid.ui.maps.ext.cluster
import com.isidroid.ui.maps.ext.fromSvg
import com.isidroid.ui.maps.model.MyClusterItem
import timber.log.Timber

//class GoogleClusterRenderer(
//    private val context: Context,
//    m: GoogleMap,
//    mgr: ClusterManager<MyClusterItem>,
//) : DefaultClusterRenderer<MyClusterItem>(context, m, mgr) {
//
//    private val icons = arrayOf(
//        fromSvg(context, R.drawable.ic_map_marker_check),
//        fromSvg(context, R.drawable.ic_map_marker),
//        fromSvg(context, R.drawable.ic_map_multiple_markers),
//        fromSvg(context, R.drawable.ic_map_marker_offline)
//    )
//
//
//    override fun onBeforeClusterItemRendered(item: MyClusterItem?, markerOptions: MarkerOptions?) {
//        item ?: return
//        val icon = when {
//            else ->  cluster(context, "1", Color.RED)
//        }
//
//        Timber.i("sdfsdfsdf onBeforeClusterItemRendered")
//
//        markerOptions
//            ?.position(item.position)
//            ?.title(item.title)
////            ?.snippet(item.office.address)
//            ?.icon(icon)
//    }
//
//    override fun onBeforeClusterRendered(
//        cluster: Cluster<MyClusterItem>?,
//        markerOptions: MarkerOptions?
//    ) {
////        val ouid = Preferences.prefs.getString(Constants.Prefs.OFFICE_DEFAULT, null)
////        val hasCurrent = cluster?.items?.any { it.office.uid == ouid } == true
////        val ovalColor = if (hasCurrent) R.color.map_selected_office_marker else R.color.map_cluster_marker
////
////        val number = cluster?.items?.size ?: 0
//        markerOptions?.icon(cluster(context, "1", Color.RED))
//
//        Timber.i("sdfsdfsdf onBeforeClusterRendered")
//    }
//}