Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Onclick on cells" #23

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ inline fun <reified T : Any> BeeTablesCompose(
textAlign: TextAlign = TextAlign.Center,
tablePadding: Dp = 0.dp,
columnToIndexIncreaseWidth: Int? = null,
crossinline onRowClick: (Int) -> Unit = {},
) {
OutlinedCard(
elevation = CardDefaults.cardElevation(defaultElevation = tableElevation),
Expand Down Expand Up @@ -143,7 +142,6 @@ inline fun <reified T : Any> BeeTablesCompose(
textAlign = textAlign,
tablePadding = tablePadding,
columnToIndexIncreaseWidth = columnToIndexIncreaseWidth,
onRowClick = { onRowClick(it) },
)
} else {
TableRowComponent(
Expand All @@ -156,8 +154,6 @@ inline fun <reified T : Any> BeeTablesCompose(
textAlign = textAlign,
tablePadding = tablePadding,
columnToIndexIncreaseWidth = columnToIndexIncreaseWidth,
onRowClick = { onRowClick(it) },

)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
*/
package com.breens.beetablescompose.components

import android.widget.Toast
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -31,7 +29,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
Expand All @@ -52,7 +49,6 @@ fun TableRowComponent(
tablePadding: Dp,
columnToIndexIncreaseWidth: Int?,
dividerThickness: Dp,
onRowClick: (Int) -> Unit = {},
) {
Row(
Modifier
Expand All @@ -68,8 +64,7 @@ fun TableRowComponent(
.border(
width = dividerThickness,
color = rowBorderColor,
)
.clickable { onRowClick(index) },
),
contentAlignment = contentAlignment,
) {
Text(
Expand All @@ -90,13 +85,11 @@ fun TableRowComponent(
@Composable
@Preview(showBackground = true)
fun TableRowComponentPreview() {
val context = LocalContext.current
val titles = listOf("Man Utd", "26", "7", "95")

TableRowComponent(
data = titles,
rowBorderColor = lightGray(),
onRowClick = { Toast.makeText(context, "Row ...${titles[it]},", Toast.LENGTH_SHORT).show() },
rowTextStyle = MaterialTheme.typography.bodySmall,
rowBackGroundColor = lightColor(),
contentAlignment = Alignment.Center,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.breens.beetablescompose.components

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -50,7 +49,6 @@ fun TableRowComponentWithoutDividers(
textAlign: TextAlign,
tablePadding: Dp,
columnToIndexIncreaseWidth: Int?,
onRowClick: (Int) -> Unit = {},
) {
Column(
modifier = Modifier.padding(horizontal = tablePadding),
Expand All @@ -64,10 +62,8 @@ fun TableRowComponentWithoutDividers(
val weight = if (index == columnToIndexIncreaseWidth) 8f else 2f
Box(
modifier = Modifier
.weight(weight)
.clickable { onRowClick(index) },
.weight(weight),
contentAlignment = contentAlignment,

) {
Text(
text = title,
Expand Down
7 changes: 0 additions & 7 deletions app/src/main/java/com/breens/beetablescompose/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.breens.beetablescompose

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -40,7 +39,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.breens.beetablescompose.ui.theme.BeeTablesComposeTheme
Expand All @@ -51,7 +49,6 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val context = LocalContext.current
BeeTablesComposeTheme {
Surface(
color = MaterialTheme.colorScheme.background,
Expand Down Expand Up @@ -95,10 +92,6 @@ class MainActivity : ComponentActivity() {
),
contentAlignment = if (centerContent) Alignment.Center else Alignment.CenterStart,
textAlign = if (centerTextAlignment) TextAlign.Center else TextAlign.Start,

onRowClick = { index ->
Log.i("TAG", "AM click at position ${ premierLeagueTeams[index]}")
},
)

Spacer(modifier = Modifier.padding(12.dp))
Expand Down
Loading