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

[iOS] Expand the description if it exceeds its line limit #403

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Changes from all commits
Commits
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
18 changes: 15 additions & 3 deletions app-ios/Modules/Sources/Session/SessionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ private let startDateFormatter: DateFormatter = {

public struct SessionView: View {
let viewModel: SessionViewModel
@State var isDescriptionExpanded: Bool = false
@State private var isDescriptionExpanded: Bool = false
@State private var canBeExpanded = false

public init(timetableItem: TimetableItem) {
self.viewModel = .init(timetableItem: timetableItem)
Expand Down Expand Up @@ -66,9 +67,21 @@ public struct SessionView: View {
VStack(alignment: .leading, spacing: 16) {
Text(session.description_)
.lineLimit(isDescriptionExpanded ? nil : 5)
if !isDescriptionExpanded {
.background {
ViewThatFits(in: .vertical) {
Text(session.description_)
.hidden()
// Just for receiving onAppear event if the description exceeds its line limit
Color.clear
.onAppear {
canBeExpanded = true
}
}
}
if canBeExpanded {
Button {
isDescriptionExpanded = true
canBeExpanded = false
} label: {
Text("続きを読む")
.font(Font.system(size: 14, weight: .medium))
Expand All @@ -78,7 +91,6 @@ public struct SessionView: View {
Capsule()
.stroke(AssetColors.outline.swiftUIColor)
}

}
}
}
Expand Down
Loading