From 381a11e86fd240592492cbc2c91259a3984598bf Mon Sep 17 00:00:00 2001 From: CHARLES BOND Date: Sat, 17 Aug 2024 13:24:10 +0900 Subject: [PATCH 1/5] Horizontal dividers working, vertical dividers have too much padding for some reason (wip) --- .../Resource/Localizable.xcstrings | 3 -- .../TimetableFeature/TimetableListView.swift | 46 +++++++++++++++++-- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/app-ios/Sources/TimetableFeature/Resource/Localizable.xcstrings b/app-ios/Sources/TimetableFeature/Resource/Localizable.xcstrings index d3fcac6ff..911e32eb3 100644 --- a/app-ios/Sources/TimetableFeature/Resource/Localizable.xcstrings +++ b/app-ios/Sources/TimetableFeature/Resource/Localizable.xcstrings @@ -13,9 +13,6 @@ } } } - }, - "Grid view placeholder" : { - }, "Timetable" : { diff --git a/app-ios/Sources/TimetableFeature/TimetableListView.swift b/app-ios/Sources/TimetableFeature/TimetableListView.swift index c13526443..ef175287b 100644 --- a/app-ios/Sources/TimetableFeature/TimetableListView.swift +++ b/app-ios/Sources/TimetableFeature/TimetableListView.swift @@ -116,7 +116,7 @@ struct TimetableGridView: View { let rooms = RoomType.allCases.filter {$0 != RoomType.roomIj} ScrollView([.horizontal, .vertical]) { - Grid { + Grid(alignment: .leading, horizontalSpacing: 1, verticalSpacing: 1) { GridRow { Color.clear .gridCellUnsizedAxes([.horizontal, .vertical]) @@ -127,6 +127,7 @@ struct TimetableGridView: View { .frame(width: 192) } } + DashedDivider(axis: .horizontal) ForEach(store.timetableItems, id: \.self) { timeBlock in GridRow { VStack { @@ -135,16 +136,20 @@ struct TimetableGridView: View { }.frame(height: 153) - + DashedDivider(axis: .vertical).frame(width: 1, height: 153) ForEach(rooms, id: \.self) { room in - timeBlock.getCellForRoom(room: room, onTap: { item in store.send(.view(.timetableItemTapped(item))) }) + //Divider().gridCellUnsizedAxes(.vertical) + DashedDivider(axis: .vertical).frame(width: 1) + // +// Divider() } } + DashedDivider(axis: .horizontal) } - } + }.fixedSize(horizontal: false, vertical: true) } } @@ -181,6 +186,39 @@ struct TimeGroupMiniList: View { } } +struct DashedDivider: View { + public var 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) + } + //shape + } +} + +struct LineShape: Shape { + public var 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 + } +} + extension RoomType { func toRoom() -> TimetableRoom { switch self { From 73247045064ec78912417b1a1011e3c3b08d938d Mon Sep 17 00:00:00 2001 From: CHARLES BOND Date: Sat, 17 Aug 2024 17:14:37 +0900 Subject: [PATCH 2/5] WIP (Horizontal grids working but unable to find a good solution for vertical grid lines yet. --- app-ios/Sources/TimetableFeature/TimetableListView.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app-ios/Sources/TimetableFeature/TimetableListView.swift b/app-ios/Sources/TimetableFeature/TimetableListView.swift index e73c72969..1b65b22e4 100644 --- a/app-ios/Sources/TimetableFeature/TimetableListView.swift +++ b/app-ios/Sources/TimetableFeature/TimetableListView.swift @@ -116,7 +116,7 @@ struct TimetableGridView: View { let rooms = RoomType.allCases.filter {$0 != RoomType.roomIj} ScrollView([.horizontal, .vertical]) { - Grid(alignment: .leading, horizontalSpacing: 1, verticalSpacing: 1) { + Grid(alignment: .leading, horizontalSpacing: 2, verticalSpacing: 1) { GridRow { Color.clear .gridCellUnsizedAxes([.horizontal, .vertical]) @@ -125,6 +125,7 @@ struct TimetableGridView: View { let room = column.toRoom() Text(room.name.currentLangTitle).foregroundStyle(room.roomTheme.primaryColor) .frame(width: 192) + } } DashedDivider(axis: .horizontal) @@ -136,14 +137,14 @@ struct TimetableGridView: View { }.frame(height: 153) - DashedDivider(axis: .vertical).frame(width: 1, height: 153) +// DashedDivider(axis: .vertical).frame(width: 1, height: 153) ForEach(rooms, id: \.self) { room in timeBlock.getCellForRoom(room: room, onTap: { item in store.send(.view(.timetableItemTapped(item))) }) //Divider().gridCellUnsizedAxes(.vertical) - DashedDivider(axis: .vertical).frame(width: 1) +// DashedDivider(axis: .vertical).frame(width: 1) // // Divider() } From 789657d5666af7a5d3ce7358bfc254efe76ed756 Mon Sep 17 00:00:00 2001 From: CHARLES BOND Date: Tue, 20 Aug 2024 23:18:26 +0900 Subject: [PATCH 3/5] For now we just have horizontl grid lines. I think this is worth adding but if someone can get vertical grid lines working I would appreciate it. --- app-ios/Sources/TimetableFeature/TimetableListView.swift | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app-ios/Sources/TimetableFeature/TimetableListView.swift b/app-ios/Sources/TimetableFeature/TimetableListView.swift index 1b65b22e4..498b524ac 100644 --- a/app-ios/Sources/TimetableFeature/TimetableListView.swift +++ b/app-ios/Sources/TimetableFeature/TimetableListView.swift @@ -116,7 +116,7 @@ struct TimetableGridView: View { let rooms = RoomType.allCases.filter {$0 != RoomType.roomIj} ScrollView([.horizontal, .vertical]) { - Grid(alignment: .leading, horizontalSpacing: 2, verticalSpacing: 1) { + Grid(alignment: .leading, horizontalSpacing: 4, verticalSpacing: 2) { GridRow { Color.clear .gridCellUnsizedAxes([.horizontal, .vertical]) @@ -136,17 +136,11 @@ struct TimetableGridView: View { Spacer() }.frame(height: 153) - -// DashedDivider(axis: .vertical).frame(width: 1, height: 153) ForEach(rooms, id: \.self) { room in timeBlock.getCellForRoom(room: room, onTap: { item in store.send(.view(.timetableItemTapped(item))) }) - //Divider().gridCellUnsizedAxes(.vertical) -// DashedDivider(axis: .vertical).frame(width: 1) - // -// Divider() } } DashedDivider(axis: .horizontal) From 573c806632e22a2f1ea16d1cff2caf2594f8de82 Mon Sep 17 00:00:00 2001 From: CHARLES BOND Date: Sat, 24 Aug 2024 13:51:35 +0900 Subject: [PATCH 4/5] code cleanup in response to comments. --- app-ios/Sources/TimetableFeature/TimetableListView.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app-ios/Sources/TimetableFeature/TimetableListView.swift b/app-ios/Sources/TimetableFeature/TimetableListView.swift index a479bd387..4364f2af2 100644 --- a/app-ios/Sources/TimetableFeature/TimetableListView.swift +++ b/app-ios/Sources/TimetableFeature/TimetableListView.swift @@ -205,12 +205,11 @@ struct DashedDivider: View { } else { shape.frame(width: 1).padding(0) } - //shape } } struct LineShape: Shape { - public var axis: Axis + public let axis: Axis func path(in rect: CGRect) -> Path { var path = Path() From db6052eead063137f308ff7461f590f75ee1b9c0 Mon Sep 17 00:00:00 2001 From: CHARLES BOND Date: Sun, 25 Aug 2024 14:47:27 +0900 Subject: [PATCH 5/5] Changed var to let as requested. --- app-ios/Sources/TimetableFeature/TimetableListView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-ios/Sources/TimetableFeature/TimetableListView.swift b/app-ios/Sources/TimetableFeature/TimetableListView.swift index 4364f2af2..69e339938 100644 --- a/app-ios/Sources/TimetableFeature/TimetableListView.swift +++ b/app-ios/Sources/TimetableFeature/TimetableListView.swift @@ -194,7 +194,7 @@ struct TimeGroupMiniList: View { } struct DashedDivider: View { - public var axis: Axis + public let axis: Axis var body: some View { let shape = LineShape(axis: axis)