-
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 #148 from DroidKaigi/feature/timetable_item_card
Add timetable item card
- Loading branch information
Showing
9 changed files
with
161 additions
and
8 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
6 changes: 6 additions & 0 deletions
6
app-ios/Sources/CommonComponents/Resources/Media.xcassets/Contents.json
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...Sources/CommonComponents/Resources/Media.xcassets/ic_favorite_fill.imageset/Contents.json
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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "favorite.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...ommonComponents/Resources/Media.xcassets/ic_favorite_fill.imageset/favorite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
...rces/CommonComponents/Resources/Media.xcassets/ic_favorite_outline.imageset/Contents.json
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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "ic_favorite_outline.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"preserves-vector-representation" : true | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...s/Resources/Media.xcassets/ic_favorite_outline.imageset/ic_favorite_outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions
6
...DetailFeature/Component/LanguageTag.swift → ...monComponents/Timetable/LanguageTag.swift
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
96 changes: 96 additions & 0 deletions
96
app-ios/Sources/CommonComponents/Timetable/TimetableCard.swift
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,96 @@ | ||
import SwiftUI | ||
import Theme | ||
import class shared.TimetableItem | ||
|
||
public struct TimetableCard: View { | ||
let timetableItem: TimetableItem | ||
let isFavorite: Bool | ||
let onTap: (TimetableItem) -> Void | ||
let onTapFavorite: (TimetableItem) -> Void | ||
|
||
public init( | ||
timetableItem: TimetableItem, | ||
isFavorite: Bool, | ||
onTap: @escaping (TimetableItem) -> Void, | ||
onTapFavorite: @escaping (TimetableItem) -> Void | ||
) { | ||
self.timetableItem = timetableItem | ||
self.isFavorite = isFavorite | ||
self.onTap = onTap | ||
self.onTapFavorite = onTapFavorite | ||
} | ||
|
||
public var body: some View { | ||
Button { | ||
onTap(timetableItem) | ||
} label: { | ||
VStack(alignment: .leading, spacing: 8) { | ||
HStack(spacing: 4) { | ||
RoomTag(.arcticFox) | ||
ForEach(timetableItem.language.labels, id: \.self) { label in | ||
LanguageTag(label) | ||
} | ||
Spacer() | ||
Button { | ||
onTapFavorite(timetableItem) | ||
} label: { | ||
Image(isFavorite ? .icFavoriteFill : .icFavoriteOutline) | ||
.resizable() | ||
.renderingMode(.template) | ||
.foregroundColor( | ||
isFavorite ? | ||
AssetColors.Primary.primaryFixed.swiftUIColor | ||
: | ||
AssetColors.Surface.onSurfaceVariant.swiftUIColor | ||
) | ||
.frame(width: 24, height: 24) | ||
} | ||
} | ||
|
||
Text(timetableItem.title.currentLangTitle) | ||
.textStyle(.titleMedium) | ||
.foregroundColor(AssetColors.Surface.onSurface.swiftUIColor) | ||
.multilineTextAlignment(.leading) | ||
|
||
ForEach(timetableItem.speakers, id: \.id) { speaker in | ||
HStack(spacing: 8) { | ||
Group { | ||
if let url = URL(string: speaker.iconUrl) { | ||
AsyncImage(url: url) { | ||
$0.image?.resizable() | ||
} | ||
} else { | ||
Circle().stroke(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) | ||
.background(AssetColors.Surface.surface.swiftUIColor, in: RoundedRectangle(cornerRadius: 4)) | ||
.overlay(RoundedRectangle(cornerRadius: 4).stroke(AssetColors.Outline.outlineVariant.swiftUIColor, lineWidth: 1)) | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
VStack { | ||
TimetableCard( | ||
timetableItem: TimetableItem.Session.companion.fake(), | ||
isFavorite: true, | ||
onTap: { _ in }, | ||
onTapFavorite: { _ in } | ||
) | ||
.padding(.horizontal, 16) | ||
} | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
.background(Color.black) | ||
} |