Skip to content

Commit

Permalink
feat(iosApp): add partners activities screens.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Dec 4, 2024
1 parent 24a7e56 commit 9431af0
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 29 deletions.
12 changes: 12 additions & 0 deletions iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
0056BD6E2D00E29400098D38 /* ActivityItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0056BD6D2D00E29400098D38 /* ActivityItemView.swift */; };
0056BD702D00E58D00098D38 /* PartnersActivitiesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0056BD6F2D00E58D00098D38 /* PartnersActivitiesView.swift */; };
0056BD742D00F0F700098D38 /* PartnerListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0056BD732D00F0F700098D38 /* PartnerListView.swift */; };
0060F46B2C8BC231000BCD06 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0060F46A2C8BC231000BCD06 /* GoogleService-Info.plist */; };
058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; };
Expand Down Expand Up @@ -115,6 +118,9 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
0056BD6D2D00E29400098D38 /* ActivityItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityItemView.swift; sourceTree = "<group>"; };
0056BD6F2D00E58D00098D38 /* PartnersActivitiesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PartnersActivitiesView.swift; sourceTree = "<group>"; };
0056BD732D00F0F700098D38 /* PartnerListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PartnerListView.swift; sourceTree = "<group>"; };
0060F46A2C8BC231000BCD06 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -528,6 +534,7 @@
isa = PBXGroup;
children = (
D57028A927B550BF008EF4AD /* PartnerDividerView.swift */,
0056BD6D2D00E29400098D38 /* ActivityItemView.swift */,
);
path = partners;
sourceTree = "<group>";
Expand All @@ -538,6 +545,8 @@
D5C92EC4283AC56F00D5CF2D /* Partners.swift */,
D5C92EC6283AC66D00D5CF2D /* PartnersVM.swift */,
D5C92EC8283AC6D400D5CF2D /* PartnersViewModel.swift */,
0056BD6F2D00E58D00098D38 /* PartnersActivitiesView.swift */,
0056BD732D00F0F700098D38 /* PartnerListView.swift */,
);
path = partners;
sourceTree = "<group>";
Expand Down Expand Up @@ -744,6 +753,7 @@
D560788E27BE86D900D4012C /* SpeakerAvatarView.swift in Sources */,
D5C7532E2975F56000E2FD0B /* AppViewModel.swift in Sources */,
D5768D6027C11E2A00FB081C /* Networking.swift in Sources */,
0056BD742D00F0F700098D38 /* PartnerListView.swift in Sources */,
D5C92ED1283ACEB500D5CF2D /* Menus.swift in Sources */,
D5C1B3BB29F26D9E00D94391 /* BundleExt.swift in Sources */,
D50A458F27B081B600C9A43C /* Agenda.swift in Sources */,
Expand All @@ -756,6 +766,7 @@
D560789727BE906500D4012C /* SpeakerDetailVM.swift in Sources */,
D5D7E1092BEE4CF40027071D /* EventSessionItemNavigation.swift in Sources */,
D50E9B0527C12AF000B7B9B9 /* NetworkingViewModel.swift in Sources */,
0056BD702D00E58D00098D38 /* PartnersActivitiesView.swift in Sources */,
D5B5E8542B4C98E600129758 /* AgendaFiltersVM.swift in Sources */,
D544C7E929548B460038CB80 /* SpeakersAvatarView.swift in Sources */,
D51C2CD128383719006EED5D /* UIApplicationExt.swift in Sources */,
Expand Down Expand Up @@ -784,6 +795,7 @@
D560789527BE8F4500D4012C /* SpeakerViewModel.swift in Sources */,
D58F1D5427B0057300FB59C7 /* Color.swift in Sources */,
D5C92EC5283AC56F00D5CF2D /* Partners.swift in Sources */,
0056BD6E2D00E29400098D38 /* ActivityItemView.swift in Sources */,
D5C92ED3283AD00800D5CF2D /* MenusVM.swift in Sources */,
D5D7E10F2BEE4FB40027071D /* ScheduleEventSessionVM.swift in Sources */,
D58F1D4F27AFF40A00FB59C7 /* TalkItemView.swift in Sources */,
Expand Down
Binary file not shown.
42 changes: 42 additions & 0 deletions iosApp/iosApp/components/partners/ActivityItemView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// ActivityItemView.swift
// iosApp
//
// Created by Gérard PALIGOT on 04/12/2024.
// Copyright © 2024 orgName. All rights reserved.
//

import SwiftUI
import SharedDi

struct ActivityItemView: View {
var activity: ActivityUi
var titleColor: Color = Color.c4hOnBackground
var titleTextStyle: Font = Font.title3

var body: some View {
VStack(alignment: .leading) {
Text(activity.activityName)
.foregroundColor(titleColor)
.font(titleTextStyle)
HStack {
TagUnStyledView(
text: activity.startTime,
icon: "clock"
)
TagUnStyledView(
text: activity.partnerName,
icon: "suitcase"
)
}
}
.frame(maxWidth: .infinity, alignment: .topLeading)
}
}

#Preview {
ActivityItemView(
activity: ActivityUi.companion.fake
)
.padding()
}
1 change: 1 addition & 0 deletions iosApp/iosApp/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"screenAgenda" = "Agenda";
"screenNetworking" = "Networking";
"screenPartners" = "Partners";
"screenActivities" = "Activities";
"screenEvent" = "Event";
"screenFilters" = "Filtres";

Expand Down
1 change: 1 addition & 0 deletions iosApp/iosApp/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"screenAgenda" = "Agenda";
"screenNetworking" = "Networking";
"screenPartners" = "Partenaires";
"screenActivities" = "Activités";
"screenEvent" = "Événement";
"screenFilters" = "Filtres";

Expand Down
43 changes: 43 additions & 0 deletions iosApp/iosApp/screens/partners/PartnerListView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// PartnerListView.swift
// iosApp
//
// Created by Gérard PALIGOT on 04/12/2024.
// Copyright © 2024 orgName. All rights reserved.
//

import SwiftUI
import SharedDi

struct PartnerListView: View {
let partners: PartnerGroupsUi
let horizontalSpacing: CGFloat = 16
let maxItems: Int = 3

var body: some View {
GeometryReader { geometry in
let parentWidth = geometry.size.width - (self.horizontalSpacing * 2)
ScrollView {
LazyVStack(spacing: 8) {
ForEach(partners.groups, id: \.type) { partnerGroup in
Section {
LazyVGrid(columns: [GridItem(.adaptive(minimum: parentWidth)), GridItem(.adaptive(minimum: parentWidth)), GridItem(.adaptive(minimum: parentWidth))], content: {
ForEach(partnerGroup.partners, id: \.id) { partner in
PartnerItemNavigation(partner: partner)
}
})
} header : {
PartnerDividerView(text: partnerGroup.type)
.padding(.horizontal, self.horizontalSpacing)
}
}
}
}
}
}
}

#Preview {
PartnerListView(partners: PartnerGroupsUi.companion.fake)
.environmentObject(ViewModelFactory())
}
41 changes: 15 additions & 26 deletions iosApp/iosApp/screens/partners/Partners.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,29 @@ import SwiftUI
import SharedDi

struct Partners: View {
let partners: PartnerGroupsUi
let horizontalSpacing: CGFloat = 16
let maxItems: Int = 3
var uiModel: PartnersActivitiesUi
@State private var selectedTab = "screenPartners"

var body: some View {
GeometryReader { geometry in
let parentWidth = geometry.size.width - (self.horizontalSpacing * 2)
ScrollView {
LazyVStack(spacing: 8) {
ForEach(partners.groups, id: \.type) { partnerGroup in
Section {
LazyVGrid(columns: [GridItem(.adaptive(minimum: parentWidth)), GridItem(.adaptive(minimum: parentWidth)), GridItem(.adaptive(minimum: parentWidth))], content: {
ForEach(partnerGroup.partners, id: \.id) { partner in
PartnerItemNavigation(partner: partner)
}
})
} header : {
PartnerDividerView(text: partnerGroup.type)
.padding(.horizontal, self.horizontalSpacing)
}
}
VStack {
if (self.uiModel.activities.keys.count > 0) {
Picker("Options:", selection: $selectedTab) {
Text("screenPartners").tag("screenPartners")
Text("screenActivities").tag("screenActivities")
}
.pickerStyle(SegmentedPickerStyle())
}
if (selectedTab == "screenActivities") {
PartnersActivitiesView(activities: uiModel.activities)
} else {
PartnerListView(partners: uiModel.partners)
}
}
.navigationTitle(Text("screenPartners"))
.navigationBarTitleDisplayMode(.inline)
}
}

struct Partners_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
Partners(partners: PartnerGroupsUi.companion.fake)
.environmentObject(ViewModelFactory())
}
}
#Preview {
Partners(uiModel: PartnersActivitiesUi.companion.fake)
}
44 changes: 44 additions & 0 deletions iosApp/iosApp/screens/partners/PartnersActivitiesView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// PartnersActivitiesView.swift
// iosApp
//
// Created by Gérard PALIGOT on 04/12/2024.
// Copyright © 2024 orgName. All rights reserved.
//

import SwiftUI
import SharedDi

struct PartnersActivitiesView: View {
var activities: [String: [ActivityUi]]

var body: some View {
List {
ForEach(activities.keys.sorted(), id: \.self) { time in
Section {
let activities = activities[time]!
ForEach(0..<activities.count, id: \.self) { index in
let activity = activities[index]
ActivityItemView(activity: activity)
}
} header: {
Text(time)
.accessibilityLabel(toSpelloutAccessibleTime(time: time))
}
}
}
}
}

#Preview {
PartnersActivitiesView(
activities: [
"09:00": [
ActivityUi.companion.fake
],
"10:00": [
ActivityUi.companion.fake
]
]
)
}
2 changes: 1 addition & 1 deletion iosApp/iosApp/screens/partners/PartnersVM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct PartnersVM: View {
Group {
switch uiState {
case .success(let partners):
Partners(partners: partners)
Partners(uiModel: partners)
case .failure:
Text("textError")
case .loading:
Expand Down
4 changes: 2 additions & 2 deletions iosApp/iosApp/screens/partners/PartnersViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import KMPNativeCoroutinesAsync

enum PartnersUiState {
case loading
case success(PartnerGroupsUi)
case success(PartnersActivitiesUi)
case failure
}

Expand All @@ -29,7 +29,7 @@ class PartnersViewModel: ObservableObject {
do {
let stream = asyncSequence(for: interactor.partners())
for try await partners in stream {
self.uiState = PartnersUiState.success(partners.partners)
self.uiState = PartnersUiState.success(partners)
}
} catch {
self.uiState = PartnersUiState.failure
Expand Down

0 comments on commit 9431af0

Please sign in to comment.