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

Feature/446 gridlines #559

Merged
merged 8 commits into from
Aug 25, 2024
42 changes: 38 additions & 4 deletions app-ios/Sources/TimetableFeature/TimetableListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ struct TimetableGridView: View {
let rooms = RoomType.allCases.filter {$0 != RoomType.roomIj}

ScrollView([.horizontal, .vertical]) {
Grid {
Grid(alignment: .leading, horizontalSpacing: 4, verticalSpacing: 2) {
GridRow {
Color.clear
.gridCellUnsizedAxes([.horizontal, .vertical])
Expand All @@ -127,18 +127,19 @@ struct TimetableGridView: View {
let room = column.toRoom()
Text(room.name.currentLangTitle).foregroundStyle(room.roomTheme.primaryColor)
.frame(width: 192)

}
}
DashedDivider(axis: .horizontal)
ForEach(store.timetableItems, id: \.self) { timeBlock in
GridRow {
VStack {
Text(timeBlock.startsTimeString).foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor)
Spacer()

}.frame(height: 153)

ForEach(rooms, id: \.self) { room in

if let cell = timeBlock.getCellForRoom(room: room, onTap: { item in
store.send(.view(.timetableItemTapped(item)))}) {
cell
Expand All @@ -151,8 +152,9 @@ struct TimetableGridView: View {
}
}
}
DashedDivider(axis: .horizontal)
}
}
}.fixedSize(horizontal: false, vertical: true)
.padding(.trailing)

bottomTabBarPadding
Expand Down Expand Up @@ -191,6 +193,38 @@ struct TimeGroupMiniList: View {
}
}

struct DashedDivider: View {
public let axis: Axis

var body: some View {
let shape = LineShape(axis: axis)
.stroke(style: .init(dash: [2]))
.foregroundStyle(AssetColors.Outline.outlineVariant.swiftUIColor)
if axis == .horizontal {
shape.frame(height: 1)
} else {
shape.frame(width: 1).padding(0)
}
}
}

struct LineShape: Shape {
public let axis: Axis

func path(in rect: CGRect) -> Path {
var path = Path()
path.move(to: CGPoint(x: 0, y: 0))

if axis == .horizontal {
path.addLine(to: CGPoint(x: rect.width, y: 0))
} else {
path.addLine(to: CGPoint(x: 0, y: rect.height))
}

return path
}
}

fileprivate var bottomTabBarPadding: some View {
// bottom floating tabbar padding
Color.clear.padding(.bottom, 60)
Expand Down
Loading