Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/timetable feature grid2 #367

Merged
merged 29 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6be1dfa
WIP
charles-b-stb Aug 12, 2024
ab2c5e5
Merge branch 'main' of github.com:DroidKaigi/conference-app-2024 into…
charles-b-stb Aug 12, 2024
3d84fe1
wip
charles-b-stb Aug 12, 2024
42a0f8f
Grid showing, data not displayable yet.
charles-b-stb Aug 12, 2024
a8ec52f
Very basic grid in operation. Still needs to fix click operation. Sti…
charles-b-stb Aug 12, 2024
398d589
Code cleanup
charles-b-stb Aug 12, 2024
16190a5
Update app-ios/Sources/CommonComponents/Timetable/TimetableGridCard.s…
charles-b-stb Aug 13, 2024
3ec6e7f
Fixes as per pull request comments.
charles-b-stb Aug 13, 2024
7ce2c62
Merge branch 'main' of github.com:DroidKaigi/conference-app-2024 into…
charles-b-stb Aug 13, 2024
3458ce9
Merge branch 'main' of github.com:DroidKaigi/conference-app-2024 into…
charles-b-stb Aug 13, 2024
0c5fac1
Fixed build with suggestions.
charles-b-stb Aug 13, 2024
404fec3
Merge branch 'main' of github.com:DroidKaigi/conference-app-2024 into…
charles-b-stb Aug 14, 2024
7ef8e12
Update app-ios/Sources/TimetableFeature/TimetableListView.swift
charles-b-stb Aug 14, 2024
01a633e
Update app-ios/Sources/CommonComponents/Timetable/TimetableGridCard.s…
charles-b-stb Aug 14, 2024
c75137c
Update app-ios/Sources/CommonComponents/Timetable/TimetableGridCard.s…
charles-b-stb Aug 14, 2024
1085d24
Update app-ios/Sources/CommonComponents/Timetable/TimetableGridCard.s…
charles-b-stb Aug 14, 2024
38eaa49
Fixed various issues.
charles-b-stb Aug 14, 2024
34c3e46
Merge branch 'feature/timetable-feature-grid2' of github.com:DroidKai…
charles-b-stb Aug 14, 2024
f201358
Fixed various issues that came up during pull request.
charles-b-stb Aug 14, 2024
2a8d3eb
Merge branch 'main' of github.com:DroidKaigi/conference-app-2024 into…
charles-b-stb Aug 14, 2024
0900ab1
Merge branch 'main' into feature/timetable-feature-grid2
charles-b-stb Aug 14, 2024
f48e5ba
Replaced Spacer with Color as per PR comment
charles-b-stb Aug 16, 2024
2563d07
Merge branch 'feature/timetable-feature-grid2' of github.com:DroidKai…
charles-b-stb Aug 16, 2024
ab85531
Update app-ios/Sources/TimetableFeature/TimetableListView.swift
charles-b-stb Aug 17, 2024
bdf3b12
Update app-ios/Sources/CommonComponents/Timetable/TimetableGridCard.s…
charles-b-stb Aug 17, 2024
348203e
Update app-ios/Sources/TimetableFeature/TimetableDataItems.swift
charles-b-stb Aug 17, 2024
b39f2d6
Fixed items broken by pullrequest suggest commits.
charles-b-stb Aug 17, 2024
16262aa
Moved GridItem back into the Timetable module.
charles-b-stb Aug 18, 2024
45d96ec
Rewrote to move clear outside TimetableGridCard
charles-b-stb Aug 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app-ios/Sources/CommonComponents/Timetable/RoomTag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extension MultiLangText {
}

extension RoomType {
var shape: some View {
public var shape: some View {
Group {
switch self {
case .roomG: Image(.icCircleFill).renderingMode(.template)
Expand Down
13 changes: 10 additions & 3 deletions app-ios/Sources/TimetableFeature/Resource/Localizable.xcstrings
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"sourceLanguage" : "en",
"strings" : {
"%@ - %@" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "%1$@ - %2$@"
}
}
}
},
"|" : {

},
Expand All @@ -13,9 +23,6 @@
}
}
}
},
"Grid view placeholder" : {

},
"Timetable" : {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import CommonComponents
import shared

public enum DayTab: String, CaseIterable, Identifiable, Sendable {
Expand Down Expand Up @@ -27,6 +28,12 @@ public struct TimetableTimeGroupItems: Identifiable, Equatable, Hashable {
self.endsTimeString = endsTimeString
self.items = items
}

func getItem(for room: RoomType) -> TimetableItemWithFavorite? {
items.filter {
$0.timetableItem.room.type == room //TODO: roomIj handling not decided?
}.first
}
}

// This exists only for previews now.
Expand Down
77 changes: 77 additions & 0 deletions app-ios/Sources/TimetableFeature/TimetableGridCard.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import Foundation
import SwiftUI
import Theme
import class shared.TimetableItem

public struct TimetableGridCard: View {
let timetableItem: TimetableItem
let onTap: (TimetableItem) -> Void

public init(
timetableItem: TimetableItem,
onTap: @escaping (TimetableItem) -> Void
) {
self.timetableItem = timetableItem
self.onTap = onTap
}

public var body: some View {
Button {
onTap(timetableItem)
} label: {
VStack(alignment: .leading, spacing: 8) {
HStack(spacing: 4) {
timetableItem.room.type.shape
.foregroundStyle(timetableItem.room.roomTheme.primaryColor)
Text("\(timetableItem.startsTimeString) - \(timetableItem.endsTimeString)")
.textStyle(.labelMedium)
.foregroundStyle(timetableItem.room.roomTheme.primaryColor)
Spacer()
}

Text(timetableItem.title.currentLangTitle)
.textStyle(.titleMedium)
.foregroundStyle(timetableItem.room.roomTheme.primaryColor)
.multilineTextAlignment(.leading)

Spacer()

ForEach(timetableItem.speakers, id: \.id) { speaker in
HStack(spacing: 8) {
Group {
AsyncImage(url: URL(string: speaker.iconUrl)) {
$0.resizable()
} placeholder: {
Color.gray
}
}
.frame(width: 32, height: 32)
.clipShape(Circle())

Text(speaker.name)
.textStyle(.titleSmall)
.foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor)
.lineLimit(1)
}
}
}
.frame(maxWidth: .infinity)
.padding(12)
.frame(width: 192, height: 153)
.background(timetableItem.room.roomTheme.containerColor, in: RoundedRectangle(cornerRadius: 4))
.overlay(RoundedRectangle(cornerRadius: 4).stroke(timetableItem.room.roomTheme.primaryColor, lineWidth: 1))
}
}
}

#Preview {
VStack {
TimetableGridCard(
timetableItem: TimetableItem.Session.companion.fake(),
onTap: { _ in }
)
.padding(.horizontal, 16)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.black)
}
148 changes: 123 additions & 25 deletions app-ios/Sources/TimetableFeature/TimetableListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public struct TimetableView: View {
case TimetableMode.list:
TimetableListView(store: store)
case TimetableMode.grid:
Text("Grid view placeholder")
.foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
TimetableGridView(store: store)
}
Spacer()
}
Expand Down Expand Up @@ -107,6 +106,56 @@ struct TimetableListView: View {
}
}

struct TimetableGridView: View {
private let store: StoreOf<TimetableReducer>
public init(store: StoreOf<TimetableReducer>) {
self.store = store
}

var body: some View {
let rooms = RoomType.allCases.filter {$0 != RoomType.roomIj}

ScrollView([.horizontal, .vertical]) {
Grid {
GridRow {
Color.clear
.gridCellUnsizedAxes([.horizontal, .vertical])

ForEach(rooms, id: \.self) { column in
let room = column.toRoom()
Text(room.name.currentLangTitle).foregroundStyle(room.roomTheme.primaryColor)
.frame(width: 192)
}
}
ForEach(store.timetableItems, id: \.self) { timeBlock in
GridRow {
VStack {
Text(timeBlock.startsTimeString).foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
Spacer()

}.frame(height: 153)

charles-b-stb marked this conversation as resolved.
Show resolved Hide resolved
ForEach(rooms, id: \.self) { room in

if let cell = timeBlock.getCellForRoom(room: room, onTap: { item in
store.send(.view(.timetableItemTapped(item)))}) {
cell
} else {
Color.clear
.frame(maxWidth: .infinity)
.padding(12)
.frame(width: 192, height: 153)
.background(Color.clear, in: RoundedRectangle(cornerRadius: 4))
}
}
}
}
}
}

}
}

struct TimeGroupMiniList: View {
let contents: TimetableTimeGroupItems
let onItemTap: (TimetableItemWithFavorite) -> Void
Expand Down Expand Up @@ -138,37 +187,86 @@ struct TimeGroupMiniList: View {
}
}

struct TagView: View {
let tagText: String
let highlight: Bool

var body: some View {
HStack {
if highlight {
Image(systemName: "diamond.fill").resizable().frame(width: 11,height: 11).foregroundStyle(AssetColors.Custom.flamingo.swiftUIColor)
.padding(-3)
}
Text(tagText).foregroundStyle(highlight ? AssetColors.Custom.flamingo.swiftUIColor : AssetColors.Surface.onSurface.swiftUIColor)
extension RoomType {
func toRoom() -> TimetableRoom {
switch self {
case .roomI:
return TimetableRoom(
id: 1,
name: MultiLangText(
jaTitle: "Iguana",
enTitle: "Iguana"
),
type: .roomI,
sort: 1
)
case .roomG:
return TimetableRoom(
id: 2,
name: MultiLangText(
jaTitle: "Giraffe",
enTitle: "Giraffe"
),
type: .roomG,
sort: 2
)
case .roomH:
return TimetableRoom(
id: 3,
name: MultiLangText(
jaTitle: "Hedgehog",
enTitle: "Hedgehog"
),
type: .roomH,
sort: 3
)
case .roomF:
return TimetableRoom(
id: 4,
name: MultiLangText(
jaTitle: "Flamingo",
enTitle: "Flamingo"
),
type: .roomF,
sort: 4
)
case .roomJ:
return TimetableRoom(
id: 5,
name: MultiLangText(
jaTitle: "Jellyfish",
enTitle: "Jellyfish"
),
type: .roomJ,
sort: 5
)
case .roomIj:
return TimetableRoom(
id: 6,
name: MultiLangText(
jaTitle: "Iguana and Jellyfish",
enTitle: "Iguana and Jellyfish"
),
type: .roomIj,
sort: 6
)
}
.padding(
EdgeInsets(top: 2,leading: 7, bottom: 2, trailing: 7))
.border(highlight ? AssetColors.Custom.flamingo.swiftUIColor : AssetColors.Surface.onSurface.swiftUIColor)
.padding(-2)
}
}

struct PhotoView: View {
let photo: String
let name: String

var body: some View {
HStack {
Image(systemName:photo).resizable().frame(width: 32,height: 32).foregroundStyle(AssetColors.Custom.flamingo.swiftUIColor)
Text(name)
extension TimetableTimeGroupItems {
func getCellForRoom(room: RoomType, onTap: @escaping (TimetableItemWithFavorite) -> Void) -> TimetableGridCard? {
return if let cell = getItem(for: room) {
TimetableGridCard(timetableItem: cell.timetableItem) { timetableItem in
onTap(cell)
}
} else {
nil
}
}
}


#Preview {
TimetableView(
store: .init(initialState: .init(timetableItems: SampleData.init().workdayResults),
Expand Down
Loading