Skip to content

Commit

Permalink
Merge pull request #559 from DroidKaigi/feature/446-gridlines
Browse files Browse the repository at this point in the history
Feature/446 gridlines
  • Loading branch information
charles-b-stb authored Aug 25, 2024
2 parents 051a4fc + db6052e commit cb967d3
Showing 1 changed file with 38 additions and 4 deletions.
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).textStyle(.titleMedium)
.frame(width: 192)

}
}
DashedDivider(axis: .horizontal)
ForEach(store.timetableItems, id: \.self) { timeBlock in
GridRow {
VStack {
Text(timeBlock.startsTimeString).foregroundStyle(AssetColors.Surface.onSurface.swiftUIColor).textStyle(.labelMedium)
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

0 comments on commit cb967d3

Please sign in to comment.