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

Add cross-platform UI based on Avalonia #336

Merged
merged 17 commits into from
May 25, 2021
Merged

Conversation

mjcheetham
Copy link
Collaborator

@mjcheetham mjcheetham commented May 5, 2021

Introduce a new set of UI helpers based on the Avalonia UI framework for GitHub and Bitbucket!

At the moment the WPF/Windows-only UI helpers continue to exist and be used on Windows. The new helpers are only used on macOS and Linux.

The design has changed slightly in most cases. The GitHub main prompt has been updated the most and hides other auth modes behind a tabbed control (rather than showing them all on one screen as we do on Windows).

(Note to reviewers: this is a large PR.. it's best to review commit by commit!)

GitHub

Windows
(WPF-based)
macOS Linux
image image image
image image image

Bitbucket

Windows
(WPF-based)
macOS Linux
image image image
image image image

macOS "About" Dialog

image

Fixes: #136

@mjcheetham mjcheetham changed the title [WIP] Add cross-platform UI based on Avalonia Add cross-platform UI based on Avalonia May 5, 2021
@mjcheetham mjcheetham marked this pull request as ready for review May 5, 2021 14:52
@vtbassmatt
Copy link
Contributor

Nice! I'm 👍 from a product perspective, no code review provided though 🤣

@mjcheetham mjcheetham added enhancement New feature or request host:bitbucket Specific to the Bitbucket host provider host:github Specific to the GitHub host provider platform:linux Specific to a Linux-based platform platform:osx Specific to the macOS platform labels May 12, 2021
Copy link
Contributor

@ldennington ldennington left a comment

Choose a reason for hiding this comment

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

On the whole, this was a lovely PR to review - the code was super clean and fun to follow.

However, I do have one recommendation. This was a bit of a long review, especially for someone like me who doesn't do a ton of UI work. Something I try to do when I'm working on big changes like this is submit them gradually in smaller, more digestible PRs. I know it's a bit of a pain to do, but from my experience it makes people more willing to look at my code and allows them to examine it more thoroughly and catch things they may have glossed over otherwise.

Other than that, awesome work! I think the new UIs are quite beautiful.

@mjcheetham
Copy link
Collaborator Author

However, I do have one recommendation. This was a bit of a long review, especially for someone like me who doesn't do a ton of UI work. Something I try to do when I'm working on big changes like this is submit them gradually in smaller, more digestible PRs. I know it's a bit of a pain to do, but from my experience it makes people more willing to look at my code and allows them to examine it more thoroughly and catch things they may have glossed over otherwise.

Ahh sorry! I should perhaps have called out in the main PR comment that the best way to review here is commit-by-commit.
I always try to ensure that each commit stands on its own, compiles, and all tests pass.

image

@ldennington
Copy link
Contributor

However, I do have one recommendation. This was a bit of a long review, especially for someone like me who doesn't do a ton of UI work. Something I try to do when I'm working on big changes like this is submit them gradually in smaller, more digestible PRs. I know it's a bit of a pain to do, but from my experience it makes people more willing to look at my code and allows them to examine it more thoroughly and catch things they may have glossed over otherwise.

Ahh sorry! I should perhaps have called out in the main PR comment that the best way to review here is commit-by-commit.
I always try to ensure that each commit stands on its own, compiles, and all tests pass.

image

Thanks, that's good to know! Will do that moving forward.

mjcheetham added 12 commits May 18, 2021 14:43
Push the `GetApplicationPath` method down to the ApplicationBase type so
its logic can be shared across other applications.
Extract the `OpenDefaultBrowser` method to a helper/util class so it can
be used by other components.
Allow UI helper processes to be terminated by cancelling a
CancelationToken that has been passes to `InvokeHelperAsync`.
Add a new project to host all the shared components for Avalonia-based
UI helpers.
Add a styled dialog window control for use by UI helper applications
built on Avalonia.
Add a new application class for helper applications to surface commands
and respond over standard output.
Add a dispatcher type for use with Avalonia. This dispatcher is
different from the built-in Avalonia `Dispatcher` type.

On macOS the underlying platform requires that the main NSRunLoop be
run on the **entry** thread of the process (that is, thread 0).
This is unlike on Windows where all that is required is an "STA" thread.

Because of this we need to "reserve" thread 0 (the main entry thread)
for running the Avalonia infrastructure, and kick off a new thread to
run the rest of the "normal" .NET application logic (such as
command-line handling).

The dispatcher allows queuing of work to be run on the initialised
thread, until the loop is terminated. We can use this dispatcher and
model to start the Avalonia app/runloops at a defered time, after main
app startup.

The Avalonia `Dispatcher` type is then used to push more work on to that
inner message pump/runloop after the Avalonia application has started.
Add a component that uses our Dispatcher, and the Avalonia Dispatcher
types to correctly initialise, show, and close windows and views in the
Avalonia UI framework, ad-hoc.
Add a new Avalonia UI project for a GitHub UI helper.
Add the main "credentials" prompt for the Avalonia-based GitHub helper
UI.
Add new Avalonia-based "two-factor" auth code prompt dialog for GitHub.
Pass the `--sms` option to the UI helper when prompting for a 2FA code
sent via SMS for GitHub.
Copy link
Contributor

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

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

This is quite a big project!

I can't speak to most of the Avalonia/UX boilerplate, but I tried to find some interesting tidbits to comment on.

Overall, I find the commits to be well organized and comments are placed to help our future selves recall what the reasons were for the complicated choices. In particular, the "thread 0" dance you need to do was very interesting.

@mjcheetham mjcheetham merged commit 1d5a694 into git-ecosystem:main May 25, 2021
@mjcheetham mjcheetham deleted the xui2 branch May 25, 2021 14:44
@BenAigan
Copy link

BenAigan commented Jun 9, 2021

Not all of the Avalonia UI parts have licenses attached so I cannot use this version.

@derrickstolee
Copy link
Contributor

Not all of the Avalonia UI parts have licenses attached so I cannot use this version.

Can you elaborate, @BenAigan?

All of the code in this repository is covered by the MIT License, even though we do not add license headers on every file.

@BenAigan
Copy link

BenAigan commented Jun 9, 2021

The package that is holding up my onboarding is https://www.nuget.org/packages/Avalonia.Angle.Windows.Natives/2.1.0.2020091801/ where you can see no license is mentioned, unfortunately the license needs to be specified for us to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request host:bitbucket Specific to the Bitbucket host provider host:github Specific to the GitHub host provider platform:linux Specific to a Linux-based platform platform:osx Specific to the macOS platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port WPF-based helper GUIs to Avalonia for Mac/Linux
7 participants