Skip to content

Commit

Permalink
Merge pull request #148 from DroidKaigi/feature/timetable_item_card
Browse files Browse the repository at this point in the history
Add timetable item card
  • Loading branch information
shin-usu authored Jul 19, 2024
2 parents 9d29ccd + b8474fb commit 5b51cb3
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 8 deletions.
7 changes: 6 additions & 1 deletion app-ios/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ let package = Package(
name: "ContributorFeature",
targets: ["ContributorFeature"]
),
.library(
name: "CommonComponents",
targets: ["CommonComponents"]
),
],
dependencies: [
.package(url: "https://github.com/pointfreeco/swift-composable-architecture.git", exact: "1.10.2"),
Expand Down Expand Up @@ -94,6 +98,7 @@ let package = Package(
.firebaseAuth,
.firebaseRemoteConfig,
.tca,
.commonComponents,
]
),
.testTarget(
Expand Down Expand Up @@ -198,7 +203,7 @@ let package = Package(
.tca
]
),
.target(name: "CommonComponents", dependencies: [.theme]),
.target(name: "CommonComponents", dependencies: [.theme, .kmpModule]),
// Please run ./gradlew app-ios-shared:assembleSharedXCFramework first
.binaryTarget(name: "KmpModule", path: "../app-ios-shared/build/XCFrameworks/debug/shared.xcframework"),
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
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
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import SwiftUI
import Theme

struct LanguageTag: View {
public struct LanguageTag: View {
let languageLabel: String

init(_ languageLabel: String) {
public init(_ languageLabel: String) {
self.languageLabel = languageLabel
}

var body: some View {
public var body: some View {
Text(languageLabel)
.textStyle(.labelMedium)
.foregroundStyle(AssetColors.Surface.onSurfaceVariant.swiftUIColor)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import SwiftUI
import Theme

struct RoomTag: View {
enum Room {
public struct RoomTag: View {
public enum Room {
case arcticFox
case bumblebee
case chipmunk
Expand All @@ -12,11 +12,11 @@ struct RoomTag: View {

let room: Room

init(_ room: Room) {
public init(_ room: Room) {
self.room = room
}

var body: some View {
public var body: some View {
HStack(spacing: 5) {
Rectangle()
.frame(width: 10, height: 10)
Expand Down
96 changes: 96 additions & 0 deletions app-ios/Sources/CommonComponents/Timetable/TimetableCard.swift
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)
}

0 comments on commit 5b51cb3

Please sign in to comment.