Skip to content

Instantly share code, notes, and snippets.

View Nirajpaul2's full-sized avatar
👨‍💻
Flutter

Niraj Paul Nirajpaul2

👨‍💻
Flutter
View GitHub Profile
@Nirajpaul2
Nirajpaul2 / CustomObjectUserDefaultWrapper.swift
Last active April 15, 2022 04:57
CustomObjectUserDefaultWrapper
import Foundation
import Combine
@propertyWrapper
struct CustomObjectUserDefaultWrapper<Value: Codable> {
let key: String
let defaultValue: Value
var container: UserDefaults = .standard
private let publisher = PassthroughSubject<Value, Never>()
@Nirajpaul2
Nirajpaul2 / CapitalizedWrapper.swift
Last active April 15, 2022 04:57
CapitalizedWrapper
@propertyWrapper
struct Capitalized {
var wrappedValue: String {
didSet { wrappedValue = wrappedValue.capitalized }
}
init(wrappedValue: String) {
self.wrappedValue = wrappedValue.capitalized
}
}
@Nirajpaul2
Nirajpaul2 / UserDefaultWrapper.swift
Last active April 15, 2022 04:56
UserDefaultWrapper
import Foundation
import Combine
@propertyWrapper
struct UserDefaultWrapper<Value: Codable> {
let key: String
let defaultValue: Value
var container: UserDefaults = .standard
private let publisher = PassthroughSubject<Value, Never>()
@Nirajpaul2
Nirajpaul2 / AtomicWrapper.swift
Last active April 15, 2022 04:56
AtomicWrapper
struct Atomic<Value> {
private let queue = DispatchQueue(label: "com.vadimbulavin.atomic")
private var value: Value
init(wrappedValue: Value) {
self.value = wrappedValue
}
var wrappedValue: Value {
@Nirajpaul2
Nirajpaul2 / LazyGridView.swift
Last active August 14, 2022 07:09
LazyGridViewThreeColumn
ScrollView {
      LazyVGrid(columns: threeColumnGrid) {
          // Display the item
      }
 }
@Nirajpaul2
Nirajpaul2 / LazyGridView.swift
Created August 14, 2022 07:12
LazyGridViewHorizontal
ScrollView(.horizontal) {
       LazyHGrid(rows: threeColumnGrid) {
           // Display the item
       }
  }