-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #367 from DroidKaigi/feature/timetable-feature-grid2
Feature/timetable feature grid2
- Loading branch information
Showing
5 changed files
with
218 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters