diff --git a/MykSuite/src/main/java/com/infomaniak/lib/myksuite/ui/views/BaseMyKSuiteChipView.kt b/MykSuite/src/main/java/com/infomaniak/lib/myksuite/ui/views/BaseMyKSuiteChipView.kt new file mode 100644 index 00000000..5de2d421 --- /dev/null +++ b/MykSuite/src/main/java/com/infomaniak/lib/myksuite/ui/views/BaseMyKSuiteChipView.kt @@ -0,0 +1,43 @@ +/* + * Infomaniak Core - Android + * Copyright (C) 2025 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.infomaniak.lib.myksuite.ui.views + +import android.content.Context +import android.util.AttributeSet +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.AbstractComposeView + +abstract class BaseMyKSuiteChipView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, +) : AbstractComposeView(context, attrs, defStyleAttr) { + + protected var onClick: OnClickListener? = null + protected abstract val chipContent: @Composable () -> Unit + + @Composable + override fun Content() { + chipContent() + } + + override fun setOnClickListener(listerner: OnClickListener?) { + super.setOnClickListener(listerner) + onClick = listerner + } +} diff --git a/MykSuite/src/main/java/com/infomaniak/lib/myksuite/ui/views/MyKSuiteChipView.kt b/MykSuite/src/main/java/com/infomaniak/lib/myksuite/ui/views/MyKSuiteChipView.kt new file mode 100644 index 00000000..ddcbcfb0 --- /dev/null +++ b/MykSuite/src/main/java/com/infomaniak/lib/myksuite/ui/views/MyKSuiteChipView.kt @@ -0,0 +1,32 @@ +/* + * Infomaniak Core - Android + * Copyright (C) 2025 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.infomaniak.lib.myksuite.ui.views + +import android.content.Context +import android.util.AttributeSet +import androidx.compose.runtime.Composable +import com.infomaniak.lib.myksuite.ui.components.MyKSuiteChip + +class MyKSuiteChipView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, +) : BaseMyKSuiteChipView(context, attrs, defStyleAttr) { + + override val chipContent = @Composable { MyKSuiteChip { onClick?.onClick(this) } } +} diff --git a/MykSuite/src/main/java/com/infomaniak/lib/myksuite/ui/views/MyKSuitePlusChipView.kt b/MykSuite/src/main/java/com/infomaniak/lib/myksuite/ui/views/MyKSuitePlusChipView.kt new file mode 100644 index 00000000..b030b730 --- /dev/null +++ b/MykSuite/src/main/java/com/infomaniak/lib/myksuite/ui/views/MyKSuitePlusChipView.kt @@ -0,0 +1,32 @@ +/* + * Infomaniak Core - Android + * Copyright (C) 2025 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.infomaniak.lib.myksuite.ui.views + +import android.content.Context +import android.util.AttributeSet +import androidx.compose.runtime.Composable +import com.infomaniak.lib.myksuite.ui.components.MyKSuitePlusChip + +class MyKSuitePlusChipView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, +) : BaseMyKSuiteChipView(context, attrs, defStyleAttr) { + + override val chipContent = @Composable { MyKSuitePlusChip { onClick?.onClick(this) } } +}