Skip to content

Commit

Permalink
feat(MyKSuite): Wrap the chips in xml custom View
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Feb 4, 2025
1 parent bbb6694 commit 39677b3
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
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
}
}
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
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) } }
}
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
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) } }
}

0 comments on commit 39677b3

Please sign in to comment.