Skip to content

Instantly share code, notes, and snippets.

View victor-gesit's full-sized avatar

Victor Idongesit victor-gesit

View GitHub Profile
@victor-gesit
victor-gesit / index.js
Created August 19, 2023 18:24
InCyan Assessment
const plotter = (payload) => {
const { title, xtitle, ytitle, items } = payload
const titleWidth = title.length
const ytitleWidth = ytitle.length
let tableHeight = 0
let maxColumnWidth = 0
let restructruedItems = []
# I relied on ChatGPT for this. However, I understand what each line does and can debug it as needed.
FROM ubuntu:focal
# Install build tools
RUN apt-get update && apt-get install -y \
g++-10 \
cmake \
ninja-build
30: move the string literal out to a util and pass it in as a variable. Also, remove the force unwrap.
35: make `self` weak to avoid a retain cycle.
50: isLoading is a boolean. No need for comparison with `!false`. `if isLoading` should do.
61: Declare showDetailView as a @State variable and pass $showDetailView into isActive.
67: You may want to move all string literals out to somewhere central, to ease localization in the future
90: after fetching the albums, I see no where `isLoading` is toggled back, to hide the `ProgressView`. Pass the responsibility of managing the loading state (`isLoading`) to the view model, and make it a @Published variable. That way you can easily toggle it when the API call is completed.
107: Did you mean to map the response from the API call? URL does not have a map function, or does it? Did you mean to declare `coverArtUrl` as an array? There will be an error there.
126: You're not checking to see if if UIImage(data:) resolves to nil. That force unwrap may cause a crash.
// Protocols
protocol Toggleable {
var selected: Bool { get }
}
protocol Toggler: AnyObject {
var selectedProperty: ToggledProperty? { get set}
func toggleTo(toggleProperty: ToggledProperty?)
}