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