-
Notifications
You must be signed in to change notification settings - Fork 200
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/445 stretchfield #603
Changes from 6 commits
441bcc0
8c9a4a1
b9b5c79
a903966
d1969a6
325766f
b07adb0
f42a6b4
4ef7e99
66b245b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,13 +7,16 @@ import CommonComponents | |||||
public struct TimetableGridCard: View { | ||||||
let timetableItem: TimetableItem | ||||||
let onTap: (TimetableItem) -> Void | ||||||
let cellCount: Int | ||||||
|
||||||
public init( | ||||||
timetableItem: TimetableItem, | ||||||
cellCount: Int? = 1, | ||||||
onTap: @escaping (TimetableItem) -> Void | ||||||
) { | ||||||
self.timetableItem = timetableItem | ||||||
self.onTap = onTap | ||||||
self.cellCount = cellCount ?? 1 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you have |
||||||
} | ||||||
|
||||||
public var body: some View { | ||||||
|
@@ -22,17 +25,19 @@ public struct TimetableGridCard: View { | |||||
} label: { | ||||||
VStack(alignment: .leading, spacing: 8) { | ||||||
HStack(spacing: 4) { | ||||||
RoomTypeShape(roomType: .init(enTitle: timetableItem.room.name.enTitle)) | ||||||
if cellCount == 1 { | ||||||
RoomTypeShape(roomType: .init(enTitle: timetableItem.room.name.enTitle)) | ||||||
.foregroundStyle(timetableItem.room.roomTheme.primaryColor) | ||||||
} | ||||||
Text("\(timetableItem.startsTimeString) - \(timetableItem.endsTimeString)") | ||||||
.textStyle(.labelMedium) | ||||||
.foregroundStyle(timetableItem.room.roomTheme.primaryColor) | ||||||
.foregroundStyle(cellCount>1 ? AssetColors.Surface.onSurfaceVariant.swiftUIColor : timetableItem.room.roomTheme.primaryColor) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I want add spaces for any operators left and right😅 |
||||||
Spacer() | ||||||
} | ||||||
|
||||||
Text(timetableItem.title.currentLangTitle) | ||||||
.textStyle(.titleMedium) | ||||||
.foregroundStyle(timetableItem.room.roomTheme.primaryColor) | ||||||
.foregroundStyle(cellCount>1 ? AssetColors.Surface.onSurface.swiftUIColor : timetableItem.room.roomTheme.primaryColor) | ||||||
.multilineTextAlignment(.leading) | ||||||
|
||||||
Spacer() | ||||||
|
@@ -58,9 +63,9 @@ public struct TimetableGridCard: View { | |||||
} | ||||||
.frame(maxWidth: .infinity) | ||||||
.padding(12) | ||||||
.frame(width: 192, height: 153) | ||||||
.background(timetableItem.room.roomTheme.containerColor, in: RoundedRectangle(cornerRadius: 4)) | ||||||
.overlay(RoundedRectangle(cornerRadius: 4).stroke(timetableItem.room.roomTheme.primaryColor, lineWidth: 1)) | ||||||
.frame(width: 192*CGFloat(cellCount)+CGFloat(12*(cellCount-1)), height: 153) | ||||||
charles-b-stb marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
.background(cellCount>1 ? AssetColors.Surface.surfaceContainer.swiftUIColor : timetableItem.room.roomTheme.containerColor, in: RoundedRectangle(cornerRadius: 4)) | ||||||
.overlay(RoundedRectangle(cornerRadius: 4).stroke(cellCount>1 ? AssetColors.Surface.onSurface.swiftUIColor : timetableItem.room.roomTheme.primaryColor, lineWidth: 1)) | ||||||
} | ||||||
} | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -95,9 +95,9 @@ struct TimetableListView: View { | |||||
ForEach(store.timetableItems, id: \.self) { item in | ||||||
TimeGroupMiniList(contents: item, onItemTap: { item in | ||||||
store.send(.view(.timetableItemTapped(item))) | ||||||
}) { | ||||||
}, onFavoriteTap: { | ||||||
store.send(.view(.favoriteTapped($0))) | ||||||
} | ||||||
}) | ||||||
} | ||||||
}.scrollContentBackground(.hidden) | ||||||
.onAppear { | ||||||
|
@@ -130,6 +130,7 @@ struct TimetableGridView: View { | |||||
.frame(width: 192) | ||||||
} | ||||||
} | ||||||
|
||||||
ForEach(store.timetableItems, id: \.self) { timeBlock in | ||||||
GridRow { | ||||||
VStack { | ||||||
|
@@ -138,17 +139,27 @@ struct TimetableGridView: View { | |||||
|
||||||
}.frame(height: 153) | ||||||
|
||||||
ForEach(rooms, id: \.self) { room in | ||||||
if (timeBlock.items.count == 1 && timeBlock.isTopLunch()) { | ||||||
|
||||||
timeBlock.getCellForRoom( | ||||||
room: RoomType.roomJ, | ||||||
cellCount: 5, | ||||||
onTap: { item in | ||||||
store.send(.view(.timetableItemTapped(item))) | ||||||
}).gridCellColumns(5) | ||||||
|
||||||
if let cell = timeBlock.getCellForRoom(room: room, onTap: { item in | ||||||
store.send(.view(.timetableItemTapped(item)))}) { | ||||||
cell | ||||||
} else { | ||||||
Color.clear | ||||||
.frame(maxWidth: .infinity) | ||||||
.padding(12) | ||||||
.frame(width: 192, height: 153) | ||||||
.background(Color.clear, in: RoundedRectangle(cornerRadius: 4)) | ||||||
} else { | ||||||
ForEach(rooms, id: \.self) { room in | ||||||
if let cell = timeBlock.getCellForRoom(room: room, onTap: { item in | ||||||
store.send(.view(.timetableItemTapped(item)))}) { | ||||||
cell | ||||||
} else { | ||||||
Color.clear | ||||||
.frame(maxWidth: .infinity) | ||||||
.padding(12) | ||||||
.frame(width: 192, height: 153) | ||||||
.background(Color.clear, in: RoundedRectangle(cornerRadius: 4)) | ||||||
} | ||||||
} | ||||||
} | ||||||
} | ||||||
|
@@ -198,7 +209,7 @@ fileprivate var bottomTabBarPadding: some View { | |||||
} | ||||||
|
||||||
extension RoomType { | ||||||
func toRoom() -> TimetableRoom { | ||||||
public func toRoom() -> TimetableRoom { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you add this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was using it elsewhere, but on closer inspection it was in the same file so public was not needed. |
||||||
switch self { | ||||||
case .roomI: | ||||||
return TimetableRoom( | ||||||
|
@@ -265,9 +276,9 @@ extension RoomType { | |||||
} | ||||||
|
||||||
extension TimetableTimeGroupItems { | ||||||
func getCellForRoom(room: RoomType, onTap: @escaping (TimetableItemWithFavorite) -> Void) -> TimetableGridCard? { | ||||||
func getCellForRoom(room: RoomType, cellCount: Int?=1, onTap: @escaping (TimetableItemWithFavorite) -> Void) -> TimetableGridCard? { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might be wrong, but I think the intended change is removing "?=1" not the Int part... correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry it's wrong😅
is correct👍 |
||||||
return if let cell = getItem(for: room) { | ||||||
TimetableGridCard(timetableItem: cell.timetableItem) { timetableItem in | ||||||
TimetableGridCard(timetableItem: cell.timetableItem, cellCount: cellCount ?? 1) { timetableItem in | ||||||
onTap(cell) | ||||||
} | ||||||
} else { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this argument is no needed an optional 🤔
and required property is no needed a default value 👍