From 6f72eab44960f7ece38b87945d722af4ba253b35 Mon Sep 17 00:00:00 2001 From: Breens Robert <72180010+Breens-Mbaka@users.noreply.github.com> Date: Sat, 24 Aug 2024 09:12:22 +0300 Subject: [PATCH] Revert "Enable compose build features to fix Previews" --- BeeTablesCompose/build.gradle.kts | 3 - app/build.gradle.kts | 4 - .../breens/beetablescompose/MainActivity.kt | 400 +++++++++--------- 3 files changed, 193 insertions(+), 214 deletions(-) diff --git a/BeeTablesCompose/build.gradle.kts b/BeeTablesCompose/build.gradle.kts index a5d91a0..387dfdd 100644 --- a/BeeTablesCompose/build.gradle.kts +++ b/BeeTablesCompose/build.gradle.kts @@ -52,9 +52,6 @@ android { excludes += "/META-INF/{AL2.0,LGPL2.1}" } } - buildFeatures { - compose = true - } } dependencies { diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c930a29..e4255b9 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -43,7 +43,6 @@ android { getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", ) - signingConfig = signingConfigs.getByName("debug") } } compileOptions { @@ -58,9 +57,6 @@ android { excludes += "/META-INF/{AL2.0,LGPL2.1}" } } - buildFeatures { - compose = true - } } dependencies { diff --git a/app/src/main/java/com/breens/beetablescompose/MainActivity.kt b/app/src/main/java/com/breens/beetablescompose/MainActivity.kt index 4ce8146..4cbdbbf 100644 --- a/app/src/main/java/com/breens/beetablescompose/MainActivity.kt +++ b/app/src/main/java/com/breens/beetablescompose/MainActivity.kt @@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn @@ -33,7 +32,6 @@ import androidx.compose.material3.Slider import androidx.compose.material3.Surface import androidx.compose.material3.Switch import androidx.compose.material3.Text -import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -42,7 +40,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.breens.beetablescompose.ui.theme.BeeTablesComposeTheme import com.breens.beetablescompose.utils.premierLeagueTeams @@ -53,232 +50,221 @@ class MainActivity : ComponentActivity() { super.onCreate(savedInstanceState) setContent { BeeTablesComposeTheme { - MainUi() - } - } - } -} + Surface( + color = MaterialTheme.colorScheme.background, + ) { + var disableVerticalDividers by remember { + mutableStateOf(false) + } + var horizontalDividerThickness by remember { + mutableStateOf(0.6f) + } -@Composable -fun MainUi(modifier: Modifier = Modifier) { - Surface( - color = MaterialTheme.colorScheme.background, - modifier = modifier.fillMaxSize(), - ) { - var disableVerticalDividers by remember { - mutableStateOf(false) - } - var horizontalDividerThickness by remember { - mutableStateOf(0.6f) - } + var enableHeaderTitles by remember { + mutableStateOf(false) + } - var enableHeaderTitles by remember { - mutableStateOf(false) - } + var centerContent by remember { + mutableStateOf(false) + } - var centerContent by remember { - mutableStateOf(false) - } + var centerTextAlignment by remember { + mutableStateOf(false) + } - var centerTextAlignment by remember { - mutableStateOf(false) - } + var increaseColumnWidth by remember { + mutableStateOf(null) + } - var increaseColumnWidth by remember { - mutableStateOf(null) - } - LazyColumn(contentPadding = PaddingValues(16.dp)) { - item { - BeeTablesCompose( - data = premierLeagueTeams, - enableTableHeaderTitles = enableHeaderTitles, - disableVerticalDividers = disableVerticalDividers, - dividerThickness = horizontalDividerThickness.dp, - columnToIndexIncreaseWidth = increaseColumnWidth?.minus(1), - headerTableTitles = titles, - headerTitlesBackGroundColor = Color(0XFFE9AB17), - tableRowColors = listOf( - MaterialTheme.colorScheme.surface, - MaterialTheme.colorScheme.surface, - ), - contentAlignment = if (centerContent) Alignment.Center else Alignment.CenterStart, - textAlign = if (centerTextAlignment) TextAlign.Center else TextAlign.Start, - ) - } + LazyColumn(contentPadding = PaddingValues(16.dp)) { + item { + BeeTablesCompose( + data = premierLeagueTeams, + enableTableHeaderTitles = enableHeaderTitles, + disableVerticalDividers = disableVerticalDividers, + dividerThickness = horizontalDividerThickness.dp, + columnToIndexIncreaseWidth = increaseColumnWidth?.minus(1), + headerTableTitles = titles, + headerTitlesBackGroundColor = Color(0XFFE9AB17), + tableRowColors = listOf( + MaterialTheme.colorScheme.surface, + MaterialTheme.colorScheme.surface, + ), + contentAlignment = if (centerContent) Alignment.Center else Alignment.CenterStart, + textAlign = if (centerTextAlignment) TextAlign.Center else TextAlign.Start, + ) - item { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Text( - text = "Enable Table Header Titles", - style = MaterialTheme.typography.bodyMedium, - ) - Switch( - checked = enableHeaderTitles, - onCheckedChange = { - enableHeaderTitles = it - }, - ) - } + Spacer(modifier = Modifier.padding(12.dp)) + } - Spacer(modifier = Modifier.padding(12.dp)) - } - item { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Text( - text = "Hide Vertical Divider", - style = MaterialTheme.typography.bodyMedium, - ) - Switch( - checked = disableVerticalDividers, - onCheckedChange = { - disableVerticalDividers = it - }, - ) - } + item { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = "Enable Table Header Titles", + style = MaterialTheme.typography.bodyMedium, + ) + Switch( + checked = enableHeaderTitles, + onCheckedChange = { + enableHeaderTitles = it + }, + ) + } - Spacer(modifier = Modifier.padding(8.dp)) - } + Spacer(modifier = Modifier.padding(12.dp)) + } + item { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = "Hide Vertical Divider", + style = MaterialTheme.typography.bodyMedium, + ) + Switch( + checked = disableVerticalDividers, + onCheckedChange = { + disableVerticalDividers = it + }, + ) + } - item { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Text( - text = "Divider Thickness", - style = MaterialTheme.typography.bodyMedium, - ) + Spacer(modifier = Modifier.padding(8.dp)) + } - Slider(value = horizontalDividerThickness, onValueChange = { - horizontalDividerThickness = it - }) - } - } + item { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = "Divider Thickness", + style = MaterialTheme.typography.bodyMedium, + ) - item { - Spacer(modifier = Modifier.padding(12.dp)) + Slider(value = horizontalDividerThickness, onValueChange = { + horizontalDividerThickness = it + }) + } + } - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Text( - text = "Center Content", - style = MaterialTheme.typography.bodyMedium, - ) - Switch( - checked = centerContent, - onCheckedChange = { - centerContent = it - }, - ) - } + item { + Spacer(modifier = Modifier.padding(12.dp)) - Spacer(modifier = Modifier.padding(12.dp)) - } + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = "Center Content", + style = MaterialTheme.typography.bodyMedium, + ) + Switch( + checked = centerContent, + onCheckedChange = { + centerContent = it + }, + ) + } - item { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Text( - text = "Text Alignment Center", - style = MaterialTheme.typography.bodyMedium, - ) - Switch( - checked = centerTextAlignment, - onCheckedChange = { - centerTextAlignment = it - }, - ) - } + Spacer(modifier = Modifier.padding(12.dp)) + } - Spacer(modifier = Modifier.padding(12.dp)) - } + item { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = "Text Alignment Center", + style = MaterialTheme.typography.bodyMedium, + ) + Switch( + checked = centerTextAlignment, + onCheckedChange = { + centerTextAlignment = it + }, + ) + } - item { - Column { - Text( - text = "The Column To Increase Width", - style = MaterialTheme.typography.bodyMedium, - ) - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(8.dp), - ) { - Text(text = "1", style = MaterialTheme.typography.bodySmall) - Checkbox( - checked = increaseColumnWidth == 1, - onCheckedChange = { - increaseColumnWidth = if (it) 1 else null - }, - ) - } + Spacer(modifier = Modifier.padding(12.dp)) + } - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(8.dp), - ) { - Text(text = "2", style = MaterialTheme.typography.bodySmall) - Checkbox( - checked = increaseColumnWidth == 2, - onCheckedChange = { - increaseColumnWidth = if (it) 2 else null - }, - ) - } + item { + Column { + Text( + text = "The Column To Increase Width", + style = MaterialTheme.typography.bodyMedium, + ) + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + Text(text = "1", style = MaterialTheme.typography.bodySmall) + Checkbox( + checked = increaseColumnWidth == 1, + onCheckedChange = { + increaseColumnWidth = if (it) 1 else null + }, + ) + } - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(8.dp), - ) { - Text(text = "3", style = MaterialTheme.typography.bodySmall) - Checkbox( - checked = increaseColumnWidth == 3, - onCheckedChange = { - increaseColumnWidth = if (it) 3 else null - }, - ) - } + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + Text(text = "2", style = MaterialTheme.typography.bodySmall) + Checkbox( + checked = increaseColumnWidth == 2, + onCheckedChange = { + increaseColumnWidth = if (it) 2 else null + }, + ) + } + + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + Text(text = "3", style = MaterialTheme.typography.bodySmall) + Checkbox( + checked = increaseColumnWidth == 3, + onCheckedChange = { + increaseColumnWidth = if (it) 3 else null + }, + ) + } - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(8.dp), - ) { - Text(text = "4", style = MaterialTheme.typography.bodySmall) - Checkbox( - checked = increaseColumnWidth == 4, - onCheckedChange = { - increaseColumnWidth = if (it) 4 else null - }, - ) + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + Text(text = "4", style = MaterialTheme.typography.bodySmall) + Checkbox( + checked = increaseColumnWidth == 4, + onCheckedChange = { + increaseColumnWidth = if (it) 4 else null + }, + ) + } + } + } } } } } } } - -@Preview -@Composable -private fun MainUiPreview() { - BeeTablesComposeTheme { - MainUi() - } -}