Skip to content

Commit

Permalink
Merge pull request #1186 from joreilly/ios_ui_updates
Browse files Browse the repository at this point in the history
iOS ui updates
  • Loading branch information
joreilly authored Mar 10, 2024
2 parents 861a694 + b9dc55d commit 4207353
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 60 deletions.
2 changes: 1 addition & 1 deletion iosApp/iosApp/ConferenceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct ConferenceView: View {
) { child in
switch child {
case let child as ConferenceComponentChild.Home: HomeView(child.component)
case let child as ConferenceComponentChild.SessionDetails: SessionDetailsView(child.component)
case let child as ConferenceComponentChild.SessionDetails: SessionDetailsView(child.component, component.conferenceThemeColor)
case let child as ConferenceComponentChild.SpeakerDetails: SpeakerDetailsView(child.component)
default: EmptyView()
}
Expand Down
56 changes: 16 additions & 40 deletions iosApp/iosApp/ConferencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,29 @@ struct ConferencesView: View {
}

var body: some View {
return NavigationView {
VStack {
switch uiState {
case let uiState as ConferencesComponentSuccess:
ConferencesByYearView(component: component, conferencesUiState: uiState)
case is ConferencesComponentError: ErrorView()
default: ProgressView()
VStack {
switch uiState {
case let uiState as ConferencesComponentSuccess:
ConferenceListContentViewShared(conferences: uiState.conferenceListByYear) { conference in
component.onConferenceClicked(conference: conference)
}
}.navigationBarTitle("Confetti", displayMode: .inline)
case is ConferencesComponentError: ErrorView()
default: ProgressView()
}
}
}
}

private struct ConferencesByYearView: View {
let component: ConferencesComponent
let conferencesUiState: ConferencesComponentSuccess

var body: some View {
VStack {
let conferencesByYear = conferencesUiState.conferenceListByYear
private struct ConferenceListContentViewShared: UIViewControllerRepresentable {
let conferences: [KotlinInt : [GetConferencesQuery.Conference]]
let onConferenceClick: (GetConferencesQuery.Conference) -> Void

func makeUIViewController(context: Context) -> UIViewController {
return SharedViewControllersKt.ConferenceListViewController(conferenceListByYear: conferences, onConferenceClick: onConferenceClick)
}

List {
ForEach(Array(conferencesByYear.keys).sorted { $0.intValue > $1.intValue }, id: \.self) { year in

Section(header: HStack {
Text(year.stringValue).font(.headline).bold()
}) {
let conferences = conferencesUiState.conferenceListByYear[year] ?? []
ForEach(conferences, id: \.self) { conference in
HStack {
Text(conference.name)
Spacer()
Text("\(conference.days[0])")
}
.background(
Rectangle()
.foregroundColor(.clear)
.contentShape(Rectangle())
)
.onTapGesture {
component.onConferenceClicked(conference: conference)
}
}
}
}
}
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
}
}

Expand Down
2 changes: 1 addition & 1 deletion iosApp/iosApp/MultiPaneView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct MultiPaneView: View {

let sessionDetailsChild = sessionDetails.child
if sessionDetailsChild != nil {
SessionDetailsView(sessionDetailsChild!.instance)
SessionDetailsView(sessionDetailsChild!.instance, "")
.frame(width: geometry.size.width * 0.7)
.transition(.opacity.animation(.easeInOut(duration: 0.25)))
.id(sessionDetailsChild!.configuration.hash)
Expand Down
7 changes: 6 additions & 1 deletion iosApp/iosApp/Sessions/SessionDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import ConfettiKit

struct SessionDetailsView: View {
private let component: SessionDetailsComponent
private let conferenceThemeColor: String?
@Environment(\.openURL) var openURL

@StateValue
private var uiState: SessionDetailsUiState

init(_ component: SessionDetailsComponent) {
init(_ component: SessionDetailsComponent, _ conferenceThemeColor: String?) {
self.component = component
self.conferenceThemeColor = conferenceThemeColor
_uiState = StateValue(component.uiState)
}

Expand All @@ -24,6 +26,7 @@ struct SessionDetailsView: View {
//SessionDetailsContentView(component: component, session: state.sessionDetails)
SessionDetailsContentViewShared(
session: state.sessionDetails,
conferenceThemeColor: conferenceThemeColor ?? "",
onSpeakerClick: { speakerId in
component.onSpeakerClicked(id: speakerId)
},
Expand All @@ -43,11 +46,13 @@ struct SessionDetailsView: View {
// This version is using Compose for iOS....
private struct SessionDetailsContentViewShared: UIViewControllerRepresentable {
let session: SessionDetails
let conferenceThemeColor: String
let onSpeakerClick: (String) -> Void
let onSocialLinkClicked: (String) -> Void

func makeUIViewController(context: Context) -> UIViewController {
return SharedViewControllersKt.SessionDetailsViewController(session: session,
conferenceThemeColor: conferenceThemeColor,
onSpeakerClick: onSpeakerClick, onSocialLinkClicked: onSocialLinkClicked)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ fun ConferenceListView(conferenceListByYear: Map<Int, List<GetConferencesQuery.C
}
}) {
LazyColumn(Modifier.padding(it)) {
conferenceListByYear.forEach { (year, conferenceList) ->
stickyHeader {
YearHeader(year.toString())
}
conferenceListByYear.keys.sortedDescending().forEach { year ->
val conferenceList = conferenceListByYear[year]
conferenceList?.let {
stickyHeader {
YearHeader(year.toString())
}

items(conferenceList) { conference ->
ConferenceCard(conference) { navigateToConference(conference) }
items(conferenceList) { conference ->
ConferenceCard(conference) { navigateToConference(conference) }
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.graphics.Color
import com.materialkolor.PaletteStyle
import com.materialkolor.rememberDynamicColorScheme
import com.russhwolf.settings.ExperimentalSettingsApi
import dev.johnoreilly.confetti.AppSettings
import org.koin.compose.koinInject

enum class DarkThemeConfig {
FOLLOW_SYSTEM, LIGHT, DARK
}

@OptIn(ExperimentalStdlibApi::class)
@OptIn(ExperimentalStdlibApi::class, ExperimentalSettingsApi::class)
@Composable
fun ConferenceMaterialTheme(
seedColorString: String?,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package dev.johnoreilly.confetti.ui

import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.window.ComposeUIViewController
import dev.johnoreilly.confetti.GetConferencesQuery
import dev.johnoreilly.confetti.fragment.SessionDetails
import platform.UIKit.UIViewController

fun SessionDetailsViewController(session: SessionDetails, onSpeakerClick: (speakerId: String) -> Unit, onSocialLinkClicked: (String) -> Unit): UIViewController =
fun SessionDetailsViewController(session: SessionDetails, conferenceThemeColor: String?, onSpeakerClick: (speakerId: String) -> Unit, onSocialLinkClicked: (String) -> Unit): UIViewController =
ComposeUIViewController {
// iOS specific colors...just adding like this as test for now
val colorScheme = lightColorScheme(
primary = Color(0xFF007AFF),
surface = Color(0xFFFFFFFF)
)

MaterialTheme(colorScheme = colorScheme) {
ConferenceMaterialTheme(conferenceThemeColor) {
SessionDetailViewShared(session, onSpeakerClick, onSocialLinkClicked)
}
}


fun ConferenceListViewController(conferenceListByYear: Map<Int, List<GetConferencesQuery.Conference>>, onConferenceClick: (GetConferencesQuery.Conference) -> Unit): UIViewController =
ComposeUIViewController {
MaterialTheme {
ConferenceListView(conferenceListByYear, onConferenceClick)
}
}

0 comments on commit 4207353

Please sign in to comment.