You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi guys, I wanted to add ViewModifier for Image and storyRowType function do reduce duplication in code, but found out that your repository is required access.
So basically my idea was next:
import SwiftUI
struct ImageModifier: ViewModifier {
let customFont: Font
let color: Color
func body(content: Content) -> some View {
content
.font(customFont)
.foregroundColor(color)
}
}
extension Image {
func imageStyle(font: Font = .system(size: 12), color: Color = .primary) -> some View {
self.modifier(ImageModifier(customFont: font, color: color))
}
}
private enum StoryRowSize {
case small, medium, basic
}
private func storyRowType(_ prefixAmount: Int, size: StoryRowSize) -> some View {
ForEach(entry.stories.prefix(prefixAmount), id: \.id) { story in
switch size {
case .small: smallStoryRow(story)
case .medium: mediumStoryRow(story)
case .basic: storyRow(story)
}
if story.id != entry.stories.prefix(prefixAmount).last?.id {
Divider()
}
}
}
It can help you to eliminate duplication:
switch family {
case .systemSmall:
storyRowType(2, size: .small)
case .systemMedium:
storyRowType(2, size: .medium)
case .systemLarge, .systemExtraLarge:
storyRowType(5, size: .basic)
case .accessoryCircular, .accessoryRectangular, .accessoryInline:
fatalError("Unsupported family \(family)")
@unknown default:
fatalError("Unsupported family \(family)")
}
The text was updated successfully, but these errors were encountered:
Thanks for the suggestions! Some parts of the UI is still changing as we try to get this on the app store, so we will likely hold off on factoring out shared code for now until the dust settles, but these are good ideas.
Hi guys, I wanted to add ViewModifier for Image and storyRowType function do reduce duplication in code, but found out that your repository is required access.
So you can use:
instead of
It can help you to eliminate duplication:
The text was updated successfully, but these errors were encountered: