fix: correct indentation and formatting in PreferencesManager and ListDetailScreen for improved readability
This commit is contained in:
+6
-3
@@ -166,7 +166,8 @@ fun ListDetailScreen(
|
||||
val savedAlign = prefs.getColumnAlignments(listId)
|
||||
stableFields.forEach { field ->
|
||||
val raw = (field.alignment.ifBlank { savedAlign[field.id] ?: "start" }).lowercase()
|
||||
columnAlignments[field.id] = when (raw) {
|
||||
columnAlignments[field.id] =
|
||||
when (raw) {
|
||||
"center" -> "center"
|
||||
"end", "right" -> "end"
|
||||
else -> "start"
|
||||
@@ -577,7 +578,8 @@ fun ListDetailScreen(
|
||||
|
||||
// Items list below the fixed header
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
modifier =
|
||||
Modifier
|
||||
.fillMaxSize(),
|
||||
state = listState,
|
||||
contentPadding = PaddingValues(0.dp),
|
||||
@@ -613,7 +615,8 @@ fun ListDetailScreen(
|
||||
// Refresh alignments from current fields (DB-backed)
|
||||
stableFields.forEach { field ->
|
||||
val a = field.alignment.lowercase().ifBlank { columnAlignments[field.id] ?: "start" }
|
||||
columnAlignments[field.id] = when (a) {
|
||||
columnAlignments[field.id] =
|
||||
when (a) {
|
||||
"center" -> "center"
|
||||
"end", "right" -> "end"
|
||||
else -> "start"
|
||||
|
||||
+14
-6
@@ -1,10 +1,10 @@
|
||||
package com.collabtable.app.ui.screens
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.ProcessLifecycleOwner
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.room.withTransaction
|
||||
import com.collabtable.app.data.database.CollabTableDatabase
|
||||
import com.collabtable.app.data.model.CollabList
|
||||
@@ -51,6 +51,7 @@ class ListDetailViewModel(
|
||||
var hasList = false
|
||||
var hasFields = false
|
||||
var hasItems = false
|
||||
|
||||
fun maybeLoaded() {
|
||||
if (hasFields && hasItems) {
|
||||
_isLoading.value = false
|
||||
@@ -128,10 +129,13 @@ class ListDetailViewModel(
|
||||
}
|
||||
|
||||
private fun maybeNotifyListContentUpdated() {
|
||||
val prefs = com.collabtable.app.data.preferences.PreferencesManager.getInstance(context)
|
||||
val prefs =
|
||||
com.collabtable.app.data.preferences.PreferencesManager
|
||||
.getInstance(context)
|
||||
if (prefs.notifyListContentUpdated.value && !isInForeground()) {
|
||||
val name = _list.value?.name ?: "Table"
|
||||
com.collabtable.app.notifications.NotificationHelper.showListContentUpdated(context, listId, name)
|
||||
com.collabtable.app.notifications.NotificationHelper
|
||||
.showListContentUpdated(context, listId, name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,12 +258,16 @@ class ListDetailViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
fun updateFieldAlignment(fieldId: String, alignment: String) {
|
||||
fun updateFieldAlignment(
|
||||
fieldId: String,
|
||||
alignment: String,
|
||||
) {
|
||||
viewModelScope.launch {
|
||||
val field = database.fieldDao().getFieldById(fieldId)
|
||||
if (field != null) {
|
||||
val ts = System.currentTimeMillis()
|
||||
val normalized = when (alignment.lowercase()) {
|
||||
val normalized =
|
||||
when (alignment.lowercase()) {
|
||||
"center" -> "center"
|
||||
"end", "right" -> "end"
|
||||
else -> "start"
|
||||
|
||||
@@ -4,6 +4,9 @@ package com.collabtable.app.ui.screens
|
||||
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@@ -50,10 +53,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.core.content.ContextCompat
|
||||
import android.os.Build
|
||||
import com.collabtable.app.R
|
||||
import com.collabtable.app.data.database.CollabTableDatabase
|
||||
import com.collabtable.app.data.model.CollabList
|
||||
@@ -117,7 +117,10 @@ fun ListsScreen(
|
||||
prefsLocal.setNotifyListAddedEnabled(granted)
|
||||
prefsLocal.setNotifyListEditedEnabled(granted)
|
||||
prefsLocal.setNotifyListRemovedEnabled(granted)
|
||||
try { prefsLocal.setNotifyListContentUpdatedEnabled(granted) } catch (_: Throwable) {}
|
||||
try {
|
||||
prefsLocal.setNotifyListContentUpdatedEnabled(granted)
|
||||
} catch (_: Throwable) {
|
||||
}
|
||||
}
|
||||
|
||||
ConnectionStatusAction(
|
||||
|
||||
+11
-4
@@ -1,8 +1,8 @@
|
||||
package com.collabtable.app.ui.screens
|
||||
|
||||
import android.os.Build
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
@@ -46,8 +46,8 @@ import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||
import androidx.compose.ui.text.input.VisualTransformation
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.collabtable.app.data.preferences.PreferencesManager
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.collabtable.app.data.preferences.PreferencesManager
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -64,6 +64,7 @@ fun ServerSetupScreen(onSetupComplete: () -> Unit) {
|
||||
val validationError by viewModel.validationError.collectAsState()
|
||||
|
||||
var completed by remember { mutableStateOf(false) }
|
||||
|
||||
fun finishOnce() {
|
||||
if (!completed) {
|
||||
completed = true
|
||||
@@ -99,7 +100,10 @@ fun ServerSetupScreen(onSetupComplete: () -> Unit) {
|
||||
preferencesManager.setNotifyListAddedEnabled(true)
|
||||
preferencesManager.setNotifyListEditedEnabled(true)
|
||||
preferencesManager.setNotifyListRemovedEnabled(true)
|
||||
try { preferencesManager.setNotifyListContentUpdatedEnabled(true) } catch (_: Throwable) {}
|
||||
try {
|
||||
preferencesManager.setNotifyListContentUpdatedEnabled(true)
|
||||
} catch (_: Throwable) {
|
||||
}
|
||||
finishOnce()
|
||||
} else {
|
||||
// Request permission; callback will complete
|
||||
@@ -109,7 +113,10 @@ fun ServerSetupScreen(onSetupComplete: () -> Unit) {
|
||||
preferencesManager.setNotifyListAddedEnabled(true)
|
||||
preferencesManager.setNotifyListEditedEnabled(true)
|
||||
preferencesManager.setNotifyListRemovedEnabled(true)
|
||||
try { preferencesManager.setNotifyListContentUpdatedEnabled(true) } catch (_: Throwable) {}
|
||||
try {
|
||||
preferencesManager.setNotifyListContentUpdatedEnabled(true)
|
||||
} catch (_: Throwable) {
|
||||
}
|
||||
finishOnce()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,6 @@ type Param = any;
|
||||
|
||||
type ExecResult = { changes: number };
|
||||
|
||||
type TxClient = {
|
||||
query: (text: string, params?: any[]) => Promise<QueryResult<any>>;
|
||||
};
|
||||
|
||||
interface DBAdapter {
|
||||
queryAll(sql: string, params?: Param[]): Promise<any[]>;
|
||||
@@ -66,7 +63,6 @@ class SqliteAdapter implements DBAdapter {
|
||||
fieldType TEXT NOT NULL,
|
||||
fieldOptions TEXT,
|
||||
alignment TEXT NOT NULL DEFAULT 'start',
|
||||
alignment TEXT NOT NULL DEFAULT 'start',
|
||||
listId TEXT NOT NULL,
|
||||
"order" INTEGER NOT NULL,
|
||||
createdAt INTEGER NOT NULL,
|
||||
@@ -222,8 +218,7 @@ class PostgresAdapter implements DBAdapter {
|
||||
private async runQuery(sql: string, params: Param[] = [], client?: PoolClient): Promise<QueryResult<any>> {
|
||||
// Replace backticks and convert ? to $1..$n
|
||||
const text = convertQMarksToPg(replaceQuotedIdentifiers(sql));
|
||||
const runner = client || this.pool;
|
||||
// @ts-ignore - Pool and PoolClient share query signature
|
||||
const runner: Pool | PoolClient = client || this.pool;
|
||||
return runner.query(text, params);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user