Skip to content

Instantly share code, notes, and snippets.

View mdb1's full-sized avatar
🎯
Focusing

Manu mdb1

🎯
Focusing
View GitHub Profile
@mdb1
mdb1 / View+Scrollable.swift
Created January 3, 2023 22:23
Scrollable View Modifier
extension View {
/// View modifier that embeds the content inside a scroll view.
func scrollable(axis: Axis.Set = .vertical) -> some View {
modifier(
ScrollViewModifier(axis: axis)
)
}
}
/// A modifier that embeds the content inside a scroll view.
@mdb1
mdb1 / View+RoundedOverlayBorder.swift
Last active January 3, 2023 22:45
RoundedOverlayBorder modifier
/// Extension to apply a RoundedOverlayBorder modifier.
extension View {
/// Adds a rounded overlay border to the view.
func roundedOverlayBorder(
cornerRadius: CGFloat,
color: Color = .gray,
lineWidth: CGFloat = 1
) -> some View {
modifier(
RoundedOverlayBorderModifier(
@mdb1
mdb1 / contributing.md
Last active February 16, 2023 20:51
Contributing template

Contributing

This is a living document representing some guidelines that will help our team do great work, and keep consistency in the codebase and the systems over time.

Code Quality Principles

  • Naming → Explicitness, brevity, and consistency.
  • Commenting → Exist to help future readers (including yourself).
  • Testing:
  • Code isn’t high quality without tests.
@mdb1
mdb1 / .swiftformat
Created January 1, 2023 18:11
SwiftFormat options and Rules
# format options
--allman false
--indent 4
--maxwidth 120
--commas inline
--decimalgrouping 3
--wraparguments before-first
# rules
--enable isEmpty
@mdb1
mdb1 / LocalizedExample.swift
Created December 27, 2022 12:59
Using localized strings in a SwiftUI View
import SwiftUI
struct ContentView: View {
let name: String
var body: some View {
VStack {
Text(ViewConstants.title.localized(with: [name]))
Text(ViewConstants.description)
}
@mdb1
mdb1 / String+Localized.swift
Last active April 29, 2025 15:24
String Localizable extension
import Foundation
extension String {
/// Returns the localized value for the given key (`self`).
/// This property will look in the `Localizable.strings` file based on the current system language.
///
/// Usage
/// ===================================
/// ```swift
/// "key".localized
@mdb1
mdb1 / CGFloat+Spacing.swift
Created December 24, 2022 18:45
CGFloat Spacing Constants
import Foundation
extension CGFloat {
/// Spacing constants to use across the app.
enum Spacing {
/// Extra small spacing. (4 points).
static let xSmall: CGFloat = 4.0
/// Small spacing. (8 points).
static let small: CGFloat = 8.0
/// Medium spacing. (16 points).
@mdb1
mdb1 / SemanticColor.swift
Last active December 24, 2022 18:47
Using semantic colors
Text("Your text")
.padding()
.foregroundColor(.Text.primary)
.background(Color.Background.primary)
@mdb1
mdb1 / Color+Extension.swift
Last active December 26, 2022 14:16
Color Extension SwiftUI
import SwiftUI
/// Namespaces.
extension Color {
/// Colors for Texts.
enum Text {}
/// Colors for Backgrounds
enum Background {}
/// Colors for Borders.
enum Border {}
@mdb1
mdb1 / reading-q4-2022.md
Last active October 29, 2022 18:20
Industry-Related reading - Q4 2022