Skip to content

Tiny convenient code pieces that I'm tired of copy-paste across all my projects.

License

Notifications You must be signed in to change notification settings

bigMOTOR/Helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Helpers

Helpers Logo

Tiny convenient code pieces that I'm tired of copy-paste across all my projects.

Swift Stdlib Extensions and Common things I need sometimes (Helpers):

Array;
subscript (safe index: Int) -> Element?
func subtract(_ other: [Element]) -> [Element]
func distance(to index: Index) -> Int 
Decimal;
var doubleValue: Double
Double;
func roundToDecimals(_ decimals: Int, rule: FloatingPointRoundingRule = .toNearestOrAwayFromZero) -> Double
Date;
  • work with unixMilliseconds;
  • date components;
  • beginning/end of date components;
  • adding date components;
  • comparison.
UserDefaults;
  • provides getter and setter for Codable values.
Something I need sometimes;
  • struct DateRange;
  • protocol AppDetails - provides app version and build number;
  • protocol AppStoreReview - provides dialog for Rate Us;
  • protocol DeviceDetails - provides device model, system version and device locale;
  • protocol ErrorLocalizedDescription;
  • Formatter - easy way to format numbers;
  • JsonObject - pretty typealias for [String: Any].

Combine (HelpersCombine)

  • Publisher:
func mapToVoid()
func mapToOptional()
func flatMapLatest()
func filterFalse() 
func filterTrue() 
func invert() 
func mapArray<T>(transform)
func shareReplay(bufferSize)    // Adapted from https://www.onswiftwings.com/posts/share-replay-operator/ 
  • Future:
convenience init(asyncFunc: @escaping () async throws -> Output)
convenience init(asyncFunc: @escaping () async -> Output)

In-App (HelpersIAP):

  • IAPProduct model;

RxSwift Extensions (HelpersRxSwift):

func mapToVoid()
func filterFalse()
func filterTrue()
func invert()
func asDelayedActivity(_ delay: DispatchTimeInterval = .milliseconds(200))
func mapArray<T>(transform)
func fromAsync(_ block: { element in ... }) -> Single<Element>

SwiftUI (HelpersSwiftUI):

ViewExtension:

/// Applies the given transform if the given condition evaluates to `true`
@ViewBuilder func `if`<Content: View>(_ condition: @autoclosure () -> Bool, transform: (Self) -> Content) -> some View

Modifiers:

func blink(on state: Binding<Bool>, duration: Double = 0.1)
func navigationBarColors(background: Color, tint: Color)
func onFrameChange(enabled isEnabled: Bool = true, frameHandler: @escaping (CGRect)->Void)
func cornerRadius(_ radius: CGFloat, corners: UIRectCorner)
func onRotate(perform action: @escaping (UIDeviceOrientation) -> Void)
func rotateHandling(anchor: UnitPoint = .center)
func rotated(_ angle: Angle)
func shimmer(isActive: Bool = true, speed: Double = 0.15, angle: Angle = .init(degrees: 70), opacity: Double = 1.0)

Shapes:

func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) 
Views
  • MailView.

Installation

Helpers available via:

License

Helpers is available under the MIT license. See the LICENSE file for more info.

About

Tiny convenient code pieces that I'm tired of copy-paste across all my projects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages