Commit Graph

29 Commits

Author SHA1 Message Date
Davide De Rosa 5627e6c4a9
Address UI race conditions (#229)
* Make some managers concurrency-safe

- IntentsManager: @MainActor, non-shared, continuation

- SSIDReader: @MainActor, continuation

- Reviewer: main queue, non-shared

* Review wrong use of Concurrency framework

There were background thread calls e.g. in VPNToggle, because
ProfileManager was used inside a VPNManager async call.

Annotate @MainActor wherever a Task involves UI.

* Make main managers MainActor

* Apply MainActor to Mac menus

* [ci skip] Update CHANGELOG

* Set MainActor consistently on Mac menu view models
2022-10-13 08:53:50 +02:00
Davide De Rosa 025421aa08 Refactor some alert translations 2022-09-25 08:35:52 +02:00
Davide De Rosa 4c4b3ee0c9 Revert to concrete-only managers
Abstraction was overcomplicated. Strategy pattern is enough.
2022-09-03 12:47:40 +02:00
Davide De Rosa f36d7596d0 Integrate settings with about screen
Move everything to SettingsView and remove invite actions.
2022-08-27 23:15:51 +02:00
Davide De Rosa 9a8477225e Refactor library into domain + impl 2022-06-23 23:31:01 +02:00
Davide De Rosa 14b42fbea5 Persist managers state to generic key-value store
Move all persisted state out of AppManager to where it really
belongs. To do that, inject a shared KeyValueStore object into
managers that need to persist part of their state in a strongly
typed manner.

Below are persisted states:

- PersistenceManager
    - persistenceAuthor

- ProfileManager
    - activeProfileId

- UpgradeManager (formerly AppManager)
    - didMigrateToV2 (migrate former value)

- VPNManager
    - tunnelLogFormat
    - masksPrivateData

A similar approach is used for app-specific preferences, by using
a strongly typed enum (AppPreference) together with SwiftUI
@AppStorage property wrapper.

Worth moving logging logic into a specific LogManager.

Finally, drop any former view dependency on AppManager, as states
are now accessed through specific managers.
2022-06-16 13:42:37 +02:00
Davide De Rosa f0c5ecd84f Handle configuration errors out of VPN status
On configuration error, retain information about the profile that
triggered the error. For now, present an alert, but with this
information the UI can be easily changed later.
2022-05-21 19:01:49 +02:00
Davide De Rosa 46a8fb8a74 Delay presentation of imported file modal
Fixes navigation bug on iOS 14 preventing modal from dismissing
via close button.
2022-05-20 16:35:45 +02:00
Davide De Rosa 16d618df0e Show info menu in ProfileView on iPad/Mac
Use .navigationBarTrailing to avoid artifact on Catalyst (item
relocates when first clicked).

Rename menu files too.
2022-05-16 11:18:58 +02:00
Davide De Rosa 6fddbb8bfc Decouple menus from OrganizerView
Could move .sheet() from parent View to Menu, but no luck with
.fileImporter()
2022-05-16 11:18:58 +02:00
Davide De Rosa 743facca6b Improve Catalyst appearance
- Revert to more "stable" iPad idiom

- Set accent color the proper way

- Use .tint when available

- Unify navigation style by idiom

- Retain navigation bars in sidebar/detail

- Lighten sidebar appearance

- Fix Menu style (dropdown -> button)

- Use native Picker (dropdown)

- Use switch toggles rather than checkboxes

- Replace .actionSheet with .alert

- Increase minimum row height

CAVEAT: on Mac with iPad idiom, having a Section in .sidebar
produces artifacts. Header keeps changing height for no reason.
Retain Section on iPad multitasking only to not break navigation.
2022-05-15 22:24:36 +02:00
Davide De Rosa cca2dca047 Export providers database in beta 2022-05-05 09:46:12 +02:00
Davide De Rosa 3c0e511e84 Split again OrganizerView and ProfilesList
On iOS 14, Organizer scrolls abruptly on profile selection. It
looks like this was introduced by merging ProfilesList into
OrganizerView.

Try to revert merge to split observation responsibilities.

Drop unused AppManager in +Scene along the way.
2022-05-03 14:40:41 +02:00
Davide De Rosa 93abaf538b Simplify redundant parts of ProfileManager
- Drop overthought activeHeader

- Drop willUpdateCurrentProfile, use observable

- Drop willUpdateActiveId, observe value publisher
2022-05-03 14:36:55 +02:00
Davide De Rosa 576eb1512a Fix slow active profile selection on launch
Regression due to missing .stack navigation style basically.

Restore .onAppear() on NavigationLink.
2022-05-02 09:53:18 +02:00
Davide De Rosa 472b5e4b41 Fix active profile flickering on first launch
Move .onAppear() handler to main view.
2022-05-01 20:16:05 +02:00
Davide De Rosa 171c1e1dd4 Omit wrapping Section on Mac 2022-05-01 19:30:56 +02:00
Davide De Rosa cfc0d4f572 Restore active profile on top
Flashing on activation was caused by VPNManager.disable() in
ProfileView+VPN, because by setting lastError to nil it would
notify a change to ProfileRow (via VPNStateView) during the
profile row activation animation. That caused the flicker.

Instead, disable VPN first, then start the animation.

Anyway, avoid clearing a nil lastError.
2022-05-01 19:19:43 +02:00
Davide De Rosa edc7cdf045 Merge List into OrganizerView
- Restore wrapping Section as it seems to fix multitasking

- Hide profiles section if empty
2022-05-01 19:19:31 +02:00
Davide De Rosa 4a0245d757 Rename AddHostView to .NameView
In preparation of future additions to flow.
2022-04-26 22:44:34 +02:00
Davide De Rosa c507c739bd Move WelcomeView to its own view 2022-04-23 10:25:31 +02:00
Davide De Rosa 8838e9d130 Strip a few unnecessary publishers
- Drop unused AppManager from OrganizerView

- Do not notify ProfileManager subscribers on activeProfileId

Saved active profile is already notified by:

- Core Data
- AppManager
2022-04-23 10:25:31 +02:00
Davide De Rosa d8e47cb7c0 Refactor strings and add new ones
- Move Localizable.strings above to share *.lproj folders

- Reorg menus into contextual/system

- Shorten titles of contextual menus

- Update sharing message with WireGuard

- Drop AlternativeTo

7 phrases left to translate into 9 languages.
2022-04-22 13:12:42 +02:00
Davide De Rosa 867b415b6b Fix double add menu in Organizer
Seems to happen when launching with active profile.

Use explicit position.
2022-04-22 09:52:10 +02:00
Davide De Rosa 992178bcd6 Move toolbar content inline
For consistency, can search with "toolbar {".
2022-04-21 16:24:08 +02:00
Davide De Rosa dbc007b184 Restore .navigation for SettingsMenu 2022-04-19 23:20:04 +02:00
Davide De Rosa 5b2ccaa110 Reposition Organizer toolbar 2022-04-19 23:02:19 +02:00
Davide De Rosa 7128352a9c Fix settings menu not shown on iOS 14
Change to .navigation placement.
2022-04-19 21:19:43 +02:00
Davide De Rosa bf65f76401 Merge project into iOS + macOS
Share views with both platforms initially. Will split specific
views step by step.
2022-04-19 16:14:23 +02:00