tiki-deprecated / publish-sdk-ios

TIKI SDK (iOS) - Consumer Data Licensing
https://mytiki.com/docs/sdk-overview
MIT License
3 stars 2 forks source link

Make TikiSdk.present() method agnostic about environment #185

Closed ricardobrg closed 1 year ago

ricardobrg commented 1 year ago

The TikiSdk.present() method currently assumes that it will be called within a specific environment, and this can cause issues when integrating with different applications, using SwiftUI or UIKit.

It would be ideal if the method were agnostic about its environment and could adapt to whatever environment it is called in.

To achieve this, the TikiSdk.present() needs to be modified method to grab the topmost visible view and overlay the whole screen with either a BottomSheetView for bottom sheets or a NavigatorRouteView for screens. This can be done using the UIApplication.shared.keyWindow property to add the overlay.

Here is some sample code that demonstrates how this could be achieved:

if let window = UIApplication.shared.keyWindow {
    let overlay = OfferFlow()
    overlay.tag = 1001
    // add the overlay
    window.addSubview(overlay)
    // remove itself when completed (this could be passed to the View as a callback)
    window.viewWithTag(overlay.tag)?.removeFromSuperview()
}

Implement this modification and test it to ensure that it works in UIKit and SwiftUI

ricardobrg commented 1 year ago

https://user-images.githubusercontent.com/8357343/225941315-7ea97598-d7a1-451e-bf9f-46c832df73bc.mp4 https://user-images.githubusercontent.com/8357343/225941314-f5d2a714-3580-4871-a4b9-2ec1507762b0.mp4