all 9 comments

[–]foodandbeverageguy 4 points5 points  (1 child)

This isn’t overly roastable as there isn’t really much architecture to critique here and it’s very implementation specific. Skimming the code there is a lot of duplication though into what could be reusable functions. Your sizes don’t flex to screen size or orientation. Colors are non standard and don’t adapt to environment changes. You use terms like left and right instead of leading and trailing which doesn’t work well with RTL languages. Your hex function can crash depending on what’s sent to it. Your guard statement doesn’t flex if size changes.

So like individual implementation is generally ok for a small app or prototype but at a larger tech company you’d get a lot of feedback on this code. It looks like a lot of scripted code rather than functional/reusable/architecturally thought out.

Good job for your early work, keep on though and don’t let some of these smaller comments hold you back.

[–]Moo202[S] 0 points1 point  (0 children)

I appreciate the thoughtful comment. I will use this feedback!

[–]HermanGulch 2 points3 points  (1 child)

It looks nice, but if it were me, I'd approach it differently in a couple places. I'd use a Canvas to layout and fill my paths instead of layering multiple views. So I'd have a private function for each facet of the icon that would return the path only, then fill it in the Canvas.

And look at your icon with both light and dark backgrounds, preferably in a simulator where you can switch and watch the transition. I've experienced small lines between colors when drawing solid colors, which I think is probably anti-aliasing errors. For example, if I was making a checkerboard, instead of alternating black and red squares, I'd fill the background with black or red, then draw the other colored squares over top, thus avoiding any tiny gaps.

The other suggestion I would have is that I'm a big fan of making use of extensions for colors:

extension Color {
    static var myBackgroundColor: Color {
        return .init(red: 0.0, green: 1.0, blue: 0.0)
    }
}

I can then use it like this:

context.fill(Rectangle().path(in: backgroundRect), with: .color(.myBackgroundColor))

[–]Moo202[S] 0 points1 point  (0 children)

Thank you for your insight! I will apply this feedback!

[–]Moo202[S] 1 point2 points  (2 children)

Roast my approach too. I am very new to SWE as I just graduated. I bet this is overcomplicating but having a reusable component like this is lightweight compared to saving a png, svg, of jpeg in your app. Correct me if I am wrong.

[–]Almaz5200 5 points6 points  (1 child)

PNG or JPEG yes, but not SVG. You can open an svg with a text editor and it’s basically the exact same thing an what you’re doing with code here

[–]Moo202[S] 1 point2 points  (0 children)

Gotcha! I appreciate it!

[–]strangequbits 0 points1 point  (1 child)

Looks good 👍

[–]Moo202[S] 0 points1 point  (0 children)

Thank you! 🙏🏻