Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable showDoneButtonOnModals icon #49

Closed
djfpaagman opened this issue Nov 25, 2024 · 2 comments
Closed

Configurable showDoneButtonOnModals icon #49

djfpaagman opened this issue Nov 25, 2024 · 2 comments

Comments

@djfpaagman
Copy link

djfpaagman commented Nov 25, 2024

Right now when you enable showDoneButtonOnModals you get a "Done" (UIBarButtonItem.SystemItem.done) button on your modal. This could be confusing when having a form inside the modal, the user might assume the data also gets saved when they click "done".

I would prefer those modals to show "Close" (UIBarButtonItem.SystemItem.close) as I think that's more distinct and signalling that nothing is being saved.

Right now you can't configure what type of button is placed. I would also be happy with the default becoming close.

I can try to implement something but could use some direction on how to do so in Swift 😅

@djfpaagman
Copy link
Author

djfpaagman commented Nov 25, 2024

I played around with it a bit and .close gives an icon:

CleanShot 2024-11-25 at 11 53 17@2x

So I think I prefer .cancel:

CleanShot 2024-11-25 at 11 53 40@2x

I've implemented it for now like so:

import HotwireNative
import UIKit

class CustomHotwireWebViewController: HotwireWebViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        addDoneButtonToModals()
    }
    private func addDoneButtonToModals() {
        if presentingViewController != nil {
            let action = UIAction { [unowned self] _ in
                dismiss(animated: true)
            }

            navigationItem.leftBarButtonItem = UIBarButtonItem(systemItem: .cancel, primaryAction: action)
        }
    }
}

and use CustomHotwireWebViewController instead of HotwireWebViewController in my SceneController! Make sure to disable Hotwire.config.showDoneButtonOnModals if you do this.

Maybe being able to customize it via a setting might still be nice :)

@joemasilotti
Copy link
Member

Your approach, subclassing HotwireWebViewController, looks good to me. I don't see us exposing anything outside of the "Done" button via a configuration, there are just way too many options.

@joemasilotti joemasilotti closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants