Skip to content

Commit

Permalink
Merge pull request #1227 from joreilly/compose_desktop
Browse files Browse the repository at this point in the history
Compose cleanup + venue info in compose for desktop client
  • Loading branch information
joreilly authored Mar 31, 2024
2 parents 03bee39 + 7461aa1 commit d4400ef
Show file tree
Hide file tree
Showing 36 changed files with 186 additions and 663 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import androidx.compose.material3.TabRow
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.res.stringResource
import dev.johnoreilly.confetti.R
import dev.johnoreilly.confetti.decompose.DateSessionsMap
import dev.johnoreilly.confetti.sessions.SessionItemView
import dev.johnoreilly.confetti.ui.LoadingView
Expand Down Expand Up @@ -71,7 +73,7 @@ private fun BookmarksContent(
) {
Column {
val pagerState = rememberPagerState(initialPage = 1) {
BookmarksTab.values().size
BookmarksTab.entries.size
}

BookmarksTabRow(pagerState = pagerState)
Expand All @@ -97,7 +99,7 @@ private enum class BookmarksTab(val title: String) {
@Composable
private fun BookmarksTabRow(pagerState: PagerState) {
TabRow(selectedTabIndex = pagerState.currentPage) {
for ((index, tab) in BookmarksTab.values().withIndex()) {
for ((index, tab) in BookmarksTab.entries.withIndex()) {
val tabScope = rememberCoroutineScope()

ConfettiTab(
Expand Down Expand Up @@ -132,7 +134,7 @@ private fun BookmarksHorizontalPager(
}

if (displayedSessions.isEmpty()) {
EmptyView()
EmptyView(stringResource(id = R.string.no_bookmarks))
} else {
LazyColumn(
contentPadding = WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.ShapeDefaults
Expand All @@ -39,7 +38,6 @@ import dev.johnoreilly.confetti.ui.ErrorView
import dev.johnoreilly.confetti.ui.HomeScaffold
import dev.johnoreilly.confetti.ui.LoadingView

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun RecommendationsRoute(
component: RecommendationsComponent,
Expand Down Expand Up @@ -118,9 +116,9 @@ fun RecommendationsView(
session = session,
sessionSelected = navigateToSession,
isBookmarked = false, //bookmarks.contains(session.id),
addBookmark = { },
removeBookmark = { },
onNavigateToSignIn = { },
addBookmark = addBookmark,
removeBookmark = removeBookmark,
onNavigateToSignIn = {},
isLoggedIn = false,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.net.Uri
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Share
import androidx.compose.material3.CenterAlignedTopAppBar
Expand Down Expand Up @@ -100,7 +101,7 @@ fun SessionDetailView(
title = {},
navigationIcon = {
IconButton(onClick = { popBack() }) {
Icon(Icons.Filled.ArrowBack, contentDescription = "Back")
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
}
},
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.foundation.selection.toggleable
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.Checkbox
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
Expand All @@ -30,7 +27,7 @@ import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -111,7 +108,7 @@ fun SettingsScreen(
.clipToBounds()
.padding(it)
) {
Divider(Modifier.padding(top = 8.dp))
HorizontalDivider(Modifier.padding(top = 8.dp))

LazyColumn(modifier = Modifier.weight(1f)) {
item {
Expand Down Expand Up @@ -164,7 +161,7 @@ fun SettingsScreen(

HorizontalDivider()

var developerModeCount by remember { mutableStateOf(0) }
var developerModeCount by remember { mutableIntStateOf(0) }
Box(modifier = Modifier.run {
if (developerSettings == null) {
clickable {
Expand Down Expand Up @@ -307,53 +304,4 @@ fun SettingsDialogThemeChooserRow(
}
}

@Composable
fun CheckboxWithLabel(
text: String,
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
) {
Row(
Modifier
.fillMaxWidth()
.toggleable(
value = checked,
onValueChange = { onCheckedChange(!checked) },
role = Role.Checkbox
)
.padding(horizontal = 16.dp),
verticalAlignment = Alignment.CenterVertically
) {
Checkbox(
checked = checked,
onCheckedChange = null
)
Text(
text = text,
style = MaterialTheme.typography.bodyLarge,
modifier = Modifier.padding(start = 16.dp)
)
}
}


@Composable
private fun TextLink(text: String, url: String) {
val launchResourceIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
val context = LocalContext.current

Text(
text = text,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
modifier = Modifier
.padding(vertical = 8.dp)
.clickable {
runCatching {
startActivity(context, launchResourceIntent, null)
}.getOrElse { error ->
error.printStackTrace()
}
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import dev.johnoreilly.confetti.UserEditableSettings
import dev.johnoreilly.confetti.auth.Authentication
import dev.johnoreilly.confetti.decompose.SettingsComponent
import dev.johnoreilly.confetti.decompose.coroutineScope
import dev.johnoreilly.confetti.wear.WearSettingsSync
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
Expand All @@ -36,8 +35,8 @@ class DefaultSettingsComponent(
if (!it) {
flowOf(null)
} else {
authentication.currentUser.map {
DeveloperSettings(token = it?.token(false))
authentication.currentUser.map { user ->
DeveloperSettings(token = user?.token(false))
}
}
}.stateIn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.selection.SelectionContainer
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.material.icons.filled.Event
import androidx.compose.material3.CenterAlignedTopAppBar
Expand Down Expand Up @@ -90,7 +91,7 @@ fun SpeakerDetailsView(
},
navigationIcon = {
IconButton(onClick = { popBack() }) {
Icon(Icons.Filled.ArrowBack, contentDescription = "Back")
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
}
},
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.johnoreilly.confetti.speakers

import SpeakerGridView
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
Expand Down Expand Up @@ -38,6 +37,7 @@ import dev.johnoreilly.confetti.fragment.SpeakerDetails
import dev.johnoreilly.confetti.ui.ErrorView
import dev.johnoreilly.confetti.ui.HomeScaffold
import dev.johnoreilly.confetti.ui.LoadingView
import dev.johnoreilly.confetti.ui.SpeakerGridView
import dev.johnoreilly.confetti.ui.isExpanded

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package dev.johnoreilly.confetti.ui

import androidx.compose.material3.windowsizeclass.WindowSizeClass
import androidx.compose.runtime.Composable
import com.arkivanov.decompose.ExperimentalDecomposeApi
import com.arkivanov.decompose.FaultyDecomposeApi
import com.arkivanov.decompose.extensions.compose.jetpack.stack.Children
import com.arkivanov.decompose.extensions.compose.jetpack.stack.animation.fade
import com.arkivanov.decompose.extensions.compose.jetpack.stack.animation.isFront
Expand All @@ -16,6 +18,7 @@ import dev.johnoreilly.confetti.sessiondetails.SessionDetailsRoute
import dev.johnoreilly.confetti.settings.SettingsRoute
import dev.johnoreilly.confetti.speakerdetails.SpeakerDetailsRoute

@OptIn(ExperimentalDecomposeApi::class, FaultyDecomposeApi::class)
@Composable
fun ConferenceRoute(
component: ConferenceComponent,
Expand Down
21 changes: 0 additions & 21 deletions androidApp/src/main/java/dev/johnoreilly/confetti/ui/Gradient.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import androidx.compose.material.icons.outlined.CalendarMonth
import androidx.compose.material.icons.outlined.Person
import androidx.compose.material.icons.outlined.Place
import androidx.compose.material.icons.outlined.Search
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import dev.johnoreilly.confetti.ui.component.BackgroundTheme
import dev.johnoreilly.confetti.ui.component.LocalBackgroundTheme

Expand Down
Loading

0 comments on commit d4400ef

Please sign in to comment.