Skip to content

Commit

Permalink
Fix the scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
greenart7c3 committed Nov 18, 2024
1 parent 9faa09e commit edd424d
Show file tree
Hide file tree
Showing 21 changed files with 310 additions and 352 deletions.
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.ButtonDefaults
Expand Down Expand Up @@ -93,12 +91,18 @@ fun EditConfigurationScreen(
}

if (isLoading.value) {
CenterCircularProgressIndicator(modifier)
CenterCircularProgressIndicator(
modifier,
if (textFieldRelay.value.text.isNotBlank()) {
"Testing relay..."
} else {
null
},
)
} else {
Column(
modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
.fillMaxSize(),
) {
Text(stringResource(R.string.edit_configuration_description))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
Expand Down Expand Up @@ -119,8 +117,7 @@ fun EditPermission(
}

Column(
modifier = modifier
.verticalScroll(rememberScrollState()),
modifier = modifier,
) {
if (!applicationData.isConnected) {
Text(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.greenart7c3.nostrsigner.ui

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
Expand Down Expand Up @@ -38,6 +38,7 @@ import kotlinx.coroutines.launch
@Composable
fun IncomingRequestScreen(
modifier: Modifier,
paddingValues: PaddingValues,
intents: List<IntentData>,
packageName: String?,
applicationName: String?,
Expand Down Expand Up @@ -69,47 +70,45 @@ fun IncomingRequestScreen(
if (loading) {
CenterCircularProgressIndicator(modifier)
} else {
Box(
modifier,
) {
if (intents.isEmpty()) {
Column(
Modifier.fillMaxSize(),
Arrangement.Center,
Alignment.CenterHorizontally,
) {
Text(
stringResource(R.string.nothing_to_approve_yet),
fontWeight = FontWeight.Bold,
fontSize = 21.sp,
)
Spacer(Modifier.size(8.dp))
Text(
stringResource(R.string.why_not_explore_your_favorite_nostr_app_a_bit),
textAlign = TextAlign.Center,
)
}
} else if (intents.size == 1) {
SingleEventHomeScreen(
packageName,
applicationName,
intents.first(),
account,
database,
onRemoveIntentData,
) {
loading = it
}
} else {
MultiEventHomeScreen(
intents,
packageName,
account,
navController,
onRemoveIntentData,
) {
loading = it
}
if (intents.isEmpty()) {
Column(
modifier.fillMaxSize(),
Arrangement.Center,
Alignment.CenterHorizontally,
) {
Text(
stringResource(R.string.nothing_to_approve_yet),
fontWeight = FontWeight.Bold,
fontSize = 21.sp,
)
Spacer(Modifier.size(8.dp))
Text(
stringResource(R.string.why_not_explore_your_favorite_nostr_app_a_bit),
textAlign = TextAlign.Center,
)
}
} else if (intents.size == 1) {
SingleEventHomeScreen(
paddingValues,
packageName,
applicationName,
intents.first(),
account,
database,
onRemoveIntentData,
) {
loading = it
}
} else {
MultiEventHomeScreen(
paddingValues = paddingValues,
intents,
packageName,
account,
navController,
onRemoveIntentData,
) {
loading = it
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import androidx.appcompat.app.AppCompatDelegate
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.intl.Locale
import androidx.compose.ui.unit.dp
import androidx.core.os.LocaleListCompat
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.R
Expand Down Expand Up @@ -40,8 +38,7 @@ fun LanguageScreen(
) {
Column {
Box(
Modifier
.padding(8.dp),
Modifier,
) {
SettingsRow(
R.string.language,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fun MainPage(
state.animateScrollToPage(2)
}
},
text = stringResource(R.string.sign_policy),
text = stringResource(R.string.generate_a_new_key),
)
}
}
Expand Down
113 changes: 56 additions & 57 deletions app/src/main/java/com/greenart7c3/nostrsigner/ui/LogsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.greenart7c3.nostrsigner.ui

import androidx.compose.foundation.layout.Arrangement
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
Expand Down Expand Up @@ -31,72 +32,70 @@ import kotlinx.coroutines.launch

@Composable
fun LogsScreen(
paddingValues: PaddingValues,
account: Account,
modifier: Modifier = Modifier,
) {
val scope = rememberCoroutineScope()
Column(
modifier = modifier
val logsFlow = NostrSigner.getInstance().getDatabase(account.signer.keyPair.pubKey.toNpub()).applicationDao().getLogs()
val logs = logsFlow.collectAsStateWithLifecycle(initialValue = emptyList())

LazyColumn(
modifier = Modifier
.fillMaxSize(),
contentPadding = paddingValues,
) {
val logsFlow = NostrSigner.getInstance().getDatabase(account.signer.keyPair.pubKey.toNpub()).applicationDao().getLogs()
val logs = logsFlow.collectAsStateWithLifecycle(initialValue = emptyList())

LazyColumn(
Modifier.weight(1f),
) {
items(logs.value) { log ->
Row(
modifier = Modifier
.fillMaxSize()
.padding(vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
item {
AmberButton(
modifier = Modifier.padding(bottom = 8.dp),
onClick = {
scope.launch(Dispatchers.IO) {
NostrSigner.getInstance().getDatabase(account.signer.keyPair.pubKey.toNpub()).applicationDao().clearLogs()
}
},
text = stringResource(R.string.clear_logs),
)
}
items(logs.value) { log ->
Row(
modifier = Modifier
.fillMaxSize()
.padding(vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Column(
verticalArrangement = Arrangement.Center,
) {
Column(
verticalArrangement = Arrangement.Center,
) {
Text(
modifier = Modifier.padding(top = 16.dp),
text = TimeUtils.formatLongToCustomDateTimeWithSeconds(log.time),
fontSize = 14.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Text(
modifier = Modifier.padding(top = 4.dp),
text = log.url,
fontSize = 20.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Text(
modifier = Modifier.padding(top = 4.dp),
text = log.type,
fontSize = 20.sp,
)
Text(
modifier = Modifier.padding(top = 4.dp, bottom = 16.dp),
text = log.message,
fontSize = 20.sp,
)
Text(
modifier = Modifier.padding(top = 16.dp),
text = TimeUtils.formatLongToCustomDateTimeWithSeconds(log.time),
fontSize = 14.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Text(
modifier = Modifier.padding(top = 4.dp),
text = log.url,
fontSize = 20.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Text(
modifier = Modifier.padding(top = 4.dp),
text = log.type,
fontSize = 20.sp,
)
Text(
modifier = Modifier.padding(top = 4.dp, bottom = 16.dp),
text = log.message,
fontSize = 20.sp,
)

Spacer(Modifier.weight(1f))
HorizontalDivider(
color = MaterialTheme.colorScheme.primary,
)
}
Spacer(Modifier.weight(1f))
HorizontalDivider(
color = MaterialTheme.colorScheme.primary,
)
}
}
}

AmberButton(
modifier = Modifier.padding(top = 8.dp),
onClick = {
scope.launch(Dispatchers.IO) {
NostrSigner.getInstance().getDatabase(account.signer.keyPair.pubKey.toNpub()).applicationDao().clearLogs()
}
},
text = stringResource(R.string.clear_logs),
)
}
}
Loading

0 comments on commit edd424d

Please sign in to comment.