Skip to content

Instantly share code, notes, and snippets.

View mattrighetti's full-sized avatar
👨‍💻
:(){ :|:& };:

Mattia Righetti mattrighetti

👨‍💻
:(){ :|:& };:
View GitHub Profile
@mattrighetti
mattrighetti / light_dark_mode_render.swift
Created April 22, 2020 10:47
Code that will render ContentView both in Light and Dark mode in Xcode
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
Group {
ContentView().environment(\.colorScheme, .light)
ContentView().environment(\.colorScheme, .dark)
}
}
}
@mattrighetti
mattrighetti / CategoryPill.swift
Created April 22, 2020 10:11
Pill like component for RowCard View
struct CategoryPill: View {
var categoryName: String
var fontSize: CGFloat = 12.0
var body: some View {
ZStack {
Text(categoryName)
.font(.system(size: fontSize, weight: .regular))
.lineLimit(2)
@mattrighetti
mattrighetti / RowCard.swift
Created April 22, 2020 09:55
Flat Card Design for SwiftUI List
struct StoreRow: View {
var title: String
var address: String
var city: String
var categories: [String]
var kilometres: Double
var body: some View {
ZStack(alignment: .leading) {
@mattrighetti
mattrighetti / +uicolour.swift
Last active April 22, 2020 08:24
UIColor extension
extension UIColor {
static let flatDarkBackground = UIColor(red: 36, green: 36, blue: 36)
static let flatDarkCardBackground = UIColor(red: 46, green: 46, blue: 46)
convenience init(red: Int, green: Int, blue: Int, a: CGFloat = 1.0) {
self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: a)
}
}