Skip to content

Commit

Permalink
Merge pull request #1046 from woxtu/open-url
Browse files Browse the repository at this point in the history
[iOS] Enable links in descriptions on the session detail
  • Loading branch information
ry-itto authored Sep 2, 2023
2 parents 21cabc2 + 5a11f9f commit e5f0fe3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app-ios/Modules/Sources/Session/SessionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ private let startDateFormatter: DateFormatter = {
public struct SessionView: View {
let viewModel: SessionViewModel
@State private var isDescriptionExpanded: Bool = false
@State private var canBeExpanded = false
@State private var canBeExpanded: Bool = false
@State private var presentingURL: IdentifiableURL?

public init(timetableItem: TimetableItem) {
self.viewModel = .init(timetableItem: timetableItem)
Expand Down Expand Up @@ -65,7 +66,7 @@ public struct SessionView: View {

if let session = viewModel.timetableItem as? TimetableItem.Session {
VStack(alignment: .leading, spacing: 16) {
Text(session.description_.currentLangTitle)
Text(.init(session.description_.currentLangTitle))
.textSelection(.enabled)
.lineLimit(isDescriptionExpanded ? nil : 5)
.background {
Expand Down Expand Up @@ -189,7 +190,16 @@ public struct SessionView: View {
}
}
}

.sheet(item: $presentingURL) { url in
if let url = url.id {
SafariView(url: url)
.ignoresSafeArea()
}
}
.environment(\.openURL, OpenURLAction { url in
presentingURL = IdentifiableURL(url)
return .handled
})
}
}

Expand Down

0 comments on commit e5f0fe3

Please sign in to comment.