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

[macOS] Add platform view documentation #10796

Merged
merged 9 commits into from
Jul 6, 2024

Conversation

cbracken
Copy link
Member

@cbracken cbracken commented Jun 25, 2024

This adds documentation on authoring and using platform views for Flutter apps targeting macOS.

The initial version of this documentation is Swift-only, but a follow-up will add Objective-C example code.

Fixes: #9424

Presubmit checklist

  • This PR is marked as draft with an explanation if not meant to land until a future stable release.
  • This PR doesn’t contain automatically generated corrections (Grammarly or similar).
  • This PR follows the Google Developer Documentation Style Guidelines — for example, it doesn’t use i.e. or e.g., and it avoids I and we (first person).
  • This PR uses semantic line breaks of 80 characters or fewer.

// ignore_for_file: unused_local_variable

// #docregion import
import 'package:flutter/foundation.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this part of a project? We use flutter projects to confirm the code is up to date as flutter changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find any related projects for this, but can confirm the code passes analysis and compiles, similar to the iOS code in native_view_example_3.dart. I couldn't find any project on GitHub that included this code though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should wrap it in a project here. @khanhnwin can give progress on how to do this in a way that makes sure this code will stay correct going forward.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khanhnwin currently the Dart code is checked into the examples directory similar to the iOS/Android versions, but the Swift code is not (also similar to the iOS/Android versions). Where's the best place to land that code?

@domesticmouse do you think we should hold off landing this until that happens, or follow up with separate PRs that lands macOS, iOS, and Android versions of the native code as well?

Agreed we should do this though -- writing the Swift code for this involved basically recreating the exact project you're asking for, just to be sure the code is actually correct.

@flutter-website-bot
Copy link
Collaborator

flutter-website-bot commented Jun 25, 2024

Visit the preview URL for this PR (updated for commit bd8c6aa):

https://flutter-docs-prod--pr10796-macos-platformview-docs-hj2iqzhf.web.app

@atsansone
Copy link
Contributor

Does this fix #9424?

@cbracken
Copy link
Member Author

@atsansone yes, this will fix that bug; added to the description -- thanks!

@stuartmorgan
Copy link
Contributor

The initial version of this documentation is Swift-only, but a follow-up will add Objective-C example code.

Technically we've never supported Obj-C as a language for macOS. In practice it works because of interop of course, but we haven't traditionally done documentation or examples in anything but Swift.

This adds documentation on authoring and using platform views for
Flutter apps targeting macOS.

The initial version of this documentation is Swift-only, but a follow-up
will add Objective-C example code.

Fixes: flutter#9424
@cbracken
Copy link
Member Author

Technically we've never supported Obj-C as a language for macOS.

Thanks. Was thinking it might be handy just in case people had some existing Obj-C NSViews they'd like to wrap but you're entirely right: we don't even have an Obj-C template for macOS, and people in that boat can just expose their own Swift-friendly header to the plugin. Not only that, but publishing Obj-C source implies that we're willing to commit to supporting that use-case and we aren't in a position to do so.

Removed the tabs and sending this out as Swift-only.

@cbracken cbracken marked this pull request as ready for review June 27, 2024 06:22
@cbracken
Copy link
Member Author

Alright; this is ready for a proper review.

Copy link
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Thanks so much for this, @cbracken!

@parlough
Copy link
Member

Does this need any version note or similar clarification?

@sfshaza2 sfshaza2 self-assigned this Jul 1, 2024
@sfshaza2
Copy link
Contributor

sfshaza2 commented Jul 1, 2024

@cbracken, are these docs valid for the current stable release? If not, I can add a note at the top stating that fact.

@sfshaza2
Copy link
Contributor

sfshaza2 commented Jul 2, 2024

@loic-sharma, do you know if this info is valid as of now, or if it's valid after the next release? Before I land it, I want to be clear. If it's for the next release, I can still land it, but will first add a note.

@stuartmorgan
Copy link
Contributor

@sfshaza2 In general we don't want to tell people to use macOS platform views until after the next stable release (due to critical missing functionality like gesture support).

Copy link
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a version note. Thanks for that info, @stuartmorgan!

@sfshaza2 sfshaza2 merged commit ebeff7a into flutter:main Jul 6, 2024
9 checks passed
@cbracken cbracken deleted the macos-platformview-docs branch July 8, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explain how to create macOS PlatformViews
8 participants