checkout / frames-ios

Frames iOS: making native card payments simple

Home Page:https://www.checkout.com/docs/integrate/sdks/ios-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Review possibility to use simpler APIs

melting-snowman opened this issue · comments

Is your feature request related to a problem? Please describe.
Remove the need for Bundle to be provided when using Swift Packages

Describe the solution you'd like
Use @available to provide an implementation that doesn't require a class to be provided and remove syntax sugar.

Example
Have something similar to

    @available(_PackageDescription, introduced: 1)
    func localized(comment: String = "") -> String {
        ""
    }

Use this method for any package based use, removing sugar code and having simpler syntax at call site.

"key".localized(forClass: CheckoutTheme.self)
// Should become
"key".localized()

 

 

Did not scope enough the feasibility, but may look at injecting the Bundle on the remaining classes, instead of injecting a class type. Then we can have the bundle referenced as a single instance across the module and make code easier to navigate

"key".localized(forClass: SomeClassFromModule.self)

// Should become

// declared internal at module level. This way there is only 1 source of truth for the bundle
let MODULE_BUNDLE = Bundle(for: SomeClassFromModule.self) 

// Use site
"key".localized(bundle: MODULE_BUNDLE)

Noted. Thanks