Skip to content

Commit

Permalink
Add back buttn to the feed screen
Browse files Browse the repository at this point in the history
  • Loading branch information
greenart7c3 committed Jan 1, 2025
1 parent 5df0ea1 commit 2ee2131
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
66 changes: 66 additions & 0 deletions app/src/main/java/com/greenart7c3/citrine/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,26 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.compose.setContent
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
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.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.BottomAppBar
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ElevatedButton
Expand All @@ -36,6 +43,7 @@ import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand All @@ -45,12 +53,16 @@ import androidx.compose.runtime.rememberCoroutineScope
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.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.compose.LocalLifecycleOwner
Expand Down Expand Up @@ -85,6 +97,48 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun IconRow(
center: Boolean = false,
title: String,
icon: ImageVector,
tint: Color,
onClick: () -> Unit,
onLongClick: (() -> Unit)? = null,
) {
Row(
modifier = Modifier
.fillMaxWidth()
.combinedClickable(
onClick = onClick,
onLongClick = onLongClick,
),
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 15.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = if (center) Arrangement.Center else Arrangement.Start,
) {
Icon(
icon,
null,
modifier = Modifier.size(22.dp),
tint = tint,
)
Text(
modifier = Modifier.padding(start = 16.dp),
text = title,
fontSize = 18.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
}
}

class MainActivity : ComponentActivity() {
private val storageHelper = SimpleStorageHelper(this@MainActivity)

Expand Down Expand Up @@ -126,6 +180,18 @@ class MainActivity : ComponentActivity() {
)
}
}
} else if (destinationRoute.startsWith("Feed")) {
BottomAppBar {
IconRow(
center = true,
title = stringResource(R.string.go_back),
icon = Icons.AutoMirrored.Filled.ArrowBack,
onClick = {
navController.navigateUp()
},
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
}
},
topBar = {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
<string name="show_events">Show events</string>
<string name="copy_address">Copy Address</string>
<string name="relay_running_at_ws">Relay running at ws://%1$s:%2$s</string>
<string name="go_back">Go back</string>

</resources>

0 comments on commit 2ee2131

Please sign in to comment.